PluginProbe ʕ •ᴥ•ʔ
Booking Calendar Contact Form / trunk
Booking Calendar Contact Form vtrunk
1.2.66 1.2.65 trunk 1.0.1 1.1.80 1.1.81 1.1.82 1.1.83 1.1.84 1.1.85 1.1.86 1.1.87 1.1.88 1.1.89 1.1.90 1.1.91 1.1.92 1.1.93 1.1.94 1.1.95 1.1.96 1.1.97 1.1.98 1.1.99 1.2.07 1.2.08 1.2.09 1.2.10 1.2.11 1.2.12 1.2.14 1.2.15 1.2.16 1.2.17 1.2.18 1.2.19 1.2.20 1.2.21 1.2.22 1.2.23 1.2.24 1.2.25 1.2.26 1.2.27 1.2.28 1.2.29 1.2.30 1.2.31 1.2.32 1.2.33 1.2.34 1.2.35 1.2.36 1.2.37 1.2.38 1.2.39 1.2.40 1.2.41 1.2.42 1.2.43 1.2.44 1.2.45 1.2.46 1.2.47 1.2.48 1.2.49 1.2.50 1.2.51 1.2.52 1.2.53 1.2.54 1.2.55 1.2.56 1.2.57 1.2.58 1.2.59 1.2.60 1.2.61 1.2.62 1.2.63 1.2.64
booking-calendar-contact-form / captcha / captcha.php
booking-calendar-contact-form / captcha Last commit date
captcha.php 4 months ago font-1.ttf 12 years ago font-2.ttf 12 years ago font-3.ttf 12 years ago font-4.ttf 12 years ago
captcha.php
172 lines
1 <?php
2 /*
3 PHP Captcha by Codepeople.net
4 http://www.codepeople.net
5 */
6
7 if (!ini_get("zlib.output_compression")) ob_clean();
8
9 header("Cache-Control: no-store, no-cache, must-revalidate");
10 header("Pragma: no-cache");
11
12 if (!isset($_GET["ps"])) $_GET["ps"] = '';
13 if (!isset($_GET["bcolor"]) || $_GET["bcolor"] == '') $_GET["bcolor"] = "FFFFFF";
14 if (!isset($_GET["border"]) || $_GET["border"] == '') $_GET["border"] = "FFFFFF";
15
16 //configuration
17 $imgX = min( ( isset($_GET["width"]) && is_numeric( $_GET["width"] ) )? intval($_GET["width"]) : "180" , 800);
18 $imgY = min( ( isset($_GET["height"]) && is_numeric( $_GET["height"] ) )? intval($_GET["height"]) : "60" , 600);
19
20 $letter_count = min( ( isset($_GET["letter_count"]) && is_numeric( $_GET["letter_count"] ) )? intval($_GET["letter_count"]) : "5", 20);
21 $min_size = min( ( isset($_GET["min_size"]) && is_numeric( $_GET["min_size"] ) )? intval($_GET["min_size"]) : "35", 200);
22 $max_size = min( ( isset($_GET["max_size"]) && is_numeric( $_GET["max_size"] ) )? intval($_GET["max_size"]) : "45", 200);
23 $noise = min( ( isset($_GET["noise"]) && is_numeric( $_GET["noise"] ) )? intval($_GET["noise"]) : "200", 5000);
24 $noiselength = min( ( isset($_GET["noiselength"]) && is_numeric( $_GET["noiselength"] ) )? intval($_GET["noiselength"]) : "5", 50);
25 $bcolor = cpcff_decodeColor($_GET["bcolor"]);
26 $border = cpcff_decodeColor($_GET["border"]);
27
28 $noisecolor = 0xcdcdcd;
29 $random_noise_color= true;
30 $tcolor = cpcff_decodeColor("666666");
31 $random_text_color= true;
32
33 function cpcff_decodeColor($hexcolor)
34 {
35 $color = (hexdec($hexcolor));
36 $c["b"] = $color % 256;
37 $color = $color / 256;
38 $c["g"] = floor($color) % 256;
39 $color = $color / 256;
40 $c["r"] = floor($color) % 256;
41 return $c;
42 }
43
44 function cpcff_similarColors($c1, $c2)
45 {
46 return sqrt( pow($c1["r"]-$c2["r"],2) + pow($c1["g"]-$c2["g"],2) + pow($c1["b"]-$c2["b"],2)) < 125;
47 }
48
49
50 function bccf_captcha_sanitize_key( $key ) {
51 $key = strtolower( $key );
52 $key = preg_replace( '/[^a-z0-9_\-]/', '', $key );
53
54 return $key;
55 }
56
57 if (function_exists('session_start')) @session_start();
58
59 function cpcff_make_seed() {
60 list($usec, $sec) = explode(' ', microtime());
61 return round((float) $sec + ((float) $usec * 100000));
62 }
63 mt_srand(cpcff_make_seed());
64 $randval = mt_rand();
65
66 $str = "";
67 $length = 0;
68 for ($i = 0; $i < $letter_count; $i++) {
69 $str .= chr(mt_rand(97, 122))." ";
70 }
71 $_SESSION['rand_code'.bccf_captcha_sanitize_key($_GET["ps"])] = str_replace(" ", "", $str);
72
73 setCookie('rand_code'.bccf_captcha_sanitize_key($_GET["ps"]), md5(str_replace(" ", "", $str)), time()+36000,"/");
74
75 $image = imagecreatetruecolor($imgX, $imgY);
76 $backgr_col = imagecolorallocate($image, $bcolor["r"],$bcolor["g"],$bcolor["b"]);
77 $border_col = imagecolorallocate($image, $border["r"],$border["g"],$border["b"]);
78
79 if ($random_text_color)
80 {
81 do
82 {
83 $selcolor = mt_rand(0,256*256*256);
84 } while ( cpcff_similarColors(cpcff_decodeColor($selcolor), $bcolor) );
85 $tcolor = cpcff_decodeColor($selcolor);
86 }
87
88 $text_col = imagecolorallocate($image, $tcolor["r"],$tcolor["g"],$tcolor["b"]);
89
90
91
92 switch (@$_GET["font"]) {
93 case "font-2.ttf":
94 $selected_font = "font-2.ttf";
95 break;
96 case "font-3.ttf":
97 $selected_font = "font-3.ttf";
98 break;
99 case "font-4.ttf":
100 $selected_font = "font-4.ttf";
101 break;
102 default:
103 $selected_font = "font-1.ttf";
104 }
105
106 $font = dirname( __FILE__ ) . "/". $selected_font;
107
108
109 // 1. Create Image and Colors
110 $image = imagecreatetruecolor($imgX, $imgY);
111 imagealphablending($image, true);
112 imagesavealpha($image, true);
113
114 $bgColor = imagecolorallocate($image, $bcolor['r'], $bcolor['g'], $bcolor['b']);
115 $borderColor = imagecolorallocate($image, $border['r'], $border['g'], $border['b']);
116 imagefill($image, 0, 0, $bgColor);
117
118 // 1. Setup Margins
119 $leftPadding = 15; // Explicit safe zone for the first character
120 $rightPadding = 15; // Safe zone for the last character
121 $availableWidth = $imgX - ($leftPadding + $rightPadding);
122
123 $charArray = str_split($str);
124 $totalChars = count($charArray);
125 $cellWidth = $availableWidth / $totalChars;
126
127 // 2. Decorative Background Noise
128 for ($i = 0; $i < 6; $i++) {
129 $shapeAlpha = imagecolorallocatealpha($image, rand(220, 245), rand(220, 245), rand(220, 245), 90);
130 imagefilledellipse($image, rand(0, $imgX), rand(0, $imgY), rand(20, $imgX), rand(20, $imgY), $shapeAlpha);
131 }
132
133 // 3. Render Characters with Safe Positioning
134 foreach ($charArray as $i => $char) {
135 $fontSize = rand($min_size, $max_size);
136 $angle = rand(-10, 10);
137
138 $bbox = imagettfbbox($fontSize, $angle, $font, $char);
139
140 // Calculate dimensions from bounding box
141 $charWidth = abs($bbox[4] - $bbox[0]);
142 $charHeight = abs($bbox[5] - $bbox[1]);
143
144 // X = Base padding + (index * cell width) + centering within that cell
145 $x = $leftPadding + ($i * $cellWidth) + ($cellWidth - $charWidth) / 2;
146
147 // Y = Centered vertically with a slight random jitter for modern feel
148 $y = ($imgY / 2) + ($charHeight / 2) - rand(-2, 2);
149
150 $textColor = imagecolorallocatealpha($image, rand(40, 70), rand(40, 70), rand(80, 110), 0);
151
152 imagettftext($image, $fontSize, $angle, $x, $y, $textColor, $font, $char);
153 }
154
155 // 4. Fine Grain Noise
156 for ($i = 0; $i < $noise; $i++) {
157 $noiseColor = imagecolorallocatealpha($image, 80, 80, 80, rand(90, 110));
158 $x1 = rand(0, $imgX);
159 $y1 = rand(0, $imgY);
160 // Using noiselength to define the sprawl of the noise dots/lines
161 imageline($image, $x1, $y1, $x1 + rand(1, $noiselength), $y1 + rand(1, $noiselength), $noiseColor);
162 }
163
164 // 5. Border and Output
165 imagerectangle($image, 0, 0, $imgX - 1, $imgY - 1, $borderColor);
166
167 header('Content-Type: image/png');
168 imagepng($image);
169 imagedestroy($image);
170
171 exit;
172 ?>