Index: trunk/CHANGELOG
===================================================================
--- trunk/CHANGELOG	(revision 608)
+++ trunk/CHANGELOG	(revision 609)
@@ -10,7 +10,10 @@
 # = Bugfix
 ! = Update/Change
 
-------------------------------------- 2.7.0 -------------------------------------
+------------------------------------- 2.7.0 -------------------------------------
+27-Jan-2008 Thomas Hornik
++	Added preview-images for CAPTCHA.
+!	Improved security: CAPTCHAS can't be loaded from outside WB
 26-Jan-2008 Christian Sommer
 !	changed WYSIWYG content field from text to longtext (allows more than 65'534 characters) 
 +	Added Javascript Admin module (developed by Stepan Riha, adapted for WB2.7 by Swen Uth)
Index: trunk/wb/include/captcha/captchas/ttf_image.png
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: trunk/wb/include/captcha/captchas/ttf_image.png
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: trunk/wb/include/captcha/captchas/old_image.png
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: trunk/wb/include/captcha/captchas/old_image.png
___________________________________________________________________
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 608)
+++ trunk/wb/include/captcha/captchas/ttf_image.php	(revision 609)
@@ -26,6 +26,10 @@
 require_once("../../../config.php");
 require_once(WB_PATH.'/include/captcha/captcha.php');
 
+if(!isset($_SESSION['captcha_time']))
+	exit;
+unset($_SESSION['captcha_time']);
+
 // get lists of fonts and backgrounds
 require_once(WB_PATH.'/search/search_modext.php');
 list($fonts, $dirs) = list_files_dirs(WB_PATH.'/include/captcha/fonts', false);
Index: trunk/wb/include/captcha/captchas/old_image.php
===================================================================
--- trunk/wb/include/captcha/captchas/old_image.php	(revision 608)
+++ trunk/wb/include/captcha/captchas/old_image.php	(revision 609)
@@ -26,6 +26,10 @@
 require_once("../../../config.php");
 require_once(WB_PATH.'/include/captcha/captcha.php');
 
+if(!isset($_SESSION['captcha_time']))
+	exit;
+unset($_SESSION['captcha_time']);
+
 // Captcha
 srand((double)microtime()*100000);
 $_SESSION['captcha'] = rand(10000,99999);
Index: trunk/wb/include/captcha/captchas/calc_image.png
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: trunk/wb/include/captcha/captchas/calc_image.png
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: trunk/wb/include/captcha/captchas/calc_text.png
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: trunk/wb/include/captcha/captchas/calc_text.png
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: trunk/wb/include/captcha/captchas/calc_image.php
===================================================================
--- trunk/wb/include/captcha/captchas/calc_image.php	(revision 608)
+++ trunk/wb/include/captcha/captchas/calc_image.php	(revision 609)
@@ -26,6 +26,10 @@
 require_once("../../../config.php");
 require_once(WB_PATH.'/include/captcha/captcha.php');
 
+if(!isset($_SESSION['captcha_time']))
+	exit;
+unset($_SESSION['captcha_time']);
+
 // Captcha
 $_SESSION['captcha'] = '';
 mt_srand((double)microtime()*100000);
Index: trunk/wb/include/captcha/captcha.php
===================================================================
--- trunk/wb/include/captcha/captcha.php	(revision 608)
+++ trunk/wb/include/captcha/captcha.php	(revision 609)
@@ -88,7 +88,9 @@
 if(!function_exists('call_captcha')) {
 	function call_captcha() {
 		global $MOD_CAPTCHA;
-
+		$t = time();
+		$_SESSION['captcha_time'] = $t;
+	
 		switch(CAPTCHA_TYPE) {
 			// two special cases
 			case 'calc_text': // calculation as text
@@ -99,7 +101,7 @@
 				break;
 			case 'calc_image': // calculation with image (old captcha)
 				?>
-				<img src="<?php echo WB_URL.'/include/captcha/captchas/calc_image.php?t='.time(); ?>" align="middle" alt="Captcha" /> = 
+				<img src="<?php echo WB_URL."/include/captcha/captchas/calc_image.php?t=$t"; ?>" align="middle" alt="Captcha" /> = 
 				<input type="text" name="captcha" maxlength="5" style="width:20px" />&nbsp;&nbsp;<?php echo $MOD_CAPTCHA['VERIFICATION_INFO_RES']; ?></font>
 				<?php
 				break;
@@ -107,7 +109,7 @@
 			case 'ttf_image': // captcha with varying background and ttf-font
 			case 'old_image': // old captcha
 				?>
-				<img src="<?php echo WB_URL.'/include/captcha/captchas/'.CAPTCHA_TYPE.'.php?t='.time(); ?>" align="middle" alt="Captcha" />
+				<img src="<?php echo WB_URL.'/include/captcha/captchas/'.CAPTCHA_TYPE.".php?t=$t"; ?>" align="middle" alt="Captcha" />
 				<input type="text" name="captcha" maxlength="5" style="width:50px" />&nbsp;&nbsp;<?php echo $MOD_CAPTCHA['VERIFICATION_INFO_TEXT']; ?></font>
 				<?php
 				break;
Index: trunk/wb/modules/captcha_control/tool.php
===================================================================
--- trunk/wb/modules/captcha_control/tool.php	(revision 608)
+++ trunk/wb/modules/captcha_control/tool.php	(revision 609)
@@ -63,6 +63,26 @@
 	// include captcha-file
 	require_once(WB_PATH .'/include/captcha/captcha.php');
 
+// script to load image
+?>
+<script type="text/javascript">
+	var pics = new Array();
+
+	pics["ttf_image"] = new Image();
+	pics["ttf_image"].src = "<?php echo WB_URL.'/include/captcha/captchas/ttf_image.png'?>";
+
+	pics["calc_image"] = new Image();
+	pics["calc_image"].src = "<?php echo WB_URL.'/include/captcha/captchas/calc_image.png'?>";
+	
+	pics["old_image"] = new Image();
+	pics["old_image"].src = "<?php echo WB_URL.'/include/captcha/captchas/old_image.png'?>";
+	
+	pics["calc_text"] = new Image();
+	pics["calc_text"].src = "<?php echo WB_URL.'/include/captcha/captchas/calc_text.png'?>";
+
+</script>
+<?php
+
 	// connect to database and read out captcha settings
 	if($query = $database->query("SELECT * FROM $table")) {
 		$data = $query->fetchRow();
@@ -85,10 +105,15 @@
 <form name="store_settings" action="<?php echo $_SERVER['REQUEST_URI']; ?>" method="post">
 	<table width="98%" cellspacing="0" cellpadding="5px" class="row_a">
 	<tr><td colspan="2"><strong><?php echo $MOD_CAPTCHA_CONTROL['CAPTCHA_CONF'];?>:</strong></td></tr>
-	<tr>
-		<td width="35%"><?php echo $MOD_CAPTCHA_CONTROL['CAPTCHA_TYPE'];?>:</td>
+	<tr><td>
+		<table>
+			<tr height="50px">
+			<td><?php echo $MOD_CAPTCHA_CONTROL['CAPTCHA_TYPE'];?>:</td>
+			<td align="right" width="150px"><img name="captcha_example" id="captcha_example" src="<?php echo WB_URL.'/include/captcha/captchas/calc_text.png'?>" onload="javascript: document.captcha_example.src = pics[document.store_settings.captcha_type.value].src;"></td>
+			</tr>
+		</table>
 		<td>
-			<select name="captcha_type" id="captcha_type" style="width: 98%;">
+			<select name="captcha_type" id="captcha_type" onchange="load_captcha_image()" style="width: 98%;">
 			<?php foreach($useable_captchas AS $key=>$text) {
 				echo "<option value=\"$key\" ".($captcha_type==$key?'selected':'').">$text</option>";
 			} ?>
