Index: trunk/wb/search/search.php
===================================================================
--- trunk/wb/search/search.php	(revision 237)
+++ trunk/wb/search/search.php	(revision 238)
@@ -35,17 +35,17 @@
 	$items_listed = array();
 
 	// Get search string
-	if(isset($_REQUEST['string'])) {
-		if ($_REQUEST['match']!='exact') {
-			$string=str_replace(',', '', $_REQUEST['string']);
+	if(isset($_REQUEST['string'])) {
+		if ($_REQUEST['match']!='exact') {
+			$string=str_replace(',', '', $_REQUEST['string']);
 		} else {
 			$string=$_REQUEST['string'];
 		}
-		// reverse potential magic_quotes action
-		$original_string=$wb->strip_slashes($string);
-		// Double backslashes (mySQL needs doubly escaped backslashes in LIKE comparisons)
+		// reverse potential magic_quotes action
+		$original_string=$wb->strip_slashes($string);
+		// Double backslashes (mySQL needs doubly escaped backslashes in LIKE comparisons)
 		$string = addslashes($wb->escape_backslashes($original_string));
-		// then escape for mySQL query
+		// then escape for mySQL query
 		$search_string = htmlspecialchars($original_string,ENT_QUOTES);
 	} else {
 		$string = '';
@@ -55,7 +55,7 @@
 	// Work-out what to do (match all words, any words, or do exact match), and do relevant with query settings
 	$all_checked = '';
 	$any_checked = '';
-	$exact_checked = '';
+	$exact_checked = '';
 	if($_REQUEST['match'] != 'exact') {
 		// Split string into array with explode() function
 		$exploded_string = explode(' ', $string);
@@ -66,18 +66,18 @@
 				$string[] = $each_exploded_string;
 			}
 		}
-		if ($_REQUEST['match'] == 'any') {
-			$any_checked = ' checked';
-			$logical_operator = ' OR';
-		} else {
-			$all_checked = ' checked';
-			$logical_operator = ' AND';
-		}
+		if ($_REQUEST['match'] == 'any') {
+			$any_checked = ' checked';
+			$logical_operator = ' OR';
+		} else {
+			$all_checked = ' checked';
+			$logical_operator = ' AND';
+		}
 	} else {
 		$exact_checked = ' checked';
-		$exact_string=$string;
-		$string=array();
-		$string[]=$exact_string;
+		$exact_string=$string;
+		$string=array();
+		$string[]=$exact_string;
 	}	
 	// Get list of usernames and display names
 	$query_users = $database->query("SELECT user_id,username,display_name FROM ".TABLE_PREFIX."users");
@@ -208,7 +208,7 @@
 								if($count != 0) { $prepared_query .= $logical_operator; }
 								$prepared_query .= str_replace('[STRING]', $each_string, $query_body);
 								$count = $count+1;
-							}
+							}
 							$prepared_query .= $query_end;
 							// Execute query
 							$query = $database->query($prepared_query);
Index: trunk/wb/admin/groups/get_permissions.php
===================================================================
--- trunk/wb/admin/groups/get_permissions.php	(revision 237)
+++ trunk/wb/admin/groups/get_permissions.php	(revision 238)
@@ -1,246 +1,246 @@
-<?php
-
-// $Id$
-
-/*
-
- Website Baker Project <http://www.websitebaker.org/>
- Copyright (C) 2004-2005, 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
-
-*/
-
-if(!defined('WB_PATH')) { exit('Direct access to this file is not allowed'); }
-
-// Get system permissions
-if($admin->get_post('advanced') != 'yes') {
-	$system_permissions['pages'] = $admin->get_post('pages');
-		$system_permissions['pages_view'] = $system_permissions['pages'];
-		$system_permissions['pages_add'] = $system_permissions['pages'];
-		$system_permissions['pages_add_l0'] = $system_permissions['pages'];
-		$system_permissions['pages_settings'] = $system_permissions['pages'];
-		$system_permissions['pages_modify'] = $system_permissions['pages'];
-		$system_permissions['pages_intro'] = $system_permissions['pages'];
-		$system_permissions['pages_delete'] = $system_permissions['pages'];
-	$system_permissions['media'] = $admin->get_post('media');
-		$system_permissions['media_view'] = $system_permissions['media'];
-		$system_permissions['media_upload'] = $system_permissions['media'];
-		$system_permissions['media_rename'] = $system_permissions['media'];
-		$system_permissions['media_delete'] = $system_permissions['media'];
-		$system_permissions['media_create'] = $system_permissions['media'];
-	if($admin->get_post('modules') != '' OR $admin->get_post('templates') != '' OR $admin->get_post('languages') != '') {
-		$system_permissions['addons'] = 1;
-	} else {
-		$system_permissions['addons'] = 0;
-	}
-		$system_permissions['modules'] = $admin->get_post('modules');
-			$system_permissions['modules_view'] = $system_permissions['modules'];
-			$system_permissions['modules_install'] = $system_permissions['modules'];
-			$system_permissions['modules_uninstall'] = $system_permissions['modules'];
-		$system_permissions['templates'] = $admin->get_post('templates');
-			$system_permissions['templates_view'] = $system_permissions['templates'];
-			$system_permissions['templates_install'] = $system_permissions['templates'];
-			$system_permissions['templates_uninstall'] = $system_permissions['templates'];
-		$system_permissions['languages'] = $admin->get_post('languages');
-			$system_permissions['languages_view'] = $system_permissions['languages'];
-			$system_permissions['languages_install'] = $system_permissions['languages'];
-			$system_permissions['languages_uninstall'] = $system_permissions['languages'];
-	$system_permissions['settings'] = $admin->get_post('settings');
-		$system_permissions['settings_basic'] = $system_permissions['settings'];
-		$system_permissions['settings_advanced'] = $system_permissions['settings'];
-	if($admin->get_post('users') != '' AND $admin->get_post('groups') != '') {
-		$system_permissions['access'] = 1;
-	} else {
-		$system_permissions['access'] = 0;
-	}
-		$system_permissions['users'] = $admin->get_post('users');
-			$system_permissions['users_view'] = $system_permissions['users'];
-			$system_permissions['users_add'] = $system_permissions['users'];
-			$system_permissions['users_modify'] = $system_permissions['users'];
-			$system_permissions['users_delete'] = $system_permissions['users'];
-		$system_permissions['groups'] = $admin->get_post('groups');
-			$system_permissions['groups_view'] = $system_permissions['groups'];
-			$system_permissions['groups_add'] = $system_permissions['groups'];
-			$system_permissions['groups_modify'] = $system_permissions['groups'];
-			$system_permissions['groups_delete'] = $system_permissions['groups'];
-} else {
-	// Pages
-	$system_permissions['pages_view'] = $admin->get_post('pages_view');
-		$system_permissions['pages_add'] = $admin->get_post('pages_add');
-	if($admin->get_post('pages_add') != 1 AND $admin->get_post('pages_add_l0') == 1) {
-		$system_permissions['pages_add'] = $admin->get_post('pages_add_l0');
-	}
-	$system_permissions['pages_add_l0'] = $admin->get_post('pages_add_l0');
-	$system_permissions['pages_settings'] = $admin->get_post('pages_settings');
-	$system_permissions['pages_modify'] = $admin->get_post('pages_modify');
-	$system_permissions['pages_intro'] = $admin->get_post('pages_intro');
-	$system_permissions['pages_delete'] = $admin->get_post('pages_delete');
-	if($system_permissions['pages_view'] == 1 OR $system_permissions['pages_add'] == 1 OR $system_permissions['pages_settings'] == 1 OR $system_permissions['pages_modify'] == 1 OR $system_permissions['pages_intro'] == 1 OR $system_permissions['pages_delete'] == 1) {
-		$system_permissions['pages'] = 1;
-	} else {
-		$system_permissions['pages'] = '';
-	}
-	// Media
-	$system_permissions['media_view'] = $admin->get_post('media_view');
-	$system_permissions['media_upload'] = $admin->get_post('media_upload');
-	$system_permissions['media_rename'] = $admin->get_post('media_rename');
-	$system_permissions['media_delete'] = $admin->get_post('media_delete');
-	$system_permissions['media_create'] = $admin->get_post('media_create');
-	if($system_permissions['media_view'] == 1 OR $system_permissions['media_upload'] == 1 OR $system_permissions['media_rename'] == 1 OR $system_permissions['media_delete'] == 1 OR $system_permissions['media_create'] == 1) {
-		$system_permissions['media'] = 1;
-	} else {
-		$system_permissions['media'] = '';
-	}
-	// Add-ons
-		// Modules
-		$system_permissions['modules_view'] = $admin->get_post('modules_view');
-		$system_permissions['modules_install'] = $admin->get_post('modules_install');
-		$system_permissions['modules_uninstall'] = $admin->get_post('modules_uninstall');
-		if($system_permissions['modules_view'] == 1 OR $system_permissions['modules_install'] == 1 OR $system_permissions['modules_uninstall'] == 1) {
-			$system_permissions['modules'] = 1;
-		} else {
-			$system_permissions['modules'] = '';
-		}
-		// Templates
-		$system_permissions['templates_view'] = $admin->get_post('templates_view');
-		$system_permissions['templates_install'] = $admin->get_post('templates_install');
-		$system_permissions['templates_uninstall'] = $admin->get_post('templates_uninstall');
-		if($system_permissions['templates_view'] == 1 OR $system_permissions['templates_install'] == 1 OR $system_permissions['templates_uninstall'] == 1) {
-			$system_permissions['templates'] = 1;
-		} else {
-			$system_permissions['templates'] = '';
-		}
-		// Languages
-		$system_permissions['languages_view'] = $admin->get_post('languages_view');
-		$system_permissions['languages_install'] = $admin->get_post('languages_install');
-		$system_permissions['languages_uninstall'] = $admin->get_post('languages_uninstall');
-		if($system_permissions['languages_install'] == 1 OR $system_permissions['languages_uninstall'] == 1) {
-			$system_permissions['languages'] = 1;
-		} else {
-			$system_permissions['languages'] = '';
-		}
-	if($system_permissions['modules'] == 1 OR $system_permissions['templates'] == 1 OR $system_permissions['languages'] == 1) {
-		$system_permissions['addons'] = 1;
-	} else {
-		$system_permissions['addons'] = '';
-	}
-	// Settings
-	$system_permissions['settings_basic'] = $admin->get_post('settings_basic');
-	$system_permissions['settings_advanced'] = $admin->get_post('settings_advanced');
-	if($system_permissions['settings_basic'] == 1 OR $system_permissions['settings_advanced'] == 1) {
-		$system_permissions['settings'] = 1;
-	} else {
-		$system_permissions['settings'] = '';
-	}
-	// Access
-		// Users
-		$system_permissions['users_view'] = $admin->get_post('users_view');
-		$system_permissions['users_add'] = $admin->get_post('users_add');
-		$system_permissions['users_modify'] = $admin->get_post('users_modify');
-		$system_permissions['users_delete'] = $admin->get_post('users_delete');
-		if($system_permissions['users_view'] == 1 OR $system_permissions['users_add'] == 1 OR $system_permissions['users_modify'] == 1 OR $system_permissions['users_delete'] == 1) {
-			$system_permissions['users'] = 1;
-		} else {
-			$system_permissions['users'] = '';
-		}
-		// Groups
-		$system_permissions['groups_view'] = $admin->get_post('groups_view');
-		$system_permissions['groups_add'] = $admin->get_post('groups_add');
-		$system_permissions['groups_modify'] = $admin->get_post('groups_modify');
-		$system_permissions['groups_delete'] = $admin->get_post('groups_delete');
-		if($system_permissions['groups_view'] == 1 OR $system_permissions['groups_add'] == 1 OR $system_permissions['groups_modify'] == 1 OR $system_permissions['groups_delete'] == 1) {
-			$system_permissions['groups'] = 1;
-		} else {
-			$system_permissions['groups'] = '';
-		}
-	if($system_permissions['users'] == 1 OR $system_permissions['groups'] == 1) {
-		$system_permissions['access'] = 1;
-	} else {
-		$system_permissions['access'] = '';
-	}
-}
-
-// Implode system permissions
-$imploded_system_permissions = '';
-foreach($system_permissions AS $name => $value) {
-	if($value == true) {
-		if($imploded_system_permissions == '') {
-			$imploded_system_permissions = $name;
-		} else {
-			$imploded_system_permissions .= ','.$name;
-		}
-	}
-}
-
-$system_permissions = $imploded_system_permissions;
-
-// Get module permissions
-$module_permissions = '';
-if($handle = opendir(WB_PATH.'/modules/')) {
-	while (false !== ($file = readdir($handle))) {
-		if($file != "." AND $file != ".." AND $file != ".svn" AND is_dir(WB_PATH."/modules/$file") AND file_exists(WB_PATH."/modules/$file/info.php")) {
-			// Include the modules info file
-			require(WB_PATH.'/modules/'.$file.'/info.php');
-			// Check if it was selected to be used or not
-			$count = 0;
-			if(is_array($admin->get_post('module_permissions'))) {
-				foreach($admin->get_post('module_permissions') AS $selected_name) {
-					if($file == $selected_name) {
-						$count = $count+1;
-					}
-				}
-			}
-			if($count == 0) {
-				// Add unselected modules to list
-				if($module_permissions == '') {
-					$module_permissions = $file;
-				} else {
-					$module_permissions .= ','.$file;
-				}
-			}
-		}
-	}
-}
-
-// Get template permissions
-$template_permissions = '';
-if($handle = opendir(WB_PATH.'/templates/')) {
-	while (false !== ($file = readdir($handle))) {
-		if($file != "." AND $file != ".." AND $file != ".svn" AND is_dir(WB_PATH."/templates/$file") AND file_exists(WB_PATH."/templates/$file/info.php")) {
-			// Include the modules info file
-			require(WB_PATH.'/templates/'.$file.'/info.php');
-			// Check if it was selected to be used or not
-			$count = 0;
-			if(is_array($admin->get_post('template_permissions'))) {
-				foreach($admin->get_post('template_permissions') AS $selected_name) {
-					if($file == $selected_name) {
-						$count = $count+1;
-					}
-				}
-			}
-			if($count == 0) {
-				// Add unselected modules to list
-				if($template_permissions == '') {
-					$template_permissions = $file;
-				} else {
-					$template_permissions .= ','.$file;
-				}
-			}
-		}
-	}
-}
-
-?>
+<?php
+
+// $Id$
+
+/*
+
+ Website Baker Project <http://www.websitebaker.org/>
+ Copyright (C) 2004-2005, 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
+
+*/
+
+if(!defined('WB_PATH')) { exit('Direct access to this file is not allowed'); }
+
+// Get system permissions
+if($admin->get_post('advanced') != 'yes') {
+	$system_permissions['pages'] = $admin->get_post('pages');
+		$system_permissions['pages_view'] = $system_permissions['pages'];
+		$system_permissions['pages_add'] = $system_permissions['pages'];
+		$system_permissions['pages_add_l0'] = $system_permissions['pages'];
+		$system_permissions['pages_settings'] = $system_permissions['pages'];
+		$system_permissions['pages_modify'] = $system_permissions['pages'];
+		$system_permissions['pages_intro'] = $system_permissions['pages'];
+		$system_permissions['pages_delete'] = $system_permissions['pages'];
+	$system_permissions['media'] = $admin->get_post('media');
+		$system_permissions['media_view'] = $system_permissions['media'];
+		$system_permissions['media_upload'] = $system_permissions['media'];
+		$system_permissions['media_rename'] = $system_permissions['media'];
+		$system_permissions['media_delete'] = $system_permissions['media'];
+		$system_permissions['media_create'] = $system_permissions['media'];
+	if($admin->get_post('modules') != '' OR $admin->get_post('templates') != '' OR $admin->get_post('languages') != '') {
+		$system_permissions['addons'] = 1;
+	} else {
+		$system_permissions['addons'] = 0;
+	}
+		$system_permissions['modules'] = $admin->get_post('modules');
+			$system_permissions['modules_view'] = $system_permissions['modules'];
+			$system_permissions['modules_install'] = $system_permissions['modules'];
+			$system_permissions['modules_uninstall'] = $system_permissions['modules'];
+		$system_permissions['templates'] = $admin->get_post('templates');
+			$system_permissions['templates_view'] = $system_permissions['templates'];
+			$system_permissions['templates_install'] = $system_permissions['templates'];
+			$system_permissions['templates_uninstall'] = $system_permissions['templates'];
+		$system_permissions['languages'] = $admin->get_post('languages');
+			$system_permissions['languages_view'] = $system_permissions['languages'];
+			$system_permissions['languages_install'] = $system_permissions['languages'];
+			$system_permissions['languages_uninstall'] = $system_permissions['languages'];
+	$system_permissions['settings'] = $admin->get_post('settings');
+		$system_permissions['settings_basic'] = $system_permissions['settings'];
+		$system_permissions['settings_advanced'] = $system_permissions['settings'];
+	if($admin->get_post('users') != '' AND $admin->get_post('groups') != '') {
+		$system_permissions['access'] = 1;
+	} else {
+		$system_permissions['access'] = 0;
+	}
+		$system_permissions['users'] = $admin->get_post('users');
+			$system_permissions['users_view'] = $system_permissions['users'];
+			$system_permissions['users_add'] = $system_permissions['users'];
+			$system_permissions['users_modify'] = $system_permissions['users'];
+			$system_permissions['users_delete'] = $system_permissions['users'];
+		$system_permissions['groups'] = $admin->get_post('groups');
+			$system_permissions['groups_view'] = $system_permissions['groups'];
+			$system_permissions['groups_add'] = $system_permissions['groups'];
+			$system_permissions['groups_modify'] = $system_permissions['groups'];
+			$system_permissions['groups_delete'] = $system_permissions['groups'];
+} else {
+	// Pages
+	$system_permissions['pages_view'] = $admin->get_post('pages_view');
+		$system_permissions['pages_add'] = $admin->get_post('pages_add');
+	if($admin->get_post('pages_add') != 1 AND $admin->get_post('pages_add_l0') == 1) {
+		$system_permissions['pages_add'] = $admin->get_post('pages_add_l0');
+	}
+	$system_permissions['pages_add_l0'] = $admin->get_post('pages_add_l0');
+	$system_permissions['pages_settings'] = $admin->get_post('pages_settings');
+	$system_permissions['pages_modify'] = $admin->get_post('pages_modify');
+	$system_permissions['pages_intro'] = $admin->get_post('pages_intro');
+	$system_permissions['pages_delete'] = $admin->get_post('pages_delete');
+	if($system_permissions['pages_view'] == 1 OR $system_permissions['pages_add'] == 1 OR $system_permissions['pages_settings'] == 1 OR $system_permissions['pages_modify'] == 1 OR $system_permissions['pages_intro'] == 1 OR $system_permissions['pages_delete'] == 1) {
+		$system_permissions['pages'] = 1;
+	} else {
+		$system_permissions['pages'] = '';
+	}
+	// Media
+	$system_permissions['media_view'] = $admin->get_post('media_view');
+	$system_permissions['media_upload'] = $admin->get_post('media_upload');
+	$system_permissions['media_rename'] = $admin->get_post('media_rename');
+	$system_permissions['media_delete'] = $admin->get_post('media_delete');
+	$system_permissions['media_create'] = $admin->get_post('media_create');
+	if($system_permissions['media_view'] == 1 OR $system_permissions['media_upload'] == 1 OR $system_permissions['media_rename'] == 1 OR $system_permissions['media_delete'] == 1 OR $system_permissions['media_create'] == 1) {
+		$system_permissions['media'] = 1;
+	} else {
+		$system_permissions['media'] = '';
+	}
+	// Add-ons
+		// Modules
+		$system_permissions['modules_view'] = $admin->get_post('modules_view');
+		$system_permissions['modules_install'] = $admin->get_post('modules_install');
+		$system_permissions['modules_uninstall'] = $admin->get_post('modules_uninstall');
+		if($system_permissions['modules_view'] == 1 OR $system_permissions['modules_install'] == 1 OR $system_permissions['modules_uninstall'] == 1) {
+			$system_permissions['modules'] = 1;
+		} else {
+			$system_permissions['modules'] = '';
+		}
+		// Templates
+		$system_permissions['templates_view'] = $admin->get_post('templates_view');
+		$system_permissions['templates_install'] = $admin->get_post('templates_install');
+		$system_permissions['templates_uninstall'] = $admin->get_post('templates_uninstall');
+		if($system_permissions['templates_view'] == 1 OR $system_permissions['templates_install'] == 1 OR $system_permissions['templates_uninstall'] == 1) {
+			$system_permissions['templates'] = 1;
+		} else {
+			$system_permissions['templates'] = '';
+		}
+		// Languages
+		$system_permissions['languages_view'] = $admin->get_post('languages_view');
+		$system_permissions['languages_install'] = $admin->get_post('languages_install');
+		$system_permissions['languages_uninstall'] = $admin->get_post('languages_uninstall');
+		if($system_permissions['languages_install'] == 1 OR $system_permissions['languages_uninstall'] == 1) {
+			$system_permissions['languages'] = 1;
+		} else {
+			$system_permissions['languages'] = '';
+		}
+	if($system_permissions['modules'] == 1 OR $system_permissions['templates'] == 1 OR $system_permissions['languages'] == 1) {
+		$system_permissions['addons'] = 1;
+	} else {
+		$system_permissions['addons'] = '';
+	}
+	// Settings
+	$system_permissions['settings_basic'] = $admin->get_post('settings_basic');
+	$system_permissions['settings_advanced'] = $admin->get_post('settings_advanced');
+	if($system_permissions['settings_basic'] == 1 OR $system_permissions['settings_advanced'] == 1) {
+		$system_permissions['settings'] = 1;
+	} else {
+		$system_permissions['settings'] = '';
+	}
+	// Access
+		// Users
+		$system_permissions['users_view'] = $admin->get_post('users_view');
+		$system_permissions['users_add'] = $admin->get_post('users_add');
+		$system_permissions['users_modify'] = $admin->get_post('users_modify');
+		$system_permissions['users_delete'] = $admin->get_post('users_delete');
+		if($system_permissions['users_view'] == 1 OR $system_permissions['users_add'] == 1 OR $system_permissions['users_modify'] == 1 OR $system_permissions['users_delete'] == 1) {
+			$system_permissions['users'] = 1;
+		} else {
+			$system_permissions['users'] = '';
+		}
+		// Groups
+		$system_permissions['groups_view'] = $admin->get_post('groups_view');
+		$system_permissions['groups_add'] = $admin->get_post('groups_add');
+		$system_permissions['groups_modify'] = $admin->get_post('groups_modify');
+		$system_permissions['groups_delete'] = $admin->get_post('groups_delete');
+		if($system_permissions['groups_view'] == 1 OR $system_permissions['groups_add'] == 1 OR $system_permissions['groups_modify'] == 1 OR $system_permissions['groups_delete'] == 1) {
+			$system_permissions['groups'] = 1;
+		} else {
+			$system_permissions['groups'] = '';
+		}
+	if($system_permissions['users'] == 1 OR $system_permissions['groups'] == 1) {
+		$system_permissions['access'] = 1;
+	} else {
+		$system_permissions['access'] = '';
+	}
+}
+
+// Implode system permissions
+$imploded_system_permissions = '';
+foreach($system_permissions AS $name => $value) {
+	if($value == true) {
+		if($imploded_system_permissions == '') {
+			$imploded_system_permissions = $name;
+		} else {
+			$imploded_system_permissions .= ','.$name;
+		}
+	}
+}
+
+$system_permissions = $imploded_system_permissions;
+
+// Get module permissions
+$module_permissions = '';
+if($handle = opendir(WB_PATH.'/modules/')) {
+	while (false !== ($file = readdir($handle))) {
+		if($file != "." AND $file != ".." AND $file != ".svn" AND is_dir(WB_PATH."/modules/$file") AND file_exists(WB_PATH."/modules/$file/info.php")) {
+			// Include the modules info file
+			require(WB_PATH.'/modules/'.$file.'/info.php');
+			// Check if it was selected to be used or not
+			$count = 0;
+			if(is_array($admin->get_post('module_permissions'))) {
+				foreach($admin->get_post('module_permissions') AS $selected_name) {
+					if($file == $selected_name) {
+						$count = $count+1;
+					}
+				}
+			}
+			if($count == 0) {
+				// Add unselected modules to list
+				if($module_permissions == '') {
+					$module_permissions = $file;
+				} else {
+					$module_permissions .= ','.$file;
+				}
+			}
+		}
+	}
+}
+
+// Get template permissions
+$template_permissions = '';
+if($handle = opendir(WB_PATH.'/templates/')) {
+	while (false !== ($file = readdir($handle))) {
+		if($file != "." AND $file != ".." AND $file != ".svn" AND is_dir(WB_PATH."/templates/$file") AND file_exists(WB_PATH."/templates/$file/info.php")) {
+			// Include the modules info file
+			require(WB_PATH.'/templates/'.$file.'/info.php');
+			// Check if it was selected to be used or not
+			$count = 0;
+			if(is_array($admin->get_post('template_permissions'))) {
+				foreach($admin->get_post('template_permissions') AS $selected_name) {
+					if($file == $selected_name) {
+						$count = $count+1;
+					}
+				}
+			}
+			if($count == 0) {
+				// Add unselected modules to list
+				if($template_permissions == '') {
+					$template_permissions = $file;
+				} else {
+					$template_permissions .= ','.$file;
+				}
+			}
+		}
+	}
+}
+
+?>
Index: trunk/wb/admin/groups/groups.php
===================================================================
--- trunk/wb/admin/groups/groups.php	(revision 237)
+++ trunk/wb/admin/groups/groups.php	(revision 238)
@@ -1,185 +1,185 @@
-<?php
-
-// $Id$
-
-/*
-
- Website Baker Project <http://www.websitebaker.org/>
- Copyright (C) 2004-2005, 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
-
-*/
-
-// Include config file and admin class file
-require('../../config.php');
-require_once(WB_PATH.'/framework/class.admin.php');
-
-// Create new database object
-$database = new database();
-
-if(!isset($_POST['action']) OR $_POST['action'] != "modify" AND $_POST['action'] != "delete") {
-	header("Location: index.php");
-}
-
-// Check if group group_id is a valid number and doesnt equal 1
-if(!isset($_POST['group_id']) OR !is_numeric($_POST['group_id']) OR $_POST['group_id'] == 1) {
-	header("Location: index.php");
-}
-
-if($_POST['action'] == 'modify') {
-	// Create new admin object
-	$admin = new admin('Access', 'groups_modify', false);
-	// Print header
-	$admin->print_header();
-	// Get existing values
-	$results = $database->query("SELECT * FROM ".TABLE_PREFIX."groups WHERE group_id = '".$_POST['group_id']."'");
-	$group = $results->fetchRow();
-	// Setup template object
-	$template = new Template(ADMIN_PATH.'/groups');
-	$template->set_file('page', 'group_form.html');
-	$template->set_block('page', 'main_block', 'main');
-	$template->set_var(	array(
-										'ACTION_URL' => ADMIN_URL.'/groups/save.php',
-										'SUBMIT_TITLE' => $TEXT['SAVE'],
-										'GROUP_ID' => $group['group_id'],
-										'GROUP_NAME' => $group['name'],
-										'ADVANCED_ACTION' => 'groups.php'
-										)
-							);
-	// Tell the browser whether or not to show advanced options
-	if(isset($_POST['advanced']) AND $_POST['advanced'] == $TEXT['SHOW_ADVANCED'].' >>') {
-		$template->set_var('DISPLAY_ADVANCED', '');
-		$template->set_var('DISPLAY_BASIC', 'none');
-		$template->set_var('ADVANCED', 'yes');
-		$template->set_var('ADVANCED_BUTTON', '<< '.$TEXT['HIDE_ADVANCED']);
-	} else {
-		$template->set_var('DISPLAY_ADVANCED', 'none');
-		$template->set_var('DISPLAY_BASIC', '');
-		$template->set_var('ADVANCED', 'no');
-		$template->set_var('ADVANCED_BUTTON', $TEXT['SHOW_ADVANCED'].' >>');
-	}
-	
-	// Explode system permissions
-	$system_permissions = explode(',', $group['system_permissions']);
-	// Check system permissions boxes
-	foreach($system_permissions AS $name) {
-			$template->set_var($name.'_checked', 'checked');
-	}
-	// Explode module permissions
-	$module_permissions = explode(',', $group['module_permissions']);
-	// Explode template permissions
-	$template_permissions = explode(',', $group['template_permissions']);
-	
-	// Insert values into module list
-	$template->set_block('main_block', 'module_list_block', 'module_list');
-	$result = $database->query("SELECT * FROM ".TABLE_PREFIX."addons WHERE type = 'module' AND function = 'page'");
-	if($result->numRows() > 0) {
-		while($addon = $result->fetchRow()) {
-			$template->set_var('VALUE', $addon['directory']);
-			$template->set_var('NAME', $addon['name']);
-			if(!is_numeric(array_search($addon['directory'], $module_permissions))) {
-				$template->set_var('CHECKED', 'checked');
-			} else {
-				$template->set_var('CHECKED', '');
-			}
-			$template->parse('module_list', 'module_list_block', true);
-		}
-	}
-	
-	// Insert values into template list
-	$template->set_block('main_block', 'template_list_block', 'template_list');
-	$result = $database->query("SELECT * FROM ".TABLE_PREFIX."addons WHERE type = 'template'");
-	if($result->numRows() > 0) {
-		while($addon = $result->fetchRow()) {
-			$template->set_var('VALUE', $addon['directory']);
-			$template->set_var('NAME', $addon['name']);
-			if(!is_numeric(array_search($addon['directory'], $template_permissions))) {
-				$template->set_var('CHECKED', 'checked');
-			} else {
-				$template->set_var('CHECKED', '');
-			}
-			$template->parse('template_list', 'template_list_block', true);
-		}
-	}
-		
-	// Insert language text and messages
-	$template->set_var(array(
-									'TEXT_RESET' => $TEXT['RESET'],
-									'TEXT_ACTIVE' => $TEXT['ACTIVE'],
-									'TEXT_DISABLED' => $TEXT['DISABLED'],
-									'TEXT_PLEASE_SELECT' => $TEXT['PLEASE_SELECT'],
-									'TEXT_USERNAME' => $TEXT['USERNAME'],
-									'TEXT_PASSWORD' => $TEXT['PASSWORD'],
-									'TEXT_RETYPE_PASSWORD' => $TEXT['RETYPE_PASSWORD'],
-									'TEXT_DISPLAY_NAME' => $TEXT['DISPLAY_NAME'],
-									'TEXT_EMAIL' => $TEXT['EMAIL'],
-									'TEXT_GROUP' => $TEXT['GROUP'],
-									'TEXT_SYSTEM_PERMISSIONS' => $TEXT['SYSTEM_PERMISSIONS'],
-									'TEXT_MODULE_PERMISSIONS' => $TEXT['MODULE_PERMISSIONS'],
-									'TEXT_TEMPLATE_PERMISSIONS' => $TEXT['TEMPLATE_PERMISSIONS'],
-									'TEXT_NAME' => $TEXT['NAME'],
-									'SECTION_PAGES' => $MENU['PAGES'],
-									'SECTION_MEDIA' => $MENU['MEDIA'],
-									'SECTION_MODULES' => $MENU['MODULES'],
-									'SECTION_TEMPLATES' => $MENU['TEMPLATES'],
-									'SECTION_LANGUAGES' => $MENU['LANGUAGES'],
-									'SECTION_SETTINGS' => $MENU['SETTINGS'],
-									'SECTION_USERS' => $MENU['USERS'],
-									'SECTION_GROUPS' => $MENU['GROUPS'],
-									'TEXT_VIEW' => $TEXT['VIEW'],
-									'TEXT_ADD' => $TEXT['ADD'],
-									'TEXT_LEVEL' => $TEXT['LEVEL'],
-									'TEXT_MODIFY' => $TEXT['MODIFY'],
-									'TEXT_DELETE' => $TEXT['DELETE'],
-									'TEXT_MODIFY_CONTENT' => $TEXT['MODIFY_CONTENT'],
-									'TEXT_MODIFY_SETTINGS' => $TEXT['MODIFY_SETTINGS'],
-									'HEADING_MODIFY_INTRO_PAGE' => $HEADING['MODIFY_INTRO_PAGE'],
-									'TEXT_CREATE_FOLDER' => $TEXT['CREATE_FOLDER'],
-									'TEXT_RENAME' => $TEXT['RENAME'],
-									'TEXT_UPLOAD_FILES' => $TEXT['UPLOAD_FILES'],
-									'TEXT_BASIC' => $TEXT['BASIC'],
-									'TEXT_ADVANCED' => $TEXT['ADVANCED'],
-									'CHANGING_PASSWORD' => $MESSAGE['USERS']['CHANGING_PASSWORD']
-									)
-							);
-	
-	// Parse template object
-	$template->parse('main', 'main_block', false);
-	$template->pparse('output', 'page');
-} elseif($_POST['action'] == 'delete') {
-	// Create new admin object
-	$admin = new admin('Access', 'groups_delete', false);
-	// Print header
-	$admin->print_header();
-	// Delete the group
-	$database->query("DELETE FROM ".TABLE_PREFIX."groups WHERE group_id = '".$_POST['group_id']."' LIMIT 1");
-	if($database->is_error()) {
-		$admin->print_error($database->get_error());
-	} else {
-		// Delete users in the group
-		$database->query("DELETE FROM ".TABLE_PREFIX."users WHERE group_id = '".$_POST['group_id']."'");
-		if($database->is_error()) {
-			$admin->print_error($database->get_error());
-		} else {
-			$admin->print_success($MESSAGE['GROUPS']['DELETED']);
-		}
-	}
-}
-
-// Print admin footer
-$admin->print_footer();
-
-?>
+<?php
+
+// $Id$
+
+/*
+
+ Website Baker Project <http://www.websitebaker.org/>
+ Copyright (C) 2004-2005, 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
+
+*/
+
+// Include config file and admin class file
+require('../../config.php');
+require_once(WB_PATH.'/framework/class.admin.php');
+
+// Create new database object
+$database = new database();
+
+if(!isset($_POST['action']) OR $_POST['action'] != "modify" AND $_POST['action'] != "delete") {
+	header("Location: index.php");
+}
+
+// Check if group group_id is a valid number and doesnt equal 1
+if(!isset($_POST['group_id']) OR !is_numeric($_POST['group_id']) OR $_POST['group_id'] == 1) {
+	header("Location: index.php");
+}
+
+if($_POST['action'] == 'modify') {
+	// Create new admin object
+	$admin = new admin('Access', 'groups_modify', false);
+	// Print header
+	$admin->print_header();
+	// Get existing values
+	$results = $database->query("SELECT * FROM ".TABLE_PREFIX."groups WHERE group_id = '".$_POST['group_id']."'");
+	$group = $results->fetchRow();
+	// Setup template object
+	$template = new Template(ADMIN_PATH.'/groups');
+	$template->set_file('page', 'group_form.html');
+	$template->set_block('page', 'main_block', 'main');
+	$template->set_var(	array(
+										'ACTION_URL' => ADMIN_URL.'/groups/save.php',
+										'SUBMIT_TITLE' => $TEXT['SAVE'],
+										'GROUP_ID' => $group['group_id'],
+										'GROUP_NAME' => $group['name'],
+										'ADVANCED_ACTION' => 'groups.php'
+										)
+							);
+	// Tell the browser whether or not to show advanced options
+	if(isset($_POST['advanced']) AND $_POST['advanced'] == $TEXT['SHOW_ADVANCED'].' >>') {
+		$template->set_var('DISPLAY_ADVANCED', '');
+		$template->set_var('DISPLAY_BASIC', 'none');
+		$template->set_var('ADVANCED', 'yes');
+		$template->set_var('ADVANCED_BUTTON', '<< '.$TEXT['HIDE_ADVANCED']);
+	} else {
+		$template->set_var('DISPLAY_ADVANCED', 'none');
+		$template->set_var('DISPLAY_BASIC', '');
+		$template->set_var('ADVANCED', 'no');
+		$template->set_var('ADVANCED_BUTTON', $TEXT['SHOW_ADVANCED'].' >>');
+	}
+	
+	// Explode system permissions
+	$system_permissions = explode(',', $group['system_permissions']);
+	// Check system permissions boxes
+	foreach($system_permissions AS $name) {
+			$template->set_var($name.'_checked', 'checked');
+	}
+	// Explode module permissions
+	$module_permissions = explode(',', $group['module_permissions']);
+	// Explode template permissions
+	$template_permissions = explode(',', $group['template_permissions']);
+	
+	// Insert values into module list
+	$template->set_block('main_block', 'module_list_block', 'module_list');
+	$result = $database->query("SELECT * FROM ".TABLE_PREFIX."addons WHERE type = 'module' AND function = 'page'");
+	if($result->numRows() > 0) {
+		while($addon = $result->fetchRow()) {
+			$template->set_var('VALUE', $addon['directory']);
+			$template->set_var('NAME', $addon['name']);
+			if(!is_numeric(array_search($addon['directory'], $module_permissions))) {
+				$template->set_var('CHECKED', 'checked');
+			} else {
+				$template->set_var('CHECKED', '');
+			}
+			$template->parse('module_list', 'module_list_block', true);
+		}
+	}
+	
+	// Insert values into template list
+	$template->set_block('main_block', 'template_list_block', 'template_list');
+	$result = $database->query("SELECT * FROM ".TABLE_PREFIX."addons WHERE type = 'template'");
+	if($result->numRows() > 0) {
+		while($addon = $result->fetchRow()) {
+			$template->set_var('VALUE', $addon['directory']);
+			$template->set_var('NAME', $addon['name']);
+			if(!is_numeric(array_search($addon['directory'], $template_permissions))) {
+				$template->set_var('CHECKED', 'checked');
+			} else {
+				$template->set_var('CHECKED', '');
+			}
+			$template->parse('template_list', 'template_list_block', true);
+		}
+	}
+		
+	// Insert language text and messages
+	$template->set_var(array(
+									'TEXT_RESET' => $TEXT['RESET'],
+									'TEXT_ACTIVE' => $TEXT['ACTIVE'],
+									'TEXT_DISABLED' => $TEXT['DISABLED'],
+									'TEXT_PLEASE_SELECT' => $TEXT['PLEASE_SELECT'],
+									'TEXT_USERNAME' => $TEXT['USERNAME'],
+									'TEXT_PASSWORD' => $TEXT['PASSWORD'],
+									'TEXT_RETYPE_PASSWORD' => $TEXT['RETYPE_PASSWORD'],
+									'TEXT_DISPLAY_NAME' => $TEXT['DISPLAY_NAME'],
+									'TEXT_EMAIL' => $TEXT['EMAIL'],
+									'TEXT_GROUP' => $TEXT['GROUP'],
+									'TEXT_SYSTEM_PERMISSIONS' => $TEXT['SYSTEM_PERMISSIONS'],
+									'TEXT_MODULE_PERMISSIONS' => $TEXT['MODULE_PERMISSIONS'],
+									'TEXT_TEMPLATE_PERMISSIONS' => $TEXT['TEMPLATE_PERMISSIONS'],
+									'TEXT_NAME' => $TEXT['NAME'],
+									'SECTION_PAGES' => $MENU['PAGES'],
+									'SECTION_MEDIA' => $MENU['MEDIA'],
+									'SECTION_MODULES' => $MENU['MODULES'],
+									'SECTION_TEMPLATES' => $MENU['TEMPLATES'],
+									'SECTION_LANGUAGES' => $MENU['LANGUAGES'],
+									'SECTION_SETTINGS' => $MENU['SETTINGS'],
+									'SECTION_USERS' => $MENU['USERS'],
+									'SECTION_GROUPS' => $MENU['GROUPS'],
+									'TEXT_VIEW' => $TEXT['VIEW'],
+									'TEXT_ADD' => $TEXT['ADD'],
+									'TEXT_LEVEL' => $TEXT['LEVEL'],
+									'TEXT_MODIFY' => $TEXT['MODIFY'],
+									'TEXT_DELETE' => $TEXT['DELETE'],
+									'TEXT_MODIFY_CONTENT' => $TEXT['MODIFY_CONTENT'],
+									'TEXT_MODIFY_SETTINGS' => $TEXT['MODIFY_SETTINGS'],
+									'HEADING_MODIFY_INTRO_PAGE' => $HEADING['MODIFY_INTRO_PAGE'],
+									'TEXT_CREATE_FOLDER' => $TEXT['CREATE_FOLDER'],
+									'TEXT_RENAME' => $TEXT['RENAME'],
+									'TEXT_UPLOAD_FILES' => $TEXT['UPLOAD_FILES'],
+									'TEXT_BASIC' => $TEXT['BASIC'],
+									'TEXT_ADVANCED' => $TEXT['ADVANCED'],
+									'CHANGING_PASSWORD' => $MESSAGE['USERS']['CHANGING_PASSWORD']
+									)
+							);
+	
+	// Parse template object
+	$template->parse('main', 'main_block', false);
+	$template->pparse('output', 'page');
+} elseif($_POST['action'] == 'delete') {
+	// Create new admin object
+	$admin = new admin('Access', 'groups_delete', false);
+	// Print header
+	$admin->print_header();
+	// Delete the group
+	$database->query("DELETE FROM ".TABLE_PREFIX."groups WHERE group_id = '".$_POST['group_id']."' LIMIT 1");
+	if($database->is_error()) {
+		$admin->print_error($database->get_error());
+	} else {
+		// Delete users in the group
+		$database->query("DELETE FROM ".TABLE_PREFIX."users WHERE group_id = '".$_POST['group_id']."'");
+		if($database->is_error()) {
+			$admin->print_error($database->get_error());
+		} else {
+			$admin->print_success($MESSAGE['GROUPS']['DELETED']);
+		}
+	}
+}
+
+// Print admin footer
+$admin->print_footer();
+
+?>
Index: trunk/wb/admin/media/rename2.php
===================================================================
--- trunk/wb/admin/media/rename2.php	(revision 237)
+++ trunk/wb/admin/media/rename2.php	(revision 238)
@@ -1,167 +1,167 @@
-<?php
-
-/*
-
- Website Baker Project <http://www.websitebaker.org/>
- Copyright (C) 2004-2005, 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 admin object
-require('../../config.php');
-require_once(WB_PATH.'/framework/class.admin.php');
-$admin = new admin('Media', 'media_rename', false);
-
-// Include the WB functions file
-require_once(WB_PATH.'/framework/functions.php');
-
-// Include the basic header file
-require(ADMIN_PATH.'/media/basic_header.html');
-
-// Get list of file types to which we're supposed to append 'txt'
-$get_result=$database->query("SELECT value FROM ".TABLE_PREFIX."settings WHERE name='rename_files_on_upload' LIMIT 1");
-$file_extension_string='';
-if ($get_result->numRows()>0) {
-	$fetch_result=$get_result->fetchRow();
-	$file_extension_string=$fetch_result['value'];
-}
-$file_extensions=explode(",",$file_extension_string);
-
-
-// Get the current dir
-$directory = $admin->get_post('dir');
-if($directory == '/') {
-	$directory = '';
-}
-// Check to see if it contains ../
-if(strstr($directory, '../')) {
-	$admin->print_header();
-	$admin->print_error($MESSAGE['MEDIA']['DIR_DOT_DOT_SLASH']);
-}
-
-// Get the temp id
-if(!is_numeric($admin->get_post('id'))) {
-	header("Location: browse.php?dir=$directory");
-} else {
-	$file_id = $admin->get_post('id');
-}
-
-// Get home folder not to show
-$home_folders = get_home_folders();
-
-// Figure out what folder name the temp id is
-if($handle = opendir(WB_PATH.MEDIA_DIRECTORY.'/'.$directory)) {
-	// Loop through the files and dirs an add to list
-   while (false !== ($file = readdir($handle))) {
-		if(substr($file, 0, 1) != '.' AND $file != '.svn' AND $file != 'index.php') {
-			if(is_dir(WB_PATH.MEDIA_DIRECTORY.$directory.'/'.$file)) {
-				if(!isset($home_folders[$directory.'/'.$file])) {
-					$DIR[] = $file;
-				}
-			} else {
-				$FILE[] = $file;
-			}
-		}
-	}
-	$temp_id = 0;
-	if(isset($DIR)) {
-		foreach($DIR AS $name) {
-			$temp_id++;
-			if($file_id == $temp_id) {
-				$rename_file = $name;
-				$type = 'folder';
-			}
-		}
-	}
-	if(isset($FILE)) {
-		foreach($FILE AS $name) {
-			$temp_id++;
-			if($file_id == $temp_id) {
-				$rename_file = $name;
-				$type = 'file';
-			}
-		}
-	}
-}
-
-if(!isset($rename_file)) {
-	$admin->print_error($MESSAGE['MEDIA']['FILE_NOT_FOUND'], "browse.php?dir=$directory", false);
-}
-
-// Check if they entered a new name
-if(media_filename($admin->get_post('name')) == "") {
-	$admin->print_error($MESSAGE['MEDIA']['BLANK_NAME'], "rename.php?dir=$directory&id=$file_id", false);
-} else {
-	$old_name = $admin->get_post('old_name');
-	$new_name =  media_filename($admin->get_post('name'));
-}
-
-// Check if they entered an extension
-if($type == 'file') {
-	if(media_filename($admin->get_post('extension')) == "") {
-		$admin->print_error($MESSAGE['MEDIA']['BLANK_EXTENSION'], "rename.php?dir=$directory&id=$file_id", false);
-	} else {
-		$extension = media_filename($admin->get_post('extension'));
-	}
-} else {
-	$extension = '';
-}
-
-// Join new name and extension
-$name = $new_name.$extension;
-
-// Check if the name contains ..
-if(strstr($name, '..')) {
-	$admin->print_error($MESSAGE['MEDIA']['NAME_DOT_DOT_SLASH'], "rename.php?dir=$directory&id=$file_id", false);
-}
-
-// Check if the name is index.php
-if($name == 'index.php') {
-	$admin->print_error($MESSAGE['MEDIA']['NAME_INDEX_PHP'], "rename.php?dir=$directory&id=$file_id", false);
-}
-
-// Check that the name still has a value
-if($name == '') {
-	$admin->print_error($MESSAGE['MEDIA']['BLANK_NAME'], "rename.php?dir=$directory&id=$file_id", false);
-}
-
-// Check for potentially malicious files and append 'txt' to their name
-foreach($file_extensions as $file_ext) {
-	$file_ext_len=strlen($file_ext);
-	if (substr($name,-$file_ext_len)==$file_ext) {
-		$name.='.txt';
-	}
-}		
-
-
-// Check if we should overwrite or not
-if($admin->get_post('overwrite') != 'yes' AND file_exists(WB_PATH.MEDIA_DIRECTORY.$directory.'/'.$name) == true) {
-	if($type == 'folder') {
-		$admin->print_error($MESSAGE['MEDIA']['DIR_EXISTS'], "rename.php?dir=$directory&id=$file_id", false);
-	} else {
-		$admin->print_error($MESSAGE['MEDIA']['FILE_EXISTS'], "rename.php?dir=$directory&id=$file_id", false);
-	}
-}
-
-// Try and rename the file/folder
-if(rename(WB_PATH.MEDIA_DIRECTORY.$directory.'/'.$rename_file, WB_PATH.MEDIA_DIRECTORY.$directory.'/'.$name)) {
-	$admin->print_success($MESSAGE['MEDIA']['RENAMED'], "browse.php?dir=$directory");
-} else {
-	$admin->print_error($MESSAGE['MEDIA']['CANNOT_RENAME'], "rename.php?dir=$directory&id=$file_id", false);
-}
-
-?>
+<?php
+
+/*
+
+ Website Baker Project <http://www.websitebaker.org/>
+ Copyright (C) 2004-2005, 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 admin object
+require('../../config.php');
+require_once(WB_PATH.'/framework/class.admin.php');
+$admin = new admin('Media', 'media_rename', false);
+
+// Include the WB functions file
+require_once(WB_PATH.'/framework/functions.php');
+
+// Include the basic header file
+require(ADMIN_PATH.'/media/basic_header.html');
+
+// Get list of file types to which we're supposed to append 'txt'
+$get_result=$database->query("SELECT value FROM ".TABLE_PREFIX."settings WHERE name='rename_files_on_upload' LIMIT 1");
+$file_extension_string='';
+if ($get_result->numRows()>0) {
+	$fetch_result=$get_result->fetchRow();
+	$file_extension_string=$fetch_result['value'];
+}
+$file_extensions=explode(",",$file_extension_string);
+
+
+// Get the current dir
+$directory = $admin->get_post('dir');
+if($directory == '/') {
+	$directory = '';
+}
+// Check to see if it contains ../
+if(strstr($directory, '../')) {
+	$admin->print_header();
+	$admin->print_error($MESSAGE['MEDIA']['DIR_DOT_DOT_SLASH']);
+}
+
+// Get the temp id
+if(!is_numeric($admin->get_post('id'))) {
+	header("Location: browse.php?dir=$directory");
+} else {
+	$file_id = $admin->get_post('id');
+}
+
+// Get home folder not to show
+$home_folders = get_home_folders();
+
+// Figure out what folder name the temp id is
+if($handle = opendir(WB_PATH.MEDIA_DIRECTORY.'/'.$directory)) {
+	// Loop through the files and dirs an add to list
+   while (false !== ($file = readdir($handle))) {
+		if(substr($file, 0, 1) != '.' AND $file != '.svn' AND $file != 'index.php') {
+			if(is_dir(WB_PATH.MEDIA_DIRECTORY.$directory.'/'.$file)) {
+				if(!isset($home_folders[$directory.'/'.$file])) {
+					$DIR[] = $file;
+				}
+			} else {
+				$FILE[] = $file;
+			}
+		}
+	}
+	$temp_id = 0;
+	if(isset($DIR)) {
+		foreach($DIR AS $name) {
+			$temp_id++;
+			if($file_id == $temp_id) {
+				$rename_file = $name;
+				$type = 'folder';
+			}
+		}
+	}
+	if(isset($FILE)) {
+		foreach($FILE AS $name) {
+			$temp_id++;
+			if($file_id == $temp_id) {
+				$rename_file = $name;
+				$type = 'file';
+			}
+		}
+	}
+}
+
+if(!isset($rename_file)) {
+	$admin->print_error($MESSAGE['MEDIA']['FILE_NOT_FOUND'], "browse.php?dir=$directory", false);
+}
+
+// Check if they entered a new name
+if(media_filename($admin->get_post('name')) == "") {
+	$admin->print_error($MESSAGE['MEDIA']['BLANK_NAME'], "rename.php?dir=$directory&id=$file_id", false);
+} else {
+	$old_name = $admin->get_post('old_name');
+	$new_name =  media_filename($admin->get_post('name'));
+}
+
+// Check if they entered an extension
+if($type == 'file') {
+	if(media_filename($admin->get_post('extension')) == "") {
+		$admin->print_error($MESSAGE['MEDIA']['BLANK_EXTENSION'], "rename.php?dir=$directory&id=$file_id", false);
+	} else {
+		$extension = media_filename($admin->get_post('extension'));
+	}
+} else {
+	$extension = '';
+}
+
+// Join new name and extension
+$name = $new_name.$extension;
+
+// Check if the name contains ..
+if(strstr($name, '..')) {
+	$admin->print_error($MESSAGE['MEDIA']['NAME_DOT_DOT_SLASH'], "rename.php?dir=$directory&id=$file_id", false);
+}
+
+// Check if the name is index.php
+if($name == 'index.php') {
+	$admin->print_error($MESSAGE['MEDIA']['NAME_INDEX_PHP'], "rename.php?dir=$directory&id=$file_id", false);
+}
+
+// Check that the name still has a value
+if($name == '') {
+	$admin->print_error($MESSAGE['MEDIA']['BLANK_NAME'], "rename.php?dir=$directory&id=$file_id", false);
+}
+
+// Check for potentially malicious files and append 'txt' to their name
+foreach($file_extensions as $file_ext) {
+	$file_ext_len=strlen($file_ext);
+	if (substr($name,-$file_ext_len)==$file_ext) {
+		$name.='.txt';
+	}
+}		
+
+
+// Check if we should overwrite or not
+if($admin->get_post('overwrite') != 'yes' AND file_exists(WB_PATH.MEDIA_DIRECTORY.$directory.'/'.$name) == true) {
+	if($type == 'folder') {
+		$admin->print_error($MESSAGE['MEDIA']['DIR_EXISTS'], "rename.php?dir=$directory&id=$file_id", false);
+	} else {
+		$admin->print_error($MESSAGE['MEDIA']['FILE_EXISTS'], "rename.php?dir=$directory&id=$file_id", false);
+	}
+}
+
+// Try and rename the file/folder
+if(rename(WB_PATH.MEDIA_DIRECTORY.$directory.'/'.$rename_file, WB_PATH.MEDIA_DIRECTORY.$directory.'/'.$name)) {
+	$admin->print_success($MESSAGE['MEDIA']['RENAMED'], "browse.php?dir=$directory");
+} else {
+	$admin->print_error($MESSAGE['MEDIA']['CANNOT_RENAME'], "rename.php?dir=$directory&id=$file_id", false);
+}
+
+?>
Index: trunk/wb/admin/media/browse.php
===================================================================
--- trunk/wb/admin/media/browse.php	(revision 237)
+++ trunk/wb/admin/media/browse.php	(revision 238)
@@ -1,179 +1,179 @@
-<?php
-
-// $Id$
-
-/*
-
- Website Baker Project <http://www.websitebaker.org/>
- Copyright (C) 2004-2005, 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 admin object
-require('../../config.php');
-require_once(WB_PATH.'/framework/class.admin.php');
-$admin = new admin('Media', 'media', false);
-
-// Include the WB functions file
-require_once(WB_PATH.'/framework/functions.php');
-
-// Setup template object
-$template = new Template(ADMIN_PATH.'/media');
-$template->set_file('page', 'browse.html');
-$template->set_block('page', 'main_block', 'main');
-
-// Get the current dir
-$directory = $admin->get_get('dir');
-if($directory == '/') {
-	$directory = '';
-}
-
-// Check to see if it contains ../
-if(strstr($directory, '../')) {
-	$admin->print_header();
-	$admin->print_error($MESSAGE['MEDIA']['DIR_DOT_DOT_SLASH']);
-}
-
-if(!file_exists(WB_PATH.'/media'.$directory)) {
-	$admin->print_header();
-	$admin->print_error($MESSAGE['MEDIA']['DIR_DOES_NOT_EXIST']);
-}
-
-// Check to see if the user wanted to go up a directory into the parent folder
-if($admin->get_get('up') == 1) {
-	$parent_directory = dirname($directory);
-	header("Location: browse.php?dir=$parent_directory");	
-}
-
-// Workout the parent dir link
-$parent_dir_link = ADMIN_URL.'/media/browse.php?dir='.$directory.'&up=1';
-// Workout if the up arrow should be shown
-if($directory == '') {
-	$display_up_arrow = 'hide';
-} else {
-	$display_up_arrow = '';
-}
-
-// Insert values
-$template->set_var(array(
-								'CURRENT_DIR' => $directory,
-								'PARENT_DIR_LINK' => $parent_dir_link,
-								'DISPLAY_UP_ARROW' => $display_up_arrow
-								)
-						);
-
-// Get home folder not to show
-$home_folders = get_home_folders();
-
-// Generate list
-$template->set_block('main_block', 'list_block', 'list');
-if($handle = opendir(WB_PATH.MEDIA_DIRECTORY.'/'.$directory)) {
-	// Loop through the files and dirs an add to list
-   while(false !== ($file = readdir($handle))) {
-		if(substr($file, 0, 1) != '.' AND $file != '.svn' AND $file != 'index.php') {
-			if(is_dir(WB_PATH.MEDIA_DIRECTORY.$directory.'/'.$file)) {
-				if(!isset($home_folders[$directory.'/'.$file])) {
-					$DIR[] = $file;
-				}
-			} else {
-				$FILE[] = $file;
-			}
-		}
-	}
-	// Now parse these values to the template
-	$temp_id = 0;
-	$row_bg_color = 'EEEEEE';
-	if(isset($DIR)) {
-		foreach($DIR AS $name) {
-			$link_name = str_replace(' ', '%20', $name);
-			$temp_id++;
-			$template->set_var(array(
-											'NAME' => $name,
-											'NAME_SLASHED' => addslashes($name),
-											'TEMP_ID' => $temp_id,
-											'LINK' => "browse.php?dir=$directory/$link_name",
-											'LINK_TARGET' => '',
-											'ROW_BG_COLOR' => $row_bg_color,
-											'FILETYPE_ICON' => ADMIN_URL.'/images/folder_16.png'
-											)
-									);
-			$template->parse('list', 'list_block', true);
-			// Code to alternate row colors
-			if($row_bg_color == 'DEDEDE') {
-				$row_bg_color = 'EEEEEE';
-			} else {
-				$row_bg_color = 'DEDEDE';
-			}
-		}
-	}
-	if(isset($FILE)) {
-		foreach($FILE AS $name) {
-			$temp_id++;
-			$template->set_var(array(
-											'NAME' => $name,
-											'NAME_SLASHED' => addslashes($name),
-											'TEMP_ID' => $temp_id,
-											'LINK' => WB_URL.MEDIA_DIRECTORY.$directory.'/'.$name,
-											'LINK_TARGET' => '_blank',
-											'ROW_BG_COLOR' => $row_bg_color,
-											'FILETYPE_ICON' => ADMIN_URL.'/images/blank.gif'
-											)
-									);
-			$template->parse('list', 'list_block', true);
-			// Code to alternate row colors
-			if($row_bg_color == 'DEDEDE') {
-				$row_bg_color = 'EEEEEE';
-			} else {
-				$row_bg_color = 'DEDEDE';
-			}
-		}
-	}
-}
-
-// If no files are in the media folder say so
-if($temp_id == 0) {
-	$template->set_var('DISPLAY_LIST_TABLE', 'hide');
-} else {
-	$template->set_var('DISPLAY_NONE_FOUND', 'hide');
-}
-
-// Insert permissions values
-if($admin->get_permission('media_rename') != true) {
-	$template->set_var('DISPLAY_RENAME', 'hide');
-}
-if($admin->get_permission('media_delete') != true) {
-	$template->set_var('DISPLAY_DELETE', 'hide');
-}
-
-// Insert language text and messages
-$template->set_var(array(
-								'MEDIA_DIRECTORY' => MEDIA_DIRECTORY,
-								'TEXT_CURRENT_FOLDER' => $TEXT['CURRENT_FOLDER'],
-								'TEXT_RELOAD' => $TEXT['RELOAD'],
-								'TEXT_RENAME' => $TEXT['RENAME'],
-								'TEXT_DELETE' => $TEXT['DELETE'],
-								'TEXT_UP' => $TEXT['UP'],
-								'NONE_FOUND' => $MESSAGE['MEDIA']['NONE_FOUND'],
-								'CONFIRM_DELETE' => $MESSAGE['MEDIA']['CONFIRM_DELETE']
-								)
-						);
-
-// Parse template object
-$template->parse('main', 'main_block', false);
-$template->pparse('output', 'page');
-
-?>
+<?php
+
+// $Id$
+
+/*
+
+ Website Baker Project <http://www.websitebaker.org/>
+ Copyright (C) 2004-2005, 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 admin object
+require('../../config.php');
+require_once(WB_PATH.'/framework/class.admin.php');
+$admin = new admin('Media', 'media', false);
+
+// Include the WB functions file
+require_once(WB_PATH.'/framework/functions.php');
+
+// Setup template object
+$template = new Template(ADMIN_PATH.'/media');
+$template->set_file('page', 'browse.html');
+$template->set_block('page', 'main_block', 'main');
+
+// Get the current dir
+$directory = $admin->get_get('dir');
+if($directory == '/') {
+	$directory = '';
+}
+
+// Check to see if it contains ../
+if(strstr($directory, '../')) {
+	$admin->print_header();
+	$admin->print_error($MESSAGE['MEDIA']['DIR_DOT_DOT_SLASH']);
+}
+
+if(!file_exists(WB_PATH.'/media'.$directory)) {
+	$admin->print_header();
+	$admin->print_error($MESSAGE['MEDIA']['DIR_DOES_NOT_EXIST']);
+}
+
+// Check to see if the user wanted to go up a directory into the parent folder
+if($admin->get_get('up') == 1) {
+	$parent_directory = dirname($directory);
+	header("Location: browse.php?dir=$parent_directory");	
+}
+
+// Workout the parent dir link
+$parent_dir_link = ADMIN_URL.'/media/browse.php?dir='.$directory.'&up=1';
+// Workout if the up arrow should be shown
+if($directory == '') {
+	$display_up_arrow = 'hide';
+} else {
+	$display_up_arrow = '';
+}
+
+// Insert values
+$template->set_var(array(
+								'CURRENT_DIR' => $directory,
+								'PARENT_DIR_LINK' => $parent_dir_link,
+								'DISPLAY_UP_ARROW' => $display_up_arrow
+								)
+						);
+
+// Get home folder not to show
+$home_folders = get_home_folders();
+
+// Generate list
+$template->set_block('main_block', 'list_block', 'list');
+if($handle = opendir(WB_PATH.MEDIA_DIRECTORY.'/'.$directory)) {
+	// Loop through the files and dirs an add to list
+   while(false !== ($file = readdir($handle))) {
+		if(substr($file, 0, 1) != '.' AND $file != '.svn' AND $file != 'index.php') {
+			if(is_dir(WB_PATH.MEDIA_DIRECTORY.$directory.'/'.$file)) {
+				if(!isset($home_folders[$directory.'/'.$file])) {
+					$DIR[] = $file;
+				}
+			} else {
+				$FILE[] = $file;
+			}
+		}
+	}
+	// Now parse these values to the template
+	$temp_id = 0;
+	$row_bg_color = 'EEEEEE';
+	if(isset($DIR)) {
+		foreach($DIR AS $name) {
+			$link_name = str_replace(' ', '%20', $name);
+			$temp_id++;
+			$template->set_var(array(
+											'NAME' => $name,
+											'NAME_SLASHED' => addslashes($name),
+											'TEMP_ID' => $temp_id,
+											'LINK' => "browse.php?dir=$directory/$link_name",
+											'LINK_TARGET' => '',
+											'ROW_BG_COLOR' => $row_bg_color,
+											'FILETYPE_ICON' => ADMIN_URL.'/images/folder_16.png'
+											)
+									);
+			$template->parse('list', 'list_block', true);
+			// Code to alternate row colors
+			if($row_bg_color == 'DEDEDE') {
+				$row_bg_color = 'EEEEEE';
+			} else {
+				$row_bg_color = 'DEDEDE';
+			}
+		}
+	}
+	if(isset($FILE)) {
+		foreach($FILE AS $name) {
+			$temp_id++;
+			$template->set_var(array(
+											'NAME' => $name,
+											'NAME_SLASHED' => addslashes($name),
+											'TEMP_ID' => $temp_id,
+											'LINK' => WB_URL.MEDIA_DIRECTORY.$directory.'/'.$name,
+											'LINK_TARGET' => '_blank',
+											'ROW_BG_COLOR' => $row_bg_color,
+											'FILETYPE_ICON' => ADMIN_URL.'/images/blank.gif'
+											)
+									);
+			$template->parse('list', 'list_block', true);
+			// Code to alternate row colors
+			if($row_bg_color == 'DEDEDE') {
+				$row_bg_color = 'EEEEEE';
+			} else {
+				$row_bg_color = 'DEDEDE';
+			}
+		}
+	}
+}
+
+// If no files are in the media folder say so
+if($temp_id == 0) {
+	$template->set_var('DISPLAY_LIST_TABLE', 'hide');
+} else {
+	$template->set_var('DISPLAY_NONE_FOUND', 'hide');
+}
+
+// Insert permissions values
+if($admin->get_permission('media_rename') != true) {
+	$template->set_var('DISPLAY_RENAME', 'hide');
+}
+if($admin->get_permission('media_delete') != true) {
+	$template->set_var('DISPLAY_DELETE', 'hide');
+}
+
+// Insert language text and messages
+$template->set_var(array(
+								'MEDIA_DIRECTORY' => MEDIA_DIRECTORY,
+								'TEXT_CURRENT_FOLDER' => $TEXT['CURRENT_FOLDER'],
+								'TEXT_RELOAD' => $TEXT['RELOAD'],
+								'TEXT_RENAME' => $TEXT['RENAME'],
+								'TEXT_DELETE' => $TEXT['DELETE'],
+								'TEXT_UP' => $TEXT['UP'],
+								'NONE_FOUND' => $MESSAGE['MEDIA']['NONE_FOUND'],
+								'CONFIRM_DELETE' => $MESSAGE['MEDIA']['CONFIRM_DELETE']
+								)
+						);
+
+// Parse template object
+$template->parse('main', 'main_block', false);
+$template->pparse('output', 'page');
+
+?>
Index: trunk/wb/admin/media/delete.php
===================================================================
--- trunk/wb/admin/media/delete.php	(revision 237)
+++ trunk/wb/admin/media/delete.php	(revision 238)
@@ -1,120 +1,120 @@
-<?php
-
-// $Id: delete.php,v 1.5 2005/04/04 00:56:30 rdjurovich Exp $
-
-/*
-
- Website Baker Project <http://www.websitebaker.org/>
- Copyright (C) 2004-2005, 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 admin object
-require('../../config.php');
-require_once(WB_PATH.'/framework/class.admin.php');
-$admin = new admin('Media', 'media_delete', false);
-
-// Include the WB functions file
-require_once(WB_PATH.'/framework/functions.php');
-
-// Include the stripped-down header file
-require('basic_header.html');
-
-// Get the current dir
-$directory = $admin->get_get('dir');
-if($directory == '/') {
-	$directory = '';
-}
-// Check to see if it contains ../
-if(strstr($directory, '../')) {
-	$admin->print_header();
-	$admin->print_error($MESSAGE['MEDIA']['DOT_DOT_SLASH']);
-}
-
-// Get the temp id
-if(!is_numeric($admin->get_get('id'))) {
-	header("Location: browse.php?dir=$directory");
-} else {
-	$file_id = $admin->get_get('id');
-}
-
-// Get home folder not to show
-$home_folders = get_home_folders();
-
-// Figure out what folder name the temp id is
-if($handle = opendir(WB_PATH.MEDIA_DIRECTORY.'/'.$directory)) {
-	// Loop through the files and dirs an add to list
-   while (false !== ($file = readdir($handle))) {
-		if(substr($file, 0, 1) != '.' AND $file != '.svn' AND $file != 'index.php') {
-			if(is_dir(WB_PATH.MEDIA_DIRECTORY.$directory.'/'.$file)) {
-				if(!isset($home_folders[$directory.'/'.$file])) {
-					$DIR[] = $file;
-				}
-			} else {
-				$FILE[] = $file;
-			}
-		}
-	}
-	$temp_id = 0;
-	if(isset($DIR)) {
-		foreach($DIR AS $name) {
-			$temp_id++;
-			if(!isset($delete_file) AND $file_id == $temp_id) {
-				$delete_file = $name;
-				$type = 'folder';
-			}
-		}
-	}
-	if(isset($FILE)) {
-		foreach($FILE AS $name) {
-			$temp_id++;
-			if(!isset($delete_file) AND $file_id == $temp_id) {
-				$delete_file = $name;
-				$type = 'file';
-			}
-		}
-	}
-}
-
-// Check to see if we could find an id to match
-if(!isset($delete_file)) {
-	$admin->print_error($MESSAGE['MEDIA']['FILE_NOT_FOUND'], "browse.php?dir=$directory", false);
-}
-$relative_path = WB_PATH.MEDIA_DIRECTORY.'/'.$directory.'/'.$delete_file;
-// Check if the file/folder exists
-if(!file_exists($relative_path)) {
-	$admin->print_error($MESSAGE['MEDIA']['FILE_NOT_FOUND'], "browse.php?dir=$directory", false);	
-}
-
-// Find out whether its a file or folder
-if($type == 'folder') {
-	// Try and delete the directory
-	if(rm_full_dir($relative_path)) {
-		$admin->print_success($MESSAGE['MEDIA']['DELETED_DIR'], "browse.php?dir=$directory");
-	} else {
-		$admin->print_error($MESSAGE['MEDIA']['CANNOT_DELETE_DIR'], "browse.php?dir=$directory", false);
-	}
-} else {
-	// Try and delete the file
-	if(unlink($relative_path)) {
-		$admin->print_success($MESSAGE['MEDIA']['DELETED_FILE'], "browse.php?dir=$directory");
-	} else {
-		$admin->print_error($MESSAGE['MEDIA']['CANNOT_DELETE_FILE'], "browse.php?dir=$directory", false);
-	}
-}
-
-?>
+<?php
+
+// $Id$
+
+/*
+
+ Website Baker Project <http://www.websitebaker.org/>
+ Copyright (C) 2004-2005, 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 admin object
+require('../../config.php');
+require_once(WB_PATH.'/framework/class.admin.php');
+$admin = new admin('Media', 'media_delete', false);
+
+// Include the WB functions file
+require_once(WB_PATH.'/framework/functions.php');
+
+// Include the stripped-down header file
+require('basic_header.html');
+
+// Get the current dir
+$directory = $admin->get_get('dir');
+if($directory == '/') {
+	$directory = '';
+}
+// Check to see if it contains ../
+if(strstr($directory, '../')) {
+	$admin->print_header();
+	$admin->print_error($MESSAGE['MEDIA']['DOT_DOT_SLASH']);
+}
+
+// Get the temp id
+if(!is_numeric($admin->get_get('id'))) {
+	header("Location: browse.php?dir=$directory");
+} else {
+	$file_id = $admin->get_get('id');
+}
+
+// Get home folder not to show
+$home_folders = get_home_folders();
+
+// Figure out what folder name the temp id is
+if($handle = opendir(WB_PATH.MEDIA_DIRECTORY.'/'.$directory)) {
+	// Loop through the files and dirs an add to list
+   while (false !== ($file = readdir($handle))) {
+		if(substr($file, 0, 1) != '.' AND $file != '.svn' AND $file != 'index.php') {
+			if(is_dir(WB_PATH.MEDIA_DIRECTORY.$directory.'/'.$file)) {
+				if(!isset($home_folders[$directory.'/'.$file])) {
+					$DIR[] = $file;
+				}
+			} else {
+				$FILE[] = $file;
+			}
+		}
+	}
+	$temp_id = 0;
+	if(isset($DIR)) {
+		foreach($DIR AS $name) {
+			$temp_id++;
+			if(!isset($delete_file) AND $file_id == $temp_id) {
+				$delete_file = $name;
+				$type = 'folder';
+			}
+		}
+	}
+	if(isset($FILE)) {
+		foreach($FILE AS $name) {
+			$temp_id++;
+			if(!isset($delete_file) AND $file_id == $temp_id) {
+				$delete_file = $name;
+				$type = 'file';
+			}
+		}
+	}
+}
+
+// Check to see if we could find an id to match
+if(!isset($delete_file)) {
+	$admin->print_error($MESSAGE['MEDIA']['FILE_NOT_FOUND'], "browse.php?dir=$directory", false);
+}
+$relative_path = WB_PATH.MEDIA_DIRECTORY.'/'.$directory.'/'.$delete_file;
+// Check if the file/folder exists
+if(!file_exists($relative_path)) {
+	$admin->print_error($MESSAGE['MEDIA']['FILE_NOT_FOUND'], "browse.php?dir=$directory", false);	
+}
+
+// Find out whether its a file or folder
+if($type == 'folder') {
+	// Try and delete the directory
+	if(rm_full_dir($relative_path)) {
+		$admin->print_success($MESSAGE['MEDIA']['DELETED_DIR'], "browse.php?dir=$directory");
+	} else {
+		$admin->print_error($MESSAGE['MEDIA']['CANNOT_DELETE_DIR'], "browse.php?dir=$directory", false);
+	}
+} else {
+	// Try and delete the file
+	if(unlink($relative_path)) {
+		$admin->print_success($MESSAGE['MEDIA']['DELETED_FILE'], "browse.php?dir=$directory");
+	} else {
+		$admin->print_error($MESSAGE['MEDIA']['CANNOT_DELETE_FILE'], "browse.php?dir=$directory", false);
+	}
+}
+
+?>
Index: trunk/wb/admin/media/rename.php
===================================================================
--- trunk/wb/admin/media/rename.php	(revision 237)
+++ trunk/wb/admin/media/rename.php	(revision 238)
@@ -1,139 +1,139 @@
-<?php
-
-// $Id: rename.php,v 1.4 2005/04/04 00:56:30 rdjurovich Exp $
-
-/*
-
- Website Baker Project <http://www.websitebaker.org/>
- Copyright (C) 2004-2005, 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 admin object
-require('../../config.php');
-require_once(WB_PATH.'/framework/class.admin.php');
-$admin = new admin('Media', 'media_rename', false);
-
-// Include the WB functions file
-require_once(WB_PATH.'/framework/functions.php');
-
-// Include the basic header file
-require(ADMIN_PATH.'/media/basic_header.html');
-
-// Get the current dir
-$directory = $admin->get_get('dir');
-if($directory == '/') {
-	$directory = '';
-}
-// Check to see if it contains ../
-if(strstr($directory, '../')) {
-	$admin->print_error($MESSAGE['MEDIA']['DIR_DOT_DOT_SLASH'], "rename.php?dir=$directory&id=$file_id", false);
-}
-
-// Get the temp id
-if(!is_numeric($admin->get_get('id'))) {
-	header("Location: browse.php?dir=$directory");
-} else {
-	$file_id = $admin->get_get('id');
-}
-
-// Get home folder not to show
-$home_folders = get_home_folders();
-
-// Figure out what folder name the temp id is
-if($handle = opendir(WB_PATH.MEDIA_DIRECTORY.'/'.$directory)) {
-	// Loop through the files and dirs an add to list
-   while (false !== ($file = readdir($handle))) {
-		if(substr($file, 0, 1) != '.' AND $file != '.svn' AND $file != 'index.php') {
-			if(is_dir(WB_PATH.MEDIA_DIRECTORY.$directory.'/'.$file)) {
-				if(!isset($home_folders[$directory.'/'.$file])) {
-					$DIR[] = $file;
-				}
-			} else {
-				$FILE[] = $file;
-			}
-		}
-	}
-	$temp_id = 0;
-	if(isset($DIR)) {
-		foreach($DIR AS $name) {
-			$temp_id++;
-			if($file_id == $temp_id) {
-				$rename_file = $name;
-				$type = 'folder';
-			}
-		}
-	}
-	if(isset($FILE)) {
-		foreach($FILE AS $name) {
-			$temp_id++;
-			if($file_id == $temp_id) {
-				$rename_file = $name;
-				$type = 'file';
-			}
-		}
-	}
-}
-
-if(!isset($rename_file)) {
-	$admin->print_error($MESSAGE['MEDIA']['FILE_NOT_FOUND'], "browse.php?dir=$directory", false);
-}
-
-// Setup template object
-$template = new Template(ADMIN_PATH.'/media');
-$template->set_file('page', 'rename.html');
-$template->set_block('page', 'main_block', 'main');
-//echo WB_PATH.'/media/'.$directory.'/'.$rename_file;
-if($type == 'folder') {
-	$template->set_var('DISPlAY_EXTENSION', 'hide');
-	$extension = '';
-} else {
-	$template->set_var('DISPlAY_EXTENSION', '');
-	$extension = strstr($rename_file, '.');
-}
-
-if($type == 'folder') {
-	$type = $TEXT['FOLDER'];
-} else {
-	$type = $TEXT['FILE'];
-}
-
-$template->set_var(array(
-								'FILENAME' => $rename_file,
-								'DIR' => $directory,
-								'FILE_ID' => $file_id,
-								'TYPE' => $type,
-								'EXTENSION' => $extension
-								)
-						);
-
-
-// Insert language text and messages
-$template->set_var(array(
-								'TEXT_TO' => $TEXT['TO'],
-								'TEXT_RENAME' => $TEXT['RENAME'],
-								'TEXT_CANCEL' => $TEXT['CANCEL'],
-								'TEXT_UP' => $TEXT['UP'],
-								'TEXT_OVERWRITE_EXISTING' => $TEXT['OVERWRITE_EXISTING']
-								)
-						);
-
-// Parse template object
-$template->parse('main', 'main_block', false);
-$template->pparse('output', 'page');
-
-?>
+<?php
+
+// $Id$
+
+/*
+
+ Website Baker Project <http://www.websitebaker.org/>
+ Copyright (C) 2004-2005, 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 admin object
+require('../../config.php');
+require_once(WB_PATH.'/framework/class.admin.php');
+$admin = new admin('Media', 'media_rename', false);
+
+// Include the WB functions file
+require_once(WB_PATH.'/framework/functions.php');
+
+// Include the basic header file
+require(ADMIN_PATH.'/media/basic_header.html');
+
+// Get the current dir
+$directory = $admin->get_get('dir');
+if($directory == '/') {
+	$directory = '';
+}
+// Check to see if it contains ../
+if(strstr($directory, '../')) {
+	$admin->print_error($MESSAGE['MEDIA']['DIR_DOT_DOT_SLASH'], "rename.php?dir=$directory&id=$file_id", false);
+}
+
+// Get the temp id
+if(!is_numeric($admin->get_get('id'))) {
+	header("Location: browse.php?dir=$directory");
+} else {
+	$file_id = $admin->get_get('id');
+}
+
+// Get home folder not to show
+$home_folders = get_home_folders();
+
+// Figure out what folder name the temp id is
+if($handle = opendir(WB_PATH.MEDIA_DIRECTORY.'/'.$directory)) {
+	// Loop through the files and dirs an add to list
+   while (false !== ($file = readdir($handle))) {
+		if(substr($file, 0, 1) != '.' AND $file != '.svn' AND $file != 'index.php') {
+			if(is_dir(WB_PATH.MEDIA_DIRECTORY.$directory.'/'.$file)) {
+				if(!isset($home_folders[$directory.'/'.$file])) {
+					$DIR[] = $file;
+				}
+			} else {
+				$FILE[] = $file;
+			}
+		}
+	}
+	$temp_id = 0;
+	if(isset($DIR)) {
+		foreach($DIR AS $name) {
+			$temp_id++;
+			if($file_id == $temp_id) {
+				$rename_file = $name;
+				$type = 'folder';
+			}
+		}
+	}
+	if(isset($FILE)) {
+		foreach($FILE AS $name) {
+			$temp_id++;
+			if($file_id == $temp_id) {
+				$rename_file = $name;
+				$type = 'file';
+			}
+		}
+	}
+}
+
+if(!isset($rename_file)) {
+	$admin->print_error($MESSAGE['MEDIA']['FILE_NOT_FOUND'], "browse.php?dir=$directory", false);
+}
+
+// Setup template object
+$template = new Template(ADMIN_PATH.'/media');
+$template->set_file('page', 'rename.html');
+$template->set_block('page', 'main_block', 'main');
+//echo WB_PATH.'/media/'.$directory.'/'.$rename_file;
+if($type == 'folder') {
+	$template->set_var('DISPlAY_EXTENSION', 'hide');
+	$extension = '';
+} else {
+	$template->set_var('DISPlAY_EXTENSION', '');
+	$extension = strstr($rename_file, '.');
+}
+
+if($type == 'folder') {
+	$type = $TEXT['FOLDER'];
+} else {
+	$type = $TEXT['FILE'];
+}
+
+$template->set_var(array(
+								'FILENAME' => $rename_file,
+								'DIR' => $directory,
+								'FILE_ID' => $file_id,
+								'TYPE' => $type,
+								'EXTENSION' => $extension
+								)
+						);
+
+
+// Insert language text and messages
+$template->set_var(array(
+								'TEXT_TO' => $TEXT['TO'],
+								'TEXT_RENAME' => $TEXT['RENAME'],
+								'TEXT_CANCEL' => $TEXT['CANCEL'],
+								'TEXT_UP' => $TEXT['UP'],
+								'TEXT_OVERWRITE_EXISTING' => $TEXT['OVERWRITE_EXISTING']
+								)
+						);
+
+// Parse template object
+$template->parse('main', 'main_block', false);
+$template->pparse('output', 'page');
+
+?>
Index: trunk/wb/admin/templates/index.php
===================================================================
--- trunk/wb/admin/templates/index.php	(revision 237)
+++ trunk/wb/admin/templates/index.php	(revision 238)
@@ -1,80 +1,80 @@
-<?php
-
-/*
-
- Website Baker Project <http://www.websitebaker.org/>
- Copyright (C) 2004-2005, 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
-
-*/
-
-// Print admin header
-require('../../config.php');
-require_once(WB_PATH.'/framework/class.admin.php');
-$admin = new admin('Addons', 'templates');
-
-// Setup template object
-$template = new Template(ADMIN_PATH.'/templates');
-$template->set_file('page', 'template.html');
-$template->set_block('page', 'main_block', 'main');
-
-// Insert values into template list
-$template->set_block('main_block', 'template_list_block', 'template_list');
-$result = $database->query("SELECT * FROM ".TABLE_PREFIX."addons WHERE type = 'template'");
-if($result->numRows() > 0) {
-	while($addon = $result->fetchRow()) {
-		$template->set_var('VALUE', $addon['directory']);
-		$template->set_var('NAME', $addon['name']);
-		$template->parse('template_list', 'template_list_block', true);
-	}
-}
-
-// Insert permissions values
-if($admin->get_permission('templates_install') != true) {
-	$template->set_var('DISPLAY_INSTALL', 'hide');
-}
-if($admin->get_permission('templates_uninstall') != true) {
-	$template->set_var('DISPLAY_UNINSTALL', 'hide');
-}
-if($admin->get_permission('templates_view') != true) {
-	$template->set_var('DISPLAY_LIST', 'hide');
-}
-
-// Insert language headings
-$template->set_var(array(
-								'HEADING_INSTALL_TEMPLATE' => $HEADING['INSTALL_TEMPLATE'],
-								'HEADING_UNINSTALL_TEMPLATE' => $HEADING['UNINSTALL_TEMPLATE'],
-								'HEADING_TEMPLATE_DETAILS' => $HEADING['TEMPLATE_DETAILS']
-								)
-						);
-// Insert language text and messages
-$template->set_var(array(
-								'TEXT_INSTALL' => $TEXT['INSTALL'],
-								'TEXT_UNINSTALL' => $TEXT['UNINSTALL'],
-								'TEXT_VIEW_DETAILS' => $TEXT['VIEW_DETAILS'],
-								'TEXT_PLEASE_SELECT' => $TEXT['PLEASE_SELECT'],
-								'CHANGE_TEMPLATE_NOTICE' => $MESSAGE['TEMPLATES']['CHANGE_TEMPLATE_NOTICE']
-								)
-						);
-
-// Parse template object
-$template->parse('main', 'main_block', false);
-$template->pparse('output', 'page');
-
-// Print admin footer
-$admin->print_footer();
-
-?>
+<?php
+
+/*
+
+ Website Baker Project <http://www.websitebaker.org/>
+ Copyright (C) 2004-2005, 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
+
+*/
+
+// Print admin header
+require('../../config.php');
+require_once(WB_PATH.'/framework/class.admin.php');
+$admin = new admin('Addons', 'templates');
+
+// Setup template object
+$template = new Template(ADMIN_PATH.'/templates');
+$template->set_file('page', 'template.html');
+$template->set_block('page', 'main_block', 'main');
+
+// Insert values into template list
+$template->set_block('main_block', 'template_list_block', 'template_list');
+$result = $database->query("SELECT * FROM ".TABLE_PREFIX."addons WHERE type = 'template'");
+if($result->numRows() > 0) {
+	while($addon = $result->fetchRow()) {
+		$template->set_var('VALUE', $addon['directory']);
+		$template->set_var('NAME', $addon['name']);
+		$template->parse('template_list', 'template_list_block', true);
+	}
+}
+
+// Insert permissions values
+if($admin->get_permission('templates_install') != true) {
+	$template->set_var('DISPLAY_INSTALL', 'hide');
+}
+if($admin->get_permission('templates_uninstall') != true) {
+	$template->set_var('DISPLAY_UNINSTALL', 'hide');
+}
+if($admin->get_permission('templates_view') != true) {
+	$template->set_var('DISPLAY_LIST', 'hide');
+}
+
+// Insert language headings
+$template->set_var(array(
+								'HEADING_INSTALL_TEMPLATE' => $HEADING['INSTALL_TEMPLATE'],
+								'HEADING_UNINSTALL_TEMPLATE' => $HEADING['UNINSTALL_TEMPLATE'],
+								'HEADING_TEMPLATE_DETAILS' => $HEADING['TEMPLATE_DETAILS']
+								)
+						);
+// Insert language text and messages
+$template->set_var(array(
+								'TEXT_INSTALL' => $TEXT['INSTALL'],
+								'TEXT_UNINSTALL' => $TEXT['UNINSTALL'],
+								'TEXT_VIEW_DETAILS' => $TEXT['VIEW_DETAILS'],
+								'TEXT_PLEASE_SELECT' => $TEXT['PLEASE_SELECT'],
+								'CHANGE_TEMPLATE_NOTICE' => $MESSAGE['TEMPLATES']['CHANGE_TEMPLATE_NOTICE']
+								)
+						);
+
+// Parse template object
+$template->parse('main', 'main_block', false);
+$template->pparse('output', 'page');
+
+// Print admin footer
+$admin->print_footer();
+
+?>
Index: trunk/wb/admin/pages/settings.php
===================================================================
--- trunk/wb/admin/pages/settings.php	(revision 237)
+++ trunk/wb/admin/pages/settings.php	(revision 238)
@@ -1,417 +1,417 @@
-<?php
-
-/*
-
- Website Baker Project <http://www.websitebaker.org/>
- Copyright (C) 2004-2005, 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
-
-*/
-
-// Get page id
-if(!isset($_GET['page_id']) OR !is_numeric($_GET['page_id'])) {
-	header("Location: index.php");
-} else {
-	$page_id = $_GET['page_id'];
-}
-
-// Create new admin object
-require('../../config.php');
-require_once(WB_PATH.'/framework/class.admin.php');
-$admin = new admin('Pages', 'pages_settings');
-
-// Get perms
-$database = new database();
-$results = $database->query("SELECT * FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id'");
-$results_array = $results->fetchRow();
-$old_admin_groups = explode(',', $results_array['admin_groups']);
-$old_admin_users = explode(',', $results_array['admin_users']);
-if(!is_numeric(array_search($admin->get_group_id(), $old_admin_groups)) AND !is_numeric(array_search($admin->get_user_id(), $old_admin_users))) {
-	$admin->print_error($MESSAGE['PAGES']['INSUFFICIENT_PERMISSIONS']);
-}
-
-// Get page details
-$database = new database();
-$query = "SELECT * FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id'";
-$results = $database->query($query);
-if($database->is_error()) {
-	$admin->print_header();
-	$admin->print_error($database->get_error());
-}
-if($results->numRows() == 0) {
-	$admin->print_header();
-	$admin->print_error($MESSAGE['PAGES']['NOT_FOUND']);
-}
-$results_array = $results->fetchRow();
-
-// Get display name of person who last modified the page
-$query_user = "SELECT username,display_name FROM ".TABLE_PREFIX."users WHERE user_id = '".$results_array['modified_by']."'";
-$get_user = $database->query($query_user);
-if($get_user->numRows() != 0) {
-	$user = $get_user->fetchRow();
-} else {
-	$user['display_name'] = 'Unknown';
-	$user['username'] = 'unknown';
-}
-// Convert the unix ts for modified_when to human a readable form
-if($results_array['modified_when'] != 0) {
-	$modified_ts = gmdate(TIME_FORMAT.', '.DATE_FORMAT, $results_array['modified_when']+TIMEZONE);
-} else {
-	$modified_ts = 'Unknown';
-}
-
-// Setup template object, parse vars to it, then parse it
-$template = new Template(ADMIN_PATH.'/pages');
-$template->set_file('page', 'settings.html');
-$template->set_block('page', 'main_block', 'main');
-$template->set_var(array(
-								'PAGE_ID' => $results_array['page_id'],
-								'PAGE_TITLE' => ($results_array['page_title']),
-								'MENU_TITLE' => ($results_array['menu_title']),
-								'DESCRIPTION' => ($results_array['description']),
-								'KEYWORDS' => ($results_array['keywords']),
-								'MODIFIED_BY' => $user['display_name'],
-								'MODIFIED_BY_USERNAME' => $user['username'],
-								'MODIFIED_WHEN' => $modified_ts,
-								'ADMIN_URL' => ADMIN_URL
-								)
-						);
-
-// Work-out if we should show the "manage sections" link
-$query_sections = $database->query("SELECT section_id FROM ".TABLE_PREFIX."sections WHERE page_id = '$page_id' AND module = 'menu_link'");
-if($query_sections->numRows() > 0) {
-	$template->set_var('DISPLAY_MANAGE_SECTIONS', 'none');
-} elseif(MANAGE_SECTIONS == 'enabled') {
-	$template->set_var('TEXT_MANAGE_SECTIONS', $HEADING['MANAGE_SECTIONS']);
-} else {
-	$template->set_var('DISPLAY_MANAGE_SECTIONS', 'none');
-}
-
-// Visibility
-if($results_array['visibility'] == 'public') {
-	$template->set_var('PUBLIC_SELECTED', ' selected');
-} elseif($results_array['visibility'] == 'private') {
-	$template->set_var('PRIVATE_SELECTED', ' selected');
-} elseif($results_array['visibility'] == 'registered') {
-	$template->set_var('REGISTERED_SELECTED', ' selected');
-} elseif($results_array['visibility'] == 'hidden') {
-	$template->set_var('HIDDEN_SELECTED', ' selected');
-} elseif($results_array['visibility'] == 'none') {
-	$template->set_var('NO_VIS_SELECTED', ' selected');
-}
-// Group list 1 (admin_groups)
-	$admin_groups = explode(',', str_replace('_', '', $results_array['admin_groups']));
-	if($admin->get_group_id() == 1) {
-		$query = "SELECT * FROM ".TABLE_PREFIX."groups";
-	} else {
-		$query = "SELECT * FROM ".TABLE_PREFIX."groups WHERE group_id != '".$admin->get_group_id()."'";
-	}
-	$get_groups = $database->query($query);
-	$template->set_block('main_block', 'group_list_block', 'group_list');
-	// Insert admin group and current group first
-	$admin_group_name = $get_groups->fetchRow();
-	$template->set_var(array(
-									'ID' => 1,
-									'TOGGLE' => '',
-									'DISABLED' => ' disabled',
-									'LINK_COLOR' => '000000',
-									'CURSOR' => 'default',
-									'NAME' => $admin_group_name['name'],
-									'CHECKED' => ' checked'
-									)
-							);
-	$template->parse('group_list', 'group_list_block', true);
-	if($admin->get_group_id() != 1) {
-		$template->set_var(array(
-										'ID' => $admin->get_group_id(),
-										'TOGGLE' => '',
-										'DISABLED' => ' disabled',
-										'LINK_COLOR' => '000000',
-										'CURSOR' => 'default',
-										'NAME' => $admin->get_group_name(),
-										'CHECKED' => ' checked'
-										)
-								);
-		$template->parse('group_list', 'group_list_block', true);
-	}
-	while($group = $get_groups->fetchRow()) {
-		// Check if the group is allowed to edit pages
-		$system_permissions = explode(',', $group['system_permissions']);
-		if(is_numeric(array_search('pages_modify', $system_permissions))) {
-			$template->set_var(array(
-											'ID' => $group['group_id'],
-											'TOGGLE' => $group['group_id'],
-											'DISABLED' => '',
-											'LINK_COLOR' => '',
-											'CURSOR' => 'pointer',
-											'NAME' => $group['name'],
-											'CHECKED' => ''
-											)
-									);
-			if(is_numeric(array_search($group['group_id'], $admin_groups))) {
-				$template->set_var('CHECKED', 'checked');
-			} else {
-				$template->set_var('CHECKED', '');
-			}
-			$template->parse('group_list', 'group_list_block', true);
-		}
-	}
-// Group list 2 (viewing_groups)
-	$viewing_groups = explode(',', str_replace('_', '', $results_array['viewing_groups']));
-	if($admin->get_group_id() == 1) {
-		$query = "SELECT * FROM ".TABLE_PREFIX."groups";
-	} else {
-		$query = "SELECT * FROM ".TABLE_PREFIX."groups WHERE group_id != '".$admin->get_group_id()."'";
-	}
-	$get_groups = $database->query($query);
-	$template->set_block('main_block', 'group_list_block2', 'group_list2');
-	// Insert admin group and current group first
-	$admin_group_name = $get_groups->fetchRow();
-	$template->set_var(array(
-									'ID' => 1,
-									'TOGGLE' => '',
-									'DISABLED' => ' disabled',
-									'LINK_COLOR' => '000000',
-									'CURSOR' => 'default',
-									'NAME' => $admin_group_name['name'],
-									'CHECKED' => ' checked'
-									)
-							);
-	$template->parse('group_list2', 'group_list_block2', true);
-	if($admin->get_group_id() != 1) {
-		$template->set_var(array(
-										'ID' => $admin->get_group_id(),
-										'TOGGLE' => '',
-										'DISABLED' => ' disabled',
-										'LINK_COLOR' => '000000',
-										'CURSOR' => 'default',
-										'NAME' => $admin->get_group_name(),
-										'CHECKED' => ' checked'
-										)
-								);
-		$template->parse('group_list2', 'group_list_block2', true);
-	}
-	while($group = $get_groups->fetchRow()) {
-		$template->set_var(array(
-										'ID' => $group['group_id'],
-										'TOGGLE' => $group['group_id'],
-										'DISABLED' => '',
-										'LINK_COLOR' => '',
-										'CURSOR' => 'pointer',
-										'NAME' => $group['name'],
-										)
-								);
-		if(is_numeric(array_search($group['group_id'], $viewing_groups))) {
-			$template->set_var('CHECKED', 'checked');
-		} else {
-			$template->set_var('CHECKED', '');
-		}
-		$template->parse('group_list2', 'group_list_block2', true);
-	}
-// Show private viewers
-if($results_array['visibility'] == 'private') {
-	$template->set_var('DISPLAY_PRIVATE', '');
-} else {
-	$template->set_var('DISPLAY_PRIVATE', 'none');
-}
-// Parent page list
-$database = new database();
-function parent_list($parent) {
-	global $admin, $database, $template, $results_array;
-	$query = "SELECT * FROM ".TABLE_PREFIX."pages WHERE parent = '$parent' ORDER BY position ASC";
-	$get_pages = $database->query($query);
-	while($page = $get_pages->fetchRow()) {
-		// 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
-		if($page['level']+1 < PAGE_LEVEL_LIMIT) {
-			// Get user perms
-			$admin_groups = explode(',', str_replace('_', '', $page['admin_groups']));
-			$admin_users = explode(',', str_replace('_', '', $page['admin_users']));
-			if(is_numeric(array_search($admin->get_group_id(), $admin_groups)) OR is_numeric(array_search($admin->get_user_id(), $admin_users))) {
-				$can_modify = true;
-			} else {
-				$can_modify = false;
-			}
-			// Title -'s prefix
-			$title_prefix = '';
-			for($i = 1; $i <= $page['level']; $i++) { $title_prefix .= ' - '; }
-			$template->set_var(array(
-											'ID' => $page['page_id'],
-											'TITLE' => ($title_prefix.$page['page_title'])
-											)
-									);
-			if($results_array['parent'] == $page['page_id']) {
-				$template->set_var('SELECTED', ' selected');
-			} elseif($results_array['page_id'] == $page['page_id']) {
-				$template->set_var('SELECTED', ' disabled');
-				$list_next_level=false;
-			} elseif($can_modify != true) {
-				$template->set_var('SELECTED', ' disabled');
-			} else {
-				$template->set_var('SELECTED', '');
-			}
-			$template->parse('page_list2', 'page_list_block2', true);
-		}
-		if ($list_next_level)
-			parent_list($page['page_id']);
-	}
-}
-$template->set_block('main_block', 'page_list_block2', 'page_list2');
-if($admin->get_permission('pages_add_l0') == true OR $results_array['level'] == 0) {
-	if($results_array['parent'] == 0) { $selected = ' selected'; } else { $selected = ''; }
-	$template->set_var(array(
-									'ID' => '0',
-									'TITLE' => $TEXT['NONE'],
-									'SELECTED' => $selected
-									)
-							);
-	$template->parse('page_list2', 'page_list_block2', true);
-}
-parent_list(0);
-
-if($modified_ts == 'Unknown') {
-	$template->set_var('DISPLAY_MODIFIED', 'hide');
-} else {
-	$template->set_var('DISPLAY_MODIFIED', '');
-}
-// Templates list
-$template->set_block('main_block', 'template_list_block', 'template_list');
-$result = $database->query("SELECT * FROM ".TABLE_PREFIX."addons WHERE type = 'template'");
-if($result->numRows() > 0) {
-	while($addon = $result->fetchRow()) { 
-		// Check if the user has perms to use this template
-		if($addon['directory'] == $results_array['template'] OR $admin->get_permission($addon['directory'], 'template') == true) {
-			$template->set_var('VALUE', $addon['directory']);
-			$template->set_var('NAME', $addon['name']);
-			if($addon['directory'] == $results_array['template']) {
-				$template->set_var('SELECTED', ' selected');
-			} else {
-				$template->set_var('SELECTED', '');
-			}
-			$template->parse('template_list', 'template_list_block', true);
-		}
-	}
-}
-
-// Menu list
-if(MULTIPLE_MENUS == false) {
-	$template->set_var('DISPLAY_MENU_LIST', 'none');
-}
-// Include template info file (if it exists)
-if($results_array['template'] != '') {
-	$template_location = WB_PATH.'/templates/'.$results_array['template'].'/info.php';
-} else {
-	$template_location = WB_PATH.'/templates/'.DEFAULT_TEMPLATE.'/info.php';
-}
-if(file_exists($template_location)) {
-	require($template_location);
-}
-// Check if $menu is set
-if(!isset($menu[1]) OR $menu[1] == '') {
-	// Make our own menu list
-	$menu[1] = $TEXT['MAIN'];
-}
-// Add menu options to the list
-$template->set_block('main_block', 'menu_list_block', 'menu_list');
-foreach($menu AS $number => $name) {
-	$template->set_var('NAME', $name);
-	$template->set_var('VALUE', $number);
-	if($results_array['menu'] == $number) {
-		$template->set_var('SELECTED', 'selected');
-	} else {
-		$template->set_var('SELECTED', '');
-	}
-	$template->parse('menu_list', 'menu_list_block', true);
-}
-
-// Language list
-if($handle = opendir(WB_PATH.'/languages/')) {
-	$template->set_block('main_block', 'language_list_block', 'language_list');
-	while (false !== ($file = readdir($handle))) {
-		if($file != '.' AND $file != '..' AND $file != '.svn' AND $file != 'index.php') {
-			// Include the languages info file
-			require(WB_PATH.'/languages/'.$file);
-			// Work-out if this language is selected
-			if($language_code == $results_array['language']) { $selected = ' selected'; } else { $selected = ''; }
-			// Set the language info
-			$template->set_var(array('VALUE' => $language_code, 'SELECTED' => $selected, 'NAME' => $language_name));
-			// Parse row
-			$template->parse('language_list', 'language_list_block', true);
-		}
-	}
-}
-// Restore to original language
-require(WB_PATH.'/languages/'.LANGUAGE.'.php');
-
-// Select disabled if searching is disabled
-if($results_array['searching'] == 0) {
-	$template->set_var('SEARCHING_DISABLED', ' selected');
-}
-// Select what the page target is
-if($results_array['target'] == '_top') {
-	$template->set_var('TOP_SELECTED', ' selected');
-} elseif($results_array['target'] == '_blank') {
-	$template->set_var('BLANK_SELECTED', ' selected');
-}
-
-// Insert language text
-$template->set_var(array(
-								'HEADING_MODIFY_PAGE_SETTINGS' => $HEADING['MODIFY_PAGE_SETTINGS'],
-								'TEXT_CURRENT_PAGE' => $TEXT['CURRENT_PAGE'],
-								'TEXT_MODIFY' => $TEXT['MODIFY'],
-								'TEXT_MODIFY_PAGE' => $HEADING['MODIFY_PAGE'],
-								'LAST_MODIFIED' => $MESSAGE['PAGES']['LAST_MODIFIED'],
-								'TEXT_PAGE_TITLE' => $TEXT['PAGE_TITLE'],
-								'TEXT_MENU_TITLE' => $TEXT['MENU_TITLE'],
-								'TEXT_TYPE' => $TEXT['TYPE'],
-								'TEXT_MENU' => $TEXT['MENU'],
-								'TEXT_PARENT' => $TEXT['PARENT'],
-								'TEXT_VISIBILITY' => $TEXT['VISIBILITY'],
-								'TEXT_PUBLIC' => $TEXT['PUBLIC'],
-								'TEXT_PRIVATE' => $TEXT['PRIVATE'],
-								'TEXT_REGISTERED' => $TEXT['REGISTERED'],
-								'TEXT_NONE' => $TEXT['NONE'],
-								'TEXT_HIDDEN' => $TEXT['HIDDEN'],
-								'TEXT_TEMPLATE' => $TEXT['TEMPLATE'],
-								'TEXT_TARGET' => $TEXT['TARGET'],
-								'TEXT_SYSTEM_DEFAULT' => $TEXT['SYSTEM_DEFAULT'],
-								'TEXT_PLEASE_SELECT' => $TEXT['PLEASE_SELECT'],
-								'TEXT_NEW_WINDOW' => $TEXT['NEW_WINDOW'],
-								'TEXT_SAME_WINDOW' => $TEXT['SAME_WINDOW'],
-								'TEXT_ADMINISTRATORS' => $TEXT['ADMINISTRATORS'],
-								'TEXT_PRIVATE_VIEWERS' => $TEXT['PRIVATE_VIEWERS'],
-								'TEXT_REGISTERED_VIEWERS' => $TEXT['REGISTERED_VIEWERS'],
-								'TEXT_DESCRIPTION' => $TEXT['DESCRIPTION'],
-								'TEXT_KEYWORDS' => $TEXT['KEYWORDS'],
-								'TEXT_SEARCHING' => $TEXT['SEARCHING'],
-								'TEXT_LANGUAGE' => $TEXT['LANGUAGE'],
-								'TEXT_ENABLED' => $TEXT['ENABLED'],
-								'TEXT_DISABLED' => $TEXT['DISABLED'],
-								'TEXT_SAVE' => $TEXT['SAVE'],
-								'TEXT_RESET' => $TEXT['RESET'],
-								'LAST_MODIFIED' => $MESSAGE['PAGES']['LAST_MODIFIED'],
-								'HEADING_MODIFY_PAGE' => $HEADING['MODIFY_PAGE']
-								)
-						);
-
-$template->parse('main', 'main_block', false);
-$template->pparse('output', 'page');
-
-// Print admin footer
-$admin->print_footer();
-
-?>
+<?php
+
+/*
+
+ Website Baker Project <http://www.websitebaker.org/>
+ Copyright (C) 2004-2005, 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
+
+*/
+
+// Get page id
+if(!isset($_GET['page_id']) OR !is_numeric($_GET['page_id'])) {
+	header("Location: index.php");
+} else {
+	$page_id = $_GET['page_id'];
+}
+
+// Create new admin object
+require('../../config.php');
+require_once(WB_PATH.'/framework/class.admin.php');
+$admin = new admin('Pages', 'pages_settings');
+
+// Get perms
+$database = new database();
+$results = $database->query("SELECT * FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id'");
+$results_array = $results->fetchRow();
+$old_admin_groups = explode(',', $results_array['admin_groups']);
+$old_admin_users = explode(',', $results_array['admin_users']);
+if(!is_numeric(array_search($admin->get_group_id(), $old_admin_groups)) AND !is_numeric(array_search($admin->get_user_id(), $old_admin_users))) {
+	$admin->print_error($MESSAGE['PAGES']['INSUFFICIENT_PERMISSIONS']);
+}
+
+// Get page details
+$database = new database();
+$query = "SELECT * FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id'";
+$results = $database->query($query);
+if($database->is_error()) {
+	$admin->print_header();
+	$admin->print_error($database->get_error());
+}
+if($results->numRows() == 0) {
+	$admin->print_header();
+	$admin->print_error($MESSAGE['PAGES']['NOT_FOUND']);
+}
+$results_array = $results->fetchRow();
+
+// Get display name of person who last modified the page
+$query_user = "SELECT username,display_name FROM ".TABLE_PREFIX."users WHERE user_id = '".$results_array['modified_by']."'";
+$get_user = $database->query($query_user);
+if($get_user->numRows() != 0) {
+	$user = $get_user->fetchRow();
+} else {
+	$user['display_name'] = 'Unknown';
+	$user['username'] = 'unknown';
+}
+// Convert the unix ts for modified_when to human a readable form
+if($results_array['modified_when'] != 0) {
+	$modified_ts = gmdate(TIME_FORMAT.', '.DATE_FORMAT, $results_array['modified_when']+TIMEZONE);
+} else {
+	$modified_ts = 'Unknown';
+}
+
+// Setup template object, parse vars to it, then parse it
+$template = new Template(ADMIN_PATH.'/pages');
+$template->set_file('page', 'settings.html');
+$template->set_block('page', 'main_block', 'main');
+$template->set_var(array(
+								'PAGE_ID' => $results_array['page_id'],
+								'PAGE_TITLE' => ($results_array['page_title']),
+								'MENU_TITLE' => ($results_array['menu_title']),
+								'DESCRIPTION' => ($results_array['description']),
+								'KEYWORDS' => ($results_array['keywords']),
+								'MODIFIED_BY' => $user['display_name'],
+								'MODIFIED_BY_USERNAME' => $user['username'],
+								'MODIFIED_WHEN' => $modified_ts,
+								'ADMIN_URL' => ADMIN_URL
+								)
+						);
+
+// Work-out if we should show the "manage sections" link
+$query_sections = $database->query("SELECT section_id FROM ".TABLE_PREFIX."sections WHERE page_id = '$page_id' AND module = 'menu_link'");
+if($query_sections->numRows() > 0) {
+	$template->set_var('DISPLAY_MANAGE_SECTIONS', 'none');
+} elseif(MANAGE_SECTIONS == 'enabled') {
+	$template->set_var('TEXT_MANAGE_SECTIONS', $HEADING['MANAGE_SECTIONS']);
+} else {
+	$template->set_var('DISPLAY_MANAGE_SECTIONS', 'none');
+}
+
+// Visibility
+if($results_array['visibility'] == 'public') {
+	$template->set_var('PUBLIC_SELECTED', ' selected');
+} elseif($results_array['visibility'] == 'private') {
+	$template->set_var('PRIVATE_SELECTED', ' selected');
+} elseif($results_array['visibility'] == 'registered') {
+	$template->set_var('REGISTERED_SELECTED', ' selected');
+} elseif($results_array['visibility'] == 'hidden') {
+	$template->set_var('HIDDEN_SELECTED', ' selected');
+} elseif($results_array['visibility'] == 'none') {
+	$template->set_var('NO_VIS_SELECTED', ' selected');
+}
+// Group list 1 (admin_groups)
+	$admin_groups = explode(',', str_replace('_', '', $results_array['admin_groups']));
+	if($admin->get_group_id() == 1) {
+		$query = "SELECT * FROM ".TABLE_PREFIX."groups";
+	} else {
+		$query = "SELECT * FROM ".TABLE_PREFIX."groups WHERE group_id != '".$admin->get_group_id()."'";
+	}
+	$get_groups = $database->query($query);
+	$template->set_block('main_block', 'group_list_block', 'group_list');
+	// Insert admin group and current group first
+	$admin_group_name = $get_groups->fetchRow();
+	$template->set_var(array(
+									'ID' => 1,
+									'TOGGLE' => '',
+									'DISABLED' => ' disabled',
+									'LINK_COLOR' => '000000',
+									'CURSOR' => 'default',
+									'NAME' => $admin_group_name['name'],
+									'CHECKED' => ' checked'
+									)
+							);
+	$template->parse('group_list', 'group_list_block', true);
+	if($admin->get_group_id() != 1) {
+		$template->set_var(array(
+										'ID' => $admin->get_group_id(),
+										'TOGGLE' => '',
+										'DISABLED' => ' disabled',
+										'LINK_COLOR' => '000000',
+										'CURSOR' => 'default',
+										'NAME' => $admin->get_group_name(),
+										'CHECKED' => ' checked'
+										)
+								);
+		$template->parse('group_list', 'group_list_block', true);
+	}
+	while($group = $get_groups->fetchRow()) {
+		// Check if the group is allowed to edit pages
+		$system_permissions = explode(',', $group['system_permissions']);
+		if(is_numeric(array_search('pages_modify', $system_permissions))) {
+			$template->set_var(array(
+											'ID' => $group['group_id'],
+											'TOGGLE' => $group['group_id'],
+											'DISABLED' => '',
+											'LINK_COLOR' => '',
+											'CURSOR' => 'pointer',
+											'NAME' => $group['name'],
+											'CHECKED' => ''
+											)
+									);
+			if(is_numeric(array_search($group['group_id'], $admin_groups))) {
+				$template->set_var('CHECKED', 'checked');
+			} else {
+				$template->set_var('CHECKED', '');
+			}
+			$template->parse('group_list', 'group_list_block', true);
+		}
+	}
+// Group list 2 (viewing_groups)
+	$viewing_groups = explode(',', str_replace('_', '', $results_array['viewing_groups']));
+	if($admin->get_group_id() == 1) {
+		$query = "SELECT * FROM ".TABLE_PREFIX."groups";
+	} else {
+		$query = "SELECT * FROM ".TABLE_PREFIX."groups WHERE group_id != '".$admin->get_group_id()."'";
+	}
+	$get_groups = $database->query($query);
+	$template->set_block('main_block', 'group_list_block2', 'group_list2');
+	// Insert admin group and current group first
+	$admin_group_name = $get_groups->fetchRow();
+	$template->set_var(array(
+									'ID' => 1,
+									'TOGGLE' => '',
+									'DISABLED' => ' disabled',
+									'LINK_COLOR' => '000000',
+									'CURSOR' => 'default',
+									'NAME' => $admin_group_name['name'],
+									'CHECKED' => ' checked'
+									)
+							);
+	$template->parse('group_list2', 'group_list_block2', true);
+	if($admin->get_group_id() != 1) {
+		$template->set_var(array(
+										'ID' => $admin->get_group_id(),
+										'TOGGLE' => '',
+										'DISABLED' => ' disabled',
+										'LINK_COLOR' => '000000',
+										'CURSOR' => 'default',
+										'NAME' => $admin->get_group_name(),
+										'CHECKED' => ' checked'
+										)
+								);
+		$template->parse('group_list2', 'group_list_block2', true);
+	}
+	while($group = $get_groups->fetchRow()) {
+		$template->set_var(array(
+										'ID' => $group['group_id'],
+										'TOGGLE' => $group['group_id'],
+										'DISABLED' => '',
+										'LINK_COLOR' => '',
+										'CURSOR' => 'pointer',
+										'NAME' => $group['name'],
+										)
+								);
+		if(is_numeric(array_search($group['group_id'], $viewing_groups))) {
+			$template->set_var('CHECKED', 'checked');
+		} else {
+			$template->set_var('CHECKED', '');
+		}
+		$template->parse('group_list2', 'group_list_block2', true);
+	}
+// Show private viewers
+if($results_array['visibility'] == 'private') {
+	$template->set_var('DISPLAY_PRIVATE', '');
+} else {
+	$template->set_var('DISPLAY_PRIVATE', 'none');
+}
+// Parent page list
+$database = new database();
+function parent_list($parent) {
+	global $admin, $database, $template, $results_array;
+	$query = "SELECT * FROM ".TABLE_PREFIX."pages WHERE parent = '$parent' ORDER BY position ASC";
+	$get_pages = $database->query($query);
+	while($page = $get_pages->fetchRow()) {
+		// 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
+		if($page['level']+1 < PAGE_LEVEL_LIMIT) {
+			// Get user perms
+			$admin_groups = explode(',', str_replace('_', '', $page['admin_groups']));
+			$admin_users = explode(',', str_replace('_', '', $page['admin_users']));
+			if(is_numeric(array_search($admin->get_group_id(), $admin_groups)) OR is_numeric(array_search($admin->get_user_id(), $admin_users))) {
+				$can_modify = true;
+			} else {
+				$can_modify = false;
+			}
+			// Title -'s prefix
+			$title_prefix = '';
+			for($i = 1; $i <= $page['level']; $i++) { $title_prefix .= ' - '; }
+			$template->set_var(array(
+											'ID' => $page['page_id'],
+											'TITLE' => ($title_prefix.$page['page_title'])
+											)
+									);
+			if($results_array['parent'] == $page['page_id']) {
+				$template->set_var('SELECTED', ' selected');
+			} elseif($results_array['page_id'] == $page['page_id']) {
+				$template->set_var('SELECTED', ' disabled');
+				$list_next_level=false;
+			} elseif($can_modify != true) {
+				$template->set_var('SELECTED', ' disabled');
+			} else {
+				$template->set_var('SELECTED', '');
+			}
+			$template->parse('page_list2', 'page_list_block2', true);
+		}
+		if ($list_next_level)
+			parent_list($page['page_id']);
+	}
+}
+$template->set_block('main_block', 'page_list_block2', 'page_list2');
+if($admin->get_permission('pages_add_l0') == true OR $results_array['level'] == 0) {
+	if($results_array['parent'] == 0) { $selected = ' selected'; } else { $selected = ''; }
+	$template->set_var(array(
+									'ID' => '0',
+									'TITLE' => $TEXT['NONE'],
+									'SELECTED' => $selected
+									)
+							);
+	$template->parse('page_list2', 'page_list_block2', true);
+}
+parent_list(0);
+
+if($modified_ts == 'Unknown') {
+	$template->set_var('DISPLAY_MODIFIED', 'hide');
+} else {
+	$template->set_var('DISPLAY_MODIFIED', '');
+}
+// Templates list
+$template->set_block('main_block', 'template_list_block', 'template_list');
+$result = $database->query("SELECT * FROM ".TABLE_PREFIX."addons WHERE type = 'template'");
+if($result->numRows() > 0) {
+	while($addon = $result->fetchRow()) { 
+		// Check if the user has perms to use this template
+		if($addon['directory'] == $results_array['template'] OR $admin->get_permission($addon['directory'], 'template') == true) {
+			$template->set_var('VALUE', $addon['directory']);
+			$template->set_var('NAME', $addon['name']);
+			if($addon['directory'] == $results_array['template']) {
+				$template->set_var('SELECTED', ' selected');
+			} else {
+				$template->set_var('SELECTED', '');
+			}
+			$template->parse('template_list', 'template_list_block', true);
+		}
+	}
+}
+
+// Menu list
+if(MULTIPLE_MENUS == false) {
+	$template->set_var('DISPLAY_MENU_LIST', 'none');
+}
+// Include template info file (if it exists)
+if($results_array['template'] != '') {
+	$template_location = WB_PATH.'/templates/'.$results_array['template'].'/info.php';
+} else {
+	$template_location = WB_PATH.'/templates/'.DEFAULT_TEMPLATE.'/info.php';
+}
+if(file_exists($template_location)) {
+	require($template_location);
+}
+// Check if $menu is set
+if(!isset($menu[1]) OR $menu[1] == '') {
+	// Make our own menu list
+	$menu[1] = $TEXT['MAIN'];
+}
+// Add menu options to the list
+$template->set_block('main_block', 'menu_list_block', 'menu_list');
+foreach($menu AS $number => $name) {
+	$template->set_var('NAME', $name);
+	$template->set_var('VALUE', $number);
+	if($results_array['menu'] == $number) {
+		$template->set_var('SELECTED', 'selected');
+	} else {
+		$template->set_var('SELECTED', '');
+	}
+	$template->parse('menu_list', 'menu_list_block', true);
+}
+
+// Language list
+if($handle = opendir(WB_PATH.'/languages/')) {
+	$template->set_block('main_block', 'language_list_block', 'language_list');
+	while (false !== ($file = readdir($handle))) {
+		if($file != '.' AND $file != '..' AND $file != '.svn' AND $file != 'index.php') {
+			// Include the languages info file
+			require(WB_PATH.'/languages/'.$file);
+			// Work-out if this language is selected
+			if($language_code == $results_array['language']) { $selected = ' selected'; } else { $selected = ''; }
+			// Set the language info
+			$template->set_var(array('VALUE' => $language_code, 'SELECTED' => $selected, 'NAME' => $language_name));
+			// Parse row
+			$template->parse('language_list', 'language_list_block', true);
+		}
+	}
+}
+// Restore to original language
+require(WB_PATH.'/languages/'.LANGUAGE.'.php');
+
+// Select disabled if searching is disabled
+if($results_array['searching'] == 0) {
+	$template->set_var('SEARCHING_DISABLED', ' selected');
+}
+// Select what the page target is
+if($results_array['target'] == '_top') {
+	$template->set_var('TOP_SELECTED', ' selected');
+} elseif($results_array['target'] == '_blank') {
+	$template->set_var('BLANK_SELECTED', ' selected');
+}
+
+// Insert language text
+$template->set_var(array(
+								'HEADING_MODIFY_PAGE_SETTINGS' => $HEADING['MODIFY_PAGE_SETTINGS'],
+								'TEXT_CURRENT_PAGE' => $TEXT['CURRENT_PAGE'],
+								'TEXT_MODIFY' => $TEXT['MODIFY'],
+								'TEXT_MODIFY_PAGE' => $HEADING['MODIFY_PAGE'],
+								'LAST_MODIFIED' => $MESSAGE['PAGES']['LAST_MODIFIED'],
+								'TEXT_PAGE_TITLE' => $TEXT['PAGE_TITLE'],
+								'TEXT_MENU_TITLE' => $TEXT['MENU_TITLE'],
+								'TEXT_TYPE' => $TEXT['TYPE'],
+								'TEXT_MENU' => $TEXT['MENU'],
+								'TEXT_PARENT' => $TEXT['PARENT'],
+								'TEXT_VISIBILITY' => $TEXT['VISIBILITY'],
+								'TEXT_PUBLIC' => $TEXT['PUBLIC'],
+								'TEXT_PRIVATE' => $TEXT['PRIVATE'],
+								'TEXT_REGISTERED' => $TEXT['REGISTERED'],
+								'TEXT_NONE' => $TEXT['NONE'],
+								'TEXT_HIDDEN' => $TEXT['HIDDEN'],
+								'TEXT_TEMPLATE' => $TEXT['TEMPLATE'],
+								'TEXT_TARGET' => $TEXT['TARGET'],
+								'TEXT_SYSTEM_DEFAULT' => $TEXT['SYSTEM_DEFAULT'],
+								'TEXT_PLEASE_SELECT' => $TEXT['PLEASE_SELECT'],
+								'TEXT_NEW_WINDOW' => $TEXT['NEW_WINDOW'],
+								'TEXT_SAME_WINDOW' => $TEXT['SAME_WINDOW'],
+								'TEXT_ADMINISTRATORS' => $TEXT['ADMINISTRATORS'],
+								'TEXT_PRIVATE_VIEWERS' => $TEXT['PRIVATE_VIEWERS'],
+								'TEXT_REGISTERED_VIEWERS' => $TEXT['REGISTERED_VIEWERS'],
+								'TEXT_DESCRIPTION' => $TEXT['DESCRIPTION'],
+								'TEXT_KEYWORDS' => $TEXT['KEYWORDS'],
+								'TEXT_SEARCHING' => $TEXT['SEARCHING'],
+								'TEXT_LANGUAGE' => $TEXT['LANGUAGE'],
+								'TEXT_ENABLED' => $TEXT['ENABLED'],
+								'TEXT_DISABLED' => $TEXT['DISABLED'],
+								'TEXT_SAVE' => $TEXT['SAVE'],
+								'TEXT_RESET' => $TEXT['RESET'],
+								'LAST_MODIFIED' => $MESSAGE['PAGES']['LAST_MODIFIED'],
+								'HEADING_MODIFY_PAGE' => $HEADING['MODIFY_PAGE']
+								)
+						);
+
+$template->parse('main', 'main_block', false);
+$template->pparse('output', 'page');
+
+// Print admin footer
+$admin->print_footer();
+
+?>
Index: trunk/wb/admin/pages/sections_save.php
===================================================================
--- trunk/wb/admin/pages/sections_save.php	(revision 237)
+++ trunk/wb/admin/pages/sections_save.php	(revision 238)
@@ -1,84 +1,84 @@
-<?php
-
-// $Id$-
-/*
-
- Website Baker Project <http://www.websitebaker.org/>
- Copyright (C) 2004-2005, 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
-
-*/
-
+<?php
+
+// $Id$
+
+/*
+
+ Website Baker Project <http://www.websitebaker.org/>
+ Copyright (C) 2004-2005, 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
+
+*/
+
 // Include config file
-require('../../config.php');
-
+require('../../config.php');
+
 // Make sure people are allowed to access this page
-if(MANAGE_SECTIONS != 'enabled') {
-	header('Location: '.ADMIN_URL.'/pages/index.php');
-}
-
+if(MANAGE_SECTIONS != 'enabled') {
+	header('Location: '.ADMIN_URL.'/pages/index.php');
+}
+
 // Get page id
-if(!isset($_GET['page_id']) OR !is_numeric($_GET['page_id'])) {
-	header("Location: index.php");
-} else {
-	$page_id = $_GET['page_id'];
-}
-
+if(!isset($_GET['page_id']) OR !is_numeric($_GET['page_id'])) {
+	header("Location: index.php");
+} else {
+	$page_id = $_GET['page_id'];
+}
+
 // Create new admin object
-require_once(WB_PATH.'/framework/class.admin.php');
-$admin = new admin('Pages', 'pages_modify');
-
+require_once(WB_PATH.'/framework/class.admin.php');
+$admin = new admin('Pages', 'pages_modify');
+
 // Get perms
-$database = new database();
-$results = $database->query("SELECT admin_groups,admin_users FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id'");
-$results_array = $results->fetchRow();
-$old_admin_groups = explode(',', $results_array['admin_groups']);
-$old_admin_users = explode(',', $results_array['admin_users']);
-if(!is_numeric(array_search($admin->get_group_id(), $old_admin_groups)) AND !is_numeric(array_search($admin->get_user_id(), $old_admin_users))) {
-	$admin->print_error($MESSAGE['PAGES']['INSUFFICIENT_PERMISSIONS']);
-}
-
+$database = new database();
+$results = $database->query("SELECT admin_groups,admin_users FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id'");
+$results_array = $results->fetchRow();
+$old_admin_groups = explode(',', $results_array['admin_groups']);
+$old_admin_users = explode(',', $results_array['admin_users']);
+if(!is_numeric(array_search($admin->get_group_id(), $old_admin_groups)) AND !is_numeric(array_search($admin->get_user_id(), $old_admin_users))) {
+	$admin->print_error($MESSAGE['PAGES']['INSUFFICIENT_PERMISSIONS']);
+}
+
 // Get page details
-$database = new database();
-$query = "SELECT * FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id'";
-$results = $database->query($query);
-if($database->is_error()) {
-	$admin->print_header();
-	$admin->print_error($database->get_error());
-}
-if($results->numRows() == 0) {
-	$admin->print_header();
-	$admin->print_error($MESSAGE['PAGES']['NOT_FOUND']);
-}
-$results_array = $results->fetchRow();
-
+$database = new database();
+$query = "SELECT * FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id'";
+$results = $database->query($query);
+if($database->is_error()) {
+	$admin->print_header();
+	$admin->print_error($database->get_error());
+}
+if($results->numRows() == 0) {
+	$admin->print_header();
+	$admin->print_error($MESSAGE['PAGES']['NOT_FOUND']);
+}
+$results_array = $results->fetchRow();
+
 // Set module permissions
-$module_permissions = $_SESSION['MODULE_PERMISSIONS'];
-
+$module_permissions = $_SESSION['MODULE_PERMISSIONS'];
+
 // Loop through sections
-$query_sections = $database->query("SELECT section_id,module,position FROM ".TABLE_PREFIX."sections WHERE page_id = '$page_id' ORDER BY position ASC");
-if($query_sections->numRows() > 0) {
-	$num_sections = $query_sections->numRows();
-	while($section = $query_sections->fetchRow()) {
+$query_sections = $database->query("SELECT section_id,module,position FROM ".TABLE_PREFIX."sections WHERE page_id = '$page_id' ORDER BY position ASC");
+if($query_sections->numRows() > 0) {
+	$num_sections = $query_sections->numRows();
+	while($section = $query_sections->fetchRow()) {
 		// Get the modules real name
-		$module_path = WB_PATH.'/modules/'.$section['module'].'/info.php';
-		if(file_exists($module_path)) {
-			require($module_path);
-			if(!isset($module_function)) { $module_function = 'unknown'; }
+		$module_path = WB_PATH.'/modules/'.$section['module'].'/info.php';
+		if(file_exists($module_path)) {
+			require($module_path);
+			if(!isset($module_function)) { $module_function = 'unknown'; }
 			if(!is_numeric(array_search($section['module'], $module_permissions)) AND $module_function == 'page') {
 				// Update the section record with properties
 				$section_id = $section['section_id'];
@@ -89,21 +89,20 @@
 					if($sql != '') {
 						$database->query($query);
 					}
-				}
-			}
+				}
+			}
 			if(isset($module_function)) { unset($module_function); } // Unset module type
-		}
-	}
-}
-
-// Check for error or print success message
+		}
+	}
+}
+// Check for error or print success message
 if($database->is_error()) {
 	$admin->print_error($database->get_error(), ADMIN_URL.'/pages/sections.php?page_id='.$page_id);
 } else {
 	$admin->print_success($MESSAGE['PAGES']['SECTIONS_PROPERTIES_SAVED'], ADMIN_URL.'/pages/sections.php?page_id='.$page_id);
 }
-
+
 // Print admin footer
-$admin->print_footer();
-
-?>
\ No newline at end of file
+$admin->print_footer();
+
+?>
Index: trunk/wb/admin/pages/index.php
===================================================================
--- trunk/wb/admin/pages/index.php	(revision 237)
+++ trunk/wb/admin/pages/index.php	(revision 238)
@@ -1,547 +1,547 @@
-<?php
-
-/*
-
- Website Baker Project <http://www.websitebaker.org/>
- Copyright (C) 2004-2005, 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('../../config.php');
-require_once(WB_PATH.'/framework/class.admin.php');
-$admin = new admin('Pages', 'pages');
-// Include the WB functions file
-require_once(WB_PATH.'/framework/functions.php');
-
-?>
-<script type="text/javascript" language="javascript">
-function toggle_viewers() {
-	if(document.add.visibility.value == 'private') {
-		document.getElementById('private_viewers').style.display = 'block';
-		document.getElementById('registered_viewers').style.display = 'none';
-	} else if(document.add.visibility.value == 'registered') {
-		document.getElementById('private_viewers').style.display = 'none';
-		document.getElementById('registered_viewers').style.display = 'block';
-	} else {
-		document.getElementById('private_viewers').style.display = 'none';
-		document.getElementById('registered_viewers').style.display = 'none';
-	}
-}
-function toggle_visibility(id){
-	if(document.getElementById(id).style.display == "block") {
-		document.getElementById(id).style.display = "none";
-	} else {
-		document.getElementById(id).style.display = "block";
-	}
-}
-var plus = new Image;
-plus.src = "<?php echo ADMIN_URL; ?>/images/plus_16.png";
-var minus = new Image;
-minus.src = "<?php echo ADMIN_URL; ?>/images/minus_16.png";
-function toggle_plus_minus(id) {
-	var img_src = document.images['plus_minus_' + id].src;
-	if(img_src == plus.src) {
-		document.images['plus_minus_' + id].src = minus.src;
-	} else {
-		document.images['plus_minus_' + id].src = plus.src;
-	}
-}
-</script>
-
-<style type="text/css">
-.pages_list img {
-	display: block;
-}
-ul, li {
-	list-style: none;
-	margin: 0;
-	padding: 0;
-}
-.page_list {
-	display: none;
-}
-</style>
-
-<noscript>
-	<style type="text/css">
-	.page_list {
-		display: block;
-	}
-	</style>
-</noscript>
-<?php
-
-function make_list($parent, $editable_pages) {
-	// Get objects and vars from outside this function
-	global $admin, $template, $database, $TEXT, $MESSAGE;
-	?>
-	<ul id="p<?php echo $parent; ?>" <?php if($parent != 0) { echo 'class="page_list"'; } ?>>
-	<?php	
-	// Get page list from database
-	$database = new database();
-	if(PAGE_TRASH != 'inline') {
-		$query = "SELECT * FROM ".TABLE_PREFIX."pages WHERE parent = '$parent' AND visibility != 'deleted' ORDER BY position ASC";
-	} else {
-		$query = "SELECT * FROM ".TABLE_PREFIX."pages WHERE parent = '$parent' ORDER BY position ASC";
-	}
-	$get_pages = $database->query($query);
-	
-	// Insert values into main page list
-	if($get_pages->numRows() > 0)	{
-		while($page = $get_pages->fetchRow()) {
-			// Get user perms
-			$admin_groups = explode(',', str_replace('_', '', $page['admin_groups']));
-			$admin_users = explode(',', str_replace('_', '', $page['admin_users']));
-			if(is_numeric(array_search($admin->get_group_id(), $admin_groups)) OR is_numeric(array_search($admin->get_user_id(), $admin_users))) {
-				if($page['visibility'] == 'deleted') {
-					if(PAGE_TRASH == 'inline') {
-						$can_modify = true;
-						$editable_pages = $editable_pages+1;
-					} else {
-						$can_modify = false;
-					}
-				} elseif($page['visibility'] != 'deleted') {
-					$can_modify = true;
-					$editable_pages = $editable_pages+1;
-				}
-			} else {
-				$can_modify = false;
-			}
-						
-			// Work out if we should show a plus or not
-			if(PAGE_TRASH != 'inline') {
-				$get_page_subs = $database->query("SELECT page_id,admin_groups,admin_users FROM ".TABLE_PREFIX."pages WHERE parent = '".$page['page_id']."' AND visibility!='deleted'");
-			} else {
-				$get_page_subs = $database->query("SELECT page_id,admin_groups,admin_users FROM ".TABLE_PREFIX."pages WHERE parent = '".$page['page_id']."'");
-			}
-			if($get_page_subs->numRows() > 0) {
-				$display_plus = true;
-			} else {
-				$display_plus = false;
-			}
-			
-			// Work out how many pages there are for this parent
-			$num_pages = $get_pages->numRows();
-			?>
-			
-			<li id="p<?php echo $page['parent']; ?>" style="padding: 2px 0px 2px 0px;">
-			<table width="720" cellpadding="1" cellspacing="0" border="0" style="background-color: #F0F0F0;">
-			<tr>
-				<td width="20" style="padding-left: <?php echo $page['level']*20; ?>px;">
-					<?php
-					if($display_plus == true) {
-					?>
-					<a href="javascript: toggle_visibility('p<?php echo $page['page_id']; ?>');" title="<?php echo $TEXT['EXPAND'].'/'.$TEXT['COLLAPSE']; ?>">
-						<img src="<?php echo ADMIN_URL; ?>/images/plus_16.png" onclick="toggle_plus_minus('<?php echo $page['page_id']; ?>');" name="plus_minus_<?php echo $page['page_id']; ?>" border="0" alt="+" />
-					</a>
-					<?php
-					}
-					?>
-				</td>
-				<?php if($admin->get_permission('pages_modify') == true AND $can_modify == true) { ?>
-				<td>
-					<a href="<?php echo ADMIN_URL; ?>/pages/modify.php?page_id=<?php echo $page['page_id']; ?>" title="<?php echo $TEXT['MODIFY']; ?>"><?php echo ($page['page_title']); ?></a>
-				</td>
-				<?php } else { ?>
-				<td>
-					<?php	echo ($page['page_title']); ?>
-				</td>
-				<?php } ?>
-				<td align="left" width="232">
-					<font color="#999999"><?php echo ($page['menu_title']); ?></font>
-				</td>
-				<td align="center" valign="middle" width="90">
-				<?php if($page['visibility'] == 'public') { ?>
-					<img src="<?php echo ADMIN_URL; ?>/images/visible_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['PUBLIC']; ?>" border="0" />
-				<?php } elseif($page['visibility'] == 'private') { ?>
-					<img src="<?php echo ADMIN_URL; ?>/images/private_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['PRIVATE']; ?>" border="0" />
-				<?php } elseif($page['visibility'] == 'registered') { ?>
-					<img src="<?php echo ADMIN_URL; ?>/images/keys_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['REGISTERED']; ?>" border="0" />
-				<?php } elseif($page['visibility'] == 'hidden') { ?>
-					<img src="<?php echo ADMIN_URL; ?>/images/hidden_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['HIDDEN']; ?>" border="0" />
-				<?php } elseif($page['visibility'] == 'none') { ?>
-					<img src="<?php echo ADMIN_URL; ?>/images/none_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['NONE']; ?>" border="0" />
-				<?php } elseif($page['visibility'] == 'deleted') { ?>
-					<img src="<?php echo ADMIN_URL; ?>/images/deleted_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['DELETED']; ?>" border="0" />
-				<?php } ?>
-				</td>
-				<td width="20">
-					<?php if($page['visibility'] != 'deleted') { ?>
-						<?php if($admin->get_permission('pages_settings') == true AND $can_modify == true) { ?>
-						<a href="<?php echo ADMIN_URL; ?>/pages/settings.php?page_id=<?php echo $page['page_id']; ?>" title="<?php echo $TEXT['SETTINGS']; ?>">
-							<img src="<?php echo ADMIN_URL; ?>/images/modify_16.png" border="0" alt="<?php echo $TEXT['SETTINGS']; ?>" />
-						</a>
-						<?php } ?>
-					<?php } else { ?>
-						<a href="<?php echo ADMIN_URL; ?>/pages/restore.php?page_id=<?php echo $page['page_id']; ?>" title="<?php echo $TEXT['RESTORE']; ?>">
-							<img src="<?php echo ADMIN_URL; ?>/images/restore_16.png" border="0" alt="<?php echo $TEXT['RESTORE']; ?>" />
-						</a>
-					<?php } ?>
-				</td>
-				<td width="20">
-				<?php if($page['position'] != 1) { ?>
-					<?php if($page['visibility'] != 'deleted') { ?>
-						<?php if($admin->get_permission('pages_settings') == true AND $can_modify == true) { ?>
-						<a href="<?php echo ADMIN_URL; ?>/pages/move_up.php?page_id=<?php echo $page['page_id']; ?>" title="<?php echo $TEXT['MOVE_UP']; ?>">
-							<img src="<?php echo ADMIN_URL; ?>/images/up_16.png" border="0" alt="^" />
-						</a>
-						<?php } ?>
-					<?php } ?>
-				<?php } ?>
-				</td>
-				<td width="20">
-				<?php if($page['position'] != $num_pages) { ?>
-					<?php if($page['visibility'] != 'deleted') { ?>
-						<?php if($admin->get_permission('pages_settings') == true AND $can_modify == true) { ?>
-						<a href="<?php echo ADMIN_URL; ?>/pages/move_down.php?page_id=<?php echo $page['page_id']; ?>" title="<?php echo $TEXT['MOVE_DOWN']; ?>">
-							<img src="<?php echo ADMIN_URL; ?>/images/down_16.png" border="0" alt="v" />
-						</a>
-						<?php } ?>
-					<?php } ?>
-				<?php } ?>
-				</td>
-				<td width="20">
-					<?php if($admin->get_permission('pages_delete') == true AND $can_modify == true) { ?>
-					<a href="javascript: confirm_link('<?php echo $MESSAGE['PAGES']['DELETE_CONFIRM']; ?>?', '<?php echo ADMIN_URL; ?>/pages/delete.php?page_id=<?php echo $page['page_id']; ?>');" title="<?php echo $TEXT['DELETE']; ?>">
-						<img src="<?php echo ADMIN_URL; ?>/images/delete_16.png" border="0" alt="X" />
-					</a>
-					<?php } ?>
-				</td>
-				<td width="20">
-					<?php if($page['visibility'] != 'deleted' AND $page['visibility'] != 'none') { ?>
-					<a href="<?php echo page_link($page['link']); ?>" target="_blank">
-						<img src="<?php echo ADMIN_URL; ?>/images/view_16.png" border="0" alt="<?php echo $TEXT['VIEW']; ?>" />
-					</a>
-					<?php } ?>
-				</td>
-			</tr>
-			</table>
-			</li>
-							
-			<?php
-			// Get subs
-			$editable_pages=make_list($page['page_id'], $editable_pages);
-		}
-
-	}
-	?>
-	</ul>
-	<?php
-	return $editable_pages;
-}
-
-// Generate pages list
-if($admin->get_permission('pages_view') == true) {
-	?>
-	<table cellpadding="0" cellspacing="0" width="100%" border="0">
-	<tr>
-		<td>
-			<h2><?php echo $HEADING['MODIFY_DELETE_PAGE']; ?></h2>
-		</td>
-		<td align="right">
-			<?php
-				// Check if there are any pages that are in trash, and if we should show a link to the trash page
-				if(PAGE_TRASH == 'separate') {
-					$query_trash = $database->query("SELECT page_id FROM ".TABLE_PREFIX."pages WHERE visibility = 'deleted'");
-					if($query_trash->numRows() > 0) {
-						?>
-						<a href="<?php echo ADMIN_URL; ?>/pages/trash.php">
-						<img src="<?php echo ADMIN_URL; ?>/images/delete_16.png" alt="<?php echo $TEXT['PAGE_TRASH']; ?>" border="0" />
-						<?php echo $TEXT['VIEW_DELETED_PAGES']; ?></a>
-						<?php
-					}
-				}
-			?>
-		</td>
-	</tr>
-	</table>
-	<div class="pages_list">
-	<table cellpadding="1" cellspacing="0" width="720" border="0">
-	<tr>
-		<td width="20">
-			&nbsp;
-		</td>
-		<td>
-			<?php echo $TEXT['PAGE_TITLE']; ?>:
-		</td>
-		<td width="175" align="left">
-			<?php echo $TEXT['MENU_TITLE']; ?>:
-		</td>
-		<td width="130" align="right">
-			<?php echo $TEXT['VISIBILITY']; ?>:
-		</td>
-		<td width="125" align="center">
-			<?php echo $TEXT['ACTIONS']; ?>:
-		</td>		
-	</tr>
-	</table>
-	<?php
-	$editable_pages = make_list(0, 0);
-	?>
-	</div>
-	<div class="empty_list">
-		<?php echo $TEXT['NONE_FOUND']; ?>
-	</div>
-	<?php
-} else {
-	$editable_pages = 0;
-}
-
-// Setup template object
-$template = new Template(ADMIN_PATH.'/pages');
-$template->set_file('page', 'template.html');
-$template->set_block('page', 'main_block', 'main');
-
-// Figure out if the no pages found message should be shown or not
-if($editable_pages == 0) {
-	?>
-	<style type="text/css">
-	.pages_list {
-		display: none;
-	}
-	</style>
-	<?php
-} else {
-	?>
-	<style type="text/css">
-	.empty_list {
-		display: none;
-	}
-	</style>
-	<?php
-}
-
-// Insert values into the add page form
-
-// Group list 1
-	if($admin->get_group_id() == 1) {
-		$query = "SELECT * FROM ".TABLE_PREFIX."groups";
-	} else {
-		$query = "SELECT * FROM ".TABLE_PREFIX."groups WHERE group_id != '".$admin->get_group_id()."'";
-	}
-	$get_groups = $database->query($query);
-	$template->set_block('main_block', 'group_list_block', 'group_list');
-	// Insert admin group and current group first
-	$admin_group_name = $get_groups->fetchRow();
-	$template->set_var(array(
-									'ID' => 1,
-									'TOGGLE' => '',
-									'DISABLED' => ' disabled',
-									'LINK_COLOR' => '000000',
-									'CURSOR' => 'default',
-									'NAME' => $admin_group_name['name'],
-									'CHECKED' => ' checked'
-									)
-							);
-	$template->parse('group_list', 'group_list_block', true);
-	if($admin->get_group_id() != 1) {
-		$template->set_var(array(
-										'ID' => $admin->get_group_id(),
-										'TOGGLE' => '',
-										'DISABLED' => ' disabled',
-										'LINK_COLOR' => '000000',
-										'CURSOR' => 'default',
-										'NAME' => $admin->get_group_name(),
-										'CHECKED' => ' checked'
-										)
-								);
-		$template->parse('group_list', 'group_list_block', true);
-	}
-	while($group = $get_groups->fetchRow()) {
-		// Check if the group is allowed to edit pages
-		$system_permissions = explode(',', $group['system_permissions']);
-		if(is_numeric(array_search('pages_modify', $system_permissions))) {
-			$template->set_var(array(
-											'ID' => $group['group_id'],
-											'TOGGLE' => $group['group_id'],
-											'CHECKED' => '',
-											'DISABLED' => '',
-											'LINK_COLOR' => '',
-											'CURSOR' => 'pointer',
-											'NAME' => $group['name'],
-											'CHECKED' => ''
-											)
-									);
-			$template->parse('group_list', 'group_list_block', true);
-		}
-	}
-// Group list 2
-	if($admin->get_group_id() == 1) {
-		$query = "SELECT * FROM ".TABLE_PREFIX."groups";
-	} else {
-		$query = "SELECT * FROM ".TABLE_PREFIX."groups WHERE group_id != '".$admin->get_group_id()."'";
-	}
-	$get_groups = $database->query($query);
-	$template->set_block('main_block', 'group_list_block2', 'group_list2');
-	// Insert admin group and current group first
-	$admin_group_name = $get_groups->fetchRow();
-	$template->set_var(array(
-									'ID' => 1,
-									'TOGGLE' => '',
-									'DISABLED' => ' disabled',
-									'LINK_COLOR' => '000000',
-									'CURSOR' => 'default',
-									'NAME' => $admin_group_name['name'],
-									'CHECKED' => ' checked'
-									)
-							);
-	$template->parse('group_list2', 'group_list_block2', true);
-	if($admin->get_group_id() != 1) {
-		$template->set_var(array(
-										'ID' => $admin->get_group_id(),
-										'TOGGLE' => '',
-										'DISABLED' => ' disabled',
-										'LINK_COLOR' => '000000',
-										'CURSOR' => 'default',
-										'NAME' => $admin->get_group_name(),
-										'CHECKED' => ' checked'
-										)
-								);
-		$template->parse('group_list2', 'group_list_block2', true);
-	}
-	while($group = $get_groups->fetchRow()) {
-		$template->set_var(array(
-										'ID' => $group['group_id'],
-										'TOGGLE' => $group['group_id'],
-										'CHECKED' => '',
-										'DISABLED' => '',
-										'LINK_COLOR' => '',
-										'CURSOR' => 'pointer',
-										'NAME' => $group['name'],
-										'CHECKED' => ''
-										)
-								);
-		$template->parse('group_list2', 'group_list_block2', true);
-	}
-
-// Parent page list
-$database = new database();
-function parent_list($parent) {
-	global $admin, $database, $template;
-	$query = "SELECT * FROM ".TABLE_PREFIX."pages WHERE parent = '$parent' AND visibility!='deleted' ORDER BY position ASC";
-	$get_pages = $database->query($query);
-	while($page = $get_pages->fetchRow()) {
-		// Stop users from adding pages with a level of more than the set page level limit
-		if($page['level']+1 < PAGE_LEVEL_LIMIT) {
-			// Get user perms
-			$admin_groups = explode(',', str_replace('_', '', $page['admin_groups']));
-			$admin_users = explode(',', str_replace('_', '', $page['admin_users']));
-			if(is_numeric(array_search($admin->get_group_id(), $admin_groups)) OR is_numeric(array_search($admin->get_user_id(), $admin_users))) {
-				$can_modify = true;
-			} else {
-				$can_modify = false;
-			}
-			// Title -'s prefix
-			$title_prefix = '';
-			for($i = 1; $i <= $page['level']; $i++) { $title_prefix .= ' - '; }
-				$template->set_var(array(
-												'ID' => $page['page_id'],
-												'TITLE' => ($title_prefix.$page['page_title'])
-												)
-										);
-				if($can_modify == true) {
-					$template->set_var('DISABLED', '');
-				} else {
-					$template->set_var('DISABLED', ' disabled');
-				}
-				$template->parse('page_list2', 'page_list_block2', true);
-		}
-		parent_list($page['page_id']);
-	}
-}
-$template->set_block('main_block', 'page_list_block2', 'page_list2');
-if($admin->get_permission('pages_add_l0') == true) {
-	$template->set_var(array(
-									'ID' => '0',
-									'TITLE' => $TEXT['NONE'],
-									'SELECTED' => ' selected',
-									'DISABLED' => ''
-									)
-							);
-	$template->parse('page_list2', 'page_list_block2', true);
-}
-parent_list(0);
-
-// Explode module permissions
-$module_permissions = $_SESSION['MODULE_PERMISSIONS'];
-// Modules list
-$template->set_block('main_block', 'module_list_block', 'module_list');
-$result = $database->query("SELECT * FROM ".TABLE_PREFIX."addons WHERE type = 'module' AND function = 'page'");
-if($result->numRows() > 0) {
-	while ($module = $result->fetchRow()) {
-		// Check if user is allowed to use this module
-		if(!isset($module['function'])) { $module['function'] = 'unknown'; }
-		if(!is_numeric(array_search($module['directory'], $module_permissions))) {
-			$template->set_var('VALUE', $module['directory']);
-			$template->set_var('NAME', $module['name']);
-			if($module['directory'] == 'wysiwyg') {
-				$template->set_var('SELECTED', ' selected');
-			} else {
-				$template->set_var('SELECTED', '');
-			}
-			$template->parse('module_list', 'module_list_block', true);
-		}
-		if(isset($module_function)) { unset($module_function); } // Unset module type
-	}
-}
-
-// Insert language headings
-$template->set_var(array(
-								'HEADING_ADD_PAGE' => $HEADING['ADD_PAGE'],
-								'HEADING_MODIFY_INTRO_PAGE' => $HEADING['MODIFY_INTRO_PAGE']
-								)
-						);
-// Insert language text and messages
-$template->set_var(array(
-								'TEXT_TITLE' => $TEXT['TITLE'],
-								'TEXT_TYPE' => $TEXT['TYPE'],
-								'TEXT_PARENT' => $TEXT['PARENT'],
-								'TEXT_VISIBILITY' => $TEXT['VISIBILITY'],
-								'TEXT_PUBLIC' => $TEXT['PUBLIC'],
-								'TEXT_PRIVATE' => $TEXT['PRIVATE'],
-								'TEXT_REGISTERED' => $TEXT['REGISTERED'],
-								'TEXT_HIDDEN' => $TEXT['HIDDEN'],
-								'TEXT_NONE' => $TEXT['NONE'],
-								'TEXT_NONE_FOUND' => $TEXT['NONE_FOUND'],
-								'TEXT_ADD' => $TEXT['ADD'],
-								'TEXT_RESET' => $TEXT['RESET'],
-								'TEXT_ADMINISTRATORS' => $TEXT['ADMINISTRATORS'],								
-								'TEXT_PRIVATE_VIEWERS' => $TEXT['PRIVATE_VIEWERS'],
-								'TEXT_REGISTERED_VIEWERS' => $TEXT['REGISTERED_VIEWERS'],
-								'INTRO_LINK' => $MESSAGE['PAGES']['INTRO_LINK'],
-								)
-						);
-
-// Insert permissions values
-if($admin->get_permission('pages_add') != true) {
-	$template->set_var('DISPLAY_ADD', 'hide');
-} elseif($admin->get_permission('pages_add_l0') != true AND $editable_pages == 0) {
-	$template->set_var('DISPLAY_ADD', 'hide');
-}
-if($admin->get_permission('pages_intro') != true OR INTRO_PAGE != 'enabled') {
-	$template->set_var('DISPLAY_INTRO', 'hide');
-}
-
-
-// Parse template object
-$template->parse('main', 'main_block', false);
-$template->pparse('output', 'page');
-
-// Print admin 
-$admin->print_footer();
-
-?>
+<?php
+
+/*
+
+ Website Baker Project <http://www.websitebaker.org/>
+ Copyright (C) 2004-2005, 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('../../config.php');
+require_once(WB_PATH.'/framework/class.admin.php');
+$admin = new admin('Pages', 'pages');
+// Include the WB functions file
+require_once(WB_PATH.'/framework/functions.php');
+
+?>
+<script type="text/javascript" language="javascript">
+function toggle_viewers() {
+	if(document.add.visibility.value == 'private') {
+		document.getElementById('private_viewers').style.display = 'block';
+		document.getElementById('registered_viewers').style.display = 'none';
+	} else if(document.add.visibility.value == 'registered') {
+		document.getElementById('private_viewers').style.display = 'none';
+		document.getElementById('registered_viewers').style.display = 'block';
+	} else {
+		document.getElementById('private_viewers').style.display = 'none';
+		document.getElementById('registered_viewers').style.display = 'none';
+	}
+}
+function toggle_visibility(id){
+	if(document.getElementById(id).style.display == "block") {
+		document.getElementById(id).style.display = "none";
+	} else {
+		document.getElementById(id).style.display = "block";
+	}
+}
+var plus = new Image;
+plus.src = "<?php echo ADMIN_URL; ?>/images/plus_16.png";
+var minus = new Image;
+minus.src = "<?php echo ADMIN_URL; ?>/images/minus_16.png";
+function toggle_plus_minus(id) {
+	var img_src = document.images['plus_minus_' + id].src;
+	if(img_src == plus.src) {
+		document.images['plus_minus_' + id].src = minus.src;
+	} else {
+		document.images['plus_minus_' + id].src = plus.src;
+	}
+}
+</script>
+
+<style type="text/css">
+.pages_list img {
+	display: block;
+}
+ul, li {
+	list-style: none;
+	margin: 0;
+	padding: 0;
+}
+.page_list {
+	display: none;
+}
+</style>
+
+<noscript>
+	<style type="text/css">
+	.page_list {
+		display: block;
+	}
+	</style>
+</noscript>
+<?php
+
+function make_list($parent, $editable_pages) {
+	// Get objects and vars from outside this function
+	global $admin, $template, $database, $TEXT, $MESSAGE;
+	?>
+	<ul id="p<?php echo $parent; ?>" <?php if($parent != 0) { echo 'class="page_list"'; } ?>>
+	<?php	
+	// Get page list from database
+	$database = new database();
+	if(PAGE_TRASH != 'inline') {
+		$query = "SELECT * FROM ".TABLE_PREFIX."pages WHERE parent = '$parent' AND visibility != 'deleted' ORDER BY position ASC";
+	} else {
+		$query = "SELECT * FROM ".TABLE_PREFIX."pages WHERE parent = '$parent' ORDER BY position ASC";
+	}
+	$get_pages = $database->query($query);
+	
+	// Insert values into main page list
+	if($get_pages->numRows() > 0)	{
+		while($page = $get_pages->fetchRow()) {
+			// Get user perms
+			$admin_groups = explode(',', str_replace('_', '', $page['admin_groups']));
+			$admin_users = explode(',', str_replace('_', '', $page['admin_users']));
+			if(is_numeric(array_search($admin->get_group_id(), $admin_groups)) OR is_numeric(array_search($admin->get_user_id(), $admin_users))) {
+				if($page['visibility'] == 'deleted') {
+					if(PAGE_TRASH == 'inline') {
+						$can_modify = true;
+						$editable_pages = $editable_pages+1;
+					} else {
+						$can_modify = false;
+					}
+				} elseif($page['visibility'] != 'deleted') {
+					$can_modify = true;
+					$editable_pages = $editable_pages+1;
+				}
+			} else {
+				$can_modify = false;
+			}
+						
+			// Work out if we should show a plus or not
+			if(PAGE_TRASH != 'inline') {
+				$get_page_subs = $database->query("SELECT page_id,admin_groups,admin_users FROM ".TABLE_PREFIX."pages WHERE parent = '".$page['page_id']."' AND visibility!='deleted'");
+			} else {
+				$get_page_subs = $database->query("SELECT page_id,admin_groups,admin_users FROM ".TABLE_PREFIX."pages WHERE parent = '".$page['page_id']."'");
+			}
+			if($get_page_subs->numRows() > 0) {
+				$display_plus = true;
+			} else {
+				$display_plus = false;
+			}
+			
+			// Work out how many pages there are for this parent
+			$num_pages = $get_pages->numRows();
+			?>
+			
+			<li id="p<?php echo $page['parent']; ?>" style="padding: 2px 0px 2px 0px;">
+			<table width="720" cellpadding="1" cellspacing="0" border="0" style="background-color: #F0F0F0;">
+			<tr>
+				<td width="20" style="padding-left: <?php echo $page['level']*20; ?>px;">
+					<?php
+					if($display_plus == true) {
+					?>
+					<a href="javascript: toggle_visibility('p<?php echo $page['page_id']; ?>');" title="<?php echo $TEXT['EXPAND'].'/'.$TEXT['COLLAPSE']; ?>">
+						<img src="<?php echo ADMIN_URL; ?>/images/plus_16.png" onclick="toggle_plus_minus('<?php echo $page['page_id']; ?>');" name="plus_minus_<?php echo $page['page_id']; ?>" border="0" alt="+" />
+					</a>
+					<?php
+					}
+					?>
+				</td>
+				<?php if($admin->get_permission('pages_modify') == true AND $can_modify == true) { ?>
+				<td>
+					<a href="<?php echo ADMIN_URL; ?>/pages/modify.php?page_id=<?php echo $page['page_id']; ?>" title="<?php echo $TEXT['MODIFY']; ?>"><?php echo ($page['page_title']); ?></a>
+				</td>
+				<?php } else { ?>
+				<td>
+					<?php	echo ($page['page_title']); ?>
+				</td>
+				<?php } ?>
+				<td align="left" width="232">
+					<font color="#999999"><?php echo ($page['menu_title']); ?></font>
+				</td>
+				<td align="center" valign="middle" width="90">
+				<?php if($page['visibility'] == 'public') { ?>
+					<img src="<?php echo ADMIN_URL; ?>/images/visible_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['PUBLIC']; ?>" border="0" />
+				<?php } elseif($page['visibility'] == 'private') { ?>
+					<img src="<?php echo ADMIN_URL; ?>/images/private_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['PRIVATE']; ?>" border="0" />
+				<?php } elseif($page['visibility'] == 'registered') { ?>
+					<img src="<?php echo ADMIN_URL; ?>/images/keys_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['REGISTERED']; ?>" border="0" />
+				<?php } elseif($page['visibility'] == 'hidden') { ?>
+					<img src="<?php echo ADMIN_URL; ?>/images/hidden_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['HIDDEN']; ?>" border="0" />
+				<?php } elseif($page['visibility'] == 'none') { ?>
+					<img src="<?php echo ADMIN_URL; ?>/images/none_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['NONE']; ?>" border="0" />
+				<?php } elseif($page['visibility'] == 'deleted') { ?>
+					<img src="<?php echo ADMIN_URL; ?>/images/deleted_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['DELETED']; ?>" border="0" />
+				<?php } ?>
+				</td>
+				<td width="20">
+					<?php if($page['visibility'] != 'deleted') { ?>
+						<?php if($admin->get_permission('pages_settings') == true AND $can_modify == true) { ?>
+						<a href="<?php echo ADMIN_URL; ?>/pages/settings.php?page_id=<?php echo $page['page_id']; ?>" title="<?php echo $TEXT['SETTINGS']; ?>">
+							<img src="<?php echo ADMIN_URL; ?>/images/modify_16.png" border="0" alt="<?php echo $TEXT['SETTINGS']; ?>" />
+						</a>
+						<?php } ?>
+					<?php } else { ?>
+						<a href="<?php echo ADMIN_URL; ?>/pages/restore.php?page_id=<?php echo $page['page_id']; ?>" title="<?php echo $TEXT['RESTORE']; ?>">
+							<img src="<?php echo ADMIN_URL; ?>/images/restore_16.png" border="0" alt="<?php echo $TEXT['RESTORE']; ?>" />
+						</a>
+					<?php } ?>
+				</td>
+				<td width="20">
+				<?php if($page['position'] != 1) { ?>
+					<?php if($page['visibility'] != 'deleted') { ?>
+						<?php if($admin->get_permission('pages_settings') == true AND $can_modify == true) { ?>
+						<a href="<?php echo ADMIN_URL; ?>/pages/move_up.php?page_id=<?php echo $page['page_id']; ?>" title="<?php echo $TEXT['MOVE_UP']; ?>">
+							<img src="<?php echo ADMIN_URL; ?>/images/up_16.png" border="0" alt="^" />
+						</a>
+						<?php } ?>
+					<?php } ?>
+				<?php } ?>
+				</td>
+				<td width="20">
+				<?php if($page['position'] != $num_pages) { ?>
+					<?php if($page['visibility'] != 'deleted') { ?>
+						<?php if($admin->get_permission('pages_settings') == true AND $can_modify == true) { ?>
+						<a href="<?php echo ADMIN_URL; ?>/pages/move_down.php?page_id=<?php echo $page['page_id']; ?>" title="<?php echo $TEXT['MOVE_DOWN']; ?>">
+							<img src="<?php echo ADMIN_URL; ?>/images/down_16.png" border="0" alt="v" />
+						</a>
+						<?php } ?>
+					<?php } ?>
+				<?php } ?>
+				</td>
+				<td width="20">
+					<?php if($admin->get_permission('pages_delete') == true AND $can_modify == true) { ?>
+					<a href="javascript: confirm_link('<?php echo $MESSAGE['PAGES']['DELETE_CONFIRM']; ?>?', '<?php echo ADMIN_URL; ?>/pages/delete.php?page_id=<?php echo $page['page_id']; ?>');" title="<?php echo $TEXT['DELETE']; ?>">
+						<img src="<?php echo ADMIN_URL; ?>/images/delete_16.png" border="0" alt="X" />
+					</a>
+					<?php } ?>
+				</td>
+				<td width="20">
+					<?php if($page['visibility'] != 'deleted' AND $page['visibility'] != 'none') { ?>
+					<a href="<?php echo page_link($page['link']); ?>" target="_blank">
+						<img src="<?php echo ADMIN_URL; ?>/images/view_16.png" border="0" alt="<?php echo $TEXT['VIEW']; ?>" />
+					</a>
+					<?php } ?>
+				</td>
+			</tr>
+			</table>
+			</li>
+							
+			<?php
+			// Get subs
+			$editable_pages=make_list($page['page_id'], $editable_pages);
+		}
+
+	}
+	?>
+	</ul>
+	<?php
+	return $editable_pages;
+}
+
+// Generate pages list
+if($admin->get_permission('pages_view') == true) {
+	?>
+	<table cellpadding="0" cellspacing="0" width="100%" border="0">
+	<tr>
+		<td>
+			<h2><?php echo $HEADING['MODIFY_DELETE_PAGE']; ?></h2>
+		</td>
+		<td align="right">
+			<?php
+				// Check if there are any pages that are in trash, and if we should show a link to the trash page
+				if(PAGE_TRASH == 'separate') {
+					$query_trash = $database->query("SELECT page_id FROM ".TABLE_PREFIX."pages WHERE visibility = 'deleted'");
+					if($query_trash->numRows() > 0) {
+						?>
+						<a href="<?php echo ADMIN_URL; ?>/pages/trash.php">
+						<img src="<?php echo ADMIN_URL; ?>/images/delete_16.png" alt="<?php echo $TEXT['PAGE_TRASH']; ?>" border="0" />
+						<?php echo $TEXT['VIEW_DELETED_PAGES']; ?></a>
+						<?php
+					}
+				}
+			?>
+		</td>
+	</tr>
+	</table>
+	<div class="pages_list">
+	<table cellpadding="1" cellspacing="0" width="720" border="0">
+	<tr>
+		<td width="20">
+			&nbsp;
+		</td>
+		<td>
+			<?php echo $TEXT['PAGE_TITLE']; ?>:
+		</td>
+		<td width="175" align="left">
+			<?php echo $TEXT['MENU_TITLE']; ?>:
+		</td>
+		<td width="130" align="right">
+			<?php echo $TEXT['VISIBILITY']; ?>:
+		</td>
+		<td width="125" align="center">
+			<?php echo $TEXT['ACTIONS']; ?>:
+		</td>		
+	</tr>
+	</table>
+	<?php
+	$editable_pages = make_list(0, 0);
+	?>
+	</div>
+	<div class="empty_list">
+		<?php echo $TEXT['NONE_FOUND']; ?>
+	</div>
+	<?php
+} else {
+	$editable_pages = 0;
+}
+
+// Setup template object
+$template = new Template(ADMIN_PATH.'/pages');
+$template->set_file('page', 'template.html');
+$template->set_block('page', 'main_block', 'main');
+
+// Figure out if the no pages found message should be shown or not
+if($editable_pages == 0) {
+	?>
+	<style type="text/css">
+	.pages_list {
+		display: none;
+	}
+	</style>
+	<?php
+} else {
+	?>
+	<style type="text/css">
+	.empty_list {
+		display: none;
+	}
+	</style>
+	<?php
+}
+
+// Insert values into the add page form
+
+// Group list 1
+	if($admin->get_group_id() == 1) {
+		$query = "SELECT * FROM ".TABLE_PREFIX."groups";
+	} else {
+		$query = "SELECT * FROM ".TABLE_PREFIX."groups WHERE group_id != '".$admin->get_group_id()."'";
+	}
+	$get_groups = $database->query($query);
+	$template->set_block('main_block', 'group_list_block', 'group_list');
+	// Insert admin group and current group first
+	$admin_group_name = $get_groups->fetchRow();
+	$template->set_var(array(
+									'ID' => 1,
+									'TOGGLE' => '',
+									'DISABLED' => ' disabled',
+									'LINK_COLOR' => '000000',
+									'CURSOR' => 'default',
+									'NAME' => $admin_group_name['name'],
+									'CHECKED' => ' checked'
+									)
+							);
+	$template->parse('group_list', 'group_list_block', true);
+	if($admin->get_group_id() != 1) {
+		$template->set_var(array(
+										'ID' => $admin->get_group_id(),
+										'TOGGLE' => '',
+										'DISABLED' => ' disabled',
+										'LINK_COLOR' => '000000',
+										'CURSOR' => 'default',
+										'NAME' => $admin->get_group_name(),
+										'CHECKED' => ' checked'
+										)
+								);
+		$template->parse('group_list', 'group_list_block', true);
+	}
+	while($group = $get_groups->fetchRow()) {
+		// Check if the group is allowed to edit pages
+		$system_permissions = explode(',', $group['system_permissions']);
+		if(is_numeric(array_search('pages_modify', $system_permissions))) {
+			$template->set_var(array(
+											'ID' => $group['group_id'],
+											'TOGGLE' => $group['group_id'],
+											'CHECKED' => '',
+											'DISABLED' => '',
+											'LINK_COLOR' => '',
+											'CURSOR' => 'pointer',
+											'NAME' => $group['name'],
+											'CHECKED' => ''
+											)
+									);
+			$template->parse('group_list', 'group_list_block', true);
+		}
+	}
+// Group list 2
+	if($admin->get_group_id() == 1) {
+		$query = "SELECT * FROM ".TABLE_PREFIX."groups";
+	} else {
+		$query = "SELECT * FROM ".TABLE_PREFIX."groups WHERE group_id != '".$admin->get_group_id()."'";
+	}
+	$get_groups = $database->query($query);
+	$template->set_block('main_block', 'group_list_block2', 'group_list2');
+	// Insert admin group and current group first
+	$admin_group_name = $get_groups->fetchRow();
+	$template->set_var(array(
+									'ID' => 1,
+									'TOGGLE' => '',
+									'DISABLED' => ' disabled',
+									'LINK_COLOR' => '000000',
+									'CURSOR' => 'default',
+									'NAME' => $admin_group_name['name'],
+									'CHECKED' => ' checked'
+									)
+							);
+	$template->parse('group_list2', 'group_list_block2', true);
+	if($admin->get_group_id() != 1) {
+		$template->set_var(array(
+										'ID' => $admin->get_group_id(),
+										'TOGGLE' => '',
+										'DISABLED' => ' disabled',
+										'LINK_COLOR' => '000000',
+										'CURSOR' => 'default',
+										'NAME' => $admin->get_group_name(),
+										'CHECKED' => ' checked'
+										)
+								);
+		$template->parse('group_list2', 'group_list_block2', true);
+	}
+	while($group = $get_groups->fetchRow()) {
+		$template->set_var(array(
+										'ID' => $group['group_id'],
+										'TOGGLE' => $group['group_id'],
+										'CHECKED' => '',
+										'DISABLED' => '',
+										'LINK_COLOR' => '',
+										'CURSOR' => 'pointer',
+										'NAME' => $group['name'],
+										'CHECKED' => ''
+										)
+								);
+		$template->parse('group_list2', 'group_list_block2', true);
+	}
+
+// Parent page list
+$database = new database();
+function parent_list($parent) {
+	global $admin, $database, $template;
+	$query = "SELECT * FROM ".TABLE_PREFIX."pages WHERE parent = '$parent' AND visibility!='deleted' ORDER BY position ASC";
+	$get_pages = $database->query($query);
+	while($page = $get_pages->fetchRow()) {
+		// Stop users from adding pages with a level of more than the set page level limit
+		if($page['level']+1 < PAGE_LEVEL_LIMIT) {
+			// Get user perms
+			$admin_groups = explode(',', str_replace('_', '', $page['admin_groups']));
+			$admin_users = explode(',', str_replace('_', '', $page['admin_users']));
+			if(is_numeric(array_search($admin->get_group_id(), $admin_groups)) OR is_numeric(array_search($admin->get_user_id(), $admin_users))) {
+				$can_modify = true;
+			} else {
+				$can_modify = false;
+			}
+			// Title -'s prefix
+			$title_prefix = '';
+			for($i = 1; $i <= $page['level']; $i++) { $title_prefix .= ' - '; }
+				$template->set_var(array(
+												'ID' => $page['page_id'],
+												'TITLE' => ($title_prefix.$page['page_title'])
+												)
+										);
+				if($can_modify == true) {
+					$template->set_var('DISABLED', '');
+				} else {
+					$template->set_var('DISABLED', ' disabled');
+				}
+				$template->parse('page_list2', 'page_list_block2', true);
+		}
+		parent_list($page['page_id']);
+	}
+}
+$template->set_block('main_block', 'page_list_block2', 'page_list2');
+if($admin->get_permission('pages_add_l0') == true) {
+	$template->set_var(array(
+									'ID' => '0',
+									'TITLE' => $TEXT['NONE'],
+									'SELECTED' => ' selected',
+									'DISABLED' => ''
+									)
+							);
+	$template->parse('page_list2', 'page_list_block2', true);
+}
+parent_list(0);
+
+// Explode module permissions
+$module_permissions = $_SESSION['MODULE_PERMISSIONS'];
+// Modules list
+$template->set_block('main_block', 'module_list_block', 'module_list');
+$result = $database->query("SELECT * FROM ".TABLE_PREFIX."addons WHERE type = 'module' AND function = 'page'");
+if($result->numRows() > 0) {
+	while ($module = $result->fetchRow()) {
+		// Check if user is allowed to use this module
+		if(!isset($module['function'])) { $module['function'] = 'unknown'; }
+		if(!is_numeric(array_search($module['directory'], $module_permissions))) {
+			$template->set_var('VALUE', $module['directory']);
+			$template->set_var('NAME', $module['name']);
+			if($module['directory'] == 'wysiwyg') {
+				$template->set_var('SELECTED', ' selected');
+			} else {
+				$template->set_var('SELECTED', '');
+			}
+			$template->parse('module_list', 'module_list_block', true);
+		}
+		if(isset($module_function)) { unset($module_function); } // Unset module type
+	}
+}
+
+// Insert language headings
+$template->set_var(array(
+								'HEADING_ADD_PAGE' => $HEADING['ADD_PAGE'],
+								'HEADING_MODIFY_INTRO_PAGE' => $HEADING['MODIFY_INTRO_PAGE']
+								)
+						);
+// Insert language text and messages
+$template->set_var(array(
+								'TEXT_TITLE' => $TEXT['TITLE'],
+								'TEXT_TYPE' => $TEXT['TYPE'],
+								'TEXT_PARENT' => $TEXT['PARENT'],
+								'TEXT_VISIBILITY' => $TEXT['VISIBILITY'],
+								'TEXT_PUBLIC' => $TEXT['PUBLIC'],
+								'TEXT_PRIVATE' => $TEXT['PRIVATE'],
+								'TEXT_REGISTERED' => $TEXT['REGISTERED'],
+								'TEXT_HIDDEN' => $TEXT['HIDDEN'],
+								'TEXT_NONE' => $TEXT['NONE'],
+								'TEXT_NONE_FOUND' => $TEXT['NONE_FOUND'],
+								'TEXT_ADD' => $TEXT['ADD'],
+								'TEXT_RESET' => $TEXT['RESET'],
+								'TEXT_ADMINISTRATORS' => $TEXT['ADMINISTRATORS'],								
+								'TEXT_PRIVATE_VIEWERS' => $TEXT['PRIVATE_VIEWERS'],
+								'TEXT_REGISTERED_VIEWERS' => $TEXT['REGISTERED_VIEWERS'],
+								'INTRO_LINK' => $MESSAGE['PAGES']['INTRO_LINK'],
+								)
+						);
+
+// Insert permissions values
+if($admin->get_permission('pages_add') != true) {
+	$template->set_var('DISPLAY_ADD', 'hide');
+} elseif($admin->get_permission('pages_add_l0') != true AND $editable_pages == 0) {
+	$template->set_var('DISPLAY_ADD', 'hide');
+}
+if($admin->get_permission('pages_intro') != true OR INTRO_PAGE != 'enabled') {
+	$template->set_var('DISPLAY_INTRO', 'hide');
+}
+
+
+// Parse template object
+$template->parse('main', 'main_block', false);
+$template->pparse('output', 'page');
+
+// Print admin 
+$admin->print_footer();
+
+?>
Index: trunk/wb/admin/pages/sections.php
===================================================================
--- trunk/wb/admin/pages/sections.php	(revision 237)
+++ trunk/wb/admin/pages/sections.php	(revision 238)
@@ -1,266 +1,266 @@
-<?php
-
-/*
-
- Website Baker Project <http://www.websitebaker.org/>
- Copyright (C) 2004-2005, 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
-
-*/
-
-// Include config file
-require('../../config.php');
-
-// Make sure people are allowed to access this page
-if(MANAGE_SECTIONS != 'enabled') {
-	header('Location: '.ADMIN_URL.'/pages/index.php');
-}
-
-// Get page id
-if(!isset($_GET['page_id']) OR !is_numeric($_GET['page_id'])) {
-	header("Location: index.php");
-} else {
-	$page_id = $_GET['page_id'];
-}
-
-// Create new admin object
-require_once(WB_PATH.'/framework/class.admin.php');
-$admin = new admin('Pages', 'pages_modify');
-
-// Check if we are supposed to add or delete a section
-if(isset($_GET['section_id']) AND is_numeric($_GET['section_id'])) {
-	// Get more information about this section
-	$section_id = $_GET['section_id'];
-	$query_section = $database->query("SELECT module FROM ".TABLE_PREFIX."sections WHERE section_id = '$section_id'");
-	if($query_section->numRows() == 0) {
-		$admin->print_error('Section not found');
-	}
-	$section = $query_section->fetchRow();
-	// Include the modules delete file if it exists
-	if(file_exists(WB_PATH.'/modules/'.$section['module'].'/delete.php')) {
-		require(WB_PATH.'/modules/'.$section['module'].'/delete.php');
-	}
-	$database->query("DELETE FROM ".TABLE_PREFIX."sections WHERE section_id = '$section_id' LIMIT 1");
-	if($database->is_error()) {
-		$admin->print_error($database->get_error());
-	} else {
-		require(WB_PATH.'/framework/class.order.php');
-		$order = new order(TABLE_PREFIX.'sections', 'position', 'section_id', 'page_id');
-		$order->clean($page_id);
-		$admin->print_success($TEXT['SUCCESS'], ADMIN_URL.'/pages/sections.php?page_id='.$page_id);
-		$admin->print_footer();
-		exit();
-	}
-} elseif(isset($_POST['module']) AND $_POST['module'] != '') {
-	// Get section info
-	$module = $_POST['module'];
-	// Include the ordering class
-	require(WB_PATH.'/framework/class.order.php');
-	// Get new order
-	$order = new order(TABLE_PREFIX.'sections', 'position', 'section_id', 'page_id');
-	$position = $order->get_new($page_id);	
-	// Insert module into DB
-	$database->query("INSERT INTO ".TABLE_PREFIX."sections (page_id,module,position,block) VALUES ('$page_id','$module','$position','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');
-	}	
-}
-
-// Get perms
-$database = new database();
-$results = $database->query("SELECT admin_groups,admin_users FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id'");
-$results_array = $results->fetchRow();
-$old_admin_groups = explode(',', $results_array['admin_groups']);
-$old_admin_users = explode(',', $results_array['admin_users']);
-if(!is_numeric(array_search($admin->get_group_id(), $old_admin_groups)) AND !is_numeric(array_search($admin->get_user_id(), $old_admin_users))) {
-	$admin->print_error($MESSAGE['PAGES']['INSUFFICIENT_PERMISSIONS']);
-}
-
-// Get page details
-$database = new database();
-$query = "SELECT * FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id'";
-$results = $database->query($query);
-if($database->is_error()) {
-	$admin->print_header();
-	$admin->print_error($database->get_error());
-}
-if($results->numRows() == 0) {
-	$admin->print_header();
-	$admin->print_error($MESSAGE['PAGES']['NOT_FOUND']);
-}
-$results_array = $results->fetchRow();
-
-// Set module permissions
-$module_permissions = $_SESSION['MODULE_PERMISSIONS'];
-
-// Unset block var
-unset($block);
-// Include template info file (if it exists)
-if($results_array['template'] != '') {
-	$template_location = WB_PATH.'/templates/'.$results_array['template'].'/info.php';
-} else {
-	$template_location = WB_PATH.'/templates/'.DEFAULT_TEMPLATE.'/info.php';
-}
-if(file_exists($template_location)) {
-	require($template_location);
-}
-// Check if $menu is set
-if(!isset($block[1]) OR $block[1] == '') {
-	// Make our own menu list
-	$block[1] = $TEXT['MAIN'];
-}
-
-?>
-<table cellpadding="5" cellspacing="0" border="0" align="center" width="100%" height="50" style="margin-bottom: 10px;">
-<tr style="background-color: #F0F0F0;">
-	<td valign="middle" align="left">
-		<h2><?php echo $HEADING['MANAGE_SECTIONS']; ?></h2>
-	</td>
-	<td align="right">
-		<?php echo $TEXT['CURRENT_PAGE']; ?>: 
-		<b><?php echo ($results_array['page_title']); ?></b>
-		-
-		<a href="<?php echo ADMIN_URL; ?>/pages/modify.php?page_id=<?php echo $page_id; ?>"><?php echo $HEADING['MODIFY_PAGE']; ?></a>
-		-
-		<a href="<?php echo ADMIN_URL; ?>/pages/settings.php?page_id=<?php echo $page_id; ?>"><?php echo $TEXT['CHANGE_SETTINGS']; ?></a>
-	</td>
-</tr>
-</table>
-
-<?php
-$query_sections = $database->query("SELECT section_id,module,position,block FROM ".TABLE_PREFIX."sections WHERE page_id = '$page_id' ORDER BY position ASC");
-if($query_sections->numRows() > 0) {
-?>
-<form name="section_properties" action="<?php echo ADMIN_URL; ?>/pages/sections_save.php?page_id=<?php echo $page_id; ?>" method="post">
-
-<table cellpadding="5" cellspacing="0" border="0" align="center" width="100%">
-<tr>
-	<td><?php echo $TEXT['TYPE']; ?>:</td>
-	<?php if(SECTION_BLOCKS) { ?>
-	<td style="display: {DISPLAY_BLOCK}"><?php echo $TEXT['BLOCK']; ?>:</td>
-	<?php } ?>
-	<td colspan="3" width="60"><?php echo $TEXT['ACTIONS']; ?>:</td>
-</tr>
-<?php
-	$num_sections = $query_sections->numRows();
-	while($section = $query_sections->fetchRow()) {
-		// Get the modules real name
-		$module_path = WB_PATH.'/modules/'.$section['module'].'/info.php';
-		if(file_exists($module_path)) {
-			require($module_path);
-			if(!isset($module_function)) { $module_function = 'unknown'; }
-			if(!is_numeric(array_search($section['module'], $module_permissions)) AND $module_function == 'page') {
-			?>
-			<tr>
-				<td style="width: 250px;"><a href="<?php echo ADMIN_URL; ?>/pages/modify.php?page_id=<?php echo $page_id; ?>#<?php echo $section['section_id']; ?>"><?php echo $module_name; ?></a></td>
-				<?php if(SECTION_BLOCKS) { ?>
-				<td>
-					<select name="block<?php echo $section['section_id']; ?>" style="width: 150px;">
-						<?php
-						foreach($block AS $number => $name) {
-							?>
-							<option value="<?php echo $number; ?>"<?php if($number == $section['block']) { echo ' selected'; } ?>><?php echo $name; ?></option>
-							<?php
-						}
-						?>
-					</select>
-				</td>
-				<?php } ?>
-				<td width="20">
-					<?php if($section['position'] != 1) { ?>
-					<a href="<?php echo ADMIN_URL; ?>/pages/move_up.php?page_id=<?php echo $page_id; ?>&section_id=<?php echo $section['section_id']; ?>">
-						<img src="<?php echo ADMIN_URL; ?>/images/up_16.png" alt="^" border="0" />
-					</a>
-					<?php } ?>
-				</td>
-				<td width="20">
-					<?php if($section['position'] != $num_sections) { ?>
-					<a href="<?php echo ADMIN_URL; ?>/pages/move_down.php?page_id=<?php echo $page_id; ?>&section_id=<?php echo $section['section_id']; ?>">
-						<img src="<?php echo ADMIN_URL; ?>/images/down_16.png" alt="v" border="0" />
-					</a>
-					<?php } ?>
-				</td>
-				<td width="20">
-					<a href="javascript: confirm_link('<?php echo $TEXT['ARE_YOU_SURE']; ?>', '<?php echo ADMIN_URL; ?>/pages/sections.php?page_id=<?php echo $page_id; ?>&section_id=<?php echo $section['section_id']; ?>');">
-						<img src="<?php echo ADMIN_URL; ?>/images/delete_16.png" alt="Del" border="0" />
-					</a>
-				</td>
-			</tr>
-			<?php
-			}
-			if(isset($module_function)) { unset($module_function); } // Unset module type
-		}
-	}
-	?>
-	<tr>
-		<td>&nbsp;</td>
-		<?php if(SECTION_BLOCKS) { ?>
-		<td><input type="submit" name="save" value="<?php echo $TEXT['SAVE']; ?>" style="width: 150px;" /></td>
-		<?php } ?>
-		<td colspan="3" width="60">&nbsp;</td>
-	</tr>
-	</table>
-
-</form>
-
-<?php
-}
-
-// Work-out if we should show the "Add Section" form
-$query_sections = $database->query("SELECT section_id FROM ".TABLE_PREFIX."sections WHERE page_id = '$page_id' AND module = 'menu_link'");
-if($query_sections->numRows() == 0) {
-	?>
-	<h2><?php echo $TEXT['ADD_SECTION']; ?></h2>
-	
-	<form name="add" action="<?php echo ADMIN_URL; ?>/pages/sections.php?page_id=<?php echo $page_id; ?>" method="post">
-	
-	<table cellpadding="5" cellspacing="0" border="0" align="center" width="100%">
-	<tr>
-		<td>
-			<select name="module" style="width: 100%;">
-			<?php
-			// Insert module list
-			$result = $database->query("SELECT * FROM ".TABLE_PREFIX."addons WHERE type = 'module' AND function = 'page' AND directory != 'menu_link'");
-			if($result->numRows() > 0) {
-				while($module = $result->fetchRow()) {
-					// Check if user is allowed to use this module
-					if(!is_numeric(array_search($module['directory'], $module_permissions))) {
-						?>
-						<option value="<?php echo $module['directory']; ?>"<?php if($module['directory'] == 'wysiwyg') { echo 'selected'; } ?>><?php echo $module['name']; ?></option>
-						<?php
-					}
-				}
-			}
-			?>
-			</select>
-		</td>
-		<td width="100">
-			<input type="submit" name="submit" value="<?php echo $TEXT['ADD']; ?>" style="width: 100px" />
-		</td>
-	</tr>
-	</table>
-	
-	</form>
-	<?php
-}
-
-// Print admin footer
-$admin->print_footer();
-
-?>
+<?php
+
+/*
+
+ Website Baker Project <http://www.websitebaker.org/>
+ Copyright (C) 2004-2005, 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
+
+*/
+
+// Include config file
+require('../../config.php');
+
+// Make sure people are allowed to access this page
+if(MANAGE_SECTIONS != 'enabled') {
+	header('Location: '.ADMIN_URL.'/pages/index.php');
+}
+
+// Get page id
+if(!isset($_GET['page_id']) OR !is_numeric($_GET['page_id'])) {
+	header("Location: index.php");
+} else {
+	$page_id = $_GET['page_id'];
+}
+
+// Create new admin object
+require_once(WB_PATH.'/framework/class.admin.php');
+$admin = new admin('Pages', 'pages_modify');
+
+// Check if we are supposed to add or delete a section
+if(isset($_GET['section_id']) AND is_numeric($_GET['section_id'])) {
+	// Get more information about this section
+	$section_id = $_GET['section_id'];
+	$query_section = $database->query("SELECT module FROM ".TABLE_PREFIX."sections WHERE section_id = '$section_id'");
+	if($query_section->numRows() == 0) {
+		$admin->print_error('Section not found');
+	}
+	$section = $query_section->fetchRow();
+	// Include the modules delete file if it exists
+	if(file_exists(WB_PATH.'/modules/'.$section['module'].'/delete.php')) {
+		require(WB_PATH.'/modules/'.$section['module'].'/delete.php');
+	}
+	$database->query("DELETE FROM ".TABLE_PREFIX."sections WHERE section_id = '$section_id' LIMIT 1");
+	if($database->is_error()) {
+		$admin->print_error($database->get_error());
+	} else {
+		require(WB_PATH.'/framework/class.order.php');
+		$order = new order(TABLE_PREFIX.'sections', 'position', 'section_id', 'page_id');
+		$order->clean($page_id);
+		$admin->print_success($TEXT['SUCCESS'], ADMIN_URL.'/pages/sections.php?page_id='.$page_id);
+		$admin->print_footer();
+		exit();
+	}
+} elseif(isset($_POST['module']) AND $_POST['module'] != '') {
+	// Get section info
+	$module = $_POST['module'];
+	// Include the ordering class
+	require(WB_PATH.'/framework/class.order.php');
+	// Get new order
+	$order = new order(TABLE_PREFIX.'sections', 'position', 'section_id', 'page_id');
+	$position = $order->get_new($page_id);	
+	// Insert module into DB
+	$database->query("INSERT INTO ".TABLE_PREFIX."sections (page_id,module,position,block) VALUES ('$page_id','$module','$position','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');
+	}	
+}
+
+// Get perms
+$database = new database();
+$results = $database->query("SELECT admin_groups,admin_users FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id'");
+$results_array = $results->fetchRow();
+$old_admin_groups = explode(',', $results_array['admin_groups']);
+$old_admin_users = explode(',', $results_array['admin_users']);
+if(!is_numeric(array_search($admin->get_group_id(), $old_admin_groups)) AND !is_numeric(array_search($admin->get_user_id(), $old_admin_users))) {
+	$admin->print_error($MESSAGE['PAGES']['INSUFFICIENT_PERMISSIONS']);
+}
+
+// Get page details
+$database = new database();
+$query = "SELECT * FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id'";
+$results = $database->query($query);
+if($database->is_error()) {
+	$admin->print_header();
+	$admin->print_error($database->get_error());
+}
+if($results->numRows() == 0) {
+	$admin->print_header();
+	$admin->print_error($MESSAGE['PAGES']['NOT_FOUND']);
+}
+$results_array = $results->fetchRow();
+
+// Set module permissions
+$module_permissions = $_SESSION['MODULE_PERMISSIONS'];
+
+// Unset block var
+unset($block);
+// Include template info file (if it exists)
+if($results_array['template'] != '') {
+	$template_location = WB_PATH.'/templates/'.$results_array['template'].'/info.php';
+} else {
+	$template_location = WB_PATH.'/templates/'.DEFAULT_TEMPLATE.'/info.php';
+}
+if(file_exists($template_location)) {
+	require($template_location);
+}
+// Check if $menu is set
+if(!isset($block[1]) OR $block[1] == '') {
+	// Make our own menu list
+	$block[1] = $TEXT['MAIN'];
+}
+
+?>
+<table cellpadding="5" cellspacing="0" border="0" align="center" width="100%" height="50" style="margin-bottom: 10px;">
+<tr style="background-color: #F0F0F0;">
+	<td valign="middle" align="left">
+		<h2><?php echo $HEADING['MANAGE_SECTIONS']; ?></h2>
+	</td>
+	<td align="right">
+		<?php echo $TEXT['CURRENT_PAGE']; ?>: 
+		<b><?php echo ($results_array['page_title']); ?></b>
+		-
+		<a href="<?php echo ADMIN_URL; ?>/pages/modify.php?page_id=<?php echo $page_id; ?>"><?php echo $HEADING['MODIFY_PAGE']; ?></a>
+		-
+		<a href="<?php echo ADMIN_URL; ?>/pages/settings.php?page_id=<?php echo $page_id; ?>"><?php echo $TEXT['CHANGE_SETTINGS']; ?></a>
+	</td>
+</tr>
+</table>
+
+<?php
+$query_sections = $database->query("SELECT section_id,module,position,block FROM ".TABLE_PREFIX."sections WHERE page_id = '$page_id' ORDER BY position ASC");
+if($query_sections->numRows() > 0) {
+?>
+<form name="section_properties" action="<?php echo ADMIN_URL; ?>/pages/sections_save.php?page_id=<?php echo $page_id; ?>" method="post">
+
+<table cellpadding="5" cellspacing="0" border="0" align="center" width="100%">
+<tr>
+	<td><?php echo $TEXT['TYPE']; ?>:</td>
+	<?php if(SECTION_BLOCKS) { ?>
+	<td style="display: {DISPLAY_BLOCK}"><?php echo $TEXT['BLOCK']; ?>:</td>
+	<?php } ?>
+	<td colspan="3" width="60"><?php echo $TEXT['ACTIONS']; ?>:</td>
+</tr>
+<?php
+	$num_sections = $query_sections->numRows();
+	while($section = $query_sections->fetchRow()) {
+		// Get the modules real name
+		$module_path = WB_PATH.'/modules/'.$section['module'].'/info.php';
+		if(file_exists($module_path)) {
+			require($module_path);
+			if(!isset($module_function)) { $module_function = 'unknown'; }
+			if(!is_numeric(array_search($section['module'], $module_permissions)) AND $module_function == 'page') {
+			?>
+			<tr>
+				<td style="width: 250px;"><a href="<?php echo ADMIN_URL; ?>/pages/modify.php?page_id=<?php echo $page_id; ?>#<?php echo $section['section_id']; ?>"><?php echo $module_name; ?></a></td>
+				<?php if(SECTION_BLOCKS) { ?>
+				<td>
+					<select name="block<?php echo $section['section_id']; ?>" style="width: 150px;">
+						<?php
+						foreach($block AS $number => $name) {
+							?>
+							<option value="<?php echo $number; ?>"<?php if($number == $section['block']) { echo ' selected'; } ?>><?php echo $name; ?></option>
+							<?php
+						}
+						?>
+					</select>
+				</td>
+				<?php } ?>
+				<td width="20">
+					<?php if($section['position'] != 1) { ?>
+					<a href="<?php echo ADMIN_URL; ?>/pages/move_up.php?page_id=<?php echo $page_id; ?>&section_id=<?php echo $section['section_id']; ?>">
+						<img src="<?php echo ADMIN_URL; ?>/images/up_16.png" alt="^" border="0" />
+					</a>
+					<?php } ?>
+				</td>
+				<td width="20">
+					<?php if($section['position'] != $num_sections) { ?>
+					<a href="<?php echo ADMIN_URL; ?>/pages/move_down.php?page_id=<?php echo $page_id; ?>&section_id=<?php echo $section['section_id']; ?>">
+						<img src="<?php echo ADMIN_URL; ?>/images/down_16.png" alt="v" border="0" />
+					</a>
+					<?php } ?>
+				</td>
+				<td width="20">
+					<a href="javascript: confirm_link('<?php echo $TEXT['ARE_YOU_SURE']; ?>', '<?php echo ADMIN_URL; ?>/pages/sections.php?page_id=<?php echo $page_id; ?>&section_id=<?php echo $section['section_id']; ?>');">
+						<img src="<?php echo ADMIN_URL; ?>/images/delete_16.png" alt="Del" border="0" />
+					</a>
+				</td>
+			</tr>
+			<?php
+			}
+			if(isset($module_function)) { unset($module_function); } // Unset module type
+		}
+	}
+	?>
+	<tr>
+		<td>&nbsp;</td>
+		<?php if(SECTION_BLOCKS) { ?>
+		<td><input type="submit" name="save" value="<?php echo $TEXT['SAVE']; ?>" style="width: 150px;" /></td>
+		<?php } ?>
+		<td colspan="3" width="60">&nbsp;</td>
+	</tr>
+	</table>
+
+</form>
+
+<?php
+}
+
+// Work-out if we should show the "Add Section" form
+$query_sections = $database->query("SELECT section_id FROM ".TABLE_PREFIX."sections WHERE page_id = '$page_id' AND module = 'menu_link'");
+if($query_sections->numRows() == 0) {
+	?>
+	<h2><?php echo $TEXT['ADD_SECTION']; ?></h2>
+	
+	<form name="add" action="<?php echo ADMIN_URL; ?>/pages/sections.php?page_id=<?php echo $page_id; ?>" method="post">
+	
+	<table cellpadding="5" cellspacing="0" border="0" align="center" width="100%">
+	<tr>
+		<td>
+			<select name="module" style="width: 100%;">
+			<?php
+			// Insert module list
+			$result = $database->query("SELECT * FROM ".TABLE_PREFIX."addons WHERE type = 'module' AND function = 'page' AND directory != 'menu_link'");
+			if($result->numRows() > 0) {
+				while($module = $result->fetchRow()) {
+					// Check if user is allowed to use this module
+					if(!is_numeric(array_search($module['directory'], $module_permissions))) {
+						?>
+						<option value="<?php echo $module['directory']; ?>"<?php if($module['directory'] == 'wysiwyg') { echo 'selected'; } ?>><?php echo $module['name']; ?></option>
+						<?php
+					}
+				}
+			}
+			?>
+			</select>
+		</td>
+		<td width="100">
+			<input type="submit" name="submit" value="<?php echo $TEXT['ADD']; ?>" style="width: 100px" />
+		</td>
+	</tr>
+	</table>
+	
+	</form>
+	<?php
+}
+
+// Print admin footer
+$admin->print_footer();
+
+?>
Index: trunk/wb/admin/settings/tool.php
===================================================================
--- trunk/wb/admin/settings/tool.php	(revision 237)
+++ trunk/wb/admin/settings/tool.php	(revision 238)
@@ -1,56 +1,56 @@
-<?php
-
-// $Id$
-
-/*
-
- Website Baker Project <http://www.websitebaker.org/>
- Copyright (C) 2004-2005, 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('../../config.php');
-require_once(WB_PATH.'/framework/class.admin.php');
-require_once(WB_PATH.'/framework/functions.php');
-
-if(!isset($_GET['tool'])) {
-	header("Location: index.php?advanced=yes");
-}
-
-// Check if tool is installed
-$result = $database->query("SELECT * FROM ".TABLE_PREFIX."addons WHERE type = 'module' AND function = 'tool' AND directory = '".$_GET['tool']."'");
-if($result->numRows() == 0) {
-	header("Location: index.php?advanced=yes");
-}
-$tool = $result->fetchRow();
-
-$admin = new admin('Settings', 'settings_advanced');
-
-?>
-<h4 style="margin: 0; border-bottom: 1px solid #DDD; padding-bottom: 5px;">
-	<a href="<?php echo ADMIN_URL; ?>/settings/index.php?advanced=yes"><?php echo $MENU['SETTINGS']; ?></a>
-	->
-	<a href="<?php echo ADMIN_URL; ?>/settings/index.php?advanced=yes#administration_tools"><?php echo $HEADING['ADMINISTRATION_TOOLS']; ?></a>
-	->
-	<?php echo $tool['name']; ?>
-</h4>
-<?php
-require(WB_PATH.'/modules/'.$tool['directory'].'/tool.php');
-
-$admin->print_footer();
-
-?>
\ No newline at end of file
+<?php
+
+// $Id$
+
+/*
+
+ Website Baker Project <http://www.websitebaker.org/>
+ Copyright (C) 2004-2005, 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('../../config.php');
+require_once(WB_PATH.'/framework/class.admin.php');
+require_once(WB_PATH.'/framework/functions.php');
+
+if(!isset($_GET['tool'])) {
+	header("Location: index.php?advanced=yes");
+}
+
+// Check if tool is installed
+$result = $database->query("SELECT * FROM ".TABLE_PREFIX."addons WHERE type = 'module' AND function = 'tool' AND directory = '".$_GET['tool']."'");
+if($result->numRows() == 0) {
+	header("Location: index.php?advanced=yes");
+}
+$tool = $result->fetchRow();
+
+$admin = new admin('Settings', 'settings_advanced');
+
+?>
+<h4 style="margin: 0; border-bottom: 1px solid #DDD; padding-bottom: 5px;">
+	<a href="<?php echo ADMIN_URL; ?>/settings/index.php?advanced=yes"><?php echo $MENU['SETTINGS']; ?></a>
+	->
+	<a href="<?php echo ADMIN_URL; ?>/settings/index.php?advanced=yes#administration_tools"><?php echo $HEADING['ADMINISTRATION_TOOLS']; ?></a>
+	->
+	<?php echo $tool['name']; ?>
+</h4>
+<?php
+require(WB_PATH.'/modules/'.$tool['directory'].'/tool.php');
+
+$admin->print_footer();
+
+?>
Index: trunk/wb/admin/settings/template.html
===================================================================
--- trunk/wb/admin/settings/template.html	(revision 237)
+++ trunk/wb/admin/settings/template.html	(revision 238)
@@ -1,586 +1,586 @@
-</div><!-- BEGIN main_block -->
-
-<script language="javascript" type="text/javascript">
-function change_os(type) {
-	if(type == 'linux') {
-		document.getElementById('file_perms_box1').style.display = 'block';
-		document.getElementById('file_perms_box2').style.display = 'block';
-		document.getElementById('file_perms_box3').style.display = 'block';
-	} else if(type == 'windows') {
-		document.getElementById('file_perms_box1').style.display = 'none';
-		document.getElementById('file_perms_box2').style.display = 'none';
-		document.getElementById('file_perms_box3').style.display = 'none';
-	}
-}
-</script>
-
-<style>
-.settings_table td {
-	vertical-align: top;
-	text-align: left;
-}
-.setting_name {
-	width: 180px;
-}
-.setting_value input, .setting_value select, .setting_value textarea {
-	width: 100%;
-}
-.setting_value textarea {
-	height: 50px;
-}
-#file_mode input {
-	width: 12px;
-	height: 12px;
-}
-#dir_mode input {
-	width: 12px;
-	height: 12px;
-}
-.advanced {
-	display: {DISPLAY_ADVANCED};
-}
-.save, .reset {
-	width: 100px;
-}
-#hide2 {
-	display: none;
-}
-</style>
-
-<form name="settings" action="save.php" method="post">
-<input type="hidden" name="advanced" value="{ADVANCED}" />
-
-<table cellpadding="3" cellspacing="0" border="0" align="center" width="100%" class="settings_table">
-<tr>
-	<td colspan="3">
-		<h2>{HEADING_GENERAL_SETTINGS}</h2>
-	</td>
-</tr>
-<tr>
-	<td class="setting_name">{TEXT_WEBSITE_TITLE}:</td>
-	<td class="setting_value" colspan="2">
-		<input type="text" name="website_title" value="{WEBSITE_TITLE}" />
-	</td>
-	<script language="javascript" type="text/javascript">
-	document.settings.title.focus();
-	</script>
-</tr>
-<tr>
-	<td class="setting_name">{TEXT_WEBSITE_DESCRIPTION}:</td>
-	<td class="setting_value" colspan="2">
-		<textarea name="website_description">{WEBSITE_DESCRIPTION}</textarea>
-	</td>
-</tr>
-<tr>
-	<td class="setting_name">{TEXT_WEBSITE_KEYWORDS}:</td>
-	<td class="setting_value" colspan="2">
-		<textarea name="website_keywords">{WEBSITE_KEYWORDS}</textarea>
-	</td>
-</tr>
-<tr class="advanced">
-	<td class="setting_name">{TEXT_WEBSITE_HEADER}:</td>
-	<td class="setting_value" colspan="2">
-		<textarea name="website_header">{WEBSITE_HEADER}</textarea>
-	</td>
-</tr>
-<tr>
-	<td class="setting_name">{TEXT_WEBSITE_FOOTER}:</td>
-	<td class="setting_value" colspan="2">
-		<textarea name="website_footer">{WEBSITE_FOOTER}</textarea>
-	</td>
-</tr>
-<tr class="advanced">
-	<td class="setting_name">{TEXT_PAGE_LEVEL_LIMIT}:</td>
-	<td class="setting_value" colspan="2">
-		<select name="page_level_limit">
-		<!-- BEGIN page_level_limit_list_block -->
-			<option value="{NUMBER}"{SELECTED}>{NUMBER}</option>
-		<!-- END page_level_limit_list_block -->
-		</select>
-	</td>
-</tr>
-<tr>
-	<td class="setting_name">{TEXT_PAGE_TRASH}:</td>
-	<td class="setting_value" colspan="2">
-		<input type="radio" name="page_trash" id="page_trash_disabled" style="width: 14px; height: 14px;" value="disabled"{PAGE_TRASH_DISABLED} />
-		<label for="page_trash_disabled">{TEXT_DISABLED}</label>
-		<input type="radio" name="page_trash" id="page_trash_inline" style="width: 14px; height: 14px;" value="inline"{PAGE_TRASH_INLINE} />
-		<label for="page_trash_inline">{TEXT_INLINE}</label>
-		<div style="margin: 0; padding: 0;{DISPLAY_PAGE_TRASH_SEPARATE}">
-			<input type="radio" name="page_trash" id="page_trash_separate" style="width: 14px; height: 14px;" value="separate"{PAGE_TRASH_SEPARATE} />
-			<label for="page_trash_separate">{TEXT_SEPARATE}</label>
-		</div>
-	</td>
-</tr>
-<input type="hidden" name="page_languages" value="{PAGE_LANGUAGES}" />
-<tr class="advanced">
-	<td class="setting_name">{TEXT_MULTIPLE_MENUS}:</td>
-	<td class="setting_value" colspan="2">
-		<input type="radio" name="multiple_menus" id="multiple_menus_true" style="width: 14px; height: 14px;" value="true"{MULTIPLE_MENUS_ENABLED} />
-		<label for="multiple_menus_true">{TEXT_ENABLED}</label>
-		<input type="radio" name="multiple_menus" id="multiple_menus_false" style="width: 14px; height: 14px;" value="false"{MULTIPLE_MENUS_DISABLED} />
-		<label for="multiple_menus_false">{TEXT_DISABLED}</label>
-	</td>
-</tr>
-<tr>
-	<td class="setting_name">{TEXT_HOME_FOLDERS}:</td>
-	<td class="setting_value" colspan="2">
-		<input type="radio" name="home_folders" id="home_folders_true" style="width: 14px; height: 14px;" value="true"{HOME_FOLDERS_ENABLED} />
-		<label for="home_folders_true">{TEXT_ENABLED}</label>
-		<input type="radio" name="home_folders" id="home_folders_false" style="width: 14px; height: 14px;" value="false"{HOME_FOLDERS_DISABLED} />
-		<label for="home_folders_false">{TEXT_DISABLED}</label>
-	</td>
-</tr>
-<tr class="advanced">
-	<td class="setting_name">{TEXT_MANAGE_SECTIONS}:</td>
-	<td class="setting_value" colspan="2">
-		<input type="radio" name="manage_sections" id="manage_sections_true" style="width: 14px; height: 14px;" value="true"{MANAGE_SECTIONS_ENABLED} />
-		<label for="manage_sections_true">{TEXT_ENABLED}</label>
-		<input type="radio" name="manage_sections" id="manage_sections_false" style="width: 14px; height: 14px;" value="false"{MANAGE_SECTIONS_DISABLED} />
-		<label for="manage_sections_false">{TEXT_DISABLED}</label>
-	</td>
-</tr>
-<tr class="advanced">
-	<td class="setting_name">{TEXT_SECTION_BLOCKS}:</td>
-	<td class="setting_value" colspan="2">
-		<input type="radio" name="section_blocks" id="section_blocks_true" style="width: 14px; height: 14px;" value="true"{SECTION_BLOCKS_ENABLED} />
-		<label for="section_blocks_true">{TEXT_ENABLED}</label>
-		<input type="radio" name="section_blocks" id="section_blocks_false" style="width: 14px; height: 14px;" value="false"{SECTION_BLOCKS_DISABLED} />
-		<label for="section_blocks_false">{TEXT_DISABLED}</label>
-	</td>
-</tr>
-<tr>
-	<td class="setting_name">{TEXT_INTRO_PAGE}:</td>
-	<td class="setting_value" colspan="2">
-		<input type="radio" name="intro_page" id="intro_page_true" style="width: 14px; height: 14px;" value="true"{INTRO_PAGE_ENABLED} />
-		<label for="intro_page_true">{TEXT_ENABLED}</label>
-		<input type="radio" name="intro_page" id="intro_page_false" style="width: 14px; height: 14px;" value="false"{INTRO_PAGE_DISABLED} />
-		<label for="intro_page_false">{TEXT_DISABLED}</label>
-	</td>
-</tr>
-<tr class="advanced">
-	<td class="setting_name">{TEXT_HOMEPAGE_REDIRECTION}:</td>
-	<td class="setting_value" colspan="2">
-		<input type="radio" name="homepage_redirection" id="homepage_redirection_true" style="width: 14px; height: 14px;" value="true"{HOMEPAGE_REDIRECTION_ENABLED} />
-		<label for="homepage_redirection_true">{TEXT_ENABLED}</label>
-		<input type="radio" name="homepage_redirection" id="homepage_redirection_false" style="width: 14px; height: 14px;" value="false"{HOMEPAGE_REDIRECTION_DISABLED} />
-		<label for="homepage_redirection_false">{TEXT_DISABLED}</font>
-	</td>
-</tr>
-<tr class="advanced">
-	<td class="setting_name">{TEXT_SMART_LOGIN}:</td>
-	<td class="setting_value" colspan="2">
-		<input type="radio" name="smart_login" id="smart_login_true" style="width: 14px; height: 14px;" value="true"{SMART_LOGIN_ENABLED} />
-		<label for="smart_login_true">{TEXT_ENABLED}</label>
-		<input type="radio" name="smart_login" id="smart_login_false" style="width: 14px; height: 14px;" value="false"{SMART_LOGIN_DISABLED} />
-		<label for="smart_login_false">{TEXT_DISABLED}</label>
-	</td>
-</tr>
-<tr>
-	<td class="setting_name">{TEXT_LOGIN}:</td>
-	<td class="setting_value" colspan="2">
-		<input type="radio" name="frontend_login" id="frontend_login_true" style="width: 14px; height: 14px;" value="true"{PRIVATE_ENABLED} />
-		<label for="frontend_login_true">{TEXT_ENABLED}</label>
-		<input type="radio" name="frontend_login" id="frontend_login_false" style="width: 14px; height: 14px;" value="false"{PRIVATE_DISABLED} />
-		<label for="frontend_login_false">{TEXT_DISABLED}</label>
-	</td>
-</tr>
-<tr>
-	<td class="setting_name">{TEXT_SIGNUP}:</td>
-	<td class="setting_value" colspan="2">
-		<select name="frontend_signup">
-			<option value="false">{TEXT_DISABLED}</option>
-			<!-- BEGIN group_list_block -->
-				<option value="{ID}" {SELECTED}>{NAME}</option>
-			<!-- END group_list_block -->
-		</select>
-	</td>
-</tr>
-<tr class="advanced">
-	<td class="setting_name">{TEXT_PHP_ERROR_LEVEL}:</td>
-	<td class="setting_value" colspan="2">
-		<select name="er_level">
-			<option value="">{TEXT_PLEASE_SELECT}...</option>
-			<!-- BEGIN error_reporting_list_block -->
-				<option value="{VALUE}"{SELECTED}>{NAME}</option>
-			<!-- END error_reporting_list_block -->
-		</select>
-	</td>
-</tr>
-<tr class="advancedfont">
-	<td class="setting_name">{TEXT_WYSIWYG_STYLE}:</td>
-	<td class="setting_value" colspan="2">
-		<input type="text" name="wysiwyg_style" value="{WYSIWYG_STYLE}" />
-	</td>
-</tr>
-<tr class="advanced">
-	<td class="setting_name">{TEXT_SERVER_EMAIL}:</td>
-	<td class="setting_value" colspan="2">
-		<input type="text" name="server_email" value="{SERVER_EMAIL}" />
-	</td>
-</tr>
-<tr class="advanced">
-	<td class="setting_name">{TEXT_WYSIWYG_EDITOR}:</td>
-	<td class="setting_value" colspan="2">
-		<select name="wysiwyg_editor">
-		<!-- BEGIN editor_list_block -->
-			<option value="{FILE}"{SELECTED}>{NAME}</option>
-		<!-- END editor_list_block -->
-		</select>
-	</td>
-</tr>
-<tr>
-	<td>&nbsp;</td>
-	<td>
-		<input type="submit" name="submit" value="{TEXT_SAVE}" class="save" />
-		<input type="reset" name="reset" value="{TEXT_RESET}" class="reset" />
-	</td>
-	<td style="text-align: right;">
-		<button onclick="window.location = '{ADVANCED_LINK}'; return false;" class="{DISPLAY_ADVANCED_BUTTON}">{ADVANCED_BUTTON}</button>
-	</td>
-</tr>
-<tr>
-	<td colspan="3" style="padding-top: 10px;">
-		<h2>{HEADING_DEFAULT_SETTINGS}</h2>
-	</td>
-</tr>
-<tr>
-	<td class="setting_name">{TEXT_LANGUAGE}:</td>
-	<td class="setting_value" colspan="2">
-		<select name="default_language">
-			<!-- BEGIN language_list_block -->
-			<option value="{CODE}"{SELECTED}>{NAME} ({CODE})</option>
-			<!-- END language_list_block -->
-		</select>
-	</td>
-</tr>
-<tr>
-	<td class="setting_name">{TEXT_TIMEZONE}:</td>
-	<td class="setting_value" colspan="2">
-		<select name="default_timezone">
-			<option value="0">{TEXT_PLEASE_SELECT}...</option>
-			<!-- BEGIN timezone_list_block -->
-				<option value="{VALUE}" {SELECTED}>{NAME}</option>
-			<!-- END timezone_list_block -->
-		</select>
-	</td>
-</tr>
-<tr>
-	<td class="setting_name">{TEXT_DATE_FORMAT}:</td>
-	<td class="setting_value" colspan="2">
-		<select name="default_date_format">
-			<option value="M d Y">{TEXT_PLEASE_SELECT}...</option>
-			<!-- BEGIN date_format_list_block -->
-				<option value="{VALUE}" {SELECTED}>{NAME}</option>
-			<!-- END date_format_list_block -->
-		</select>
-	</td>
-</tr>
-<tr>
-	<td class="setting_name">{TEXT_TIME_FORMAT}:</td>
-	<td class="setting_value" colspan="2">
-		<select name="default_time_format">
-			<option value="g:i A">{TEXT_PLEASE_SELECT}...</option>
-			<!-- BEGIN time_format_list_block -->
-				<option value="{VALUE}" {SELECTED}>{NAME}</option>
-			<!-- END time_format_list_block -->
-		</select>
-	</td>
-</tr>
-<tr>
-	<td class="setting_name">{TEXT_TEMPLATE}:</td>
-	<td class="setting_value" colspan="2">
-		<select name="default_template">
-		<!-- BEGIN template_list_block -->
-			<option value="{FILE}"{SELECTED}>{NAME}</option>
-		<!-- END template_list_block -->
-		</select>
-	</td>
-</tr>
-<tr>
-	<td>&nbsp;</td>
-	<td>
-		<input type="submit" name="submit" value="{TEXT_SAVE}" class="save" />
-		<input type="reset" name="reset" value="{TEXT_RESET}" class="reset" />
-	</td>
-	<td style="text-align: right;">
-		<button onclick="window.location = '{ADVANCED_LINK}'; return false;" class="{DISPLAY_ADVANCED_BUTTON}">{ADVANCED_BUTTON}</button>
-	</td>
-</tr>
-<tr>
-	<td colspan="3" style="padding-top: 10px;">
-		<h2>{HEADING_SEARCH_SETTINGS}</h2>
-	</td>
-</tr>
-<tr>
-	<td class="setting_name">{TEXT_VISIBILITY}:</td>
-	<td class="setting_value" colspan="2">
-		<select name="search">
-			<option value="public">{TEXT_PUBLIC}</option>
-			<option value="private" {PRIVATE_SEARCH}>{TEXT_PRIVATE}</option>
-			<option value="registered" {REGISTERED_SEARCH}>{TEXT_REGISTERED}</option>
-			<option value="none" {NONE_SEARCH}>{TEXT_NONE}</option>
-		</select>
-	</td>
-</tr>
-<tr>
-	<td class="setting_name">{TEXT_TEMPLATE}:</td>
-	<td class="setting_value" colspan="2">
-		<select name="search_template">
-		<!-- BEGIN search_template_list_block -->
-			<option value="{FILE}"{SELECTED}>{NAME}</option>
-		<!-- END search_template_list_block -->
-		</select>
-	</td>
-</tr>
-<tr class="advanced">
-	<td class="setting_name">{TEXT_HEADER}:</td>
-	<td class="setting_value" colspan="2">
-		<textarea name="search_header" style="height: 100px;">{SEARCH_HEADER}</textarea>
-	</td>
-</tr>
-<tr class="advanced">
-	<td class="setting_name">{TEXT_RESULTS_HEADER}:</td>
-	<td class="setting_value" colspan="2">
-		<textarea name="search_results_header">{SEARCH_RESULTS_HEADER}</textarea>
-	</td>
-</tr>
-<tr class="advanced">
-	<td class="setting_name">{TEXT_RESULTS_LOOP}:</td>
-	<td class="setting_value" colspan="2">
-		<textarea name="search_results_loop">{SEARCH_RESULTS_LOOP}</textarea>
-	</td>
-</tr>
-<tr class="advanced">
-	<td class="setting_name">{TEXT_RESULTS_FOOTER}:</td>
-	<td class="setting_value" colspan="2">
-		<textarea name="search_results_footer">{SEARCH_RESULTS_FOOTER}</textarea>
-	</td>
-</tr>
-<tr class="advanced">
-	<td class="setting_name">{TEXT_NO_RESULTS}:</td>
-	<td class="setting_value" colspan="2">
-		<input type="text" name="search_no_results" value="{SEARCH_NO_RESULTS}" />
-	</td>
-</tr>
-<tr class="advanced">
-	<td class="setting_name">{TEXT_FOOTER}:</td>
-	<td class="setting_value" colspan="2">
-		<textarea name="search_footer">{SEARCH_FOOTER}</textarea>
-	</td>
-</tr>
-<tr>
-	<td>&nbsp;</td>
-	<td>
-		<input type="submit" name="submit" value="{TEXT_SAVE}" class="save" />
-		<input type="reset" name="reset" value="{TEXT_RESET}" class="reset" />
-	</td>
-	<td style="text-align: right;">
-		<button onclick="window.location = '{ADVANCED_LINK}'; return false;" class="{DISPLAY_ADVANCED_BUTTON}">{ADVANCED_BUTTON}</button>
-	</td>
-</tr>
-<tr>
-	<td colspan="3" style="padding-top: 10px;">
-		<h2>{HEADING_SERVER_SETTINGS}</h2>
-	</td>
-</tr>
-<tr>
-	<td class="setting_name">{TEXT_SERVER_OPERATING_SYSTEM}:</td>
-	<td class="setting_value" colspan="2">
-		<input type="radio" name="operating_system" id="operating_system_linux" onclick="javascript: change_os('linux');" style="width: 14px; height: 14px;" value="linux"{LINUX_SELECTED} />
-		<label for="operating_system_linux" onclick="javascript: change_os('linux');">{TEXT_LINUX_UNIX_BASED}</label>
-		<input type="radio" name="operating_system" id="operating_system_windows" onclick="javascript: change_os('windows');"" style="width: 14px; height: 14px;" value="windows"{WINDOWS_SELECTED} />
-		<label for="operating_system_windows" onclick="javascript: change_os('windows');">{TEXT_WINDOWS}</label>
-	</td>
-</tr>
-<tr>
-	<td class="setting_name"><div id="{BASIC_FILE_PERMS_ID}1" style="margin: 0; padding: 0;">&nbsp;</div></td>
-	<td class="setting_value" colspan="3">
-		<div id="{BASIC_FILE_PERMS_ID}2" style="margin: 0; padding: 0;">
-			<input type="checkbox" name="world_writeable" id="world_writeable" style="width: 14px; height: 14px;" value="true"{WORLD_WRITEABLE_SELECTED} />
-			<label for="world_writeable">
-				{TEXT_WORLD_WRITEABLE_FILE_PERMISSIONS} (777)
-			</font>
-			<br />
-			<font class="note">({WORLD_WRITEABLE_WARNING})</font>
-		</div>
-		<div id="{BASIC_FILE_PERMS_ID}3" style="margin: 0; padding: 0;"></div>
-	</td>
-</tr>
-<tr class="advanced">
-	<td class="setting_name"><div id="{ADVANCED_FILE_PERMS_ID}1" style="margin: 0; padding: 0;">{TEXT_FILESYSTEM_PERMISSIONS}:</div></td>
-	<td class="setting_value" id="file_mode" align="left">
-		<table cellpadding="2" cellspacing="0" border="0" width="100%" style="border-right: 1px solid #DDDDDD;" id="{ADVANCED_FILE_PERMS_ID}2">
-		<tr>
-			<td colspan="3" style="text-align: center; font-weight: bold;">
-				{TEXT_FILES}:
-			</td>
-		</tr>
-		<tr>
-			<td>{TEXT_USER}:</td>
-			<td>{TEXT_GROUP}:</td>
-			<td>{TEXT_OTHERS}:</td>
-		</tr>
-		<tr>
-			<td>
-				<input type="checkbox" name="file_u_r" id="file_u_r" value="true"{FILE_U_R_CHECKED} />
-				<label for="file_u_r">{TEXT_READ}</label>
-				<br />
-				<input type="checkbox" name="file_u_w" id="file_u_w" value="true"{FILE_U_W_CHECKED} />
-				<label for="file_u_w">{TEXT_WRITE}</label>
-				<br />
-				<input type="checkbox" name="file_u_e" id="file_u_e" value="true"{FILE_U_E_CHECKED} />
-				<label for="file_u_e">{TEXT_EXECUTE}</label>
-			</td>
-			<td>
-				<input type="checkbox" name="file_g_r" id="file_g_r" value="true"{FILE_G_R_CHECKED} />
-				<label for="file_g_r">{TEXT_READ}</label>
-				<br />
-				<input type="checkbox" name="file_g_w" id="file_g_w" value="true"{FILE_G_W_CHECKED} />
-				<label for="file_g_w">{TEXT_WRITE}</label>
-				<br />
-				<input type="checkbox" name="file_g_e" id="file_g_e" value="true"{FILE_G_E_CHECKED} />
-				<label for="file_g_e">{TEXT_EXECUTE}</label>
-			</td>
-			<td>
-				<input type="checkbox" name="file_o_r" id="file_o_r" value="true"{FILE_O_R_CHECKED} />
-				<label for="file_o_r">{TEXT_READ}</label>
-				<br />
-				<input type="checkbox" name="file_o_w" id="file_o_w" value="true"{FILE_O_W_CHECKED} />
-				<label for="file_o_w">{TEXT_WRITE}</label>
-				<br />
-				<input type="checkbox" name="file_o_e" id="file_o_e" value="true"{FILE_O_E_CHECKED} />
-				<label for="file_o_e">{TEXT_EXECUTE}</label>
-			</td>
-		</tr>
-		</table>
-	</td>
-	<td class="setting_value" id="dir_mode" style="text-align: right;">
-		<table cellpadding="2" cellspacing="0" border="0" width="100%" id="{ADVANCED_FILE_PERMS_ID}3">
-		<tr>
-			<td colspan="3" style="text-align: center; font-weight: bold;">
-				{TEXT_DIRECTORIES}:
-			</td>
-		</tr>
-		<tr>
-			<td>{TEXT_USER}:</td>
-			<td>{TEXT_GROUP}:</td>
-			<td>{TEXT_OTHERS}:</td>
-		</tr>
-		<tr>
-			<td>
-				<input type="checkbox" name="dir_u_r" id="dir_u_r" value="true"{DIR_U_R_CHECKED} />
-				<label for="dir_u_r">{TEXT_READ}</label>
-				<br />
-				<input type="checkbox" name="dir_u_w" id="dir_u_w" value="true"{DIR_U_W_CHECKED} />
-				<label for="dir_u_w">{TEXT_WRITE}</label>
-				<br />
-				<input type="checkbox" name="dir_u_e" id="dir_u_e" value="true"{DIR_U_E_CHECKED} />
-				<label for="dir_u_e">{TEXT_EXECUTE}</label>
-			</td>
-			<td>
-				<input type="checkbox" name="dir_g_r" id="dir_g_r" value="true"{DIR_G_R_CHECKED} />
-				<label for="dir_g_r">{TEXT_READ}</label>
-				<br />
-				<input type="checkbox" name="dir_g_w" id="dir_g_w" value="true"{DIR_G_W_CHECKED} />
-				<label for="dir_g_w">{TEXT_WRITE}</label>
-				<br />
-				<input type="checkbox" name="dir_g_e" id="dir_g_e" value="true"{DIR_G_E_CHECKED} />
-				<label for="dir_g_e">{TEXT_EXECUTE}</label>
-			</td>
-			<td>
-				<input type="checkbox" name="dir_o_r" id="dir_o_r" value="true"{DIR_O_R_CHECKED} />
-				<label for="dir_o_r">{TEXT_READ}</label>
-				<br />
-				<input type="checkbox" name="dir_o_w" id="dir_o_w" value="true"{DIR_O_W_CHECKED} />
-				<label for="dir_o_w">{TEXT_WRITE}</label>
-				<br />
-				<input type="checkbox" name="dir_o_e" id="dir_o_e" value="true"{DIR_O_E_CHECKED} />
-				<label for="dir_o_e">{TEXT_EXECUTE}</label>
-			</td>
-		</tr>
-		</table>
-	</td>
-</tr>
-<tr class="advanced">
-	<td class="setting_name">{TEXT_PAGES_DIRECTORY}:</td>
-	<td class="setting_value" colspan="2">
-		<input type="text" name="pages_directory" value="{PAGES_DIRECTORY}" />
-	</td>
-</tr>
-<tr class="advanced">
-	<td class="setting_name">{TEXT_MEDIA_DIRECTORY}:</td>
-	<td class="setting_value" colspan="2">
-		<input type="text" name="media_directory" value="{MEDIA_DIRECTORY}" />
-	</td>
-</tr>
-<tr class="advanced">
-	<td class="setting_name">{TEXT_PAGE_EXTENSION}:</td>
-	<td class="setting_value" colspan="2">
-		<input type="text" name="page_extension" value="{PAGE_EXTENSION}" />
-	</td>
-</tr>
-<tr class="advanced">
-	<td class="setting_name">{TEXT_PAGE_SPACER}:</td>
-	<td class="setting_value" colspan="2">
-		<input type="text" name="page_spacer" value="{PAGE_SPACER}" />
-	</td>
-</tr>
-<tr class="advanced">
-	<td class="setting_name">{TEXT_RENAME_FILES_ON_UPLOAD}:</td>
-	<td class="setting_value" colspan="2">
-		<input type="text" name="rename_files_on_upload" value="{RENAME_FILES_ON_UPLOAD}" />
-	</td>
-</tr>
-<tr class="advanced">
-	<td class="setting_name">{TEXT_SESSION_IDENTIFIER}:</td>
-	<td class="setting_value" colspan="2">
-		<input type="text" name="app_name" value="{APP_NAME}" />
-	</td>
-</tr>
-<tr class="advanced">
-	<td colspan="3" style="padding-top: 10px;">
-		<a name="administration_tools"></a>
-		<h2>{HEADING_ADMINISTRATION_TOOLS}</h2>
-	</td>
-</tr>
-<tr class="advanced">
-	<td colspan="3">
-		<ul style="margin: 0; padding: 0; margin-left: 20px; margin-bottom: 10px;">
-		<!-- BEGIN tool_list_block -->
-		<li style="padding-bottom: 5px;">
-		<a href="{ADMIN_URL}/settings/tool.php?tool={TOOL_DIR}">{TOOL_NAME}</a>
-		<br />{TOOL_DESCRIPTION}
-		</li>
-		<!-- END tool_list_block -->
-		</ul>
-		{TOOL_LIST}
-	</td>
-	<td>
-		&nbsp;
-	</td>
-	<td>&nbsp;</td>
-</tr>
-<tr>
-	<td>&nbsp;</td>
-	<td>
-		<input type="submit" name="submit" value="{TEXT_SAVE}" class="save" />
-		<input type="reset" name="reset" value="{TEXT_RESET}" class="reset" />
-	</td>
-	<td style="text-align: right;">
-		<button onclick="window.location = '{ADVANCED_LINK}'; return false;" class="{DISPLAY_ADVANCED_BUTTON}">{ADVANCED_BUTTON}</button>
-	</td>
-</tr>
-</table>
-
-</form>
-
-<hr />
-
-<button onclick="window.location = '{ADVANCED_LINK}'; return false;" class="{DISPLAY_ADVANCED_BUTTON}">{ADVANCED_BUTTON}</button>
-
-<font class="{DISPLAY_ADVANCED_BUTTON}">
-&nbsp; {MODE_SWITCH_WARNING}
-</font>
-
-<!-- END main_block -->
+</div><!-- BEGIN main_block -->
+
+<script language="javascript" type="text/javascript">
+function change_os(type) {
+	if(type == 'linux') {
+		document.getElementById('file_perms_box1').style.display = 'block';
+		document.getElementById('file_perms_box2').style.display = 'block';
+		document.getElementById('file_perms_box3').style.display = 'block';
+	} else if(type == 'windows') {
+		document.getElementById('file_perms_box1').style.display = 'none';
+		document.getElementById('file_perms_box2').style.display = 'none';
+		document.getElementById('file_perms_box3').style.display = 'none';
+	}
+}
+</script>
+
+<style>
+.settings_table td {
+	vertical-align: top;
+	text-align: left;
+}
+.setting_name {
+	width: 180px;
+}
+.setting_value input, .setting_value select, .setting_value textarea {
+	width: 100%;
+}
+.setting_value textarea {
+	height: 50px;
+}
+#file_mode input {
+	width: 12px;
+	height: 12px;
+}
+#dir_mode input {
+	width: 12px;
+	height: 12px;
+}
+.advanced {
+	display: {DISPLAY_ADVANCED};
+}
+.save, .reset {
+	width: 100px;
+}
+#hide2 {
+	display: none;
+}
+</style>
+
+<form name="settings" action="save.php" method="post">
+<input type="hidden" name="advanced" value="{ADVANCED}" />
+
+<table cellpadding="3" cellspacing="0" border="0" align="center" width="100%" class="settings_table">
+<tr>
+	<td colspan="3">
+		<h2>{HEADING_GENERAL_SETTINGS}</h2>
+	</td>
+</tr>
+<tr>
+	<td class="setting_name">{TEXT_WEBSITE_TITLE}:</td>
+	<td class="setting_value" colspan="2">
+		<input type="text" name="website_title" value="{WEBSITE_TITLE}" />
+	</td>
+	<script language="javascript" type="text/javascript">
+	document.settings.title.focus();
+	</script>
+</tr>
+<tr>
+	<td class="setting_name">{TEXT_WEBSITE_DESCRIPTION}:</td>
+	<td class="setting_value" colspan="2">
+		<textarea name="website_description">{WEBSITE_DESCRIPTION}</textarea>
+	</td>
+</tr>
+<tr>
+	<td class="setting_name">{TEXT_WEBSITE_KEYWORDS}:</td>
+	<td class="setting_value" colspan="2">
+		<textarea name="website_keywords">{WEBSITE_KEYWORDS}</textarea>
+	</td>
+</tr>
+<tr class="advanced">
+	<td class="setting_name">{TEXT_WEBSITE_HEADER}:</td>
+	<td class="setting_value" colspan="2">
+		<textarea name="website_header">{WEBSITE_HEADER}</textarea>
+	</td>
+</tr>
+<tr>
+	<td class="setting_name">{TEXT_WEBSITE_FOOTER}:</td>
+	<td class="setting_value" colspan="2">
+		<textarea name="website_footer">{WEBSITE_FOOTER}</textarea>
+	</td>
+</tr>
+<tr class="advanced">
+	<td class="setting_name">{TEXT_PAGE_LEVEL_LIMIT}:</td>
+	<td class="setting_value" colspan="2">
+		<select name="page_level_limit">
+		<!-- BEGIN page_level_limit_list_block -->
+			<option value="{NUMBER}"{SELECTED}>{NUMBER}</option>
+		<!-- END page_level_limit_list_block -->
+		</select>
+	</td>
+</tr>
+<tr>
+	<td class="setting_name">{TEXT_PAGE_TRASH}:</td>
+	<td class="setting_value" colspan="2">
+		<input type="radio" name="page_trash" id="page_trash_disabled" style="width: 14px; height: 14px;" value="disabled"{PAGE_TRASH_DISABLED} />
+		<label for="page_trash_disabled">{TEXT_DISABLED}</label>
+		<input type="radio" name="page_trash" id="page_trash_inline" style="width: 14px; height: 14px;" value="inline"{PAGE_TRASH_INLINE} />
+		<label for="page_trash_inline">{TEXT_INLINE}</label>
+		<div style="margin: 0; padding: 0;{DISPLAY_PAGE_TRASH_SEPARATE}">
+			<input type="radio" name="page_trash" id="page_trash_separate" style="width: 14px; height: 14px;" value="separate"{PAGE_TRASH_SEPARATE} />
+			<label for="page_trash_separate">{TEXT_SEPARATE}</label>
+		</div>
+	</td>
+</tr>
+<input type="hidden" name="page_languages" value="{PAGE_LANGUAGES}" />
+<tr class="advanced">
+	<td class="setting_name">{TEXT_MULTIPLE_MENUS}:</td>
+	<td class="setting_value" colspan="2">
+		<input type="radio" name="multiple_menus" id="multiple_menus_true" style="width: 14px; height: 14px;" value="true"{MULTIPLE_MENUS_ENABLED} />
+		<label for="multiple_menus_true">{TEXT_ENABLED}</label>
+		<input type="radio" name="multiple_menus" id="multiple_menus_false" style="width: 14px; height: 14px;" value="false"{MULTIPLE_MENUS_DISABLED} />
+		<label for="multiple_menus_false">{TEXT_DISABLED}</label>
+	</td>
+</tr>
+<tr>
+	<td class="setting_name">{TEXT_HOME_FOLDERS}:</td>
+	<td class="setting_value" colspan="2">
+		<input type="radio" name="home_folders" id="home_folders_true" style="width: 14px; height: 14px;" value="true"{HOME_FOLDERS_ENABLED} />
+		<label for="home_folders_true">{TEXT_ENABLED}</label>
+		<input type="radio" name="home_folders" id="home_folders_false" style="width: 14px; height: 14px;" value="false"{HOME_FOLDERS_DISABLED} />
+		<label for="home_folders_false">{TEXT_DISABLED}</label>
+	</td>
+</tr>
+<tr class="advanced">
+	<td class="setting_name">{TEXT_MANAGE_SECTIONS}:</td>
+	<td class="setting_value" colspan="2">
+		<input type="radio" name="manage_sections" id="manage_sections_true" style="width: 14px; height: 14px;" value="true"{MANAGE_SECTIONS_ENABLED} />
+		<label for="manage_sections_true">{TEXT_ENABLED}</label>
+		<input type="radio" name="manage_sections" id="manage_sections_false" style="width: 14px; height: 14px;" value="false"{MANAGE_SECTIONS_DISABLED} />
+		<label for="manage_sections_false">{TEXT_DISABLED}</label>
+	</td>
+</tr>
+<tr class="advanced">
+	<td class="setting_name">{TEXT_SECTION_BLOCKS}:</td>
+	<td class="setting_value" colspan="2">
+		<input type="radio" name="section_blocks" id="section_blocks_true" style="width: 14px; height: 14px;" value="true"{SECTION_BLOCKS_ENABLED} />
+		<label for="section_blocks_true">{TEXT_ENABLED}</label>
+		<input type="radio" name="section_blocks" id="section_blocks_false" style="width: 14px; height: 14px;" value="false"{SECTION_BLOCKS_DISABLED} />
+		<label for="section_blocks_false">{TEXT_DISABLED}</label>
+	</td>
+</tr>
+<tr>
+	<td class="setting_name">{TEXT_INTRO_PAGE}:</td>
+	<td class="setting_value" colspan="2">
+		<input type="radio" name="intro_page" id="intro_page_true" style="width: 14px; height: 14px;" value="true"{INTRO_PAGE_ENABLED} />
+		<label for="intro_page_true">{TEXT_ENABLED}</label>
+		<input type="radio" name="intro_page" id="intro_page_false" style="width: 14px; height: 14px;" value="false"{INTRO_PAGE_DISABLED} />
+		<label for="intro_page_false">{TEXT_DISABLED}</label>
+	</td>
+</tr>
+<tr class="advanced">
+	<td class="setting_name">{TEXT_HOMEPAGE_REDIRECTION}:</td>
+	<td class="setting_value" colspan="2">
+		<input type="radio" name="homepage_redirection" id="homepage_redirection_true" style="width: 14px; height: 14px;" value="true"{HOMEPAGE_REDIRECTION_ENABLED} />
+		<label for="homepage_redirection_true">{TEXT_ENABLED}</label>
+		<input type="radio" name="homepage_redirection" id="homepage_redirection_false" style="width: 14px; height: 14px;" value="false"{HOMEPAGE_REDIRECTION_DISABLED} />
+		<label for="homepage_redirection_false">{TEXT_DISABLED}</font>
+	</td>
+</tr>
+<tr class="advanced">
+	<td class="setting_name">{TEXT_SMART_LOGIN}:</td>
+	<td class="setting_value" colspan="2">
+		<input type="radio" name="smart_login" id="smart_login_true" style="width: 14px; height: 14px;" value="true"{SMART_LOGIN_ENABLED} />
+		<label for="smart_login_true">{TEXT_ENABLED}</label>
+		<input type="radio" name="smart_login" id="smart_login_false" style="width: 14px; height: 14px;" value="false"{SMART_LOGIN_DISABLED} />
+		<label for="smart_login_false">{TEXT_DISABLED}</label>
+	</td>
+</tr>
+<tr>
+	<td class="setting_name">{TEXT_LOGIN}:</td>
+	<td class="setting_value" colspan="2">
+		<input type="radio" name="frontend_login" id="frontend_login_true" style="width: 14px; height: 14px;" value="true"{PRIVATE_ENABLED} />
+		<label for="frontend_login_true">{TEXT_ENABLED}</label>
+		<input type="radio" name="frontend_login" id="frontend_login_false" style="width: 14px; height: 14px;" value="false"{PRIVATE_DISABLED} />
+		<label for="frontend_login_false">{TEXT_DISABLED}</label>
+	</td>
+</tr>
+<tr>
+	<td class="setting_name">{TEXT_SIGNUP}:</td>
+	<td class="setting_value" colspan="2">
+		<select name="frontend_signup">
+			<option value="false">{TEXT_DISABLED}</option>
+			<!-- BEGIN group_list_block -->
+				<option value="{ID}" {SELECTED}>{NAME}</option>
+			<!-- END group_list_block -->
+		</select>
+	</td>
+</tr>
+<tr class="advanced">
+	<td class="setting_name">{TEXT_PHP_ERROR_LEVEL}:</td>
+	<td class="setting_value" colspan="2">
+		<select name="er_level">
+			<option value="">{TEXT_PLEASE_SELECT}...</option>
+			<!-- BEGIN error_reporting_list_block -->
+				<option value="{VALUE}"{SELECTED}>{NAME}</option>
+			<!-- END error_reporting_list_block -->
+		</select>
+	</td>
+</tr>
+<tr class="advancedfont">
+	<td class="setting_name">{TEXT_WYSIWYG_STYLE}:</td>
+	<td class="setting_value" colspan="2">
+		<input type="text" name="wysiwyg_style" value="{WYSIWYG_STYLE}" />
+	</td>
+</tr>
+<tr class="advanced">
+	<td class="setting_name">{TEXT_SERVER_EMAIL}:</td>
+	<td class="setting_value" colspan="2">
+		<input type="text" name="server_email" value="{SERVER_EMAIL}" />
+	</td>
+</tr>
+<tr class="advanced">
+	<td class="setting_name">{TEXT_WYSIWYG_EDITOR}:</td>
+	<td class="setting_value" colspan="2">
+		<select name="wysiwyg_editor">
+		<!-- BEGIN editor_list_block -->
+			<option value="{FILE}"{SELECTED}>{NAME}</option>
+		<!-- END editor_list_block -->
+		</select>
+	</td>
+</tr>
+<tr>
+	<td>&nbsp;</td>
+	<td>
+		<input type="submit" name="submit" value="{TEXT_SAVE}" class="save" />
+		<input type="reset" name="reset" value="{TEXT_RESET}" class="reset" />
+	</td>
+	<td style="text-align: right;">
+		<button onclick="window.location = '{ADVANCED_LINK}'; return false;" class="{DISPLAY_ADVANCED_BUTTON}">{ADVANCED_BUTTON}</button>
+	</td>
+</tr>
+<tr>
+	<td colspan="3" style="padding-top: 10px;">
+		<h2>{HEADING_DEFAULT_SETTINGS}</h2>
+	</td>
+</tr>
+<tr>
+	<td class="setting_name">{TEXT_LANGUAGE}:</td>
+	<td class="setting_value" colspan="2">
+		<select name="default_language">
+			<!-- BEGIN language_list_block -->
+			<option value="{CODE}"{SELECTED}>{NAME} ({CODE})</option>
+			<!-- END language_list_block -->
+		</select>
+	</td>
+</tr>
+<tr>
+	<td class="setting_name">{TEXT_TIMEZONE}:</td>
+	<td class="setting_value" colspan="2">
+		<select name="default_timezone">
+			<option value="0">{TEXT_PLEASE_SELECT}...</option>
+			<!-- BEGIN timezone_list_block -->
+				<option value="{VALUE}" {SELECTED}>{NAME}</option>
+			<!-- END timezone_list_block -->
+		</select>
+	</td>
+</tr>
+<tr>
+	<td class="setting_name">{TEXT_DATE_FORMAT}:</td>
+	<td class="setting_value" colspan="2">
+		<select name="default_date_format">
+			<option value="M d Y">{TEXT_PLEASE_SELECT}...</option>
+			<!-- BEGIN date_format_list_block -->
+				<option value="{VALUE}" {SELECTED}>{NAME}</option>
+			<!-- END date_format_list_block -->
+		</select>
+	</td>
+</tr>
+<tr>
+	<td class="setting_name">{TEXT_TIME_FORMAT}:</td>
+	<td class="setting_value" colspan="2">
+		<select name="default_time_format">
+			<option value="g:i A">{TEXT_PLEASE_SELECT}...</option>
+			<!-- BEGIN time_format_list_block -->
+				<option value="{VALUE}" {SELECTED}>{NAME}</option>
+			<!-- END time_format_list_block -->
+		</select>
+	</td>
+</tr>
+<tr>
+	<td class="setting_name">{TEXT_TEMPLATE}:</td>
+	<td class="setting_value" colspan="2">
+		<select name="default_template">
+		<!-- BEGIN template_list_block -->
+			<option value="{FILE}"{SELECTED}>{NAME}</option>
+		<!-- END template_list_block -->
+		</select>
+	</td>
+</tr>
+<tr>
+	<td>&nbsp;</td>
+	<td>
+		<input type="submit" name="submit" value="{TEXT_SAVE}" class="save" />
+		<input type="reset" name="reset" value="{TEXT_RESET}" class="reset" />
+	</td>
+	<td style="text-align: right;">
+		<button onclick="window.location = '{ADVANCED_LINK}'; return false;" class="{DISPLAY_ADVANCED_BUTTON}">{ADVANCED_BUTTON}</button>
+	</td>
+</tr>
+<tr>
+	<td colspan="3" style="padding-top: 10px;">
+		<h2>{HEADING_SEARCH_SETTINGS}</h2>
+	</td>
+</tr>
+<tr>
+	<td class="setting_name">{TEXT_VISIBILITY}:</td>
+	<td class="setting_value" colspan="2">
+		<select name="search">
+			<option value="public">{TEXT_PUBLIC}</option>
+			<option value="private" {PRIVATE_SEARCH}>{TEXT_PRIVATE}</option>
+			<option value="registered" {REGISTERED_SEARCH}>{TEXT_REGISTERED}</option>
+			<option value="none" {NONE_SEARCH}>{TEXT_NONE}</option>
+		</select>
+	</td>
+</tr>
+<tr>
+	<td class="setting_name">{TEXT_TEMPLATE}:</td>
+	<td class="setting_value" colspan="2">
+		<select name="search_template">
+		<!-- BEGIN search_template_list_block -->
+			<option value="{FILE}"{SELECTED}>{NAME}</option>
+		<!-- END search_template_list_block -->
+		</select>
+	</td>
+</tr>
+<tr class="advanced">
+	<td class="setting_name">{TEXT_HEADER}:</td>
+	<td class="setting_value" colspan="2">
+		<textarea name="search_header" style="height: 100px;">{SEARCH_HEADER}</textarea>
+	</td>
+</tr>
+<tr class="advanced">
+	<td class="setting_name">{TEXT_RESULTS_HEADER}:</td>
+	<td class="setting_value" colspan="2">
+		<textarea name="search_results_header">{SEARCH_RESULTS_HEADER}</textarea>
+	</td>
+</tr>
+<tr class="advanced">
+	<td class="setting_name">{TEXT_RESULTS_LOOP}:</td>
+	<td class="setting_value" colspan="2">
+		<textarea name="search_results_loop">{SEARCH_RESULTS_LOOP}</textarea>
+	</td>
+</tr>
+<tr class="advanced">
+	<td class="setting_name">{TEXT_RESULTS_FOOTER}:</td>
+	<td class="setting_value" colspan="2">
+		<textarea name="search_results_footer">{SEARCH_RESULTS_FOOTER}</textarea>
+	</td>
+</tr>
+<tr class="advanced">
+	<td class="setting_name">{TEXT_NO_RESULTS}:</td>
+	<td class="setting_value" colspan="2">
+		<input type="text" name="search_no_results" value="{SEARCH_NO_RESULTS}" />
+	</td>
+</tr>
+<tr class="advanced">
+	<td class="setting_name">{TEXT_FOOTER}:</td>
+	<td class="setting_value" colspan="2">
+		<textarea name="search_footer">{SEARCH_FOOTER}</textarea>
+	</td>
+</tr>
+<tr>
+	<td>&nbsp;</td>
+	<td>
+		<input type="submit" name="submit" value="{TEXT_SAVE}" class="save" />
+		<input type="reset" name="reset" value="{TEXT_RESET}" class="reset" />
+	</td>
+	<td style="text-align: right;">
+		<button onclick="window.location = '{ADVANCED_LINK}'; return false;" class="{DISPLAY_ADVANCED_BUTTON}">{ADVANCED_BUTTON}</button>
+	</td>
+</tr>
+<tr>
+	<td colspan="3" style="padding-top: 10px;">
+		<h2>{HEADING_SERVER_SETTINGS}</h2>
+	</td>
+</tr>
+<tr>
+	<td class="setting_name">{TEXT_SERVER_OPERATING_SYSTEM}:</td>
+	<td class="setting_value" colspan="2">
+		<input type="radio" name="operating_system" id="operating_system_linux" onclick="javascript: change_os('linux');" style="width: 14px; height: 14px;" value="linux"{LINUX_SELECTED} />
+		<label for="operating_system_linux" onclick="javascript: change_os('linux');">{TEXT_LINUX_UNIX_BASED}</label>
+		<input type="radio" name="operating_system" id="operating_system_windows" onclick="javascript: change_os('windows');"" style="width: 14px; height: 14px;" value="windows"{WINDOWS_SELECTED} />
+		<label for="operating_system_windows" onclick="javascript: change_os('windows');">{TEXT_WINDOWS}</label>
+	</td>
+</tr>
+<tr>
+	<td class="setting_name"><div id="{BASIC_FILE_PERMS_ID}1" style="margin: 0; padding: 0;">&nbsp;</div></td>
+	<td class="setting_value" colspan="3">
+		<div id="{BASIC_FILE_PERMS_ID}2" style="margin: 0; padding: 0;">
+			<input type="checkbox" name="world_writeable" id="world_writeable" style="width: 14px; height: 14px;" value="true"{WORLD_WRITEABLE_SELECTED} />
+			<label for="world_writeable">
+				{TEXT_WORLD_WRITEABLE_FILE_PERMISSIONS} (777)
+			</font>
+			<br />
+			<font class="note">({WORLD_WRITEABLE_WARNING})</font>
+		</div>
+		<div id="{BASIC_FILE_PERMS_ID}3" style="margin: 0; padding: 0;"></div>
+	</td>
+</tr>
+<tr class="advanced">
+	<td class="setting_name"><div id="{ADVANCED_FILE_PERMS_ID}1" style="margin: 0; padding: 0;">{TEXT_FILESYSTEM_PERMISSIONS}:</div></td>
+	<td class="setting_value" id="file_mode" align="left">
+		<table cellpadding="2" cellspacing="0" border="0" width="100%" style="border-right: 1px solid #DDDDDD;" id="{ADVANCED_FILE_PERMS_ID}2">
+		<tr>
+			<td colspan="3" style="text-align: center; font-weight: bold;">
+				{TEXT_FILES}:
+			</td>
+		</tr>
+		<tr>
+			<td>{TEXT_USER}:</td>
+			<td>{TEXT_GROUP}:</td>
+			<td>{TEXT_OTHERS}:</td>
+		</tr>
+		<tr>
+			<td>
+				<input type="checkbox" name="file_u_r" id="file_u_r" value="true"{FILE_U_R_CHECKED} />
+				<label for="file_u_r">{TEXT_READ}</label>
+				<br />
+				<input type="checkbox" name="file_u_w" id="file_u_w" value="true"{FILE_U_W_CHECKED} />
+				<label for="file_u_w">{TEXT_WRITE}</label>
+				<br />
+				<input type="checkbox" name="file_u_e" id="file_u_e" value="true"{FILE_U_E_CHECKED} />
+				<label for="file_u_e">{TEXT_EXECUTE}</label>
+			</td>
+			<td>
+				<input type="checkbox" name="file_g_r" id="file_g_r" value="true"{FILE_G_R_CHECKED} />
+				<label for="file_g_r">{TEXT_READ}</label>
+				<br />
+				<input type="checkbox" name="file_g_w" id="file_g_w" value="true"{FILE_G_W_CHECKED} />
+				<label for="file_g_w">{TEXT_WRITE}</label>
+				<br />
+				<input type="checkbox" name="file_g_e" id="file_g_e" value="true"{FILE_G_E_CHECKED} />
+				<label for="file_g_e">{TEXT_EXECUTE}</label>
+			</td>
+			<td>
+				<input type="checkbox" name="file_o_r" id="file_o_r" value="true"{FILE_O_R_CHECKED} />
+				<label for="file_o_r">{TEXT_READ}</label>
+				<br />
+				<input type="checkbox" name="file_o_w" id="file_o_w" value="true"{FILE_O_W_CHECKED} />
+				<label for="file_o_w">{TEXT_WRITE}</label>
+				<br />
+				<input type="checkbox" name="file_o_e" id="file_o_e" value="true"{FILE_O_E_CHECKED} />
+				<label for="file_o_e">{TEXT_EXECUTE}</label>
+			</td>
+		</tr>
+		</table>
+	</td>
+	<td class="setting_value" id="dir_mode" style="text-align: right;">
+		<table cellpadding="2" cellspacing="0" border="0" width="100%" id="{ADVANCED_FILE_PERMS_ID}3">
+		<tr>
+			<td colspan="3" style="text-align: center; font-weight: bold;">
+				{TEXT_DIRECTORIES}:
+			</td>
+		</tr>
+		<tr>
+			<td>{TEXT_USER}:</td>
+			<td>{TEXT_GROUP}:</td>
+			<td>{TEXT_OTHERS}:</td>
+		</tr>
+		<tr>
+			<td>
+				<input type="checkbox" name="dir_u_r" id="dir_u_r" value="true"{DIR_U_R_CHECKED} />
+				<label for="dir_u_r">{TEXT_READ}</label>
+				<br />
+				<input type="checkbox" name="dir_u_w" id="dir_u_w" value="true"{DIR_U_W_CHECKED} />
+				<label for="dir_u_w">{TEXT_WRITE}</label>
+				<br />
+				<input type="checkbox" name="dir_u_e" id="dir_u_e" value="true"{DIR_U_E_CHECKED} />
+				<label for="dir_u_e">{TEXT_EXECUTE}</label>
+			</td>
+			<td>
+				<input type="checkbox" name="dir_g_r" id="dir_g_r" value="true"{DIR_G_R_CHECKED} />
+				<label for="dir_g_r">{TEXT_READ}</label>
+				<br />
+				<input type="checkbox" name="dir_g_w" id="dir_g_w" value="true"{DIR_G_W_CHECKED} />
+				<label for="dir_g_w">{TEXT_WRITE}</label>
+				<br />
+				<input type="checkbox" name="dir_g_e" id="dir_g_e" value="true"{DIR_G_E_CHECKED} />
+				<label for="dir_g_e">{TEXT_EXECUTE}</label>
+			</td>
+			<td>
+				<input type="checkbox" name="dir_o_r" id="dir_o_r" value="true"{DIR_O_R_CHECKED} />
+				<label for="dir_o_r">{TEXT_READ}</label>
+				<br />
+				<input type="checkbox" name="dir_o_w" id="dir_o_w" value="true"{DIR_O_W_CHECKED} />
+				<label for="dir_o_w">{TEXT_WRITE}</label>
+				<br />
+				<input type="checkbox" name="dir_o_e" id="dir_o_e" value="true"{DIR_O_E_CHECKED} />
+				<label for="dir_o_e">{TEXT_EXECUTE}</label>
+			</td>
+		</tr>
+		</table>
+	</td>
+</tr>
+<tr class="advanced">
+	<td class="setting_name">{TEXT_PAGES_DIRECTORY}:</td>
+	<td class="setting_value" colspan="2">
+		<input type="text" name="pages_directory" value="{PAGES_DIRECTORY}" />
+	</td>
+</tr>
+<tr class="advanced">
+	<td class="setting_name">{TEXT_MEDIA_DIRECTORY}:</td>
+	<td class="setting_value" colspan="2">
+		<input type="text" name="media_directory" value="{MEDIA_DIRECTORY}" />
+	</td>
+</tr>
+<tr class="advanced">
+	<td class="setting_name">{TEXT_PAGE_EXTENSION}:</td>
+	<td class="setting_value" colspan="2">
+		<input type="text" name="page_extension" value="{PAGE_EXTENSION}" />
+	</td>
+</tr>
+<tr class="advanced">
+	<td class="setting_name">{TEXT_PAGE_SPACER}:</td>
+	<td class="setting_value" colspan="2">
+		<input type="text" name="page_spacer" value="{PAGE_SPACER}" />
+	</td>
+</tr>
+<tr class="advanced">
+	<td class="setting_name">{TEXT_RENAME_FILES_ON_UPLOAD}:</td>
+	<td class="setting_value" colspan="2">
+		<input type="text" name="rename_files_on_upload" value="{RENAME_FILES_ON_UPLOAD}" />
+	</td>
+</tr>
+<tr class="advanced">
+	<td class="setting_name">{TEXT_SESSION_IDENTIFIER}:</td>
+	<td class="setting_value" colspan="2">
+		<input type="text" name="app_name" value="{APP_NAME}" />
+	</td>
+</tr>
+<tr class="advanced">
+	<td colspan="3" style="padding-top: 10px;">
+		<a name="administration_tools"></a>
+		<h2>{HEADING_ADMINISTRATION_TOOLS}</h2>
+	</td>
+</tr>
+<tr class="advanced">
+	<td colspan="3">
+		<ul style="margin: 0; padding: 0; margin-left: 20px; margin-bottom: 10px;">
+		<!-- BEGIN tool_list_block -->
+		<li style="padding-bottom: 5px;">
+		<a href="{ADMIN_URL}/settings/tool.php?tool={TOOL_DIR}">{TOOL_NAME}</a>
+		<br />{TOOL_DESCRIPTION}
+		</li>
+		<!-- END tool_list_block -->
+		</ul>
+		{TOOL_LIST}
+	</td>
+	<td>
+		&nbsp;
+	</td>
+	<td>&nbsp;</td>
+</tr>
+<tr>
+	<td>&nbsp;</td>
+	<td>
+		<input type="submit" name="submit" value="{TEXT_SAVE}" class="save" />
+		<input type="reset" name="reset" value="{TEXT_RESET}" class="reset" />
+	</td>
+	<td style="text-align: right;">
+		<button onclick="window.location = '{ADVANCED_LINK}'; return false;" class="{DISPLAY_ADVANCED_BUTTON}">{ADVANCED_BUTTON}</button>
+	</td>
+</tr>
+</table>
+
+</form>
+
+<hr />
+
+<button onclick="window.location = '{ADVANCED_LINK}'; return false;" class="{DISPLAY_ADVANCED_BUTTON}">{ADVANCED_BUTTON}</button>
+
+<font class="{DISPLAY_ADVANCED_BUTTON}">
+&nbsp; {MODE_SWITCH_WARNING}
+</font>
+
+<!-- END main_block -->
Index: trunk/wb/admin/preferences/index.php
===================================================================
--- trunk/wb/admin/preferences/index.php	(revision 237)
+++ trunk/wb/admin/preferences/index.php	(revision 238)
@@ -1,152 +1,152 @@
-<?php
-
-/*
-
- Website Baker Project <http://www.websitebaker.org/>
- Copyright (C) 2004-2005, 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('../../config.php');
-require_once(WB_PATH.'/framework/class.admin.php');
-$admin = new admin('Preferences');
-
-// Create new template object for the preferences form
-$template = new Template(ADMIN_PATH.'/preferences');
-$template->set_file('page', 'template.html');
-$template->set_block('page', 'main_block', 'main');
-
-// Get existing value from database
-$database = new database();
-$query = "SELECT display_name,email FROM ".TABLE_PREFIX."users WHERE user_id = '".$admin->get_user_id()."'";
-$results = $database->query($query);
-if($database->is_error()) {
-	$admin->print_error($database->get_error(), 'index.php');
-}
-$details = $results->fetchRow();
-
-// Insert values into form
-$template->set_var('DISPLAY_NAME', $details['display_name']);
-$template->set_var('EMAIL', $details['email']);
-
-// Insert language values
-$template->set_block('main_block', 'language_list_block', 'language_list');
-$result = $database->query("SELECT * FROM ".TABLE_PREFIX."addons WHERE type = 'language'");
-if($result->numRows() > 0) {
-	while($addon = $result->fetchRow()) {
-		// Insert code and name
-		$template->set_var(array(
-								'CODE' => $addon['directory'],
-								'NAME' => $addon['name']
-								));
-		// Check if it is selected
-		if(LANGUAGE == $addon['directory']) {
-			$template->set_var('SELECTED', ' selected');
-		} else {
-			$template->set_var('SELECTED', '');
-		}
-		$template->parse('language_list', 'language_list_block', true);
-	}
-}
-
-// Insert default timezone values
-require(ADMIN_PATH.'/interface/timezones.php');
-$template->set_block('main_block', 'timezone_list_block', 'timezone_list');
-foreach($TIMEZONES AS $hour_offset => $title) {
-	$template->set_var('VALUE', $hour_offset);
-	$template->set_var('NAME', $title);
-	if($admin->get_timezone() == $hour_offset*60*60) {
-		$template->set_var('SELECTED', 'selected');
-	} else {
-		$template->set_var('SELECTED', '');
-	}
-	$template->parse('timezone_list', 'timezone_list_block', true);
-}
-
-// Insert date format list
-$user_time = true;
-require(ADMIN_PATH.'/interface/date_formats.php');
-$template->set_block('main_block', 'date_format_list_block', 'date_format_list');
-foreach($DATE_FORMATS AS $format => $title) {
-	$format = str_replace('|', ' ', $format); // Add's white-spaces (not able to be stored in array key)
-	if($format != 'system_default') {
-		$template->set_var('VALUE', $format);
-	} else {
-		$template->set_var('VALUE', '');
-	}
-	$template->set_var('NAME', $title);
-	if(DATE_FORMAT == $format AND !isset($_SESSION['USE_DEFAULT_DATE_FORMAT'])) {
-		$template->set_var('SELECTED', 'selected');
-	} elseif($format == 'system_default' AND isset($_SESSION['USE_DEFAULT_DATE_FORMAT'])) {
-		$template->set_var('SELECTED', 'selected');
-	} else {
-		$template->set_var('SELECTED', '');
-	}
-	$template->parse('date_format_list', 'date_format_list_block', true);
-}
-
-// Insert time format list
-require(ADMIN_PATH.'/interface/time_formats.php');
-$template->set_block('main_block', 'time_format_list_block', 'time_format_list');
-foreach($TIME_FORMATS AS $format => $title) {
-	$format = str_replace('|', ' ', $format); // Add's white-spaces (not able to be stored in array key)
-	if($format != 'system_default') {
-		$template->set_var('VALUE', $format);
-	} else {
-		$template->set_var('VALUE', '');
-	}
-	$template->set_var('NAME', $title);
-	if(TIME_FORMAT == $format AND !isset($_SESSION['USE_DEFAULT_TIME_FORMAT'])) {
-		$template->set_var('SELECTED', 'selected');
-	} elseif($format == 'system_default' AND isset($_SESSION['USE_DEFAULT_TIME_FORMAT'])) {
-		$template->set_var('SELECTED', 'selected');
-	} else {
-		$template->set_var('SELECTED', '');
-	}
-	$template->parse('time_format_list', 'time_format_list_block', true);
-}
-
-// Insert language headings
-$template->set_var(array(
-								'HEADING_MY_SETTINGS' => $HEADING['MY_SETTINGS'],
-								'HEADING_MY_EMAIL' => $HEADING['MY_EMAIL'],
-								'HEADING_MY_PASSWORD' => $HEADING['MY_PASSWORD']
-								)
-						);
-// Insert language text and messages
-$template->set_var(array(
-								'TEXT_SAVE' => $TEXT['SAVE'],
-								'TEXT_RESET' => $TEXT['RESET'],
-								'TEXT_DISPLAY_NAME' => $TEXT['DISPLAY_NAME'],
-								'TEXT_EMAIL' => $TEXT['EMAIL'],
-								'TEXT_LANGUAGE' => $TEXT['LANGUAGE'],
-								'TEXT_TIMEZONE' => $TEXT['TIMEZONE'],
-								'TEXT_DATE_FORMAT' => $TEXT['DATE_FORMAT'],
-								'TEXT_TIME_FORMAT' => $TEXT['TIME_FORMAT'],
-								'TEXT_CURRENT_PASSWORD' => $TEXT['CURRENT_PASSWORD'],
-								'TEXT_NEW_PASSWORD' => $TEXT['NEW_PASSWORD'],
-								'TEXT_RETYPE_NEW_PASSWORD' => $TEXT['RETYPE_NEW_PASSWORD']
-								)
-						);
-
-// Parse template for preferences form
-$template->parse('main', 'main_block', false);
-$template->pparse('output', 'page');
-
-$admin->print_footer();
-
-?>
+<?php
+
+/*
+
+ Website Baker Project <http://www.websitebaker.org/>
+ Copyright (C) 2004-2005, 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('../../config.php');
+require_once(WB_PATH.'/framework/class.admin.php');
+$admin = new admin('Preferences');
+
+// Create new template object for the preferences form
+$template = new Template(ADMIN_PATH.'/preferences');
+$template->set_file('page', 'template.html');
+$template->set_block('page', 'main_block', 'main');
+
+// Get existing value from database
+$database = new database();
+$query = "SELECT display_name,email FROM ".TABLE_PREFIX."users WHERE user_id = '".$admin->get_user_id()."'";
+$results = $database->query($query);
+if($database->is_error()) {
+	$admin->print_error($database->get_error(), 'index.php');
+}
+$details = $results->fetchRow();
+
+// Insert values into form
+$template->set_var('DISPLAY_NAME', $details['display_name']);
+$template->set_var('EMAIL', $details['email']);
+
+// Insert language values
+$template->set_block('main_block', 'language_list_block', 'language_list');
+$result = $database->query("SELECT * FROM ".TABLE_PREFIX."addons WHERE type = 'language'");
+if($result->numRows() > 0) {
+	while($addon = $result->fetchRow()) {
+		// Insert code and name
+		$template->set_var(array(
+								'CODE' => $addon['directory'],
+								'NAME' => $addon['name']
+								));
+		// Check if it is selected
+		if(LANGUAGE == $addon['directory']) {
+			$template->set_var('SELECTED', ' selected');
+		} else {
+			$template->set_var('SELECTED', '');
+		}
+		$template->parse('language_list', 'language_list_block', true);
+	}
+}
+
+// Insert default timezone values
+require(ADMIN_PATH.'/interface/timezones.php');
+$template->set_block('main_block', 'timezone_list_block', 'timezone_list');
+foreach($TIMEZONES AS $hour_offset => $title) {
+	$template->set_var('VALUE', $hour_offset);
+	$template->set_var('NAME', $title);
+	if($admin->get_timezone() == $hour_offset*60*60) {
+		$template->set_var('SELECTED', 'selected');
+	} else {
+		$template->set_var('SELECTED', '');
+	}
+	$template->parse('timezone_list', 'timezone_list_block', true);
+}
+
+// Insert date format list
+$user_time = true;
+require(ADMIN_PATH.'/interface/date_formats.php');
+$template->set_block('main_block', 'date_format_list_block', 'date_format_list');
+foreach($DATE_FORMATS AS $format => $title) {
+	$format = str_replace('|', ' ', $format); // Add's white-spaces (not able to be stored in array key)
+	if($format != 'system_default') {
+		$template->set_var('VALUE', $format);
+	} else {
+		$template->set_var('VALUE', '');
+	}
+	$template->set_var('NAME', $title);
+	if(DATE_FORMAT == $format AND !isset($_SESSION['USE_DEFAULT_DATE_FORMAT'])) {
+		$template->set_var('SELECTED', 'selected');
+	} elseif($format == 'system_default' AND isset($_SESSION['USE_DEFAULT_DATE_FORMAT'])) {
+		$template->set_var('SELECTED', 'selected');
+	} else {
+		$template->set_var('SELECTED', '');
+	}
+	$template->parse('date_format_list', 'date_format_list_block', true);
+}
+
+// Insert time format list
+require(ADMIN_PATH.'/interface/time_formats.php');
+$template->set_block('main_block', 'time_format_list_block', 'time_format_list');
+foreach($TIME_FORMATS AS $format => $title) {
+	$format = str_replace('|', ' ', $format); // Add's white-spaces (not able to be stored in array key)
+	if($format != 'system_default') {
+		$template->set_var('VALUE', $format);
+	} else {
+		$template->set_var('VALUE', '');
+	}
+	$template->set_var('NAME', $title);
+	if(TIME_FORMAT == $format AND !isset($_SESSION['USE_DEFAULT_TIME_FORMAT'])) {
+		$template->set_var('SELECTED', 'selected');
+	} elseif($format == 'system_default' AND isset($_SESSION['USE_DEFAULT_TIME_FORMAT'])) {
+		$template->set_var('SELECTED', 'selected');
+	} else {
+		$template->set_var('SELECTED', '');
+	}
+	$template->parse('time_format_list', 'time_format_list_block', true);
+}
+
+// Insert language headings
+$template->set_var(array(
+								'HEADING_MY_SETTINGS' => $HEADING['MY_SETTINGS'],
+								'HEADING_MY_EMAIL' => $HEADING['MY_EMAIL'],
+								'HEADING_MY_PASSWORD' => $HEADING['MY_PASSWORD']
+								)
+						);
+// Insert language text and messages
+$template->set_var(array(
+								'TEXT_SAVE' => $TEXT['SAVE'],
+								'TEXT_RESET' => $TEXT['RESET'],
+								'TEXT_DISPLAY_NAME' => $TEXT['DISPLAY_NAME'],
+								'TEXT_EMAIL' => $TEXT['EMAIL'],
+								'TEXT_LANGUAGE' => $TEXT['LANGUAGE'],
+								'TEXT_TIMEZONE' => $TEXT['TIMEZONE'],
+								'TEXT_DATE_FORMAT' => $TEXT['DATE_FORMAT'],
+								'TEXT_TIME_FORMAT' => $TEXT['TIME_FORMAT'],
+								'TEXT_CURRENT_PASSWORD' => $TEXT['CURRENT_PASSWORD'],
+								'TEXT_NEW_PASSWORD' => $TEXT['NEW_PASSWORD'],
+								'TEXT_RETYPE_NEW_PASSWORD' => $TEXT['RETYPE_NEW_PASSWORD']
+								)
+						);
+
+// Parse template for preferences form
+$template->parse('main', 'main_block', false);
+$template->pparse('output', 'page');
+
+$admin->print_footer();
+
+?>
Index: trunk/wb/admin/languages/index.php
===================================================================
--- trunk/wb/admin/languages/index.php	(revision 237)
+++ trunk/wb/admin/languages/index.php	(revision 238)
@@ -1,81 +1,81 @@
-<?php
-
-// $Id$
-
-/*
-
- Website Baker Project <http://www.websitebaker.org/>
- Copyright (C) 2004-2005, 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
-
-*/
-
-// Print admin header
-require('../../config.php');
-require_once(WB_PATH.'/framework/class.admin.php');
-$admin = new admin('Addons', 'languages');
-
-// Setup template object
-$template = new Template(ADMIN_PATH.'/languages');
-$template->set_file('page', 'template.html');
-$template->set_block('page', 'main_block', 'main');
-
-// Insert values into language list
-$template->set_block('main_block', 'language_list_block', 'language_list');
-$result = $database->query("SELECT * FROM ".TABLE_PREFIX."addons WHERE type = 'language'");
-if($result->numRows() > 0) {
-	while($addon = $result->fetchRow()) {
-		$template->set_var('VALUE', $addon['directory']);
-		$template->set_var('NAME', $addon['name'].' ('.$addon['directory'].')');
-		$template->parse('language_list', 'language_list_block', true);
-	}
-}
-
-// Insert permissions values
-if($admin->get_permission('languages_install') != true) {
-	$template->set_var('DISPLAY_INSTALL', 'hide');
-}
-if($admin->get_permission('languages_uninstall') != true) {
-	$template->set_var('DISPLAY_UNINSTALL', 'hide');
-}
-if($admin->get_permission('languages_view') != true) {
-	$template->set_var('DISPLAY_LIST', 'hide');
-}
-
-// Insert language headings
-$template->set_var(array(
-								'HEADING_INSTALL_LANGUAGE' => $HEADING['INSTALL_LANGUAGE'],
-								'HEADING_UNINSTALL_LANGUAGE' => $HEADING['UNINSTALL_LANGUAGE'],
-								'HEADING_LANGUAGE_DETAILS' => $HEADING['LANGUAGE_DETAILS']
-								)
-						);
-// Insert language text and messages
-$template->set_var(array(
-								'TEXT_INSTALL' => $TEXT['INSTALL'],
-								'TEXT_UNINSTALL' => $TEXT['UNINSTALL'],
-								'TEXT_VIEW_DETAILS' => $TEXT['VIEW_DETAILS'],
-								'TEXT_PLEASE_SELECT' => $TEXT['PLEASE_SELECT']
-								)
-						);
-
-// Parse template object
-$template->parse('main', 'main_block', false);
-$template->pparse('output', 'page');
-
-// Print admin footer
-$admin->print_footer();
-
-?>
+<?php
+
+// $Id$
+
+/*
+
+ Website Baker Project <http://www.websitebaker.org/>
+ Copyright (C) 2004-2005, 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
+
+*/
+
+// Print admin header
+require('../../config.php');
+require_once(WB_PATH.'/framework/class.admin.php');
+$admin = new admin('Addons', 'languages');
+
+// Setup template object
+$template = new Template(ADMIN_PATH.'/languages');
+$template->set_file('page', 'template.html');
+$template->set_block('page', 'main_block', 'main');
+
+// Insert values into language list
+$template->set_block('main_block', 'language_list_block', 'language_list');
+$result = $database->query("SELECT * FROM ".TABLE_PREFIX."addons WHERE type = 'language'");
+if($result->numRows() > 0) {
+	while($addon = $result->fetchRow()) {
+		$template->set_var('VALUE', $addon['directory']);
+		$template->set_var('NAME', $addon['name'].' ('.$addon['directory'].')');
+		$template->parse('language_list', 'language_list_block', true);
+	}
+}
+
+// Insert permissions values
+if($admin->get_permission('languages_install') != true) {
+	$template->set_var('DISPLAY_INSTALL', 'hide');
+}
+if($admin->get_permission('languages_uninstall') != true) {
+	$template->set_var('DISPLAY_UNINSTALL', 'hide');
+}
+if($admin->get_permission('languages_view') != true) {
+	$template->set_var('DISPLAY_LIST', 'hide');
+}
+
+// Insert language headings
+$template->set_var(array(
+								'HEADING_INSTALL_LANGUAGE' => $HEADING['INSTALL_LANGUAGE'],
+								'HEADING_UNINSTALL_LANGUAGE' => $HEADING['UNINSTALL_LANGUAGE'],
+								'HEADING_LANGUAGE_DETAILS' => $HEADING['LANGUAGE_DETAILS']
+								)
+						);
+// Insert language text and messages
+$template->set_var(array(
+								'TEXT_INSTALL' => $TEXT['INSTALL'],
+								'TEXT_UNINSTALL' => $TEXT['UNINSTALL'],
+								'TEXT_VIEW_DETAILS' => $TEXT['VIEW_DETAILS'],
+								'TEXT_PLEASE_SELECT' => $TEXT['PLEASE_SELECT']
+								)
+						);
+
+// Parse template object
+$template->parse('main', 'main_block', false);
+$template->pparse('output', 'page');
+
+// Print admin footer
+$admin->print_footer();
+
+?>
Index: trunk/wb/admin/modules/index.php
===================================================================
--- trunk/wb/admin/modules/index.php	(revision 237)
+++ trunk/wb/admin/modules/index.php	(revision 238)
@@ -1,81 +1,81 @@
-<?php
-
-// $Id$
-
-/*
-
- Website Baker Project <http://www.websitebaker.org/>
- Copyright (C) 2004-2005, 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
-
-*/
-
-// Print admin header
-require('../../config.php');
-require_once(WB_PATH.'/framework/class.admin.php');
-$admin = new admin('Addons', 'modules');
-
-// Setup template object
-$template = new Template(ADMIN_PATH.'/modules');
-$template->set_file('page', 'template.html');
-$template->set_block('page', 'main_block', 'main');
-
-// Insert values into module list
-$template->set_block('main_block', 'module_list_block', 'module_list');
-$result = $database->query("SELECT * FROM ".TABLE_PREFIX."addons WHERE type = 'module'");
-if($result->numRows() > 0) {
-	while ($addon = $result->fetchRow()) {
-		$template->set_var('VALUE', $addon['directory']);
-		$template->set_var('NAME', $addon['name']);
-		$template->parse('module_list', 'module_list_block', true);
-	}
-}
-
-// Insert permissions values
-if($admin->get_permission('modules_install') != true) {
-	$template->set_var('DISPLAY_INSTALL', 'hide');
-}
-if($admin->get_permission('modules_uninstall') != true) {
-	$template->set_var('DISPLAY_UNINSTALL', 'hide');
-}
-if($admin->get_permission('modules_view') != true) {
-	$template->set_var('DISPLAY_LIST', 'hide');
-}
-
-// Insert language headings
-$template->set_var(array(
-								'HEADING_INSTALL_MODULE' => $HEADING['INSTALL_MODULE'],
-								'HEADING_UNINSTALL_MODULE' => $HEADING['UNINSTALL_MODULE'],
-								'HEADING_MODULE_DETAILS' => $HEADING['MODULE_DETAILS']
-								)
-						);
-// Insert language text and messages
-$template->set_var(array(
-								'TEXT_INSTALL' => $TEXT['INSTALL'],
-								'TEXT_UNINSTALL' => $TEXT['UNINSTALL'],
-								'TEXT_VIEW_DETAILS' => $TEXT['VIEW_DETAILS'],
-								'TEXT_PLEASE_SELECT' => $TEXT['PLEASE_SELECT']
-								)
-						);
-
-// Parse template object
-$template->parse('main', 'main_block', false);
-$template->pparse('output', 'page');
-
-// Print admin footer
-$admin->print_footer();
-
-?>
+<?php
+
+// $Id$
+
+/*
+
+ Website Baker Project <http://www.websitebaker.org/>
+ Copyright (C) 2004-2005, 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
+
+*/
+
+// Print admin header
+require('../../config.php');
+require_once(WB_PATH.'/framework/class.admin.php');
+$admin = new admin('Addons', 'modules');
+
+// Setup template object
+$template = new Template(ADMIN_PATH.'/modules');
+$template->set_file('page', 'template.html');
+$template->set_block('page', 'main_block', 'main');
+
+// Insert values into module list
+$template->set_block('main_block', 'module_list_block', 'module_list');
+$result = $database->query("SELECT * FROM ".TABLE_PREFIX."addons WHERE type = 'module'");
+if($result->numRows() > 0) {
+	while ($addon = $result->fetchRow()) {
+		$template->set_var('VALUE', $addon['directory']);
+		$template->set_var('NAME', $addon['name']);
+		$template->parse('module_list', 'module_list_block', true);
+	}
+}
+
+// Insert permissions values
+if($admin->get_permission('modules_install') != true) {
+	$template->set_var('DISPLAY_INSTALL', 'hide');
+}
+if($admin->get_permission('modules_uninstall') != true) {
+	$template->set_var('DISPLAY_UNINSTALL', 'hide');
+}
+if($admin->get_permission('modules_view') != true) {
+	$template->set_var('DISPLAY_LIST', 'hide');
+}
+
+// Insert language headings
+$template->set_var(array(
+								'HEADING_INSTALL_MODULE' => $HEADING['INSTALL_MODULE'],
+								'HEADING_UNINSTALL_MODULE' => $HEADING['UNINSTALL_MODULE'],
+								'HEADING_MODULE_DETAILS' => $HEADING['MODULE_DETAILS']
+								)
+						);
+// Insert language text and messages
+$template->set_var(array(
+								'TEXT_INSTALL' => $TEXT['INSTALL'],
+								'TEXT_UNINSTALL' => $TEXT['UNINSTALL'],
+								'TEXT_VIEW_DETAILS' => $TEXT['VIEW_DETAILS'],
+								'TEXT_PLEASE_SELECT' => $TEXT['PLEASE_SELECT']
+								)
+						);
+
+// Parse template object
+$template->parse('main', 'main_block', false);
+$template->pparse('output', 'page');
+
+// Print admin footer
+$admin->print_footer();
+
+?>
Index: trunk/wb/modules/wysiwyg/modify.php
===================================================================
--- trunk/wb/modules/wysiwyg/modify.php	(revision 237)
+++ trunk/wb/modules/wysiwyg/modify.php	(revision 238)
@@ -1,79 +1,79 @@
-<?php
-
-// $Id$
-
-/*
-
- Website Baker Project <http://www.websitebaker.org/>
- Copyright (C) 2004-2005, 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
-
-*/
-
-if(!defined('WB_PATH')) exit('Direct access to this file is not allowed');
-
-// Get page content
-$query = "SELECT content FROM ".TABLE_PREFIX."mod_wysiwyg WHERE section_id = '$section_id'";
-$get_content = $database->query($query);
-$content = $get_content->fetchRow();
-$content = (htmlspecialchars($content['content']));
-
-if(!isset($wysiwyg_editor_loaded)) {
-	$wysiwyg_editor_loaded=true;
-
-	if (!defined('WYSIWYG_EDITOR') OR WYSIWYG_EDITOR=="none" OR !file_exists(WB_PATH.'/modules/'.WYSIWYG_EDITOR.'/include.php')) {
-		function show_wysiwyg_editor($name,$id,$content,$width,$height) {
-			echo '<textarea name="'.$name.'" id="'.$id.'" style="width: '.$width.'; height: '.$height.';">'.$content.'</textarea>';
-		}
-	} else {
-		$id_list=array();
-		$query_wysiwyg = $database->query("SELECT section_id FROM ".TABLE_PREFIX."sections WHERE page_id = '$page_id' AND module = 'wysiwyg'");
-		if($query_wysiwyg->numRows() > 0) {
-			while($wysiwyg_section = $query_wysiwyg->fetchRow()) {
-				$entry='content'.$wysiwyg_section['section_id'];
-				array_push($id_list,$entry);
-			}
-			require(WB_PATH.'/modules/'.WYSIWYG_EDITOR.'/include.php');
-		}
-	}
-}
-
-?>
-
-<form name="wysiwyg<?php echo $section_id; ?>" action="<?php echo WB_URL; ?>/modules/wysiwyg/save.php" method="post">
-
-<input type="hidden" name="page_id" value="<?php echo $page_id; ?>" />
-<input type="hidden" name="section_id" value="<?php echo $section_id; ?>" />
-
-<?php
-show_wysiwyg_editor('content'.$section_id,'content'.$section_id,$content,'725px','350px');
-?>
-
-<table cellpadding="0" cellspacing="0" border="0" width="100%" style="padding-bottom: 10px;">
-<tr>
-	<td align="left">
-		<input type="submit" value="<?php echo $TEXT['SAVE']; ?>" style="width: 100px; margin-top: 5px;" />
-	</td>
-	<td align="right">
-		</form>
-		<input type="button" value="<?php echo $TEXT['CANCEL']; ?>" onclick="javascript: window.location = 'index.php';" style="width: 100px; margin-top: 5px;" />
-	</td>
-</tr>
-</table>
-
-</form>
-
-<br />
+<?php
+
+// $Id$
+
+/*
+
+ Website Baker Project <http://www.websitebaker.org/>
+ Copyright (C) 2004-2005, 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
+
+*/
+
+if(!defined('WB_PATH')) exit('Direct access to this file is not allowed');
+
+// Get page content
+$query = "SELECT content FROM ".TABLE_PREFIX."mod_wysiwyg WHERE section_id = '$section_id'";
+$get_content = $database->query($query);
+$content = $get_content->fetchRow();
+$content = (htmlspecialchars($content['content']));
+
+if(!isset($wysiwyg_editor_loaded)) {
+	$wysiwyg_editor_loaded=true;
+
+	if (!defined('WYSIWYG_EDITOR') OR WYSIWYG_EDITOR=="none" OR !file_exists(WB_PATH.'/modules/'.WYSIWYG_EDITOR.'/include.php')) {
+		function show_wysiwyg_editor($name,$id,$content,$width,$height) {
+			echo '<textarea name="'.$name.'" id="'.$id.'" style="width: '.$width.'; height: '.$height.';">'.$content.'</textarea>';
+		}
+	} else {
+		$id_list=array();
+		$query_wysiwyg = $database->query("SELECT section_id FROM ".TABLE_PREFIX."sections WHERE page_id = '$page_id' AND module = 'wysiwyg'");
+		if($query_wysiwyg->numRows() > 0) {
+			while($wysiwyg_section = $query_wysiwyg->fetchRow()) {
+				$entry='content'.$wysiwyg_section['section_id'];
+				array_push($id_list,$entry);
+			}
+			require(WB_PATH.'/modules/'.WYSIWYG_EDITOR.'/include.php');
+		}
+	}
+}
+
+?>
+
+<form name="wysiwyg<?php echo $section_id; ?>" action="<?php echo WB_URL; ?>/modules/wysiwyg/save.php" method="post">
+
+<input type="hidden" name="page_id" value="<?php echo $page_id; ?>" />
+<input type="hidden" name="section_id" value="<?php echo $section_id; ?>" />
+
+<?php
+show_wysiwyg_editor('content'.$section_id,'content'.$section_id,$content,'725px','350px');
+?>
+
+<table cellpadding="0" cellspacing="0" border="0" width="100%" style="padding-bottom: 10px;">
+<tr>
+	<td align="left">
+		<input type="submit" value="<?php echo $TEXT['SAVE']; ?>" style="width: 100px; margin-top: 5px;" />
+	</td>
+	<td align="right">
+		</form>
+		<input type="button" value="<?php echo $TEXT['CANCEL']; ?>" onclick="javascript: window.location = 'index.php';" style="width: 100px; margin-top: 5px;" />
+	</td>
+</tr>
+</table>
+
+</form>
+
+<br />
Index: trunk/wb/modules/news/modify_post.php
===================================================================
--- trunk/wb/modules/news/modify_post.php	(revision 237)
+++ trunk/wb/modules/news/modify_post.php	(revision 238)
@@ -1,197 +1,197 @@
-<?php
-
-// $Id$
-
-/*
-
- Website Baker Project <http://www.websitebaker.org/>
- Copyright (C) 2004-2005, 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('../../config.php');
-
-// Get id
-if(!isset($_GET['post_id']) OR !is_numeric($_GET['post_id'])) {
-	header("Location: ".ADMIN_URL."/pages/index.php");
-} else {
-	$post_id = $_GET['post_id'];
-}
-
-// Include WB admin wrapper script
-require(WB_PATH.'/modules/admin.php');
-
-// Get header and footer
-$query_content = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_news_posts WHERE post_id = '$post_id'");
-$fetch_content = $query_content->fetchRow();
-
-if (!defined('WYSIWYG_EDITOR') OR WYSIWYG_EDITOR=="none" OR !file_exists(WB_PATH.'/modules/'.WYSIWYG_EDITOR.'/include.php')) {
-	function show_wysiwyg_editor($name,$id,$content,$width,$height) {
-		echo '<textarea name="'.$name.'" id="'.$id.'" style="width: '.$width.'; height: '.$height.';">'.$content.'</textarea>';
-	}
-} else {
-	$id_list=array("short","long");
-			require(WB_PATH.'/modules/'.WYSIWYG_EDITOR.'/include.php');
-}
-
-?>
-<form name="modify" action="<?php echo WB_URL; ?>/modules/news/save_post.php" method="post" style="margin: 0;">
-
-<input type="hidden" name="section_id" value="<?php echo $section_id; ?>">
-<input type="hidden" name="page_id" value="<?php echo $page_id; ?>">
-<input type="hidden" name="post_id" value="<?php echo $post_id; ?>">
-<input type="hidden" name="link" value="<?php echo $fetch_content['link']; ?>">
-
-<table cellpadding="4" cellspacing="0" border="0" width="100%">
-<tr>
-	<td width="80"><?php echo $TEXT['TITLE']; ?>:</td>
-	<td width="100%">
-		<input type="text" name="title" value="<?php echo (htmlspecialchars($fetch_content['title'])); ?>" style="width: 100%;" maxlength="255" />
-	</td>
-</tr>
-<tr>
-	<td><?php echo $TEXT['GROUP']; ?>:</td>
-	<td>
-		<select name="group" style="width: 100%;">
-			<option value="0"><?php echo $TEXT['NONE']; ?></option>
-			<?php
-			$query = $database->query("SELECT group_id,title FROM ".TABLE_PREFIX."mod_news_groups WHERE section_id = '$section_id' ORDER BY position ASC");
-			if($query->numRows() > 0) {
-				// Loop through groups
-				while($group = $query->fetchRow()) {
-					?>
-					<option value="<?php echo $group['group_id']; ?>"<?php if($fetch_content['group_id'] == $group['group_id']) { echo ' selected'; } ?>><?php echo $group['title']; ?></option>
-					<?php
-				}
-			}
-			?>
-		</select>
-	</td>
-</tr>
-<tr>
-	<td><?php echo $TEXT['COMMENTING']; ?>:</td>
-	<td>
-		<select name="commenting" style="width: 100%;">
-			<option value="none"><?php echo $TEXT['DISABLED']; ?></option>
-			<option value="public" <?php if($fetch_content['commenting'] == 'public') { echo 'selected'; } ?>><?php echo $TEXT['PUBLIC']; ?></option>
-			<option value="private" <?php if($fetch_content['commenting'] == 'private') { echo 'selected'; } ?>><?php echo $TEXT['PRIVATE']; ?></option>
-		</select>
-	</td>
-</tr>
-<tr>
-	<td><?php echo $TEXT['ACTIVE']; ?>:</td>
-	<td>
-		<input type="radio" name="active" id="active_true" value="1" <?php if($fetch_content['active'] == 1) { echo ' checked'; } ?> />
-		<a href="#" onclick="javascript: document.getElementById('active_true').checked = true;">
-		<?php echo $TEXT['YES']; ?>
-		</a>
-		&nbsp;
-		<input type="radio" name="active" id="active_false" value="0" <?php if($fetch_content['active'] == 0) { echo ' checked'; } ?> />
-		<a href="#" onclick="javascript: document.getElementById('active_false').checked = true;">
-		<?php echo $TEXT['NO']; ?>
-		</a>
-	</td>
-</tr>
-<tr>
-	<td valign="top"><?php echo $TEXT['SHORT']; ?>:</td>
-	<td>
-	<?php
-	show_wysiwyg_editor("short","short",$fetch_content['content_short'],"100%","135px");
-	?>
-	</td>
-</tr>
-<tr>
-	<td valign="top"><?php echo $TEXT['LONG']; ?>:</td>
-	<td>
-	<?php
-	show_wysiwyg_editor("long","long",$fetch_content['content_long'],"100%","300px");
-	?>
-	</td>
-</tr>
-</table>
-
-<table cellpadding="0" cellspacing="0" border="0" width="100%">
-<tr>
-	<td width="90">
-		&nbsp;
-	</td>
-	<td align="left">
-		<input name="save" type="submit" value="<?php echo $TEXT['SAVE']; ?>" style="width: 200px; margin-top: 5px;"></form>
-	</td>
-	<td align="right">
-		<input type="button" value="<?php echo $TEXT['CANCEL']; ?>" onclick="javascript: window.location = '<?php echo ADMIN_URL; ?>/pages/modify.php?page_id=<?php echo $page_id; ?>';" style="width: 100px; margin-top: 5px;" />
-	</td>
-</tr>
-</table>
-
-<br />
-
-<h2><?php echo $TEXT['MODIFY'].'/'.$TEXT['DELETE'].' '.$TEXT['COMMENT']; ?></h2>
-
-<?php
-
-// Loop through existing posts
-$query_comments = $database->query("SELECT * FROM `".TABLE_PREFIX."mod_news_comments` WHERE section_id = '$section_id' AND post_id = '$post_id' ORDER BY commented_when DESC");
-if($query_comments->numRows() > 0) {
-	$row = 'a';
-	?>
-	<table cellpadding="2" cellspacing="0" border="0" width="100%">
-	<?php
-	while($comment = $query_comments->fetchRow()) {
-		?>
-		<tr class="row_<?php echo $row; ?>" height="20">
-			<td width="20" style="padding-left: 5px;">
-				<a href="<?php echo WB_URL; ?>/modules/news/modify_comment.php?page_id=<?php echo $page_id; ?>&section_id=<?php echo $section_id; ?>&comment_id=<?php echo $comment['comment_id']; ?>" title="<?php echo $TEXT['MODIFY']; ?>">
-					<img src="<?php echo ADMIN_URL; ?>/images/modify_16.png" border="0" alt="^" />
-				</a>
-			</td>	
-			<td>
-				<a href="<?php echo WB_URL; ?>/modules/news/modify_comment.php?page_id=<?php echo $page_id; ?>&section_id=<?php echo $section_id; ?>&comment_id=<?php echo $comment['comment_id']; ?>">
-					<?php echo $comment['title']; ?>
-				</a>
-			</td>
-			<td width="20">
-				<a href="javascript: confirm_link('<?php echo $TEXT['ARE_YOU_SURE']; ?>', '<?php echo WB_URL; ?>/modules/news/delete_comment.php?page_id=<?php echo $page_id; ?>&section_id=<?php echo $section_id; ?>&post_id=<?php echo $post_id; ?>&comment_id=<?php echo $comment['comment_id']; ?>');" title="<?php echo $TEXT['DELETE']; ?>">
-					<img src="<?php echo ADMIN_URL; ?>/images/delete_16.png" border="0" alt="X" />
-				</a>
-			</td>
-		</tr>
-		<?php
-		// Alternate row color
-		if($row == 'a') {
-			$row = 'b';
-		} else {
-			$row = 'a';
-		}
-	}
-	?>
-	</table>
-	<?php
-} else {
-	echo $TEXT['NONE_FOUND'];
-}
-
-?>
-
-
-
-<?php
-
-// Print admin footer
-$admin->print_footer();
-
-?>
+<?php
+
+// $Id$
+
+/*
+
+ Website Baker Project <http://www.websitebaker.org/>
+ Copyright (C) 2004-2005, 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('../../config.php');
+
+// Get id
+if(!isset($_GET['post_id']) OR !is_numeric($_GET['post_id'])) {
+	header("Location: ".ADMIN_URL."/pages/index.php");
+} else {
+	$post_id = $_GET['post_id'];
+}
+
+// Include WB admin wrapper script
+require(WB_PATH.'/modules/admin.php');
+
+// Get header and footer
+$query_content = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_news_posts WHERE post_id = '$post_id'");
+$fetch_content = $query_content->fetchRow();
+
+if (!defined('WYSIWYG_EDITOR') OR WYSIWYG_EDITOR=="none" OR !file_exists(WB_PATH.'/modules/'.WYSIWYG_EDITOR.'/include.php')) {
+	function show_wysiwyg_editor($name,$id,$content,$width,$height) {
+		echo '<textarea name="'.$name.'" id="'.$id.'" style="width: '.$width.'; height: '.$height.';">'.$content.'</textarea>';
+	}
+} else {
+	$id_list=array("short","long");
+			require(WB_PATH.'/modules/'.WYSIWYG_EDITOR.'/include.php');
+}
+
+?>
+<form name="modify" action="<?php echo WB_URL; ?>/modules/news/save_post.php" method="post" style="margin: 0;">
+
+<input type="hidden" name="section_id" value="<?php echo $section_id; ?>">
+<input type="hidden" name="page_id" value="<?php echo $page_id; ?>">
+<input type="hidden" name="post_id" value="<?php echo $post_id; ?>">
+<input type="hidden" name="link" value="<?php echo $fetch_content['link']; ?>">
+
+<table cellpadding="4" cellspacing="0" border="0" width="100%">
+<tr>
+	<td width="80"><?php echo $TEXT['TITLE']; ?>:</td>
+	<td width="100%">
+		<input type="text" name="title" value="<?php echo (htmlspecialchars($fetch_content['title'])); ?>" style="width: 100%;" maxlength="255" />
+	</td>
+</tr>
+<tr>
+	<td><?php echo $TEXT['GROUP']; ?>:</td>
+	<td>
+		<select name="group" style="width: 100%;">
+			<option value="0"><?php echo $TEXT['NONE']; ?></option>
+			<?php
+			$query = $database->query("SELECT group_id,title FROM ".TABLE_PREFIX."mod_news_groups WHERE section_id = '$section_id' ORDER BY position ASC");
+			if($query->numRows() > 0) {
+				// Loop through groups
+				while($group = $query->fetchRow()) {
+					?>
+					<option value="<?php echo $group['group_id']; ?>"<?php if($fetch_content['group_id'] == $group['group_id']) { echo ' selected'; } ?>><?php echo $group['title']; ?></option>
+					<?php
+				}
+			}
+			?>
+		</select>
+	</td>
+</tr>
+<tr>
+	<td><?php echo $TEXT['COMMENTING']; ?>:</td>
+	<td>
+		<select name="commenting" style="width: 100%;">
+			<option value="none"><?php echo $TEXT['DISABLED']; ?></option>
+			<option value="public" <?php if($fetch_content['commenting'] == 'public') { echo 'selected'; } ?>><?php echo $TEXT['PUBLIC']; ?></option>
+			<option value="private" <?php if($fetch_content['commenting'] == 'private') { echo 'selected'; } ?>><?php echo $TEXT['PRIVATE']; ?></option>
+		</select>
+	</td>
+</tr>
+<tr>
+	<td><?php echo $TEXT['ACTIVE']; ?>:</td>
+	<td>
+		<input type="radio" name="active" id="active_true" value="1" <?php if($fetch_content['active'] == 1) { echo ' checked'; } ?> />
+		<a href="#" onclick="javascript: document.getElementById('active_true').checked = true;">
+		<?php echo $TEXT['YES']; ?>
+		</a>
+		&nbsp;
+		<input type="radio" name="active" id="active_false" value="0" <?php if($fetch_content['active'] == 0) { echo ' checked'; } ?> />
+		<a href="#" onclick="javascript: document.getElementById('active_false').checked = true;">
+		<?php echo $TEXT['NO']; ?>
+		</a>
+	</td>
+</tr>
+<tr>
+	<td valign="top"><?php echo $TEXT['SHORT']; ?>:</td>
+	<td>
+	<?php
+	show_wysiwyg_editor("short","short",$fetch_content['content_short'],"100%","135px");
+	?>
+	</td>
+</tr>
+<tr>
+	<td valign="top"><?php echo $TEXT['LONG']; ?>:</td>
+	<td>
+	<?php
+	show_wysiwyg_editor("long","long",$fetch_content['content_long'],"100%","300px");
+	?>
+	</td>
+</tr>
+</table>
+
+<table cellpadding="0" cellspacing="0" border="0" width="100%">
+<tr>
+	<td width="90">
+		&nbsp;
+	</td>
+	<td align="left">
+		<input name="save" type="submit" value="<?php echo $TEXT['SAVE']; ?>" style="width: 200px; margin-top: 5px;"></form>
+	</td>
+	<td align="right">
+		<input type="button" value="<?php echo $TEXT['CANCEL']; ?>" onclick="javascript: window.location = '<?php echo ADMIN_URL; ?>/pages/modify.php?page_id=<?php echo $page_id; ?>';" style="width: 100px; margin-top: 5px;" />
+	</td>
+</tr>
+</table>
+
+<br />
+
+<h2><?php echo $TEXT['MODIFY'].'/'.$TEXT['DELETE'].' '.$TEXT['COMMENT']; ?></h2>
+
+<?php
+
+// Loop through existing posts
+$query_comments = $database->query("SELECT * FROM `".TABLE_PREFIX."mod_news_comments` WHERE section_id = '$section_id' AND post_id = '$post_id' ORDER BY commented_when DESC");
+if($query_comments->numRows() > 0) {
+	$row = 'a';
+	?>
+	<table cellpadding="2" cellspacing="0" border="0" width="100%">
+	<?php
+	while($comment = $query_comments->fetchRow()) {
+		?>
+		<tr class="row_<?php echo $row; ?>" height="20">
+			<td width="20" style="padding-left: 5px;">
+				<a href="<?php echo WB_URL; ?>/modules/news/modify_comment.php?page_id=<?php echo $page_id; ?>&section_id=<?php echo $section_id; ?>&comment_id=<?php echo $comment['comment_id']; ?>" title="<?php echo $TEXT['MODIFY']; ?>">
+					<img src="<?php echo ADMIN_URL; ?>/images/modify_16.png" border="0" alt="^" />
+				</a>
+			</td>	
+			<td>
+				<a href="<?php echo WB_URL; ?>/modules/news/modify_comment.php?page_id=<?php echo $page_id; ?>&section_id=<?php echo $section_id; ?>&comment_id=<?php echo $comment['comment_id']; ?>">
+					<?php echo $comment['title']; ?>
+				</a>
+			</td>
+			<td width="20">
+				<a href="javascript: confirm_link('<?php echo $TEXT['ARE_YOU_SURE']; ?>', '<?php echo WB_URL; ?>/modules/news/delete_comment.php?page_id=<?php echo $page_id; ?>&section_id=<?php echo $section_id; ?>&post_id=<?php echo $post_id; ?>&comment_id=<?php echo $comment['comment_id']; ?>');" title="<?php echo $TEXT['DELETE']; ?>">
+					<img src="<?php echo ADMIN_URL; ?>/images/delete_16.png" border="0" alt="X" />
+				</a>
+			</td>
+		</tr>
+		<?php
+		// Alternate row color
+		if($row == 'a') {
+			$row = 'b';
+		} else {
+			$row = 'a';
+		}
+	}
+	?>
+	</table>
+	<?php
+} else {
+	echo $TEXT['NONE_FOUND'];
+}
+
+?>
+
+
+
+<?php
+
+// Print admin footer
+$admin->print_footer();
+
+?>
Index: trunk/wb/modules/news/comment.php
===================================================================
--- trunk/wb/modules/news/comment.php	(revision 237)
+++ trunk/wb/modules/news/comment.php	(revision 238)
@@ -1,71 +1,71 @@
-<?php
-
-// $Id$
-
-/*
-
- Website Baker Project <http://www.websitebaker.org/>
- Copyright (C) 2004-2005, 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
-
-*/
-
-// Include config file
-require('../../config.php');
-
-// Check if there is a post id
-if(!isset($_GET['id']) OR !is_numeric($_GET['id'])) {
-	if(!isset($_POST['post_id']) OR !is_numeric($_POST['post_id'])) {
-		header('Location: '.WB_URL.'/pages/');
-	} else {
-		$post_id = $_POST['post_id'];
-	}
-} else {
-	$post_id = $_GET['id'];
-}
-
-// Include database class
-require_once(WB_PATH.'/framework/class.database.php');
-$database = new database();
-
-// Query post for page id
-$query_post = $database->query("SELECT post_id,title,section_id,page_id FROM ".TABLE_PREFIX."mod_news_posts WHERE post_id = '$post_id'");
-if($query_post->numRows() == 0) {
-	header('Location: '.WB_URL.'/pages/');
-} else {
-	$fetch_post = $query_post->fetchRow();
-	$page_id = $fetch_post['page_id'];
-	$section_id = $fetch_post['section_id'];
-	$post_id = $fetch_post['post_id'];
-	$post_title = $fetch_post['title'];
-	define('SECTION_ID', $section_id);
-	define('POST_ID', $post_id);
-	define('POST_TITLE', $post_title);
-	// Get page details
-	$query_page = $database->query("SELECT parent,page_title,menu_title,keywords,description,visibility FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id'");
-	if($query_page->numRows() == 0) {
-		header('Location: '.WB_URL.'/pages/');
-	} else {
-		$page = $query_page->fetchRow();
-		// Required page details
-		define('PAGE_CONTENT', WB_PATH.'/modules/news/comment_page.php');
-		// Include index (wrapper) file
-		require(WB_PATH.'/index.php');
-	}
-}
-
-
-?>
+<?php
+
+// $Id$
+
+/*
+
+ Website Baker Project <http://www.websitebaker.org/>
+ Copyright (C) 2004-2005, 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
+
+*/
+
+// Include config file
+require('../../config.php');
+
+// Check if there is a post id
+if(!isset($_GET['id']) OR !is_numeric($_GET['id'])) {
+	if(!isset($_POST['post_id']) OR !is_numeric($_POST['post_id'])) {
+		header('Location: '.WB_URL.'/pages/');
+	} else {
+		$post_id = $_POST['post_id'];
+	}
+} else {
+	$post_id = $_GET['id'];
+}
+
+// Include database class
+require_once(WB_PATH.'/framework/class.database.php');
+$database = new database();
+
+// Query post for page id
+$query_post = $database->query("SELECT post_id,title,section_id,page_id FROM ".TABLE_PREFIX."mod_news_posts WHERE post_id = '$post_id'");
+if($query_post->numRows() == 0) {
+	header('Location: '.WB_URL.'/pages/');
+} else {
+	$fetch_post = $query_post->fetchRow();
+	$page_id = $fetch_post['page_id'];
+	$section_id = $fetch_post['section_id'];
+	$post_id = $fetch_post['post_id'];
+	$post_title = $fetch_post['title'];
+	define('SECTION_ID', $section_id);
+	define('POST_ID', $post_id);
+	define('POST_TITLE', $post_title);
+	// Get page details
+	$query_page = $database->query("SELECT parent,page_title,menu_title,keywords,description,visibility FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id'");
+	if($query_page->numRows() == 0) {
+		header('Location: '.WB_URL.'/pages/');
+	} else {
+		$page = $query_page->fetchRow();
+		// Required page details
+		define('PAGE_CONTENT', WB_PATH.'/modules/news/comment_page.php');
+		// Include index (wrapper) file
+		require(WB_PATH.'/index.php');
+	}
+}
+
+
+?>
Index: trunk/wb/modules/news/view.php
===================================================================
--- trunk/wb/modules/news/view.php	(revision 237)
+++ trunk/wb/modules/news/view.php	(revision 238)
@@ -1,332 +1,332 @@
-<?php
-
-// $Id$
-
-/*
-
- Website Baker Project <http://www.websitebaker.org/>
- Copyright (C) 2004-2005, Ryan Djurovich
-
- Website Baker is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- Website Baker is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Website Baker; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-*/
-
-// Must include code to stop this file being access directly
-if(defined('WB_PATH') == false) { exit("Cannot access this file directly"); }
-
-// Check if there is a start point defined
-if(isset($_GET['p']) AND is_numeric($_GET['p']) AND $_GET['p'] >= 0) {
-	$position = $_GET['p'];
-} else {
-	$position = 0;
-}
-
-// Get user's username, display name, email, and id - needed for insertion into post info
-$users = array();
-$query_users = $database->query("SELECT user_id,username,display_name,email FROM ".TABLE_PREFIX."users");
-if($query_users->numRows() > 0) {
-	while($user = $query_users->fetchRow()) {
-		// Insert user info into users array
-		$user_id = $user['user_id'];
-		$users[$user_id]['username'] = $user['username'];
-		$users[$user_id]['display_name'] = $user['display_name'];
-		$users[$user_id]['email'] = $user['email'];
-	}
-}
-
-// Get groups (title, if they are active, and their image [if one has been uploaded])
-$groups[0]['title'] = '';
-$groups[0]['active'] = true;
-$groups[0]['image'] = '';
-$query_users = $database->query("SELECT group_id,title,active FROM ".TABLE_PREFIX."mod_news_groups WHERE section_id = '$section_id' ORDER BY position ASC");
-if($query_users->numRows() > 0) {
-	while($group = $query_users->fetchRow()) {
-		// Insert user info into users array
-		$group_id = $group['group_id'];
-		$groups[$group_id]['title'] = ($group['title']);
-		$groups[$group_id]['active'] = $group['active'];
-		if(file_exists(WB_PATH.MEDIA_DIRECTORY.'/.news/image'.$group_id.'.jpg')) {
-			$groups[$group_id]['image'] = WB_URL.MEDIA_DIRECTORY.'/.news/image'.$group_id.'.jpg';
-		} else {
-			$groups[$group_id]['image'] = '';
-		}
-	}
-}
-
-// Check if we should show the main page or a post itself
-if(!defined('POST_ID') OR !is_numeric(POST_ID)) {
-	
-	// Check if we should only list posts from a certain group
-	if(isset($_GET['g']) AND is_numeric($_GET['g'])) {
-		$query_extra = " AND group_id = '".$_GET['g']."'";
-		?>
-		<style type="text/css">.selected_group_title { font-size: 14px; text-align: center; }</style>
-		<?php
-	} else {
-		$query_extra = '';
-	}
-	
-	// Get settings
-	$query_settings = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_news_settings WHERE section_id = '$section_id'");
-	if($query_settings->numRows() > 0) {
-		$fetch_settings = $query_settings->fetchRow();
-		$setting_header = ($fetch_settings['header']);
-		$setting_post_loop = ($fetch_settings['post_loop']);
-		$setting_footer = ($fetch_settings['footer']);
-		$setting_posts_per_page = $fetch_settings['posts_per_page'];
-	} else {
-		$setting_header = '';
-		$setting_post_loop = '';
-		$setting_footer = '';
-		$setting_posts_per_page = '';
-	}
-	
-	// Get total number of posts
-	$query_total_num = $database->query("SELECT post_id FROM ".TABLE_PREFIX."mod_news_posts WHERE section_id = '$section_id' AND active = '1' AND title != ''$query_extra");
-	$total_num = $query_total_num->numRows();
-
-	// Work-out if we need to add limit code to sql
-	if($setting_posts_per_page != 0) {
-		$limit_sql = " LIMIT $position,$setting_posts_per_page";
-	} else {
-		$limit_sql = "";
-	}
-	
-	// Query posts (for this page)
-	$query_posts = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_news_posts WHERE section_id = '$section_id' AND active = '1' AND title != ''$query_extra ORDER BY position DESC".$limit_sql);
-	$num_posts = $query_posts->numRows();
-	
-	// Create previous and next links
-	if($setting_posts_per_page != 0) {
-		if($position > 0) {
-			if(isset($_GET['g']) AND is_numeric($_GET['g'])) {
-				$pl_prepend = '<a href="?p='.($position-$setting_posts_per_page).'&g='.$_GET['g'].'"><< ';
-			} else {
-				$pl_prepend = '<a href="?p='.($position-$setting_posts_per_page).'"><< ';
-			}
-			$pl_append = '</a>';
-			$previous_link = $pl_prepend.$TEXT['PREVIOUS'].$pl_append;
-			$previous_page_link = $pl_prepend.$TEXT['PREVIOUS_PAGE'].$pl_append;
-		} else {
-			$previous_link = '';
-			$previous_page_link = '';
-		}
-		if($position+$setting_posts_per_page >= $total_num) {
-			$next_link = '';
-			$next_page_link = '';
-		} else {
-			if(isset($_GET['g']) AND is_numeric($_GET['g'])) {
-				$nl_prepend = '<a href="?p='.($position+$setting_posts_per_page).'&g='.$_GET['g'].'"> ';
-			} else {
-				$nl_prepend = '<a href="?p='.($position+$setting_posts_per_page).'"> ';
-			}
-			$nl_append = ' >></a>';
-			$next_link = $nl_prepend.$TEXT['NEXT'].$nl_append;
-			$next_page_link = $nl_prepend.$TEXT['NEXT_PAGE'].$nl_append;
-		}
-		if($position+$setting_posts_per_page > $total_num) {
-			$num_of = $position+$num_posts;
-		} else {
-			$num_of = $position+$setting_posts_per_page;
-		}
-		$out_of = ($position+1).'-'.$num_of.' '.strtolower($TEXT['OUT_OF']).' '.$total_num;
-		$of = ($position+1).'-'.$num_of.' '.strtolower($TEXT['OF']).' '.$total_num;
-		$display_previous_next_links = '';
-	} else {
-		$display_previous_next_links = 'none';
-	}
-		
-	// Print header
-	if($display_previous_next_links == 'none') {
-		echo  str_replace(array('[NEXT_PAGE_LINK]','[NEXT_LINK]','[PREVIOUS_PAGE_LINK]','[PREVIOUS_LINK]','[OUT_OF]','[OF]','[DISPLAY_PREVIOUS_NEXT_LINKS]'), array('','','','','','', $display_previous_next_links), $setting_header);
-	} else {
-		echo str_replace(array('[NEXT_PAGE_LINK]','[NEXT_LINK]','[PREVIOUS_PAGE_LINK]','[PREVIOUS_LINK]','[OUT_OF]','[OF]','[DISPLAY_PREVIOUS_NEXT_LINKS]'), array($next_page_link, $next_link, $previous_page_link, $previous_link, $out_of, $of, $display_previous_next_links), $setting_header);
-	}
-	
-	if($num_posts > 0) {
-		if($query_extra != '') {
-			?>
-			<div class="selected_group_title">
-				<?php echo '<a href="'.$_SERVER['PHP_SELF'].'">'.PAGE_TITLE.'</a> >> '.$groups[$_GET['g']]['title']; ?>
-			</div>
-			<?php
-		}
-		while($post = $query_posts->fetchRow()) {
-			if(isset($groups[$post['group_id']]['active']) AND $groups[$post['group_id']]['active'] != false) { // Make sure parent group is active
-				$uid = $post['posted_by']; // User who last modified the post
-				// Workout date and time of last modified post
-				$post_date = gmdate(DATE_FORMAT, $post['posted_when']+TIMEZONE);
-				$post_time = gmdate(TIME_FORMAT, $post['posted_when']+TIMEZONE);
-				// Work-out the post link
-				$post_link = page_link($post['link']);
-				if(isset($_GET['p']) AND $position > 0) {
-					$post_link .= '?p='.$position;
-				}
-				if(isset($_GET['g']) AND is_numeric($_GET['g'])) {
-					if(isset($_GET['p']) AND $position > 0) { $post_link .= '&'; } else { $post_link .= '?'; }
-					$post_link .= 'g='.$_GET['g'];
-				}
-				// Get group id, title, and image
-				$group_id = $post['group_id'];
-				$group_title = $groups[$group_id]['title'];
-				$group_image = $groups[$group_id]['image'];
-				if($group_image == '') { $display_image = 'none'; } else { $display_image = ''; }
-				if($group_id == 0) { $display_group = 'none'; } else { $display_group = ''; }
-				// Replace [wblink--PAGE_ID--] with real link
-				$short = ($post['content_short']);
-				$wb->preprocess($short);
-				// Replace vars with values
-				$post_long_len = strlen($post['long']);
-				$vars = array('[PAGE_TITLE]', '[GROUP_ID]', '[GROUP_TITLE]', '[GROUP_IMAGE]', '[DISPLAY_GROUP]', '[DISPLAY_IMAGE]', '[TITLE]', '[SHORT]', '[LINK]', '[DATE]', '[TIME]', '[USER_ID]', '[USERNAME]', '[DISPLAY_NAME]', '[EMAIL]', '[TEXT_READ_MORE]');
-				if(isset($users[$uid]['username']) AND $users[$uid]['username'] != '') {
-					if($post_long_len < 9) {
-						$values = array(PAGE_TITLE, $group_id, $group_title, $group_image, $display_group, $display_image, stripslashes($post['title']), stripslashes($post['short']), $post_link, $post_date, $post_time, $uid, $users[$uid]['username'], $users[$uid]['display_name'], $users[$uid]['email'], '');
-					} else {
-						$values = array(PAGE_TITLE, $group_id, $group_title, $group_image, $display_group, $display_image, stripslashes($post['title']), stripslashes($post['short']), $post_link, $post_date, $post_time, $uid, $users[$uid]['username'], $users[$uid]['display_name'], $users[$uid]['email'], $TEXT['READ_MORE']);
-					}
-				} else {
-					if($post_long_len < 9) {
-						$values = array(PAGE_TITLE, $group_id, $group_title, $group_image, $display_group, $display_image, stripslashes($post['title']), stripslashes($post['short']), $post_link, $post_date, $post_time, '', '', '', '', '');
-					} else {
-						$values = array(PAGE_TITLE, $group_id, $group_title, $group_image, $display_group, $display_image, stripslashes($post['title']), stripslashes($post['short']), $post_link, $post_date, $post_time, '', '', '', '', $TEXT['READ_MORE']);
-					}
-				}
-				echo str_replace($vars, $values, $setting_post_loop);
-			}
-		}
-	}
-	
-	// Print footer
-	if($display_previous_next_links == 'none') {
-		echo  str_replace(array('[NEXT_PAGE_LINK]','[NEXT_LINK]','[PREVIOUS_PAGE_LINK]','[PREVIOUS_LINK]','[OUT_OF]','[OF]','[DISPLAY_PREVIOUS_NEXT_LINKS]'), array('','','','','','', $display_previous_next_links), $setting_footer);
-	} else {
-		echo str_replace(array('[NEXT_PAGE_LINK]','[NEXT_LINK]','[PREVIOUS_PAGE_LINK]','[PREVIOUS_LINK]','[OUT_OF]','[OF]','[DISPLAY_PREVIOUS_NEXT_LINKS]'), array($next_page_link, $next_link, $previous_page_link, $previous_link, $out_of, $of, $display_previous_next_links), $setting_footer);
-	}
-	
-} elseif(defined('POST_ID') AND is_numeric(POST_ID)) {
-	
-	// Get settings
-	$query_settings = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_news_settings WHERE section_id = '$section_id'");
-	if($query_settings->numRows() > 0) {
-		$fetch_settings = $query_settings->fetchRow();
-		$setting_post_header = ($fetch_settings['post_header']);
-		$setting_post_footer = ($fetch_settings['post_footer']);
-		$setting_comments_header = ($fetch_settings['comments_header']);
-		$setting_comments_loop = ($fetch_settings['comments_loop']);
-		$setting_comments_footer = ($fetch_settings['comments_footer']);
-	} else {
-		$setting_post_header = '';
-		$setting_post_footer = '';
-		$setting_comments_header = '';
-		$setting_comments_loop = '';
-		$setting_comments_footer = '';
-	}
-	
-	// Get page info
-	$query_page = $database->query("SELECT link FROM ".TABLE_PREFIX."pages WHERE page_id = '".PAGE_ID."'");
-	if($query_page->numRows() > 0) {
-		$page = $query_page->fetchRow();
-		$page_link = page_link($page['link']);
-		if(isset($_GET['p']) AND $position > 0) {
-			$page_link .= '?p='.$_GET['p'];
-		}
-		if(isset($_GET['g']) AND is_numeric($_GET['g'])) {
-			if(isset($_GET['p']) AND $position > 0) { $page_link .= '&'; } else { $page_link .= '?'; }
-			$page_link .= 'g='.$_GET['g'];
-		}
-	} else {
-		exit('Page not found');
-	}
-	
-	// Get post info
-	$query_post = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_news_posts WHERE post_id = '".POST_ID."' AND active = '1'");
-	if($query_post->numRows() > 0) {
-		$post = $query_post->fetchRow();
-		if(isset($groups[$post['group_id']]['active']) AND $groups[$post['group_id']]['active'] != false) { // Make sure parent group is active
-			$uid = $post['posted_by']; // User who last modified the post
-			// Workout date and time of last modified post
-			$post_date = gmdate(DATE_FORMAT, $post['posted_when']+TIMEZONE);
-			$post_time = gmdate(TIME_FORMAT, $post['posted_when']+TIMEZONE);
-			// Get group id, title, and image
-			$group_id = $post['group_id'];
-			$group_title = $groups[$group_id]['title'];
-			$group_image = $groups[$group_id]['image'];
-			if($group_image == '') { $display_image = 'none'; } else { $display_image = ''; }
-			if($group_id == 0) { $display_group = 'none'; } else { $display_group = ''; }
-			$vars = array('[PAGE_TITLE]', '[GROUP_ID]', '[GROUP_TITLE]', '[GROUP_IMAGE]', '[DISPLAY_GROUP]', '[DISPLAY_IMAGE]', '[TITLE]', '[SHORT]', '[BACK]', '[DATE]', '[TIME]', '[USER_ID]', '[USERNAME]', '[DISPLAY_NAME]', '[EMAIL]');
-			if(isset($users[$uid]['username']) AND $users[$uid]['username'] != '') {
-				$values = array(PAGE_TITLE, $group_id, $group_title, $group_image, $display_group, $display_image, ($post['title']), ($post['content_short']), $page_link, $post_date, $post_time, $uid, $users[$uid]['username'], $users[$uid]['display_name'], $users[$uid]['email']);
-			} else {
-				$values = array(PAGE_TITLE, $group_id, $group_title, $group_image, $display_group, $display_image, ($post['title']), ($post['content_short']), $page_link, $post_date, $post_time, '', '', '', '');
-			}
-			$post_long = ($post['content_long']);
-		}
-	} else {
-		header('Location: '.WB_URL.'/pages/');
-	}
-	
-	// Print post header
-	echo str_replace($vars, $values, $setting_post_header);
-	
-	// Replace [wblink--PAGE_ID--] with real link
-  	$wb->preprocess($postlong);
-	// Print long
-	echo $post_long;
-	
-	// Print post footer
-	echo str_replace($vars, $values, $setting_post_footer);
-	
-	// Show comments section if we have to
-	if($post['commenting'] == 'private' AND isset($admin) AND $admin->is_authenticated() == true OR $post['commenting'] == 'public') {
-		
-		// Print comments header
-		echo str_replace('[ADD_COMMENT_URL]', WB_URL.'/modules/news/comment.php?id='.POST_ID, $setting_comments_header);
-		
-		// Query for comments
-		$query_comments = $database->query("SELECT title,comment,commented_when,commented_by FROM ".TABLE_PREFIX."mod_news_comments WHERE post_id = '".POST_ID."' ORDER BY commented_when ASC");
-		if($query_comments->numRows() > 0) {
-			while($comment = $query_comments->fetchRow()) {
-				// Display Comments without slashes, but with new-line characters
-				$comment['comment'] = nl2br(($comment['comment']));
-				$comment['title'] = ($comment['title']);
-				// Print comments loop
-				$commented_date = gmdate(DATE_FORMAT, $comment['commented_when']+TIMEZONE);
-				$commented_time = gmdate(TIME_FORMAT, $comment['commented_when']+TIMEZONE);
-				$uid = $comment['commented_by'];
-				$vars = array('[TITLE]','[COMMENT]','[DATE]','[TIME]','[USER_ID]','[USERNAME]','[DISPLAY_NAME]', '[EMAIL]');
-				if(isset($users[$uid]['username']) AND $users[$uid]['username'] != '') {
-					$values = array(($comment['title']), ($comment['comment']), $commented_date, $commented_time, $uid, ($users[$uid]['username']), ($users[$uid]['display_name']), ($users[$uid]['email']));
-				} else {
-					$values = array(($comment['title']), ($comment['comment']), $commented_date, $commented_time, '0', strtolower($TEXT['UNKNOWN']), $TEXT['UNKNOWN'], '');
-				}
-				echo str_replace($vars, $values, $setting_comments_loop);
-			}
-		} else {
-			// Say no comments found
-			if(isset($TEXT['NONE_FOUND'])) {
-				echo $TEXT['NONE_FOUND'].'<br />';
-			} else {
-				echo 'None Found<br />';
-			}
-		}
-		
-		// Print comments footer
-		echo str_replace('[ADD_COMMENT_URL]', WB_URL.'/modules/news/comment.php?id='.POST_ID, $setting_comments_footer);
-		
-	}
-		
-}
-
-?>
+<?php
+
+// $Id$
+
+/*
+
+ Website Baker Project <http://www.websitebaker.org/>
+ Copyright (C) 2004-2005, Ryan Djurovich
+
+ Website Baker is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ Website Baker is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Website Baker; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+*/
+
+// Must include code to stop this file being access directly
+if(defined('WB_PATH') == false) { exit("Cannot access this file directly"); }
+
+// Check if there is a start point defined
+if(isset($_GET['p']) AND is_numeric($_GET['p']) AND $_GET['p'] >= 0) {
+	$position = $_GET['p'];
+} else {
+	$position = 0;
+}
+
+// Get user's username, display name, email, and id - needed for insertion into post info
+$users = array();
+$query_users = $database->query("SELECT user_id,username,display_name,email FROM ".TABLE_PREFIX."users");
+if($query_users->numRows() > 0) {
+	while($user = $query_users->fetchRow()) {
+		// Insert user info into users array
+		$user_id = $user['user_id'];
+		$users[$user_id]['username'] = $user['username'];
+		$users[$user_id]['display_name'] = $user['display_name'];
+		$users[$user_id]['email'] = $user['email'];
+	}
+}
+
+// Get groups (title, if they are active, and their image [if one has been uploaded])
+$groups[0]['title'] = '';
+$groups[0]['active'] = true;
+$groups[0]['image'] = '';
+$query_users = $database->query("SELECT group_id,title,active FROM ".TABLE_PREFIX."mod_news_groups WHERE section_id = '$section_id' ORDER BY position ASC");
+if($query_users->numRows() > 0) {
+	while($group = $query_users->fetchRow()) {
+		// Insert user info into users array
+		$group_id = $group['group_id'];
+		$groups[$group_id]['title'] = ($group['title']);
+		$groups[$group_id]['active'] = $group['active'];
+		if(file_exists(WB_PATH.MEDIA_DIRECTORY.'/.news/image'.$group_id.'.jpg')) {
+			$groups[$group_id]['image'] = WB_URL.MEDIA_DIRECTORY.'/.news/image'.$group_id.'.jpg';
+		} else {
+			$groups[$group_id]['image'] = '';
+		}
+	}
+}
+
+// Check if we should show the main page or a post itself
+if(!defined('POST_ID') OR !is_numeric(POST_ID)) {
+	
+	// Check if we should only list posts from a certain group
+	if(isset($_GET['g']) AND is_numeric($_GET['g'])) {
+		$query_extra = " AND group_id = '".$_GET['g']."'";
+		?>
+		<style type="text/css">.selected_group_title { font-size: 14px; text-align: center; }</style>
+		<?php
+	} else {
+		$query_extra = '';
+	}
+	
+	// Get settings
+	$query_settings = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_news_settings WHERE section_id = '$section_id'");
+	if($query_settings->numRows() > 0) {
+		$fetch_settings = $query_settings->fetchRow();
+		$setting_header = ($fetch_settings['header']);
+		$setting_post_loop = ($fetch_settings['post_loop']);
+		$setting_footer = ($fetch_settings['footer']);
+		$setting_posts_per_page = $fetch_settings['posts_per_page'];
+	} else {
+		$setting_header = '';
+		$setting_post_loop = '';
+		$setting_footer = '';
+		$setting_posts_per_page = '';
+	}
+	
+	// Get total number of posts
+	$query_total_num = $database->query("SELECT post_id FROM ".TABLE_PREFIX."mod_news_posts WHERE section_id = '$section_id' AND active = '1' AND title != ''$query_extra");
+	$total_num = $query_total_num->numRows();
+
+	// Work-out if we need to add limit code to sql
+	if($setting_posts_per_page != 0) {
+		$limit_sql = " LIMIT $position,$setting_posts_per_page";
+	} else {
+		$limit_sql = "";
+	}
+	
+	// Query posts (for this page)
+	$query_posts = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_news_posts WHERE section_id = '$section_id' AND active = '1' AND title != ''$query_extra ORDER BY position DESC".$limit_sql);
+	$num_posts = $query_posts->numRows();
+	
+	// Create previous and next links
+	if($setting_posts_per_page != 0) {
+		if($position > 0) {
+			if(isset($_GET['g']) AND is_numeric($_GET['g'])) {
+				$pl_prepend = '<a href="?p='.($position-$setting_posts_per_page).'&g='.$_GET['g'].'"><< ';
+			} else {
+				$pl_prepend = '<a href="?p='.($position-$setting_posts_per_page).'"><< ';
+			}
+			$pl_append = '</a>';
+			$previous_link = $pl_prepend.$TEXT['PREVIOUS'].$pl_append;
+			$previous_page_link = $pl_prepend.$TEXT['PREVIOUS_PAGE'].$pl_append;
+		} else {
+			$previous_link = '';
+			$previous_page_link = '';
+		}
+		if($position+$setting_posts_per_page >= $total_num) {
+			$next_link = '';
+			$next_page_link = '';
+		} else {
+			if(isset($_GET['g']) AND is_numeric($_GET['g'])) {
+				$nl_prepend = '<a href="?p='.($position+$setting_posts_per_page).'&g='.$_GET['g'].'"> ';
+			} else {
+				$nl_prepend = '<a href="?p='.($position+$setting_posts_per_page).'"> ';
+			}
+			$nl_append = ' >></a>';
+			$next_link = $nl_prepend.$TEXT['NEXT'].$nl_append;
+			$next_page_link = $nl_prepend.$TEXT['NEXT_PAGE'].$nl_append;
+		}
+		if($position+$setting_posts_per_page > $total_num) {
+			$num_of = $position+$num_posts;
+		} else {
+			$num_of = $position+$setting_posts_per_page;
+		}
+		$out_of = ($position+1).'-'.$num_of.' '.strtolower($TEXT['OUT_OF']).' '.$total_num;
+		$of = ($position+1).'-'.$num_of.' '.strtolower($TEXT['OF']).' '.$total_num;
+		$display_previous_next_links = '';
+	} else {
+		$display_previous_next_links = 'none';
+	}
+		
+	// Print header
+	if($display_previous_next_links == 'none') {
+		echo  str_replace(array('[NEXT_PAGE_LINK]','[NEXT_LINK]','[PREVIOUS_PAGE_LINK]','[PREVIOUS_LINK]','[OUT_OF]','[OF]','[DISPLAY_PREVIOUS_NEXT_LINKS]'), array('','','','','','', $display_previous_next_links), $setting_header);
+	} else {
+		echo str_replace(array('[NEXT_PAGE_LINK]','[NEXT_LINK]','[PREVIOUS_PAGE_LINK]','[PREVIOUS_LINK]','[OUT_OF]','[OF]','[DISPLAY_PREVIOUS_NEXT_LINKS]'), array($next_page_link, $next_link, $previous_page_link, $previous_link, $out_of, $of, $display_previous_next_links), $setting_header);
+	}
+	
+	if($num_posts > 0) {
+		if($query_extra != '') {
+			?>
+			<div class="selected_group_title">
+				<?php echo '<a href="'.$_SERVER['PHP_SELF'].'">'.PAGE_TITLE.'</a> >> '.$groups[$_GET['g']]['title']; ?>
+			</div>
+			<?php
+		}
+		while($post = $query_posts->fetchRow()) {
+			if(isset($groups[$post['group_id']]['active']) AND $groups[$post['group_id']]['active'] != false) { // Make sure parent group is active
+				$uid = $post['posted_by']; // User who last modified the post
+				// Workout date and time of last modified post
+				$post_date = gmdate(DATE_FORMAT, $post['posted_when']+TIMEZONE);
+				$post_time = gmdate(TIME_FORMAT, $post['posted_when']+TIMEZONE);
+				// Work-out the post link
+				$post_link = page_link($post['link']);
+				if(isset($_GET['p']) AND $position > 0) {
+					$post_link .= '?p='.$position;
+				}
+				if(isset($_GET['g']) AND is_numeric($_GET['g'])) {
+					if(isset($_GET['p']) AND $position > 0) { $post_link .= '&'; } else { $post_link .= '?'; }
+					$post_link .= 'g='.$_GET['g'];
+				}
+				// Get group id, title, and image
+				$group_id = $post['group_id'];
+				$group_title = $groups[$group_id]['title'];
+				$group_image = $groups[$group_id]['image'];
+				if($group_image == '') { $display_image = 'none'; } else { $display_image = ''; }
+				if($group_id == 0) { $display_group = 'none'; } else { $display_group = ''; }
+				// Replace [wblink--PAGE_ID--] with real link
+				$short = ($post['content_short']);
+				$wb->preprocess($short);
+				// Replace vars with values
+				$post_long_len = strlen($post['long']);
+				$vars = array('[PAGE_TITLE]', '[GROUP_ID]', '[GROUP_TITLE]', '[GROUP_IMAGE]', '[DISPLAY_GROUP]', '[DISPLAY_IMAGE]', '[TITLE]', '[SHORT]', '[LINK]', '[DATE]', '[TIME]', '[USER_ID]', '[USERNAME]', '[DISPLAY_NAME]', '[EMAIL]', '[TEXT_READ_MORE]');
+				if(isset($users[$uid]['username']) AND $users[$uid]['username'] != '') {
+					if($post_long_len < 9) {
+						$values = array(PAGE_TITLE, $group_id, $group_title, $group_image, $display_group, $display_image, stripslashes($post['title']), stripslashes($post['short']), $post_link, $post_date, $post_time, $uid, $users[$uid]['username'], $users[$uid]['display_name'], $users[$uid]['email'], '');
+					} else {
+						$values = array(PAGE_TITLE, $group_id, $group_title, $group_image, $display_group, $display_image, stripslashes($post['title']), stripslashes($post['short']), $post_link, $post_date, $post_time, $uid, $users[$uid]['username'], $users[$uid]['display_name'], $users[$uid]['email'], $TEXT['READ_MORE']);
+					}
+				} else {
+					if($post_long_len < 9) {
+						$values = array(PAGE_TITLE, $group_id, $group_title, $group_image, $display_group, $display_image, stripslashes($post['title']), stripslashes($post['short']), $post_link, $post_date, $post_time, '', '', '', '', '');
+					} else {
+						$values = array(PAGE_TITLE, $group_id, $group_title, $group_image, $display_group, $display_image, stripslashes($post['title']), stripslashes($post['short']), $post_link, $post_date, $post_time, '', '', '', '', $TEXT['READ_MORE']);
+					}
+				}
+				echo str_replace($vars, $values, $setting_post_loop);
+			}
+		}
+	}
+	
+	// Print footer
+	if($display_previous_next_links == 'none') {
+		echo  str_replace(array('[NEXT_PAGE_LINK]','[NEXT_LINK]','[PREVIOUS_PAGE_LINK]','[PREVIOUS_LINK]','[OUT_OF]','[OF]','[DISPLAY_PREVIOUS_NEXT_LINKS]'), array('','','','','','', $display_previous_next_links), $setting_footer);
+	} else {
+		echo str_replace(array('[NEXT_PAGE_LINK]','[NEXT_LINK]','[PREVIOUS_PAGE_LINK]','[PREVIOUS_LINK]','[OUT_OF]','[OF]','[DISPLAY_PREVIOUS_NEXT_LINKS]'), array($next_page_link, $next_link, $previous_page_link, $previous_link, $out_of, $of, $display_previous_next_links), $setting_footer);
+	}
+	
+} elseif(defined('POST_ID') AND is_numeric(POST_ID)) {
+	
+	// Get settings
+	$query_settings = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_news_settings WHERE section_id = '$section_id'");
+	if($query_settings->numRows() > 0) {
+		$fetch_settings = $query_settings->fetchRow();
+		$setting_post_header = ($fetch_settings['post_header']);
+		$setting_post_footer = ($fetch_settings['post_footer']);
+		$setting_comments_header = ($fetch_settings['comments_header']);
+		$setting_comments_loop = ($fetch_settings['comments_loop']);
+		$setting_comments_footer = ($fetch_settings['comments_footer']);
+	} else {
+		$setting_post_header = '';
+		$setting_post_footer = '';
+		$setting_comments_header = '';
+		$setting_comments_loop = '';
+		$setting_comments_footer = '';
+	}
+	
+	// Get page info
+	$query_page = $database->query("SELECT link FROM ".TABLE_PREFIX."pages WHERE page_id = '".PAGE_ID."'");
+	if($query_page->numRows() > 0) {
+		$page = $query_page->fetchRow();
+		$page_link = page_link($page['link']);
+		if(isset($_GET['p']) AND $position > 0) {
+			$page_link .= '?p='.$_GET['p'];
+		}
+		if(isset($_GET['g']) AND is_numeric($_GET['g'])) {
+			if(isset($_GET['p']) AND $position > 0) { $page_link .= '&'; } else { $page_link .= '?'; }
+			$page_link .= 'g='.$_GET['g'];
+		}
+	} else {
+		exit('Page not found');
+	}
+	
+	// Get post info
+	$query_post = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_news_posts WHERE post_id = '".POST_ID."' AND active = '1'");
+	if($query_post->numRows() > 0) {
+		$post = $query_post->fetchRow();
+		if(isset($groups[$post['group_id']]['active']) AND $groups[$post['group_id']]['active'] != false) { // Make sure parent group is active
+			$uid = $post['posted_by']; // User who last modified the post
+			// Workout date and time of last modified post
+			$post_date = gmdate(DATE_FORMAT, $post['posted_when']+TIMEZONE);
+			$post_time = gmdate(TIME_FORMAT, $post['posted_when']+TIMEZONE);
+			// Get group id, title, and image
+			$group_id = $post['group_id'];
+			$group_title = $groups[$group_id]['title'];
+			$group_image = $groups[$group_id]['image'];
+			if($group_image == '') { $display_image = 'none'; } else { $display_image = ''; }
+			if($group_id == 0) { $display_group = 'none'; } else { $display_group = ''; }
+			$vars = array('[PAGE_TITLE]', '[GROUP_ID]', '[GROUP_TITLE]', '[GROUP_IMAGE]', '[DISPLAY_GROUP]', '[DISPLAY_IMAGE]', '[TITLE]', '[SHORT]', '[BACK]', '[DATE]', '[TIME]', '[USER_ID]', '[USERNAME]', '[DISPLAY_NAME]', '[EMAIL]');
+			if(isset($users[$uid]['username']) AND $users[$uid]['username'] != '') {
+				$values = array(PAGE_TITLE, $group_id, $group_title, $group_image, $display_group, $display_image, ($post['title']), ($post['content_short']), $page_link, $post_date, $post_time, $uid, $users[$uid]['username'], $users[$uid]['display_name'], $users[$uid]['email']);
+			} else {
+				$values = array(PAGE_TITLE, $group_id, $group_title, $group_image, $display_group, $display_image, ($post['title']), ($post['content_short']), $page_link, $post_date, $post_time, '', '', '', '');
+			}
+			$post_long = ($post['content_long']);
+		}
+	} else {
+		header('Location: '.WB_URL.'/pages/');
+	}
+	
+	// Print post header
+	echo str_replace($vars, $values, $setting_post_header);
+	
+	// Replace [wblink--PAGE_ID--] with real link
+  	$wb->preprocess($postlong);
+	// Print long
+	echo $post_long;
+	
+	// Print post footer
+	echo str_replace($vars, $values, $setting_post_footer);
+	
+	// Show comments section if we have to
+	if($post['commenting'] == 'private' AND isset($admin) AND $admin->is_authenticated() == true OR $post['commenting'] == 'public') {
+		
+		// Print comments header
+		echo str_replace('[ADD_COMMENT_URL]', WB_URL.'/modules/news/comment.php?id='.POST_ID, $setting_comments_header);
+		
+		// Query for comments
+		$query_comments = $database->query("SELECT title,comment,commented_when,commented_by FROM ".TABLE_PREFIX."mod_news_comments WHERE post_id = '".POST_ID."' ORDER BY commented_when ASC");
+		if($query_comments->numRows() > 0) {
+			while($comment = $query_comments->fetchRow()) {
+				// Display Comments without slashes, but with new-line characters
+				$comment['comment'] = nl2br(($comment['comment']));
+				$comment['title'] = ($comment['title']);
+				// Print comments loop
+				$commented_date = gmdate(DATE_FORMAT, $comment['commented_when']+TIMEZONE);
+				$commented_time = gmdate(TIME_FORMAT, $comment['commented_when']+TIMEZONE);
+				$uid = $comment['commented_by'];
+				$vars = array('[TITLE]','[COMMENT]','[DATE]','[TIME]','[USER_ID]','[USERNAME]','[DISPLAY_NAME]', '[EMAIL]');
+				if(isset($users[$uid]['username']) AND $users[$uid]['username'] != '') {
+					$values = array(($comment['title']), ($comment['comment']), $commented_date, $commented_time, $uid, ($users[$uid]['username']), ($users[$uid]['display_name']), ($users[$uid]['email']));
+				} else {
+					$values = array(($comment['title']), ($comment['comment']), $commented_date, $commented_time, '0', strtolower($TEXT['UNKNOWN']), $TEXT['UNKNOWN'], '');
+				}
+				echo str_replace($vars, $values, $setting_comments_loop);
+			}
+		} else {
+			// Say no comments found
+			if(isset($TEXT['NONE_FOUND'])) {
+				echo $TEXT['NONE_FOUND'].'<br />';
+			} else {
+				echo 'None Found<br />';
+			}
+		}
+		
+		// Print comments footer
+		echo str_replace('[ADD_COMMENT_URL]', WB_URL.'/modules/news/comment.php?id='.POST_ID, $setting_comments_footer);
+		
+	}
+		
+}
+
+?>
Index: trunk/wb/modules/htmlarea/uninstall.php
===================================================================
--- trunk/wb/modules/htmlarea/uninstall.php	(revision 237)
+++ trunk/wb/modules/htmlarea/uninstall.php	(revision 238)
@@ -1,32 +1,32 @@
-<?php
-
-// $Id$
-
-/*
-
- Website Baker Project <http://www.websitebaker.org/>
- Copyright (C) 2004-2005, Ryan Djurovich
-
- Website Baker is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- Website Baker is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Website Baker; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-*/
-
-// Must include code to stop this file being access directly
-if(defined('WB_PATH') == false) { exit("Cannot access this file directly"); }
-
-// Delete the editor directory
-rm_full_dir(WB_PATH.'/modules/htmlarea/htmlarea');
-
-?>
+<?php
+
+// $Id$
+
+/*
+
+ Website Baker Project <http://www.websitebaker.org/>
+ Copyright (C) 2004-2005, Ryan Djurovich
+
+ Website Baker is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ Website Baker is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Website Baker; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+*/
+
+// Must include code to stop this file being access directly
+if(defined('WB_PATH') == false) { exit("Cannot access this file directly"); }
+
+// Delete the editor directory
+rm_full_dir(WB_PATH.'/modules/htmlarea/htmlarea');
+
+?>
Index: trunk/wb/modules/htmlarea/info.php
===================================================================
--- trunk/wb/modules/htmlarea/info.php	(revision 237)
+++ trunk/wb/modules/htmlarea/info.php	(revision 238)
@@ -1,35 +1,35 @@
-<?php
-
-// $Id$
-
-/*
-
- Website Baker Project <http://www.websitebaker.org/>
- Copyright (C) 2004-2005, 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
-
-*/
-
-$module_directory = 'htmlarea';
-$module_name = 'HTMLArea';
-$module_function = 'wysiwyg';
-$module_version = '2.6';
-$module_platform = '2.6.x';
-$module_author = 'Ryan Djurovich, Stefan Braunewell';
-$module_license = 'GNU General Public License';
-$module_description = 'This module allows you to edit the contents of a page using HTMLArea Editor.';
-
-?>
+<?php
+
+// $Id$
+
+/*
+
+ Website Baker Project <http://www.websitebaker.org/>
+ Copyright (C) 2004-2005, 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
+
+*/
+
+$module_directory = 'htmlarea';
+$module_name = 'HTMLArea';
+$module_function = 'wysiwyg';
+$module_version = '2.6';
+$module_platform = '2.6.x';
+$module_author = 'Ryan Djurovich, Stefan Braunewell';
+$module_license = 'GNU General Public License';
+$module_description = 'This module allows you to edit the contents of a page using HTMLArea Editor.';
+
+?>
Index: trunk/wb/modules/htmlarea/include.php
===================================================================
--- trunk/wb/modules/htmlarea/include.php	(revision 237)
+++ trunk/wb/modules/htmlarea/include.php	(revision 238)
@@ -1,57 +1,57 @@
-<?php
-
-// $Id$
-
-/*
-
- Website Baker Project <http://www.websitebaker.org/>
- Copyright (C) 2004-2005, 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
-
-*/
-
-$WB_DIRECTORY = substr(WB_PATH, strlen($_SERVER['DOCUMENT_ROOT'])).'/media/';
-
-?>
-
-<script type="text/javascript">
-  _editor_url = "<?php echo WB_URL;?>/modules/htmlarea/htmlarea/";
-  _editor_lang = "en";
-</script>
-
-<script type="text/javascript" src="<?php echo WB_URL;?>/modules/htmlarea/htmlarea/htmlarea.js"></script>
-<script type="text/javascript">
-	HTMLArea.loadPlugin("ContextMenu");
-	HTMLArea.loadPlugin("TableOperations");
-	window.onload = function() {
-<?php
-	foreach($id_list AS $textarea_id)
-	{
-		echo 'var editor = new HTMLArea("'.$textarea_id.'"); '
-		.'editor.registerPlugin(ContextMenu);'
-		.'editor.registerPlugin(TableOperations);'
-		.'editor.config.pageStyle = "body { '.stripslashes(WYSIWYG_STYLE).' }";'
-		.'editor.generate();';
-	}
-?>
-}
-</script>
-
-<?php
-	function show_wysiwyg_editor($name,$id,$content,$width,$height) {
-		echo '<textarea name="'.$name.'" id="'.$id.'" style="width: '.$width.'; height: '.$height.';">'.$content.'</textarea>';
-	}
-?>
+<?php
+
+// $Id$
+
+/*
+
+ Website Baker Project <http://www.websitebaker.org/>
+ Copyright (C) 2004-2005, 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
+
+*/
+
+$WB_DIRECTORY = substr(WB_PATH, strlen($_SERVER['DOCUMENT_ROOT'])).'/media/';
+
+?>
+
+<script type="text/javascript">
+  _editor_url = "<?php echo WB_URL;?>/modules/htmlarea/htmlarea/";
+  _editor_lang = "en";
+</script>
+
+<script type="text/javascript" src="<?php echo WB_URL;?>/modules/htmlarea/htmlarea/htmlarea.js"></script>
+<script type="text/javascript">
+	HTMLArea.loadPlugin("ContextMenu");
+	HTMLArea.loadPlugin("TableOperations");
+	window.onload = function() {
+<?php
+	foreach($id_list AS $textarea_id)
+	{
+		echo 'var editor = new HTMLArea("'.$textarea_id.'"); '
+		.'editor.registerPlugin(ContextMenu);'
+		.'editor.registerPlugin(TableOperations);'
+		.'editor.config.pageStyle = "body { '.stripslashes(WYSIWYG_STYLE).' }";'
+		.'editor.generate();';
+	}
+?>
+}
+</script>
+
+<?php
+	function show_wysiwyg_editor($name,$id,$content,$width,$height) {
+		echo '<textarea name="'.$name.'" id="'.$id.'" style="width: '.$width.'; height: '.$height.';">'.$content.'</textarea>';
+	}
+?>
Index: trunk/wb/modules/htmlarea/install.php
===================================================================
--- trunk/wb/modules/htmlarea/install.php	(revision 237)
+++ trunk/wb/modules/htmlarea/install.php	(revision 238)
@@ -1,51 +1,51 @@
-<?php
-
-// $Id$
-
-/*
-
- Website Baker Project <http://www.websitebaker.org/>
- Copyright (C) 2004-2005, 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
-
-*/
-
-if(defined('WB_URL')) {
-	
-	// Set the filename of the actual editor file
-	$editor_file = $module_dir.'/htmlarea.zip';
-	
-	if(file_exists($editor_file)) {
-	
-		// Setup the PclZip object
-		$editor_archive = new PclZip($editor_file);
-
-		// Unzip to module dir
-		$list = $editor_archive->extract(PCLZIP_OPT_PATH, $module_dir);
-		if(!$list) {
-			$admin->print_error($MESSAGE['GENERIC']['CANNOT_UNZIP']);
-		}
-		// Delete the zip file
-		if(file_exists($editor_file)) { unlink($editor_file); }
-	
-		// Chmod all the editors files
-		chmod_directory_contents($module_dir.'/htmlarea', OCTAL_FILE_MODE);
-	
-	}
-	
-}
-
-?>
+<?php
+
+// $Id$
+
+/*
+
+ Website Baker Project <http://www.websitebaker.org/>
+ Copyright (C) 2004-2005, 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
+
+*/
+
+if(defined('WB_URL')) {
+	
+	// Set the filename of the actual editor file
+	$editor_file = $module_dir.'/htmlarea.zip';
+	
+	if(file_exists($editor_file)) {
+	
+		// Setup the PclZip object
+		$editor_archive = new PclZip($editor_file);
+
+		// Unzip to module dir
+		$list = $editor_archive->extract(PCLZIP_OPT_PATH, $module_dir);
+		if(!$list) {
+			$admin->print_error($MESSAGE['GENERIC']['CANNOT_UNZIP']);
+		}
+		// Delete the zip file
+		if(file_exists($editor_file)) { unlink($editor_file); }
+	
+		// Chmod all the editors files
+		chmod_directory_contents($module_dir.'/htmlarea', OCTAL_FILE_MODE);
+	
+	}
+	
+}
+
+?>
Index: trunk/wb/modules/htmlarea/htmlarea/license.txt
===================================================================
--- trunk/wb/modules/htmlarea/htmlarea/license.txt	(revision 237)
+++ trunk/wb/modules/htmlarea/htmlarea/license.txt	(revision 238)
@@ -1,30 +1,30 @@
-htmlArea License (based on BSD license)
-Copyright (c) 2002-2004, interactivetools.com, inc.
-Copyright (c) 2003-2004 dynarch.com
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
-1) Redistributions of source code must retain the above copyright notice,
-   this list of conditions and the following disclaimer.
-
-2) Redistributions in binary form must reproduce the above copyright notice,
-   this list of conditions and the following disclaimer in the documentation
-   and/or other materials provided with the distribution.
-
-3) Neither the name of interactivetools.com, inc. nor the names of its
-   contributors may be used to endorse or promote products derived from this
-   software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGE.
+htmlArea License (based on BSD license)
+Copyright (c) 2002-2004, interactivetools.com, inc.
+Copyright (c) 2003-2004 dynarch.com
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+1) Redistributions of source code must retain the above copyright notice,
+   this list of conditions and the following disclaimer.
+
+2) Redistributions in binary form must reproduce the above copyright notice,
+   this list of conditions and the following disclaimer in the documentation
+   and/or other materials provided with the distribution.
+
+3) Neither the name of interactivetools.com, inc. nor the names of its
+   contributors may be used to endorse or promote products derived from this
+   software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
Index: trunk/wb/modules/htmlarea/index.php
===================================================================
--- trunk/wb/modules/htmlarea/index.php	(revision 237)
+++ trunk/wb/modules/htmlarea/index.php	(revision 238)
@@ -1,28 +1,28 @@
-<?php
-
-// $Id$
-
-/*
-
- Website Baker Project <http://www.websitebaker.org/>
- Copyright (C) 2004-2005, 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
-
-*/
-
-header('Location: ../index.php');
-
-?>
\ No newline at end of file
+<?php
+
+// $Id$
+
+/*
+
+ Website Baker Project <http://www.websitebaker.org/>
+ Copyright (C) 2004-2005, 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
+
+*/
+
+header('Location: ../index.php');
+
+?>
Index: trunk/wb/account/preferences_form.php
===================================================================
--- trunk/wb/account/preferences_form.php	(revision 237)
+++ trunk/wb/account/preferences_form.php	(revision 238)
@@ -1,231 +1,231 @@
-<?php
-
-// $Id$
-
-/*
-
- Website Baker Project <http://www.websitebaker.org/>
- Copyright (C) 2004-2005, 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
-
-*/
-
-if(!defined('WB_URL')) {
-	header('Location: ../index.php');
-}
-
-?>
-
-<h1>&nbsp;<?php echo $HEADING['MY_SETTINGS']; ?></h1>
-
-<form name="user" action="<?php echo WB_URL.'/account/preferences.php'; ?>" method="post" style="margin-bottom: 5px;">
-<input type="hidden" name="user_id" value="{USER_ID}" />
-
-<table cellpadding="5" cellspacing="0" border="0" width="97%">
-<tr>
-	<td width="140"><?php echo $TEXT['DISPLAY_NAME']; ?>:</td>
-	<td class="value_input">
-		<input type="text" name="display_name" style="width: 380px;" maxlength="255" value="<?php echo $admin->get_display_name(); ?>" />
-	</td>
-</tr>
-<tr>
-	<td><?php echo $TEXT['LANGUAGE']; ?>:</td>
-	<td>
-		<select name="language" style="width: 380px;">
-		<?php
-		// Insert language values
-		if($handle = opendir(WB_PATH.'/languages/')) {
-		   while (false !== ($file = readdir($handle))) {
-				if($file != '.' AND $file != '..' AND $file != '.svn' AND $file != 'index.php') {
-					// Get language name
-					require(WB_PATH.'/languages/'.$file);
-					// Check if it is selected
-					if(LANGUAGE == $language_code) {
-						?>
-						<option value="<?php echo $language_code; ?>" selected><?php echo $language_name.' ('.$language_code.')'; ?></option>
-						<?php
-					} else {
-						?>
-						<option value="<?php echo $language_code; ?>"><?php echo $language_name.' ('.$language_code.')'; ?></option>
-						<?php
-					}
-				}
-			}
-			// Restore language to original file
-			require(WB_PATH.'/languages/'.LANGUAGE.'.php');
-		}
-		?>
-		</select>
-	</td>
-</tr>
-<tr>
-	<td><?php echo $TEXT['TIMEZONE']; ?>:</td>
-	<td>
-		<select name="timezone" style="width: 380px;">
-			<option value="-20"><?php echo $TEXT['PLEASE_SELECT']; ?>...</option>
-			<?php
-			// Insert default timezone values
-			require_once(ADMIN_PATH.'/interface/timezones.php');
-			foreach($TIMEZONES AS $hour_offset => $title) {
-				if($admin->get_timezone() == $hour_offset*60*60) {
-					?>
-					<option value="<?php echo $hour_offset; ?>" selected><?php echo $title; ?></option>
-					<?php
-				} else {
-					?>
-					<option value="<?php echo $hour_offset; ?>"><?php echo $title; ?></option>
-					<?php
-				}
-			}
-			?>
-		</select>
-	</td>
-</tr>
-<tr>
-	<td><?php echo $TEXT['DATE_FORMAT']; ?>:</td>
-	<td>
-		<select name="date_format" style="width: 98%;">
-			<option value="">Please select...</option>
-			<?php
-			// Insert date format list
-			$user_time = true;
-			require_once(ADMIN_PATH.'/interface/date_formats.php');
-			foreach($DATE_FORMATS AS $format => $title) {
-				$format = str_replace('|', ' ', $format); // Add's white-spaces (not able to be stored in array key)
-				if($format != 'system_default') {
-					$value = $format;
-				} else {
-					$value = '';
-				}
-				if(DATE_FORMAT == $format AND !isset($_SESSION['USE_DEFAULT_DATE_FORMAT'])) {
-					$selected = ' selected';
-				} elseif($format == 'system_default' AND isset($_SESSION['USE_DEFAULT_DATE_FORMAT'])) {
-					$selected = ' selected';
-				} else {
-					$selected = '';
-				}
-				echo '<option value="'.$value.'"'.$selected.'>'.$title.'</option>';
-			}
-			?>>
-		</select>
-	</td>
-</tr>
-<tr>
-	<td><?php echo $TEXT['TIME_FORMAT']; ?>:</td>
-	<td>
-		<select name="time_format" style="width: 98%;">
-			<option value="">Please select...</option>
-			<?php
-			// Insert time format list
-			$user_time = true;
-			require_once(ADMIN_PATH.'/interface/time_formats.php');
-			foreach($TIME_FORMATS AS $format => $title) {
-				$format = str_replace('|', ' ', $format); // Add's white-spaces (not able to be stored in array key)
-				if($format != 'system_default') {
-					$value = $format;
-				} else {
-					$value = '';
-				}
-				if(TIME_FORMAT == $format AND !isset($_SESSION['USE_DEFAULT_TIME_FORMAT'])) {
-					$selected = ' selected';
-				} elseif($format == 'system_default' AND isset($_SESSION['USE_DEFAULT_TIME_FORMAT'])) {
-					$selected = ' selected';
-				} else {
-					$selected = '';
-				}
-				echo '<option value="'.$value.'"'.$selected.'>'.$title.'</option>';
-			}
-			?>
-		</select>
-	</td>
-</tr>
-<tr>
-	<td>&nbsp;</td>
-	<td>
-		<input type="submit" name="submit" value="<?php echo $TEXT['SAVE']; ?>" />
-		<input type="reset" name="reset" value="<?php echo $TEXT['RESET']; ?>" />
-	</td>
-</tr>
-</table>
-
-</form>
-
-
-<h1>&nbsp;<?php echo $HEADING['MY_EMAIL']; ?></h1>
-
-<form name="email" action="<?php echo WB_URL.'/account/preferences.php'; ?>" method="post" style="margin-bottom: 5px;">
-<input type="hidden" name="user_id" value="{USER_ID}" />
-
-<table cellpadding="5" cellspacing="0" border="0" width="97%">
-<tr>
-	<td width="140"><?php echo $TEXT['CURRENT_PASSWORD']; ?>:</td>
-	<td>
-		<input type="password" name="current_password" style="width: 380px;" />
-	</td>
-</tr>
-<tr>
-	<td><?php echo $TEXT['EMAIL']; ?>:</td>
-	<td class="value_input">
-		<input type="text" name="email" style="width: 380px;" maxlength="255" value="<?php echo $admin->get_email(); ?>" />
-	</td>
-</tr>
-<tr>
-	<td>&nbsp;</td>
-	<td>
-		<input type="submit" name="submit" value="<?php echo $TEXT['SAVE']; ?>" />
-		<input type="reset" name="reset" value="<?php echo $TEXT['RESET']; ?>" />
-	</td>
-</tr>
-</table>
-
-</form>
-
-
-<h1>&nbsp;<?php echo $HEADING['MY_PASSWORD']; ?></h1>
-
-<form name="user" action="<?php echo WB_URL.'/account/preferences.php'; ?>" method="post">
-<input type="hidden" name="user_id" value="{USER_ID}" />
-
-<table cellpadding="5" cellspacing="0" border="0" width="97%">
-<tr>
-	<td width="140"><?php echo $TEXT['CURRENT_PASSWORD']; ?>:</td>
-	<td>
-		<input type="password" name="current_password" style="width: 380px;" />
-	</td>
-</tr>
-<tr>
-	<td><?php echo $TEXT['NEW_PASSWORD']; ?>:</td>
-	<td>
-		<input type="password" name="new_password" style="width: 380px;" />
-	</td>
-</tr>
-<tr>
-	<td><?php echo $TEXT['RETYPE_NEW_PASSWORD']; ?>:</td>
-	<td>
-		<input type="password" name="new_password2" style="width: 380px;" />
-	</td>
-</tr>
-</tr>
-<tr>
-	<td>&nbsp;</td>
-	<td>
-		<input type="submit" name="submit" value="<?php echo $TEXT['SAVE']; ?>" />
-		<input type="reset" name="reset" value="<?php echo $TEXT['RESET']; ?>" />
-	</td>
-</tr>
-</table>
-
-</form>
+<?php
+
+// $Id$
+
+/*
+
+ Website Baker Project <http://www.websitebaker.org/>
+ Copyright (C) 2004-2005, 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
+
+*/
+
+if(!defined('WB_URL')) {
+	header('Location: ../index.php');
+}
+
+?>
+
+<h1>&nbsp;<?php echo $HEADING['MY_SETTINGS']; ?></h1>
+
+<form name="user" action="<?php echo WB_URL.'/account/preferences.php'; ?>" method="post" style="margin-bottom: 5px;">
+<input type="hidden" name="user_id" value="{USER_ID}" />
+
+<table cellpadding="5" cellspacing="0" border="0" width="97%">
+<tr>
+	<td width="140"><?php echo $TEXT['DISPLAY_NAME']; ?>:</td>
+	<td class="value_input">
+		<input type="text" name="display_name" style="width: 380px;" maxlength="255" value="<?php echo $admin->get_display_name(); ?>" />
+	</td>
+</tr>
+<tr>
+	<td><?php echo $TEXT['LANGUAGE']; ?>:</td>
+	<td>
+		<select name="language" style="width: 380px;">
+		<?php
+		// Insert language values
+		if($handle = opendir(WB_PATH.'/languages/')) {
+		   while (false !== ($file = readdir($handle))) {
+				if($file != '.' AND $file != '..' AND $file != '.svn' AND $file != 'index.php') {
+					// Get language name
+					require(WB_PATH.'/languages/'.$file);
+					// Check if it is selected
+					if(LANGUAGE == $language_code) {
+						?>
+						<option value="<?php echo $language_code; ?>" selected><?php echo $language_name.' ('.$language_code.')'; ?></option>
+						<?php
+					} else {
+						?>
+						<option value="<?php echo $language_code; ?>"><?php echo $language_name.' ('.$language_code.')'; ?></option>
+						<?php
+					}
+				}
+			}
+			// Restore language to original file
+			require(WB_PATH.'/languages/'.LANGUAGE.'.php');
+		}
+		?>
+		</select>
+	</td>
+</tr>
+<tr>
+	<td><?php echo $TEXT['TIMEZONE']; ?>:</td>
+	<td>
+		<select name="timezone" style="width: 380px;">
+			<option value="-20"><?php echo $TEXT['PLEASE_SELECT']; ?>...</option>
+			<?php
+			// Insert default timezone values
+			require_once(ADMIN_PATH.'/interface/timezones.php');
+			foreach($TIMEZONES AS $hour_offset => $title) {
+				if($admin->get_timezone() == $hour_offset*60*60) {
+					?>
+					<option value="<?php echo $hour_offset; ?>" selected><?php echo $title; ?></option>
+					<?php
+				} else {
+					?>
+					<option value="<?php echo $hour_offset; ?>"><?php echo $title; ?></option>
+					<?php
+				}
+			}
+			?>
+		</select>
+	</td>
+</tr>
+<tr>
+	<td><?php echo $TEXT['DATE_FORMAT']; ?>:</td>
+	<td>
+		<select name="date_format" style="width: 98%;">
+			<option value="">Please select...</option>
+			<?php
+			// Insert date format list
+			$user_time = true;
+			require_once(ADMIN_PATH.'/interface/date_formats.php');
+			foreach($DATE_FORMATS AS $format => $title) {
+				$format = str_replace('|', ' ', $format); // Add's white-spaces (not able to be stored in array key)
+				if($format != 'system_default') {
+					$value = $format;
+				} else {
+					$value = '';
+				}
+				if(DATE_FORMAT == $format AND !isset($_SESSION['USE_DEFAULT_DATE_FORMAT'])) {
+					$selected = ' selected';
+				} elseif($format == 'system_default' AND isset($_SESSION['USE_DEFAULT_DATE_FORMAT'])) {
+					$selected = ' selected';
+				} else {
+					$selected = '';
+				}
+				echo '<option value="'.$value.'"'.$selected.'>'.$title.'</option>';
+			}
+			?>>
+		</select>
+	</td>
+</tr>
+<tr>
+	<td><?php echo $TEXT['TIME_FORMAT']; ?>:</td>
+	<td>
+		<select name="time_format" style="width: 98%;">
+			<option value="">Please select...</option>
+			<?php
+			// Insert time format list
+			$user_time = true;
+			require_once(ADMIN_PATH.'/interface/time_formats.php');
+			foreach($TIME_FORMATS AS $format => $title) {
+				$format = str_replace('|', ' ', $format); // Add's white-spaces (not able to be stored in array key)
+				if($format != 'system_default') {
+					$value = $format;
+				} else {
+					$value = '';
+				}
+				if(TIME_FORMAT == $format AND !isset($_SESSION['USE_DEFAULT_TIME_FORMAT'])) {
+					$selected = ' selected';
+				} elseif($format == 'system_default' AND isset($_SESSION['USE_DEFAULT_TIME_FORMAT'])) {
+					$selected = ' selected';
+				} else {
+					$selected = '';
+				}
+				echo '<option value="'.$value.'"'.$selected.'>'.$title.'</option>';
+			}
+			?>
+		</select>
+	</td>
+</tr>
+<tr>
+	<td>&nbsp;</td>
+	<td>
+		<input type="submit" name="submit" value="<?php echo $TEXT['SAVE']; ?>" />
+		<input type="reset" name="reset" value="<?php echo $TEXT['RESET']; ?>" />
+	</td>
+</tr>
+</table>
+
+</form>
+
+
+<h1>&nbsp;<?php echo $HEADING['MY_EMAIL']; ?></h1>
+
+<form name="email" action="<?php echo WB_URL.'/account/preferences.php'; ?>" method="post" style="margin-bottom: 5px;">
+<input type="hidden" name="user_id" value="{USER_ID}" />
+
+<table cellpadding="5" cellspacing="0" border="0" width="97%">
+<tr>
+	<td width="140"><?php echo $TEXT['CURRENT_PASSWORD']; ?>:</td>
+	<td>
+		<input type="password" name="current_password" style="width: 380px;" />
+	</td>
+</tr>
+<tr>
+	<td><?php echo $TEXT['EMAIL']; ?>:</td>
+	<td class="value_input">
+		<input type="text" name="email" style="width: 380px;" maxlength="255" value="<?php echo $admin->get_email(); ?>" />
+	</td>
+</tr>
+<tr>
+	<td>&nbsp;</td>
+	<td>
+		<input type="submit" name="submit" value="<?php echo $TEXT['SAVE']; ?>" />
+		<input type="reset" name="reset" value="<?php echo $TEXT['RESET']; ?>" />
+	</td>
+</tr>
+</table>
+
+</form>
+
+
+<h1>&nbsp;<?php echo $HEADING['MY_PASSWORD']; ?></h1>
+
+<form name="user" action="<?php echo WB_URL.'/account/preferences.php'; ?>" method="post">
+<input type="hidden" name="user_id" value="{USER_ID}" />
+
+<table cellpadding="5" cellspacing="0" border="0" width="97%">
+<tr>
+	<td width="140"><?php echo $TEXT['CURRENT_PASSWORD']; ?>:</td>
+	<td>
+		<input type="password" name="current_password" style="width: 380px;" />
+	</td>
+</tr>
+<tr>
+	<td><?php echo $TEXT['NEW_PASSWORD']; ?>:</td>
+	<td>
+		<input type="password" name="new_password" style="width: 380px;" />
+	</td>
+</tr>
+<tr>
+	<td><?php echo $TEXT['RETYPE_NEW_PASSWORD']; ?>:</td>
+	<td>
+		<input type="password" name="new_password2" style="width: 380px;" />
+	</td>
+</tr>
+</tr>
+<tr>
+	<td>&nbsp;</td>
+	<td>
+		<input type="submit" name="submit" value="<?php echo $TEXT['SAVE']; ?>" />
+		<input type="reset" name="reset" value="<?php echo $TEXT['RESET']; ?>" />
+	</td>
+</tr>
+</table>
+
+</form>
Index: trunk/wb/framework/class.wb.php
===================================================================
--- trunk/wb/framework/class.wb.php	(revision 237)
+++ trunk/wb/framework/class.wb.php	(revision 238)
@@ -36,10 +36,10 @@
 class wb
 {
 	// General initialization function 
-	// performed when frontend or backend is loaded.
+	// performed when frontend or backend is loaded.
 	function wb() {
-	}
-
+	}
+
 	// Check whether we should show a page or not (for front-end)
 	function show_page($page) {
 		// First check if the page is set to private
@@ -72,9 +72,8 @@
 			return false;
 		}
 	}
-
-	// Modified addslashes function which takes into account magic_quotes
-	function add_slashes($input) {
+	// Modified addslashes function which takes into account magic_quotes
+	function add_slashes($input) {
 		if ( get_magic_quotes_gpc() || ( !is_string($input) ) ) {
 			return $input;
 		}
@@ -82,7 +81,7 @@
 		return $output;
 	}
 
-	// Ditto for stripslashes
+	// Ditto for stripslashes
 	function strip_slashes($input) {
 		if ( !get_magic_quotes_gpc() || ( !is_string($input) ) ) {
 			return $input;
@@ -91,7 +90,7 @@
 		return $output;
 	}
 
-	// Escape backslashes for use with mySQL LIKE strings
+	// Escape backslashes for use with mySQL LIKE strings
 	function escape_backslashes($input) {
 		return str_replace("\\","\\\\",$input);
 	}
Index: trunk/wb/framework/initialize.php
===================================================================
--- trunk/wb/framework/initialize.php	(revision 237)
+++ trunk/wb/framework/initialize.php	(revision 238)
@@ -1,103 +1,103 @@
-<?php
-
-// $Id$
-
-/*
-
- Website Baker Project <http://www.websitebaker.org/>
- Copyright (C) 2004-2005, 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
-
-*/
- 
-if (file_exists(WB_PATH.'/framework/class.database.php'))
-{
-	require_once(WB_PATH.'/framework/class.database.php');
-		
-	// Create database class
-	$database = new database();
-	
-	set_magic_quotes_runtime(0);
-	
-	// Get website settings (title, keywords, description, header, and footer)
-	$query_settings = "SELECT name,value FROM ".TABLE_PREFIX."settings";
-	$get_settings = $database->query($query_settings);
-	if($database->is_error()) { die($database->get_error()); }
-	if($get_settings->numRows() == 0) { die("Settings not found"); }
-	while($setting = $get_settings->fetchRow()) {
-		$setting_name=strtoupper($setting['name']);
-		$setting_value=$setting['value'];
-		if ($setting_value=='false')
-			$setting_value=false;
-		if ($setting_value=='true')
-			$setting_value=true;
-		define($setting_name,$setting_value);
-	}
-	$string_file_mode = STRING_FILE_MODE;
-	define('OCTAL_FILE_MODE',(int) octdec($string_file_mode));
-	$string_dir_mode = STRING_DIR_MODE;
-	define('OCTAL_DIR_MODE',(int) octdec($string_dir_mode));
-	
-	// Start a session
-	if(!defined('SESSION_STARTED')) {
-		session_name(APP_NAME.'_session_id');
-		session_start();
-		define('SESSION_STARTED', true);
-	}
-	
-	// Get users language
-	if(isset($_GET['lang']) AND $_GET['lang'] != '' AND !is_numeric($_GET['lang']) AND strlen($_GET['lang']) == 2) {
-	  	define('LANGUAGE', strtoupper($_GET['lang']));
-		$_SESSION['LANGUAGE']=LANGUAGE;
-	} else {
-		if(isset($_SESSION['LANGUAGE']) AND $_SESSION['LANGUAGE'] != '') {
-			define('LANGUAGE', $_SESSION['LANGUAGE']);
-		} else {
-			define('LANGUAGE', DEFAULT_LANGUAGE);
-		}
-	}
-	
-	// Load Language file
-	if(!defined('LANGUAGE_LOADED')) {
-		if(!file_exists(WB_PATH.'/languages/'.LANGUAGE.'.php')) {
-			exit('Error loading language file '.LANGUAGE.', please check configuration');
-		} else {
-			require_once(WB_PATH.'/languages/'.LANGUAGE.'.php');
-		}
-	}
-	
-	// Get users timezone
-	if(isset($_SESSION['TIMEZONE'])) {
-		define('TIMEZONE', $_SESSION['TIMEZONE']);
-	} else {
-		define('TIMEZONE', DEFAULT_TIMEZONE);
-	}
-	// Get users date format
-	if(isset($_SESSION['DATE_FORMAT'])) {
-		define('DATE_FORMAT', $_SESSION['DATE_FORMAT']);
-	} else {
-		define('DATE_FORMAT', DEFAULT_DATE_FORMAT);
-	}
-	// Get users time format
-	if(isset($_SESSION['TIME_FORMAT'])) {
-		define('TIME_FORMAT', $_SESSION['TIME_FORMAT']);
-	} else {
-		define('TIME_FORMAT', DEFAULT_TIME_FORMAT);
-	}
-		
-}
-
-?>
+<?php
+
+// $Id$
+
+/*
+
+ Website Baker Project <http://www.websitebaker.org/>
+ Copyright (C) 2004-2005, 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
+
+*/
+ 
+if (file_exists(WB_PATH.'/framework/class.database.php'))
+{
+	require_once(WB_PATH.'/framework/class.database.php');
+		
+	// Create database class
+	$database = new database();
+	
+	set_magic_quotes_runtime(0);
+	
+	// Get website settings (title, keywords, description, header, and footer)
+	$query_settings = "SELECT name,value FROM ".TABLE_PREFIX."settings";
+	$get_settings = $database->query($query_settings);
+	if($database->is_error()) { die($database->get_error()); }
+	if($get_settings->numRows() == 0) { die("Settings not found"); }
+	while($setting = $get_settings->fetchRow()) {
+		$setting_name=strtoupper($setting['name']);
+		$setting_value=$setting['value'];
+		if ($setting_value=='false')
+			$setting_value=false;
+		if ($setting_value=='true')
+			$setting_value=true;
+		define($setting_name,$setting_value);
+	}
+	$string_file_mode = STRING_FILE_MODE;
+	define('OCTAL_FILE_MODE',(int) octdec($string_file_mode));
+	$string_dir_mode = STRING_DIR_MODE;
+	define('OCTAL_DIR_MODE',(int) octdec($string_dir_mode));
+	
+	// Start a session
+	if(!defined('SESSION_STARTED')) {
+		session_name(APP_NAME.'_session_id');
+		session_start();
+		define('SESSION_STARTED', true);
+	}
+	
+	// Get users language
+	if(isset($_GET['lang']) AND $_GET['lang'] != '' AND !is_numeric($_GET['lang']) AND strlen($_GET['lang']) == 2) {
+	  	define('LANGUAGE', strtoupper($_GET['lang']));
+		$_SESSION['LANGUAGE']=LANGUAGE;
+	} else {
+		if(isset($_SESSION['LANGUAGE']) AND $_SESSION['LANGUAGE'] != '') {
+			define('LANGUAGE', $_SESSION['LANGUAGE']);
+		} else {
+			define('LANGUAGE', DEFAULT_LANGUAGE);
+		}
+	}
+	
+	// Load Language file
+	if(!defined('LANGUAGE_LOADED')) {
+		if(!file_exists(WB_PATH.'/languages/'.LANGUAGE.'.php')) {
+			exit('Error loading language file '.LANGUAGE.', please check configuration');
+		} else {
+			require_once(WB_PATH.'/languages/'.LANGUAGE.'.php');
+		}
+	}
+	
+	// Get users timezone
+	if(isset($_SESSION['TIMEZONE'])) {
+		define('TIMEZONE', $_SESSION['TIMEZONE']);
+	} else {
+		define('TIMEZONE', DEFAULT_TIMEZONE);
+	}
+	// Get users date format
+	if(isset($_SESSION['DATE_FORMAT'])) {
+		define('DATE_FORMAT', $_SESSION['DATE_FORMAT']);
+	} else {
+		define('DATE_FORMAT', DEFAULT_DATE_FORMAT);
+	}
+	// Get users time format
+	if(isset($_SESSION['TIME_FORMAT'])) {
+		define('TIME_FORMAT', $_SESSION['TIME_FORMAT']);
+	} else {
+		define('TIME_FORMAT', DEFAULT_TIME_FORMAT);
+	}
+		
+}
+
+?>
Index: trunk/wb/framework/functions.php
===================================================================
--- trunk/wb/framework/functions.php	(revision 237)
+++ trunk/wb/framework/functions.php	(revision 238)
@@ -1,759 +1,759 @@
-<?php
-
-// $Id$
-
-/*
-
- Website Baker Project <http://www.websitebaker.org/>
- Copyright (C) 2004-2005, 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
-
-*/
-
-/*
-
-Website Baker functions file
-This file contains general functions used in Website Baker
-
-*/
-
-// Stop this file from being accessed directly
-if(!defined('WB_URL')) {
-	header('Location: ../index.php');
-}
-
-// Define that this file has been loaded
-define('FUNCTIONS_FILE_LOADED', true);
-
-// Function to remove a non-empty directory
-function rm_full_dir($directory)
-{
-    // If suplied dirname is a file then unlink it
-    if (is_file($directory)) {
-        return unlink($directory);
-    }
-
-    // Empty the folder
-    $dir = dir($directory);
-    while (false !== $entry = $dir->read()) {
-        // Skip pointers
-        if ($entry == '.' || $entry == '..') {
-            continue;
-        }
-
-        // Deep delete directories      
-        if (is_dir("$directory/$entry")) {
-            rm_full_dir("$directory/$entry");
-        } else {
-            unlink("$directory/$entry");
-        }
-    }
-
-    // Now delete the folder
-    $dir->close();
-    return rmdir($directory);
-}
-
-// Function to open a directory and add to a dir list
-function directory_list($directory) {
-	
-	$list = array();
-
-	// Open the directory then loop through its contents
-	$dir = dir($directory);
-	while (false !== $entry = $dir->read()) {
-		// Skip pointers
-		if(substr($entry, 0, 1) == '.' || $entry == '.svn') {
-			continue;
-		}
-		// Add dir and contents to list
-		if (is_dir("$directory/$entry")) {
-			$list = array_merge($list, directory_list("$directory/$entry"));
-			$list[] = "$directory/$entry";
-		}
-	}
-
-	// Now return the list
-	return $list;
-}
-
-// Function to open a directory and add to a dir list
-function chmod_directory_contents($directory, $file_mode) {
-	
-	// Set the umask to 0
-	$umask = umask(0);
-	
-	// Open the directory then loop through its contents
-	$dir = dir($directory);
-	while (false !== $entry = $dir->read()) {
-		// Skip pointers
-		if(substr($entry, 0, 1) == '.' || $entry == '.svn') {
-			continue;
-		}
-		// Chmod the sub-dirs contents
-		if(is_dir("$directory/$entry")) {
-			chmod_directory_contents("$directory/$entry", $file_mode);
-		}
-		change_mode($directory.'/'.$entry, 'file');
-	}
-	
-	// Restore the umask
-	umask($umask);
-
-}
-
-// Function to open a directory and add to a file list
-function file_list($directory, $skip = array()) {
-	
-	$list = array();
-	$skip_file = false;
-	
-	// Open the directory then loop through its contents
-	$dir = dir($directory);
-	while (false !== $entry = $dir->read()) {
-		// Skip pointers
-		if($entry == '.' || $entry == '..') {
-			$skip_file = true;
-		}
-		// Check if we to skip anything else
-		if($skip != array()) {
-			foreach($skip AS $skip_name) {
-				if($entry == $skip_name) {
-					$skip_file = true;
-				}
-			}
-		}
-		// Add dir and contents to list
-		if($skip_file != true AND is_file("$directory/$entry")) {
-			$list[] = "$directory/$entry";
-		}
-		
-		// Reset the skip file var
-		$skip_file = false;
-	}
-
-	// Now delete the folder
-	return $list;
-}
-
-// Function to get a list of home folders not to show
-function get_home_folders() {
-	global $database, $admin;
-	$home_folders = array();
-	// Only return home folders is this feature is enabled
-	if(HOME_FOLDERS) {
-		$query_home_folders = $database->query("SELECT home_folder FROM ".TABLE_PREFIX."users WHERE home_folder != '".$admin->get_home_folder()."'");
-		if($query_home_folders->numRows() > 0) {
-			while($folder = $query_home_folders->fetchRow()) {
-				$home_folders[$folder['home_folder']] = $folder['home_folder'];
-			}
-		}
-		function remove_home_subs($directory = '/', $home_folders) {
-			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(substr($file, 0, 1) != '.' AND $file != '.svn' AND $file != 'index.php') {
-						if(is_dir(WB_PATH.MEDIA_DIRECTORY.$directory.'/'.$file)) {
-							if($directory != '/') { $file = $directory.'/'.$file; } else { $file = '/'.$file; }
-							foreach($home_folders AS $hf) {
-								$hf_length = strlen($hf);
-								if($hf_length > 0) {
-									if(substr($file, 0, $hf_length+1) == $hf) {
-										$home_folders[$file] = $file;
-									}
-								}
-							}
-							$home_folders = remove_home_subs($file, $home_folders);
-						}
-					}
-				}
-			}
-			return $home_folders;
-		}
-		$home_folders = remove_home_subs('/', $home_folders);
-	}
-	return $home_folders;
-}
-
-// Function to create directories
-function make_dir($dir_name, $dir_mode = OCTAL_DIR_MODE) {
-	if(!file_exists($dir_name)) {
-		$umask = umask(0);
-		mkdir($dir_name, $dir_mode);
-		umask($umask);
-		return true;
-	} else {
-		return false;	
-	}
-}
-
-// Function to chmod files and directories
-function change_mode($name) {
-	if(OPERATING_SYSTEM != 'windows') {
-		// Only chmod if os is not windows
-		if(is_dir($name)) {
-			$mode = OCTAL_DIR_MODE;
-		} else {
-			$mode = OCTAL_FILE_MODE;
-		}
-		if(file_exists($name)) {
-			$umask = umask(0);
-			chmod($name, $mode);
-			umask($umask);
-			return true;
-		} else {
-			return false;	
-		}
-	} else {
-		return true;
-	}
-}
-
-// Function to figure out if a parent exists
-function is_parent($page_id) {
-	global $database;
-	// Get parent
-	$query = $database->query("SELECT parent FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id'");
-	$fetch = $query->fetchRow();
-	// If parent isnt 0 return its ID
-	if($fetch['parent'] == '0') {
-		return false;
-	} else {
-		return $fetch['parent'];
-	}
-}
-
-// Function to work out level
-function level_count($page_id) {
-	global $database;
-	// Get page parent
-	$query_page = $database->query("SELECT parent FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id' LIMIT 1");
-	$fetch_page = $query_page->fetchRow();
-	$parent = $fetch_page['parent'];
-	if($parent > 0) {
-		// Get the level of the parent
-		$query_parent = $database->query("SELECT level FROM ".TABLE_PREFIX."pages WHERE page_id = '$parent' LIMIT 1");
-		$fetch_parent = $query_parent->fetchRow();
-		$level = $fetch_parent['level'];
-		return $level+1;
-	} else {
-		return 0;
-	}
-}
-
-// Function to work out root parent
-function root_parent($page_id) {
-	global $database;
-	// Get page details
-	$query_page = $database->query("SELECT parent,level FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id' LIMIT 1");
-	$fetch_page = $query_page->fetchRow();
-	$parent = $fetch_page['parent'];
-	$level = $fetch_page['level'];	
-	if($level == 1) {
-		return $parent;
-	} elseif($parent == 0) {
-		return 0;
-	} else {
-		// Figure out what the root parents id is
-		$parent_ids = array_reverse(get_parent_ids($page_id));
-		return $parent_ids[0];
-	}
-}
-
-// Function to get page title
-function get_page_title($id) {
-	global $database;
-	// Get title
-	$query = $database->query("SELECT page_title FROM ".TABLE_PREFIX."pages WHERE page_id = '$id'");
-	$fetch = $query->fetchRow();
-	// Return title
-	return $fetch['page_title'];
-}
-
-// Function to get a pages menu title
-function get_menu_title($id) {
-	// Connect to the database
-	$database = new database();
-	// Get title
-	$query = $database->query("SELECT menu_title FROM ".TABLE_PREFIX."pages WHERE page_id = '$id'");
-	$fetch = $query->fetchRow();
-	// Return title
-	return $fetch['menu_title'];
-}
-
-// Function to get all parent page titles
-function get_parent_titles($parent_id) {
-	$titles[] = get_menu_title($parent_id);
-	if(is_parent($parent_id) != false) {
-		$parent_titles = get_parent_titles(is_parent($parent_id));
-		$titles = array_merge($titles, $parent_titles);
-	}
-	return $titles;
-}
-
-// Function to get all parent page id's
-function get_parent_ids($parent_id) {
-	$ids[] = $parent_id;
-	if(is_parent($parent_id) != false) {
-		$parent_ids = get_parent_ids(is_parent($parent_id));
-		$ids = array_merge($ids, $parent_ids);
-	}
-	return $ids;
-}
-
-// Function to genereate page trail
-function get_page_trail($page_id) {
-	return implode(',', array_reverse(get_parent_ids($page_id)));
-}
-
-// Function to get all sub pages id's
-function get_subs($parent, $subs) {
-	// Connect to the database
-	$database = new database();
-	// Get id's
-	$query = $database->query("SELECT page_id FROM ".TABLE_PREFIX."pages WHERE parent = '$parent'");
-	if($query->numRows() > 0) {
-		while($fetch = $query->fetchRow()) {
-			$subs[] = $fetch['page_id'];
-			// Get subs of this sub
-			$subs = get_subs($fetch['page_id'], $subs);
-		}
-	}
-	// Return subs array
-	return $subs;
-}
-
-// Function to convert a page title to a page filename
-function page_filename($string) {
-	// First, translate any non-english characters to their english equivalents
-	require(WB_PATH.'/framework/convert.php');
-   $string = strtr($string, $conversion_array);
-	// Now replace spaces with page spcacer
-	$string = str_replace(' ', PAGE_SPACER, $string);
-	// Now remove all bad characters
-	$bad = array(
-	'\'', /* /  */ '"', /* " */	'<', /* < */	'>', /* > */
-	'{', /* { */	'}', /* } */	'[', /* [ */	']', /* ] */	'`', /* ` */
-	'!', /* ! */	'@', /* @ */	'#', /* # */	'$', /* $ */	'%', /* % */
-	'^', /* ^ */	'&', /* & */	'*', /* * */	'(', /* ( */	')', /* ) */
-	'=', /* = */	'+', /* + */	'|', /* | */	'/', /* / */	'\\', /* \ */
-	';', /* ; */	':', /* : */	',', /* , */	'?' /* ? */
-	);
-	$string = str_replace($bad, '', $string);
-	// Now convert to lower-case
-	$string = strtolower($string);
-	// Now remove multiple page spacers
-	$string = str_replace(PAGE_SPACER.PAGE_SPACER, PAGE_SPACER, $string);
-	// Clean any page spacers at the end of string
-	$string = str_replace(PAGE_SPACER, ' ', $string);
-	$string = trim($string);
-	$string = str_replace(' ', PAGE_SPACER, $string);
-	// If there are any weird language characters, this will protect us against possible problems they could cause
-	$string = str_replace(array('%2F', '%'), array('/', ''), urlencode($string));
-	// Finally, return the cleaned string
-	return $string;
-}
-
-// Function to convert a desired media filename to a clean filename
-function media_filename($string) {
-	// First, translate any non-english characters to their english equivalents
-	require(WB_PATH.'/framework/convert.php');
-   $string = strtr($string, $conversion_array);
-	// Now remove all bad characters
-	$bad = array(
-	'\'', // '
-	'"', // "
-	'`', // `
-	'!', // !
-	'@', // @
-	'#', // #
-	'$', // $
-	'%', // %
-	'^', // ^
-	'&', // &
-	'*', // *
-	'=', // =
-	'+', // +
-	'|', // |
-	'/', // /
-	'\\', // \
-	';', // ;
-	':', // :
-	',', // ,
-	'?' // ?
-	);
-	$string = str_replace($bad, '', $string);
-	// Clean any page spacers at the end of string
-	$string = trim($string);
-	// Finally, return the cleaned string
-	return $string;
-}
-
-// Function to work out a page link
-if(!function_exists('page_link')) {
-	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;
-		}
-	}
-}
-
-// Create a new file in the pages directory
-function create_access_file($filename,$page_id,$level) {
-	global $admin;
-	if(!is_writable(WB_PATH.PAGES_DIRECTORY.'/')) {
-		$admin->print_error($MESSAGE['PAGES']['CANNOT_CREATE_ACCESS_FILE']);
-	} else {
-		// First make sure parent folder exists
-		$parent_folders = explode('/',str_replace(WB_PATH.PAGES_DIRECTORY, '', dirname($filename)));
-		$parents = '';
-		foreach($parent_folders AS $parent_folder) {
-			if($parent_folder != '/' AND $parent_folder != '') {
-				$parents .= '/'.$parent_folder;
-				if(!file_exists(WB_PATH.PAGES_DIRECTORY.$parents)) {
-					make_dir(WB_PATH.PAGES_DIRECTORY.$parents);
-				}
-			}	
-		}
-		// The depth of the page directory in the directory hierarchy
-		// '/pages' is at depth 1
-		$pages_dir_depth=count(explode('/',PAGES_DIRECTORY))-1;
-		// Work-out how many ../'s we need to get to the index page
-		$index_location = '';
-		for($i = 0; $i < $level + $pages_dir_depth; $i++) {
-			$index_location .= '../';
-		}
-		$content = ''.
-'<?php
-$page_id = '.$page_id.';
-require("'.$index_location.'config.php");
-require(WB_PATH."/index.php");
-?>';
-		$handle = fopen($filename, 'w');
-		fwrite($handle, $content);
-		fclose($handle);
-		// Chmod the file
-		change_mode($filename, 'file');
-	}
-}
-
-// Function for working out a file mime type (if the in-built PHP one is not enabled)
-if(!function_exists('mime_content_type')) {
-   function mime_content_type($file) {
-       $file = escapeshellarg($file);
-       return trim(`file -bi $file`);
-   }
-}
-
-// Generate a thumbnail from an image
-function make_thumb($source, $destination, $size) {
-	// Check if GD is installed
-	if(extension_loaded('gd') AND function_exists('imageCreateFromJpeg')) {
-		// First figure out the size of the thumbnail
-		list($original_x, $original_y) = getimagesize($source);
-		if ($original_x > $original_y) {
-			$thumb_w = $size;
-			$thumb_h = $original_y*($size/$original_x);
-		}
-		if ($original_x < $original_y) {
-			$thumb_w = $original_x*($size/$original_y);
-			$thumb_h = $size;
-		}
-		if ($original_x == $original_y) {
-			$thumb_w = $size;
-			$thumb_h = $size;	
-		}
-		// Now make the thumbnail
-		$source = imageCreateFromJpeg($source);
-		$dst_img = ImageCreateTrueColor($thumb_w, $thumb_h);
-		imagecopyresampled($dst_img,$source,0,0,0,0,$thumb_w,$thumb_h,$original_x,$original_y);
-		imagejpeg($dst_img, $destination);
-		// Clear memory
-		imagedestroy($dst_img);
-	   imagedestroy($source);
-	   // Return true
-	   return true;
-   } else {
-   	return false;
-   }
-}
-
-// Function to work-out a single part of an octal permission value
-function extract_permission($octal_value, $who, $action) {
-	// Make sure the octal value is 4 chars long
-	if(strlen($octal_value) == 0) {
-		$octal_value = '0000';
-	} elseif(strlen($octal_value) == 1) {
-		$octal_value = '000'.$octal_value;
-	} elseif(strlen($octal_value) == 2) {
-		$octal_value = '00'.$octal_value;
-	} elseif(strlen($octal_value) == 3) {
-		$octal_value = '0'.$octal_value;
-	} elseif(strlen($octal_value) == 4) {
-		$octal_value = ''.$octal_value;
-	} else {
-		$octal_value = '0000';
-	}
-	// Work-out what position of the octal value to look at
-	switch($who) {
-	case 'u':
-		$position = '1';
-		break;
-	case 'user':
-		$position = '1';
-		break;
-	case 'g':
-		$position = '2';
-		break;
-	case 'group':
-		$position = '2';
-		break;
-	case 'o':
-		$position = '3';
-		break;
-	case 'others':
-		$position = '3';
-		break;
-	}
-	// Work-out how long the octal value is and ajust acording
-	if(strlen($octal_value) == 4) {
-		$position = $position+1;
-	} elseif(strlen($octal_value) != 3) {
-		exit('Error');
-	}
-	// Now work-out what action the script is trying to look-up
-	switch($action) {
-	case 'r':
-		$action = 'r';
-		break;
-	case 'read':
-		$action = 'r';
-		break;
-	case 'w':
-		$action = 'w';
-		break;
-	case 'write':
-		$action = 'w';
-		break;
-	case 'e':
-		$action = 'e';
-		break;
-	case 'execute':
-		$action = 'e';
-		break;
-	}
-	// Get the value for "who"
-	$value = substr($octal_value, $position-1, 1);
-	// Now work-out the details of the value
-	switch($value) {
-	case '0':
-		$r = false;
-		$w = false;
-		$e = false;
-		break;
-	case '1':
-		$r = false;
-		$w = false;
-		$e = true;
-		break;
-	case '2':
-		$r = false;
-		$w = true;
-		$e = false;
-		break;
-	case '3':
-		$r = false;
-		$w = true;
-		$e = true;
-		break;
-	case '4':
-		$r = true;
-		$w = false;
-		$e = false;
-		break;
-	case '5':
-		$r = true;
-		$w = false;
-		$e = true;
-		break;
-	case '6':
-		$r = true;
-		$w = true;
-		$e = false;
-		break;
-	case '7':
-		$r = true;
-		$w = true;
-		$e = true;
-		break;
-	default:
-		$r = false;
-		$w = false;
-		$e = false;
-	}
-	// And finally, return either true or false
-	return $$action;
-}
-
-// Function to delete a page
-function delete_page($page_id) {
-	
-	global $admin, $database;
-	
-	// Find out more about the page
-	$database = new database();
-	$query = "SELECT page_id,menu_title,page_title,level,link,parent,modified_by,modified_when FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id'";
-	$results = $database->query($query);
-	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
-	$query_sections = $database->query("SELECT section_id,module FROM ".TABLE_PREFIX."sections WHERE page_id = '$page_id'");
-	if($query_sections->numRows() > 0) {
-		while($section = $query_sections->fetchRow()) {
-			// 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')) {
-				require(WB_PATH.'/modules/'.$section['module'].'/delete.php');
-			}
-		}
-	}
-	
-	// Update the pages table
-	$query = "DELETE FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id'";
-	$database->query($query);
-	if($database->is_error()) {
-		$admin->print_error($database->get_error());
-	}
-	
-	// Update the sections table
-	$query = "DELETE FROM ".TABLE_PREFIX."sections WHERE page_id = '$page_id'";
-	$database->query($query);
-	if($database->is_error()) {
-		$admin->print_error($database->get_error());
-	}
-	
-	// Include the ordering class or clean-up ordering
-	require_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.'.php';
-	$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)) {
-				rm_full_dir($directory);
-			}
-		}
-	}
-	
-}
-
-// Load module into DB
-function load_module($directory, $install = false) {
-	global $database;
-	if(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; }
-			$module_function = strtolower($module_function);
-			// Check that it doesn't already exist
-			$result = $database->query("SELECT addon_id FROM ".TABLE_PREFIX."addons WHERE directory = '".$module_directory."' LIMIT 0,1");
-			if($result->numRows() == 0) {
-				// Load into DB
-				$query = "INSERT INTO ".TABLE_PREFIX."addons ".
-				"(directory,name,description,type,function,version,platform,author,license) ".
-				"VALUES ('$module_directory','$module_name','".addslashes($module_description)."','module',".
-				"'$module_function','$module_version','$module_platform','$module_author','$module_license')";
-				$database->query($query);
-				// Run installation script
-				if($install == true) {
-					if(file_exists($directory.'/install.php')) {
-						require($directory.'/install.php');
-					}
-				}
-			}
-		}
-	}
-}
-
-// Load template into DB
-function load_template($directory) {
-	global $database;
-	if(file_exists($directory.'/info.php')) {
-		require($directory.'/info.php');
-		if(isset($template_name)) {
-			if(!isset($template_license)) { $template_license = 'GNU General Public License'; }
-			if(!isset($template_platform) AND isset($template_designed_for)) { $template_platform = $template_designed_for; }
-			// Check that it doesn't already exist
-			$result = $database->query("SELECT addon_id FROM ".TABLE_PREFIX."addons WHERE directory = '".$template_directory."' LIMIT 0,1");
-			if($result->numRows() == 0) {
-				// Load into DB
-				$query = "INSERT INTO ".TABLE_PREFIX."addons ".
-				"(directory,name,description,type,version,platform,author,license) ".
-				"VALUES ('$template_directory','$template_name','".addslashes($template_description)."','template',".
-				"'$template_version','$template_platform','$template_author','$template_license')";
-				$database->query($query);
-			}
-		}
-	}
-}
-
-// Load language into DB
-function load_language($file) {
-	global $database;
-	if(file_exists($file)) {
-		require($file);
-		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; }
-			// Check that it doesn't already exist
-			$result = $database->query("SELECT addon_id FROM ".TABLE_PREFIX."addons WHERE directory = '".$language_code."' LIMIT 0,1");
-			if($result->numRows() == 0) {
-				// Load into DB
-				$query = "INSERT INTO ".TABLE_PREFIX."addons ".
-				"(directory,name,type,version,platform,author,license) ".
-				"VALUES ('$language_code','$language_name','language',".
-				"'$language_version','$language_platform','$language_author','$language_license')";
-	 		$database->query($query);
-			}
-		}
-	}
-}
-
-?>
\ No newline at end of file
+<?php
+
+// $Id$
+
+/*
+
+ Website Baker Project <http://www.websitebaker.org/>
+ Copyright (C) 2004-2005, 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
+
+*/
+
+/*
+
+Website Baker functions file
+This file contains general functions used in Website Baker
+
+*/
+
+// Stop this file from being accessed directly
+if(!defined('WB_URL')) {
+	header('Location: ../index.php');
+}
+
+// Define that this file has been loaded
+define('FUNCTIONS_FILE_LOADED', true);
+
+// Function to remove a non-empty directory
+function rm_full_dir($directory)
+{
+    // If suplied dirname is a file then unlink it
+    if (is_file($directory)) {
+        return unlink($directory);
+    }
+
+    // Empty the folder
+    $dir = dir($directory);
+    while (false !== $entry = $dir->read()) {
+        // Skip pointers
+        if ($entry == '.' || $entry == '..') {
+            continue;
+        }
+
+        // Deep delete directories      
+        if (is_dir("$directory/$entry")) {
+            rm_full_dir("$directory/$entry");
+        } else {
+            unlink("$directory/$entry");
+        }
+    }
+
+    // Now delete the folder
+    $dir->close();
+    return rmdir($directory);
+}
+
+// Function to open a directory and add to a dir list
+function directory_list($directory) {
+	
+	$list = array();
+
+	// Open the directory then loop through its contents
+	$dir = dir($directory);
+	while (false !== $entry = $dir->read()) {
+		// Skip pointers
+		if(substr($entry, 0, 1) == '.' || $entry == '.svn') {
+			continue;
+		}
+		// Add dir and contents to list
+		if (is_dir("$directory/$entry")) {
+			$list = array_merge($list, directory_list("$directory/$entry"));
+			$list[] = "$directory/$entry";
+		}
+	}
+
+	// Now return the list
+	return $list;
+}
+
+// Function to open a directory and add to a dir list
+function chmod_directory_contents($directory, $file_mode) {
+	
+	// Set the umask to 0
+	$umask = umask(0);
+	
+	// Open the directory then loop through its contents
+	$dir = dir($directory);
+	while (false !== $entry = $dir->read()) {
+		// Skip pointers
+		if(substr($entry, 0, 1) == '.' || $entry == '.svn') {
+			continue;
+		}
+		// Chmod the sub-dirs contents
+		if(is_dir("$directory/$entry")) {
+			chmod_directory_contents("$directory/$entry", $file_mode);
+		}
+		change_mode($directory.'/'.$entry, 'file');
+	}
+	
+	// Restore the umask
+	umask($umask);
+
+}
+
+// Function to open a directory and add to a file list
+function file_list($directory, $skip = array()) {
+	
+	$list = array();
+	$skip_file = false;
+	
+	// Open the directory then loop through its contents
+	$dir = dir($directory);
+	while (false !== $entry = $dir->read()) {
+		// Skip pointers
+		if($entry == '.' || $entry == '..') {
+			$skip_file = true;
+		}
+		// Check if we to skip anything else
+		if($skip != array()) {
+			foreach($skip AS $skip_name) {
+				if($entry == $skip_name) {
+					$skip_file = true;
+				}
+			}
+		}
+		// Add dir and contents to list
+		if($skip_file != true AND is_file("$directory/$entry")) {
+			$list[] = "$directory/$entry";
+		}
+		
+		// Reset the skip file var
+		$skip_file = false;
+	}
+
+	// Now delete the folder
+	return $list;
+}
+
+// Function to get a list of home folders not to show
+function get_home_folders() {
+	global $database, $admin;
+	$home_folders = array();
+	// Only return home folders is this feature is enabled
+	if(HOME_FOLDERS) {
+		$query_home_folders = $database->query("SELECT home_folder FROM ".TABLE_PREFIX."users WHERE home_folder != '".$admin->get_home_folder()."'");
+		if($query_home_folders->numRows() > 0) {
+			while($folder = $query_home_folders->fetchRow()) {
+				$home_folders[$folder['home_folder']] = $folder['home_folder'];
+			}
+		}
+		function remove_home_subs($directory = '/', $home_folders) {
+			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(substr($file, 0, 1) != '.' AND $file != '.svn' AND $file != 'index.php') {
+						if(is_dir(WB_PATH.MEDIA_DIRECTORY.$directory.'/'.$file)) {
+							if($directory != '/') { $file = $directory.'/'.$file; } else { $file = '/'.$file; }
+							foreach($home_folders AS $hf) {
+								$hf_length = strlen($hf);
+								if($hf_length > 0) {
+									if(substr($file, 0, $hf_length+1) == $hf) {
+										$home_folders[$file] = $file;
+									}
+								}
+							}
+							$home_folders = remove_home_subs($file, $home_folders);
+						}
+					}
+				}
+			}
+			return $home_folders;
+		}
+		$home_folders = remove_home_subs('/', $home_folders);
+	}
+	return $home_folders;
+}
+
+// Function to create directories
+function make_dir($dir_name, $dir_mode = OCTAL_DIR_MODE) {
+	if(!file_exists($dir_name)) {
+		$umask = umask(0);
+		mkdir($dir_name, $dir_mode);
+		umask($umask);
+		return true;
+	} else {
+		return false;	
+	}
+}
+
+// Function to chmod files and directories
+function change_mode($name) {
+	if(OPERATING_SYSTEM != 'windows') {
+		// Only chmod if os is not windows
+		if(is_dir($name)) {
+			$mode = OCTAL_DIR_MODE;
+		} else {
+			$mode = OCTAL_FILE_MODE;
+		}
+		if(file_exists($name)) {
+			$umask = umask(0);
+			chmod($name, $mode);
+			umask($umask);
+			return true;
+		} else {
+			return false;	
+		}
+	} else {
+		return true;
+	}
+}
+
+// Function to figure out if a parent exists
+function is_parent($page_id) {
+	global $database;
+	// Get parent
+	$query = $database->query("SELECT parent FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id'");
+	$fetch = $query->fetchRow();
+	// If parent isnt 0 return its ID
+	if($fetch['parent'] == '0') {
+		return false;
+	} else {
+		return $fetch['parent'];
+	}
+}
+
+// Function to work out level
+function level_count($page_id) {
+	global $database;
+	// Get page parent
+	$query_page = $database->query("SELECT parent FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id' LIMIT 1");
+	$fetch_page = $query_page->fetchRow();
+	$parent = $fetch_page['parent'];
+	if($parent > 0) {
+		// Get the level of the parent
+		$query_parent = $database->query("SELECT level FROM ".TABLE_PREFIX."pages WHERE page_id = '$parent' LIMIT 1");
+		$fetch_parent = $query_parent->fetchRow();
+		$level = $fetch_parent['level'];
+		return $level+1;
+	} else {
+		return 0;
+	}
+}
+
+// Function to work out root parent
+function root_parent($page_id) {
+	global $database;
+	// Get page details
+	$query_page = $database->query("SELECT parent,level FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id' LIMIT 1");
+	$fetch_page = $query_page->fetchRow();
+	$parent = $fetch_page['parent'];
+	$level = $fetch_page['level'];	
+	if($level == 1) {
+		return $parent;
+	} elseif($parent == 0) {
+		return 0;
+	} else {
+		// Figure out what the root parents id is
+		$parent_ids = array_reverse(get_parent_ids($page_id));
+		return $parent_ids[0];
+	}
+}
+
+// Function to get page title
+function get_page_title($id) {
+	global $database;
+	// Get title
+	$query = $database->query("SELECT page_title FROM ".TABLE_PREFIX."pages WHERE page_id = '$id'");
+	$fetch = $query->fetchRow();
+	// Return title
+	return $fetch['page_title'];
+}
+
+// Function to get a pages menu title
+function get_menu_title($id) {
+	// Connect to the database
+	$database = new database();
+	// Get title
+	$query = $database->query("SELECT menu_title FROM ".TABLE_PREFIX."pages WHERE page_id = '$id'");
+	$fetch = $query->fetchRow();
+	// Return title
+	return $fetch['menu_title'];
+}
+
+// Function to get all parent page titles
+function get_parent_titles($parent_id) {
+	$titles[] = get_menu_title($parent_id);
+	if(is_parent($parent_id) != false) {
+		$parent_titles = get_parent_titles(is_parent($parent_id));
+		$titles = array_merge($titles, $parent_titles);
+	}
+	return $titles;
+}
+
+// Function to get all parent page id's
+function get_parent_ids($parent_id) {
+	$ids[] = $parent_id;
+	if(is_parent($parent_id) != false) {
+		$parent_ids = get_parent_ids(is_parent($parent_id));
+		$ids = array_merge($ids, $parent_ids);
+	}
+	return $ids;
+}
+
+// Function to genereate page trail
+function get_page_trail($page_id) {
+	return implode(',', array_reverse(get_parent_ids($page_id)));
+}
+
+// Function to get all sub pages id's
+function get_subs($parent, $subs) {
+	// Connect to the database
+	$database = new database();
+	// Get id's
+	$query = $database->query("SELECT page_id FROM ".TABLE_PREFIX."pages WHERE parent = '$parent'");
+	if($query->numRows() > 0) {
+		while($fetch = $query->fetchRow()) {
+			$subs[] = $fetch['page_id'];
+			// Get subs of this sub
+			$subs = get_subs($fetch['page_id'], $subs);
+		}
+	}
+	// Return subs array
+	return $subs;
+}
+
+// Function to convert a page title to a page filename
+function page_filename($string) {
+	// First, translate any non-english characters to their english equivalents
+	require(WB_PATH.'/framework/convert.php');
+   $string = strtr($string, $conversion_array);
+	// Now replace spaces with page spcacer
+	$string = str_replace(' ', PAGE_SPACER, $string);
+	// Now remove all bad characters
+	$bad = array(
+	'\'', /* /  */ '"', /* " */	'<', /* < */	'>', /* > */
+	'{', /* { */	'}', /* } */	'[', /* [ */	']', /* ] */	'`', /* ` */
+	'!', /* ! */	'@', /* @ */	'#', /* # */	'$', /* $ */	'%', /* % */
+	'^', /* ^ */	'&', /* & */	'*', /* * */	'(', /* ( */	')', /* ) */
+	'=', /* = */	'+', /* + */	'|', /* | */	'/', /* / */	'\\', /* \ */
+	';', /* ; */	':', /* : */	',', /* , */	'?' /* ? */
+	);
+	$string = str_replace($bad, '', $string);
+	// Now convert to lower-case
+	$string = strtolower($string);
+	// Now remove multiple page spacers
+	$string = str_replace(PAGE_SPACER.PAGE_SPACER, PAGE_SPACER, $string);
+	// Clean any page spacers at the end of string
+	$string = str_replace(PAGE_SPACER, ' ', $string);
+	$string = trim($string);
+	$string = str_replace(' ', PAGE_SPACER, $string);
+	// If there are any weird language characters, this will protect us against possible problems they could cause
+	$string = str_replace(array('%2F', '%'), array('/', ''), urlencode($string));
+	// Finally, return the cleaned string
+	return $string;
+}
+
+// Function to convert a desired media filename to a clean filename
+function media_filename($string) {
+	// First, translate any non-english characters to their english equivalents
+	require(WB_PATH.'/framework/convert.php');
+   $string = strtr($string, $conversion_array);
+	// Now remove all bad characters
+	$bad = array(
+	'\'', // '
+	'"', // "
+	'`', // `
+	'!', // !
+	'@', // @
+	'#', // #
+	'$', // $
+	'%', // %
+	'^', // ^
+	'&', // &
+	'*', // *
+	'=', // =
+	'+', // +
+	'|', // |
+	'/', // /
+	'\\', // \
+	';', // ;
+	':', // :
+	',', // ,
+	'?' // ?
+	);
+	$string = str_replace($bad, '', $string);
+	// Clean any page spacers at the end of string
+	$string = trim($string);
+	// Finally, return the cleaned string
+	return $string;
+}
+
+// Function to work out a page link
+if(!function_exists('page_link')) {
+	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;
+		}
+	}
+}
+
+// Create a new file in the pages directory
+function create_access_file($filename,$page_id,$level) {
+	global $admin;
+	if(!is_writable(WB_PATH.PAGES_DIRECTORY.'/')) {
+		$admin->print_error($MESSAGE['PAGES']['CANNOT_CREATE_ACCESS_FILE']);
+	} else {
+		// First make sure parent folder exists
+		$parent_folders = explode('/',str_replace(WB_PATH.PAGES_DIRECTORY, '', dirname($filename)));
+		$parents = '';
+		foreach($parent_folders AS $parent_folder) {
+			if($parent_folder != '/' AND $parent_folder != '') {
+				$parents .= '/'.$parent_folder;
+				if(!file_exists(WB_PATH.PAGES_DIRECTORY.$parents)) {
+					make_dir(WB_PATH.PAGES_DIRECTORY.$parents);
+				}
+			}	
+		}
+		// The depth of the page directory in the directory hierarchy
+		// '/pages' is at depth 1
+		$pages_dir_depth=count(explode('/',PAGES_DIRECTORY))-1;
+		// Work-out how many ../'s we need to get to the index page
+		$index_location = '';
+		for($i = 0; $i < $level + $pages_dir_depth; $i++) {
+			$index_location .= '../';
+		}
+		$content = ''.
+'<?php
+$page_id = '.$page_id.';
+require("'.$index_location.'config.php");
+require(WB_PATH."/index.php");
+?>';
+		$handle = fopen($filename, 'w');
+		fwrite($handle, $content);
+		fclose($handle);
+		// Chmod the file
+		change_mode($filename, 'file');
+	}
+}
+
+// Function for working out a file mime type (if the in-built PHP one is not enabled)
+if(!function_exists('mime_content_type')) {
+   function mime_content_type($file) {
+       $file = escapeshellarg($file);
+       return trim(`file -bi $file`);
+   }
+}
+
+// Generate a thumbnail from an image
+function make_thumb($source, $destination, $size) {
+	// Check if GD is installed
+	if(extension_loaded('gd') AND function_exists('imageCreateFromJpeg')) {
+		// First figure out the size of the thumbnail
+		list($original_x, $original_y) = getimagesize($source);
+		if ($original_x > $original_y) {
+			$thumb_w = $size;
+			$thumb_h = $original_y*($size/$original_x);
+		}
+		if ($original_x < $original_y) {
+			$thumb_w = $original_x*($size/$original_y);
+			$thumb_h = $size;
+		}
+		if ($original_x == $original_y) {
+			$thumb_w = $size;
+			$thumb_h = $size;	
+		}
+		// Now make the thumbnail
+		$source = imageCreateFromJpeg($source);
+		$dst_img = ImageCreateTrueColor($thumb_w, $thumb_h);
+		imagecopyresampled($dst_img,$source,0,0,0,0,$thumb_w,$thumb_h,$original_x,$original_y);
+		imagejpeg($dst_img, $destination);
+		// Clear memory
+		imagedestroy($dst_img);
+	   imagedestroy($source);
+	   // Return true
+	   return true;
+   } else {
+   	return false;
+   }
+}
+
+// Function to work-out a single part of an octal permission value
+function extract_permission($octal_value, $who, $action) {
+	// Make sure the octal value is 4 chars long
+	if(strlen($octal_value) == 0) {
+		$octal_value = '0000';
+	} elseif(strlen($octal_value) == 1) {
+		$octal_value = '000'.$octal_value;
+	} elseif(strlen($octal_value) == 2) {
+		$octal_value = '00'.$octal_value;
+	} elseif(strlen($octal_value) == 3) {
+		$octal_value = '0'.$octal_value;
+	} elseif(strlen($octal_value) == 4) {
+		$octal_value = ''.$octal_value;
+	} else {
+		$octal_value = '0000';
+	}
+	// Work-out what position of the octal value to look at
+	switch($who) {
+	case 'u':
+		$position = '1';
+		break;
+	case 'user':
+		$position = '1';
+		break;
+	case 'g':
+		$position = '2';
+		break;
+	case 'group':
+		$position = '2';
+		break;
+	case 'o':
+		$position = '3';
+		break;
+	case 'others':
+		$position = '3';
+		break;
+	}
+	// Work-out how long the octal value is and ajust acording
+	if(strlen($octal_value) == 4) {
+		$position = $position+1;
+	} elseif(strlen($octal_value) != 3) {
+		exit('Error');
+	}
+	// Now work-out what action the script is trying to look-up
+	switch($action) {
+	case 'r':
+		$action = 'r';
+		break;
+	case 'read':
+		$action = 'r';
+		break;
+	case 'w':
+		$action = 'w';
+		break;
+	case 'write':
+		$action = 'w';
+		break;
+	case 'e':
+		$action = 'e';
+		break;
+	case 'execute':
+		$action = 'e';
+		break;
+	}
+	// Get the value for "who"
+	$value = substr($octal_value, $position-1, 1);
+	// Now work-out the details of the value
+	switch($value) {
+	case '0':
+		$r = false;
+		$w = false;
+		$e = false;
+		break;
+	case '1':
+		$r = false;
+		$w = false;
+		$e = true;
+		break;
+	case '2':
+		$r = false;
+		$w = true;
+		$e = false;
+		break;
+	case '3':
+		$r = false;
+		$w = true;
+		$e = true;
+		break;
+	case '4':
+		$r = true;
+		$w = false;
+		$e = false;
+		break;
+	case '5':
+		$r = true;
+		$w = false;
+		$e = true;
+		break;
+	case '6':
+		$r = true;
+		$w = true;
+		$e = false;
+		break;
+	case '7':
+		$r = true;
+		$w = true;
+		$e = true;
+		break;
+	default:
+		$r = false;
+		$w = false;
+		$e = false;
+	}
+	// And finally, return either true or false
+	return $$action;
+}
+
+// Function to delete a page
+function delete_page($page_id) {
+	
+	global $admin, $database;
+	
+	// Find out more about the page
+	$database = new database();
+	$query = "SELECT page_id,menu_title,page_title,level,link,parent,modified_by,modified_when FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id'";
+	$results = $database->query($query);
+	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
+	$query_sections = $database->query("SELECT section_id,module FROM ".TABLE_PREFIX."sections WHERE page_id = '$page_id'");
+	if($query_sections->numRows() > 0) {
+		while($section = $query_sections->fetchRow()) {
+			// 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')) {
+				require(WB_PATH.'/modules/'.$section['module'].'/delete.php');
+			}
+		}
+	}
+	
+	// Update the pages table
+	$query = "DELETE FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id'";
+	$database->query($query);
+	if($database->is_error()) {
+		$admin->print_error($database->get_error());
+	}
+	
+	// Update the sections table
+	$query = "DELETE FROM ".TABLE_PREFIX."sections WHERE page_id = '$page_id'";
+	$database->query($query);
+	if($database->is_error()) {
+		$admin->print_error($database->get_error());
+	}
+	
+	// Include the ordering class or clean-up ordering
+	require_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.'.php';
+	$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)) {
+				rm_full_dir($directory);
+			}
+		}
+	}
+	
+}
+
+// Load module into DB
+function load_module($directory, $install = false) {
+	global $database;
+	if(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; }
+			$module_function = strtolower($module_function);
+			// Check that it doesn't already exist
+			$result = $database->query("SELECT addon_id FROM ".TABLE_PREFIX."addons WHERE directory = '".$module_directory."' LIMIT 0,1");
+			if($result->numRows() == 0) {
+				// Load into DB
+				$query = "INSERT INTO ".TABLE_PREFIX."addons ".
+				"(directory,name,description,type,function,version,platform,author,license) ".
+				"VALUES ('$module_directory','$module_name','".addslashes($module_description)."','module',".
+				"'$module_function','$module_version','$module_platform','$module_author','$module_license')";
+				$database->query($query);
+				// Run installation script
+				if($install == true) {
+					if(file_exists($directory.'/install.php')) {
+						require($directory.'/install.php');
+					}
+				}
+			}
+		}
+	}
+}
+
+// Load template into DB
+function load_template($directory) {
+	global $database;
+	if(file_exists($directory.'/info.php')) {
+		require($directory.'/info.php');
+		if(isset($template_name)) {
+			if(!isset($template_license)) { $template_license = 'GNU General Public License'; }
+			if(!isset($template_platform) AND isset($template_designed_for)) { $template_platform = $template_designed_for; }
+			// Check that it doesn't already exist
+			$result = $database->query("SELECT addon_id FROM ".TABLE_PREFIX."addons WHERE directory = '".$template_directory."' LIMIT 0,1");
+			if($result->numRows() == 0) {
+				// Load into DB
+				$query = "INSERT INTO ".TABLE_PREFIX."addons ".
+				"(directory,name,description,type,version,platform,author,license) ".
+				"VALUES ('$template_directory','$template_name','".addslashes($template_description)."','template',".
+				"'$template_version','$template_platform','$template_author','$template_license')";
+				$database->query($query);
+			}
+		}
+	}
+}
+
+// Load language into DB
+function load_language($file) {
+	global $database;
+	if(file_exists($file)) {
+		require($file);
+		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; }
+			// Check that it doesn't already exist
+			$result = $database->query("SELECT addon_id FROM ".TABLE_PREFIX."addons WHERE directory = '".$language_code."' LIMIT 0,1");
+			if($result->numRows() == 0) {
+				// Load into DB
+				$query = "INSERT INTO ".TABLE_PREFIX."addons ".
+				"(directory,name,type,version,platform,author,license) ".
+				"VALUES ('$language_code','$language_name','language',".
+				"'$language_version','$language_platform','$language_author','$language_license')";
+	 		$database->query($query);
+			}
+		}
+	}
+}
+
+?>
Index: trunk/wb/index.php
===================================================================
--- trunk/wb/index.php	(revision 237)
+++ trunk/wb/index.php	(revision 238)
@@ -1,58 +1,58 @@
-<?php
-
-// $Id$
-
-/*
-
- Website Baker Project <http://www.websitebaker.org/>
- Copyright (C) 2004-2005, 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
-
-*/
-
-$starttime = array_sum(explode(" ",microtime()));
-
-// Include config file
-require_once(dirname(__FILE__).'/config.php');
-
-// Check if the config file has been set-up
-if(!defined('WB_PATH')) {
-	header("Location: install/index.php");
-}
-
-require_once(WB_PATH.'/framework/class.frontend.php');
-// Create new frontend object
-$wb = new frontend();
-
-// Figure out which page to display
-// Stop processing if intro page was shown
-$wb->page_select() or die();
-
-// Collect info about the currently viewed page
-// and check permissions
-$wb->get_page_details();
-
-// Collect general website settings
-$wb->get_website_settings();
-
-// Load functions available to templates, modules and code sections
-// also, set some aliases for backward compatibility
-require(WB_PATH.'/framework/frontend.functions.php');
-
-// Display the template
-require(WB_PATH.'/templates/'.TEMPLATE.'/index.php');
-
-?>
+<?php
+
+// $Id$
+
+/*
+
+ Website Baker Project <http://www.websitebaker.org/>
+ Copyright (C) 2004-2005, 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
+
+*/
+
+$starttime = array_sum(explode(" ",microtime()));
+
+// Include config file
+require_once(dirname(__FILE__).'/config.php');
+
+// Check if the config file has been set-up
+if(!defined('WB_PATH')) {
+	header("Location: install/index.php");
+}
+
+require_once(WB_PATH.'/framework/class.frontend.php');
+// Create new frontend object
+$wb = new frontend();
+
+// Figure out which page to display
+// Stop processing if intro page was shown
+$wb->page_select() or die();
+
+// Collect info about the currently viewed page
+// and check permissions
+$wb->get_page_details();
+
+// Collect general website settings
+$wb->get_website_settings();
+
+// Load functions available to templates, modules and code sections
+// also, set some aliases for backward compatibility
+require(WB_PATH.'/framework/frontend.functions.php');
+
+// Display the template
+require(WB_PATH.'/templates/'.TEMPLATE.'/index.php');
+
+?>
