最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

php 數(shù)學(xué)運(yùn)算驗(yàn)證碼實(shí)現(xiàn)代碼

 更新時(shí)間:2009年10月11日 15:28:38   作者:  
php 數(shù)學(xué)運(yùn)算驗(yàn)證碼實(shí)現(xiàn)代碼
復(fù)制代碼 代碼如下:

<?php
//-------------------------------------
// 文件說(shuō)明:數(shù)學(xué)運(yùn)算驗(yàn)證碼
// 文件作者:Jesse Lee
// 最后更新:2008-09-07
//-------------------------------------

session_start();

$sessionvar = 'vdcode'; //Session變量名稱
$width = 150; //圖像寬度
$height = 20; //圖像高度

$operator = '+-*'; //運(yùn)算符

$code = array();
$code[] = mt_rand(1,9);
$code[] = $operator{mt_rand(0,2)};
$code[] = mt_rand(1,9);
$code[] = $operator{mt_rand(0,2)};
$code[] = mt_rand(1,9);
$codestr = implode('',$code);
eval("\$result = ".implode('',$code).";");
$code[] = '=';

$_SESSION[$sessionvar] = $result;

$img = ImageCreate($width,$height);
ImageColorAllocate($img, mt_rand(230,250), mt_rand(230,250), mt_rand(230,250));
$color = ImageColorAllocate($img, 0, 0, 0);

$offset = 0;
foreach ($code as $char) {
$offset += 20;
$txtcolor = ImageColorAllocate($img, mt_rand(0,255), mt_rand(0,150), mt_rand(0,255));
ImageChar($img, mt_rand(3,5), $offset, mt_rand(1,5), $char, $txtcolor);
}

for ($i=0; $i<100; $i++) {
$pxcolor = ImageColorAllocate($img, mt_rand(0,255), mt_rand(0,255), mt_rand(0,255));
ImageSetPixel($img, mt_rand(0,$width), mt_rand(0,$height), $pxcolor);
}

header('Content-type: image/png');
ImagePng($img);
?>

相關(guān)文章

最新評(píng)論

鄂伦春自治旗| 中江县| 巨鹿县| 获嘉县| 伊宁县| 乐至县| 合阳县| 新闻| 张家口市| 虞城县| 长岛县| 虎林市| 交口县| 离岛区| 隆安县| 维西| 绿春县| 剑河县| 邯郸县| 黄骅市| 聂拉木县| 宾川县| 商丘市| 大丰市| 额济纳旗| 丰顺县| 柞水县| 佛教| 沙田区| 兴隆县| 铁岭县| 高唐县| 平凉市| 永嘉县| 泉州市| 双辽市| 潮安县| 栾城县| 斗六市| 盐亭县| 广安市|