Browse code

Initial uplad w/ php7 fixes

Rainer Volkrodt authored on 2016/03/12 15:54:02
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,87 @@
1
+<?php
2
+
3
+session_start();
4
+define("_BASEDIR", "../");
5
+include("../config.php");
6
+unset($_SESSION[$sitekey.'_digit']);
7
+
8
+$image = imagecreate(140, 40);
9
+
10
+$white    = imagecolorallocate($image, 0xFF, 0xFF, 0xFF);
11
+$gray    = imagecolorallocate($image, 0xC0, 0xC0, 0xC0);
12
+$darkgray = imagecolorallocate($image, 0x50, 0x50, 0x50);
13
+$black = imagecolorallocate($image, 0x00, 0x00, 0x00);
14
+
15
+
16
+srand((double)microtime()*1000000);
17
+unset($digit, $cnum);
18
+
19
+
20
+function rgb_rand($min=0,$max=255) {
21
+$color['r'] = mt_rand($min,$max);
22
+$color['g'] = mt_rand($min,$max);
23
+$color['b'] = mt_rand($min,$max);
24
+return $color;
25
+}
26
+
27
+/* Build the list of fonts */
28
+
29
+putenv('GDFONTPATH=' . realpath('.'));
30
+
31
+$folder=dir("cFonts/"); //The directory where your fonts reside
32
+
33
+while($font=$folder->read()) {
34
+  if(stristr($font,'.ttf')) $fontList[] = "cFonts/".$font;
35
+}
36
+
37
+$folder->close();
38
+
39
+for ($i = 0; $i < 5; $i++) {
40
+$cnum[$i] = rand(0,9);
41
+$rC = rgb_rand(0, 175);
42
+$rColors[$i] = imagecolorallocate($image, $rC['r'], $rC['g'], $rC['b']);
43
+
44
+for ($x = 0; $x < 2; $x++) {
45
+  $x1 = rand(0,140);
46
+  $y1 = rand(0,40);
47
+  $x2 = rand(0,140);
48
+  $y2 = rand(0,40);
49
+  imageline($image, $x1, $y1, $x2, $y2 , $rColors[$i]);  
50
+}
51
+
52
+}
53
+
54
+/* generate random dots in background */
55
+for( $i=0; $i<(140*40)/3; $i++ ) {
56
+  imagefilledellipse($image, mt_rand(0,140), mt_rand(0,40), 1, 1, $gray);
57
+}
58
+
59
+
60
+for ($i = 0; $i < 5; $i++) {
61
+ $x = $x + mt_rand(16, 24);
62
+ $y = mt_rand(26, 32); 
63
+ $angle = mt_rand(-15, 15);
64
+ $c = $ccolor[$i];
65
+ $fnt = mt_rand(0, sizeof($fontList) - 1);
66
+ $colori = $rColors[$i];
67
+ imagettftext($image, mt_rand(20, 24), $angle,  $x, $y, $colori, $fontList[$fnt], $cnum[$i]); 
68
+
69
+}
70
+
71
+
72
+$digit = "$cnum[0]$cnum[1]$cnum[2]$cnum[3]$cnum[4]";
73
+
74
+$_SESSION[$sitekey.'_digit'] = md5($sitekey.$digit);
75
+
76
+header("Expires: Tue, 11 Jun 1985 05:00:00 GMT");  
77
+header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");  
78
+header("Cache-Control: no-store, no-cache, must-revalidate");  
79
+header("Cache-Control: post-check=0, pre-check=0", false);
80
+header("Pragma: no-cache");
81
+header('Content-type: image/png');
82
+imagepng($image);
83
+imagedestroy($image);
84
+
85
+exit( );
86
+?> 
87
+