PluginProbe ʕ •ᴥ•ʔ
Appointment Booking Calendar / 1.3.94
Appointment Booking Calendar v1.3.94
1.4.04 1.4.03 1.4.02 trunk 1.3.51 1.3.52 1.3.53 1.3.54 1.3.55 1.3.56 1.3.57 1.3.58 1.3.59 1.3.60 1.3.61 1.3.62 1.3.63 1.3.64 1.3.65 1.3.66 1.3.67 1.3.68 1.3.69 1.3.70 1.3.71 1.3.72 1.3.73 1.3.74 1.3.75 1.3.76 1.3.77 1.3.78 1.3.79 1.3.80 1.3.81 1.3.82 1.3.83 1.3.84 1.3.85 1.3.86 1.3.87 1.3.88 1.3.89 1.3.90 1.3.91 1.3.92 1.3.93 1.3.94 1.3.95 1.3.96 1.3.97 1.3.98 1.3.99 1.4.01
appointment-booking-calendar / captcha / captcha.php
appointment-booking-calendar / captcha Last commit date
captcha.php 1 year ago font-1.ttf 1 year ago font-2.ttf 1 year ago font-3.ttf 1 year ago font-4.ttf 1 year ago no-gd-library.png 1 year ago
captcha.php
164 lines
1 <?php
2 /*
3 PHP Captcha by Codepeople.net
4 http://www.codepeople.net
5 */
6
7 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
8
9 if (!ini_get("zlib.output_compression")) ob_clean();
10
11 header("Cache-Control: no-store, no-cache, must-revalidate");
12 header("Pragma: no-cache");
13
14 if (!isset($_GET["ps"])) $_GET["ps"] = '';
15 if (!isset($_GET["bcolor"]) || $_GET["bcolor"] == '') $_GET["bcolor"] = "FFFFFF";
16 if (!isset($_GET["border"]) || $_GET["border"] == '') $_GET["border"] = "000000";
17
18 //configuration
19 $imgX = min( ( isset($_GET["width"]) && is_numeric( $_GET["width"] ) )? intval($_GET["width"]) : "180" , 800);
20 $imgY = min( ( isset($_GET["height"]) && is_numeric( $_GET["height"] ) )? intval($_GET["height"]) : "60" , 600);
21
22 $letter_count = min( ( isset($_GET["letter_count"]) && is_numeric( $_GET["letter_count"] ) )? intval($_GET["letter_count"]) : "5", 20);
23 $min_size = min( ( isset($_GET["min_size"]) && is_numeric( $_GET["min_size"] ) )? intval($_GET["min_size"]) : "35", 200);
24 $max_size = min( ( isset($_GET["max_size"]) && is_numeric( $_GET["max_size"] ) )? intval($_GET["max_size"]) : "45", 200);
25 $noise = min( ( isset($_GET["noise"]) && is_numeric( $_GET["noise"] ) )? intval($_GET["noise"]) : "200", 5000);
26 $noiselength = min( ( isset($_GET["noiselength"]) && is_numeric( $_GET["noiselength"] ) )? intval($_GET["noiselength"]) : "5", 50);
27 $bcolor = cpcff_decodeColor($_GET["bcolor"]);
28 $border = cpcff_decodeColor($_GET["border"]);
29
30 $noisecolor = 0xcdcdcd;
31 $random_noise_color= true;
32 $tcolor = cpcff_decodeColor("666666");
33 $random_text_color= true;
34
35 function cpcff_decodeColor($hexcolor)
36 {
37 $color = hexdec($hexcolor);
38 $c["b"] = $color % 256;
39 $color = $color / 256;
40 $c["g"] = $color % 256;
41 $color = $color / 256;
42 $c["r"] = $color % 256;
43 return $c;
44 }
45
46 function cpcff_similarColors($c1, $c2)
47 {
48 return sqrt( pow($c1["r"]-$c2["r"],2) + pow($c1["g"]-$c2["g"],2) + pow($c1["b"]-$c2["b"],2)) < 125;
49 }
50
51 if (function_exists('session_start')) @session_start();
52
53 function cpcff_make_seed() {
54 list($usec, $sec) = explode(' ', microtime());
55 return (float) $sec + ((float) $usec * 100000);
56 }
57 mt_srand(cpcff_make_seed());
58 $randval = mt_rand();
59
60 $str = "";
61 $length = 0;
62 for ($i = 0; $i < $letter_count; $i++) {
63 $str .= chr(mt_rand(97, 122))." ";
64 }
65 $_SESSION['rand_code'.sanitize_key($_GET["ps"])] = str_replace(" ", "", $str);
66
67 $uidt = uniqid();
68 set_transient( "cpeople-captcha-".$uidt , str_replace(" ", "", $str) , 1800 );
69 setCookie('rand_code'.sanitize_key($_GET["ps"]), $uidt, time()+36000,"/");
70
71 if (!function_exists('imagecreatetruecolor'))
72 {
73 header("Content-type: image/png");
74 readfile( dirname( __FILE__ ) . "/no-gd-library.png");
75 exit;
76 }
77
78 $image = imagecreatetruecolor($imgX, $imgY);
79 $backgr_col = imagecolorallocate($image, $bcolor["r"],$bcolor["g"],$bcolor["b"]);
80 $border_col = imagecolorallocate($image, $border["r"],$border["g"],$border["b"]);
81
82 if ($random_text_color)
83 {
84 do
85 {
86 $selcolor = mt_rand(0,256*256*256);
87 } while ( cpcff_similarColors(cpcff_decodeColor($selcolor), $bcolor) );
88 $tcolor = cpcff_decodeColor($selcolor);
89 }
90
91 $text_col = imagecolorallocate($image, $tcolor["r"],$tcolor["g"],$tcolor["b"]);
92
93 imagefilledrectangle($image, 0, 0, $imgX, $imgY, $backgr_col);
94 imagerectangle($image, 0, 0, $imgX-1, $imgY-1, $border_col);
95 for ($i=0;$i<$noise;$i++)
96 {
97 if ($random_noise_color)
98 $color = mt_rand(0, 256*256*256);
99 else
100 $color = $noisecolor;
101 $x1 = mt_rand(2,$imgX-2);
102 $y1 = mt_rand(2,$imgY-2);
103 imageline ( $image, $x1, $y1, mt_rand($x1-$noiselength,$x1+$noiselength), mt_rand($y1-$noiselength,$y1+$noiselength), $color);
104 }
105
106
107 if (empty($_GET["font"]))
108 $selected_font = "font-1.ttf";
109 else
110 {
111 switch (@$_GET["font"]) {
112 case "font-2.ttf":
113 case "font2":
114 $selected_font = "font-2.ttf";
115 break;
116 case "font-3.ttf":
117 case "font3":
118 $selected_font = "font-3.ttf";
119 break;
120 case "font-4.ttf":
121 case "font4":
122 $selected_font = "font-4.ttf";
123 break;
124 default:
125 $selected_font = "font-1.ttf";
126 }
127 }
128
129 $font = dirname( __FILE__ ) . "/". $selected_font;
130
131 $font_size = rand($min_size, $max_size);
132
133 $angle = rand(-15, 15);
134
135 if (function_exists("imagettfbbox") && function_exists("imagettftext"))
136 {
137 $box = imagettfbbox($font_size, $angle, $font, $str);
138 $x = (int)($imgX - $box[4]) / 2;
139 $y = (int)($imgY - $box[5]) / 2;
140 imagettftext($image, $font_size, $angle, $x, $y, $text_col, $font, $str);
141 }
142 else if (function_exists("imageFtBBox") && function_exists("imageFTText"))
143 {
144 $box = imageFtBBox($font_size, $angle, $font, $str);
145 $x = (int)($imgX - $box[4]) / 2;
146 $y = (int)($imgY - $box[5]) / 2;
147 imageFTText ($image, $font_size, $angle, $x, $y, $text_col, $font, $str);
148 }
149 else
150 {
151 $angle = 0;
152 $font = 6;
153 $wf = ImageFontWidth(6) * strlen($str);
154 $hf = ImageFontHeight(6);
155 $x = (int)($imgX - $wf) / 2;
156 $y = (int)($imgY - $hf) / 2;
157 imagestring ( $image, $font, $x, $y, $str, $text_col);
158 }
159
160 header("Content-type: image/png");
161 imagepng($image);
162 imagedestroy ($image);
163 exit;
164 ?>