PluginProbe ʕ •ᴥ•ʔ
Appointment Booking Calendar / 1.3.81
Appointment Booking Calendar v1.3.81
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 2 years ago font-1.ttf 2 years ago font-2.ttf 2 years ago font-3.ttf 2 years ago font-4.ttf 2 years ago no-gd-library.png 2 years ago
captcha.php
159 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 = ( isset($_GET["width"]) && is_numeric( $_GET["width"] ) )? $_GET["width"] : "180" ;
20 $imgY = ( isset($_GET["height"]) && is_numeric( $_GET["height"] ) )? $_GET["height"] : "60" ;
21
22 $letter_count = ( isset($_GET["letter_count"]) && is_numeric( $_GET["letter_count"] ) )? $_GET["letter_count"] : "5";
23 $min_size = ( isset($_GET["min_size"]) && is_numeric( $_GET["min_size"] ) )? $_GET["min_size"] : "25";
24 $max_size = ( isset($_GET["max_size"]) && is_numeric( $_GET["max_size"] ) )? $_GET["max_size"] : "35";
25 $noise = ( isset($_GET["noise"]) && is_numeric( $_GET["noise"] ) )? $_GET["noise"] : "200";
26 $noiselength = ( isset($_GET["noiselength"]) && is_numeric( $_GET["noiselength"] ) )? $_GET["noiselength"] : "4";
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 switch (@$_GET["font"]) {
108 case "font-2.ttf":
109 case "font2":
110 $selected_font = "font-2.ttf";
111 break;
112 case "font-3.ttf":
113 case "font3":
114 $selected_font = "font-3.ttf";
115 break;
116 case "font-4.ttf":
117 case "font4":
118 $selected_font = "font-4.ttf";
119 break;
120 default:
121 $selected_font = "font-1.ttf";
122 }
123
124 $font = dirname( __FILE__ ) . "/". $selected_font;
125
126 $font_size = rand($min_size, $max_size);
127
128 $angle = rand(-15, 15);
129
130 if (function_exists("imagettfbbox") && function_exists("imagettftext"))
131 {
132 $box = imagettfbbox($font_size, $angle, $font, $str);
133 $x = (int)($imgX - $box[4]) / 2;
134 $y = (int)($imgY - $box[5]) / 2;
135 imagettftext($image, $font_size, $angle, $x, $y, $text_col, $font, $str);
136 }
137 else if (function_exists("imageFtBBox") && function_exists("imageFTText"))
138 {
139 $box = imageFtBBox($font_size, $angle, $font, $str);
140 $x = (int)($imgX - $box[4]) / 2;
141 $y = (int)($imgY - $box[5]) / 2;
142 imageFTText ($image, $font_size, $angle, $x, $y, $text_col, $font, $str);
143 }
144 else
145 {
146 $angle = 0;
147 $font = 6;
148 $wf = ImageFontWidth(6) * strlen($str);
149 $hf = ImageFontHeight(6);
150 $x = (int)($imgX - $wf) / 2;
151 $y = (int)($imgY - $hf) / 2;
152 imagestring ( $image, $font, $x, $y, $str, $text_col);
153 }
154
155 header("Content-type: image/png");
156 imagepng($image);
157 imagedestroy ($image);
158 exit;
159 ?>