-
Notifications
You must be signed in to change notification settings - Fork 3
/
image_verify.php
60 lines (45 loc) · 1.56 KB
/
image_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
<?PHP
// Image Verify For MMW
// Creator =Master=, Edit by Vaflan
// generate 5 digit random Alpha
session_start();
$alphanum = "abcdefghijklmnopqwstuvwxyz0123456789";
$rand = substr(str_shuffle($alphanum), 0, 6);
// create the hash for the random number and put it in the session
$_SESSION['image_random_value'] = md5($rand);
// create the image
$image = imagecreate(54, 18);
// Generate 3 Img Color
$coloring = rand(1,3);
if($coloring == 1) {
$bgColor = imagecolorallocate ($image, 0x79, 0x79, 0x79);
$textColor = imagecolorallocate ($image, 0xEE, 0XEE, 0xEE);
}
if($coloring == 2) {
$bgColor = imagecolorallocate ($image, 0xCC, 0xCC, 0xCC);
$textColor = imagecolorallocate ($image, 0x00, 0X00, 0x00);
}
if($coloring == 3) {
$bgColor = imagecolorallocate ($image, 0x00, 0x00, 0x00);
$textColor = imagecolorallocate ($image, 0xFF, 0XFF, 0xFF);
}
// write the random number
imagestring ($image, 4, 3, 1, $rand, $textColor);
// send several headers to make sure the image is not cached
// taken directly from the PHP Manual
// Date in the past
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
// always modified
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
// HTTP/1.1
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
// HTTP/1.0
header("Pragma: no-cache");
// send the content type header so the image is displayed properly
header('Content-type: image/jpeg');
// send the image to the browser
imagejpeg($image);
// destroy the image to free up the memory
imagedestroy($image);
?>