Revision 858
Added by thorn about 17 years ago
| trunk/CHANGELOG | ||
|---|---|---|
| 11 | 11 |
! = Update/Change |
| 12 | 12 |
|
| 13 | 13 |
------------------------------------- 2.7.1 ------------------------------------- |
| 14 |
18-Sep-2008 Thomas Hornik |
|
| 15 |
+ Added captcha-reload |
|
| 14 | 16 |
16-Sep-2008 Thomas Hornik |
| 15 | 17 |
# search: fixed windows-related regex issue |
| 16 | 18 |
19-Aug-2008 Matthias Gallas |
| trunk/wb/include/captcha/captchas/ttf_image.php | ||
|---|---|---|
| 62 | 62 |
// get image-dimensions |
| 63 | 63 |
list($width, $height, $type, $attr) = getimagesize($bg); |
| 64 | 64 |
|
| 65 |
// create image |
|
| 66 |
$image = ImageCreateFromPNG($bg); // background image |
|
| 67 |
$grey = mt_rand(0,50); |
|
| 68 |
$color = ImageColorAllocate($image, $grey, $grey, $grey); // font-color |
|
| 69 |
$ttf = $font; |
|
| 70 |
$ttfsize = 25; // fontsize |
|
| 65 |
// create reload-image |
|
| 66 |
$reload = ImageCreateFromPNG(WB_PATH.'/include/captcha/reload_140_40.png'); // reload-overlay |
|
| 71 | 67 |
|
| 72 | 68 |
if(mt_rand(0,2)==0) { // 1 out of 3
|
| 73 | 69 |
|
| 74 | 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 |
|
| 75 | 76 |
$count = 0; |
| 76 | 77 |
$image_failed = true; |
| 77 | 78 |
$angle = mt_rand(-15,15); |
| ... | ... | |
| 122 | 123 |
|
| 123 | 124 |
} |
| 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 |
|
|
| 125 | 134 |
captcha_header(); |
| 126 | 135 |
ob_start(); |
| 127 | 136 |
imagepng($image); |
| trunk/wb/include/captcha/captchas/old_image.php | ||
|---|---|---|
| 34 | 34 |
srand((double)microtime()*100000); |
| 35 | 35 |
$_SESSION['captcha'] = rand(10000,99999); |
| 36 | 36 |
|
| 37 |
// create reload-image |
|
| 38 |
$reload = ImageCreateFromPNG(WB_PATH.'/include/captcha/reload_120_30.png'); // reload-overlay |
|
| 39 |
|
|
| 37 | 40 |
$w=120; |
| 38 | 41 |
$h=30; |
| 39 | 42 |
$image = imagecreate($w, $h); |
| ... | ... | |
| 58 | 61 |
imagestring($image, $fnt, $x, $y, substr($_SESSION['captcha'], $i, 1), $darkgray); |
| 59 | 62 |
} |
| 60 | 63 |
|
| 64 |
imagealphablending($reload, TRUE); |
|
| 65 |
imagesavealpha($reload, TRUE); |
|
| 66 |
|
|
| 67 |
// overlay |
|
| 68 |
imagecopy($reload, $image, 0,0,0,0, 120,30); |
|
| 69 |
imagedestroy($image); |
|
| 70 |
$image = $reload; |
|
| 71 |
|
|
| 61 | 72 |
captcha_header(); |
| 62 | 73 |
ob_start(); |
| 63 | 74 |
imagepng($image); |
| trunk/wb/include/captcha/captchas/calc_ttf_image.php | ||
|---|---|---|
| 71 | 71 |
// get image-dimensions |
| 72 | 72 |
list($width, $height, $type, $attr) = getimagesize($bg); |
| 73 | 73 |
|
| 74 |
// create image |
|
| 75 |
$image = ImageCreateFromPNG($bg); // background image |
|
| 76 |
$grey = mt_rand(0,50); |
|
| 77 |
$color = ImageColorAllocate($image, $grey, $grey, $grey); // font-color |
|
| 78 |
$ttf = $font; |
|
| 79 |
$ttfsize = 25; // fontsize |
|
| 74 |
// create reload-image |
|
| 75 |
$reload = ImageCreateFromPNG(WB_PATH.'/include/captcha/reload_140_40.png'); // reload-overlay |
|
| 80 | 76 |
|
| 81 | 77 |
if(mt_rand(0,2)==0) { // 1 out of 3
|
| 82 | 78 |
|
| 83 | 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 |
|
| 84 | 85 |
$count = 0; |
| 85 | 86 |
$image_failed = true; |
| 86 | 87 |
$angle = mt_rand(-10,10); |
| ... | ... | |
| 111 | 112 |
$image = ImageCreateFromPNG($bg); // background image |
| 112 | 113 |
$grey = mt_rand(0,50); |
| 113 | 114 |
$color = ImageColorAllocate($image, $grey, $grey, $grey); // font-color |
| 115 |
$ttf = $font; |
|
| 116 |
$ttfsize = 25; // fontsize |
|
| 114 | 117 |
$angle = mt_rand(0,5); |
| 115 | 118 |
$x = mt_rand(20,35); |
| 116 | 119 |
$y = mt_rand($height-10,$height-2); |
| ... | ... | |
| 129 | 132 |
|
| 130 | 133 |
} |
| 131 | 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 |
|
|
| 132 | 143 |
captcha_header(); |
| 133 | 144 |
ob_start(); |
| 134 | 145 |
imagepng($image); |
| trunk/wb/include/captcha/captchas/calc_image.php | ||
|---|---|---|
| 55 | 55 |
break; |
| 56 | 56 |
} |
| 57 | 57 |
|
| 58 |
$image = imagecreate(100, 30); |
|
| 58 |
// create reload-image |
|
| 59 |
$reload = ImageCreateFromPNG(WB_PATH.'/include/captcha/reload_120_30.png'); // reload-overlay |
|
| 59 | 60 |
|
| 61 |
$image = imagecreate(120, 30); |
|
| 62 |
|
|
| 60 | 63 |
$white = imagecolorallocate($image, 0xFF, 0xFF, 0xFF); |
| 61 | 64 |
$gray = imagecolorallocate($image, 0xC0, 0xC0, 0xC0); |
| 62 | 65 |
$darkgray = imagecolorallocate($image, 0x30, 0x30, 0x30); |
| 63 | 66 |
|
| 64 | 67 |
for($i = 0; $i < 30; $i++) {
|
| 65 |
$x1 = mt_rand(0,100);
|
|
| 68 |
$x1 = mt_rand(0,120);
|
|
| 66 | 69 |
$y1 = mt_rand(0,30); |
| 67 |
$x2 = mt_rand(0,100);
|
|
| 70 |
$x2 = mt_rand(0,120);
|
|
| 68 | 71 |
$y2 = mt_rand(0,30); |
| 69 | 72 |
imageline($image, $x1, $y1, $x2, $y2 , $gray); |
| 70 | 73 |
} |
| 71 | 74 |
|
| 72 |
$x = 0; |
|
| 75 |
$x = 10;
|
|
| 73 | 76 |
$l = strlen($cap); |
| 74 | 77 |
for($i = 0; $i < $l; $i++) {
|
| 75 | 78 |
$fnt = mt_rand(3,5); |
| ... | ... | |
| 78 | 81 |
imagestring($image, $fnt, $x, $y, substr($cap, $i, 1), $darkgray); |
| 79 | 82 |
} |
| 80 | 83 |
|
| 84 |
imagealphablending($reload, TRUE); |
|
| 85 |
imagesavealpha($reload, TRUE); |
|
| 86 |
|
|
| 87 |
// overlay |
|
| 88 |
imagecopy($reload, $image, 0,0,0,0, 120,30); |
|
| 89 |
imagedestroy($image); |
|
| 90 |
$image = $reload; |
|
| 91 |
|
|
| 81 | 92 |
captcha_header(); |
| 82 | 93 |
imagepng($image); |
| 83 | 94 |
imagedestroy($image); |
| trunk/wb/include/captcha/captchas/calc_text.php | ||
|---|---|---|
| 26 | 26 |
// Must include code to stop this file being accessed directly |
| 27 | 27 |
if(defined('WB_PATH') == false) { exit("Cannot access this file directly"); }
|
| 28 | 28 |
|
| 29 |
if(!file_exists(WB_PATH.'/modules/captcha_control/languages/'.LANGUAGE .'.php')) {
|
|
| 30 |
// no module language file exists for the language set by the user, include default module language file EN.php |
|
| 31 |
require_once(WB_PATH.'/modules/captcha_control/languages/EN.php'); |
|
| 32 |
} else {
|
|
| 33 |
// a module language file exists for the language defined by the user, load it |
|
| 34 |
require_once(WB_PATH.'/modules/captcha_control/languages/'.LANGUAGE .'.php'); |
|
| 35 |
} |
|
| 36 |
|
|
| 29 | 37 |
$_SESSION['captcha'] = ''; |
| 30 | 38 |
mt_srand((double)microtime()*1000000); |
| 31 | 39 |
$n = mt_rand(1,3); |
| ... | ... | |
| 50 | 58 |
break; |
| 51 | 59 |
} |
| 52 | 60 |
echo $cap; |
| 53 |
?> |
|
| 61 |
?> |
|
| trunk/wb/include/captcha/captcha.php | ||
|---|---|---|
| 23 | 23 |
|
| 24 | 24 |
*/ |
| 25 | 25 |
|
| 26 |
// Must include code to stop this file being accessed directly |
|
| 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 |
} elseif($kind=='text') {
|
|
| 35 |
?><a style="text-decoration:none;" title="reload" href="<?php echo WB_URL.'/include/captcha/captcha.php?display_captcha_X986E21=2'; ?>"><?php |
|
| 36 |
include(WB_PATH.'/include/captcha/captchas/'.CAPTCHA_TYPE.'.php'); |
|
| 37 |
?></a><?php |
|
| 38 |
} else {
|
|
| 39 |
echo 'error'; |
|
| 40 |
} |
|
| 41 |
} |
|
| 42 |
|
|
| 43 |
// called from an <iframe> |
|
| 44 |
if(isset($_GET['display_captcha_X986E21'])) {
|
|
| 45 |
require('../../config.php');
|
|
| 46 |
switch(CAPTCHA_TYPE) {
|
|
| 47 |
case 'text': |
|
| 48 |
case 'calc_text': |
|
| 49 |
display_captcha_real('text');
|
|
| 50 |
break; |
|
| 51 |
case 'calc_image': |
|
| 52 |
case 'calc_ttf_image': |
|
| 53 |
case 'ttf_image': |
|
| 54 |
case 'old_image': |
|
| 55 |
display_captcha_real('image');
|
|
| 56 |
break; |
|
| 57 |
} |
|
| 58 |
exit(0); |
|
| 59 |
} |
|
| 60 |
|
|
| 61 |
|
|
| 62 |
// Make sure page cannot be accessed directly |
|
| 27 | 63 |
if(!defined('WB_PATH')) { exit("Cannot access this file directly"); }
|
| 28 | 64 |
|
| 29 | 65 |
// check if module language file exists for the language set by the user (e.g. DE, EN) |
| ... | ... | |
| 78 | 114 |
global $MOD_CAPTCHA; |
| 79 | 115 |
$t = time(); |
| 80 | 116 |
$_SESSION['captcha_time'] = $t; |
| 81 |
|
|
| 117 |
|
|
| 118 |
// get width and height of captcha image or text for use in <iframe> |
|
| 119 |
switch(CAPTCHA_TYPE) {
|
|
| 120 |
case 'text': |
|
| 121 |
$captcha_width = 250; |
|
| 122 |
$captcha_height = 100; |
|
| 123 |
break; |
|
| 124 |
case 'calc_text': |
|
| 125 |
$captcha_width = 120; |
|
| 126 |
$captcha_height = 20; |
|
| 127 |
break; |
|
| 128 |
case 'calc_image': |
|
| 129 |
$captcha_width = 142; |
|
| 130 |
$captcha_height = 30; |
|
| 131 |
break; |
|
| 132 |
case 'calc_ttf_image': |
|
| 133 |
$captcha_width = 162; |
|
| 134 |
$captcha_height = 40; |
|
| 135 |
break; |
|
| 136 |
case 'ttf_image': |
|
| 137 |
$captcha_width = 162; |
|
| 138 |
$captcha_height = 40; |
|
| 139 |
break; |
|
| 140 |
case 'old_image': |
|
| 141 |
$captcha_width = 142; |
|
| 142 |
$captcha_height = 30; |
|
| 143 |
break; |
|
| 144 |
default: |
|
| 145 |
$captcha_width = 250; |
|
| 146 |
$captcha_height = 100; |
|
| 147 |
} |
|
| 148 |
|
|
| 82 | 149 |
if($action=='all') {
|
| 83 | 150 |
switch(CAPTCHA_TYPE) {
|
| 84 | 151 |
// one special case |
| 85 |
case 'text': // text-captcha |
|
| 152 |
case 'text': // text-captcha - we don't use an <iframe> in this case
|
|
| 86 | 153 |
?><table class="captcha_table"><tr> |
| 87 |
<td class="text_captcha"><?php include(WB_PATH.'/include/captcha/captchas/'.CAPTCHA_TYPE.'.php'); ?></td> |
|
| 154 |
<td class="text_captcha"> |
|
| 155 |
<?php include(WB_PATH.'/include/captcha/captchas/'.CAPTCHA_TYPE.'.php'); ?> |
|
| 156 |
</td> |
|
| 157 |
<td></td> |
|
| 88 | 158 |
<td><input type="text" name="captcha" maxlength="50" style="width:150px;" /></td> |
| 89 | 159 |
<td class="captcha_expl"><?php echo $MOD_CAPTCHA['VERIFICATION_INFO_QUEST']; ?></td> |
| 90 | 160 |
</tr></table><?php |
| ... | ... | |
| 92 | 162 |
// two special cases |
| 93 | 163 |
case 'calc_text': // calculation as text |
| 94 | 164 |
?><table class="captcha_table"><tr> |
| 95 |
<td class="text_captcha"><?php include(WB_PATH.'/include/captcha/captchas/'.CAPTCHA_TYPE.'.php'); ?> = </td> |
|
| 165 |
<td class="text_captcha"> |
|
| 166 |
<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'; ?>"> |
|
| 167 |
<?php include(WB_PATH.'/include/captcha/captchas/'.CAPTCHA_TYPE.'.php'); ?> |
|
| 168 |
</iframe> |
|
| 169 |
</td> |
|
| 170 |
<td> = </td> |
|
| 96 | 171 |
<td><input type="text" name="captcha" maxlength="10" style="width:20px;" /></td> |
| 97 | 172 |
<td class="captcha_expl"><?php echo $MOD_CAPTCHA['VERIFICATION_INFO_RES']; ?></td> |
| 98 | 173 |
</tr></table><?php |
| 99 | 174 |
break; |
| 100 | 175 |
case 'calc_image': // calculation with image (old captcha) |
| 101 | 176 |
case 'calc_ttf_image': // calculation with varying background and ttf-font |
| 102 |
?><table class="captcha_table"><tr> |
|
| 103 |
<td class="image_captcha"><img src="<?php echo WB_URL.'/include/captcha/captchas/'.CAPTCHA_TYPE.".php?t=$t"; ?>" alt="Captcha" /></td><td> = </td> |
|
| 177 |
?><table class="captcha_table"><tr> |
|
| 178 |
<td class="image_captcha"> |
|
| 179 |
<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'; ?>"> |
|
| 180 |
<img src="<?php echo WB_URL.'/include/captcha/captchas/'.CAPTCHA_TYPE.".php?t=$t"; ?>" alt="Captcha" /> |
|
| 181 |
</iframe> |
|
| 182 |
</td> |
|
| 183 |
<td> = </td> |
|
| 104 | 184 |
<td><input type="text" name="captcha" maxlength="10" style="width:20px;" /></td> |
| 105 | 185 |
<td class="captcha_expl"><?php echo $MOD_CAPTCHA['VERIFICATION_INFO_RES']; ?></td> |
| 106 | 186 |
</tr></table><?php |
| ... | ... | |
| 109 | 189 |
case 'ttf_image': // captcha with varying background and ttf-font |
| 110 | 190 |
case 'old_image': // old captcha |
| 111 | 191 |
?><table class="captcha_table"><tr> |
| 112 |
<td class="image_captcha"><img src="<?php echo WB_URL.'/include/captcha/captchas/'.CAPTCHA_TYPE.".php?t=$t"; ?>" alt="Captcha" /></td> |
|
| 192 |
<td class="image_captcha"> |
|
| 193 |
<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'; ?>"> |
|
| 194 |
<img src="<?php echo WB_URL.'/include/captcha/captchas/'.CAPTCHA_TYPE.".php?t=$t"; ?>" alt="Captcha" /> |
|
| 195 |
</iframe> |
|
| 196 |
</td> |
|
| 197 |
<td></td> |
|
| 113 | 198 |
<td><input type="text" name="captcha" maxlength="10" style="width:50px;" /></td> |
| 114 | 199 |
<td class="captcha_expl"><?php echo $MOD_CAPTCHA['VERIFICATION_INFO_TEXT']; ?></td> |
| 115 | 200 |
</tr></table><?php |
| ... | ... | |
| 130 | 215 |
echo "<img $style src=\"".WB_URL.'/include/captcha/captchas/'.CAPTCHA_TYPE.".php?t=$t\" />"; |
| 131 | 216 |
break; |
| 132 | 217 |
} |
| 218 |
} elseif($action=='image_iframe') {
|
|
| 219 |
switch(CAPTCHA_TYPE) {
|
|
| 220 |
case 'text': // text-captcha |
|
| 221 |
echo ($style?"<span $style>":''); |
|
| 222 |
include(WB_PATH.'/include/captcha/captchas/'.CAPTCHA_TYPE.'.php'); |
|
| 223 |
echo ($style?'</span>':''); |
|
| 224 |
break; |
|
| 225 |
case 'calc_text': // calculation as text |
|
| 226 |
?><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 |
|
| 227 |
include(WB_PATH.'/include/captcha/captchas/'.CAPTCHA_TYPE.'.php'); |
|
| 228 |
?></iframe><?php |
|
| 229 |
break; |
|
| 230 |
case 'calc_image': // calculation with image (old captcha) |
|
| 231 |
case 'calc_ttf_image': // calculation with varying background and ttf-font |
|
| 232 |
case 'ttf_image': // captcha with varying background and ttf-font |
|
| 233 |
case 'old_image': // old captcha |
|
| 234 |
?><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 |
|
| 235 |
echo "<img $style alt=\"Captcha\" src=\"".WB_URL.'/include/captcha/captchas/'.CAPTCHA_TYPE.".php?t=$t\" />"; |
|
| 236 |
?></iframe><?php |
|
| 237 |
break; |
|
| 238 |
} |
|
| 133 | 239 |
} elseif($action=='input') {
|
| 134 | 240 |
switch(CAPTCHA_TYPE) {
|
| 135 | 241 |
case 'text': // text-captcha |
| ... | ... | |
| 165 | 271 |
} |
| 166 | 272 |
} |
| 167 | 273 |
} |
| 168 |
?> |
|
| 274 |
|
|
Also available in: Unified diff
Added captcha-reload