Index: branches/2.8.x/CHANGELOG
===================================================================
--- branches/2.8.x/CHANGELOG	(revision 1300)
+++ branches/2.8.x/CHANGELOG	(revision 1301)
@@ -11,6 +11,13 @@
 ! = Update/Change
 
 ------------------------------------- 2.8.1 -------------------------------------
+07-Mar-2010 Dietmar Woellbrink (Luisehahne)
+#	Tickets #932 change deprecated eregi functions 
+#	Tickets #948 fixed Multiple use of same parametrised droplet - parameter handling
+!	Upgrade Droplets to Version 1.0.3
+!	update some headerinfos
+!	non existing pages will be created if clicking save in page settings
+07-Mar-2010 Dietmar Woellbrink (Luisehahne)
 #	Ticket #950 missing classes in theme.css ( Tks to Ruebenwurzel )
 !	update jquery-min.js to version 1.4.2
 20-Feb-2010 Dietmar Woellbrink (Luisehahne)
Index: branches/2.8.x/wb/include/phpmailer/class.phpmailer.php
===================================================================
--- branches/2.8.x/wb/include/phpmailer/class.phpmailer.php	(revision 1300)
+++ branches/2.8.x/wb/include/phpmailer/class.phpmailer.php	(revision 1301)
@@ -583,8 +583,10 @@
    * @access private
    * @return bool
    */
-  function SmtpConnect() {
-    if($this->smtp == NULL) {
+  function SmtpConnect()
+  {
+    if($this->smtp == NULL)
+    {
       $this->smtp = new SMTP();
     }
 
@@ -594,9 +596,11 @@
     $connection = ($this->smtp->Connected());
 
     /* Retry while there is no connection */
-    while($index < count($hosts) && $connection == false) {
+    while($index < count($hosts) && $connection == false)
+    {
       $hostinfo = array();
-      if(eregi('^(.+):([0-9]+)$', $hosts[$index], $hostinfo)) {
+      if(preg_match('/(.+):([0-9]+)/', $hosts[$index], $hostinfo))
+      {
         $host = $hostinfo[1];
         $port = $hostinfo[2];
       } else {
Index: branches/2.8.x/wb/include/captcha/captchas/ttf_image.php
===================================================================
--- branches/2.8.x/wb/include/captcha/captchas/ttf_image.php	(revision 1300)
+++ branches/2.8.x/wb/include/captcha/captchas/ttf_image.php	(revision 1301)
@@ -1,141 +1,141 @@
-<?php
-
-// $Id$
-
-/*
-
- Website Baker Project <http://www.websitebaker.org/>
- Copyright (C) 2004-2009, 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
-
-*/
-
-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.'/framework/functions.php');
-$t_fonts = file_list(WB_PATH.'/include/captcha/fonts');
-$t_bgs = file_list(WB_PATH.'/include/captcha/backgrounds');
-$fonts = array();
-$bgs = array();
-foreach($t_fonts as $file) if(eregi('\.ttf$',$file)) $fonts[]=$file;
-foreach($t_bgs as $file) if(eregi('\.png$',$file)) $bgs[]=$file;
-
-// make random string
-if(!function_exists('randomString')) {
-	function randomString($len) {
-		list($usec, $sec) = explode(' ', microtime());
-		mt_srand((float)$sec + ((float)$usec * 100000));
-		//$possible="ABCDEFGHJKLMNPRSTUVWXYZabcdefghkmnpqrstuvwxyz23456789";
-		$possible="abdfhkrsvwxz23456789";
-		$str="";
-		while(strlen($str)<$len) {
-			$str.=substr($possible,(mt_rand()%(strlen($possible))),1);
-		}
-		return($str);
-	}
-}
-$text = randomString(5); // number of characters
-$_SESSION['captcha'] = $text; 
-
-// choose a font and background
-$font = $fonts[array_rand($fonts)];
-$bg = $bgs[array_rand($bgs)];
-// get image-dimensions
-list($width, $height, $type, $attr) = getimagesize($bg);
-
-// 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);
-	$x = mt_rand(10,25);
-	$y = mt_rand($height-10,$height-2);
-	do {
-		for($i=0;$i<strlen($text);$i++) {
-			$res = imagettftext($image, $ttfsize, $angle, $x, $y, $color, $ttf, $text{$i});
-			$angle = mt_rand(-15,15);
-			$x = mt_rand($res[4],$res[4]+10);
-			$y = mt_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 = 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(5,30);
-		$y = mt_rand($height-10,$height-2);
-		$res = imagettftext($image, $ttfsize, $angle, $x, $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 > 4) // too many tries! Use the image
-			break;
-	} while($image_failed);
-	
-}
-
-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);
-header("Content-Length: ".ob_get_length()); 
-ob_end_flush();
-imagedestroy($image);
-
+<?php
+
+// $Id$
+
+/*
+
+ Website Baker Project <http://www.websitebaker.org/>
+ Copyright (C) 2004-2009, 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
+
+*/
+
+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.'/framework/functions.php');
+$t_fonts = file_list(WB_PATH.'/include/captcha/fonts');
+$t_bgs = file_list(WB_PATH.'/include/captcha/backgrounds');
+$fonts = array();
+$bgs = array();
+foreach($t_fonts as $file) { if(preg_match('/\.ttf/',$file)) { $fonts[]=$file; } }
+foreach($t_bgs as $file) { if(preg_match('/\.png/',$file)) { $bgs[]=$file; } }
+
+// make random string
+if(!function_exists('randomString')) {
+	function randomString($len) {
+		list($usec, $sec) = explode(' ', microtime());
+		mt_srand((float)$sec + ((float)$usec * 100000));
+		//$possible="ABCDEFGHJKLMNPRSTUVWXYZabcdefghkmnpqrstuvwxyz23456789";
+		$possible="abdfhkrsvwxz23456789";
+		$str="";
+		while(strlen($str)<$len) {
+			$str.=substr($possible,(mt_rand()%(strlen($possible))),1);
+		}
+		return($str);
+	}
+}
+$text = randomString(5); // number of characters
+$_SESSION['captcha'] = $text; 
+
+// choose a font and background
+$font = $fonts[array_rand($fonts)];
+$bg = $bgs[array_rand($bgs)];
+// get image-dimensions
+list($width, $height, $type, $attr) = getimagesize($bg);
+
+// 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);
+	$x = mt_rand(10,25);
+	$y = mt_rand($height-10,$height-2);
+	do {
+		for($i=0;$i<strlen($text);$i++) {
+			$res = imagettftext($image, $ttfsize, $angle, $x, $y, $color, $ttf, $text{$i});
+			$angle = mt_rand(-15,15);
+			$x = mt_rand($res[4],$res[4]+10);
+			$y = mt_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 = 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(5,30);
+		$y = mt_rand($height-10,$height-2);
+		$res = imagettftext($image, $ttfsize, $angle, $x, $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 > 4) // too many tries! Use the image
+			break;
+	} while($image_failed);
+	
+}
+
+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);
+header("Content-Length: ".ob_get_length()); 
+ob_end_flush();
+imagedestroy($image);
+
 ?>
\ No newline at end of file

Property changes on: branches/2.8.x/wb/include/captcha/captchas/ttf_image.php
___________________________________________________________________
Modified: svn:keywords
## -1 +1,4 ##
-Id
\ No newline at end of property
+Id
+Revision
+HeadURL
+Date
\ No newline at end of property
Index: branches/2.8.x/wb/include/captcha/captchas/calc_ttf_image.php
===================================================================
--- branches/2.8.x/wb/include/captcha/captchas/calc_ttf_image.php	(revision 1300)
+++ branches/2.8.x/wb/include/captcha/captchas/calc_ttf_image.php	(revision 1301)
@@ -1,150 +1,150 @@
-<?php
-
-// $Id$
-
-/*
-
- Website Baker Project <http://www.websitebaker.org/>
- Copyright (C) 2004-2009, 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
-
-*/
-
-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.'/framework/functions.php');
-$t_fonts = file_list(WB_PATH.'/include/captcha/fonts');
-$t_bgs = file_list(WB_PATH.'/include/captcha/backgrounds');
-$fonts = array();
-$bgs = array();
-foreach($t_fonts as $file) if(eregi('\.ttf$',$file)) $fonts[]=$file;
-foreach($t_bgs as $file) if(eregi('\.png$',$file)) $bgs[]=$file;
-
-// Captcha
-$_SESSION['captcha'] = '';
-mt_srand((double)microtime()*1000000);
-$n = mt_rand(1,3);
-switch ($n) {
-	case 1:
-		$x = mt_rand(1,9);
-		$y = mt_rand(1,9);
-		$_SESSION['captcha'] = $x + $y;
-		$cap = "$x+$y"; 
-		break; 
-	case 2:
-		$x = mt_rand(10,20);
-		$y = mt_rand(1,9);
-		$_SESSION['captcha'] = $x - $y; 
-		$cap = "$x-$y"; 
-		break;
-	case 3:
-		$x = mt_rand(2,10);
-		$y = mt_rand(2,5);
-		$_SESSION['captcha'] = $x * $y; 
-		$cap = "$x*$y"; 
-		break;
-}
-$text = $cap;
-
-// choose a font and background
-$font = $fonts[array_rand($fonts)];
-$bg = $bgs[array_rand($bgs)];
-// get image-dimensions
-list($width, $height, $type, $attr) = getimagesize($bg);
-
-// 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);
-	$x = mt_rand(20,35);
-	$y = mt_rand($height-10,$height-2);
-	do {
-		for($i=0;$i<strlen($text);$i++) {
-			$res = imagettftext($image, $ttfsize, $angle, $x, $y, $color, $ttf, $text{$i});
-			$angle = mt_rand(-10,10);
-			$x = mt_rand($res[4],$res[4]+10);
-			$y = mt_rand($height-12,$height-7);
-		}
-		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 = 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);
-		$res = imagettftext($image, $ttfsize, $angle, $x, $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 > 4) // too many tries! Use the image
-			break;
-	} while($image_failed);
-	
-}
-
-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);
-header("Content-Length: ".ob_get_length()); 
-ob_end_flush();
-imagedestroy($image);
-
+<?php
+
+// $Id$
+
+/*
+
+ Website Baker Project <http://www.websitebaker.org/>
+ Copyright (C) 2004-2009, 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
+
+*/
+
+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.'/framework/functions.php');
+$t_fonts = file_list(WB_PATH.'/include/captcha/fonts');
+$t_bgs = file_list(WB_PATH.'/include/captcha/backgrounds');
+$fonts = array();
+$bgs = array();
+foreach($t_fonts as $file) { if(preg_match('/\.ttf/',$file)) { $fonts[]=$file; } }
+foreach($t_bgs as $file) { if(preg_match('/\.png/',$file)) { $bgs[]=$file; } }
+
+// Captcha
+$_SESSION['captcha'] = '';
+mt_srand((double)microtime()*1000000);
+$n = mt_rand(1,3);
+switch ($n) {
+	case 1:
+		$x = mt_rand(1,9);
+		$y = mt_rand(1,9);
+		$_SESSION['captcha'] = $x + $y;
+		$cap = "$x+$y"; 
+		break; 
+	case 2:
+		$x = mt_rand(10,20);
+		$y = mt_rand(1,9);
+		$_SESSION['captcha'] = $x - $y; 
+		$cap = "$x-$y"; 
+		break;
+	case 3:
+		$x = mt_rand(2,10);
+		$y = mt_rand(2,5);
+		$_SESSION['captcha'] = $x * $y; 
+		$cap = "$x*$y"; 
+		break;
+}
+$text = $cap;
+
+// choose a font and background
+$font = $fonts[array_rand($fonts)];
+$bg = $bgs[array_rand($bgs)];
+// get image-dimensions
+list($width, $height, $type, $attr) = getimagesize($bg);
+
+// 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);
+	$x = mt_rand(20,35);
+	$y = mt_rand($height-10,$height-2);
+	do {
+		for($i=0;$i<strlen($text);$i++) {
+			$res = imagettftext($image, $ttfsize, $angle, $x, $y, $color, $ttf, $text{$i});
+			$angle = mt_rand(-10,10);
+			$x = mt_rand($res[4],$res[4]+10);
+			$y = mt_rand($height-12,$height-7);
+		}
+		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 = 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);
+		$res = imagettftext($image, $ttfsize, $angle, $x, $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 > 4) // too many tries! Use the image
+			break;
+	} while($image_failed);
+	
+}
+
+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);
+header("Content-Length: ".ob_get_length()); 
+ob_end_flush();
+imagedestroy($image);
+
 ?>
\ No newline at end of file

Property changes on: branches/2.8.x/wb/include/captcha/captchas/calc_ttf_image.php
___________________________________________________________________
Modified: svn:keywords
## -1 +1,4 ##
-Id
\ No newline at end of property
+Id
+Revision
+HeadURL
+Date
\ No newline at end of property
Index: branches/2.8.x/wb/admin/pages/settings.php
===================================================================
--- branches/2.8.x/wb/admin/pages/settings.php	(revision 1300)
+++ branches/2.8.x/wb/admin/pages/settings.php	(revision 1301)
@@ -277,13 +277,14 @@
 
 		while($page = $get_pages->fetchRow())
         {
-			if($admin->page_is_visible($page)==false)
-				continue;
+			if($admin->page_is_visible($page)==false) { continue; }
+
 			$template->set_var('FLAG_CODE_ICON',' none ');
 			if( $page['parent'] == 0 )
             {
 				$template->set_var('FLAG_CODE_ICON','url('.THEME_URL.'/images/flags/'.strtolower($page['language']).'.png)');
 			}
+
 			// If the current page cannot be parent, then its children neither
 			$list_next_level = true;
 			// Stop users from adding pages with a level of more than the set page level limit
@@ -314,16 +315,19 @@
                 // $space = str_repeat('&nbsp;', 3);  $space.'&lt;'..'&gt;'
 				$template->set_var(array(
 										'VALUE' => $page['page_code'],
-                                        'PAGE_VALUE' => $title_prefix.$page['page_code'],
-										'PAGE_CODE' => $title_prefix.$page['menu_title']
+                                        'PAGE_VALUE' => $title_prefix.$page['menu_title'],
+										'PAGE_CODE' => $title_prefix.$page['page_id']
 										)
 								);
-				if($results_array['page_code'] == $page['page_code']) {
+				if($results_array['page_code'] == $page['page_code'])
+                {
 					$template->set_var('SELECTED', ' selected="selected"');
-				} elseif($results_array['page_code'] == $page['page_code']) {
+				} elseif($results_array['page_code'] == $page['page_code'])
+                {
 					$template->set_var('SELECTED', ' disabled="disabled" class="disabled"');
 					$list_next_level=false;
-				} elseif($can_modify != true) {
+				} elseif($can_modify != true)
+                {
 					$template->set_var('SELECTED', ' disabled="disabled" class="disabled"');
 				} else {
 					$template->set_var('SELECTED', '');
Index: branches/2.8.x/wb/admin/pages/settings2.php
===================================================================
--- branches/2.8.x/wb/admin/pages/settings2.php	(revision 1300)
+++ branches/2.8.x/wb/admin/pages/settings2.php	(revision 1301)
@@ -34,14 +34,11 @@
 require_once(WB_PATH.'/framework/functions.php');
 
 // Get values
-$page_title = $admin->get_post_escaped('page_title');
-$page_title = htmlspecialchars($page_title);
-$menu_title = $admin->get_post_escaped('menu_title');
-$menu_title = htmlspecialchars($menu_title);
+$page_title = htmlspecialchars($admin->get_post_escaped('page_title') );
+$menu_title = htmlspecialchars($admin->get_post_escaped('menu_title') );
 $page_code = $admin->get_post_escaped('page_code');
-$page_code = htmlspecialchars($page_code);
-$description = htmlspecialchars($admin->add_slashes($admin->get_post('description')));
-$keywords = htmlspecialchars($admin->add_slashes($admin->get_post('keywords')));
+$description = htmlspecialchars($admin->add_slashes($admin->get_post('description')) );
+$keywords = htmlspecialchars($admin->add_slashes($admin->get_post('keywords')) );
 $parent = $admin->get_post_escaped('parent');
 $visibility = $admin->get_post_escaped('visibility');
 $template = $admin->get_post_escaped('template');
@@ -81,8 +78,10 @@
 $field_set = $field_sql->numRows();
 
 $in_old_group = FALSE;
-foreach($admin->get_groups_id() as $cur_gid){
-    if (in_array($cur_gid, $old_admin_groups)) {
+foreach($admin->get_groups_id() as $cur_gid)
+{
+    if (in_array($cur_gid, $old_admin_groups))
+    {
 	$in_old_group = TRUE;
     }
 }
@@ -194,7 +193,7 @@
 $sql .= '`language` = "'.$language.'", ';
 $sql .= '`admin_groups` = "'.$admin_groups.'", ';
 $sql .= '`viewing_groups` = "'.$viewing_groups.'"';
-$sql .= (defined('PAGE_LANGUAGES') && PAGE_LANGUAGES) && $field_set && (file_exists(WB_PATH.'/modules/mod_multilingual/update_keys.php')) ? ', `page_code` = "'.$page_code.'" ' : ' ';
+$sql .= (defined('PAGE_LANGUAGES') && PAGE_LANGUAGES) && $field_set && (file_exists(WB_PATH.'/modules/mod_multilingual/update_keys.php')) ? ', `page_code` = '.(int)$page_code.' ' : ' ';
 $sql .= 'WHERE `page_id` = '.$page_id;
 $database->query($sql);
 
@@ -216,8 +215,9 @@
 {
 	$admin->print_error($MESSAGE['PAGES']['CANNOT_CREATE_ACCESS_FILE']);
 } else {
+    $old_filename = WB_PATH.PAGES_DIRECTORY.$old_link.PAGE_EXTENSION;
 	// First check if we need to create a new file
-	if($old_link != $link)
+	if(($old_link != $link) || (!file_exists($old_filename)))
     {
 		// Delete old file
 		$old_filename = WB_PATH.PAGES_DIRECTORY.$old_link.PAGE_EXTENSION;
Index: branches/2.8.x/wb/admin/pages/add.php
===================================================================
--- branches/2.8.x/wb/admin/pages/add.php	(revision 1300)
+++ branches/2.8.x/wb/admin/pages/add.php	(revision 1301)
@@ -1,178 +1,233 @@
-<?php
-
-// $Id$
-
-/*
-
- Website Baker Project <http://www.websitebaker.org/>
- Copyright (C) 2004-2009, 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
-
-*/
-
-// Create new admin object and print admin header
-require('../../config.php');
-require_once(WB_PATH.'/framework/class.admin.php');
-$admin = new admin('Pages', 'pages_add');
-
-// Include the WB functions file
-require_once(WB_PATH.'/framework/functions.php');
-
-// Get values
-$title = $admin->get_post_escaped('title');
-$title = htmlspecialchars($title);
-$module = $admin->get_post('type');
-$parent = $admin->get_post('parent');
-$visibility = $admin->get_post('visibility');
-$admin_groups = $admin->get_post('admin_groups');
-$viewing_groups = $admin->get_post('viewing_groups');
-
-// add Admin to admin and viewing-groups
-$admin_groups[] = 1;
-$viewing_groups[] = 1;
-
-if ($parent!=0) {
-	if (!$admin->get_page_permission($parent,'admin'))
-		$admin->print_error($MESSAGE['PAGES']['INSUFFICIENT_PERMISSIONS']);
-} elseif (!$admin->get_permission('pages_add_l0','system')) {
-	$admin->print_error($MESSAGE['PAGES']['INSUFFICIENT_PERMISSIONS']);
-}	
-
-// Validate data
-if($title == '' || substr($title,0,1)=='.') {
-	$admin->print_error($MESSAGE['PAGES']['BLANK_PAGE_TITLE']);
-}
-
-// Check to see if page created has needed permissions
-if(!in_array(1, $admin->get_groups_id())) {
-	$admin_perm_ok = false;
-	foreach ($admin_groups as $adm_group) {
-		if (in_array($adm_group, $admin->get_groups_id())) {
-			$admin_perm_ok = true;
-		}
-	}
-	if ($admin_perm_ok == false) {
-		$admin->print_error($MESSAGE['PAGES']['INSUFFICIENT_PERMISSIONS']);
-	}
-	$admin_perm_ok = false;
-	foreach ($viewing_groups as $view_group) {
-		if (in_array($view_group, $admin->get_groups_id())) {
-			$admin_perm_ok = true;
-		}
-	}
-	if ($admin_perm_ok == false) {
-		$admin->print_error($MESSAGE['PAGES']['INSUFFICIENT_PERMISSIONS']);
-	}
-}
-
-$admin_groups = implode(',', $admin_groups);
-$viewing_groups = implode(',', $viewing_groups);
-
-// Work-out what the link and page filename should be
-if($parent == '0') {
-	$link = '/'.page_filename($title);
-	// rename menu titles: index && intro to prevent clashes with intro page feature and WB core file /pages/index.php
-	if($link == '/index' || $link == '/intro') {
-		$link .= '_0';
-		$filename = WB_PATH .PAGES_DIRECTORY .'/' .page_filename($title) .'_0' .PAGE_EXTENSION;
-	} else {
-		$filename = WB_PATH.PAGES_DIRECTORY.'/'.page_filename($title).PAGE_EXTENSION;
-	}
-} else {
-	$parent_section = '';
-	$parent_titles = array_reverse(get_parent_titles($parent));
-	foreach($parent_titles AS $parent_title) {
-		$parent_section .= page_filename($parent_title).'/';
-	}
-	if($parent_section == '/') { $parent_section = ''; }
-	$link = '/'.$parent_section.page_filename($title);
-	$filename = WB_PATH.PAGES_DIRECTORY.'/'.$parent_section.page_filename($title).PAGE_EXTENSION;
-	make_dir(WB_PATH.PAGES_DIRECTORY.'/'.$parent_section);
-}
-
-// Check if a page with same page filename exists
-$get_same_page = $database->query("SELECT page_id FROM ".TABLE_PREFIX."pages WHERE link = '$link'");
-if($get_same_page->numRows() > 0 OR file_exists(WB_PATH.PAGES_DIRECTORY.$link.PAGE_EXTENSION) OR file_exists(WB_PATH.PAGES_DIRECTORY.$link.'/')) {
-	$admin->print_error($MESSAGE['PAGES']['PAGE_EXISTS']);
-}
-
-// Include the ordering class
-require(WB_PATH.'/framework/class.order.php');
-$order = new order(TABLE_PREFIX.'pages', 'position', 'page_id', 'parent');
-// First clean order
-$order->clean($parent);
-// Get new order
-$position = $order->get_new($parent);
-
-// Work-out if the page parent (if selected) has a seperate template or language to the default
-$query_parent = $database->query("SELECT template, language FROM ".TABLE_PREFIX."pages WHERE page_id = '$parent'");
-if($query_parent->numRows() > 0) {
-	$fetch_parent = $query_parent->fetchRow();
-	$template = $fetch_parent['template'];
-	$language = $fetch_parent['language'];
-} else {
-	$template = '';
-	$language = DEFAULT_LANGUAGE;
-}
-
-// Insert page into pages table
-$query = "INSERT INTO ".TABLE_PREFIX."pages (page_title,menu_title,parent,template,target,position,visibility,searching,menu,language,admin_groups,viewing_groups,modified_when,modified_by) VALUES ('$title','$title','$parent','$template','_top','$position','$visibility','1','1','$language','$admin_groups','$viewing_groups','".time()."','".$admin->get_user_id()."')";
-$database->query($query);
-if($database->is_error()) {
-	$admin->print_error($database->get_error());
-}
-
-// Get the page id
-$page_id = $database->get_one("SELECT LAST_INSERT_ID()");
-
-// Work out level
-$level = level_count($page_id);
-// Work out root parent
-$root_parent = root_parent($page_id);
-// Work out page trail
-$page_trail = get_page_trail($page_id);
-
-// Update page with new level and link
-$database->query("UPDATE ".TABLE_PREFIX."pages SET link = '$link', level = '$level', root_parent = '$root_parent', page_trail = '$page_trail' WHERE page_id = '$page_id'");
-
-// Create a new file in the /pages dir
-create_access_file($filename, $page_id, $level);
-
-// add position 1 to new page
-$position = 1;
-
-// Add new record into the sections table
-$database->query("INSERT INTO ".TABLE_PREFIX."sections (page_id,position,module,block) VALUES ('$page_id','$position', '$module','1')");
-
-// Get the section id
-$section_id = $database->get_one("SELECT LAST_INSERT_ID()");
-
-// Include the selected modules add file if it exists
-if(file_exists(WB_PATH.'/modules/'.$module.'/add.php')) {
-	require(WB_PATH.'/modules/'.$module.'/add.php');
-}
-
-// Check if there is a db error, otherwise say successful
-if($database->is_error()) {
-	$admin->print_error($database->get_error());
-} else {
-	$admin->print_success($MESSAGE['PAGES']['ADDED'], ADMIN_URL.'/pages/modify.php?page_id='.$page_id);
-}
-
-// Print admin footer
-$admin->print_footer();
-
+<?php
+/**
+ *
+ * @category        admin
+ * @package         pages
+ * @author          WebsiteBaker Project
+ * @copyright       2004-2009, Ryan Djurovich
+ * @copyright       2009-2010, Website Baker Org. e.V.
+ * @link			http://www.websitebaker2.org/
+ * @license         http://www.gnu.org/licenses/gpl.html
+ * @platform        WebsiteBaker 2.8.x
+ * @requirements    PHP 4.3.4 and higher
+ * @version         $Id$
+ * @filesource		$HeadURL$
+ * @lastmodified    $Date$
+ *
+ */
+
+// Create new admin object and print admin header
+require('../../config.php');
+require_once(WB_PATH.'/framework/class.admin.php');
+$admin = new admin('Pages', 'pages_add');
+
+// Include the WB functions file
+require_once(WB_PATH.'/framework/functions.php');
+
+// Get values
+$title = $admin->get_post_escaped('title');
+$title = htmlspecialchars($title);
+$module = $admin->get_post('type');
+$parent = $admin->get_post('parent');
+$visibility = $admin->get_post('visibility');
+$admin_groups = $admin->get_post('admin_groups');
+$viewing_groups = $admin->get_post('viewing_groups');
+
+// Work-out if we should check for existing page_code
+$sql = 'DESCRIBE `'.TABLE_PREFIX.'pages` `page_code`';
+$field_sql = $database->query($sql);
+$field_set = $field_sql->numRows();
+
+// add Admin to admin and viewing-groups
+$admin_groups[] = 1;
+$viewing_groups[] = 1;
+
+if ($parent!=0) {
+	if (!$admin->get_page_permission($parent,'admin'))
+    {
+        $admin->print_error($MESSAGE['PAGES']['INSUFFICIENT_PERMISSIONS']);
+    }
+
+} elseif (!$admin->get_permission('pages_add_l0','system'))
+{
+	$admin->print_error($MESSAGE['PAGES']['INSUFFICIENT_PERMISSIONS']);
+}	
+
+// Validate data
+if($title == '' || substr($title,0,1)=='.')
+{
+	$admin->print_error($MESSAGE['PAGES']['BLANK_PAGE_TITLE']);
+}
+
+// Check to see if page created has needed permissions
+if(!in_array(1, $admin->get_groups_id()))
+{
+	$admin_perm_ok = false;
+	foreach ($admin_groups as $adm_group)
+    {
+		if (in_array($adm_group, $admin->get_groups_id()))
+        {
+			$admin_perm_ok = true;
+		}
+	}
+	if ($admin_perm_ok == false)
+    {
+		$admin->print_error($MESSAGE['PAGES']['INSUFFICIENT_PERMISSIONS']);
+	}
+	$admin_perm_ok = false;
+	foreach ($viewing_groups as $view_group)
+    {
+		if (in_array($view_group, $admin->get_groups_id()))
+        {
+			$admin_perm_ok = true;
+		}
+	}
+	if ($admin_perm_ok == false)
+    {
+		$admin->print_error($MESSAGE['PAGES']['INSUFFICIENT_PERMISSIONS']);
+	}
+}
+
+$admin_groups = implode(',', $admin_groups);
+$viewing_groups = implode(',', $viewing_groups);
+
+// Work-out what the link and page filename should be
+if($parent == '0')
+{
+	$link = '/'.page_filename($title);
+	// rename menu titles: index && intro to prevent clashes with intro page feature and WB core file /pages/index.php
+	if($link == '/index' || $link == '/intro')
+    {
+		$link .= '_0';
+		$filename = WB_PATH .PAGES_DIRECTORY .'/' .page_filename($title) .'_0' .PAGE_EXTENSION;
+	} else {
+		$filename = WB_PATH.PAGES_DIRECTORY.'/'.page_filename($title).PAGE_EXTENSION;
+	}
+} else {
+	$parent_section = '';
+	$parent_titles = array_reverse(get_parent_titles($parent));
+	foreach($parent_titles AS $parent_title)
+    {
+		$parent_section .= page_filename($parent_title).'/';
+	}
+	if($parent_section == '/') { $parent_section = ''; }
+	$link = '/'.$parent_section.page_filename($title);
+	$filename = WB_PATH.PAGES_DIRECTORY.'/'.$parent_section.page_filename($title).PAGE_EXTENSION;
+	make_dir(WB_PATH.PAGES_DIRECTORY.'/'.$parent_section);
+}
+
+// Check if a page with same page filename exists
+$get_same_page = $database->query("SELECT page_id FROM ".TABLE_PREFIX."pages WHERE link = '$link'");
+if($get_same_page->numRows() > 0 OR file_exists(WB_PATH.PAGES_DIRECTORY.$link.PAGE_EXTENSION) OR file_exists(WB_PATH.PAGES_DIRECTORY.$link.'/'))
+{
+	$admin->print_error($MESSAGE['PAGES']['PAGE_EXISTS']);
+}
+
+// Include the ordering class
+require(WB_PATH.'/framework/class.order.php');
+$order = new order(TABLE_PREFIX.'pages', 'position', 'page_id', 'parent');
+// First clean order
+$order->clean($parent);
+// Get new order
+$position = $order->get_new($parent);
+
+// Work-out if the page parent (if selected) has a seperate template or language to the default
+$query_parent = $database->query("SELECT template, language FROM ".TABLE_PREFIX."pages WHERE page_id = '$parent'");
+if($query_parent->numRows() > 0)
+{
+	$fetch_parent = $query_parent->fetchRow();
+	$template = $fetch_parent['template'];
+	$language = $fetch_parent['language'];
+} else {
+	$template = '';
+	$language = DEFAULT_LANGUAGE;
+}
+
+// Insert page into pages table
+$sql  = 'INSERT INTO `'.TABLE_PREFIX.'pages` SET ';
+$sql .= '`parent` = '.$parent.', ';
+$sql .= '`target` = "_top", ';
+$sql .= '`page_title` = "'.$title.'", ';
+$sql .= '`menu_title` = "'.$title.'", ';
+$sql .= '`template` = "'.$template.'", ';
+$sql .= '`visibility` = "'.$visibility.'", ';
+$sql .= '`position` = '.$position.', ';
+$sql .= '`menu` = 1, ';
+$sql .= '`language` = "'.$language.'", ';
+$sql .= '`searching` = 1, ';
+$sql .= '`modified_when` = '.time().', ';
+$sql .= '`modified_by` = '.$admin->get_user_id().', ';
+$sql .= '`admin_groups` = "'.$admin_groups.'", ';
+$sql .= '`viewing_groups` = "'.$viewing_groups.'"';
+
+$database->query($sql);
+/*
+$query = "INSERT INTO ".TABLE_PREFIX."pages
+(page_title,menu_title,parent,template,target,position,visibility,searching,menu,language,admin_groups,viewing_groups,modified_when,modified_by) VALUES
+('$title','$title','$parent','$template','_top','$position','$visibility','1','1','$language','$admin_groups','$viewing_groups','".time()."','".$admin->get_user_id()."')";
+$database->query($query);
+*/
+if($database->is_error())
+{
+	$admin->print_error($database->get_error());
+}
+
+// Get the page id
+$page_id = $database->get_one("SELECT LAST_INSERT_ID()");
+
+// Work out level
+$level = level_count($page_id);
+// Work out root parent
+$root_parent = root_parent($page_id);
+// Work out page trail
+$page_trail = get_page_trail($page_id);
+
+// Update page with new level and link
+$sql  = 'UPDATE `'.TABLE_PREFIX.'pages` SET ';
+$sql .= '`root_parent` = '.$root_parent.', ';
+$sql .= '`level` = '.$level.', ';
+$sql .= '`link` = "'.$link.'", ';
+$sql .= '`page_trail` = "'.$page_trail.'"';
+$sql .= (defined('PAGE_LANGUAGES') && PAGE_LANGUAGES)
+         && $field_set
+         && ($language == DEFAULT_LANGUAGE)
+         && (file_exists(WB_PATH.'/modules/mod_multilingual/update_keys.php')
+         )
+         ? ', `page_code` = '.(int)$page_id.' ' : ' ';
+$sql .= 'WHERE `page_id` = '.$page_id;
+$database->query($sql);
+/*
+$database->query("UPDATE ".TABLE_PREFIX."pages SET link = '$link', level = '$level', root_parent = '$root_parent', page_trail = '$page_trail' WHERE page_id = '$page_id'");
+*/
+if($database->is_error())
+{
+	$admin->print_error($database->get_error());
+}
+// Create a new file in the /pages dir
+create_access_file($filename, $page_id, $level);
+
+// add position 1 to new page
+$position = 1;
+
+// Add new record into the sections table
+$database->query("INSERT INTO ".TABLE_PREFIX."sections (page_id,position,module,block) VALUES ('$page_id','$position', '$module','1')");
+
+// Get the section id
+$section_id = $database->get_one("SELECT LAST_INSERT_ID()");
+
+// Include the selected modules add file if it exists
+if(file_exists(WB_PATH.'/modules/'.$module.'/add.php')) {
+	require(WB_PATH.'/modules/'.$module.'/add.php');
+}
+
+// Check if there is a db error, otherwise say successful
+if($database->is_error()) {
+	$admin->print_error($database->get_error());
+} else {
+	$admin->print_success($MESSAGE['PAGES']['ADDED'], ADMIN_URL.'/pages/modify.php?page_id='.$page_id);
+}
+
+// Print admin footer
+$admin->print_footer();
+
 ?>
\ No newline at end of file

Property changes on: branches/2.8.x/wb/admin/pages/add.php
___________________________________________________________________
Modified: svn:keywords
## -1 +1,4 ##
-Id
\ No newline at end of property
+Id
+Revision
+HeadURL
+Date
\ No newline at end of property
Index: branches/2.8.x/wb/admin/settings/save.php
===================================================================
--- branches/2.8.x/wb/admin/settings/save.php	(revision 1300)
+++ branches/2.8.x/wb/admin/settings/save.php	(revision 1301)
@@ -25,7 +25,8 @@
 // Print admin header
 require('../../config.php');
 require_once(WB_PATH.'/framework/class.admin.php');
-if($advanced == '') {
+if($advanced == '')
+{
 	$admin = new admin('Settings', 'settings_basic');
 	$_POST['database_password'] = DB_PASSWORD;
 } else {
@@ -39,7 +40,10 @@
 if(isset($_POST['server_email']))
 {
 	$_POST['server_email'] = strip_tags($_POST['server_email']);
-	if(!eregi("^([0-9a-zA-Z]+[-._+&])*[0-9a-zA-Z]+@([-0-9a-zA-Z]+[.])+[a-zA-Z]{2,6}$", $_POST['server_email'])) {
+    $pattern = '/^[-a-z0-9~!$%^&*_=+}{\'?]+(\.[-a-z0-9~!$%^&*_=+}{\'?]+)*@([a-z0-9]([-a-z0-9_]?[a-z0-9])*(\.[-a-z0-9_]+)*\.(aero|arpa|biz|com|coop|edu|gov|info|int|mil|museum|name|net|org|pro|travel|mobi|[a-z]{2})|([1]?\d{1,2}|2[0-4]{1}\d{1}|25[0-5]{1})(\.([1]?\d{1,2}|2[0-4]{1}\d{1}|25[0-5]{1})){3})(:[0-9]{1,5})?\r/im';
+    // $pattern = '/^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.(([0-9]{1,3})|([a-zA-Z]{2,6}))$/';
+    if(false == preg_match($pattern, $_POST['server_email']))
+    {
 		$admin->print_error($MESSAGE['USERS']['INVALID_EMAIL'].
 			'<br /><strong>Email: '.htmlentities($_POST['server_email']).'</strong>', $js_back);
 	}
Index: branches/2.8.x/wb/search/search_modext.php
===================================================================
--- branches/2.8.x/wb/search/search_modext.php	(revision 1300)
+++ branches/2.8.x/wb/search/search_modext.php	(revision 1301)
@@ -17,9 +17,11 @@
  */
 
 // make the url-string for highlighting
-function make_url_searchstring($search_match, $search_url_array) {
+function make_url_searchstring($search_match, $search_url_array)
+{
 	$link = "";
-	if ($search_match != 'exact') {
+	if ($search_match != 'exact')
+    {
 		$str = implode(" ", $search_url_array);
 		$link = "?searchresult=1&amp;sstring=".urlencode($str);
 	} else {
@@ -30,9 +32,11 @@
 }
 
 // make date and time for "last modified by... on ..."-string
-function get_page_modified($page_modified_when) {
+function get_page_modified($page_modified_when)
+{
 	global $TEXT;
-	if($page_modified_when > 0) {
+	if($page_modified_when > 0)
+    {
 		$date = gmdate(DATE_FORMAT, $page_modified_when+TIMEZONE);
 		$time = gmdate(TIME_FORMAT, $page_modified_when+TIMEZONE);
 	} else {
@@ -43,12 +47,15 @@
 }
 
 // make username and displayname for "last modified by... on ..."-string
-function get_page_modified_by($page_modified_by, $users) {
+function get_page_modified_by($page_modified_by, $users)
+{
 	global $TEXT;
 	// check for existing user-id
 	if(!isset($users[$page_modified_by]))
-		$page_modified_by = 0;
-	
+    {
+        $page_modified_by = 0;
+    }
+
 	$username = $users[$page_modified_by]['username'];
 	$displayname = $users[$page_modified_by]['display_name'];
 	return array($username, $displayname);
@@ -55,10 +62,13 @@
 }
 
 // checks if _all_ searchwords matches
-function is_all_matched($text, $search_words) {
+function is_all_matched($text, $search_words)
+{
 	$all_matched = true;
-	foreach ($search_words AS $word) {
-		if(!preg_match('/'.$word.'/ui', $text)) {
+	foreach ($search_words AS $word)
+    {
+		if(!preg_match('/'.$word.'/ui', $text))
+        {
 			$all_matched = false;
 			break;
 		}
@@ -67,10 +77,12 @@
 }
 
 // checks if _any_ of the searchwords matches
-function is_any_matched($text, $search_words) {
+function is_any_matched($text, $search_words)
+{
 	$any_matched = false;
 	$word = '('.implode('|', $search_words).')';
-	if(preg_match('/'.$word.'/ui', $text)) {
+	if(preg_match('/'.$word.'/ui', $text))
+    {
 		$any_matched = true;
 	}
 	return $any_matched;
@@ -77,7 +89,8 @@
 }
 
 // collects the matches from text in excerpt_array
-function get_excerpts($text, $search_words, $max_excerpt_num) {
+function get_excerpts($text, $search_words, $max_excerpt_num)
+{
 	$match_array = array();
 	$excerpt_array = array();
 	$word = '('.implode('|', $search_words).')';
@@ -84,12 +97,14 @@
 
 	//Filter droplets from the page data
 	preg_match_all('~\[\[(.*?)\]\]~', $text, $matches);
-	foreach ($matches[1] as $match) {
+	foreach ($matches[1] as $match)
+    {
 		$text = str_replace('[['.$match.']]', '', $text);					
 	}
 
 	// Build the regex-string
-	if(strpos(strtoupper(PHP_OS), 'WIN')===0) { // windows -> see below
+	if(strpos(strtoupper(PHP_OS), 'WIN')===0)  // windows -> see below
+    {
 		$str1=".!?;";
 		$str2=".!?;";
 	} else { // linux & Co.
@@ -104,16 +119,20 @@
 	) { // this may crash windows server, so skip if on windows
 		// jump from match to match, get excerpt, stop if $max_excerpt_num is reached
 		$last_end = 0; $offset = 0;
-		while(preg_match('/'.$word.'/uis', $text, $match_array, PREG_OFFSET_CAPTURE, $last_end)) {
+		while(preg_match('/'.$word.'/uis', $text, $match_array, PREG_OFFSET_CAPTURE, $last_end))
+        {
 			$offset = ($match_array[0][1]-206 < $last_end)?$last_end:$match_array[0][1]-206;
-			if(preg_match($regex, $text, $matches, PREG_OFFSET_CAPTURE, $offset)) {
+			if(preg_match($regex, $text, $matches, PREG_OFFSET_CAPTURE, $offset))
+            {
 				$last_end = $matches[1][1]+strlen($matches[1][0])-1;
 				if(!preg_match('/\b[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\./', $matches[1][0])) // skip excerpts with email-addresses
-					$excerpt_array[] = trim($matches[1][0]);
-				if(count($excerpt_array)>=$max_excerpt_num) {
+				{
+				  $excerpt_array[] = trim($matches[1][0]);
+                }
+				if(count($excerpt_array)>=$max_excerpt_num)
+                {
 					$excerpt_array = array_unique($excerpt_array);
-					if(count($excerpt_array) >= $max_excerpt_num)
-						break;
+					if(count($excerpt_array) >= $max_excerpt_num) { break; }
 				}
 			} else { // problem: preg_match failed - can't find a start- or stop-sign
 				$last_end += 201; // jump forward and try again
@@ -120,11 +139,15 @@
 			}
 		}
 	} else { // compatible, but may be very slow with large pages
-		if(preg_match_all($regex, $text, $match_array)) {
-			foreach($match_array[1] AS $string) {
+		if(preg_match_all($regex, $text, $match_array))
+        {
+			foreach($match_array[1] AS $string)
+            {
 				if(!preg_match('/\b[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\./', $string))  // skip excerpts with email-addresses
-					$excerpt_array[] = trim($string);
-				
+				{
+				  $excerpt_array[] = trim($string);
+                }
+
 			}
 		}
 	}
@@ -132,7 +155,8 @@
 }
 
 // makes excerpt_array a string ready to print out
-function prepare_excerpts($excerpt_array, $search_words, $max_excerpt_num) {
+function prepare_excerpts($excerpt_array, $search_words, $max_excerpt_num)
+{
 	// excerpts: text before and after a single excerpt, html-tag for markup
 	$EXCERPT_BEFORE =       '...&nbsp;';
 	$EXCERPT_AFTER =        '&nbsp;...<br />';
@@ -141,7 +165,8 @@
 	// remove duplicate matches from $excerpt_array, if any.
 	$excerpt_array = array_unique($excerpt_array);
 	// use the first $max_excerpt_num excerpts only
-	if(count($excerpt_array) > $max_excerpt_num) {
+	if(count($excerpt_array) > $max_excerpt_num)
+    {
 		$excerpt_array = array_slice($excerpt_array, 0, $max_excerpt_num);
 	}
 	// prepare search-string
@@ -149,7 +174,8 @@
 	// we want markup on search-results page,
 	// but we need some 'magic' to prevent <br />, <b>... from being highlighted
 	$excerpt = '';
-	foreach($excerpt_array as $str) {
+	foreach($excerpt_array as $str)
+    {
 		$excerpt .= '#,,#'.preg_replace("/($string)/iu","#,,,,#$1#,,,,,#",$str).'#,,,#';
 	}
 	$excerpt = str_replace(array('&','<','>','"','\'',"\xC2\xA0"), array('&amp;','&lt;','&gt;','&quot;','&#039;','&nbsp;'), $excerpt);
@@ -156,7 +182,8 @@
 	$excerpt = str_replace(array('#,,,,#','#,,,,,#'), array($EXCERPT_MARKUP_START,$EXCERPT_MARKUP_END), $excerpt);
 	$excerpt = str_replace(array('#,,#','#,,,#'), array($EXCERPT_BEFORE,$EXCERPT_AFTER), $excerpt);
 	// prepare to write out
-	if(DEFAULT_CHARSET != 'utf-8') {
+	if(DEFAULT_CHARSET != 'utf-8')
+    {
 		$excerpt = umlauts_to_entities($excerpt, 'UTF-8');
 	}
 	return $excerpt;
@@ -163,38 +190,46 @@
 }
 
 // work out what the link-anchor should be
-function make_url_target($page_link_target, $text, $search_words) {
+function make_url_target($page_link_target, $text, $search_words)
+{
 	// 1. e.g. $page_link_target=="&monthno=5&year=2007" - module-dependent target. Do nothing.
 	// 2. $page_link_target=="#!wb_section_..." - the user wants the section-target, so do nothing.
 	// 3. $page_link_target=="#wb_section_..." - try to find a better target, use the section-target as fallback.
 	// 4. $page_link_target=="" - do nothing
-	if(version_compare(PHP_VERSION, '4.3.3', ">=") && substr($page_link_target,0,12)=='#wb_section_') {
+	if(version_compare(PHP_VERSION, '4.3.3', ">=") && substr($page_link_target,0,12)=='#wb_section_')
+    {
 		$word = '('.implode('|', $search_words).')';
 		preg_match('/'.$word.'/ui', $text, $match, PREG_OFFSET_CAPTURE);
-		if($match && is_array($match[0])) {
+		if($match && is_array($match[0]))
+        {
 			$x=$match[0][1]; // position of first match
 			// is there an anchor nearby?
-			if(preg_match_all('/<(?:[^>]+id|\s*a[^>]+name)\s*=\s*"(.*)"/iU', substr($text,0,$x), $match, PREG_OFFSET_CAPTURE)) {
+			if(preg_match_all('/<(?:[^>]+id|\s*a[^>]+name)\s*=\s*"(.*)"/iU', substr($text,0,$x), $match, PREG_OFFSET_CAPTURE))
+            {
 				$anchor='';
-				foreach($match[1] AS $array) {
-					if($array[1] > $x) {
+				foreach($match[1] AS $array)
+                {
+					if($array[1] > $x)
+                    {
 						break;
 					}
 					$anchor = $array[0];
 				}
-				if($anchor != '') {
+				if($anchor != '')
+                {
 					$page_link_target = '#'.$anchor;
 				}
 			}
 		}
-	}
-	elseif(substr($page_link_target,0,13)=='#!wb_section_') {
+	} elseif(substr($page_link_target,0,13)=='#!wb_section_') {
 		$page_link_target = '#'.substr($page_link_target, 2);
 	}
 	
 	// since wb 2.7.1 the section-anchor is configurable - SEC_ANCHOR holds the anchor name
-	if(substr($page_link_target,0,12)=='#wb_section_') {
-		if(defined('SEC_ANCHOR') && SEC_ANCHOR!='') {
+	if(substr($page_link_target,0,12)=='#wb_section_')
+    {
+		if(defined('SEC_ANCHOR') && SEC_ANCHOR!='')
+        {
 			$sec_id = substr($page_link_target, 12);
 			$page_link_target = '#'.SEC_ANCHOR.$sec_id;
 		} else { // section-anchors are disabled
@@ -206,7 +241,8 @@
 }
 
 // wrapper for compatibility with old print_excerpt()
-function print_excerpt($page_link, $page_link_target, $page_title, $page_description, $page_modified_when, $page_modified_by, $text, $max_excerpt_num, $func_vars, $pic_link="") {
+function print_excerpt($page_link, $page_link_target, $page_title, $page_description, $page_modified_when, $page_modified_by, $text, $max_excerpt_num, $func_vars, $pic_link="")
+{
 	$mod_vars = array(
 		'page_link' => $page_link,
 		'page_link_target' => $page_link_target,
@@ -228,26 +264,31 @@
  * list_files_dirs() - lists all files and dirs below a given directory
  * clear_filelist() - keeps only wanted or removes unwanted entries in file-list.
  */
- 
+
 // prints the excerpts for one section
-function print_excerpt2($mod_vars, $func_vars) {
+function print_excerpt2($mod_vars, $func_vars)
+{
 	extract($func_vars, EXTR_PREFIX_ALL, 'func');
 	extract($mod_vars, EXTR_PREFIX_ALL, 'mod');
 	global $TEXT;
 	// check $mod_...vars
-	if(!isset($mod_page_link))          $mod_page_link = $func_page_link;
-	if(!isset($mod_page_link_target))   $mod_page_link_target = "";
-	if(!isset($mod_page_title))         $mod_page_title = $func_page_title;
-	if(!isset($mod_page_description))   $mod_page_description = $func_page_description;
-	if(!isset($mod_page_modified_when)) $mod_page_modified_when = $func_page_modified_when;
-	if(!isset($mod_page_modified_by))   $mod_page_modified_by = $func_page_modified_by;
-	if(!isset($mod_text))               $mod_text = "";
-	if(!isset($mod_max_excerpt_num))    $mod_max_excerpt_num = $func_default_max_excerpt;
-	if(!isset($mod_pic_link))           $mod_pic_link = "";
-	if(!isset($mod_no_highlight))       $mod_no_highlight = false;
-	if(!isset($func_enable_flush))      $func_enable_flush = false; // set this in db: wb_search.cfg_enable_flush [READ THE DOC BEFORE]
-	if(isset($mod_ext_charset)) $mod_ext_charset = strtolower($mod_ext_charset);
-	else $mod_ext_charset = '';
+	if(!isset($mod_page_link))          { $mod_page_link = $func_page_link; }
+	if(!isset($mod_page_link_target))   { $mod_page_link_target = ''; }
+	if(!isset($mod_page_title))         { $mod_page_title = $func_page_title; }
+	if(!isset($mod_page_description))   { $mod_page_description = $func_page_description; }
+	if(!isset($mod_page_modified_when)) { $mod_page_modified_when = $func_page_modified_when; }
+	if(!isset($mod_page_modified_by))   { $mod_page_modified_by = $func_page_modified_by; }
+	if(!isset($mod_text))               { $mod_text = ''; }
+	if(!isset($mod_max_excerpt_num))    { $mod_max_excerpt_num = $func_default_max_excerpt; }
+	if(!isset($mod_pic_link))           { $mod_pic_link = ''; }
+	if(!isset($mod_no_highlight))       { $mod_no_highlight = false; }
+	if(!isset($func_enable_flush))      { $func_enable_flush = false; } // set this in db: wb_search.cfg_enable_flush [READ THE DOC BEFORE]
+	if(isset($mod_ext_charset))
+    {
+      $mod_ext_charset = strtolower($mod_ext_charset);
+    } else {
+      $mod_ext_charset = '';
+    }
 
 	if($mod_text == "") // nothing to do
 		{ return false; }
@@ -379,19 +420,25 @@
 }
 
 // keeps only wanted entries in array $files. $str have to be an eregi()-compatible regex
-function clear_filelist($files, $str, $keep=true) {
+/*
+function clear_filelist($files, $str, $keep=true)
+{
 	// options: $keep = true  : remove all non-matching entries
 	//          $keep = false : remove all matching entries
 	$c_filelist = array();
 	if($str == '')
 		return $files;
-	foreach($files as $file) {
-		if($keep) {
-			if(eregi($str, $file)) {
+	foreach($files as $file)
+    {
+		if($keep)
+        {
+			if(eregi($str, $file))
+            {
 				$c_filelist[] = $file;
 			}
 		} else {
-			if(!eregi($str, $file)) {
+			if(!eregi($str, $file))
+            {
 				$c_filelist[] = $file;
 			}
 		}
@@ -398,5 +445,5 @@
 	}
 	return($c_filelist);
 }
-
-?>
+*/
+?>
\ No newline at end of file
Index: branches/2.8.x/wb/modules/droplets/info.php
===================================================================
--- branches/2.8.x/wb/modules/droplets/info.php	(revision 1300)
+++ branches/2.8.x/wb/modules/droplets/info.php	(revision 1301)
@@ -20,7 +20,7 @@
 $module_directory = 'droplets';
 $module_name = 'Droplets';
 $module_function = 'tool';
-$module_version = '1.0.2';
+$module_version = '1.0.3';
 $module_platform = '2.8.x';
 $module_author = 'Ruud and pcwacht';
 $module_license = 'GNU General Public License';
Index: branches/2.8.x/wb/modules/droplets/droplets.php
===================================================================
--- branches/2.8.x/wb/modules/droplets/droplets.php	(revision 1300)
+++ branches/2.8.x/wb/modules/droplets/droplets.php	(revision 1301)
@@ -2,7 +2,7 @@
 /**
  *
  * @category        module
- * @package         droplet
+ * @package         droplets
  * @author          Ruud Eisinga (Ruud) John (PCWacht)
  * @author          WebsiteBaker Project
  * @copyright       2004-2009, Ryan Djurovich
@@ -15,57 +15,99 @@
  * @filesource		$HeadURL$
  * @lastmodified    $Date$
  *
- */
-
-/*
- *	@version	1.0.2
- *	@date		June 2009
- *
  *	droplets are small codeblocks that are called from anywhere in the template.
  * 	To call a droplet just use [[dropletname]]. optional parameters for a droplet can be used like [[dropletname?parameter=value&parameter2=value]]\
  *
- *  1.0.2, bugfix. Reused the evalDroplet function so the extracted parameters will be only available within the scope of the eval and cleared when ready.
+ *  1.0.2, bugfix, Reused the evalDroplet function so the extracted parameters will be only available within the scope of the eval and cleared when ready.
+ *  1.0.3, optimize, reduce memory consumption, increase speed, remove CSS, enable nested droplets
+ *
  */
 
-function evalDroplets ($wb_page_data) {
-	global $database;
-	$parameter = array();
-	preg_match_all('~\[\[(.*?)\]\]~', $wb_page_data, $matches);
-	foreach ($matches[1] as $match) {
-		if (strpos($match,"?")) {
-			list ($droplet,$params) = explode("?",$match);
-			if(!empty($params)) {
-				$params = html_entity_decode($params,ENT_COMPAT,DEFAULT_CHARSET); // make sure we can parse the parameters correctly
-				$paramarray = explode("&",$params); //create array of parms as parm=value
-				foreach ($paramarray as $paramelement) {
-					$parameterTemp = explode("=", $paramelement,2);
-					if (count($parameterTemp) == 2)
-						$parameter[$parameterTemp[0]] = htmlentities($parameterTemp[1],ENT_COMPAT,DEFAULT_CHARSET); //re-encode the parameter values
+	function do_eval($_x_codedata, $_x_varlist, &$wb_page_data)
+	{
+		extract($_x_varlist, EXTR_SKIP);
+		return(eval($_x_codedata));
+	}
+
+	function processDroplets( &$wb_page_data ) {
+// collect all droplets from document
+		$droplet_tags = array();
+		$droplet_replacements = array();
+		if( preg_match_all( '/\[\[(.*?)\]\]/', $wb_page_data, $found_droplets ) )
+		{
+			foreach( $found_droplets[1] as $droplet )
+			{
+				if(array_key_exists( '[['.$droplet.']]', $droplet_tags) == false)
+				{
+// go in if same droplet with same arguments is not processed already
+					$varlist = array();
+// split each droplet command into droplet_name and request_string
+					$tmp = preg_split('/\?/', $droplet, 2);
+					$droplet_name = $tmp[0];
+					$request_string = (isset($tmp[1]) ? $tmp[1] : '');
+					if( $request_string != '' )
+					{
+// make sure we can parse the arguments correctly
+						$request_string = html_entity_decode($request_string, ENT_COMPAT,DEFAULT_CHARSET);
+// create array of arguments from query_string
+						$argv = preg_split( '/&(?!amp;)/', $request_string );
+						foreach ($argv as $argument)
+						{
+// split argument in pair of varname, value
+							list( $variable, $value ) = explode('=', $argument,2);
+							if( !empty($value) )
+							{
+// re-encode the value and push the var into varlist
+								$varlist[$variable] = htmlentities($value, ENT_COMPAT,DEFAULT_CHARSET);
+							}
+						}
+					}
 					else
-						$parameter['parm'] = htmlentities($parameterTemp[0],ENT_COMPAT,DEFAULT_CHARSET);
+					{
+// no arguments given, so
+						$droplet_name = $droplet;
+					}
+// request the droplet code from database
+					$sql = 'SELECT `code` FROM `'.TABLE_PREFIX.'mod_droplets` WHERE `name` LIKE "'.$droplet_name.'" AND `active` = 1';
+					$codedata = $GLOBALS['database']->get_one($sql);
+					if (!is_null($codedata))
+					{
+						$newvalue = do_eval($codedata, $varlist, $wb_page_data);
+// check returnvalue (must be a string of 1 char at least or (bool)true
+						if ($newvalue == '' && $newvalue !== true)
+						{
+							if(DEBUG === true)
+							{
+								$newvalue = '<span class="mod_droplets_err">Error in: '.$droplet.', no valid returnvalue.</span>';
+							}
+							else
+							{
+								$newvalue = true;
+							}
+						}
+						if ($newvalue === true) { $newvalue = ""; }
+// remove any defined CSS section from code. For valid XHTML a CSS-section is allowed inside <head>...</head> only!
+						$newvalue = preg_replace('/<style.*>.*<\/style>/siU', '', $newvalue);
+// push droplet-tag and it's replacement into Search/Replace array after executing only
+						$droplet_tags[]         = '[['.$droplet.']]';
+						$droplet_replacements[] = $newvalue;
+					}
 				}
-			}
-		} else {
-			$droplet = $match;
-			$parameter = "";
+			}	// End foreach( $found_droplets[1] as $droplet )
+// replace each Droplet-Tag with coresponding $newvalue
+			$wb_page_data = str_replace($droplet_tags, $droplet_replacements, $wb_page_data);
 		}
-		$query_content = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_droplets WHERE name = '$droplet' AND active = 1 ");
-		if ($query_content && $query_content->numRows() > 0){
-			$fetch_content = $query_content->fetchRow();
-			$codedata = ($fetch_content['code']);
-			$newvalue = evalDroplet($codedata, $parameter, $wb_page_data);
-			if ($newvalue == "" && !$newvalue === true) 
-				$newvalue = "<font color=\"red\">Error in: $match, no correct returnvalue.</font>";
-			if ($newvalue === true) 
-				$newvalue = "";
-			$wb_page_data = str_replace("[[".$match."]]", $newvalue, $wb_page_data);
+// returns TRUE if droplets found in content, FALSE if not
+		return( count($droplet_tags)!=0 );
+	}
+
+	function evalDroplets( &$wb_page_data, $max_loops = 3 ) {
+		$max_loops = ((int)$max_loops = 0 ? 3 : (int)$max_loops);
+		while( (processDroplets($wb_page_data) == true) && ($max_loops > 0))
+		{ 
+			$max_loops--;
 		}
+		return $wb_page_data;
 	}
-	return $wb_page_data;
-}
 
-function evalDroplet($droplet, $params, &$wb_page_data) {
-    if(is_array($params)) extract($params, EXTR_SKIP);
-	return eval($droplet);
-}
 ?>
\ No newline at end of file
Index: branches/2.8.x/wb/modules/droplets/example/Text2Image.php
===================================================================
--- branches/2.8.x/wb/modules/droplets/example/Text2Image.php	(revision 1300)
+++ branches/2.8.x/wb/modules/droplets/example/Text2Image.php	(revision 1301)
@@ -1,30 +1,30 @@
-//:Create an image from the textparameter
-//:Use [[text2image?text=The text to create]]
-//clean up old files..-$dir = WB_PATH.'/temp/';-$dp = opendir($dir) or die ('Could not open '.$dir);-while ($file = readdir($dp)) {-	if ((eregi('img_',$file)) && (filemtime($dir.$file)) < (strtotime('-10 minutes'))) {-		unlink($dir.$file);-	}-}-closedir($dp);--$imgfilename = 'img_'.rand().'_'.time().'.jpg';-//create image-$padding = 0;-$font = 3;  	--$height = imagefontheight($font) + ($padding * 2);-$width = imagefontwidth($font) * strlen($text) + ($padding * 2);-$image_handle = imagecreatetruecolor($width, $height);-$text_color = imagecolorallocate($image_handle, 0, 0, 0);-$background_color = imagecolorallocate($image_handle, 255, 255, 255);-$bg_height = imagesy($image_handle);-$bg_width = imagesx($image_handle);-imagefilledrectangle($image_handle, 0, 0, $bg_width, $bg_height, $background_color);-imagestring($image_handle, $font, $padding, $padding, $text, $text_color);-imagejpeg($image_handle,WB_PATH.'/temp/'.$imgfilename,100);-imagedestroy($image_handle);-+//:Create an image from the textparameter
+//:Use [[text2image?text=The text to create]]
+//clean up old files..
+$dir = WB_PATH.'/temp/';
+$dp = opendir($dir) or die ('Could not open '.$dir);
+while ($file = readdir($dp)) {
+	if ((preg_match('/img_/',$file)) && (filemtime($dir.$file)) <  (strtotime('-10 minutes'))) {
+		unlink($dir.$file);
+	}
+}
+closedir($dp);
+
+$imgfilename = 'img_'.rand().'_'.time().'.jpg';
+//create image
+$padding = 0;
+$font = 3;  	
+
+$height = imagefontheight($font) + ($padding * 2);
+$width = imagefontwidth($font) * strlen($text) + ($padding * 2);
+$image_handle = imagecreatetruecolor($width, $height);
+$text_color = imagecolorallocate($image_handle, 0, 0, 0);
+$background_color = imagecolorallocate($image_handle, 255, 255, 255);
+$bg_height = imagesy($image_handle);
+$bg_width = imagesx($image_handle);
+imagefilledrectangle($image_handle, 0, 0, $bg_width, $bg_height, $background_color);
+imagestring($image_handle, $font, $padding, $padding, $text, $text_color);
+imagejpeg($image_handle,WB_PATH.'/temp/'.$imgfilename,100);
+imagedestroy($image_handle);
+
 return '<img src="'.WB_URL.'/temp/'.$imgfilename.'" style="border:0px;margin:0px;padding:0px;vertical-align:middle;" />';
\ No newline at end of file
