首页 > IT职业 > IT职场 > php生成动态验证码代码分享
0) { // 屏蔽第一帧
$top = 0;
for ($k = 0; $k GetAnimation();
}
/**
* *GIFEncoder类
* *
*/
class GIFEncoder {
var $GIF = "GIF89a"; /* GIF header 6 bytes */
var $VER = "GIFEncoder V2.06"; /* Encoder version */
var $BUF = Array();
var $LOP = 0;
var $DIS = 2;
var $COL = - 1;
var $IMG = - 1;
var $ERR = Array(
'ERR00' => "Does not supported function for only one image!",
'ERR01' => "Source is not a GIF image!",
'ERR02' => "Unintelligible flag ",
'ERR03' => "Could not make animation from animated GIF source"
);
function GIFEncoder($GIF_src, $GIF_dly = 100, $GIF_lop = 0, $GIF_dis = 0, $GIF_red = 0, $GIF_grn = 0, $GIF_blu = 0, $GIF_mod = 'bin') {
if (! is_array($GIF_src) && ! is_array($GIF_tim)) {
printf("%s: %s", $this->VER, $this->ERR['ERR00']);
exit(0);
}
$this->LOP = ($GIF_lop > - 1) ? $GIF_lop : 0;
$this->DIS = ($GIF_dis > - 1) ? (($GIF_dis COL = ($GIF_red > - 1 && $GIF_grn > - 1 && $GIF_blu > - 1) ? ($GIF_red | ($GIF_grn BUF[] = fread(fopen($GIF_src[$i], "rb"), filesize($GIF_src[$i]));
} elseif (strToLower($GIF_mod) == "bin") {
$this->BUF[] = $GIF_src[$i];
} else {
printf("%s: %s(%s)!", $this->VER, $this->ERR['ERR02'], $GIF_mod);
exit(0);
}
if (substr($this->BUF[$i], 0, 6) != "GIF87a" && substr($this->BUF[$i], 0, 6) != "GIF89a") {
printf("%s: %d %s", $this->VER, $i, $this->ERR['ERR01']);
exit(0);
}
for ($j = (13 + 3 * (2 BUF[$i]{10}) & 0x07))), $k = TRUE; $k; $j ++) {
switch ($this->BUF[$i]{$j}) {
case "!" :
if ((substr($this->BUF[$i], ($j + 3), 8)) == "NETSCAPE") {
printf("%s: %s(%s source)!", $this->VER, $this->ERR['ERR03'], ($i + 1));
exit(0);
}
break;
case ";" :
$k = FALSE;
break;
}
}
}
GIFEncoder::GIFAddHeader();
for ($i = 0, $count_buf = count($this->BUF); $i BUF[0]{10}) & 0x80) {
$cmap = 3 * (2 BUF[0]{10}) & 0x07));
$this->GIF .= substr($this->BUF[0], 6, 7);
$this->GIF .= substr($this->BUF[0], 13, $cmap);
$this->GIF .= "!37713NETSCAPE2.031" . GIFEncoder::GIFWord($this->LOP) . "
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/1551/viewspace-2801941/ ,如需转载,请注明出处,否则将追究法律责任。