Index: trunk/CHANGELOG
===================================================================
--- trunk/CHANGELOG	(revision 623)
+++ trunk/CHANGELOG	(revision 624)
@@ -10,7 +10,9 @@
 # = Bugfix
 ! = Update/Change
 
-------------------------------------- 2.7.0 -------------------------------------
+------------------------------------- 2.7.0 -------------------------------------
+28-Jan-2008 Thomas Hornik
++	Added Text-CAPTCHA on request. The captcha-text will be stored in temp/.captcha_text.txt
 27-Jan-2008 Christian Sommer
 !	fixed CSS background color of the installer CSS
 !	replaced static text with variable text from language file
Index: trunk/wb/include/captcha/captchas/text.png
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: trunk/wb/include/captcha/captchas/text.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/text.php
===================================================================
--- trunk/wb/include/captcha/captchas/text.php	(nonexistent)
+++ trunk/wb/include/captcha/captchas/text.php	(revision 624)
@@ -0,0 +1,90 @@
+<?php
+
+// $Id$
+
+/*
+
+ Website Baker Project <http://www.websitebaker.org/>
+ Copyright (C) 2004-2008, Ryan Djurovich
+
+ Website Baker is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ Website Baker is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Website Baker; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+*/
+
+// Must include code to stop this file being accessed directly
+if(defined('WB_PATH') == false) { exit("Cannot access this file directly"); }
+
+$name = 'text';
+$file = WB_PATH."/temp/.captcha_$name.txt";
+
+srand((double)microtime()*100000);
+$_SESSION['captcha'] = rand(0,99999);
+
+// get questions and answers
+$qa = array();
+@$content = file($file);
+if($content===FALSE) {
+	echo '<b>Error</b>: Can not read text! Enter <b>0</b> to solve this captcha';
+	$_SESSION['captcha'] = '0';
+	exit;
+}
+reset($content);
+while($s = current($content)) {
+	// get question
+	$s=trim(rtrim(rtrim($s,"\n"),"\r")); // remove newline
+	if($s=='' OR $s{0}!='?') {
+		next($content);
+		continue;
+	}
+	if(isset($s{3}) && $s{3}==':') {
+		$lang=substr($s,1,2);
+		$q=substr($s,4);
+	}	else {
+		$lang='XX';
+		$q=substr($s,1);
+	}
+	// get answer
+	$s=next($content);
+	$s=trim(rtrim(rtrim($s,"\n"),"\r")); // remove newline
+	if($s{0}!='!') continue;
+	$a=substr($s,1);
+	$qa[$lang][$q]=$a;
+	next($content);
+}
+if($qa == array()) {
+	echo '<b>Error</b>: no text defined! Enter <b>0</b> to solve this captcha';
+	$_SESSION['captcha'] = '0';
+	exit;
+}
+
+// choose language to use
+if(defined('LANGUAGE') && isset($qa[LANGUAGE]))
+	$lang = LANGUAGE;
+else
+	$lang = 'XX';
+if(!isset($qa[$lang])) {
+	echo '<b>Error</b>: no text defined! Enter <b>0</b> to solve this captcha';
+	$_SESSION['captcha'] = '0';
+	exit;
+}
+
+// choose random question
+$k = array_rand($qa[$lang]);
+
+$_SESSION['captcha'] = $qa[$lang][$k];
+
+echo $k;
+
+?>
\ No newline at end of file

Property changes on: trunk/wb/include/captcha/captchas/text.php
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: trunk/wb/include/captcha/captcha.php
===================================================================
--- trunk/wb/include/captcha/captcha.php	(revision 623)
+++ trunk/wb/include/captcha/captcha.php	(revision 624)
@@ -61,17 +61,20 @@
 		'calc_image'=>$MOD_CAPTCHA_CONTROL['CALC_IMAGE'],
 		'calc_ttf_image'=>$MOD_CAPTCHA_CONTROL['CALC_TTF_IMAGE'],
 		'ttf_image'=>$MOD_CAPTCHA_CONTROL['TTF_IMAGE'],
-		'old_image'=>$MOD_CAPTCHA_CONTROL['OLD_IMAGE']
+		'old_image'=>$MOD_CAPTCHA_CONTROL['OLD_IMAGE'],
+		'text'=>$MOD_CAPTCHA_CONTROL['TEXT']
 	);
 } elseif(extension_loaded('gd') && function_exists('imagepng')) {
 	$useable_captchas = array(
 		'calc_text'=>$MOD_CAPTCHA_CONTROL['CALC_TEXT'],
 		'calc_image'=>$MOD_CAPTCHA_CONTROL['CALC_IMAGE'],
-		'old_image'=>$MOD_CAPTCHA_CONTROL['OLD_IMAGE']
+		'old_image'=>$MOD_CAPTCHA_CONTROL['OLD_IMAGE'],
+		'text'=>$MOD_CAPTCHA_CONTROL['TEXT']
 	);
 } else {
 	$useable_captchas = array(
-		'calc_text'=>$MOD_CAPTCHA_CONTROL['CALC_TEXT']
+		'calc_text'=>$MOD_CAPTCHA_CONTROL['CALC_TEXT'],
+		'text'=>$MOD_CAPTCHA_CONTROL['TEXT']
 	);
 }
 
@@ -82,10 +85,18 @@
 		$_SESSION['captcha_time'] = $t;
 	
 		switch(CAPTCHA_TYPE) {
+			// one special case
+			case 'text': // text-captcha
+				?><table class="captcha_table"><tr>
+				<td class="text_captcha"><?php include(WB_PATH.'/include/captcha/captchas/text.php'); ?></td>
+				<td><input type="text" name="captcha" maxlength="10"  style="width:70px" /></td>
+				<td class="captcha_expl"><?php echo $MOD_CAPTCHA['VERIFICATION_INFO_QUEST']; ?></td>
+				</tr></table><?php
+				break;
 			// two special cases
 			case 'calc_text': // calculation as text
 				?><table class="captcha_table"><tr>
-				<td><?php include(WB_PATH.'/include/captcha/captchas/calc_text.php'); ?>&nbsp;=&nbsp;</td>
+				<td class="text_captcha"><?php include(WB_PATH.'/include/captcha/captchas/calc_text.php'); ?>&nbsp;=&nbsp;</td>
 				<td><input type="text" name="captcha" maxlength="5"  style="width:20px" /></td>
 				<td class="captcha_expl"><?php echo $MOD_CAPTCHA['VERIFICATION_INFO_RES']; ?></td>
 				</tr></table><?php
@@ -92,7 +103,7 @@
 				break;
 			case 'calc_image': // calculation with image (old captcha)
 				?><table class="captcha_table"><tr>
-				<td><img src="<?php echo WB_URL."/include/captcha/captchas/calc_image.php?t=$t"; ?>" alt="Captcha" /></td><td>&nbsp;=&nbsp;</td>
+				<td class="image_captcha"><img src="<?php echo WB_URL."/include/captcha/captchas/calc_image.php?t=$t"; ?>" alt="Captcha" /></td><td>&nbsp;=&nbsp;</td>
 				<td><input type="text" name="captcha" maxlength="5" style="width:20px" /></td>
 				<td class="captcha_expl"><?php echo $MOD_CAPTCHA['VERIFICATION_INFO_RES']; ?></td>
 				</tr></table><?php
@@ -102,7 +113,7 @@
 			case 'calc_ttf_image': // calculation with varying background and ttf-font
 			case 'old_image': // old captcha
 				?><table class="captcha_table"><tr>
-				<td><img src="<?php echo WB_URL.'/include/captcha/captchas/'.CAPTCHA_TYPE.".php?t=$t"; ?>" alt="Captcha" /></td>
+				<td class="image_captcha"><img src="<?php echo WB_URL.'/include/captcha/captchas/'.CAPTCHA_TYPE.".php?t=$t"; ?>" alt="Captcha" /></td>
 				<td><input type="text" name="captcha" maxlength="5" style="width:50px" /></td>
 				<td class="captcha_expl"><?php echo $MOD_CAPTCHA['VERIFICATION_INFO_TEXT']; ?></td>
 				</tr></table><?php
Index: trunk/wb/modules/captcha_control/tool.php
===================================================================
--- trunk/wb/modules/captcha_control/tool.php	(revision 623)
+++ trunk/wb/modules/captcha_control/tool.php	(revision 624)
@@ -51,6 +51,15 @@
 		captcha_type = '$captcha_type'
 	");
 
+	// save text-captchas
+	if($_POST['captcha_type'] == 'text') {
+		$text_qa=$admin->add_slashes($_POST['text_qa']);
+		if($fh = fopen(WB_PATH.'/temp/.captcha_text.txt', 'wb')) {
+			fwrite($fh, $text_qa);
+			fclose($fh);
+		}
+	}
+	
 	// check if there is a database error, otherwise say successful
 	if($database->is_error()) {
 		$admin->print_error($database->get_error(), $js_back);
@@ -63,6 +72,17 @@
 	// include captcha-file
 	require_once(WB_PATH .'/include/captcha/captcha.php');
 
+	// load text-captchas
+	$text_qa='';
+	if(file_exists(WB_PATH.'/include/captcha/captchas/text.php')) {
+		if(file_exists(WB_PATH.'/temp/.captcha_text.txt')) {
+			@$content = file(WB_PATH.'/temp/.captcha_text.txt');
+			if($content!==FALSE) {
+				$text_qa = $admin->strip_slashes(implode('', $content));
+			}
+		}
+	}
+
 // script to load image
 ?>
 <script type="text/javascript">
@@ -83,9 +103,22 @@
 	pics["calc_text"] = new Image();
 	pics["calc_text"].src = "<?php echo WB_URL.'/include/captcha/captchas/calc_text.png'?>";
 	
+	pics["text"] = new Image();
+	pics["text"].src = "<?php echo WB_URL.'/include/captcha/captchas/text.png'?>";
+
 	function load_captcha_image() {
 		document.captcha_example.src = pics[document.store_settings.captcha_type.value].src;
+		toggle_text_qa();
 	}
+	
+	function toggle_text_qa() {
+		if(document.store_settings.captcha_type.value == 'text' ) {
+			document.getElementById('text_qa').style.display = '';
+		} else {
+			document.getElementById('text_qa').style.display = 'none';
+		}
+	}
+
 </script>
 <?php
 
@@ -126,6 +159,12 @@
 		</select>
 		</td>
 	</tr>
+	<tr id="text_qa" style="display:<?php if($captcha_type=='text') echo ''; else echo 'none'; ;?>;">
+		<td class="setting_name"><?php echo $MOD_CAPTCHA_CONTROL['CAPTCHA_ENTER_TEXT'];?>:</td>
+		<td class="setting_value" colspan="2">
+			<textarea name="text_qa" wrap="off" cols="50" rows="10"><?php echo $text_qa; ?></textarea>
+		</td>
+	</tr>
 	<tr>
 		<td><?php echo $MOD_CAPTCHA_CONTROL['USE_SIGNUP_CAPTCHA'];?>:</td>
 		<td>
Index: trunk/wb/modules/captcha_control/languages/EN.php
===================================================================
--- trunk/wb/modules/captcha_control/languages/EN.php	(revision 623)
+++ trunk/wb/modules/captcha_control/languages/EN.php	(revision 624)
@@ -39,12 +39,14 @@
 $MOD_CAPTCHA_CONTROL['DISABLED']          = 'Disabled';
 $MOD_CAPTCHA_CONTROL['ASP_CONF']          = 'Advanced Spam Protection Configuration';
 $MOD_CAPTCHA_CONTROL['ASP_TEXT']          = 'Activate ASP (if available)';
-$MOD_CAPTCHA_CONTROL['ASP_EXP']           = 'ASP tries to determine if a form-inputs was originated from a human or a spam-bot.';
-$MOD_CAPTCHA_CONTROL['CALC_TEXT']         = "Calculation as text";
-$MOD_CAPTCHA_CONTROL['CALC_IMAGE']        = "Calculation as image";
-$MOD_CAPTCHA_CONTROL['CALC_TTF_IMAGE']    = "Calculation as image with varying fonts and backgrounds"; 
-$MOD_CAPTCHA_CONTROL['TTF_IMAGE']         = "Image with varying fonts and backgrounds";
-$MOD_CAPTCHA_CONTROL['OLD_IMAGE']         = "Old style (not recommended)";
+$MOD_CAPTCHA_CONTROL['ASP_EXP']           = 'ASP tries to determine if a form-input was originated from a human or a spam-bot.';
+$MOD_CAPTCHA_CONTROL['CALC_TEXT']         = 'Calculation as text';
+$MOD_CAPTCHA_CONTROL['CALC_IMAGE']        = 'Calculation as image';
+$MOD_CAPTCHA_CONTROL['CALC_TTF_IMAGE']    = 'Calculation as image with varying fonts and backgrounds'; 
+$MOD_CAPTCHA_CONTROL['TTF_IMAGE']         = 'Image with varying fonts and backgrounds';
+$MOD_CAPTCHA_CONTROL['OLD_IMAGE']         = 'Old style (not recommended)';
+$MOD_CAPTCHA_CONTROL['TEXT']              = 'Text-CAPTCHA';
+$MOD_CAPTCHA_CONTROL['CAPTCHA_ENTER_TEXT']= 'Questions and Answers';
 
 $MOD_CAPTCHA['VERIFICATION']           = 'Verification';
 $MOD_CAPTCHA['ADDITION']               = 'add';
@@ -52,6 +54,7 @@
 $MOD_CAPTCHA['MULTIPLIKATION']         = 'multiply';
 $MOD_CAPTCHA['VERIFICATION_INFO_RES']  = 'Fill in the result';
 $MOD_CAPTCHA['VERIFICATION_INFO_TEXT'] = 'Fill in the text';
+$MOD_CAPTCHA['VERIFICATION_INFO_QUEST'] = 'Answer the question';
 $MOD_CAPTCHA['INCORRECT_VERIFICATION'] = 'Verification failed';
 
 ?>
\ No newline at end of file
Index: trunk/wb/modules/captcha_control/languages/DE.php
===================================================================
--- trunk/wb/modules/captcha_control/languages/DE.php	(revision 623)
+++ trunk/wb/modules/captcha_control/languages/DE.php	(revision 624)
@@ -43,11 +43,13 @@
 $MOD_CAPTCHA_CONTROL['ASP_CONF']          = 'Erweiterter-Spam-Schutz (ASP) Einstellungen';
 $MOD_CAPTCHA_CONTROL['ASP_TEXT']          = 'ASP benutzen (wenn im Modul vorhanden)';
 $MOD_CAPTCHA_CONTROL['ASP_EXP']           = 'ASP versucht anhand der verschiedenen Verhaltensweisen zu erkennen, ob eine Formular-Eingabe von einem Menschen oder einem Spam-Bot kommt.';
-$MOD_CAPTCHA_CONTROL['CALC_TEXT']         = "Rechnung als Text";
-$MOD_CAPTCHA_CONTROL['CALC_IMAGE']        = "Rechnung als Bild";
-$MOD_CAPTCHA_CONTROL['CALC_TTF_IMAGE']    = "Rechnung als Bild mit wechselnden Schriften und Hintergr&uuml;nden";
-$MOD_CAPTCHA_CONTROL['TTF_IMAGE']         = "Bild mit wechselnden Schriften und Hintergr&uuml;nden";
-$MOD_CAPTCHA_CONTROL['OLD_IMAGE']         = "Alter Stil (nicht empfohlen)";
+$MOD_CAPTCHA_CONTROL['CALC_TEXT']         = 'Rechnung als Text';
+$MOD_CAPTCHA_CONTROL['CALC_IMAGE']        = 'Rechnung als Bild';
+$MOD_CAPTCHA_CONTROL['CALC_TTF_IMAGE']    = 'Rechnung als Bild mit wechselnden Schriften und Hintergr&uuml;nden';
+$MOD_CAPTCHA_CONTROL['TTF_IMAGE']         = 'Bild mit wechselnden Schriften und Hintergr&uuml;nden';
+$MOD_CAPTCHA_CONTROL['OLD_IMAGE']         = 'Alter Stil (nicht empfohlen)';
+$MOD_CAPTCHA_CONTROL['TEXT']              = 'Text-CAPTCHA';
+$MOD_CAPTCHA_CONTROL['CAPTCHA_ENTER_TEXT']= 'Fragen und Antworten';
 
 $MOD_CAPTCHA['VERIFICATION']           = 'Pr&uuml;fziffer';
 $MOD_CAPTCHA['ADDITION']               = 'plus';
@@ -55,6 +57,7 @@
 $MOD_CAPTCHA['MULTIPLIKATION']         = 'mal';
 $MOD_CAPTCHA['VERIFICATION_INFO_RES']  = 'Bitte Ergebnis eintragen';
 $MOD_CAPTCHA['VERIFICATION_INFO_TEXT'] = 'Bitte Text eintragen';
+$MOD_CAPTCHA['VERIFICATION_INFO_QUEST'] = 'Bitte Frage beantworten';
 $MOD_CAPTCHA['INCORRECT_VERIFICATION'] = 'Ergebnis ist falsch. Bitte neu eintragen';
 
 ?>
\ No newline at end of file
