Index: branches/2.8.x/CHANGELOG
===================================================================
--- branches/2.8.x/CHANGELOG	(revision 1364)
+++ branches/2.8.x/CHANGELOG	(revision 1365)
@@ -11,6 +11,9 @@
 ! = Update/Change
 
 ------------------------------------- 2.8.2 -------------------------------------
+29 Dec-2010 Build 1365 Dietmar Woellbrink (Luisehahne)
+! added some functions 
+! set status to 2.8.2 RC3
 29 Dec-2010 Build 1364 Dietmar Woellbrink (Luisehahne)
 ! added function 'db_update_key_value()'
 29 Dec-2010 Build 1363 Dietmar Woellbrink (Luisehahne)
Index: branches/2.8.x/wb/admin/interface/version.php
===================================================================
--- branches/2.8.x/wb/admin/interface/version.php	(revision 1364)
+++ branches/2.8.x/wb/admin/interface/version.php	(revision 1365)
@@ -51,7 +51,7 @@
 }
 
 // check if defined to avoid errors during installation (redirect to admin panel fails if PHP error/warnings are enabled)
-if(!defined('VERSION')) define('VERSION', '2.8.2.RC2');
-if(!defined('REVISION')) define('REVISION', '1364');
+if(!defined('VERSION')) define('VERSION', '2.8.2.RC3');
+if(!defined('REVISION')) define('REVISION', '1365');
 
 ?>
\ No newline at end of file
Index: branches/2.8.x/wb/framework/functions.php
===================================================================
--- branches/2.8.x/wb/framework/functions.php	(revision 1364)
+++ branches/2.8.x/wb/framework/functions.php	(revision 1365)
@@ -25,36 +25,63 @@
 // Define that this file has been loaded
 define('FUNCTIONS_FILE_LOADED', true);
 
-// Function to remove a non-empty directory
-function rm_full_dir($directory)
-{
+/**
+ * @description: recursively delete a non empty directory
+ * @param string $directory :
+ * @param bool $empty : true if you want the folder just emptied, but not deleted
+ *                      false, or just simply leave it out, the given directory will be deleted, as well
+ * @return boolean: list of ro-dirs
+ * @from http://www.php.net/manual/de/function.rmdir.php#98499
+ */
+function rm_full_dir($directory, $empty = false) {
+
+    if(substr($directory,-1) == "/")
+	{
+        $directory = substr($directory,0,-1);
+    }
+
     // If suplied dirname is a file then unlink it
-    if (is_file($directory))
+    if (is_file( $directory ))
 	{
         return unlink($directory);
     }
-    // Empty the folder
-	if (is_dir($directory))
-    {
-        $dir = dir($directory);
-        while (false !== $entry = $dir->read())
-        {
-            // Skip pointers
-            if ($entry == '.' || $entry == '..') { continue; }
-            // Deep delete directories
-            if (is_dir($directory.'/'.$entry))
+
+    if(!file_exists($directory) || !is_dir($directory))
+	{
+        return false;
+    } elseif(!is_readable($directory))
+	{
+        return false;
+    } else {
+        $directoryHandle = opendir($directory);
+
+        while ($contents = readdir($directoryHandle))
+		{
+            if($contents != '.' && $contents != '..')
 			{
-				rm_full_dir($directory.'/'.$entry);
+                $path = $directory . "/" . $contents;
+
+                if(is_dir($path))
+				{
+                    rm_full_dir($path);
+                } else {
+                    unlink($path);
+                }
             }
-            else
-            {
-                unlink($directory.'/'.$entry);
+        }
+
+        closedir($directoryHandle);
+
+        if($empty == false)
+		{
+            if(!rmdir($directory))
+			{
+                return false;
             }
         }
-        // Now delete the folder
-        $dir->close();
-        return rmdir($directory);
-	}
+
+        return true;
+    }
 }
 
 /*
@@ -90,6 +117,13 @@
     	}
         $dir->close();
     }
+
+	// sorting
+	if(natcasesort($result_list))
+	{
+		// new indexing
+		$result_list = array_merge($result_list);
+	}
 	return $result_list; // Now return the list
 }
 
@@ -119,6 +153,60 @@
     }
 }
 
+/**
+* Scan a given directory for dirs and files.
+*
+* usage: scan_current_dir ($root = '' )
+*
+* @param     $root   set a absolute rootpath as string. if root is empty the current path will be scan
+* @param     $search set a search pattern for files, empty search brings all files
+* @access    public
+* @return    array    returns a natsort array with keys 'path' and 'filename'
+*
+*/
+if(!function_exists('scan_current_dir'))
+{
+	function scan_current_dir($root = '', $search = '/.*/')
+	{
+	    $FILE = array();
+		$array = array();
+	    clearstatcache();
+	    $root = empty ($root) ? getcwd() : $root;
+	    if (($handle = opendir($root)))
+	    {
+	    // Loop through the files and dirs an add to list  DIRECTORY_SEPARATOR
+	        while (false !== ($file = readdir($handle)))
+	        {
+	            if (substr($file, 0, 1) != '.' && $file != 'index.php')
+	            {
+	                if (is_dir($root.'/'.$file))
+	                {
+	                    $FILE['path'][] = $file;
+	                } elseif (preg_match($search, $file, $array) )
+                    {
+	                    $FILE['filename'][] = $array[0];
+	                }
+	            }
+	        }
+	        $close_verz = closedir($handle);
+	    }
+
+		// sorting
+	    if (isset ($FILE['path']) && natcasesort($FILE['path']))
+	    {
+			// new indexing
+	        $FILE['path'] = array_merge($FILE['path']);
+	    }
+		// sorting
+	    if (isset ($FILE['filename']) && natcasesort($FILE['filename']))
+	    {
+			// new indexing
+	        $FILE['filename'] = array_merge($FILE['filename']);
+	    }
+	    return $FILE;
+	}
+}
+
 // Function to open a directory and add to a file list
 function file_list($directory, $skip = array(), $show_hidden = false)
 {
@@ -138,7 +226,13 @@
 		}
 		$dir->close(); // Now close the folder object
 	}
-	natsort($result_list); // make the list nice. Not all OS do this itself
+
+    // make the list nice. Not all OS do this itself
+   if(natcasesort($result_list))
+   {
+		$result_list = array_merge($result_list);
+   }
+
 	return $result_list;
 }
 
@@ -163,12 +257,12 @@
 		}
 		function remove_home_subs($directory = '/', $home_folders = '')
 		{
-			if($handle = opendir(WB_PATH.MEDIA_DIRECTORY.$directory))
+			if( ($handle = opendir(WB_PATH.MEDIA_DIRECTORY.$directory)) )
 			{
 				// Loop through the dirs to check the home folders sub-dirs are not shown
 				while(false !== ($file = readdir($handle)))
 				{
-					if($file[0] != '.' AND $file != 'index.php')
+					if($file[0] != '.' && $file != 'index.php')
 					{
 						if(is_dir(WB_PATH.MEDIA_DIRECTORY.$directory.'/'.$file))
 						{
@@ -203,6 +297,154 @@
 	return $home_folders;
 }
 
+/*
+ * @param object &$wb: $wb from frontend or $admin from backend
+ * @return array: list of new entries
+ * @description: callback remove path in files/dirs stored in array
+ * @example: array_walk($array,'remove_path',PATH);
+ */
+//
+function remove_path(&$path, $key, $vars = '')
+{
+	$path = str_replace($vars, '', $path);
+}
+
+/*
+ * @param object &$wb: $wb from frontend or $admin from backend
+ * @return array: list of ro-dirs
+ * @description: returns a list of directories beyound /wb/media which are ReadOnly for current user
+ */
+function media_dirs_ro( &$wb )
+{
+	global $database;
+	// if user is admin or home-folders not activated then there are no restrictions
+	$allow_list = array();
+	if( $wb->get_user_id() == 1 || !HOME_FOLDERS )
+	{
+		return array();
+	}
+	// at first read any dir and subdir from /media
+	$full_list = directory_list( WB_PATH.MEDIA_DIRECTORY );
+	// add own home_folder to allow-list
+	if( $wb->get_home_folder() )
+	{
+		// old: $allow_list[] = get_home_folder();
+		$allow_list[] = $wb->get_home_folder();
+	}
+	// get groups of current user
+	$curr_groups = $wb->get_groups_id();
+	// if current user is in admin-group
+	 if( ($admin_key = array_search('1', $curr_groups)) !== false)
+	{
+		// remove admin-group from list
+		unset($curr_groups[$admin_key]);
+		// search for all users where the current user is admin from
+		foreach( $curr_groups as $group)
+		{
+			$sql  = 'SELECT `home_folder` FROM `'.TABLE_PREFIX.'users` ';
+			$sql .= 'WHERE (FIND_IN_SET(\''.$group.'\', `groups_id`) > 0) AND `home_folder` <> \'\' AND `user_id` <> '.$wb->get_user_id();
+			if( ($res_hf = $database->query($sql)) != null )
+			{
+				while( $rec_hf = $res_hf->fetchrow() )
+				{
+					$allow_list[] = $rec_hf['home_folder'];
+				}
+			}
+		}
+	}
+	$tmp_array = $full_list;
+	// create a list for readonly dir
+    $array = array();
+	while( sizeof($tmp_array) > 0)
+	{
+        $tmp = array_shift($tmp_array);
+        $x = 0;
+		while($x < sizeof($allow_list))
+		{
+			if(strpos ($tmp,$allow_list[$x])) {
+				$array[] = $tmp;
+			}
+			$x++;
+		}
+	}
+
+	$full_list = array_diff( $full_list, $array );
+	$tmp = array();
+	$full_list = array_merge($tmp,$full_list);
+
+	return $full_list;
+}
+
+/*
+ * @param object &$wb: $wb from frontend or $admin from backend
+ * @return array: list of rw-dirs
+ * @description: returns a list of directories beyound /wb/media which are ReadWrite for current user
+ */
+function media_dirs_rw ( &$wb )
+{
+	global $database;
+	// if user is admin or home-folders not activated then there are no restrictions
+	// at first read any dir and subdir from /media
+	$full_list = directory_list( WB_PATH.MEDIA_DIRECTORY );
+    $array = array();
+	$allow_list = array();
+	if( ($wb->ami_group_member('1')) && !HOME_FOLDERS )
+	{
+		return $full_list;
+	}
+	// add own home_folder to allow-list
+	if( $wb->get_home_folder() )
+	{
+	  	$allow_list[] = $wb->get_home_folder();
+	} else {
+		$array = $full_list;
+	}
+	// get groups of current user
+	$curr_groups = $wb->get_groups_id();
+	// if current user is in admin-group
+	if( ($admin_key = array_search('1', $curr_groups)) == true)
+	{
+		// remove admin-group from list
+		// unset($curr_groups[$admin_key]);
+		// search for all users where the current user is admin from
+		foreach( $curr_groups as $group)
+		{
+			$sql  = 'SELECT `home_folder` FROM `'.TABLE_PREFIX.'users` ';
+			$sql .= 'WHERE (FIND_IN_SET(\''.$group.'\', `groups_id`) > 0) AND `home_folder` <> \'\' AND `user_id` <> '.$wb->get_user_id();
+			if( ($res_hf = $database->query($sql)) != null )
+			{
+				while( $rec_hf = $res_hf->fetchrow() )
+				{
+					$allow_list[] = $rec_hf['home_folder'];
+				}
+			}
+		}
+	}
+
+	$tmp_array = $full_list;
+	// create a list for readwrite dir
+	while( sizeof($tmp_array) > 0)
+	{
+        $tmp = array_shift($tmp_array);
+        $x = 0;
+		while($x < sizeof($allow_list))
+		{
+			if(strpos ($tmp,$allow_list[$x])) {
+				$array[] = $tmp;
+			}
+			$x++;
+		}
+	}
+
+	$tmp = array();
+    $array = array_unique($array);
+	$full_list = array_merge($tmp,$array);
+    unset($array);
+    unset($allow_list);
+
+	return $full_list;
+}
+
 // Function to create directories
 function make_dir($dir_name, $dir_mode = OCTAL_DIR_MODE)
 {
@@ -617,7 +859,7 @@
 function make_thumb($source, $destination, $size)
 {
 	// Check if GD is installed
-	if(extension_loaded('gd') AND function_exists('imageCreateFromJpeg'))
+	if(extension_loaded('gd') && function_exists('imageCreateFromJpeg'))
 	{
 		// First figure out the size of the thumbnail
 		list($original_x, $original_y) = getimagesize($source);
@@ -662,7 +904,7 @@
 function extract_permission($octal_value, $who, $action)
 {
 	// Make sure that all arguments are set and $octal_value is a real octal-integer
-	if( ($who == '') or ($action == '') or (preg_match( '/[^0-7]/', (string)$octal_value )) )
+	if( ($who == '') || ($action == '') || (preg_match( '/[^0-7]/', (string)$octal_value )) )
 	{
 		return false; // invalid argument, so return false
 	}
@@ -709,118 +951,165 @@
 }
 
 // Function to delete a page
-function delete_page($page_id)
-{
-	global $admin, $database, $MESSAGE;
-	// Find out more about the page
-	$database = new database();
-	$sql  = 'SELECT `page_id`, `menu_title`, `page_title`, `level`, `link`, `parent`, `modified_by`, `modified_when` ';
-	$sql .= 'FROM `'.TABLE_PREFIX.'pages` WHERE `page_id` = '.$page_id;
-	$results = $database->query($sql);
-	if($database->is_error())    { $admin->print_error($database->get_error()); }
-	if($results->numRows() == 0) { $admin->print_error($MESSAGE['PAGES']['NOT_FOUND']); }
-	$results_array = $results->fetchRow();
-	$parent     = $results_array['parent'];
-	$level      = $results_array['level'];
-	$link       = $results_array['link'];
-	$page_title = $results_array['page_title'];
-	$menu_title = $results_array['menu_title'];
-	
-	// Get the sections that belong to the page
-	$sql = 'SELECT `section_id`, `module` FROM `'.TABLE_PREFIX.'sections` WHERE `page_id` = '.$page_id;
-	$query_sections = $database->query($sql);
-	if($query_sections->numRows() > 0)
+	function delete_page($page_id)
 	{
-		while($section = $query_sections->fetchRow())
+		global $admin, $database, $MESSAGE;
+		// Find out more about the page
+		$sql  = 'SELECT `page_id`, `menu_title`, `page_title`, `level`, `link`, `parent`, `modified_by`, `modified_when` ';
+		$sql .= 'FROM `'.TABLE_PREFIX.'pages` WHERE `page_id` = '.$page_id;
+		$results = $database->query($sql);
+		if($database->is_error())    { $admin->print_error($database->get_error()); }
+		if($results->numRows() == 0) { $admin->print_error($MESSAGE['PAGES']['NOT_FOUND']); }
+		$results_array = $results->fetchRow();
+		$parent     = $results_array['parent'];
+		$level      = $results_array['level'];
+		$link       = $results_array['link'];
+		$page_title = $results_array['page_title'];
+		$menu_title = $results_array['menu_title'];
+
+		// Get the sections that belong to the page
+		$sql = 'SELECT `section_id`, `module` FROM `'.TABLE_PREFIX.'sections` WHERE `page_id` = '.$page_id;
+		$query_sections = $database->query($sql);
+		if($query_sections->numRows() > 0)
 		{
-			// Set section id
-			$section_id = $section['section_id'];
-			// Include the modules delete file if it exists
-			if(file_exists(WB_PATH.'/modules/'.$section['module'].'/delete.php'))
+			while($section = $query_sections->fetchRow())
 			{
-				include(WB_PATH.'/modules/'.$section['module'].'/delete.php');
+				// Set section id
+				$section_id = $section['section_id'];
+				// Include the modules delete file if it exists
+				if(file_exists(WB_PATH.'/modules/'.$section['module'].'/delete.php'))
+				{
+					include(WB_PATH.'/modules/'.$section['module'].'/delete.php');
+				}
 			}
 		}
+		// Update the pages table
+		$sql = 'DELETE FROM `'.TABLE_PREFIX.'pages` WHERE `page_id` = '.$page_id;
+		$database->query($sql);
+		if($database->is_error())
+		{
+			$admin->print_error($database->get_error());
+		}
+		// Update the sections table
+		$sql = 'DELETE FROM `'.TABLE_PREFIX.'sections` WHERE `page_id` = '.$page_id;
+		$database->query($sql);
+		if($database->is_error()) {
+			$admin->print_error($database->get_error());
+		}
+		// Include the ordering class or clean-up ordering
+		include_once(WB_PATH.'/framework/class.order.php');
+		$order = new order(TABLE_PREFIX.'pages', 'position', 'page_id', 'parent');
+		$order->clean($parent);
+		// Unlink the page access file and directory
+		$directory = WB_PATH.PAGES_DIRECTORY.$link;
+		$filename = $directory.PAGE_EXTENSION;
+		$directory .= '/';
+		if(file_exists($filename))
+		{
+			if(!is_writable(WB_PATH.PAGES_DIRECTORY.'/'))
+			{
+				$admin->print_error($MESSAGE['PAGES']['CANNOT_DELETE_ACCESS_FILE']);
+			}
+			else
+			{
+				unlink($filename);
+				if( file_exists($directory) &&
+				   (rtrim($directory,'/') != WB_PATH.PAGES_DIRECTORY) &&
+				   (substr($link, 0, 1) != '.'))
+				{
+					rm_full_dir($directory);
+				}
+			}
+		}
 	}
-	// Update the pages table
-	$sql = 'DELETE FROM `'.TABLE_PREFIX.'pages` WHERE `page_id` = '.$page_id;
-	$database->query($sql);
-	if($database->is_error())
+
+/*
+ * @param string $file: name of the file to read
+ * @param int $size: number of maximum bytes to read (0 = complete file)
+ * @return string: the content as string, false on error
+ */
+	function getFilePart($file, $size = 0)
 	{
-		$admin->print_error($database->get_error());
-	}
-	// Update the sections table
-	$sql = 'DELETE FROM `'.TABLE_PREFIX.'sections` WHERE `page_id` = '.$page_id;
-	$database->query($sql);
-	if($database->is_error()) {
-		$admin->print_error($database->get_error());
-	}
-	// Include the ordering class or clean-up ordering
-	include_once(WB_PATH.'/framework/class.order.php');
-	$order = new order(TABLE_PREFIX.'pages', 'position', 'page_id', 'parent');
-	$order->clean($parent);
-	// Unlink the page access file and directory
-	$directory = WB_PATH.PAGES_DIRECTORY.$link;
-	$filename = $directory.PAGE_EXTENSION;
-	$directory .= '/';
-	if(file_exists($filename))
-	{
-		if(!is_writable(WB_PATH.PAGES_DIRECTORY.'/'))
+		$file_content = '';
+		if( file_exists($file) && is_file($file) && is_readable($file))
 		{
-			$admin->print_error($MESSAGE['PAGES']['CANNOT_DELETE_ACCESS_FILE']);
+			if($size == 0)
+			{
+				$size = filesize($file);
+			}
+			if(($fh = fopen($file, 'rb')))
+			{
+				if( ($file_content = fread($fh, $size)) !== false )
+				{
+					return $file_content;
+				}
+				fclose($fh);
+			}
 		}
-		else
+		return false;
+	}
+
+	/**
+	* replace varnames with values in a string
+	*
+	* @param string $subject: stringvariable with vars placeholder
+	* @param array $replace: values to replace vars placeholder
+	* @return string
+	*/
+    function replace_vars($subject = '', &$replace = null )
+    {
+		if(is_array($replace))
 		{
-			unlink($filename);
-			if( file_exists($directory) &&
-			   (rtrim($directory,'/') != WB_PATH.PAGES_DIRECTORY) &&
-			   (substr($link, 0, 1) != '.'))
+			foreach ($replace  as $key => $value)
 			{
-				rm_full_dir($directory);
+				$subject = str_replace("{{".$key."}}", $value, $subject);
 			}
 		}
-	}
-}
+		return $subject;
+    }
 
 // Load module into DB
 function load_module($directory, $install = false)
 {
 	global $database,$admin,$MESSAGE;
-
-	if(is_dir($directory) AND file_exists($directory.'/info.php'))
+	$retVal = false;
+	if(is_dir($directory) && file_exists($directory.'/info.php'))
 	{
 		require($directory.'/info.php');
 		if(isset($module_name))
 		{
-			if(!isset($module_license))                                  { $module_license = 'GNU General Public License'; }
-			if(!isset($module_platform) AND isset($module_designed_for)) { $module_platform = $module_designed_for; }
-			if(!isset($module_function) AND isset($module_type))         { $module_function = $module_type; }
+			if(!isset($module_license)) { $module_license = 'GNU General Public License'; }
+			if(!isset($module_platform) && isset($module_designed_for)) { $module_platform = $module_designed_for; }
+			if(!isset($module_function) && isset($module_type)) { $module_function = $module_type; }
 			$module_function = strtolower($module_function);
 			// Check that it doesn't already exist
-			$sql  = 'SELECT `addon_id` FROM `'.TABLE_PREFIX.'addons` ';
-			$sql .= 'WHERE `type` = "module" AND `directory` = "'.$module_directory.'" LIMIT 0,1';
-			$result = $database->query($sql);
-			if($result->numRows() == 0)
+			$sqlwhere = 'WHERE `type` = \'module\' AND `directory` = \''.$module_directory.'\'';
+			$sql  = 'SELECT COUNT(*) FROM `'.TABLE_PREFIX.'addons` '.$sqlwhere;
+			if( $database->get_one($sql) )
 			{
+				$sql  = 'UPDATE `'.TABLE_PREFIX.'addons` SET ';
+			}else{
 				// Load into DB
 				$sql  = 'INSERT INTO `'.TABLE_PREFIX.'addons` SET ';
-				$sql .= '`directory` = "'.$module_directory.'", ';
-				$sql .= '`name` = "'.$module_name.'", ';
-				$sql .= '`description`= "'.addslashes($module_description).'", ';
-				$sql .= '`type`= "module", ';
-				$sql .= '`function` = "'.$module_function.'", ';
-				$sql .= '`version` = "'.$module_version.'", ';
-				$sql .= '`platform` = "'.$module_platform.'", ';
-				$sql .= '`author` = "'.addslashes($module_author).'", ';
-				$sql .= '`license` = "'.addslashes($module_license).'"';
-				$database->query($sql);
-				// Run installation script
-				if($install == true)
+				$sqlwhere = '';
+			}
+			$sql .= '`directory` = \''.$module_directory.'\', ';
+			$sql .= '`name` = \''.$module_name.'\', ';
+			$sql .= '`description`= \''.addslashes($module_description).'\', ';
+			$sql .= '`type`= \'module\', ';
+			$sql .= '`function` = \''.$module_function.'\', ';
+			$sql .= '`version` = \''.$module_version.'\', ';
+			$sql .= '`platform` = \''.$module_platform.'\', ';
+			$sql .= '`author` = \''.addslashes($module_author).'\', ';
+			$sql .= '`license` = \''.addslashes($module_license).'\'';
+			$sql .= $sqlwhere;
+			$retVal = $database->query($sql);
+			// Run installation script
+			if($install == true)
+			{
+				if(file_exists($directory.'/install.php'))
 				{
-					if(file_exists($directory.'/install.php'))
-					{
-						require($directory.'/install.php');
-					}
+					require($directory.'/install.php');
 				}
 			}
 		}
@@ -831,7 +1120,8 @@
 function load_template($directory)
 {
 	global $database, $admin;
-	if(is_dir($directory) AND file_exists($directory.'/info.php'))
+	$retVal = false;
+	if(is_dir($directory) && file_exists($directory.'/info.php'))
 	{
 		require($directory.'/info.php');
 		if(isset($template_name))
@@ -840,7 +1130,7 @@
             {
               $template_license = 'GNU General Public License';
             }
-			if(!isset($template_platform) AND isset($template_designed_for))
+			if(!isset($template_platform) && isset($template_designed_for))
             {
               $template_platform = $template_designed_for;
             }
@@ -849,26 +1139,30 @@
               $template_function = 'template';
             }
 			// Check that it doesn't already exist
-			$sql  = 'SELECT `addon_id` FROM `'.TABLE_PREFIX.'addons` ';
-			$sql .= 'WHERE `type` = "template" AND `directory` = "'.$template_directory.'" LIMIT 0,1';
-			$result = $database->query($sql);
-			if($result->numRows() == 0)
+			$sqlwhere = 'WHERE `type` = \'template\' AND `directory` = \''.$template_directory.'\'';
+			$sql  = 'SELECT COUNT(*) FROM `'.TABLE_PREFIX.'addons` '.$sqlwhere;
+			if( $database->get_one($sql) )
 			{
+				$sql  = 'UPDATE `'.TABLE_PREFIX.'addons` SET ';
+			}else{
 				// Load into DB
 				$sql  = 'INSERT INTO `'.TABLE_PREFIX.'addons` SET ';
-				$sql .= '`directory` = "'.$template_directory.'", ';
-				$sql .= '`name` = "'.$template_name.'", ';
-				$sql .= '`description`= "'.addslashes($template_description).'", ';
-				$sql .= '`type`= "template", ';
-				$sql .= '`function` = "'.$template_function.'", ';
-				$sql .= '`version` = "'.$template_version.'", ';
-				$sql .= '`platform` = "'.$template_platform.'", ';
-				$sql .= '`author` = "'.addslashes($template_author).'", ';
-				$sql .= '`license` = "'.addslashes($template_license).'" ';
-				$database->query($sql);
+				$sqlwhere = '';
 			}
+			$sql .= '`directory` = \''.$template_directory.'\', ';
+			$sql .= '`name` = \''.$template_name.'\', ';
+			$sql .= '`description`= \''.addslashes($template_description).'\', ';
+			$sql .= '`type`= \'template\', ';
+			$sql .= '`function` = \''.$template_function.'\', ';
+			$sql .= '`version` = \''.$template_version.'\', ';
+			$sql .= '`platform` = \''.$template_platform.'\', ';
+			$sql .= '`author` = \''.addslashes($template_author).'\', ';
+			$sql .= '`license` = \''.addslashes($template_license).'\' ';
+			$sql .= $sqlwhere;
+			$retVal = $database->query($sql);
 		}
 	}
+	return $retVal;
 }
 
 // Load language into DB
@@ -875,32 +1169,46 @@
 function load_language($file)
 {
 	global $database,$admin;
+	$retVal = false;
 	if (file_exists($file) && preg_match('#^([A-Z]{2}.php)#', basename($file)))
 	{
-		require($file);
+		// require($file);  it's to large
+		// read contents of the template language file into string
+		$data = @file_get_contents(WB_PATH.'/languages/'.str_replace('.php','',basename($file)).'.php');
+		// use regular expressions to fetch the content of the variable from the string
+		$language_name = get_variable_content('language_name', $data, false);
+		$language_code = get_variable_content('language_code', $data, false);
+		$language_author = get_variable_content('language_author', $data);
+		$language_version = get_variable_content('language_version', $data, false);
+		$language_platform = get_variable_content('language_platform', $data, false);
+
 		if(isset($language_name))
 		{
-			if(!isset($language_license))                                    { $language_license = 'GNU General Public License'; }
-			if(!isset($language_platform) AND isset($language_designed_for)) { $language_platform = $language_designed_for; }
+			if(!isset($language_license)) { $language_license = 'GNU General Public License'; }
+			if(!isset($language_platform) && isset($language_designed_for)) { $language_platform = $language_designed_for; }
 			// Check that it doesn't already exist
-			$sql  = 'SELECT `addon_id` FROM `'.TABLE_PREFIX.'addons` ';
-			$sql .= 'WHERE `type` = "language" AND `directory` = "'.$language_code.'" LIMIT 0,1';
-			$result = $database->query($sql);
-			if($result->numRows() == 0)
+			$sqlwhere = 'WHERE `type` = \'language\' AND `directory` = \''.$language_code.'\'';
+			$sql  = 'SELECT COUNT(*) FROM `'.TABLE_PREFIX.'addons` '.$sqlwhere;
+			if( $database->get_one($sql) )
 			{
+				$sql  = 'UPDATE `'.TABLE_PREFIX.'addons` SET ';
+			}else{
 				// Load into DB
 				$sql  = 'INSERT INTO `'.TABLE_PREFIX.'addons` SET ';
-				$sql .= '`directory` = "'.$language_code.'", ';
-				$sql .= '`name` = "'.$language_name.'", ';
-				$sql .= '`type`= "language", ';
-				$sql .= '`version` = "'.$language_version.'", ';
-				$sql .= '`platform` = "'.$language_platform.'", ';
-				$sql .= '`author` = "'.addslashes($language_author).'", ';
-				$sql .= '`license` = "'.addslashes($language_license).'"';
-				$database->query($sql);
+				$sqlwhere = '';
 			}
+			$sql .= '`directory` = \''.$language_code.'\', ';
+			$sql .= '`name` = \''.$language_name.'\', ';
+			$sql .= '`type`= \'language\', ';
+			$sql .= '`version` = \''.$language_version.'\', ';
+			$sql .= '`platform` = \''.$language_platform.'\', ';
+			$sql .= '`author` = \''.addslashes($language_author).'\', ';
+			$sql .= '`license` = \''.addslashes($language_license).'\' ';
+			$sql .= $sqlwhere;
+			$retVal = $database->query($sql);
 		}
 	}
+	return $retVal;
 }
 
 // Upgrade module info in DB, optionally start upgrade script
@@ -913,21 +1221,19 @@
 		require($mod_directory.'/info.php');
 		if(isset($module_name))
 		{
-			if(!isset($module_license))                                  { $module_license = 'GNU General Public License'; }
+			if(!isset($module_license)) { $module_license = 'GNU General Public License'; }
 			if(!isset($module_platform) && isset($module_designed_for)) { $module_platform = $module_designed_for; }
-			if(!isset($module_function) && isset($module_type))         { $module_function = $module_type; }
+			if(!isset($module_function) && isset($module_type)) { $module_function = $module_type; }
 			$module_function = strtolower($module_function);
 			// Check that it does already exist
-			// Check that it does already exist
 			$sql  = 'SELECT COUNT(*) FROM `'.TABLE_PREFIX.'addons` ';
 			$sql .= 'WHERE `directory` = \''.$module_directory.'\'';
-
 			if( $database->get_one($sql) )
 			{
 				// Update in DB
 				$sql  = 'UPDATE `'.TABLE_PREFIX.'addons` SET ';
-				$sql .= '`version` = \''.$module_version.'\', ';
-				$sql .= '`description` = \''.addslashes($module_description).'\', ';
+				$sql .= '`version` = "'.$module_version.'", ';
+				$sql .= '`description` = "'.addslashes($module_description).'", ';
 				$sql .= '`platform` = \''.$module_platform.'\', ';
 				$sql .= '`author` = \''.addslashes($module_author).'\', ';
 				$sql .= '`license` = \''.addslashes($module_license).'\' ';
@@ -973,4 +1279,57 @@
 	}
 }
 
-?>
+/*
+ * @param string $modulname: like saved in addons.directory
+ * @param boolean $source: true reads from database, false from info.php
+ * @return string:  the version as string, if not found returns null
+ */
+
+	function get_modul_version($modulname, $source = true)
+	{
+		global $database;
+		$version = null;
+		if( $source != true )
+		{
+			$sql = 'SELECT `version` FROM `'.TABLE_PREFIX.'addons` WHERE `directory`=\''.$modulname.'\'';
+			$version = $database->get_one($sql);
+		} else {
+			$info_file = WB_PATH.'/modules/'.$modulname.'/info.php';
+			if(file_exists($info_file))
+			{
+				if(($info_file = file_get_contents($info_file)))
+				{
+					$version = get_variable_content('module_version', $info_file, false, false);
+					$version = ($version !== false) ? $version : null;
+				}
+			}
+		}
+		return $version;
+	}
+
+/*
+ * @param string $varlist: commaseperated list of varnames to move into global space
+ * @return bool:  false if one of the vars already exists in global space (error added to msgQueue)
+ */
+	function vars2globals_wrapper($varlist)
+	{
+		$retval = true;
+		if( $varlist != '')
+		{
+			$vars = explode(',', $varlist);
+			foreach( $vars as $var)
+			{
+				if( isset($GLOBALS[$var]) )
+				{
+					ErrorLog::write( 'variabe $'.$var.' already defined in global space!!',__FILE__, __FUNCTION__, __LINE__);
+					$retval = false;
+				}else
+				{
+					global $$var;
+				}
+			}
+		}
+		return $retval;
+	}
+
+
Index: branches/2.8.x/wb/framework/class.wb.php
===================================================================
--- branches/2.8.x/wb/framework/class.wb.php	(revision 1364)
+++ branches/2.8.x/wb/framework/class.wb.php	(revision 1365)
@@ -1,365 +1,432 @@
-<?php
-/**
- *
- * @category        frontend
- * @package         framework
- * @author          WebsiteBaker Project
- * @copyright       2004-2009, Ryan Djurovich
- * @copyright       2009-2011, 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 5.2.2 and higher
- * @version         $Id$
- * @filesource		$HeadURL: $
- * @lastmodified    $Date:  $
- *
- */
-
-// Include PHPLIB template class
-require_once(WB_PATH."/include/phplib/template.inc");
-
-require_once(WB_PATH.'/framework/class.database.php');
-
-// Include new wbmailer class (subclass of PHPmailer)
-require_once(WB_PATH."/framework/class.wbmailer.php");
-
-require_once(WB_PATH."/framework/class.secureform.php");
-
-class wb extends SecureForm
-{
-
-	var $password_chars = 'a-zA-Z0-9\_\-\!\#\*\+';
-	// General initialization function
-	// performed when frontend or backend is loaded.
-
-	function wb() {
-	}
-
-
-	// Check whether a page is visible or not.
-	// This will check page-visibility and user- and group-rights.
-	/* page_is_visible() returns
-		false: if page-visibility is 'none' or 'deleted', or page-vis. is 'registered' or 'private' and user isn't allowed to see the page.
-		true: if page-visibility is 'public' or 'hidden', or page-vis. is 'registered' or 'private' and user _is_ allowed to see the page.
-	*/
-	function page_is_visible($page)
-    {
-		$show_it = false; // shall we show the page?
-		$page_id = $page['page_id'];
-		$visibility = $page['visibility'];
-		$viewing_groups = $page['viewing_groups'];
-		$viewing_users = $page['viewing_users'];
-
-		// First check if visibility is 'none', 'deleted'
-		if($visibility == 'none')
-        {
-			return(false);
-		} elseif($visibility == 'deleted')
-        {
-			return(false);
-		}
-
-		// Now check if visibility is 'hidden', 'private' or 'registered'
-		if($visibility == 'hidden') { // hidden: hide the menu-link, but show the page
-			$show_it = true;
-		} elseif($visibility == 'private' || $visibility == 'registered')
-        {
-			// Check if the user is logged in
-			if($this->is_authenticated() == true)
-            {
-				// Now check if the user has perms to view the page
-				$in_group = false;
-				foreach($this->get_groups_id() as $cur_gid)
-                {
-				    if(in_array($cur_gid, explode(',', $viewing_groups)))
-                    {
-				        $in_group = true;
-				    }
-				}
-				if($in_group || in_array($this->get_user_id(), explode(',', $viewing_users))) {
-					$show_it = true;
-				} else {
-					$show_it = false;
-				}
-			} else {
-				$show_it = false;
-			}
-		} elseif($visibility == 'public') {
-			$show_it = true;
-		} else {
-			$show_it = false;
-		}
-		return($show_it);
-	}
-	// Check if there is at least one active section on this page
-	function page_is_active($page)
-    {
-		global $database;
-		$has_active_sections = false;
-		$page_id = $page['page_id'];
-		$now = time();
-		$query_sections = $database->query("SELECT publ_start,publ_end FROM ".TABLE_PREFIX."sections WHERE page_id = '$page_id'");
-		if($query_sections->numRows() != 0)
-        {
-			while($section = $query_sections->fetchRow())
-            {
-				if($now<$section['publ_end'] && ($now>$section['publ_start'] || $section['publ_start']==0) || $now>$section['publ_start'] && $section['publ_end']==0)
-                {
-					$has_active_sections = true;
-					break;
-				}
-			}
-		}
-		return($has_active_sections);
-	}
-
-	// Check whether we should show a page or not (for front-end)
-	function show_page($page)
-    {
-		if($this->page_is_visible($page) && $this->page_is_active($page))
-        {
-			return true;
-		} else {
-			return false;
-		}
-	}
-
-	// Check if the user is already authenticated or not
-	function is_authenticated() {
-		if(isset($_SESSION['USER_ID']) AND $_SESSION['USER_ID'] != "" AND is_numeric($_SESSION['USER_ID']))
-        {
-			return true;
-		} else {
-			return false;
-		}
-	}
-
-	// Modified addslashes function which takes into account magic_quotes
-	function add_slashes($input) {
-		if ( get_magic_quotes_gpc() || ( !is_string($input) ) ) {
-			return $input;
-		}
-		$output = addslashes($input);
-		return $output;
-	}
-
-	// Ditto for stripslashes
-	// Attn: this is _not_ the counterpart to $this->add_slashes() !
-	// Use stripslashes() to undo a preliminarily done $this->add_slashes()
-	// The purpose of $this->strip_slashes() is to undo the effects of magic_quotes_gpc==On
-	function strip_slashes($input) {
-		if ( !get_magic_quotes_gpc() || ( !is_string($input) ) ) {
-			return $input;
-		}
-		$output = stripslashes($input);
-		return $output;
-	}
-
-	// Escape backslashes for use with mySQL LIKE strings
-	function escape_backslashes($input) {
-		return str_replace("\\","\\\\",$input);
-	}
-
-	function page_link($link){
-		// Check for :// in the link (used in URL's) as well as mailto:
-		if(strstr($link, '://') == '' AND substr($link, 0, 7) != 'mailto:') {
-			return WB_URL.PAGES_DIRECTORY.$link.PAGE_EXTENSION;
-		} else {
-			return $link;
-		}
-	}
-	
-	// Get POST data
-	function get_post($field) {
-		if(isset($_POST[$field])) {
-			return $_POST[$field];
-		} else {
-			return null;
-		}
-	}
-
-	// Get POST data and escape it
-	function get_post_escaped($field) {
-		$result = $this->get_post($field);
-		return (is_null($result)) ? null : $this->add_slashes($result);
-	}
-	
-	// Get GET data
-	function get_get($field) {
-		if(isset($_GET[$field])) {
-			return $_GET[$field];
-		} else {
-			return null;
-		}
-	}
-
-	// Get SESSION data
-	function get_session($field) {
-		if(isset($_SESSION[$field])) {
-			return $_SESSION[$field];
-		} else {
-			return null;
-		}
-	}
-
-	// Get SERVER data
-	function get_server($field) {
-		if(isset($_SERVER[$field])) {
-			return $_SERVER[$field];
-		} else {
-			return null;
-		}
-	}
-
-	// Get the current users id
-	function get_user_id() {
-		return $_SESSION['USER_ID'];
-	}
-
-	// Get the current users group id
-	function get_group_id() {
-		return $_SESSION['GROUP_ID'];
-	}
-
-	// Get the current users group ids
-	function get_groups_id() {
-		return explode(",", $_SESSION['GROUPS_ID']);
-	}
-
-	// Get the current users group name
-	function get_group_name() {
-		return implode(",", $_SESSION['GROUP_NAME']);
-	}
-
-	// Get the current users group name
-	function get_groups_name() {
-		return $_SESSION['GROUP_NAME'];
-	}
-
-	// Get the current users username
-	function get_username() {
-		return $_SESSION['USERNAME'];
-	}
-
-	// Get the current users display name
-	function get_display_name() {
-		return ($_SESSION['DISPLAY_NAME']);
-	}
-
-	// Get the current users email address
-	function get_email() {
-		return $_SESSION['EMAIL'];
-	}
-
-	// Get the current users home folder
-	function get_home_folder() {
-		return $_SESSION['HOME_FOLDER'];
-	}
-
-	// Get the current users timezone
-	function get_timezone() {
-		if(!isset($_SESSION['USE_DEFAULT_TIMEZONE'])) {
-			return $_SESSION['TIMEZONE'];
-		} else {
-			return '-72000';
-		}
-	}
-
-	// Validate supplied email address
-	function validate_email($email) {
-		if(preg_match('/^([0-9a-zA-Z]+[-._+&])*[0-9a-zA-Z]+@([-0-9a-zA-Z]+[.])+[a-zA-Z]{2,6}$/', $email)) {
-		return true;
-		} else {
-			return false;
-		}
-	}
-
-	// Print a success message which then automatically redirects the user to another page
-	function print_success( $message, $redirect = 'index.php' ) {
-	    global $TEXT;
-	    // fetch redirect timer for sucess messages from settings table
-	    $redirect_timer = ((defined( 'REDIRECT_TIMER' )) && (REDIRECT_TIMER >= 1500)) ? REDIRECT_TIMER : 0;
-	    // add template variables
-	    $tpl = new Template( THEME_PATH.'/templates' );
-	    $tpl->set_file( 'page', 'success.htt' );
-	    $tpl->set_block( 'page', 'main_block', 'main' );
-	    $tpl->set_block( 'main_block', 'show_redirect_block', 'show_redirect' );
-	    $tpl->set_var( 'MESSAGE', $message );
-	    $tpl->set_var( 'REDIRECT', $redirect );
-	    $tpl->set_var( 'REDIRECT_TIMER', $redirect_timer );
-	    $tpl->set_var( 'NEXT', $TEXT['NEXT'] );
-	    $tpl->set_var( 'BACK', $TEXT['BACK'] );
-	    if ($redirect_timer == 0) {
-	        $tpl->set_block( 'show_redirect', '' );
-	    }
-	    else {
-	        $tpl->parse( 'show_redirect', 'show_redirect_block', true );
-	    }
-	    $tpl->parse( 'main', 'main_block', false );
-	    $tpl->pparse( 'output', 'page' );
-	}
-
-	// Print an error message
-	function print_error($message, $link = 'index.php', $auto_footer = true) {
-		global $TEXT;
-		$success_template = new Template(THEME_PATH.'/templates');
-		$success_template->set_file('page', 'error.htt');
-		$success_template->set_block('page', 'main_block', 'main');
-		$success_template->set_var('MESSAGE', $message);
-		$success_template->set_var('LINK', $link);
-		$success_template->set_var('BACK', $TEXT['BACK']);
-		$success_template->parse('main', 'main_block', false);
-		$success_template->pparse('output', 'page');
-		if ( $auto_footer == true ) {
-			if ( method_exists($this, "print_footer") ) {
-				$this->print_footer();
-			}
-		}
-		exit();
-	}
-
-	// Validate send email
-	function mail($fromaddress, $toaddress, $subject, $message, $fromname='') {
-		/* 
-			INTEGRATED OPEN SOURCE PHPMAILER CLASS FOR SMTP SUPPORT AND MORE
-			SOME SERVICE PROVIDERS DO NOT SUPPORT SENDING MAIL VIA PHP AS IT DOES NOT PROVIDE SMTP AUTHENTICATION
-			NEW WBMAILER CLASS IS ABLE TO SEND OUT MESSAGES USING SMTP WHICH RESOLVE THESE ISSUE (C. Sommer)
-
-			NOTE:
-			To use SMTP for sending out mails, you have to specify the SMTP host of your domain
-			via the Settings panel in the backend of Website Baker
-		*/ 
-
-		$fromaddress = preg_replace('/[\r\n]/', '', $fromaddress);
-		$toaddress = preg_replace('/[\r\n]/', '', $toaddress);
-		$subject = preg_replace('/[\r\n]/', '', $subject);
-		$message_alt = $message;
-		$message = preg_replace('/[\r\n]/', '<br \>', $message);
-		
-		// create PHPMailer object and define default settings
-		$myMail = new wbmailer();
-
-		// set user defined from address
-		if ($fromaddress!='') {
-			if($fromname!='') $myMail->FromName = $fromname;         // FROM-NAME
-			$myMail->From = $fromaddress;                            // FROM:
-			$myMail->AddReplyTo($fromaddress);                       // REPLY TO:
-		}
-		
-		// define recepient and information to send out
-		$myMail->AddAddress($toaddress);                            // TO:
-		$myMail->Subject = $subject;                                // SUBJECT
-		$myMail->Body = $message;                                   // CONTENT (HTML)
-		$myMail->AltBody = strip_tags($message_alt);				// CONTENT (TEXT)
-		
-		// check if there are any send mail errors, otherwise say successful
-		if (!$myMail->Send()) {
-			return false;
-		} else {
-			return true;
-		}
-	}
-
-}
+<?php
+/**
+ *
+ * @category        frontend
+ * @package         framework
+ * @author          WebsiteBaker Project
+ * @copyright       2004-2009, Ryan Djurovich
+ * @copyright       2009-2011, 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 5.2.2 and higher
+ * @version         $Id$
+ * @filesource		$HeadURL: $
+ * @lastmodified    $Date:  $
+ *
+ */
+
+// Include PHPLIB template class
+require_once(WB_PATH."/include/phplib/template.inc");
+
+require_once(WB_PATH.'/framework/class.database.php');
+
+// Include new wbmailer class (subclass of PHPmailer)
+require_once(WB_PATH."/framework/class.wbmailer.php");
+
+require_once(WB_PATH."/framework/class.secureform.php");
+
+class wb extends SecureForm
+{
+
+	var $password_chars = 'a-zA-Z0-9\_\-\!\#\*\+';
+	// General initialization function
+	// performed when frontend or backend is loaded.
+
+	function wb() {
+	}
+
+/* ****************
+ * check if current user is member of at least one of given groups
+ * ADMIN (uid=1) always is treated like a member of any groups
+ *
+ * @access public
+ * @param mixed $groups_list: an array or a coma seperated list of group-ids
+ * @return bool: true if current user is member of one of this groups, otherwise false
+ */
+	function ami_group_member( $groups_list = '' )
+	{
+		if( $this->get_user_id() == 1 ) { return true; }
+		return $this->is_group_match( $groups_list, $this->get_groups_id() );
+	}
+
+	// Check whether a page is visible or not.
+	// This will check page-visibility and user- and group-rights.
+	/* page_is_visible() returns
+		false: if page-visibility is 'none' or 'deleted', or page-vis. is 'registered' or 'private' and user isn't allowed to see the page.
+		true: if page-visibility is 'public' or 'hidden', or page-vis. is 'registered' or 'private' and user _is_ allowed to see the page.
+	*/
+	function page_is_visible($page)
+    {
+		$show_it = false; // shall we show the page?
+		$page_id = $page['page_id'];
+		$visibility = $page['visibility'];
+		$viewing_groups = $page['viewing_groups'];
+		$viewing_users = $page['viewing_users'];
+
+		// First check if visibility is 'none', 'deleted'
+		if($visibility == 'none')
+        {
+			return(false);
+		} elseif($visibility == 'deleted')
+        {
+			return(false);
+		}
+
+		// Now check if visibility is 'hidden', 'private' or 'registered'
+		if($visibility == 'hidden') { // hidden: hide the menu-link, but show the page
+			$show_it = true;
+		} elseif($visibility == 'private' || $visibility == 'registered')
+        {
+			// Check if the user is logged in
+			if($this->is_authenticated() == true)
+            {
+				// Now check if the user has perms to view the page
+				$in_group = false;
+				foreach($this->get_groups_id() as $cur_gid)
+                {
+				    if(in_array($cur_gid, explode(',', $viewing_groups)))
+                    {
+				        $in_group = true;
+				    }
+				}
+				if($in_group || in_array($this->get_user_id(), explode(',', $viewing_users))) {
+					$show_it = true;
+				} else {
+					$show_it = false;
+				}
+			} else {
+				$show_it = false;
+			}
+		} elseif($visibility == 'public') {
+			$show_it = true;
+		} else {
+			$show_it = false;
+		}
+		return($show_it);
+	}
+	// Check if there is at least one active section on this page
+	function page_is_active($page)
+    {
+		global $database;
+		$has_active_sections = false;
+		$page_id = $page['page_id'];
+		$now = time();
+		$query_sections = $database->query("SELECT publ_start,publ_end FROM ".TABLE_PREFIX."sections WHERE page_id = '$page_id'");
+		if($query_sections->numRows() != 0)
+        {
+			while($section = $query_sections->fetchRow())
+            {
+				if($now<$section['publ_end'] && ($now>$section['publ_start'] || $section['publ_start']==0) || $now>$section['publ_start'] && $section['publ_end']==0)
+                {
+					$has_active_sections = true;
+					break;
+				}
+			}
+		}
+		return($has_active_sections);
+	}
+
+	// Check whether we should show a page or not (for front-end)
+	function show_page($page)
+    {
+		if($this->page_is_visible($page) && $this->page_is_active($page))
+        {
+			return true;
+		} else {
+			return false;
+		}
+	}
+
+	// Check if the user is already authenticated or not
+	function is_authenticated() {
+		if(isset($_SESSION['USER_ID']) AND $_SESSION['USER_ID'] != "" AND is_numeric($_SESSION['USER_ID']))
+        {
+			return true;
+		} else {
+			return false;
+		}
+	}
+
+	// Modified addslashes function which takes into account magic_quotes
+	function add_slashes($input) {
+		if ( get_magic_quotes_gpc() || ( !is_string($input) ) ) {
+			return $input;
+		}
+		$output = addslashes($input);
+		return $output;
+	}
+
+	// Ditto for stripslashes
+	// Attn: this is _not_ the counterpart to $this->add_slashes() !
+	// Use stripslashes() to undo a preliminarily done $this->add_slashes()
+	// The purpose of $this->strip_slashes() is to undo the effects of magic_quotes_gpc==On
+	function strip_slashes($input) {
+		if ( !get_magic_quotes_gpc() || ( !is_string($input) ) ) {
+			return $input;
+		}
+		$output = stripslashes($input);
+		return $output;
+	}
+
+	// Escape backslashes for use with mySQL LIKE strings
+	function escape_backslashes($input) {
+		return str_replace("\\","\\\\",$input);
+	}
+
+	function page_link($link){
+		// Check for :// in the link (used in URL's) as well as mailto:
+		if(strstr($link, '://') == '' AND substr($link, 0, 7) != 'mailto:') {
+			return WB_URL.PAGES_DIRECTORY.$link.PAGE_EXTENSION;
+		} else {
+			return $link;
+		}
+	}
+	
+	// Get POST data
+	function get_post($field) {
+		if(isset($_POST[$field])) {
+			return $_POST[$field];
+		} else {
+			return null;
+		}
+	}
+
+	// Get POST data and escape it
+	function get_post_escaped($field) {
+		$result = $this->get_post($field);
+		return (is_null($result)) ? null : $this->add_slashes($result);
+	}
+	
+	// Get GET data
+	function get_get($field) {
+		if(isset($_GET[$field])) {
+			return $_GET[$field];
+		} else {
+			return null;
+		}
+	}
+
+	// Get SESSION data
+	function get_session($field) {
+		if(isset($_SESSION[$field])) {
+			return $_SESSION[$field];
+		} else {
+			return null;
+		}
+	}
+
+	// Get SERVER data
+	function get_server($field) {
+		if(isset($_SERVER[$field])) {
+			return $_SERVER[$field];
+		} else {
+			return null;
+		}
+	}
+
+	// Get the current users id
+	function get_user_id() {
+		return $_SESSION['USER_ID'];
+	}
+
+	// Get the current users group id
+	function get_group_id() {
+		return $_SESSION['GROUP_ID'];
+	}
+
+	// Get the current users group ids
+	function get_groups_id() {
+		return explode(",", $_SESSION['GROUPS_ID']);
+	}
+
+	// Get the current users group name
+	function get_group_name() {
+		return implode(",", $_SESSION['GROUP_NAME']);
+	}
+
+	// Get the current users group name
+	function get_groups_name() {
+		return $_SESSION['GROUP_NAME'];
+	}
+
+	// Get the current users username
+	function get_username() {
+		return $_SESSION['USERNAME'];
+	}
+
+	// Get the current users display name
+	function get_display_name() {
+		return ($_SESSION['DISPLAY_NAME']);
+	}
+
+	// Get the current users email address
+	function get_email() {
+		return $_SESSION['EMAIL'];
+	}
+
+	// Get the current users home folder
+	function get_home_folder() {
+		return $_SESSION['HOME_FOLDER'];
+	}
+
+	// Get the current users timezone
+	function get_timezone() {
+		if(!isset($_SESSION['USE_DEFAULT_TIMEZONE'])) {
+			return $_SESSION['TIMEZONE'];
+		} else {
+			return '-72000';
+		}
+	}
+/*  */
+	// Validate supplied email address
+	function validate_email($email) {
+		if(preg_match('/^([0-9a-zA-Z]+[-._+&])*[0-9a-zA-Z]+@([-0-9a-zA-Z]+[.])+[a-zA-Z]{2,6}$/', $email)) {
+		return true;
+		} else {
+			return false;
+		}
+	}
+
+
+/* ****************
+ * set one or more bit in a integer value
+ *
+ * @access public
+ * @param int $value: reference to the integer, containing the value
+ * @param int $bits2set: the bitmask witch shall be added to value
+ * @return void
+ */
+	function bit_set( &$value, $bits2set )
+	{
+		$value |= $bits2set;
+	}
+
+/* ****************
+ * reset one or more bit from a integer value
+ *
+ * @access public
+ * @param int $value: reference to the integer, containing the value
+ * @param int $bits2reset: the bitmask witch shall be removed from value
+ * @return void
+ */
+	function bit_reset( &$value, $bits2reset)
+	{
+		$value &= ~$bits2reset;
+	}
+
+/* ****************
+ * check if one or more bit in a integer value are set
+ *
+ * @access public
+ * @param int $value: reference to the integer, containing the value
+ * @param int $bits2set: the bitmask witch shall be added to value
+ * @return void
+ */
+	function bit_isset( $value, $bits2test )
+	{
+		return (($value & $bits2test) == $bits2test);
+	}
+
+/*
+	// Validate supplied email address
+	function validate_email($email) {
+		if(function_exists('idn_to_ascii')){ // use pear if available 
+			$email = idn_to_ascii($email);
+		}else {
+			require_once(WB_PATH.'/include/idna_convert/idna_convert.class.php');
+			$IDN = new idna_convert();
+			$email = $IDN->encode($email);
+			unset($IDN);
+		}
+		return !(filter_var($email, FILTER_VALIDATE_EMAIL) == false);
+	}
+*/
+	// Print a success message which then automatically redirects the user to another page
+	function print_success( $message, $redirect = 'index.php' ) {
+	    global $TEXT;
+	    // fetch redirect timer for sucess messages from settings table
+	    $redirect_timer = ((defined( 'REDIRECT_TIMER' )) && (REDIRECT_TIMER >= 1500)) ? REDIRECT_TIMER : 0;
+	    // add template variables
+	    $tpl = new Template( THEME_PATH.'/templates' );
+	    $tpl->set_file( 'page', 'success.htt' );
+	    $tpl->set_block( 'page', 'main_block', 'main' );
+	    $tpl->set_block( 'main_block', 'show_redirect_block', 'show_redirect' );
+	    $tpl->set_var( 'MESSAGE', $message );
+	    $tpl->set_var( 'REDIRECT', $redirect );
+	    $tpl->set_var( 'REDIRECT_TIMER', $redirect_timer );
+	    $tpl->set_var( 'NEXT', $TEXT['NEXT'] );
+	    $tpl->set_var( 'BACK', $TEXT['BACK'] );
+	    if ($redirect_timer == 0) {
+	        $tpl->set_block( 'show_redirect', '' );
+	    }
+	    else {
+	        $tpl->parse( 'show_redirect', 'show_redirect_block', true );
+	    }
+	    $tpl->parse( 'main', 'main_block', false );
+	    $tpl->pparse( 'output', 'page' );
+	}
+
+	// Print an error message
+	function print_error($message, $link = 'index.php', $auto_footer = true) {
+		global $TEXT;
+		$success_template = new Template(THEME_PATH.'/templates');
+		$success_template->set_file('page', 'error.htt');
+		$success_template->set_block('page', 'main_block', 'main');
+		$success_template->set_var('MESSAGE', $message);
+		$success_template->set_var('LINK', $link);
+		$success_template->set_var('BACK', $TEXT['BACK']);
+		$success_template->parse('main', 'main_block', false);
+		$success_template->pparse('output', 'page');
+		if ( $auto_footer == true ) {
+			if ( method_exists($this, "print_footer") ) {
+				$this->print_footer();
+			}
+		}
+		exit();
+	}
+
+	// Validate send email
+	function mail($fromaddress, $toaddress, $subject, $message, $fromname='') {
+		/* 
+			INTEGRATED OPEN SOURCE PHPMAILER CLASS FOR SMTP SUPPORT AND MORE
+			SOME SERVICE PROVIDERS DO NOT SUPPORT SENDING MAIL VIA PHP AS IT DOES NOT PROVIDE SMTP AUTHENTICATION
+			NEW WBMAILER CLASS IS ABLE TO SEND OUT MESSAGES USING SMTP WHICH RESOLVE THESE ISSUE (C. Sommer)
+
+			NOTE:
+			To use SMTP for sending out mails, you have to specify the SMTP host of your domain
+			via the Settings panel in the backend of Website Baker
+		*/ 
+
+		$fromaddress = preg_replace('/[\r\n]/', '', $fromaddress);
+		$toaddress = preg_replace('/[\r\n]/', '', $toaddress);
+		$subject = preg_replace('/[\r\n]/', '', $subject);
+		$message_alt = $message;
+		$message = preg_replace('/[\r\n]/', '<br \>', $message);
+		
+		// create PHPMailer object and define default settings
+		$myMail = new wbmailer();
+
+		// set user defined from address
+		if ($fromaddress!='') {
+			if($fromname!='') $myMail->FromName = $fromname;         // FROM-NAME
+			$myMail->From = $fromaddress;                            // FROM:
+			$myMail->AddReplyTo($fromaddress);                       // REPLY TO:
+		}
+		
+		// define recepient and information to send out
+		$myMail->AddAddress($toaddress);                            // TO:
+		$myMail->Subject = $subject;                                // SUBJECT
+		$myMail->Body = $message;                                   // CONTENT (HTML)
+		$myMail->AltBody = strip_tags($message_alt);				// CONTENT (TEXT)
+		
+		// check if there are any send mail errors, otherwise say successful
+		if (!$myMail->Send()) {
+			return false;
+		} else {
+			return true;
+		}
+	}
+
+}
 ?>
\ No newline at end of file
Index: branches/2.8.x/wb/modules/fckeditor/upgrade.php
===================================================================
--- branches/2.8.x/wb/modules/fckeditor/upgrade.php	(nonexistent)
+++ branches/2.8.x/wb/modules/fckeditor/upgrade.php	(revision 1365)
@@ -0,0 +1,20 @@
+<?php
+/**
+ *
+ * @category        modules
+ * @package         wysiwyg
+ * @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 5.2.2 and higher
+ * @version         $Id$
+ * @filesource		$HeadURL$
+ * @lastmodified    $Date$
+ *
+ */
+
+// Must include code to stop this file being access directly
+if(defined('WB_PATH') == false) { exit("Cannot access this file directly"); }

Property changes on: branches/2.8.x/wb/modules/fckeditor/upgrade.php
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Date Revision Id HeadURL
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
