-
Notifications
You must be signed in to change notification settings - Fork 0
/
verify.php
executable file
·61 lines (57 loc) · 2.15 KB
/
verify.php
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?
header ("content-type: image/png");
header('Expires: 0');
header('Cache-Control: no-store, no-cache, must-revalidate, pre-check=0, post-check=0, max-age=0'); // HTTP/1.1
header('Pragma: no-cache'); // HTTP/1.0
session_start();
function getCode ($length = 32, $mode = 0)
{
switch ($mode)
{
case '1':
$str = '1234567890';break;
case '2':
$str = 'abcdefghijklmnopqrstuvwxyz';break;
case '3':
$str = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';break;
case '4':
$str = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';break;
case '5':
$str = 'ABCDEFGHIJKLMNPQRSTUVWXYZ123456789';break;
case '6':
$str = 'abcdefghijklmnopqrstuvwxyz123456789';break;
default:
$str = 'ABCDEFGHIJKLMNPQRSTUVWXYZabcdefghijkmnpqrstuvwxyz123456789';
break;
}
$result = '';
$l = strlen($str)-1;
for($i = 0;$i < $length;$i ++){
$num = rand(0, $l);
$result .= $str[$num];
}
return $result;
}
function createAuthNumImg($randStr,$imgW=100,$imgH=40,$fontName)
{
$image = imagecreate($imgW , $imgH);
$color_white = imagecolorallocate($image , 255 , 255 , 255);
$color_gray = imagecolorallocate($image , 228 , 228 , 228);
$color_black = imagecolorallocate($image , 255 , 102 , 204);
$color_radom = imagecolorallocate($image , rand(1,200) , rand(1,200) , rand(10,250));
for ($i = 0 ; $i < 2000 ; $i++)
{
$c = imagecolorallocate($image , rand(1,200) , rand(1,200) , rand(10,250));
imagesetpixel($image , mt_rand(0 , $imgW) , mt_rand(0 , $imgH) , $c);//Ìí¼ÓÔÓµã
}
imagerectangle($image , 0 , 0 , $imgW - 1 , $imgH - 1 , $color_gray);
imagettftext($image,50,mt_rand(-2,2),rand(0,20),50,$color_radom,$fontName,$randStr);
for ($i=10;$i<$imgH;$i+=10)imageline($image, 0, $i, $imgW, $i, $color_gray);//»ºáÏß
for ($i=10;$i<$imgW;$i+=10)imageline($image, $i, 0, $i, $imgH, $color_gray);//»ÊúÏß
imagepng($image);
imagedestroy($image);
}
$str=GetCode(5,1);
$_SESSION['VerifyCode']=md5(strtoupper($str));
createAuthNumImg($str,250,50,"includes/3dlet.ttf");
?>