Index: trunk/CHANGELOG
===================================================================
--- trunk/CHANGELOG	(revision 857)
+++ trunk/CHANGELOG	(revision 858)
@@ -11,6 +11,8 @@
 ! = Update/Change
 
 ------------------------------------- 2.7.1 -------------------------------------
+18-Sep-2008 Thomas Hornik
++ Added captcha-reload
 16-Sep-2008 Thomas Hornik
 # search: fixed windows-related regex issue
 19-Aug-2008 Matthias Gallas
Index: trunk/wb/include/captcha/reload_140_40.png
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: trunk/wb/include/captcha/reload_140_40.png
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: trunk/wb/include/captcha/captchas/ttf_image.php
===================================================================
--- trunk/wb/include/captcha/captchas/ttf_image.php	(revision 857)
+++ trunk/wb/include/captcha/captchas/ttf_image.php	(revision 858)
@@ -62,16 +62,17 @@
 // get image-dimensions
 list($width, $height, $type, $attr) = getimagesize($bg);
 
-// create image
-$image = ImageCreateFromPNG($bg); // background image
-$grey = mt_rand(0,50);
-$color = ImageColorAllocate($image, $grey, $grey, $grey); // font-color
-$ttf = $font;
-$ttfsize = 25; // fontsize
+// create reload-image
+$reload = ImageCreateFromPNG(WB_PATH.'/include/captcha/reload_140_40.png'); // reload-overlay
 
 if(mt_rand(0,2)==0) { // 1 out of 3
 
 	// draw each character individualy
+	$image = ImageCreateFromPNG($bg); // background image
+	$grey = mt_rand(0,50);
+	$color = ImageColorAllocate($image, $grey, $grey, $grey); // font-color
+	$ttf = $font;
+	$ttfsize = 25; // fontsize
 	$count = 0;
 	$image_failed = true;
 	$angle = mt_rand(-15,15);
@@ -122,6 +123,14 @@
 	
 }
 
+imagealphablending($reload, TRUE);
+imagesavealpha($reload, TRUE);
+
+// overlay
+imagecopy($reload, $image, 0,0,0,0, 140,40);
+imagedestroy($image);
+$image = $reload;
+
 captcha_header();
 ob_start();
 imagepng($image);
Index: trunk/wb/include/captcha/captchas/old_image.php
===================================================================
--- trunk/wb/include/captcha/captchas/old_image.php	(revision 857)
+++ trunk/wb/include/captcha/captchas/old_image.php	(revision 858)
@@ -34,6 +34,9 @@
 srand((double)microtime()*100000);
 $_SESSION['captcha'] = rand(10000,99999);
 
+// create reload-image
+$reload = ImageCreateFromPNG(WB_PATH.'/include/captcha/reload_120_30.png'); // reload-overlay
+
 $w=120;
 $h=30;
 $image = imagecreate($w, $h);
@@ -58,6 +61,14 @@
 	imagestring($image, $fnt, $x, $y, substr($_SESSION['captcha'], $i, 1), $darkgray); 
 }
 
+imagealphablending($reload, TRUE);
+imagesavealpha($reload, TRUE);
+
+// overlay
+imagecopy($reload, $image, 0,0,0,0, 120,30);
+imagedestroy($image);
+$image = $reload;
+
 captcha_header();
 ob_start();
 imagepng($image);
Index: trunk/wb/include/captcha/captchas/calc_ttf_image.php
===================================================================
--- trunk/wb/include/captcha/captchas/calc_ttf_image.php	(revision 857)
+++ trunk/wb/include/captcha/captchas/calc_ttf_image.php	(revision 858)
@@ -71,16 +71,17 @@
 // get image-dimensions
 list($width, $height, $type, $attr) = getimagesize($bg);
 
-// create image
-$image = ImageCreateFromPNG($bg); // background image
-$grey = mt_rand(0,50);
-$color = ImageColorAllocate($image, $grey, $grey, $grey); // font-color
-$ttf = $font;
-$ttfsize = 25; // fontsize
+// create reload-image
+$reload = ImageCreateFromPNG(WB_PATH.'/include/captcha/reload_140_40.png'); // reload-overlay
 
 if(mt_rand(0,2)==0) { // 1 out of 3
 
 	// draw each character individualy
+	$image = ImageCreateFromPNG($bg); // background image
+	$grey = mt_rand(0,50);
+	$color = ImageColorAllocate($image, $grey, $grey, $grey); // font-color
+	$ttf = $font;
+	$ttfsize = 25; // fontsize
 	$count = 0;
 	$image_failed = true;
 	$angle = mt_rand(-10,10);
@@ -111,6 +112,8 @@
 		$image = ImageCreateFromPNG($bg); // background image
 		$grey = mt_rand(0,50);
 		$color = ImageColorAllocate($image, $grey, $grey, $grey); // font-color
+		$ttf = $font;
+		$ttfsize = 25; // fontsize
 		$angle = mt_rand(0,5);
 		$x = mt_rand(20,35);
 		$y = mt_rand($height-10,$height-2);
@@ -129,6 +132,14 @@
 	
 }
 
+imagealphablending($reload, TRUE);
+imagesavealpha($reload, TRUE);
+
+// overlay
+imagecopy($reload, $image, 0,0,0,0, 140,40);
+imagedestroy($image);
+$image = $reload;
+
 captcha_header();
 ob_start();
 imagepng($image);
Index: trunk/wb/include/captcha/captchas/calc_image.php
===================================================================
--- trunk/wb/include/captcha/captchas/calc_image.php	(revision 857)
+++ trunk/wb/include/captcha/captchas/calc_image.php	(revision 858)
@@ -55,21 +55,24 @@
 		break;
 }
 
-$image = imagecreate(100, 30);
+// create reload-image
+$reload = ImageCreateFromPNG(WB_PATH.'/include/captcha/reload_120_30.png'); // reload-overlay
 
+$image = imagecreate(120, 30);
+
 $white = imagecolorallocate($image, 0xFF, 0xFF, 0xFF);
 $gray = imagecolorallocate($image, 0xC0, 0xC0, 0xC0);
 $darkgray = imagecolorallocate($image, 0x30, 0x30, 0x30);
 
 for($i = 0; $i < 30; $i++) {
-	$x1 = mt_rand(0,100);
+	$x1 = mt_rand(0,120);
 	$y1 = mt_rand(0,30);
-	$x2 = mt_rand(0,100);
+	$x2 = mt_rand(0,120);
 	$y2 = mt_rand(0,30);
 	imageline($image, $x1, $y1, $x2, $y2 , $gray);  
 }
 
-$x = 0;
+$x = 10;
 $l = strlen($cap);
 for($i = 0; $i < $l; $i++) {
 	$fnt = mt_rand(3,5);
@@ -78,6 +81,14 @@
 	imagestring($image, $fnt, $x, $y, substr($cap, $i, 1), $darkgray); 
 }
 
+imagealphablending($reload, TRUE);
+imagesavealpha($reload, TRUE);
+
+// overlay
+imagecopy($reload, $image, 0,0,0,0, 120,30);
+imagedestroy($image);
+$image = $reload;
+
 captcha_header();
 imagepng($image);
 imagedestroy($image);
Index: trunk/wb/include/captcha/captchas/calc_text.php
===================================================================
--- trunk/wb/include/captcha/captchas/calc_text.php	(revision 857)
+++ trunk/wb/include/captcha/captchas/calc_text.php	(revision 858)
@@ -26,6 +26,14 @@
 // Must include code to stop this file being accessed directly
 if(defined('WB_PATH') == false) { exit("Cannot access this file directly"); }
 
+if(!file_exists(WB_PATH.'/modules/captcha_control/languages/'.LANGUAGE .'.php')) {
+	// no module language file exists for the language set by the user, include default module language file EN.php
+	require_once(WB_PATH.'/modules/captcha_control/languages/EN.php');
+} else {
+	// a module language file exists for the language defined by the user, load it
+	require_once(WB_PATH.'/modules/captcha_control/languages/'.LANGUAGE .'.php');
+}
+
 $_SESSION['captcha'] = '';
 mt_srand((double)microtime()*1000000);
 $n = mt_rand(1,3);
@@ -50,4 +58,4 @@
 		break;
 }
 echo $cap;
-?>
\ No newline at end of file
+?>
Index: trunk/wb/include/captcha/captcha.php
===================================================================
--- trunk/wb/include/captcha/captcha.php	(revision 857)
+++ trunk/wb/include/captcha/captcha.php	(revision 858)
@@ -23,7 +23,43 @@
 
 */
 
-// Must include code to stop this file being accessed directly
+// displays the image or text inside an <iframe>
+function display_captcha_real($kind='image') {
+	$t = time();
+	$_SESSION['captcha_time'] = $t;
+	if($kind=='image') {
+		?><a title="reload" href="<?php echo WB_URL.'/include/captcha/captcha.php?display_captcha_X986E21=2'; ?>">
+		  <img style="border: none;" src="<?php echo WB_URL.'/include/captcha/captchas/'.CAPTCHA_TYPE.".php?t=$t"; ?>" alt="Captcha" />
+			</a><?php
+	} elseif($kind=='text') {
+		?><a style="text-decoration:none;" title="reload" href="<?php echo WB_URL.'/include/captcha/captcha.php?display_captcha_X986E21=2'; ?>"><?php
+		include(WB_PATH.'/include/captcha/captchas/'.CAPTCHA_TYPE.'.php');
+		?></a><?php
+	} else {
+		echo 'error';
+	}
+}
+
+// called from an <iframe>
+if(isset($_GET['display_captcha_X986E21'])) {
+	require('../../config.php');
+	switch(CAPTCHA_TYPE) {
+	case 'text':
+	case 'calc_text':
+		display_captcha_real('text');
+		break;
+	case 'calc_image':
+	case 'calc_ttf_image':
+	case 'ttf_image':
+	case 'old_image':
+		display_captcha_real('image');
+		break;
+	}
+	exit(0);
+}
+
+
+// Make sure page cannot be accessed directly
 if(!defined('WB_PATH')) { exit("Cannot access this file directly"); }
 
 // check if module language file exists for the language set by the user (e.g. DE, EN)
@@ -78,13 +114,47 @@
 		global $MOD_CAPTCHA;
 		$t = time();
 		$_SESSION['captcha_time'] = $t;
-		
+
+		// get width and height of captcha image or text for use in <iframe>
+		switch(CAPTCHA_TYPE) {
+		case 'text':
+			$captcha_width = 250;
+			$captcha_height = 100;
+			break;
+		case 'calc_text':
+			$captcha_width = 120;
+			$captcha_height = 20;
+			break;
+		case 'calc_image':
+			$captcha_width = 142;
+			$captcha_height = 30;
+			break;
+		case 'calc_ttf_image':
+			$captcha_width = 162;
+			$captcha_height = 40;
+			break;
+		case 'ttf_image':
+			$captcha_width = 162;
+			$captcha_height = 40;
+			break;
+		case 'old_image':
+			$captcha_width = 142;
+			$captcha_height = 30;
+			break;
+		default:
+			$captcha_width = 250;
+			$captcha_height = 100;
+		}
+
 		if($action=='all') {
 			switch(CAPTCHA_TYPE) {
 				// one special case
-				case 'text': // text-captcha
+				case 'text': // text-captcha - we don't use an <iframe> in this case
 					?><table class="captcha_table"><tr>
-					<td class="text_captcha"><?php include(WB_PATH.'/include/captcha/captchas/'.CAPTCHA_TYPE.'.php'); ?></td>
+					<td class="text_captcha">
+						<?php include(WB_PATH.'/include/captcha/captchas/'.CAPTCHA_TYPE.'.php'); ?>
+					</td>
+					<td></td>
 					<td><input type="text" name="captcha" maxlength="50"  style="width:150px;" /></td>
 					<td class="captcha_expl"><?php echo $MOD_CAPTCHA['VERIFICATION_INFO_QUEST']; ?></td>
 					</tr></table><?php
@@ -92,7 +162,12 @@
 				// two special cases
 				case 'calc_text': // calculation as text
 					?><table class="captcha_table"><tr>
-					<td class="text_captcha"><?php include(WB_PATH.'/include/captcha/captchas/'.CAPTCHA_TYPE.'.php'); ?>&nbsp;=&nbsp;</td>
+					<td class="text_captcha">
+						<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 include(WB_PATH.'/include/captcha/captchas/'.CAPTCHA_TYPE.'.php'); ?>
+						</iframe>
+					</td>
+					<td>&nbsp;=&nbsp;</td>
 					<td><input type="text" name="captcha" maxlength="10"  style="width:20px;" /></td>
 					<td class="captcha_expl"><?php echo $MOD_CAPTCHA['VERIFICATION_INFO_RES']; ?></td>
 					</tr></table><?php
@@ -99,8 +174,13 @@
 					break;
 				case 'calc_image': // calculation with image (old captcha)
 				case 'calc_ttf_image': // calculation with varying background and ttf-font
-					?><table class="captcha_table"><tr>
-					<td class="image_captcha"><img src="<?php echo WB_URL.'/include/captcha/captchas/'.CAPTCHA_TYPE.".php?t=$t"; ?>" alt="Captcha" /></td><td>&nbsp;=&nbsp;</td>
+				  ?><table class="captcha_table"><tr>
+					<td class="image_captcha">
+						<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'; ?>">
+						<img src="<?php echo WB_URL.'/include/captcha/captchas/'.CAPTCHA_TYPE.".php?t=$t"; ?>" alt="Captcha" />
+						</iframe>
+					</td>
+					<td>&nbsp;=&nbsp;</td>
 					<td><input type="text" name="captcha" maxlength="10" style="width:20px;" /></td>
 					<td class="captcha_expl"><?php echo $MOD_CAPTCHA['VERIFICATION_INFO_RES']; ?></td>
 					</tr></table><?php
@@ -109,7 +189,12 @@
 				case 'ttf_image': // captcha with varying background and ttf-font
 				case 'old_image': // old captcha
 					?><table class="captcha_table"><tr>
-					<td class="image_captcha"><img src="<?php echo WB_URL.'/include/captcha/captchas/'.CAPTCHA_TYPE.".php?t=$t"; ?>" alt="Captcha" /></td>
+					<td class="image_captcha">
+						<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'; ?>">
+						<img src="<?php echo WB_URL.'/include/captcha/captchas/'.CAPTCHA_TYPE.".php?t=$t"; ?>" alt="Captcha" />
+						</iframe>
+					</td>
+					<td></td>
 					<td><input type="text" name="captcha" maxlength="10" style="width:50px;" /></td>
 					<td class="captcha_expl"><?php echo $MOD_CAPTCHA['VERIFICATION_INFO_TEXT']; ?></td>
 					</tr></table><?php
@@ -130,6 +215,27 @@
 					echo "<img $style src=\"".WB_URL.'/include/captcha/captchas/'.CAPTCHA_TYPE.".php?t=$t\" />";
 					break;
 			}
+		} elseif($action=='image_iframe') {
+			switch(CAPTCHA_TYPE) {
+				case 'text': // text-captcha
+					echo ($style?"<span $style>":'');
+					include(WB_PATH.'/include/captcha/captchas/'.CAPTCHA_TYPE.'.php');
+					echo ($style?'</span>':'');
+					break;
+				case 'calc_text': // calculation as text
+					?><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
+					include(WB_PATH.'/include/captcha/captchas/'.CAPTCHA_TYPE.'.php');
+					?></iframe><?php
+					break;
+				case 'calc_image': // calculation with image (old captcha)
+				case 'calc_ttf_image': // calculation with varying background and ttf-font
+				case 'ttf_image': // captcha with varying background and ttf-font
+				case 'old_image': // old captcha
+					?><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
+					echo "<img $style alt=\"Captcha\" src=\"".WB_URL.'/include/captcha/captchas/'.CAPTCHA_TYPE.".php?t=$t\" />";
+					?></iframe><?php
+					break;
+			}
 		} elseif($action=='input') {
 			switch(CAPTCHA_TYPE) {
 				case 'text': // text-captcha
@@ -165,4 +271,4 @@
 		}
 	}
 }
-?>
+
Index: trunk/wb/include/captcha/reload_120_30.png
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: trunk/wb/include/captcha/reload_120_30.png
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
