angeljyt
中级会员
 
UID 72645
精华
0
积分 429
帖子 395
金钱 429 喜悦币
威望 0
人脉 0
阅读权限 30
注册 2006-5-1
状态 离线
|
[推荐阅读] 请高手们解一下!
图形验证码代码。
随机数生成是照搬php手册里的
<?php ob_start(); session_start();
$img = imagecreate(60,20); $bgcolor = imagecolorallocate($img,255,255,255);
mt_srand(make_seed()); $randval = mt_rand(); $seccode = substr($randval,-4); $_SESSION['seccode'] = $seccode; for($i = 0; $i < 4; $i++){ $color = imagecolorallocate($img,abs(mt_rand()%256),abs(mt_rand()%256),abs(mt_rand()%256)); imagechar($img,5,abs(mt_rand()%4)+$i*10+8,abs(mt_rand()%4),$seccode[$i],$color); }
header('content-Type:image/gif');
imagegif($img);
function make_seed() { list($usec, $sec) = explode(' ', microtime()); return (float) $sec + ((float) $usec * 100000); } ?>
|
|