forked from NitefullSand/BBS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathverify.php
More file actions
36 lines (35 loc) · 885 Bytes
/
verify.php
File metadata and controls
36 lines (35 loc) · 885 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
session_start();
$im=imagecreate(200,100);//生成画布
imagecolorallocate($im, 0, 0, 0);//背景颜色
$white=imagecolorallocate($im, rand(0,255), rand(0,255),rand(0,255));//生成随机颜色
for($i=0;$i<9;$i++)
{
imageline($im, rand(0,200), rand(0,100), rand(0,200), rand(0,100), $white);//生成干扰线条元素
}
for($i=0;$i<150;$i++)
{
imagesetpixel($im, rand(0,200), rand(0,100), $white);//生成干扰点元素
}
$str='';
for($i=0,$str='';$i<4;$i++)//通过循环获得四个字符
{
switch (rand(1,3)) {
case '1':
$ch=rand(0,9);
break;
case '2':
$ch=sprintf('%c',rand(97,122));
break;
case '3':
$ch=sprintf('%c',rand(65,90));
break;
}
$str.=$ch;
}
imagettftext($im,32,rand(0,15),55,70,$white,'c.ttf',$str);//在画布上输出字符串
header("Content-type:image/jpeg");
imagejpeg($im);
imagedestroy($im);
$_SESSION['verify']=$str;
?>