Revision 1371
Added by Dietmar almost 14 years ago
branches/2.8.x/CHANGELOG | ||
---|---|---|
11 | 11 |
! = Update/Change |
12 | 12 |
|
13 | 13 |
------------------------------------- 2.8.2 ------------------------------------- |
14 |
09 Jan-2011 Build 1371 Dietmar Woellbrink (Luisehahne) |
|
15 |
# captcha patch (Tks to FrankH) |
|
14 | 16 |
09 Jan-2011 Build 1370 Dietmar Woellbrink (Luisehahne) |
15 | 17 |
! update install, changed some default settings to enabled |
16 | 18 |
06 Jan-2011 Build 1369 Dietmar Woellbrink (Luisehahne) |
branches/2.8.x/wb/include/captcha/captchas/ttf_image.php | ||
---|---|---|
1 |
<?php |
|
2 |
|
|
3 |
// $Id$ |
|
4 |
|
|
5 |
/* |
|
6 |
|
|
7 |
Website Baker Project <http://www.websitebaker.org/> |
|
8 |
Copyright (C) 2004-2009, Ryan Djurovich |
|
9 |
|
|
10 |
Website Baker is free software; you can redistribute it and/or modify |
|
11 |
it under the terms of the GNU General Public License as published by |
|
12 |
the Free Software Foundation; either version 2 of the License, or |
|
13 |
(at your option) any later version. |
|
14 |
|
|
15 |
Website Baker is distributed in the hope that it will be useful, |
|
16 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
17 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
18 |
GNU General Public License for more details. |
|
19 |
|
|
20 |
You should have received a copy of the GNU General Public License |
|
21 |
along with Website Baker; if not, write to the Free Software |
|
22 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
23 |
|
|
24 |
*/ |
|
25 |
|
|
26 |
require_once("../../../config.php"); |
|
27 |
require_once(WB_PATH.'/include/captcha/captcha.php'); |
|
28 |
|
|
29 |
if(!isset($_SESSION['captcha_time'])) |
|
30 |
exit; |
|
31 |
unset($_SESSION['captcha_time']); |
|
32 |
|
|
33 |
// get lists of fonts and backgrounds |
|
34 |
require_once(WB_PATH.'/framework/functions.php'); |
|
35 |
$t_fonts = file_list(WB_PATH.'/include/captcha/fonts'); |
|
36 |
$t_bgs = file_list(WB_PATH.'/include/captcha/backgrounds'); |
|
37 |
$fonts = array(); |
|
38 |
$bgs = array(); |
|
39 |
foreach($t_fonts as $file) { if(preg_match('/\.ttf/',$file)) { $fonts[]=$file; } } |
|
40 |
foreach($t_bgs as $file) { if(preg_match('/\.png/',$file)) { $bgs[]=$file; } } |
|
41 |
|
|
42 |
// make random string |
|
43 |
if(!function_exists('randomString')) { |
|
44 |
function randomString($len) { |
|
45 |
list($usec, $sec) = explode(' ', microtime()); |
|
46 |
mt_srand((float)$sec + ((float)$usec * 100000)); |
|
47 |
//$possible="ABCDEFGHJKLMNPRSTUVWXYZabcdefghkmnpqrstuvwxyz23456789"; |
|
48 |
$possible="abdfhkrsvwxz23456789"; |
|
49 |
$str=""; |
|
50 |
while(strlen($str)<$len) { |
|
51 |
$str.=substr($possible,(mt_rand()%(strlen($possible))),1); |
|
52 |
} |
|
53 |
return($str); |
|
54 |
} |
|
55 |
} |
|
56 |
$text = randomString(5); // number of characters |
|
57 |
$_SESSION['captcha'] = $text; |
|
58 |
|
|
59 |
// choose a font and background |
|
60 |
$font = $fonts[array_rand($fonts)]; |
|
61 |
$bg = $bgs[array_rand($bgs)]; |
|
62 |
// get image-dimensions |
|
63 |
list($width, $height, $type, $attr) = getimagesize($bg); |
|
64 |
|
|
65 |
// create reload-image |
|
66 |
$reload = ImageCreateFromPNG(WB_PATH.'/include/captcha/reload_140_40.png'); // reload-overlay |
|
67 |
|
|
68 |
if(mt_rand(0,2)==0) { // 1 out of 3 |
|
69 |
|
|
70 |
// draw each character individualy |
|
71 |
$image = ImageCreateFromPNG($bg); // background image |
|
72 |
$grey = mt_rand(0,50); |
|
73 |
$color = ImageColorAllocate($image, $grey, $grey, $grey); // font-color |
|
74 |
$ttf = $font; |
|
75 |
$ttfsize = 25; // fontsize |
|
76 |
$count = 0; |
|
77 |
$image_failed = true; |
|
78 |
$angle = mt_rand(-15,15); |
|
79 |
$x = mt_rand(10,25); |
|
80 |
$y = mt_rand($height-10,$height-2); |
|
81 |
do { |
|
82 |
for($i=0;$i<strlen($text);$i++) { |
|
83 |
$res = imagettftext($image, $ttfsize, $angle, $x, $y, $color, $ttf, $text{$i}); |
|
84 |
$angle = mt_rand(-15,15); |
|
85 |
$x = mt_rand($res[4],$res[4]+10); |
|
86 |
$y = mt_rand($height-15,$height-5); |
|
87 |
} |
|
88 |
if($res[4] > $width) { |
|
89 |
$image_failed = true; |
|
90 |
} else { |
|
91 |
$image_failed = false; |
|
92 |
} |
|
93 |
if(++$count > 4) // too many tries! Use the image |
|
94 |
break; |
|
95 |
} while($image_failed); |
|
96 |
|
|
97 |
} else { |
|
98 |
|
|
99 |
// draw whole string at once |
|
100 |
$image_failed = true; |
|
101 |
$count=0; |
|
102 |
do { |
|
103 |
$image = ImageCreateFromPNG($bg); // background image |
|
104 |
$grey = mt_rand(0,50); |
|
105 |
$color = ImageColorAllocate($image, $grey, $grey, $grey); // font-color |
|
106 |
$ttf = $font; |
|
107 |
$ttfsize = 25; // fontsize |
|
108 |
$angle = mt_rand(0,5); |
|
109 |
$x = mt_rand(5,30); |
|
110 |
$y = mt_rand($height-10,$height-2); |
|
111 |
$res = imagettftext($image, $ttfsize, $angle, $x, $y, $color, $ttf, $text); |
|
112 |
// check if text fits into the image |
|
113 |
if(($res[0]>0 && $res[0]<$width) && ($res[1]>0 && $res[1]<$height) && |
|
114 |
($res[2]>0 && $res[2]<$width) && ($res[3]>0 && $res[3]<$height) && |
|
115 |
($res[4]>0 && $res[4]<$width) && ($res[5]>0 && $res[5]<$height) && |
|
116 |
($res[6]>0 && $res[6]<$width) && ($res[7]>0 && $res[7]<$height) |
|
117 |
) { |
|
118 |
$image_failed = false; |
|
119 |
} |
|
120 |
if(++$count > 4) // too many tries! Use the image |
|
121 |
break; |
|
122 |
} while($image_failed); |
|
123 |
|
|
124 |
} |
|
125 |
|
|
126 |
imagealphablending($reload, TRUE); |
|
127 |
imagesavealpha($reload, TRUE); |
|
128 |
|
|
129 |
// overlay |
|
130 |
imagecopy($reload, $image, 0,0,0,0, 140,40); |
|
131 |
imagedestroy($image); |
|
132 |
$image = $reload; |
|
133 |
|
|
134 |
captcha_header(); |
|
135 |
ob_start(); |
|
136 |
imagepng($image); |
|
137 |
header("Content-Length: ".ob_get_length()); |
|
138 |
ob_end_flush(); |
|
139 |
imagedestroy($image); |
|
140 |
|
|
1 |
<?php |
|
2 |
|
|
3 |
// $Id$ |
|
4 |
|
|
5 |
/* |
|
6 |
|
|
7 |
Website Baker Project <http://www.websitebaker.org/> |
|
8 |
Copyright (C) 2004-2009, Ryan Djurovich |
|
9 |
|
|
10 |
Website Baker is free software; you can redistribute it and/or modify |
|
11 |
it under the terms of the GNU General Public License as published by |
|
12 |
the Free Software Foundation; either version 2 of the License, or |
|
13 |
(at your option) any later version. |
|
14 |
|
|
15 |
Website Baker is distributed in the hope that it will be useful, |
|
16 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
17 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
18 |
GNU General Public License for more details. |
|
19 |
|
|
20 |
You should have received a copy of the GNU General Public License |
|
21 |
along with Website Baker; if not, write to the Free Software |
|
22 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
23 |
|
|
24 |
*/ |
|
25 |
|
|
26 |
require_once("../../../config.php"); |
|
27 |
require_once(WB_PATH.'/include/captcha/captcha.php'); |
|
28 |
|
|
29 |
if(!isset($_SESSION['captcha_time'])) |
|
30 |
exit; |
|
31 |
//unset($_SESSION['captcha_time']); |
|
32 |
|
|
33 |
// get lists of fonts and backgrounds |
|
34 |
require_once(WB_PATH.'/framework/functions.php'); |
|
35 |
$t_fonts = file_list(WB_PATH.'/include/captcha/fonts'); |
|
36 |
$t_bgs = file_list(WB_PATH.'/include/captcha/backgrounds'); |
|
37 |
$fonts = array(); |
|
38 |
$bgs = array(); |
|
39 |
foreach($t_fonts as $file) if(eregi('\.ttf$',$file)) $fonts[]=$file; |
|
40 |
foreach($t_bgs as $file) if(eregi('\.png$',$file)) $bgs[]=$file; |
|
41 |
|
|
42 |
// make random string |
|
43 |
if(!function_exists('randomString')) { |
|
44 |
function randomString($len) { |
|
45 |
list($usec, $sec) = explode(' ', microtime()); |
|
46 |
mt_srand((float)$sec + ((float)$usec * 100000)); |
|
47 |
//$possible="ABCDEFGHJKLMNPRSTUVWXYZabcdefghkmnpqrstuvwxyz23456789"; |
|
48 |
$possible="abdfhkrsvwxz23456789"; |
|
49 |
$str=""; |
|
50 |
while(strlen($str)<$len) { |
|
51 |
$str.=substr($possible,(mt_rand()%(strlen($possible))),1); |
|
52 |
} |
|
53 |
return($str); |
|
54 |
} |
|
55 |
} |
|
56 |
$text = randomString(5); // number of characters |
|
57 |
|
|
58 |
$sec_id = ''; |
|
59 |
if(isset($_GET['s'])) $sec_id = $_GET['s']; |
|
60 |
$_SESSION['captcha'.$sec_id] = $text; |
|
61 |
|
|
62 |
// choose a font and background |
|
63 |
$font = $fonts[array_rand($fonts)]; |
|
64 |
$bg = $bgs[array_rand($bgs)]; |
|
65 |
// get image-dimensions |
|
66 |
list($width, $height, $type, $attr) = getimagesize($bg); |
|
67 |
|
|
68 |
// create reload-image |
|
69 |
$reload = ImageCreateFromPNG(WB_PATH.'/include/captcha/reload_140_40.png'); // reload-overlay |
|
70 |
|
|
71 |
if(mt_rand(0,2)==0) { // 1 out of 3 |
|
72 |
|
|
73 |
// draw each character individualy |
|
74 |
$image = ImageCreateFromPNG($bg); // background image |
|
75 |
$grey = mt_rand(0,50); |
|
76 |
$color = ImageColorAllocate($image, $grey, $grey, $grey); // font-color |
|
77 |
$ttf = $font; |
|
78 |
$ttfsize = 25; // fontsize |
|
79 |
$count = 0; |
|
80 |
$image_failed = true; |
|
81 |
$angle = mt_rand(-15,15); |
|
82 |
$x = mt_rand(10,25); |
|
83 |
$y = mt_rand($height-10,$height-2); |
|
84 |
do { |
|
85 |
for($i=0;$i<strlen($text);$i++) { |
|
86 |
$res = imagettftext($image, $ttfsize, $angle, $x, $y, $color, $ttf, $text{$i}); |
|
87 |
$angle = mt_rand(-15,15); |
|
88 |
$x = mt_rand($res[4],$res[4]+10); |
|
89 |
$y = mt_rand($height-15,$height-5); |
|
90 |
} |
|
91 |
if($res[4] > $width) { |
|
92 |
$image_failed = true; |
|
93 |
} else { |
|
94 |
$image_failed = false; |
|
95 |
} |
|
96 |
if(++$count > 4) // too many tries! Use the image |
|
97 |
break; |
|
98 |
} while($image_failed); |
|
99 |
|
|
100 |
} else { |
|
101 |
|
|
102 |
// draw whole string at once |
|
103 |
$image_failed = true; |
|
104 |
$count=0; |
|
105 |
do { |
|
106 |
$image = ImageCreateFromPNG($bg); // background image |
|
107 |
$grey = mt_rand(0,50); |
|
108 |
$color = ImageColorAllocate($image, $grey, $grey, $grey); // font-color |
|
109 |
$ttf = $font; |
|
110 |
$ttfsize = 25; // fontsize |
|
111 |
$angle = mt_rand(0,5); |
|
112 |
$x = mt_rand(5,30); |
|
113 |
$y = mt_rand($height-10,$height-2); |
|
114 |
$res = imagettftext($image, $ttfsize, $angle, $x, $y, $color, $ttf, $text); |
|
115 |
// check if text fits into the image |
|
116 |
if(($res[0]>0 && $res[0]<$width) && ($res[1]>0 && $res[1]<$height) && |
|
117 |
($res[2]>0 && $res[2]<$width) && ($res[3]>0 && $res[3]<$height) && |
|
118 |
($res[4]>0 && $res[4]<$width) && ($res[5]>0 && $res[5]<$height) && |
|
119 |
($res[6]>0 && $res[6]<$width) && ($res[7]>0 && $res[7]<$height) |
|
120 |
) { |
|
121 |
$image_failed = false; |
|
122 |
} |
|
123 |
if(++$count > 4) // too many tries! Use the image |
|
124 |
break; |
|
125 |
} while($image_failed); |
|
126 |
|
|
127 |
} |
|
128 |
|
|
129 |
imagealphablending($reload, TRUE); |
|
130 |
imagesavealpha($reload, TRUE); |
|
131 |
|
|
132 |
// overlay |
|
133 |
imagecopy($reload, $image, 0,0,0,0, 140,40); |
|
134 |
imagedestroy($image); |
|
135 |
$image = $reload; |
|
136 |
|
|
137 |
captcha_header(); |
|
138 |
ob_start(); |
|
139 |
imagepng($image); |
|
140 |
header("Content-Length: ".ob_get_length()); |
|
141 |
ob_end_flush(); |
|
142 |
imagedestroy($image); |
|
143 |
|
|
141 | 144 |
?> |
branches/2.8.x/wb/include/captcha/captchas/old_image.php | ||
---|---|---|
28 | 28 |
|
29 | 29 |
if(!isset($_SESSION['captcha_time'])) |
30 | 30 |
exit; |
31 |
unset($_SESSION['captcha_time']); |
|
31 |
//unset($_SESSION['captcha_time']);
|
|
32 | 32 |
|
33 | 33 |
// Captcha |
34 | 34 |
srand((double)microtime()*100000); |
35 |
$_SESSION['captcha'] = rand(10000,99999); |
|
35 |
$sec_id = ''; |
|
36 |
if(isset($_GET['s'])) $sec_id = $_GET['s']; |
|
37 |
$_SESSION['captcha'.$sec_id] = rand(10000,99999); |
|
36 | 38 |
|
37 | 39 |
// create reload-image |
38 | 40 |
$reload = ImageCreateFromPNG(WB_PATH.'/include/captcha/reload_120_30.png'); // reload-overlay |
... | ... | |
58 | 60 |
$fnt = rand(3,5); |
59 | 61 |
$x = $x + rand(12 , 20); |
60 | 62 |
$y = rand(7 , 12); |
61 |
imagestring($image, $fnt, $x, $y, substr($_SESSION['captcha'], $i, 1), $darkgray); |
|
63 |
imagestring($image, $fnt, $x, $y, substr($_SESSION['captcha'.$sec_id], $i, 1), $darkgray);
|
|
62 | 64 |
} |
63 | 65 |
|
64 | 66 |
imagealphablending($reload, TRUE); |
branches/2.8.x/wb/include/captcha/captchas/calc_ttf_image.php | ||
---|---|---|
1 |
<?php |
|
2 |
|
|
3 |
// $Id$ |
|
4 |
|
|
5 |
/* |
|
6 |
|
|
7 |
Website Baker Project <http://www.websitebaker.org/> |
|
8 |
Copyright (C) 2004-2009, Ryan Djurovich |
|
9 |
|
|
10 |
Website Baker is free software; you can redistribute it and/or modify |
|
11 |
it under the terms of the GNU General Public License as published by |
|
12 |
the Free Software Foundation; either version 2 of the License, or |
|
13 |
(at your option) any later version. |
|
14 |
|
|
15 |
Website Baker is distributed in the hope that it will be useful, |
|
16 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
17 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
18 |
GNU General Public License for more details. |
|
19 |
|
|
20 |
You should have received a copy of the GNU General Public License |
|
21 |
along with Website Baker; if not, write to the Free Software |
|
22 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
23 |
|
|
24 |
*/ |
|
25 |
|
|
26 |
require_once("../../../config.php"); |
|
27 |
require_once(WB_PATH.'/include/captcha/captcha.php'); |
|
28 |
|
|
29 |
if(!isset($_SESSION['captcha_time'])) |
|
30 |
exit; |
|
31 |
unset($_SESSION['captcha_time']); |
|
32 |
|
|
33 |
// get lists of fonts and backgrounds |
|
34 |
require_once(WB_PATH.'/framework/functions.php'); |
|
35 |
$t_fonts = file_list(WB_PATH.'/include/captcha/fonts'); |
|
36 |
$t_bgs = file_list(WB_PATH.'/include/captcha/backgrounds'); |
|
37 |
$fonts = array(); |
|
38 |
$bgs = array(); |
|
39 |
foreach($t_fonts as $file) { if(preg_match('/\.ttf/',$file)) { $fonts[]=$file; } } |
|
40 |
foreach($t_bgs as $file) { if(preg_match('/\.png/',$file)) { $bgs[]=$file; } } |
|
41 |
|
|
42 |
// Captcha |
|
43 |
$_SESSION['captcha'] = ''; |
|
44 |
mt_srand((double)microtime()*1000000); |
|
45 |
$n = mt_rand(1,3); |
|
46 |
switch ($n) { |
|
47 |
case 1: |
|
48 |
$x = mt_rand(1,9); |
|
49 |
$y = mt_rand(1,9); |
|
50 |
$_SESSION['captcha'] = $x + $y; |
|
51 |
$cap = "$x+$y"; |
|
52 |
break; |
|
53 |
case 2: |
|
54 |
$x = mt_rand(10,20); |
|
55 |
$y = mt_rand(1,9); |
|
56 |
$_SESSION['captcha'] = $x - $y; |
|
57 |
$cap = "$x-$y"; |
|
58 |
break; |
|
59 |
case 3: |
|
60 |
$x = mt_rand(2,10); |
|
61 |
$y = mt_rand(2,5); |
|
62 |
$_SESSION['captcha'] = $x * $y; |
|
63 |
$cap = "$x*$y"; |
|
64 |
break; |
|
65 |
} |
|
66 |
$text = $cap; |
|
67 |
|
|
68 |
// choose a font and background |
|
69 |
$font = $fonts[array_rand($fonts)]; |
|
70 |
$bg = $bgs[array_rand($bgs)]; |
|
71 |
// get image-dimensions |
|
72 |
list($width, $height, $type, $attr) = getimagesize($bg); |
|
73 |
|
|
74 |
// create reload-image |
|
75 |
$reload = ImageCreateFromPNG(WB_PATH.'/include/captcha/reload_140_40.png'); // reload-overlay |
|
76 |
|
|
77 |
if(mt_rand(0,2)==0) { // 1 out of 3 |
|
78 |
|
|
79 |
// draw each character individualy |
|
80 |
$image = ImageCreateFromPNG($bg); // background image |
|
81 |
$grey = mt_rand(0,50); |
|
82 |
$color = ImageColorAllocate($image, $grey, $grey, $grey); // font-color |
|
83 |
$ttf = $font; |
|
84 |
$ttfsize = 25; // fontsize |
|
85 |
$count = 0; |
|
86 |
$image_failed = true; |
|
87 |
$angle = mt_rand(-10,10); |
|
88 |
$x = mt_rand(20,35); |
|
89 |
$y = mt_rand($height-10,$height-2); |
|
90 |
do { |
|
91 |
for($i=0;$i<strlen($text);$i++) { |
|
92 |
$res = imagettftext($image, $ttfsize, $angle, $x, $y, $color, $ttf, $text{$i}); |
|
93 |
$angle = mt_rand(-10,10); |
|
94 |
$x = mt_rand($res[4],$res[4]+10); |
|
95 |
$y = mt_rand($height-12,$height-7); |
|
96 |
} |
|
97 |
if($res[4] > $width) { |
|
98 |
$image_failed = true; |
|
99 |
} else { |
|
100 |
$image_failed = false; |
|
101 |
} |
|
102 |
if(++$count > 4) // too many tries! Use the image |
|
103 |
break; |
|
104 |
} while($image_failed); |
|
105 |
|
|
106 |
} else { |
|
107 |
|
|
108 |
// draw whole string at once |
|
109 |
$image_failed = true; |
|
110 |
$count=0; |
|
111 |
do { |
|
112 |
$image = ImageCreateFromPNG($bg); // background image |
|
113 |
$grey = mt_rand(0,50); |
|
114 |
$color = ImageColorAllocate($image, $grey, $grey, $grey); // font-color |
|
115 |
$ttf = $font; |
|
116 |
$ttfsize = 25; // fontsize |
|
117 |
$angle = mt_rand(0,5); |
|
118 |
$x = mt_rand(20,35); |
|
119 |
$y = mt_rand($height-10,$height-2); |
|
120 |
$res = imagettftext($image, $ttfsize, $angle, $x, $y, $color, $ttf, $text); |
|
121 |
// check if text fits into the image |
|
122 |
if(($res[0]>0 && $res[0]<$width) && ($res[1]>0 && $res[1]<$height) && |
|
123 |
($res[2]>0 && $res[2]<$width) && ($res[3]>0 && $res[3]<$height) && |
|
124 |
($res[4]>0 && $res[4]<$width) && ($res[5]>0 && $res[5]<$height) && |
|
125 |
($res[6]>0 && $res[6]<$width) && ($res[7]>0 && $res[7]<$height) |
|
126 |
) { |
|
127 |
$image_failed = false; |
|
128 |
} |
|
129 |
if(++$count > 4) // too many tries! Use the image |
|
130 |
break; |
|
131 |
} while($image_failed); |
|
132 |
|
|
133 |
} |
|
134 |
|
|
135 |
imagealphablending($reload, TRUE); |
|
136 |
imagesavealpha($reload, TRUE); |
|
137 |
|
|
138 |
// overlay |
|
139 |
imagecopy($reload, $image, 0,0,0,0, 140,40); |
|
140 |
imagedestroy($image); |
|
141 |
$image = $reload; |
|
142 |
|
|
143 |
captcha_header(); |
|
144 |
ob_start(); |
|
145 |
imagepng($image); |
|
146 |
header("Content-Length: ".ob_get_length()); |
|
147 |
ob_end_flush(); |
|
148 |
imagedestroy($image); |
|
149 |
|
|
1 |
<?php |
|
2 |
|
|
3 |
// $Id$ |
|
4 |
|
|
5 |
/* |
|
6 |
|
|
7 |
Website Baker Project <http://www.websitebaker.org/> |
|
8 |
Copyright (C) 2004-2009, Ryan Djurovich |
|
9 |
|
|
10 |
Website Baker is free software; you can redistribute it and/or modify |
|
11 |
it under the terms of the GNU General Public License as published by |
|
12 |
the Free Software Foundation; either version 2 of the License, or |
|
13 |
(at your option) any later version. |
|
14 |
|
|
15 |
Website Baker is distributed in the hope that it will be useful, |
|
16 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
17 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
18 |
GNU General Public License for more details. |
|
19 |
|
|
20 |
You should have received a copy of the GNU General Public License |
|
21 |
along with Website Baker; if not, write to the Free Software |
|
22 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
23 |
|
|
24 |
*/ |
|
25 |
|
|
26 |
require_once("../../../config.php"); |
|
27 |
require_once(WB_PATH.'/include/captcha/captcha.php'); |
|
28 |
|
|
29 |
if(!isset($_SESSION['captcha_time'])) |
|
30 |
exit; |
|
31 |
//unset($_SESSION['captcha_time']); // otherwise there can't be 2 captchas on one page! |
|
32 |
|
|
33 |
// get lists of fonts and backgrounds |
|
34 |
require_once(WB_PATH.'/framework/functions.php'); |
|
35 |
$t_fonts = file_list(WB_PATH.'/include/captcha/fonts'); |
|
36 |
$t_bgs = file_list(WB_PATH.'/include/captcha/backgrounds'); |
|
37 |
$fonts = array(); |
|
38 |
$bgs = array(); |
|
39 |
foreach($t_fonts as $file) if(eregi('\.ttf$',$file)) $fonts[]=$file; |
|
40 |
foreach($t_bgs as $file) if(eregi('\.png$',$file)) $bgs[]=$file; |
|
41 |
|
|
42 |
// Captcha |
|
43 |
$sec_id = ''; |
|
44 |
if(isset($_GET['s'])) $sec_id = $_GET['s']; |
|
45 |
$_SESSION['captcha'.$sec_id] = ''; |
|
46 |
mt_srand((double)microtime()*1000000); |
|
47 |
$n = mt_rand(1,3); |
|
48 |
switch ($n) { |
|
49 |
case 1: |
|
50 |
$x = mt_rand(1,9); |
|
51 |
$y = mt_rand(1,9); |
|
52 |
$_SESSION['captcha'.$sec_id] = $x + $y; |
|
53 |
$cap = "$x+$y"; |
|
54 |
break; |
|
55 |
case 2: |
|
56 |
$x = mt_rand(10,20); |
|
57 |
$y = mt_rand(1,9); |
|
58 |
$_SESSION['captcha'.$sec_id] = $x - $y; |
|
59 |
$cap = "$x-$y"; |
|
60 |
break; |
|
61 |
case 3: |
|
62 |
$x = mt_rand(2,10); |
|
63 |
$y = mt_rand(2,5); |
|
64 |
$_SESSION['captcha'.$sec_id] = $x * $y; |
|
65 |
$cap = "$x*$y"; |
|
66 |
break; |
|
67 |
} |
|
68 |
$text = $cap; |
|
69 |
|
|
70 |
// choose a font and background |
|
71 |
$font = $fonts[array_rand($fonts)]; |
|
72 |
$bg = $bgs[array_rand($bgs)]; |
|
73 |
// get image-dimensions |
|
74 |
list($width, $height, $type, $attr) = getimagesize($bg); |
|
75 |
|
|
76 |
// create reload-image |
|
77 |
$reload = ImageCreateFromPNG(WB_PATH.'/include/captcha/reload_140_40.png'); // reload-overlay |
|
78 |
|
|
79 |
if(mt_rand(0,2)==0) { // 1 out of 3 |
|
80 |
|
|
81 |
// draw each character individualy |
|
82 |
$image = ImageCreateFromPNG($bg); // background image |
|
83 |
$grey = mt_rand(0,50); |
|
84 |
$color = ImageColorAllocate($image, $grey, $grey, $grey); // font-color |
|
85 |
$ttf = $font; |
|
86 |
$ttfsize = 25; // fontsize |
|
87 |
$count = 0; |
|
88 |
$image_failed = true; |
|
89 |
$angle = mt_rand(-10,10); |
|
90 |
$x = mt_rand(20,35); |
|
91 |
$y = mt_rand($height-10,$height-2); |
|
92 |
do { |
|
93 |
for($i=0;$i<strlen($text);$i++) { |
|
94 |
$res = imagettftext($image, $ttfsize, $angle, $x, $y, $color, $ttf, $text{$i}); |
|
95 |
$angle = mt_rand(-10,10); |
|
96 |
$x = mt_rand($res[4],$res[4]+10); |
|
97 |
$y = mt_rand($height-12,$height-7); |
|
98 |
} |
|
99 |
if($res[4] > $width) { |
|
100 |
$image_failed = true; |
|
101 |
} else { |
|
102 |
$image_failed = false; |
|
103 |
} |
|
104 |
if(++$count > 4) // too many tries! Use the image |
|
105 |
break; |
|
106 |
} while($image_failed); |
|
107 |
|
|
108 |
} else { |
|
109 |
|
|
110 |
// draw whole string at once |
|
111 |
$image_failed = true; |
|
112 |
$count=0; |
|
113 |
do { |
|
114 |
$image = ImageCreateFromPNG($bg); // background image |
|
115 |
$grey = mt_rand(0,50); |
|
116 |
$color = ImageColorAllocate($image, $grey, $grey, $grey); // font-color |
|
117 |
$ttf = $font; |
|
118 |
$ttfsize = 25; // fontsize |
|
119 |
$angle = mt_rand(0,5); |
|
120 |
$x = mt_rand(20,35); |
|
121 |
$y = mt_rand($height-10,$height-2); |
|
122 |
$res = imagettftext($image, $ttfsize, $angle, $x, $y, $color, $ttf, $text); |
|
123 |
// check if text fits into the image |
|
124 |
if(($res[0]>0 && $res[0]<$width) && ($res[1]>0 && $res[1]<$height) && |
|
125 |
($res[2]>0 && $res[2]<$width) && ($res[3]>0 && $res[3]<$height) && |
|
126 |
($res[4]>0 && $res[4]<$width) && ($res[5]>0 && $res[5]<$height) && |
|
127 |
($res[6]>0 && $res[6]<$width) && ($res[7]>0 && $res[7]<$height) |
|
128 |
) { |
|
129 |
$image_failed = false; |
|
130 |
} |
|
131 |
if(++$count > 4) // too many tries! Use the image |
|
132 |
break; |
|
133 |
} while($image_failed); |
|
134 |
|
|
135 |
} |
|
136 |
|
|
137 |
imagealphablending($reload, TRUE); |
|
138 |
imagesavealpha($reload, TRUE); |
|
139 |
|
|
140 |
// overlay |
|
141 |
imagecopy($reload, $image, 0,0,0,0, 140,40); |
|
142 |
imagedestroy($image); |
|
143 |
$image = $reload; |
|
144 |
|
|
145 |
captcha_header(); |
|
146 |
ob_start(); |
|
147 |
imagepng($image); |
|
148 |
header("Content-Length: ".ob_get_length()); |
|
149 |
ob_end_flush(); |
|
150 |
imagedestroy($image); |
|
151 |
|
|
150 | 152 |
?> |
branches/2.8.x/wb/include/captcha/captchas/calc_image.php | ||
---|---|---|
28 | 28 |
|
29 | 29 |
if(!isset($_SESSION['captcha_time'])) |
30 | 30 |
exit; |
31 |
unset($_SESSION['captcha_time']); |
|
31 |
//unset($_SESSION['captcha_time']);
|
|
32 | 32 |
|
33 | 33 |
// Captcha |
34 |
$_SESSION['captcha'] = ''; |
|
34 |
$sec_id = ''; |
|
35 |
if(isset($_GET['s'])) $sec_id = $_GET['s']; |
|
36 |
$_SESSION['captcha'.$sec_id] = ''; |
|
35 | 37 |
mt_srand((double)microtime()*1000000); |
36 | 38 |
$n = mt_rand(1,3); |
37 | 39 |
switch ($n) { |
38 | 40 |
case 1: |
39 | 41 |
$x = mt_rand(1,9); |
40 | 42 |
$y = mt_rand(1,9); |
41 |
$_SESSION['captcha'] = $x + $y; |
|
43 |
$_SESSION['captcha'.$sec_id] = $x + $y;
|
|
42 | 44 |
$cap = "$x+$y"; |
43 | 45 |
break; |
44 | 46 |
case 2: |
45 | 47 |
$x = mt_rand(10,20); |
46 | 48 |
$y = mt_rand(1,9); |
47 |
$_SESSION['captcha'] = $x - $y; |
|
49 |
$_SESSION['captcha'.$sec_id] = $x - $y;
|
|
48 | 50 |
$cap = "$x-$y"; |
49 | 51 |
break; |
50 | 52 |
case 3: |
51 | 53 |
$x = mt_rand(2,10); |
52 | 54 |
$y = mt_rand(2,5); |
53 |
$_SESSION['captcha'] = $x * $y; |
|
55 |
$_SESSION['captcha'.$sec_id] = $x * $y;
|
|
54 | 56 |
$cap = "$x*$y"; |
55 | 57 |
break; |
56 | 58 |
} |
branches/2.8.x/wb/include/captcha/captchas/text.php | ||
---|---|---|
31 | 31 |
$file = WB_PATH."/temp/.captcha_$name.php"; |
32 | 32 |
|
33 | 33 |
srand((double)microtime()*100000); |
34 |
$_SESSION['captcha'] = rand(0,99999); |
|
34 |
$_SESSION['captcha'.$sec_id] = rand(0,99999);
|
|
35 | 35 |
|
36 | 36 |
// get questions and answers |
37 | 37 |
$text_qa=''; |
... | ... | |
90 | 90 |
// choose random question |
91 | 91 |
$k = array_rand($qa[$lang]); |
92 | 92 |
|
93 |
$_SESSION['captcha'] = $qa[$lang][$k]; |
|
93 |
$_SESSION['captcha'.$sec_id] = $qa[$lang][$k];
|
|
94 | 94 |
|
95 | 95 |
echo $k; |
96 | 96 |
|
branches/2.8.x/wb/include/captcha/captchas/calc_text.php | ||
---|---|---|
34 | 34 |
require_once(WB_PATH.'/modules/captcha_control/languages/'.LANGUAGE .'.php'); |
35 | 35 |
} |
36 | 36 |
|
37 |
$_SESSION['captcha'] = ''; |
|
37 |
$_SESSION['captcha'.$sec_id] = '';
|
|
38 | 38 |
mt_srand((double)microtime()*1000000); |
39 | 39 |
$n = mt_rand(1,3); |
40 | 40 |
switch ($n) { |
41 | 41 |
case 1: |
42 | 42 |
$x = mt_rand(1,9); |
43 | 43 |
$y = mt_rand(1,9); |
44 |
$_SESSION['captcha'] = $x + $y; |
|
44 |
$_SESSION['captcha'.$sec_id] = $x + $y;
|
|
45 | 45 |
$cap = "$x {$MOD_CAPTCHA['ADDITION']} $y"; |
46 | 46 |
break; |
47 | 47 |
case 2: |
48 | 48 |
$x = mt_rand(10,20); |
49 | 49 |
$y = mt_rand(1,9); |
50 |
$_SESSION['captcha'] = $x - $y; |
|
50 |
$_SESSION['captcha'.$sec_id] = $x - $y;
|
|
51 | 51 |
$cap = "$x {$MOD_CAPTCHA['SUBTRAKTION']} $y"; |
52 | 52 |
break; |
53 | 53 |
case 3: |
54 | 54 |
$x = mt_rand(2,10); |
55 | 55 |
$y = mt_rand(2,5); |
56 |
$_SESSION['captcha'] = $x * $y; |
|
56 |
$_SESSION['captcha'.$sec_id] = $x * $y;
|
|
57 | 57 |
$cap = "$x {$MOD_CAPTCHA['MULTIPLIKATION']} $y"; |
58 | 58 |
break; |
59 | 59 |
} |
60 | 60 |
echo $cap; |
61 |
?> |
|
61 |
?> |
branches/2.8.x/wb/include/captcha/captcha.php | ||
---|---|---|
24 | 24 |
*/ |
25 | 25 |
|
26 | 26 |
// displays the image or text inside an <iframe> |
27 |
function display_captcha_real($kind='image') { |
|
28 |
$t = time(); |
|
29 |
$_SESSION['captcha_time'] = $t; |
|
30 |
if($kind=='image') { |
|
31 |
?><a title="reload" href="<?php echo WB_URL.'/include/captcha/captcha.php?display_captcha_X986E21=2'; ?>"> |
|
32 |
<img style="border: none;" src="<?php echo WB_URL.'/include/captcha/captchas/'.CAPTCHA_TYPE.".php?t=$t"; ?>" alt="Captcha" /> |
|
33 |
</a><?php |
|
34 |
} else { |
|
35 |
echo 'error'; |
|
27 |
if(!function_exists('display_captcha_real')) { |
|
28 |
function display_captcha_real($kind='image') { |
|
29 |
$t = time(); |
|
30 |
$_SESSION['captcha_time'] = $t; |
|
31 |
$sec_id = ''; |
|
32 |
if(isset($_GET['s']) && is_numeric($_GET['s'])) $sec_id = $_GET['s']; |
|
33 |
if($kind=='image') { |
|
34 |
?><a title="reload" href="<?php echo WB_URL.'/include/captcha/captcha.php?display_captcha_X986E21=2'; ?>"> |
|
35 |
<img style="border: none;" src="<?php echo WB_URL.'/include/captcha/captchas/'.CAPTCHA_TYPE.".php?t=$t&s=$sec_id"; ?>" alt="Captcha" /> |
|
36 |
</a><?php |
|
37 |
} else { |
|
38 |
echo 'error'; |
|
39 |
} |
|
36 | 40 |
} |
37 | 41 |
} |
38 | 42 |
|
... | ... | |
70 | 74 |
header("Expires: Mon, 1 Jan 1990 05:00:00 GMT"); |
71 | 75 |
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); |
72 | 76 |
header("Cache-Control: no-store, no-cache, must-revalidate, proxy-revalidate"); |
73 |
header("Cache-Control: post-check=0, pre-check=0", false); // MS made there own headers :-( |
|
74 | 77 |
header("Pragma: no-cache"); |
75 | 78 |
header("Content-type: image/png"); |
76 | 79 |
return; |
... | ... | |
102 | 105 |
} |
103 | 106 |
|
104 | 107 |
if(!function_exists('call_captcha')) { |
105 |
function call_captcha($action='all', $style='') { |
|
108 |
function call_captcha($action='all', $style='', $sec_id='') {
|
|
106 | 109 |
global $MOD_CAPTCHA; |
107 | 110 |
$t = time(); |
108 | 111 |
$_SESSION['captcha_time'] = $t; |
... | ... | |
156 | 159 |
case 'calc_ttf_image': // calculation with varying background and ttf-font |
157 | 160 |
?><table class="captcha_table"><tr> |
158 | 161 |
<td class="image_captcha"> |
159 |
<iframe class="captcha_iframe" width="<?php echo $captcha_width; ?>" height="<?php echo $captcha_height; ?>" scrolling="no" marginheight="0" marginwidth="0" frameborder="0" name="captcha_iframe" src="<?php echo WB_URL.'/include/captcha/captcha.php?display_captcha_X986E21=1'; ?>">
|
|
160 |
<img src="<?php echo WB_URL.'/include/captcha/captchas/'.CAPTCHA_TYPE.".php?t=$t"; ?>" alt="Captcha" /> |
|
162 |
<?php echo "<iframe class=\"captcha_iframe\" width=\"$captcha_width\" height=\"$captcha_height\" scrolling=\"no\" marginheight=\"0\" marginwidth=\"0\" frameborder=\"0\" name=\"captcha_iframe_$sec_id\" src=\"". WB_URL ."/include/captcha/captcha.php?display_captcha_X986E21=1&s=$sec_id"; ?>">
|
|
163 |
<img src="<?php echo WB_URL.'/include/captcha/captchas/'.CAPTCHA_TYPE.".php?t=$t&s=$sec_id"; ?>" alt="Captcha" />
|
|
161 | 164 |
</iframe> |
162 | 165 |
</td> |
163 | 166 |
<td> = </td> |
... | ... | |
170 | 173 |
case 'old_image': // old captcha |
171 | 174 |
?><table class="captcha_table"><tr> |
172 | 175 |
<td class="image_captcha"> |
173 |
<iframe class="captcha_iframe" width="<?php echo $captcha_width; ?>" height="<?php echo $captcha_height; ?>" scrolling="no" marginheight="0" marginwidth="0" frameborder="0" name="captcha_iframe" src="<?php echo WB_URL.'/include/captcha/captcha.php?display_captcha_X986E21=1'; ?>">
|
|
174 |
<img src="<?php echo WB_URL.'/include/captcha/captchas/'.CAPTCHA_TYPE.".php?t=$t"; ?>" alt="Captcha" /> |
|
176 |
<?php echo "<iframe class=\"captcha_iframe\" width=\"$captcha_width\" height=\"$captcha_height\" scrolling=\"no\" marginheight=\"0\" marginwidth=\"0\" frameborder=\"0\" name=\"captcha_iframe_$sec_id\" src=\"". WB_URL ."/include/captcha/captcha.php?display_captcha_X986E21=1&s=$sec_id"; ?>">
|
|
177 |
<img src="<?php echo WB_URL.'/include/captcha/captchas/'.CAPTCHA_TYPE.".php?t=$t&s=$sec_id"; ?>" alt="Captcha" />
|
|
175 | 178 |
</iframe> |
176 | 179 |
</td> |
177 | 180 |
<td></td> |
... | ... | |
192 | 195 |
case 'calc_ttf_image': // calculation with varying background and ttf-font |
193 | 196 |
case 'ttf_image': // captcha with varying background and ttf-font |
194 | 197 |
case 'old_image': // old captcha |
195 |
echo "<img $style src=\"".WB_URL.'/include/captcha/captchas/'.CAPTCHA_TYPE.".php?t=$t\" />"; |
|
198 |
echo "<img $style src=\"".WB_URL.'/include/captcha/captchas/'.CAPTCHA_TYPE.".php?t=$t&s=$sec_id\" />";
|
|
196 | 199 |
break; |
197 | 200 |
} |
198 | 201 |
} elseif($action=='image_iframe') { |
... | ... | |
209 | 212 |
case 'calc_ttf_image': // calculation with varying background and ttf-font |
210 | 213 |
case 'ttf_image': // captcha with varying background and ttf-font |
211 | 214 |
case 'old_image': // old captcha |
212 |
?><iframe class="captcha_iframe" width="<?php echo $captcha_width; ?>" height="<?php echo $captcha_height; ?>" scrolling="no" marginheight="0" marginwidth="0" frameborder="0" name="captcha_iframe" src="<?php echo WB_URL.'/include/captcha/captcha.php?display_captcha_X986E21=1'; ?>"><?php |
|
215 |
?> |
|
216 |
<?php echo "<iframe class=\"captcha_iframe\" width=\"$captcha_width\" height=\"$captcha_height\" scrolling=\"no\" marginheight=\"0\" marginwidth=\"0\" frameborder=\"0\" name=\"captcha_iframe_$sec_id\" src=\"". WB_URL ."/include/captcha/captcha.php?display_captcha_X986E21=1&s=$sec_id"; ?>"> |
|
217 |
<?php |
|
213 | 218 |
echo "<img $style alt=\"Captcha\" src=\"".WB_URL.'/include/captcha/captchas/'.CAPTCHA_TYPE.".php?t=$t\" />"; |
214 | 219 |
?></iframe><?php |
215 | 220 |
break; |
branches/2.8.x/wb/admin/interface/version.php | ||
---|---|---|
51 | 51 |
} |
52 | 52 |
|
53 | 53 |
// check if defined to avoid errors during installation (redirect to admin panel fails if PHP error/warnings are enabled) |
54 |
if(!defined('VERSION')) define('VERSION', '2.8.2.RC3');
|
|
55 |
if(!defined('REVISION')) define('REVISION', '1370');
|
|
54 |
if(!defined('VERSION')) define('VERSION', '2.8.2.RC4');
|
|
55 |
if(!defined('REVISION')) define('REVISION', '1371');
|
|
56 | 56 |
|
57 | 57 |
?> |
Also available in: Unified diff
captcha patch (Tks to FrankH)