Index: trunk/CHANGELOG
===================================================================
--- trunk/CHANGELOG	(revision 609)
+++ trunk/CHANGELOG	(revision 610)
@@ -13,7 +13,8 @@
 ------------------------------------- 2.7.0 -------------------------------------
 27-Jan-2008 Thomas Hornik
 +	Added preview-images for CAPTCHA.
-!	Improved security: CAPTCHAS can't be loaded from outside WB
+!	Improved security: CAPTCHAS can't be loaded from outside WB
+!	CAPTCHA ttf_image: added variant. Adjusted character-pool and one background for better readability.
 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/backgrounds/bg_04a.png
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: trunk/wb/include/captcha/captchas/ttf_image.php
===================================================================
--- trunk/wb/include/captcha/captchas/ttf_image.php	(revision 609)
+++ trunk/wb/include/captcha/captchas/ttf_image.php	(revision 610)
@@ -43,7 +43,7 @@
 		list($usec, $sec) = explode(' ', microtime());
 		srand((float)$sec + ((float)$usec * 100000));
 		//$possible="ABCDEFGHJKLMNPRSTUVWXYZabcdefghkmnpqrstuvwxyz23456789";
-		$possible="abdfhkrsvwxyz23456789";
+		$possible="abdfhkrsvwxz23456789";
 		$str="";
 		while(strlen($str)<$len) {
 			$str.=substr($possible,(rand()%(strlen($possible))),1);
@@ -61,30 +61,66 @@
 list($width, $height, $type, $attr) = getimagesize($bg);
 
 // create image
-$image_failed = true;
-$i=0;
-do {
-	$image = ImageCreateFromPNG($bg); // backgroundimage
-	$grey = rand(0,50);
-	$color = ImageColorAllocate($image, $grey, $grey, $grey); // Farbe
-	$ttf = $font;
-	$ttfsize = 25; // fontsize
-	$angle = rand(0,5);
-	$t_x = rand(5,30);
-	$t_y = rand($height-10,$height-2);
-	$res = imagettftext($image, $ttfsize, $angle, $t_x, $t_y, $color, $ttf, $text);
-	// check if text fits into the image
-	if(($res[0]>0 && $res[0]<$width) && ($res[1]>0 && $res[1]<$height) && 
-	   ($res[2]>0 && $res[2]<$width) && ($res[3]>0 && $res[3]<$height) && 
-	   ($res[4]>0 && $res[4]<$width) && ($res[5]>0 && $res[5]<$height) && 
-	   ($res[6]>0 && $res[6]<$width) && ($res[7]>0 && $res[7]<$height)
-	) {
-		$image_failed = false;
-	}
-	if(++$i > 5) // too many tries! Use the image
-		break;
-} while($image_failed);
 
+$image = ImageCreateFromPNG($bg); // background image
+$grey = rand(0,50);
+$color = ImageColorAllocate($image, $grey, $grey, $grey); // font-color
+$ttf = $font;
+$ttfsize = 25; // fontsize
+$angle = rand(-15,15);
+$x = rand(10,25);
+$y = rand($height-10,$height-2);
+
+if(rand(0,2)==0) { // 1 out of 3
+
+	// draw each character individualy
+	$count = 0;
+	$image_failed = true;
+	do {
+		for($i=0;$i<5;$i++) {
+			$res = imagettftext($image, $ttfsize, $angle, $x, $y, $color, $ttf, $text{$i});
+			$angle = rand(-15,15);
+			$x = rand($res[4],$res[4]+10);
+			$y = rand($height-15,$height-5);
+		}
+		if($res[4] > $width) {
+			$image_failed = true;
+		} else {
+			$image_failed = false;
+		}
+		if(++$count > 4) // too many tries! Use the image
+			break;
+	} while($image_failed);
+	
+} else {
+	
+	// draw whole string at once
+	$image_failed = true;
+	$count=0;
+	do {
+		$image = ImageCreateFromPNG($bg); // background image
+		$grey = rand(0,50);
+		$color = ImageColorAllocate($image, $grey, $grey, $grey); // font-color
+		$ttf = $font;
+		$ttfsize = 25; // fontsize
+		$angle = rand(0,5);
+		$t_x = rand(5,30);
+		$t_y = rand($height-10,$height-2);
+		$res = imagettftext($image, $ttfsize, $angle, $t_x, $t_y, $color, $ttf, $text);
+		// check if text fits into the image
+		if(($res[0]>0 && $res[0]<$width) && ($res[1]>0 && $res[1]<$height) && 
+			 ($res[2]>0 && $res[2]<$width) && ($res[3]>0 && $res[3]<$height) && 
+			 ($res[4]>0 && $res[4]<$width) && ($res[5]>0 && $res[5]<$height) && 
+			 ($res[6]>0 && $res[6]<$width) && ($res[7]>0 && $res[7]<$height)
+		) {
+			$image_failed = false;
+		}
+		if(++$count > 5) // too many tries! Use the image
+			break;
+	} while($image_failed);
+	
+}
+
 captcha_header();
 ob_start();
 imagepng($image);
