<?php
if
(
$_GET
[
"action"
]==
"verifycode"
)
{
rand_create();
}
function
rand_create()
{
Header(
"Content-type: image/PNG"
);
srand((double)microtime()*1000000);
$im
= imagecreate(62,20);
$black
= ImageColorAllocate(
$im
, 0,0,0);
$white
= ImageColorAllocate(
$im
, 255,255,255);
$gray
= ImageColorAllocate(
$im
, 200,200,200);
imagefill(
$im
,0,0,
$gray
);
while
((
$randval
=rand()%100000)<10000);{
$_SESSION
[
"login_check_num"
] =
$randval
;
imagestring(
$im
, 5, 10, 3,
$randval
,
$black
);
}
for
(
$i
=0;
$i
<200;
$i
++){
$randcolor
= ImageColorallocate(
$im
,rand(0,255),rand(0,255),rand(0,255));
imagesetpixel(
$im
, rand()%70 , rand()%30 ,
$randcolor
);
}
ImagePNG(
$im
);
ImageDestroy(
$im
);
}
function
rand_check()
{
if
(
$_POST
[
"reg_rand"
] ==
$_SESSION
[
"login_check_num"
]){
return
true;
}
else
{
exit
(
"验证码输入错误"
);
}
}
?>