forked from jefferyh/enlMS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshowpic.php
48 lines (33 loc) · 1.1 KB
/
showpic.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
<?php
//error_reporting(E_ALL); //除錯用
if(!isset($_SESSION)){ session_start(); } //判斷session是否已啟動
$ans_str=0; $ans_now=''; $s_x=0; $s_y=0; $ans_right_move=''; $_SESSION['ans_ckword'] = '';
mt_srand((double)microtime() * 1000000); //重置隨機值
//隨機取得6個小寫英字a-z
for($i=0; $i<6; $i++){
$ans_str = mt_rand(97,122);
$ans_now .= chr($ans_str);
}
$_SESSION['ans_ckword'] = $ans_now; //將值放至session
$im = imagecreate(150,50);
$red2 = imagecolorallocate($im,255,0,0); //文字顏色
$gray2 = imagecolorallocate($im,242,242,242); //背影顏色
imagefill($im,0,0,$gray2);
//隨機30點
$s_dot = imagecolorallocate($im,mt_rand(0,255),mt_rand(0,255),mt_rand(0,128));
for($i=0; $i<20; $i++){
imagesetpixel($im,mt_rand(10,75),mt_rand(5,20),$s_dot);
}
//文字隨機浮動
$s_x = mt_rand(5,40);
for($i=0; $i<6; $i++){
$ans_right_move = substr($ans_now,$i,1);
$s_y = mt_rand(1,18);
imagestring($im,5,$s_x,$s_y,$ans_right_move,$red2);
$s_x = $s_x + mt_rand(10,24);
}
//輸出圖片
header('Content-type: image/png');
imagepng($im);
imagedestroy($im);
?>