最新国产好看的视频,伊人天堂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)論

榆社县| 奉新县| 双柏县| 英山县| 马尔康县| 太保市| 越西县| 丘北县| 杂多县| 日照市| 娄烦县| 镇雄县| 衢州市| 衡水市| 阳信县| 定日县| 湛江市| 手机| 九江市| 精河县| 陇西县| 老河口市| 大兴区| 灵台县| 闸北区| 吴堡县| 富裕县| 东乌珠穆沁旗| 肃宁县| 新丰县| 滨海县| 仙桃市| 庆城县| 长春市| 苍梧县| 沙洋县| 甘肃省| 琼中| 黄大仙区| 桃源县| 民乐县|