Index: branches/2.6.x/wb/search/search.php
===================================================================
--- branches/2.6.x/wb/search/search.php	(revision 451)
+++ branches/2.6.x/wb/search/search.php	(revision 452)
@@ -28,6 +28,9 @@
 	exit(0);
 }
 
+// Include the WB functions file
+require_once(WB_PATH.'/framework/functions.php');
+
 // Check if search is enabled
 if(SHOW_SEARCH != true) {
 	echo $TEXT['SEARCH'].' '.$TEXT['DISABLED'];
@@ -39,9 +42,9 @@
 
 	// Get the search type
 	$match = 'all';
-    if(isset($_REQUEST['match'])) {
-        $match = $_REQUEST['match'];
-    }
+	if(isset($_REQUEST['match'])) {
+		$match = $_REQUEST['match'];
+	}
 
 	// Get search string
 	if(isset($_REQUEST['string'])) {
@@ -54,8 +57,13 @@
 		$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
-		$search_string = htmlspecialchars($original_string,ENT_QUOTES);
+		// convert a copy of $string to HTML-ENTITIES
+		$string_entities = umlauts_to_entities($string);
+		// and do some convertion to both
+		require(WB_PATH.'/search/search_convert.php');
+		$string = strtr($string,$string_conv_all);
+		$string_entities = strtr($string_entities,$string_entities_conv_all);
+		$search_string = $string_entities;
 	} else {
 		$string = '';
 		$search_string = '';
@@ -75,6 +83,15 @@
 				$string[] = $each_exploded_string;
 			}
 		}
+		// Split $string_entities, too
+		$exploded_string = explode(' ', $string_entities);
+		// Make sure there is no blank values in the array
+		$string_entities = array();
+		foreach($exploded_string AS $each_exploded_string) {
+			if($each_exploded_string != '') {
+				$string_entities[] = $each_exploded_string;
+			}
+		}
 		if ($match == 'any') {
 			$any_checked = ' checked="checked"';
 			$logical_operator = ' OR';
@@ -87,6 +104,9 @@
 		$exact_string=$string;
 		$string=array();
 		$string[]=$exact_string;
+		$exact_string=$string_entities;
+		$string_entities=array();
+		$string_entities[]=$exact_string;
 	}	
 	// Get list of usernames and display names
 	$query_users = $database->query("SELECT user_id,username,display_name FROM ".TABLE_PREFIX."users");
@@ -121,6 +141,9 @@
 	$vars = array('[SEARCH_STRING]', '[WB_URL]', '[PAGE_EXTENSION]', '[TEXT_SEARCH]', '[TEXT_ALL_WORDS]', '[TEXT_ANY_WORDS]', '[TEXT_EXACT_MATCH]', '[TEXT_MATCH]', '[TEXT_MATCHING]', '[ALL_CHECKED]', '[ANY_CHECKED]', '[EXACT_CHECKED]', '[REFERRER_ID]');
 	$values = array($search_string, WB_URL, PAGE_EXTENSION, $TEXT['SEARCH'], $TEXT['ALL_WORDS'], $TEXT['ANY_WORDS'], $TEXT['EXACT_MATCH'], $TEXT['MATCH'], $TEXT['MATCHING'], $all_checked, $any_checked, $exact_checked, REFERRER_ID);
 	$search_header = str_replace($vars, $values, ($fetch_header['value']));
+	$vars = array('[TEXT_NO_RESULTS]');
+	$values = array($TEXT['NO_RESULTS']);
+	$search_no_results = str_replace($vars, $values, ($fetch_no_results['value']));
 	
 	// Show search header
 	echo $search_header;
@@ -131,22 +154,43 @@
 		// Show search results_header
 		echo $search_results_header;
 		// Search page details only, such as description, keywords, etc.
-			$query_pages = "SELECT page_id, page_title, menu_title, link, description, modified_when, modified_by FROM ".TABLE_PREFIX."pages WHERE ";
-			$count = 0;
-			foreach($string AS $each_string) {
-				if($count != 0) { $query_pages .= $logical_operator; }
-				$query_pages .= " visibility != 'none' AND page_title LIKE '%$each_string%' AND searching = '1'".
-				" OR visibility != 'none' AND visibility != 'deleted' AND menu_title LIKE '%$each_string%' AND searching = '1'".
-				" OR visibility != 'none' AND visibility != 'deleted' AND description LIKE '%$each_string%' AND searching = '1'".
-				" OR visibility != 'none' AND visibility != 'deleted' AND keywords LIKE '%$each_string%' AND searching = '1'";
-				$count = $count+1;
+		$query_pages = "SELECT page_id, page_title, menu_title, link, description, modified_when, modified_by FROM ".TABLE_PREFIX."pages WHERE ";
+		$count = 0;
+		foreach($string AS $each_string) {
+			if($count != 0) { 
+				$query_pages .= $logical_operator;
 			}
-			$query_pages = $database->query($query_pages);
+			$query_pages .= " visibility != 'none' AND visibility != 'deleted' AND searching = '1'".
+			" AND (page_title LIKE '%$each_string%' OR menu_title LIKE '%$each_string%' OR description LIKE '%$each_string%' OR keywords LIKE '%$each_string%')";
+			$count = $count+1;
+		}
+		$count = 0;
+		$query_pages .= ' OR';
+		foreach($string_entities AS $each_string) {
+			if($count != 0) { 
+				$query_pages .= $logical_operator;
+			}
+			$query_pages .= " visibility != 'none' AND visibility != 'deleted' AND searching = '1'".
+			" AND (page_title LIKE '%$each_string%' OR menu_title LIKE '%$each_string%' OR description LIKE '%$each_string%' OR keywords LIKE '%$each_string%')";
+			$count = $count+1;
+		}
+		$query_pages = $database->query($query_pages);
 		// Loop through pages
 		if($query_pages->numRows() > 0) {
 			while($page = $query_pages->fetchRow()) {
 				// Get page link
 				$link = page_link($page['link']);
+				
+				//Add search string for highlighting
+				if ($match!='exact') {
+					$sstring = implode(" ", $string);
+					$link = $link."?searchresult=1&amp;sstring=".urlencode($sstring);
+				}
+				else {
+					$sstring = strtr($string[0], " ", "_");
+					$link = $link."?searchresult=2&amp;sstring=".urlencode($sstring);
+				}
+				
 				// Set vars to be replaced by values
 				$vars = array('[LINK]', '[TITLE]', '[DESCRIPTION]', '[USERNAME]','[DISPLAY_NAME]','[DATE]','[TIME]','[TEXT_LAST_UPDATED_BY]','[TEXT_ON]');
 				if($page['modified_when'] > 0) {
@@ -201,11 +245,24 @@
 							$prepared_query = $query_start;
 							$count = 0;
 							foreach($string AS $each_string) {
-								if($count != 0) { $prepared_query .= $logical_operator; }
+								if($count != 0) {
+									$prepared_query .= $logical_operator;
+								}
 								$prepared_query .= str_replace('[STRING]', $each_string, $query_body);
 								$count = $count+1;
 							}
+							$count=0;
+							$prepared_query .= ' OR ';
+							foreach($string_entities AS $each_string) {
+								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);
 							// Loop though queried items
@@ -215,6 +272,17 @@
 									if(!isset($fields['page_id']) OR !isset($pages_listed[$page[$fields['page_id']]])) {
 										// Get page link
 										$link = page_link($page[$fields['link']]);
+										
+										//Add search string for highlighting
+										if ($match!='exact') {
+											$sstring = implode(" ", $string);
+											$link = $link."?searchresult=1&amp;sstring=".urlencode($sstring);
+										}
+										else {
+											$sstring = strtr($string[0], " ", "_");
+											$link = $link."?searchresult=2&amp;sstring=".urlencode($sstring);
+										}
+										
 										// Set vars to be replaced by values
 										$vars = array('[LINK]', '[TITLE]', '[DESCRIPTION]', '[USERNAME]','[DISPLAY_NAME]','[DATE]','[TIME]','[TEXT_LAST_UPDATED_BY]','[TEXT_ON]');
 										if($page[$fields['modified_when']] > 0) {
@@ -236,7 +304,6 @@
 									}
 								}
 							}
-						
 						}
 					}
 				}
@@ -247,10 +314,10 @@
 			
 		}
 	
-	// Say no items found if we should
-	if($pages_listed == array() AND $items_listed == array()) {
-		echo $fetch_no_results['value'];
-	}
+		// Say no items found if we should
+		if($pages_listed == array() AND $items_listed == array()) {
+			echo $search_no_results;
+		}
 		
 	}
 	
Index: branches/2.6.x/wb/search/index.php
===================================================================
--- branches/2.6.x/wb/search/index.php	(revision 451)
+++ branches/2.6.x/wb/search/index.php	(revision 452)
@@ -34,8 +34,8 @@
 define('ROOT_PARENT', 0);
 define('PARENT', 0);
 define('LEVEL', 0);
-define('PAGE_TITLE', 'Search');
-define('MENU_TITLE', 'Search');
+define('PAGE_TITLE', $TEXT['SEARCH']);
+define('MENU_TITLE', $TEXT['SEARCH']);
 define('MODULE', '');
 define('VISIBILITY', 'public');
 define('PAGE_CONTENT', 'search.php');
Index: branches/2.6.x/wb/install/save.php
===================================================================
--- branches/2.6.x/wb/install/save.php	(revision 451)
+++ branches/2.6.x/wb/install/save.php	(revision 452)
@@ -548,7 +548,7 @@
 	
 	// Search header
 	$search_header = addslashes('
-<h1>Search</h1>
+<h1>[TEXT_SEARCH]</h1>
 
 <form name="search" action="[WB_URL]/search/index[PAGE_EXTENSION]" method="get">
 <table cellpadding="3" cellspacing="0" border="0" width="500">
@@ -603,7 +603,7 @@
 	$insert_search_results_footer = "INSERT INTO `".TABLE_PREFIX."search` VALUES ('', 'results_footer', '$search_results_footer', '')";
 	$database->query($insert_search_results_footer);
 	// Search no results
-	$search_no_results = addslashes('<br />No results found');
+	$search_no_results = addslashes('<br />[TEXT_NO_RESULTS]');
 	$insert_search_no_results = "INSERT INTO `".TABLE_PREFIX."search` VALUES ('', 'no_results', '$search_no_results', '')";
 	$database->query($insert_search_no_results);
 	// Search template
Index: branches/2.6.x/wb/admin/pages/settings.php
===================================================================
--- branches/2.6.x/wb/admin/pages/settings.php	(revision 451)
+++ branches/2.6.x/wb/admin/pages/settings.php	(revision 452)
@@ -76,8 +76,8 @@
 $template->set_block('page', 'main_block', 'main');
 $template->set_var(array(
 								'PAGE_ID' => $results_array['page_id'],
-								'PAGE_TITLE' => (htmlentities($results_array['page_title'])),
-								'MENU_TITLE' => (htmlentities($results_array['menu_title'])),
+								'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'],
@@ -249,7 +249,7 @@
 			for($i = 1; $i <= $page['level']; $i++) { $title_prefix .= ' - '; }
 			$template->set_var(array(
 											'ID' => $page['page_id'],
-											'TITLE' => ($title_prefix.htmlentities($page['page_title']))
+											'TITLE' => ($title_prefix.$page['page_title'])
 											)
 									);
 			if($results_array['parent'] == $page['page_id']) {
Index: branches/2.6.x/wb/admin/pages/index.php
===================================================================
--- branches/2.6.x/wb/admin/pages/index.php	(revision 451)
+++ branches/2.6.x/wb/admin/pages/index.php	(revision 452)
@@ -166,15 +166,15 @@
 				</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 (htmlentities($page['page_title'])); ?></a>				
+					<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 (htmlentities($page['page_title'])); ?>
+					<?php echo ($page['page_title']); ?>
 				</td>
 				<?php } ?>
 				<td align="left" width="232">
-					<font color="#999999"><?php echo (htmlentities($page['menu_title'])); ?></font>
+					<font color="#999999"><?php echo ($page['menu_title']); ?></font>
 				</td>
 				<td align="center" valign="middle" width="90">
 				<?php if($page['visibility'] == 'public') { ?>
@@ -462,7 +462,7 @@
 			for($i = 1; $i <= $page['level']; $i++) { $title_prefix .= ' - '; }
 				$template->set_var(array(
 												'ID' => $page['page_id'],
-												'TITLE' => ($title_prefix.htmlentities($page['page_title']))
+												'TITLE' => ($title_prefix.$page['page_title'])
 												)
 										);
 				if($can_modify == true) {
Index: branches/2.6.x/wb/admin/pages/trash.php
===================================================================
--- branches/2.6.x/wb/admin/pages/trash.php	(revision 451)
+++ branches/2.6.x/wb/admin/pages/trash.php	(revision 452)
@@ -141,21 +141,21 @@
 				</td>
 				<?php if($admin->get_permission('pages_modify') == true AND $can_modify == true AND $page['visibility'] != 'heading') { ?>
 				<td>
-					<a href="<?php echo ADMIN_URL; ?>/pages/modify.php?page_id=<?php echo $page['page_id']; ?>" title="<?php echo $TEXT['MODIFY']; ?>"><?php echo (htmlentities($page['page_title'])); ?></a>
+					<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
 					if($page['visibility'] != 'heading') {
-						echo (htmlentities($page['page_title']));
+						echo ($page['page_title']);
 					} else {
-						echo '<b>'.(htmlentities($page['page_title'])).'</b>';
+						echo '<b>'.($page['page_title']).'</b>';
 					}
 					?>
 				</td>
 				<?php } ?>
 				<td align="left" width="232">
-					<font color="#999999"><?php echo htmlentities($page['menu_title']); ?></font>
+					<font color="#999999"><?php echo $page['menu_title']; ?></font>
 				</td>
 				<td align="right" valign="middle" width="30" style="padding-right: 20px;">
 				<?php if($page['visibility'] == 'public') { ?>
Index: branches/2.6.x/wb/admin/pages/settings2.php
===================================================================
--- branches/2.6.x/wb/admin/pages/settings2.php	(revision 451)
+++ branches/2.6.x/wb/admin/pages/settings2.php	(revision 452)
@@ -41,7 +41,9 @@
 
 // Get values
 $page_title = $admin->add_slashes($admin->get_post_escaped('page_title'));
+$page_title = my_htmlspecialchars($page_title);
 $menu_title = $admin->add_slashes($admin->get_post_escaped('menu_title'));
+$menu_title = my_htmlspecialchars($menu_title);
 $description = $admin->add_slashes($admin->get_post('description'));
 $keywords = $admin->add_slashes($admin->get_post('keywords'));
 $parent = $admin->get_post('parent');
@@ -55,10 +57,10 @@
 $menu = $admin->get_post('menu');
 
 // Validate data
-if($page_title == '') {
+if($page_title == '' || substr($page_title,0,1)=='.') {
 	$admin->print_error($MESSAGE['PAGES']['BLANK_PAGE_TITLE']);
 }
-if($menu_title == '') {
+if($menu_title == '' || substr($menu_title,0,1)=='.') {
 	$admin->print_error($MESSAGE['PAGES']['BLANK_MENU_TITLE']);
 }
 
@@ -114,7 +116,7 @@
 // Work-out what the link should be
 if($parent == '0') {
 	$link = '/'.page_filename($menu_title);
-	$filename = WB_PATH.PAGES_DIRECTORY.'/'.page_filename($menu_title).'.php';
+	$filename = WB_PATH.PAGES_DIRECTORY.'/'.page_filename($menu_title).PAGE_EXTENSION; 
 } else {
 	$parent_section = '';
 	$parent_titles = array_reverse(get_parent_titles($parent));
@@ -123,7 +125,7 @@
 	}
 	if($parent_section == '/') { $parent_section = ''; }
 	$link = '/'.$parent_section.page_filename($menu_title);
-	$filename = WB_PATH.PAGES_DIRECTORY.'/'.$parent_section.page_filename($menu_title).'.php';
+	$filename = WB_PATH.PAGES_DIRECTORY.'/'.$parent_section.page_filename($menu_title).PAGE_EXTENSION;  
 }
 
 // Check if a page with same page filename exists
@@ -142,9 +144,10 @@
 $page_trail = get_page_trail($page_id);
 
 // Make sure link is not overwritten if page uses the menu link module
-if(strstr($old_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) {
 	$link = $old_link;
-}
+} 
 
 // Update page settings in the pages table
 $query = "UPDATE ".TABLE_PREFIX."pages SET parent = '$parent', page_title = '$page_title', menu_title = '$menu_title', menu = '$menu', level = '$level', page_trail = '$page_trail', root_parent = '$root_parent', link = '$link', template = '$template', target = '$target', description = '$description', keywords = '$keywords', position = '$position', visibility = '$visibility', searching = '$searching', language = '$language', admin_groups = '$admin_groups', viewing_groups = '$viewing_groups' WHERE page_id = '$page_id'";
@@ -164,7 +167,7 @@
 	// First check if we need to create a new file
 	if($old_link != $link) {
 		// Delete old file
-		unlink(WB_PATH.PAGES_DIRECTORY.$old_link.'.php');
+		unlink(WB_PATH.PAGES_DIRECTORY.$old_link.PAGE_EXTENSION);
 		// Create access file
 		create_access_file($filename,$page_id,$level);
 		// Move a directory for this page
@@ -187,11 +190,11 @@
 					// Update level and link
 					$database->query("UPDATE ".TABLE_PREFIX."pages SET link = '$new_sub_link', level = '$new_sub_level' WHERE page_id = '".$sub['page_id']."' LIMIT 1");
 					// Re-write the access file for this page
-					$old_subpage_file = WB_PATH.PAGES_DIRECTORY.$new_sub_link.'.php';
+					$old_subpage_file = WB_PATH.PAGES_DIRECTORY.$new_sub_link.PAGE_EXTENSION;
 					if(file_exists($old_subpage_file)) {
 						unlink($old_subpage_file);
 					}
-					create_access_file(WB_PATH.PAGES_DIRECTORY.$new_sub_link.'.php', $sub['page_id'], $new_sub_level);
+					create_access_file(WB_PATH.PAGES_DIRECTORY.$new_sub_link.PAGE_EXTENSION, $sub['page_id'], $new_sub_level);
 				}
 			}
 		}
@@ -199,7 +202,7 @@
 }
 
 // Function to fix page trail of subs
-function fix_page_trail($parent) {
+function fix_page_trail($parent,$root_parent) {
 	// Get objects and vars from outside this function
 	global $admin, $template, $database, $TEXT, $MESSAGE;
 	// Get page list from database
@@ -210,14 +213,14 @@
 	if($get_pages->numRows() > 0)	{
 		while($page = $get_pages->fetchRow()) {
 			// Fix page trail
-			$database->query("UPDATE ".TABLE_PREFIX."pages SET page_trail = '".get_page_trail($page['page_id'])."' WHERE page_id = '".$page['page_id']."'");
+			$database->query("UPDATE ".TABLE_PREFIX."pages SET ".($root_parent != 0 ?"root_parent = '$root_parent', ":"")." page_trail = '".get_page_trail($page['page_id'])."' WHERE page_id = '".$page['page_id']."'");
 			// Run this query on subs
-			fix_page_trail($page['page_id']);
+			fix_page_trail($page['page_id'],$root_parent);
 		}
 	}
 }
 // Fix sub-pages page trail
-fix_page_trail($page_id);
+fix_page_trail($page_id,$root_parent);
 
 /* END page "access file" code */
 
Index: branches/2.6.x/wb/admin/pages/sections.php
===================================================================
--- branches/2.6.x/wb/admin/pages/sections.php	(revision 451)
+++ branches/2.6.x/wb/admin/pages/sections.php	(revision 452)
@@ -138,7 +138,7 @@
 	</td>
 	<td align="right">
 		<?php echo $TEXT['CURRENT_PAGE']; ?>: 
-		<b><?php echo (htmlentities($results_array['page_title'])); ?></b>
+		<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>
 		-
Index: branches/2.6.x/wb/admin/pages/modify.php
===================================================================
--- branches/2.6.x/wb/admin/pages/modify.php	(revision 451)
+++ branches/2.6.x/wb/admin/pages/modify.php	(revision 452)
@@ -60,7 +60,7 @@
 $template->set_block('page', 'main_block', 'main');
 $template->set_var(array(
 								'PAGE_ID' => $results_array['page_id'],
-								'PAGE_TITLE' => (htmlentities($results_array['page_title'])),
+								'PAGE_TITLE' => ($results_array['page_title']),
 								'MODIFIED_BY' => $user['display_name'],
 								'MODIFIED_BY_USERNAME' => $user['username'],
 								'MODIFIED_WHEN' => $modified_ts,
@@ -97,15 +97,19 @@
 $template->pparse('output', 'page');
 
 // Get sections for this page
+$module_permissions = $_SESSION['MODULE_PERMISSIONS'];
 $query_sections = $database->query("SELECT section_id,module FROM ".TABLE_PREFIX."sections WHERE page_id = '$page_id' ORDER BY position ASC");
 if($query_sections->numRows() > 0) {
 	while($section = $query_sections->fetchRow()) {
 		$section_id = $section['section_id'];
 		$module = $section['module'];
-		// Include the modules editing script if it exists
-		if(file_exists(WB_PATH.'/modules/'.$module.'/modify.php')) {
-			echo '<a name="'.$section_id.'"></a>';
-			require(WB_PATH.'/modules/'.$module.'/modify.php');
+		//Have permission?
+		if(!is_numeric(array_search($module, $module_permissions))) {
+			// Include the modules editing script if it exists
+			if(file_exists(WB_PATH.'/modules/'.$module.'/modify.php')) {
+				echo '<a name="'.$section_id.'"></a>';
+				require(WB_PATH.'/modules/'.$module.'/modify.php');
+			}
 		}
 	}
 }
Index: branches/2.6.x/wb/admin/pages/add.php
===================================================================
--- branches/2.6.x/wb/admin/pages/add.php	(revision 451)
+++ branches/2.6.x/wb/admin/pages/add.php	(revision 452)
@@ -33,6 +33,7 @@
 
 // Get values
 $title = $admin->add_slashes($admin->get_post_escaped('title'));
+$title = my_htmlspecialchars($title);
 $module = $admin->get_post('type');
 $parent = $admin->get_post('parent');
 $visibility = $admin->get_post('visibility');
@@ -47,7 +48,7 @@
 }	
 
 // Validate data
-if($title == '') {
+if($title == '' || substr($title,0,1)=='.') {
 	$admin->print_error($MESSAGE['PAGES']['BLANK_PAGE_TITLE']);
 }
 
Index: branches/2.6.x/wb/admin/login/index.php
===================================================================
--- branches/2.6.x/wb/admin/login/index.php	(revision 451)
+++ branches/2.6.x/wb/admin/login/index.php	(revision 452)
@@ -1,70 +1,70 @@
-<?php
-
-// $Id$
-
-/*
-
- Website Baker Project <http://www.websitebaker.org/>
- Copyright (C) 2004-2007, Ryan Djurovich
-
- Website Baker is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- Website Baker is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Website Baker; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-*/
-
-require_once("../../config.php");
-require_once(WB_PATH."/framework/class.login.php");
-
-if(defined('SMART_LOGIN') AND SMART_LOGIN == 'enabled') {
-	// Generate username field name
-	$username_fieldname = 'username_';
-	$password_fieldname = 'password_';
-	$salt = "abchefghjkmnpqrstuvwxyz0123456789";
-	srand((double)microtime()*1000000);
-	$i = 0;
-	while ($i <= 7) {
-		$num = rand() % 33;
-		$tmp = substr($salt, $num, 1);
-		$username_fieldname = $username_fieldname . $tmp;
-		$password_fieldname = $password_fieldname . $tmp;
-		$i++;
-	}
-} else {
-	$username_fieldname = 'username';
-	$password_fieldname = 'password';
-}
-
-$thisApp = new Login(
-							array(
-									'MAX_ATTEMPS' => "50",
-									'WARNING_URL' => ADMIN_URL."/login/warning.html",
-									'USERNAME_FIELDNAME' => $username_fieldname,
-									'PASSWORD_FIELDNAME' => $password_fieldname,
-									'REMEMBER_ME_OPTION' => SMART_LOGIN,
-									'MIN_USERNAME_LEN' => "2",
-									'MIN_PASSWORD_LEN' => "2",
-									'MAX_USERNAME_LEN' => "30",
-									'MAX_PASSWORD_LEN' => "30",
-									'LOGIN_URL' => ADMIN_URL."/login/index.php",
-									'DEFAULT_URL' => ADMIN_URL."/start/index.php",
-									'TEMPLATE_DIR' => ADMIN_PATH."/login",
-									'TEMPLATE_FILE' => "template.html",
-									'FRONTEND' => false,
-									'FORGOTTEN_DETAILS_APP' => ADMIN_URL."/login/forgot/index.php",
-									'USERS_TABLE' => TABLE_PREFIX."users",
-									'GROUPS_TABLE' => TABLE_PREFIX."groups",
-							)
-					);
-
+<?php
+
+// $Id$
+
+/*
+
+ Website Baker Project <http://www.websitebaker.org/>
+ Copyright (C) 2004-2007, Ryan Djurovich
+
+ Website Baker is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ Website Baker is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Website Baker; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+*/
+
+require_once("../../config.php");
+require_once(WB_PATH."/framework/class.login.php");
+
+if(defined('SMART_LOGIN') AND SMART_LOGIN == 'enabled') {
+	// Generate username field name
+	$username_fieldname = 'username_';
+	$password_fieldname = 'password_';
+	$salt = "abchefghjkmnpqrstuvwxyz0123456789";
+	srand((double)microtime()*1000000);
+	$i = 0;
+	while ($i <= 7) {
+		$num = rand() % 33;
+		$tmp = substr($salt, $num, 1);
+		$username_fieldname = $username_fieldname . $tmp;
+		$password_fieldname = $password_fieldname . $tmp;
+		$i++;
+	}
+} else {
+	$username_fieldname = 'username';
+	$password_fieldname = 'password';
+}
+
+$thisApp = new Login(
+							array(
+									'MAX_ATTEMPS' => "3",
+									'WARNING_URL' => ADMIN_URL."/login/warning.html",
+									'USERNAME_FIELDNAME' => $username_fieldname,
+									'PASSWORD_FIELDNAME' => $password_fieldname,
+									'REMEMBER_ME_OPTION' => SMART_LOGIN,
+									'MIN_USERNAME_LEN' => "2",
+									'MIN_PASSWORD_LEN' => "2",
+									'MAX_USERNAME_LEN' => "30",
+									'MAX_PASSWORD_LEN' => "30",
+									'LOGIN_URL' => ADMIN_URL."/login/index.php",
+									'DEFAULT_URL' => ADMIN_URL."/start/index.php",
+									'TEMPLATE_DIR' => ADMIN_PATH."/login",
+									'TEMPLATE_FILE' => "template.html",
+									'FRONTEND' => false,
+									'FORGOTTEN_DETAILS_APP' => ADMIN_URL."/login/forgot/index.php",
+									'USERS_TABLE' => TABLE_PREFIX."users",
+									'GROUPS_TABLE' => TABLE_PREFIX."groups",
+							)
+					);
+
 ?>
\ No newline at end of file
Index: branches/2.6.x/wb/admin/modules/details.php
===================================================================
--- branches/2.6.x/wb/admin/modules/details.php	(revision 451)
+++ branches/2.6.x/wb/admin/modules/details.php	(revision 452)
@@ -55,6 +55,27 @@
 	$module = $result->fetchRow();
 }
 
+// Get language description if available
+// First get users defined language
+$query = "SELECT language FROM ".TABLE_PREFIX."users WHERE user_id = '".$admin->get_user_id()."'";
+$results = $database->query($query);
+if($results->numRows() > 0) {
+	// We found a language for the user, store it
+	$user_info=$results->fetchRow();
+	$user_language = $user_info['language'];
+
+	// Next check for language file in module dir and insert the variables from that file
+	if(file_exists(WB_PATH.'/modules/'.$file.'/languages/'.$user_language.'.php')) {
+		require(WB_PATH.'/modules/'.$file.'/languages/'.$user_language.'.php');
+		
+		// Check to see if new variable exists... -> $module_description
+		if (isset($module_description)) {
+			// Override the module-description with correct desription in users language
+			$module['description']=$module_description;
+		}	
+	}
+}
+
 $template->set_var(array(
 								'NAME' => $module['name'],
 								'AUTHOR' => $module['author'],
Index: branches/2.6.x/wb/modules/wysiwyg/save.php
===================================================================
--- branches/2.6.x/wb/modules/wysiwyg/save.php	(revision 451)
+++ branches/2.6.x/wb/modules/wysiwyg/save.php	(revision 452)
@@ -29,10 +29,14 @@
 $update_when_modified = true; // Tells script to update when this page was last updated
 require(WB_PATH.'/modules/admin.php');
 
+// Include the WB functions file
+require_once(WB_PATH.'/framework/functions.php');
+
 // Update the mod_wysiwygs table with the contents
 if(isset($_POST['content'.$section_id])) {
 	$content = $admin->add_slashes($_POST['content'.$section_id]);
-	$text = strip_tags($content);
+	// searching in $text will be much easier this way
+	$text = umlauts_to_entities(strip_tags($content), strtoupper(DEFAULT_CHARSET), 0);
 	$database = new database();
 	$query = "UPDATE ".TABLE_PREFIX."mod_wysiwyg SET content = '$content', text = '$text' WHERE section_id = '$section_id'";
 	$database->query($query);	
Index: branches/2.6.x/wb/modules/form/install.php
===================================================================
--- branches/2.6.x/wb/modules/form/install.php	(revision 451)
+++ branches/2.6.x/wb/modules/form/install.php	(revision 452)
@@ -87,12 +87,12 @@
 	$query_start_code = "SELECT [TP]pages.page_id, [TP]pages.page_title,	[TP]pages.link, [TP]pages.description, [TP]pages.modified_when, [TP]pages.modified_by	FROM [TP]mod_form_fields, [TP]mod_form_settings, [TP]pages WHERE ";
 	$database->query("INSERT INTO ".TABLE_PREFIX."search (name,value,extra) VALUES ('query_start', '$query_start_code', 'form')");
 	// Query body
-	$query_body_code = " [TP]pages.page_id = [TP]mod_form_settings.page_id AND [TP]mod_form_settings.header [O] \'[W][STRING][W]\' AND [TP]pages.searching = \'1\'
-	OR [TP]pages.page_id = [TP]mod_form_settings.page_id AND [TP]mod_form_settings.footer [O] \'[W][STRING][W]\' AND [TP]pages.searching = \'1\'
-	OR [TP]pages.page_id = [TP]mod_form_fields.page_id AND [TP]mod_form_fields.title [O] \'[W][STRING][W]\' AND [TP]pages.searching = \'1\'";
+	$query_body_code = " [TP]pages.page_id = [TP]mod_form_settings.page_id AND [TP]mod_form_settings.header LIKE \'%[STRING]%\'
+	OR [TP]pages.page_id = [TP]mod_form_settings.page_id AND [TP]mod_form_settings.footer LIKE \'%[STRING]%\'
+	OR [TP]pages.page_id = [TP]mod_form_fields.page_id AND [TP]mod_form_fields.title LIKE \'%[STRING]%\' ";
 	$database->query("INSERT INTO ".TABLE_PREFIX."search (name,value,extra) VALUES ('query_body', '$query_body_code', 'form')");
 	// Query end
-	$query_end_code = '';
+	$query_end_code = "";
 	$database->query("INSERT INTO ".TABLE_PREFIX."search (name,value,extra) VALUES ('query_end', '$query_end_code', 'form')");
 	
 	// Insert blank row (there needs to be at least on row for the search to work)
Index: branches/2.6.x/wb/modules/form/view.php
===================================================================
--- branches/2.6.x/wb/modules/form/view.php	(revision 451)
+++ branches/2.6.x/wb/modules/form/view.php	(revision 452)
@@ -380,7 +380,9 @@
 	if(isset($success) AND $success == true) {
 		echo $success_message;
 	} else {
-		echo $TEXT['ERROR'];
+		if(isset($success) AND $success == false) {
+			echo $TEXT['ERROR'];
+		}
 	}
 	
 }
Index: branches/2.6.x/wb/modules/form/modify.php
===================================================================
--- branches/2.6.x/wb/modules/form/modify.php	(revision 451)
+++ branches/2.6.x/wb/modules/form/modify.php	(revision 452)
@@ -31,6 +31,9 @@
 // Must include code to stop this file being access directly
 if(!defined('WB_PATH')) { exit("Cannot access this file directly"); }
 
+//Delete all form fields with no title
+$database->query("DELETE FROM ".TABLE_PREFIX."mod_form_fields  WHERE page_id = '$page_id' and section_id = '$section_id' and title=''");
+
 ?>
 <table cellpadding="0" cellspacing="0" border="0" width="100%">
 <tr>
Index: branches/2.6.x/wb/modules/news/install.php
===================================================================
--- branches/2.6.x/wb/modules/news/install.php	(revision 451)
+++ branches/2.6.x/wb/modules/news/install.php	(revision 452)
@@ -130,7 +130,8 @@
 	$database->query("INSERT INTO ".TABLE_PREFIX."mod_news_settings (section_id,page_id) VALUES ('0', '0')");
 	
 	// Make news post access files dir
-	make_dir(WB_PATH.PAGES_DIRECTORY.'/posts/');
+	require_once(WB_PATH.'/framework/functions.php');
+	make_dir(WB_PATH.PAGES_DIRECTORY.'/posts');
 	
 }
 
Index: branches/2.6.x/wb/modules/news/rss.php
===================================================================
--- branches/2.6.x/wb/modules/news/rss.php	(revision 451)
+++ branches/2.6.x/wb/modules/news/rss.php	(revision 452)
@@ -46,25 +46,27 @@
 $wb->get_website_settings();
 
 // Sending XML header
-header("Content-type: text/xml");
+header("Content-type: text/xml; charset=utf-8" );
 
 // Header info
 // Required by CSS 2.0
+?>
+<rss version="2.0" >
+<channel>
+<title><?php echo PAGE_TITLE; ?></title>
+<link>http://<?php echo $_SERVER['SERVER_NAME']; ?></link>
+<description> <?php echo PAGE_DESCRIPTION; ?></description>
+<?php
+// Optional header info 
+?>
+<language><?php echo DEFAULT_LANGUAGE; ?></language>
+<copyright><?php echo WB_URL.$_SERVER['REQUEST_URI']; ?></copyright>
+<managingEditor><?php echo SERVER_EMAIL; ?></managingEditor>
+<webMaster><?php echo SERVER_EMAIL; ?></webMaster>
+<category><?php echo WEBSITE_TITLE; ?></category>
+<generator>Website Baker Content Management System</generator>
 
-echo "<rss version='2.0'>";
-echo "<channel>";
-echo "<title>".PAGE_TITLE."</title>";
-echo "<link>".WB_URL."</link>";
-echo "<description>".PAGE_DESCRIPTION."</description>";
-
-// Optional header info
-echo "<language>".DEFAULT_LANGUAGE."</language>";
-echo "<copyright>".WB_URL."</copyright>";
-echo "<managingEditor>".SERVER_EMAIL."</managingEditor>";
-echo "<webMaster>".SERVER_EMAIL."</webMaster>";
-echo "<category>".WEBSITE_TITLE."</category>";
-echo "<generator>Website Baker Content Management System</generator>";
-
+<?php
 // Get news items from database
 
 //Query
@@ -76,23 +78,16 @@
 $result = $database->query($query);
 
 //Generating the news items
-while($item = $result->fetchRow($result)){
+while($item = $result->fetchRow($result)){ ?>
 
-    echo "<item>";
-    echo "<title>".$item["title"]."</title>";
-    // Stripping HTML Tags for text-only visibility
-    echo "<description>".strip_tags($item["content_short"])."</description>";
-    echo "<link>".WB_URL."/pages".$item["link"].PAGE_EXTENSION."</link>";
-    /* Add further (non required) information here like ie.
-    echo "<author>".$item["posted_by"]."</author>");
-    etc.
-    */
-    echo "</item>";
+<item>
+<title><![CDATA[<?php echo stripslashes($item["title"]); ?>]]></title>
+<description><![CDATA[<?php echo stripslashes($item["content_short"]); ?>]]></description>
+<guid><?php echo WB_URL."/pages".$item["link"].PAGE_EXTENSION; ?></guid>
+<link><?php echo WB_URL."/pages".$item["link"].PAGE_EXTENSION; ?></link>
+</item>
 
-}
+<?php } ?>
 
-// Writing footer information
-echo "</channel>";
-echo "</rss>";
-
-?>
\ No newline at end of file
+</channel>
+</rss>
\ No newline at end of file
Index: branches/2.6.x/wb/modules/news/uninstall.php
===================================================================
--- branches/2.6.x/wb/modules/news/uninstall.php	(revision 451)
+++ branches/2.6.x/wb/modules/news/uninstall.php	(revision 452)
@@ -32,7 +32,8 @@
 $database->query("DROP TABLE ".TABLE_PREFIX."mod_news_groups");
 $database->query("DROP TABLE ".TABLE_PREFIX."mod_news_comments");
 $database->query("DROP TABLE ".TABLE_PREFIX."mod_news_settings");
-require(WB_PATH.'/framework/functions.php');
+
+require_once(WB_PATH.'/framework/functions.php');
 rm_full_dir(WB_PATH.PAGES_DIRECTORY.'/posts');
 
 ?>
\ No newline at end of file
Index: branches/2.6.x/wb/account/login.php
===================================================================
--- branches/2.6.x/wb/account/login.php	(revision 451)
+++ branches/2.6.x/wb/account/login.php	(revision 452)
@@ -1,86 +1,86 @@
-<?php
-
-// $Id$
-
-/*
-
- Website Baker Project <http://www.websitebaker.org/>
- Copyright (C) 2004-2007, Ryan Djurovich
-
- Website Baker is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- Website Baker is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Website Baker; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-*/
-
-require_once("../config.php");
-
-// Make sure the login is enabled
-if(!FRONTEND_LOGIN) {
-	if(INTRO_PAGE) {
-		header('Location: '.WB_URL.PAGES_DIRECTORY.'/index'.PAGE_EXTENSION);
-		exit(0);
-	} else {
-		header('Location: '.WB_URL.'/index'.PAGE_EXTENSION);
-		exit(0);
-	}
-}
-
-// Required page details
-$page_id = 0;
-$page_description = '';
-$page_keywords = '';
-define('PAGE_ID', 0);
-define('ROOT_PARENT', 0);
-define('PARENT', 0);
-define('LEVEL', 0);
-define('PAGE_TITLE', 'Please login');
-define('MENU_TITLE', 'Please login');
-define('VISIBILITY', 'public');
-// Set the page content include file
-define('PAGE_CONTENT', WB_PATH.'/account/login_form.php');
-
-require_once(WB_PATH.'/framework/class.login.php');
-
-// Create new login app
-$thisApp = new Login(
-							array(
-									"MAX_ATTEMPS" => "50",
-									"WARNING_URL" => ADMIN_URL."/login/warning.html",
-									"USERNAME_FIELDNAME" => 'username',
-									"PASSWORD_FIELDNAME" => 'password',
-									"REMEMBER_ME_OPTION" => SMART_LOGIN,
-									"MIN_USERNAME_LEN" => "2",
-									"MIN_PASSWORD_LEN" => "2",
-									"MAX_USERNAME_LEN" => "30",
-									"MAX_PASSWORD_LEN" => "30",
-									"LOGIN_URL" => WB_URL."/account/login".PAGE_EXTENSION.'?redirect='.$_REQUEST['redirect'],
-									"DEFAULT_URL" => WB_URL.PAGES_DIRECTORY."/index".PAGE_EXTENSION,
-									"TEMPLATE_DIR" => ADMIN_PATH."/login",
-									"TEMPLATE_FILE" => "template.html",
-									"FRONTEND" => true,
-									"FORGOTTEN_DETAILS_APP" => WB_URL."/account/forgot.php".PAGE_EXTENSION,
-									"USERS_TABLE" => TABLE_PREFIX."users",
-									"GROUPS_TABLE" => TABLE_PREFIX."groups",
-									"REDIRECT_URL" => $_REQUEST['redirect']
-							)
-					);
-
-// Set extra outsider var
-$globals[] = 'thisApp';
-
-// Include the index (wrapper) file
-require(WB_PATH.'/index.php');
-
-
+<?php
+
+// $Id$
+
+/*
+
+ Website Baker Project <http://www.websitebaker.org/>
+ Copyright (C) 2004-2007, Ryan Djurovich
+
+ Website Baker is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ Website Baker is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Website Baker; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+*/
+
+require_once("../config.php");
+
+// Make sure the login is enabled
+if(!FRONTEND_LOGIN) {
+	if(INTRO_PAGE) {
+		header('Location: '.WB_URL.PAGES_DIRECTORY.'/index'.PAGE_EXTENSION);
+		exit(0);
+	} else {
+		header('Location: '.WB_URL.'/index'.PAGE_EXTENSION);
+		exit(0);
+	}
+}
+
+// Required page details
+$page_id = 0;
+$page_description = '';
+$page_keywords = '';
+define('PAGE_ID', 0);
+define('ROOT_PARENT', 0);
+define('PARENT', 0);
+define('LEVEL', 0);
+define('PAGE_TITLE', 'Please login');
+define('MENU_TITLE', 'Please login');
+define('VISIBILITY', 'public');
+// Set the page content include file
+define('PAGE_CONTENT', WB_PATH.'/account/login_form.php');
+
+require_once(WB_PATH.'/framework/class.login.php');
+
+// Create new login app
+$thisApp = new Login(
+							array(
+									"MAX_ATTEMPS" => "3",
+									"WARNING_URL" => ADMIN_URL."/login/warning.html",
+									"USERNAME_FIELDNAME" => 'username',
+									"PASSWORD_FIELDNAME" => 'password',
+									"REMEMBER_ME_OPTION" => SMART_LOGIN,
+									"MIN_USERNAME_LEN" => "2",
+									"MIN_PASSWORD_LEN" => "2",
+									"MAX_USERNAME_LEN" => "30",
+									"MAX_PASSWORD_LEN" => "30",
+									"LOGIN_URL" => WB_URL."/account/login".PAGE_EXTENSION.'?redirect='.$_REQUEST['redirect'],
+									"DEFAULT_URL" => WB_URL.PAGES_DIRECTORY."/index".PAGE_EXTENSION,
+									"TEMPLATE_DIR" => ADMIN_PATH."/login",
+									"TEMPLATE_FILE" => "template.html",
+									"FRONTEND" => true,
+									"FORGOTTEN_DETAILS_APP" => WB_URL."/account/forgot.php".PAGE_EXTENSION,
+									"USERS_TABLE" => TABLE_PREFIX."users",
+									"GROUPS_TABLE" => TABLE_PREFIX."groups",
+									"REDIRECT_URL" => $_REQUEST['redirect']
+							)
+					);
+
+// Set extra outsider var
+$globals[] = 'thisApp';
+
+// Include the index (wrapper) file
+require(WB_PATH.'/index.php');
+
+
 ?>
\ No newline at end of file
Index: branches/2.6.x/wb/framework/convert.php
===================================================================
--- branches/2.6.x/wb/framework/convert.php	(revision 451)
+++ branches/2.6.x/wb/framework/convert.php	(revision 452)
@@ -25,8 +25,7 @@
 
 /*
 Character Conversion file
-This file helps convert possible error-causing
-characters to equivalent non-error-causing ones
+to convert some entities to there 7bit equivalents
 */
 if(!defined('WB_URL')) {
 	header('Location: ../index.php');
@@ -34,41 +33,269 @@
 }
 
 $conversion_array = array(
-'À'=>'A','�?'=>'A','Â'=>'A','Ã'=>'A','Ä'=>'Ae', '&Auml;'=>'A',
-'Å'=>'A','Ā'=>'A','Ą'=>'A','Ă'=>'A', 'Æ'=>'Ae',
-'Ç'=>'C','Ć'=>'C','Č'=>'C','Ĉ'=>'C','Ċ'=>'C',
-'Ď'=>'D','�?'=>'D','�?'=>'D',
-'È'=>'E','É'=>'E','Ê'=>'E','Ë'=>'E','Ē'=>'E',
-'Ę'=>'E','Ě'=>'E','Ĕ'=>'E','Ė'=>'E',
-'Ĝ'=>'G','Ğ'=>'G','Ġ'=>'G','Ģ'=>'G',
-'Ĥ'=>'H','Ħ'=>'H',
-'Ì'=>'I','�?'=>'I','Î'=>'I','�?'=>'I','Ī'=>'I', 'Ĩ'=>'I','Ĭ'=>'I','Į'=>'I','İ'=>'I',
-'Ĳ'=>'IJ','Ĵ'=>'J','Ķ'=>'K',
-'�?'=>'K','Ľ'=>'K','Ĺ'=>'K','Ļ'=>'K','Ŀ'=>'K',
-'Ñ'=>'N','Ń'=>'N','Ň'=>'N','Ņ'=>'N','Ŋ'=>'N',
-'Ò'=>'O','Ó'=>'O','Ô'=>'O','Õ'=>'O','Ö'=>'Oe',
-'&Ouml;'=>'Oe', 'Ø'=>'O','Ō'=>'O','�?'=>'O','Ŏ'=>'O',
-'Œ'=>'OE', 'Ŕ'=>'R','Ř'=>'R','Ŗ'=>'R',
-'Ś'=>'S','Š'=>'S','Ş'=>'S','Ŝ'=>'S','Ș'=>'S',
-'Ť'=>'T','Ţ'=>'T','Ŧ'=>'T','Ț'=>'T',
-'Ù'=>'U','Ú'=>'U','Û'=>'U','Ü'=>'Ue','Ū'=>'U',
-'&Uuml;'=>'Ue', 'Ů'=>'U','Ű'=>'U','Ŭ'=>'U','Ũ'=>'U','Ų'=>'U',
-'Ŵ'=>'W', '�?'=>'Y','Ŷ'=>'Y','Ÿ'=>'Y', 'Ź'=>'Z','Ž'=>'Z','Ż'=>'Z',
-'Þ'=>'T','Þ'=>'T', 'à'=>'a','á'=>'a','â'=>'a','ã'=>'a','ä'=>'ae',
-'&auml;'=>'ae', 'å'=>'a','�?'=>'a','ą'=>'a','ă'=>'a',
-'æ'=>'ae', 'ç'=>'c','ć'=>'c','�?'=>'c','ĉ'=>'c','ċ'=>'c',
-'�?'=>'d','đ'=>'d','ð'=>'d', 'è'=>'e','é'=>'e','ê'=>'e','ë'=>'e','ē'=>'e',
-'ę'=>'e','ě'=>'e','ĕ'=>'e','ė'=>'e', 'ƒ'=>'f',
-'�?'=>'g','ğ'=>'g','ġ'=>'g','ģ'=>'g', 'ĥ'=>'h','ħ'=>'h',
-'ì'=>'i','í'=>'i','î'=>'i','ï'=>'i','ī'=>'i', 'ĩ'=>'i','ĭ'=>'i','į'=>'i','ı'=>'i',
-'ĳ'=>'ij', 'ĵ'=>'j', 'ķ'=>'k','ĸ'=>'k', 'ł'=>'l','ľ'=>'l','ĺ'=>'l','ļ'=>'l','ŀ'=>'l',
-'ñ'=>'n','ń'=>'n','ň'=>'n','ņ'=>'n','ŉ'=>'n', 'ŋ'=>'n',
-'ò'=>'o','ó'=>'o','ô'=>'o','õ'=>'o','ö'=>'oe', '&ouml;'=>'oe',
-'ø'=>'o','�?'=>'o','ő'=>'o','�?'=>'o', 'œ'=>'oe', 'ŕ'=>'r','ř'=>'r','ŗ'=>'r',
-'š'=>'s', 'ù'=>'u','ú'=>'u','û'=>'u','ü'=>'ue','ū'=>'u', '&uuml;'=>'ue',
-'ů'=>'u','ű'=>'u','ŭ'=>'u','ũ'=>'u','ų'=>'u', 'ŵ'=>'w',
-'ý'=>'y','ÿ'=>'y','ŷ'=>'y', 'ž'=>'z','ż'=>'z','ź'=>'z', 'þ'=>'t', 'ß'=>'ss', 'ſ'=>'ss',
-'ä'=>'ae', 'ö'=>'oe', 'ü'=>'ue', 'Ä'=>'Ae', 'Ö'=>'Oe', 'Ü'=>'Ue'
+
+//### LATIN
+'&Aacute;'=>'A','&aacute;'=>'a','&Acirc;'=>'A','&acirc;'=>'a','&AElig;'=>'AE','&aelig;'=>'ae','&Agrave;'=>'A','&agrave;'=>'a','&Aring;'=>'A','&aring;'=>'a','&Atilde;'=>'A','&atilde;'=>'a','&Auml;'=>'AE','&auml;'=>'ae',
+'&Ccedil;'=>'C','&ccedil;'=>'c',
+'&Eacute;'=>'E','&eacute;'=>'e','&Ecirc;'=>'E','&ecirc;'=>'e','&Egrave;'=>'E','&egrave;'=>'e','&Euml;'=>'E','&euml;'=>'e',
+'&Iacute;'=>'I','&iacute;'=>'i','&Icirc;'=>'I','&icirc;'=>'i','&Igrave;'=>'I','&igrave;'=>'i','&Iuml;'=>'I','&iuml;'=>'i',
+'&Ntilde;'=>'N','&ntilde;'=>'n',
+'&Oacute;'=>'O','&oacute;'=>'o','&Ocirc;'=>'O','&ocirc;'=>'o','&OElig;'=>'OE','&oelig;'=>'oe','&Ograve;'=>'O','&ograve;'=>'o','&Otilde;'=>'O','&otilde;'=>'o','&Ouml;'=>'OE','&ouml;'=>'oe',
+'&Scaron;'=>'S','&scaron;'=>'s',
+'&szlig;'=>'ss',
+'&Uacute;'=>'U','&uacute;'=>'u','&Ucirc;'=>'U','&ucirc;'=>'u','&Ugrave;'=>'U','&ugrave;'=>'u','&Uuml;'=>'UE','&uuml;'=>'ue',
+'&Yacute;'=>'Y','&yacute;'=>'y','&Yuml;'=>'Y','&yuml;'=>'y',
+'&#138;'=>'S',
+'&#140;'=>'OE','&#156;'=>'oe',
+'&#154;'=>'s',
+'&#159;'=>'Y',
+'&copy;'=>'(c)','&reg;'=>'(r)','&ETH;'=>'D','&times;'=>'x','&Oslash;'=>'O','&THORN;'=>'TH','&eth;'=>'d','&oslash;'=>'o','&thorn;'=>'th',
+
+// latin extended-A
+'&#256;'=>'A','&#257;'=>'a','&#258;'=>'A','&#259;'=>'a','&#260;'=>'A','&#261;'=>'a',
+'&#262;'=>'C','&#263;'=>'c','&#264;'=>'C','&#265;'=>'c','&#269;'=>'c','&#268;'=>'C','&#267;'=>'c','&#266;'=>'C',
+'&#273;'=>'d','&#272;'=>'D','&#271;'=>'d','&#270;'=>'D',
+'&#275;'=>'e','&#274;'=>'E','&#276;'=>'E','&#277;'=>'e','&#278;'=>'E','&#279;'=>'e','&#280;'=>'E','&#281;'=>'e','&#282;'=>'E','&#283;'=>'e',
+'&#284;'=>'G','&#285;'=>'g','&#286;'=>'G','&#287;'=>'g','&#288;'=>'G','&#289;'=>'g','&#290;'=>'G','&#291;'=>'g',
+'&#292;'=>'H','&#293;'=>'h','&#294;'=>'H','&#295;'=>'h',
+'&#296;'=>'I','&#297;'=>'i','&#298;'=>'I','&#299;'=>'i','&#300;'=>'I','&#301;'=>'i','&#302;'=>'I','&#303;'=>'i','&#304;'=>'I','&#305;'=>'i',
+'&#306;'=>'IJ','&#307;'=>'ij',
+'&#308;'=>'J','&#309;'=>'j',
+'&#310;'=>'K','&#311;'=>'k','&#312;'=>'k',
+'&#313;'=>'L','&#314;'=>'l','&#315;'=>'L','&#316;'=>'l','&#317;'=>'L','&#318;'=>'l','&#319;'=>'L','&#320;'=>'l','&#321;'=>'L','&#322;'=>'l',
+'&#323;'=>'N','&#324;'=>'n','&#325;'=>'N','&#326;'=>'n','&#327;'=>'N','&#328;'=>'n','&#329;'=>'n','&#330;'=>'N','&#331;'=>'n',
+'&#332;'=>'O','&#333;'=>'o','&#334;'=>'O','&#335;'=>'o','&#336;'=>'O','&#337;'=>'o',
+'&#340;'=>'R','&#341;'=>'r','&#342;'=>'R','&#343;'=>'r','&#344;'=>'R','&#345;'=>'r',
+'&#346;'=>'S','&#347;'=>'s','&#348;'=>'S','&#349;'=>'s','&#350;'=>'S','&#351;'=>'s',
+'&#354;'=>'T','&#355;'=>'t','&#356;'=>'T','&#357;'=>'t','&#358;'=>'T','&#359;'=>'t',
+'&#360;'=>'U','&#361;'=>'u','&#362;'=>'U','&#363;'=>'u','&#364;'=>'U','&#365;'=>'u','&#366;'=>'U','&#367;'=>'u','&#368;'=>'U','&#369;'=>'u','&#370;'=>'U','&#371;'=>'u',
+'&#372;'=>'W','&#373;'=>'w',
+'&#374;'=>'Y','&#375;'=>'y','&#376;'=>'Y',
+'&#377;'=>'Z','&#378;'=>'z','&#379;'=>'Z','&#380;'=>'z','&#381;'=>'Z','&#382;'=>'z',
+'&#383;'=>'s',
+'&#64256;'=>'ff','&#64257;'=>'fi','&#64258;'=>'fl','&#64259;'=>'ffi','&#64260;'=>'ffl',
+'&#64261;'=>'st',
+'&#64262;'=>'st',
+// latin extended-b
+'&#384;'=>'b','&#385;'=>'B','&#386;'=>'B','&#387;'=>'b','&#388;'=>'6','&#389;'=>'6',
+'&#390;'=>'O','&#391;'=>'C','&#392;'=>'c','&#393;'=>'D','&#394;'=>'D','&#395;'=>'D',
+'&#396;'=>'d','&#397;'=>'d','&#398;'=>'E','&#399;'=>'e','&#400;'=>'E','&#401;'=>'F',
+'&fnof;'=>'f','&#403;'=>'G','&#404;'=>'G','&#405;'=>'hw','&#406;'=>'I','&#407;'=>'I',
+'&#408;'=>'K','&#409;'=>'k','&#410;'=>'l','&#411;'=>'l','&#412;'=>'M','&#413;'=>'N',
+'&#414;'=>'n','&#415;'=>'O','&#416;'=>'O','&#417;'=>'o','&#418;'=>'OI','&#419;'=>'oi',
+'&#420;'=>'P','&#421;'=>'p','&#422;'=>'YR','&#423;'=>'2','&#424;'=>'2','&#425;'=>'ESH',
+'&#426;'=>'esh','&#427;'=>'t','&#428;'=>'T','&#429;'=>'t','&#430;'=>'T','&#431;'=>'U',
+'&#432;'=>'u','&#433;'=>'V','&#434;'=>'v','&#435;'=>'Y','&#436;'=>'y','&#437;'=>'Z',
+'&#438;'=>'z','&#439;'=>'EZH','&#440;'=>'EZH','&#441;'=>'ezh','&#442;'=>'ezh','&#443;'=>'2',
+'&#444;'=>'5','&#445;'=>'5','&#446;'=>'-','&#447;'=>'w','&#448;'=>'-','&#449;'=>'-',
+'&#450;'=>'-','&#451;'=>'-','&#452;'=>'DZ','&#453;'=>'DZ','&#454;'=>'dz','&#455;'=>'LJ',
+'&#456;'=>'Lj','&#457;'=>'lj','&#458;'=>'NJ','&#459;'=>'Nj','&#460;'=>'nj','&#461;'=>'A',
+'&#462;'=>'a','&#463;'=>'I','&#464;'=>'i','&#465;'=>'O','&#466;'=>'o','&#467;'=>'U',
+'&#468;'=>'u','&#469;'=>'U','&#470;'=>'u','&#471;'=>'U','&#472;'=>'u','&#473;'=>'U',
+'&#474;'=>'u','&#475;'=>'U','&#476;'=>'u','&#477;'=>'e','&#478;'=>'A','&#479;'=>'a',
+'&#480;'=>'A','&#481;'=>'a','&#482;'=>'AE','&#483;'=>'ae','&#484;'=>'G','&#485;'=>'g',
+'&#486;'=>'G','&#487;'=>'g','&#488;'=>'K','&#489;'=>'k','&#490;'=>'O','&#491;'=>'o',
+'&#492;'=>'O','&#493;'=>'o','&#494;'=>'EZH','&#495;'=>'ezh','&#496;'=>'j','&#497;'=>'DZ',
+'&#498;'=>'Dz','&#499;'=>'dz','&#500;'=>'G','&#501;'=>'g','&#502;'=>'HW','&#503;'=>'W',
+'&#504;'=>'N','&#505;'=>'n','&#506;'=>'A','&#507;'=>'a','&#508;'=>'AE','&#509;'=>'ae',
+'&#510;'=>'O','&#511;'=>'o','&#512;'=>'A','&#513;'=>'a','&#514;'=>'A','&#515;'=>'a',
+'&#516;'=>'E','&#517;'=>'e','&#518;'=>'E','&#519;'=>'e','&#520;'=>'I','&#521;'=>'i',
+'&#522;'=>'I','&#523;'=>'i','&#524;'=>'O','&#525;'=>'o','&#526;'=>'O','&#527;'=>'o',
+'&#528;'=>'R','&#529;'=>'r','&#530;'=>'R','&#531;'=>'r','&#532;'=>'U','&#533;'=>'u',
+'&#534;'=>'U','&#535;'=>'u','&#536;'=>'S','&#537;'=>'s','&#538;'=>'T','&#539;'=>'t',
+'&#540;'=>'Y','&#541;'=>'y','&#542;'=>'H','&#543;'=>'h','&#544;'=>'n','&#545;'=>'d',
+'&#546;'=>'OU','&#547;'=>'ou','&#548;'=>'Z','&#549;'=>'z','&#550;'=>'A','&#551;'=>'a',
+'&#552;'=>'E','&#553;'=>'e','&#554;'=>'O','&#555;'=>'o','&#556;'=>'O','&#557;'=>'o',
+'&#558;'=>'O','&#559;'=>'o','&#560;'=>'O','&#561;'=>'o','&#562;'=>'Y','&#563;'=>'y',
+'&#564;'=>'l','&#565;'=>'n','&#566;'=>'t','&#567;'=>'j','&#568;'=>'db','&#569;'=>'qp',
+'&#570;'=>'A','&#571;'=>'C','&#572;'=>'c','&#573;'=>'L','&#574;'=>'T','&#575;'=>'s',
+'&#576;'=>'z','&#577;'=>'-',
+// latin extended additional
+'&#7680;'=>'A','&#7681;'=>'a',
+'&#7682;'=>'B','&#7683;'=>'b','&#7684;'=>'B','&#7685;'=>'b','&#7686;'=>'B','&#7687;'=>'b',
+'&#7688;'=>'C','&#7689;'=>'c',
+'&#7690;'=>'D','&#7691;'=>'d','&#7692;'=>'D','&#7693;'=>'d','&#7694;'=>'D','&#7695;'=>'d','&#7696;'=>'D','&#7697;'=>'d','&#7698;'=>'D','&#7699;'=>'d',
+'&#7700;'=>'E','&#7701;'=>'e','&#7702;'=>'E','&#7703;'=>'e','&#7704;'=>'E','&#7705;'=>'e','&#7706;'=>'E','&#7707;'=>'e','&#7708;'=>'E','&#7709;'=>'e',
+'&#7710;'=>'F','&#7711;'=>'f',
+'&#7712;'=>'G','&#7713;'=>'g',
+'&#7714;'=>'H','&#7715;'=>'h','&#7716;'=>'H','&#7717;'=>'h','&#7718;'=>'H','&#7719;'=>'h','&#7720;'=>'H','&#7721;'=>'h','&#7722;'=>'H','&#7723;'=>'h',
+'&#7724;'=>'I','&#7725;'=>'i','&#7726;'=>'I','&#7727;'=>'i',
+'&#7728;'=>'K','&#7729;'=>'k','&#7730;'=>'K','&#7731;'=>'k','&#7732;'=>'K','&#7733;'=>'k',
+'&#7734;'=>'L','&#7735;'=>'l','&#7736;'=>'L','&#7737;'=>'l','&#7738;'=>'L','&#7739;'=>'l','&#7740;'=>'L','&#7741;'=>'l',
+'&#7742;'=>'M','&#7743;'=>'m','&#7744;'=>'M','&#7745;'=>'m','&#7746;'=>'M','&#7747;'=>'m',
+'&#7748;'=>'N','&#7749;'=>'n','&#7750;'=>'N','&#7751;'=>'n','&#7752;'=>'N','&#7753;'=>'n','&#7754;'=>'N','&#7755;'=>'n',
+'&#7756;'=>'O','&#7757;'=>'o','&#7758;'=>'O','&#7759;'=>'o','&#7760;'=>'O','&#7761;'=>'o','&#7762;'=>'O','&#7763;'=>'o',
+'&#7764;'=>'P','&#7765;'=>'p','&#7766;'=>'P','&#7767;'=>'p',
+'&#7768;'=>'R','&#7769;'=>'r','&#7770;'=>'R','&#7771;'=>'r','&#7772;'=>'R','&#7773;'=>'r','&#7774;'=>'R','&#7775;'=>'r',
+'&#7776;'=>'S','&#7777;'=>'s','&#7778;'=>'S','&#7779;'=>'s','&#7780;'=>'S','&#7781;'=>'s','&#7782;'=>'S','&#7783;'=>'s','&#7784;'=>'S','&#7785;'=>'s',
+'&#7786;'=>'T','&#7787;'=>'t','&#7788;'=>'T','&#7789;'=>'t','&#7790;'=>'T','&#7791;'=>'t','&#7792;'=>'T','&#7793;'=>'t',
+'&#7794;'=>'U','&#7795;'=>'u','&#7796;'=>'U','&#7797;'=>'u','&#7798;'=>'U','&#7799;'=>'u','&#7800;'=>'U','&#7801;'=>'u','&#7802;'=>'U','&#7803;'=>'u',
+'&#7804;'=>'V','&#7805;'=>'v','&#7806;'=>'V','&#7807;'=>'v',
+'&#7808;'=>'W','&#7809;'=>'w','&#7810;'=>'W','&#7811;'=>'w','&#7812;'=>'W','&#7813;'=>'w','&#7814;'=>'W','&#7815;'=>'w','&#7816;'=>'W','&#7817;'=>'w',
+'&#7818;'=>'X','&#7819;'=>'x','&#7820;'=>'X','&#7821;'=>'x',
+'&#7822;'=>'Y','&#7823;'=>'y',
+'&#7824;'=>'Z','&#7825;'=>'z','&#7826;'=>'Z','&#7827;'=>'z','&#7828;'=>'Z','&#7829;'=>'z',
+'&#7830;'=>'h',
+'&#7831;'=>'t',
+'&#7832;'=>'w',
+'&#7833;'=>'y',
+'&#7834;'=>'a',
+'&#7835;'=>'f',
+'&#7840;'=>'A','&#7841;'=>'a','&#7842;'=>'A','&#7843;'=>'a','&#7844;'=>'A','&#7845;'=>'a','&#7846;'=>'A','&#7847;'=>'a','&#7848;'=>'A','&#7849;'=>'a',
+'&#7850;'=>'A','&#7851;'=>'a','&#7852;'=>'A','&#7853;'=>'a','&#7854;'=>'A','&#7855;'=>'a','&#7856;'=>'A','&#7857;'=>'a','&#7858;'=>'A','&#7859;'=>'a','&#7860;'=>'A','&#7861;'=>'a','&#7862;'=>'A','&#7863;'=>'a',
+'&#7864;'=>'E','&#7865;'=>'e','&#7866;'=>'E','&#7867;'=>'e','&#7868;'=>'E','&#7869;'=>'e','&#7870;'=>'E','&#7871;'=>'e','&#7872;'=>'E','&#7873;'=>'e','&#7874;'=>'E','&#7875;'=>'e','&#7876;'=>'E','&#7877;'=>'e','&#7878;'=>'E','&#7879;'=>'e',
+'&#7880;'=>'I','&#7881;'=>'i','&#7882;'=>'I','&#7883;'=>'i',
+'&#7884;'=>'O','&#7885;'=>'o','&#7886;'=>'O','&#7887;'=>'o','&#7888;'=>'O','&#7889;'=>'o','&#7890;'=>'O','&#7891;'=>'o','&#7892;'=>'O','&#7893;'=>'o','&#7894;'=>'O','&#7895;'=>'o',
+'&#7896;'=>'O','&#7897;'=>'o','&#7898;'=>'O','&#7899;'=>'o','&#7900;'=>'O','&#7901;'=>'o','&#7902;'=>'O','&#7903;'=>'o','&#7904;'=>'O','&#7905;'=>'o','&#7906;'=>'O','&#7907;'=>'o',
+'&#7908;'=>'U','&#7909;'=>'u','&#7910;'=>'U','&#7911;'=>'u','&#7912;'=>'U','&#7913;'=>'u','&#7914;'=>'U','&#7915;'=>'u','&#7916;'=>'U','&#7917;'=>'u','&#7918;'=>'U','&#7919;'=>'u','&#7920;'=>'U','&#7921;'=>'u',
+'&#7922;'=>'Y','&#7923;'=>'y','&#7924;'=>'Y','&#7925;'=>'y','&#7926;'=>'Y','&#7927;'=>'y','&#7928;'=>'Y','&#7929;'=>'y',
+
+//### CYRILLIC (transliteration following iso 9:1995)
+'&#1040;'=>'A','&#1072;'=>'a', // A
+'&#1232;'=>'A','&#1233;'=>'a', // A WITH BREVE
+'&#1234;'=>'A','&#1235;'=>'a', // A WITH DIAERESIS
+'&#1236;'=>'A','&#1237;'=>'a', // LIGATURE A IE
+'&#1240;'=>'A','&#1241;'=>'a', // SCHWA
+'&#1242;'=>'A','&#1243;'=>'a', // SCHWA WITH DIAERESIS
+'&#1041;'=>'B','&#1073;'=>'b', // BE
+'&#1042;'=>'V','&#1074;'=>'v', // VE
+'&#1043;'=>'G','&#1075;'=>'g', // GHE
+'&#1168;'=>'G','&#1169;'=>'g', // GHE WITH UPTURN
+'&#1172;'=>'G','&#1173;'=>'g', // GHE WITH MIDDLE HOOK
+'&#1170;'=>'G','&#1171;'=>'g', // GHE WITH STROKE
+'&#1270;'=>'G','&#1271;'=>'g', // GHE WITH DESCENDER
+'&#1044;'=>'D','&#1076;'=>'d', // DE
+'&#1026;'=>'D','&#1106;'=>'d', // DJE
+'&#1027;'=>'G','&#1107;'=>'g', // GJE
+'&#1024;'=>'E','&#1104;'=>'e', // IE WITH GRAVE
+'&#1045;'=>'E','&#1077;'=>'e', // IE
+'&#1025;'=>'E','&#1105;'=>'e', // IO
+'&#1238;'=>'E','&#1239;'=>'e', // IE WITH BREVE
+'&#1028;'=>'E','&#1108;'=>'e', // UKRAINIAN IE
+'&#1212;'=>'C','&#1213;'=>'c', // ABKHASIAN CHE
+'&#1214;'=>'C','&#1215;'=>'c', // ABKHASIAN CHE WITH DESCENDER
+'&#1046;'=>'Z','&#1078;'=>'z', // ZHE
+'&#1217;'=>'Z','&#1218;'=>'z', // ZHE WITH BREVE
+'&#1244;'=>'Z','&#1245;'=>'z', // ZHE WITH DIAERESIS
+'&#1174;'=>'Z','&#1175;'=>'z', // ZHE WITH DESCENDER
+'&#1047;'=>'Z','&#1079;'=>'z', // ZE
+'&#1246;'=>'Z','&#1247;'=>'z', // ZE WITH DIAERESIS
+'&#1029;'=>'Z','&#1109;'=>'z', // DZE
+'&#1248;'=>'Z','&#1249;'=>'z', // ABKHASIAN DZE
+'&#1037;'=>'I','&#1117;'=>'i', // I WITH GRAVE
+'&#1048;'=>'I','&#1080;'=>'i', // I
+'&#1250;'=>'I','&#1251;'=>'i', // I WITH MACRON
+'&#1252;'=>'I','&#1253;'=>'i', // I WITH DIAERESIS
+'&#1030;'=>'I','&#1110;'=>'i', // BYELORUSSIAN-UKRAINIAN I
+'&#1031;'=>'I','&#1111;'=>'i', // YI
+'&#1049;'=>'J','&#1081;'=>'j', // SHORT I
+'&#1032;'=>'J','&#1112;'=>'j', // JE
+'&#1050;'=>'K','&#1082;'=>'k', // KA
+'&#1178;'=>'K','&#1179;'=>'k', // KA WITH DESCENDER
+'&#1180;'=>'K','&#1181;'=>'k', // KA WITH VERTICAL STROKE
+'&#1182;'=>'K','&#1183;'=>'k', // KA WITH STROKE
+'&#1184;'=>'K','&#1185;'=>'k', // BASHKIR KA
+'&#1051;'=>'L','&#1083;'=>'l', // EL
+'&#1033;'=>'L','&#1113;'=>'l', // LJE
+'&#1052;'=>'M','&#1084;'=>'m', // EM
+'&#1053;'=>'N','&#1085;'=>'n', // EN
+'&#1034;'=>'N','&#1114;'=>'n', // NJE
+'&#1188;'=>'N','&#1189;'=>'n', // LIGATURE EN GHE
+'&#1186;'=>'N','&#1187;'=>'n', // EN WITH DESCENDER
+'&#1054;'=>'O','&#1086;'=>'o', // O
+'&#1254;'=>'O','&#1255;'=>'o', // O WITH DIAERESIS
+'&#1256;'=>'O','&#1257;'=>'o', // BARRED O
+'&#1258;'=>'O','&#1259;'=>'o', // BARRED O WITH DIAERESIS
+'&#1055;'=>'P','&#1087;'=>'p', // PE
+'&#1190;'=>'P','&#1191;'=>'p', // PE WITH MIDDLE HOOK
+'&#1056;'=>'R','&#1088;'=>'r', // ER
+'&#1057;'=>'S','&#1089;'=>'s', // ES
+'&#1194;'=>'C','&#1195;'=>'c', // ES WITH DESCENDER
+'&#1058;'=>'T','&#1090;'=>'t', // TE
+'&#1196;'=>'T','&#1197;'=>'t', // TE WITH DESCENDER
+'&#1035;'=>'C','&#1115;'=>'c', // TSHE
+'&#1036;'=>'K','&#1116;'=>'k', // KJE
+'&#1059;'=>'U','&#1091;'=>'u', // U
+'&#1038;'=>'U','&#1118;'=>'u', // SHORT U
+'&#1262;'=>'U','&#1263;'=>'u', // U WITH MACRON
+'&#1264;'=>'U','&#1265;'=>'u', // U WITH DIAERESIS
+'&#1266;'=>'U','&#1267;'=>'u', // U WITH DOUBLE ACUTE
+'&#1198;'=>'U','&#1199;'=>'u', // STRAIGHT U
+'&#1200;'=>'U','&#1201;'=>'u', // STRAIGHT U WITH STROKE
+'&#1060;'=>'F','&#1092;'=>'f', // EF
+'&#1061;'=>'H','&#1093;'=>'h', // HA
+'&#1202;'=>'H','&#1203;'=>'h', // HA WITH DESCENDER
+'&#1210;'=>'H','&#1211;'=>'h', // SHHA
+'&#1062;'=>'C','&#1094;'=>'c', // TSE
+'&#1204;'=>'C','&#1205;'=>'c', // LIGATURE TE TSE
+'&#1063;'=>'C','&#1095;'=>'c', // CHE
+'&#1268;'=>'C','&#1269;'=>'c', // CHE WITH DIAERESIS
+'&#1206;'=>'C','&#1207;'=>'c', // CHE WITH DESCENDER
+'&#1208;'=>'C','&#1209;'=>'c', // CHE WITH VERTICAL STROKE
+'&#1039;'=>'D','&#1119;'=>'d', // DZHE
+'&#1064;'=>'S','&#1096;'=>'s', // SHA
+'&#1065;'=>'S','&#1097;'=>'s', // SHCHA
+'&#1067;'=>'Y','&#1099;'=>'y', // YERU
+'&#1272;'=>'Y','&#1273;'=>'y', // YERU WITH DIAERESIS
+'&#1069;'=>'E','&#1101;'=>'e', // E
+'&#1260;'=>'E','&#1261;'=>'e', // E WITH DIAERESIS
+'&#1070;'=>'U','&#1102;'=>'u', // YU
+'&#1071;'=>'A','&#1103;'=>'a', // YA
+'&#1122;'=>'E','&#1123;'=>'e', // YAT
+'&#1130;'=>'A','&#1131;'=>'a', // BIG YUS
+'&#1138;'=>'F','&#1139;'=>'f', // FITA
+'&#1140;'=>'Y','&#1141;'=>'y', // IZHITSA
+'&#1142;'=>'Y','&#1143;'=>'y', // IZHITSA WITH DOUBLE GRAVE ACCENT
+'&#1192;'=>'O','&#1193;'=>'o', // ABKHASIAN HA
+'&#1120;'=>'O','&#1121;'=>'o', // OMEGA
+'&#1124;'=>'E','&#1125;'=>'e', // IOTIFIED E
+'&#1126;'=>'U','&#1127;'=>'u', // LITTLE YUS (???)
+'&#1128;'=>'U','&#1129;'=>'u', // IOTIFIED LITTLE YUS (???)
+'&#1132;'=>'U','&#1133;'=>'u', // IOTIFIED BIG YUS (???)
+'&#1134;'=>'K','&#1135;'=>'k', // KSI (???)
+'&#1136;'=>'P','&#1137;'=>'p', // PSI (???)
+'&#1144;'=>'U','&#1145;'=>'u', // UK
+'&#1146;'=>'O','&#1147;'=>'o', // ROUND OMEGA (???)
+'&#1148;'=>'O','&#1149;'=>'o', // OMEGA WITH TITLO (???)
+'&#1150;'=>'O','&#1151;'=>'o', // OT (???)
+'&#1152;'=>'K','&#1153;'=>'k', // KOPPA (???)
+'&#1162;'=>'J','&#1163;'=>'j', // SHORT I WITH TAIL
+'&#1166;'=>'R','&#1166;'=>'r', // ER WITH TICK
+'&#1176;'=>'Z','&#1177;'=>'z', // ZE WITH DESCENDER
+'&#1219;'=>'K','&#1220;'=>'k', // KA WITH HOOK
+'&#1221;'=>'L','&#1222;'=>'l', // EL WITH TAIL
+'&#1223;'=>'N','&#1224;'=>'n', // EN WITH HOOK
+'&#1225;'=>'N','&#1226;'=>'n', // EN WITH TAIL
+'&#1227;'=>'C','&#1228;'=>'c', // KHAKASSIAN CHE
+'&#1229;'=>'M','&#1230;'=>'m', // EM WITH TAIL
+// specialchars
+'&#1098;'=>'-','&#1066;'=>'-', // HARD SIGN
+'&#1068;'=>'-','&#1100;'=>'-', // SOFT SIGN
+'&#1164;'=>'-', // SEMISOFT SIGN
+'&#1216;'=>'-', // PALOCHKA
+'&#769;'=>'',
+
+//### (new) GREEK (transcription following wikipedia: http://de.wikipedia.org/w/index.php?title=Wikipedia:Namenskonventionen/Neugriechisch&oldid=29601735 )
+// groups of two chars
+'&alpha;&iota;'=>'e','&Alpha;&iota;'=>'E',
+'&epsilon;&iota;'=>'i','&Epsilon;&iota;'=>'I',
+'&omicron;&iota;'=>'i','&Omicron;&iota;'=>'I',
+'&omicron;&upsilon;'=>'ou','&Omicron;&upsilon;'=>'Ou',
+'&alpha;&upsilon;'=>'av','&Alpha;&upsilon;'=>'Av',
+'&epsilon;&upsilon;'=>'ev','&Epsilon;&upsilon;'=>'Ev',
+'&eta;&upsilon;'=>'iv','&Eta;&upsilon;'=>'Iv',
+'&mu;&pi;'=>'mp','&Mu;&pi;'=>'B',
+'&nu;&tau;'=>'nt','&Nu;&tau;'=>'D',
+'&tau;&zeta;'=>'tz','&Tau;&zeta;'=>'Tz',
+'&gamma;&kappa;'=>'ng','&Gamma;&kappa;'=>'G',
+'&gamma;&gamma;'=>'ng','&Gamma;&gamma;'=>'Ng',
+// single chars
+'&#902;'=>'A','&#904;'=>'E','&#905;'=>'I','&#906;'=>'I','&#908;'=>'O','&#910;'=>'Y','&#911;'=>'O','&#912;'=>'i',
+'&Alpha;'=>'A','&Beta;'=>'V','&Gamma;'=>'G','&Delta;'=>'D','&Epsilon;'=>'E','&Zeta;'=>'Z','&Eta;'=>'I','&Theta;'=>'Th','&Iota;'=>'I','&Kappa;'=>'K','&Lambda;'=>'L','&Mu;'=>'M','&Nu;'=>'N','&Xi;'=>'X','&Omicron;'=>'O','&Pi;'=>'P','&Rho;'=>'R','&Sigma;'=>'S','&Tau;'=>'T','&Upsilon;'=>'Y','&Phi;'=>'F','&Chi;'=>'Ch','&Psi;'=>'Ps','&Omega;'=>'O',
+'&#938;'=>'I','&#939;'=>'Y','&#940;'=>'a','&#941;'=>'e','&#942;'=>'i','&#943;'=>'i','&#944;'=>'y',
+'&alpha;'=>'a','&beta;'=>'v','&gamma;'=>'g','&delta;'=>'d','&epsilon;'=>'e','&zeta;'=>'z','&eta;'=>'i','&theta;'=>'th','&iota;'=>'i','&kappa;'=>'k','&lambda;'=>'l','&mu;'=>'m','&nu;'=>'n','&xi;'=>'x','&omicron;'=>'o','&pi;'=>'p','&rho;'=>'r','&sigmaf;'=>'s','&sigma;'=>'s','&tau;'=>'t','&upsilon;'=>'y','&phi;'=>'f','&chi;'=>'ch','&psi;'=>'ps','&omega;'=>'o',
+'&#970;'=>'i','&#971;'=>'y','&#972;'=>'o','&#973;'=>'y','&#974;'=>'o','&#976;'=>'b','&thetasym;'=>'th','&upsih;'=>'y','&#979;'=>'y','&#980;'=>'y'
+
 );
 
 ?>
\ No newline at end of file
Index: branches/2.6.x/wb/framework/class.frontend.php
===================================================================
--- branches/2.6.x/wb/framework/class.frontend.php	(revision 451)
+++ branches/2.6.x/wb/framework/class.frontend.php	(revision 452)
@@ -1,387 +1,388 @@
-<?php
-
-// $Id$
-
-/*
-
- Website Baker Project <http://www.websitebaker.org/>
- Copyright (C) 2004-2007, 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
-
-*/
-
-/*
-
-Frontend class
-
-*/
-
-if(!defined('WB_PATH')) {
-	header('Location: ../index.php');
-	exit(0);
-}
-
-
-require_once(WB_PATH.'/framework/class.wb.php');
-
-class frontend extends wb {
-	// defaults
-	var $default_link,$default_page_id;
-	// when multiple blocks are used, show home page blocks on 
-	// pages where no content is defined (search, login, ...)
-	var $default_block_content=true;
-
-	// page details
-	// page database row
-	var $page;
-	var $page_id,$page_title,$menu_title,$parent,$root_parent,$level,$visibility;
-	var $page_description,$page_keywords,$page_link;
-	var $page_trail=array();
-	
-	var $page_access_denied;
-	
-	// website settings
-	var $website_title,$website_description,$website_keywords,$website_header,$website_footer;
-
-	// ugly database stuff
-	var $extra_where_sql, $sql_where_language;
-
-	function page_select() {
-		global $page_id,$no_intro;
-		global $database;
-		// We have no page id and are supposed to show the intro page
-		if((INTRO_PAGE AND !isset($no_intro)) AND (!isset($page_id) OR !is_numeric($page_id))) {
-			// Since we have no page id check if we should go to intro page or default page
-			// Get intro page content
-			$filename = WB_PATH.PAGES_DIRECTORY.'/intro.php';
-			if(file_exists($filename)) {
-				$handle = fopen($filename, "r");
-				$content = fread($handle, filesize($filename));
-				fclose($handle);
-				$this->preprocess($content);
-				echo ($content);
-				return false;
-			}
-		}
-		// Check if we should add page language sql code
-		if(PAGE_LANGUAGES) {
-			$this->sql_where_language = " AND language = '".LANGUAGE."'";
-		}
-		// Get default page
-		// Check for a page id
-		$query_default = "SELECT page_id,link FROM ".TABLE_PREFIX."pages WHERE parent = '0' AND visibility = 'public'$this->sql_where_language ORDER BY position ASC LIMIT 1";
-		$get_default = $database->query($query_default);
-		$default_num_rows = $get_default->numRows();
-		if(!isset($page_id) OR !is_numeric($page_id)){
-			// Go to or show default page
-			if($default_num_rows > 0) {
-				$fetch_default = $get_default->fetchRow();
-				$this->default_link = $fetch_default['link'];
-				$this->default_page_id = $fetch_default['page_id'];
-				// Check if we should redirect or include page inline
-				if(HOMEPAGE_REDIRECTION) {
-					// Redirect to page
-					header("Location: ".$this->page_link($this->default_link));
-					exit();
-				} else {
-					// Include page inline
-					$this->page_id = $this->default_page_id;
-				}
-			} else {
-		   		// No pages have been added, so print under construction page
-				$this->print_under_construction();
-				exit();
-			}
-		} else {
-			$this->page_id=$page_id;
-		}
-		// Get default page link
-		if(!isset($fetch_default)) {
-		  	$fetch_default = $get_default->fetchRow();
-	 		$this->default_link = $fetch_default['link'];
-			$this->default_page_id = $fetch_default['page_id'];
-		}
-		return true;
-	}
-
-	function get_page_details() {
-		global $database;
-	    if($this->page_id != 0) {
-			// Query page details
-			$query_page = "SELECT * FROM ".TABLE_PREFIX."pages WHERE page_id = '{$this->page_id}'";
-			$get_page = $database->query($query_page);
-			// Make sure page was found in database
-			if($get_page->numRows() == 0) {
-				// Print page not found message
-				exit("Page not found");
-			}
-			// Fetch page details
-			$this->page = $get_page->fetchRow();
-			// Check if the page language is also the selected language. If not, send headers again.
-			if ($this->page['language']!=LANGUAGE) {
-				header('Location: '.$this->page_link($this->page['link']).'?lang='.$this->page['language']);
-				exit();
-			}
-			// Begin code to set details as either variables of constants
-			// Page ID
-			define('PAGE_ID', $this->page['page_id']);
-			// Page Title
-			define('PAGE_TITLE', htmlentities(($this->page['page_title'])));
-			$this->page_title=PAGE_TITLE;
-			// Menu Title
-			$menu_title = htmlentities($this->page['menu_title']);
-			if($menu_title != '') {
-				define('MENU_TITLE', $menu_title);
-			} else {
-				define('MENU_TITLE', PAGE_TITLE);
-			}
-			$this->menu_title=MENU_TITLE;
-			// Page parent
-			define('PARENT', $this->page['parent']);
-			$this->parent=$this->page['parent'];
-			// Page root parent
-			define('ROOT_PARENT', $this->page['root_parent']);
-			$this->root_parent=$this->page['root_parent'];
-			// Page level
-			define('LEVEL', $this->page['level']);
-			$this->level=$this->page['level'];
-			// Page visibility
-			define('VISIBILITY', $this->page['visibility']);
-			$this->visibility=$this->page['visibility'];
-			// Page trail
-			foreach(explode(',', $this->page['page_trail']) AS $pid) {
-				$this->page_trail[$pid]=$pid;
-			}
-			// Page description
-			$this->page_description=$this->page['description'];
-			if($this->page_description != '') {
-				define('PAGE_DESCRIPTION', $this->page_description);
-			} else {
-				define('PAGE_DESCRIPTION', WEBSITE_DESCRIPTION);
-			}
-			// Page keywords
-			$this->page_keywords=$this->page['keywords'];
-			// Page link
-			$this->link=$this->page_link($this->page['link']);
-
-		// End code to set details as either variables of constants
-		}
-
-		// Figure out what template to use
-		if(!defined('TEMPLATE')) {
-			if(isset($this->page['template']) AND $this->page['template'] != '') {
-				if(file_exists(WB_PATH.'/templates/'.$this->page['template'].'/index.php')) {
-					define('TEMPLATE', $this->page['template']);
-				} else {
-					define('TEMPLATE', DEFAULT_TEMPLATE);
-				}
-			} else {
-				define('TEMPLATE', DEFAULT_TEMPLATE);
-			}
-		}
-		// Set the template dir
-		define('TEMPLATE_DIR', WB_URL.'/templates/'.TEMPLATE);
-
-		// Check if user is allowed to view this page
-		if(VISIBILITY == 'private' OR VISIBILITY == 'registered') {
-			// Check if the user is authenticated
-			if($this->is_authenticated() == false) {
-				// User needs to login first
-				header("Location: ".WB_URL."/account/login".PAGE_EXTENSION.'?redirect='.$this->link);
-				exit(0);
-			}
-			// Check if we should show this page
-			if($this->show_page($this->page) == false) {
-				$this->page_access_denied=true;
-			}
-		} elseif(VISIBILITY == 'deleted' OR VISIBILITY == 'none') {
-			// User isnt allowed on this page so tell them
-			$this->page_access_denied=true;
-		}
-	}
-
-	function get_website_settings() {
-		global $database;
-
-		// set visibility SQL code
-		// never show no-vis, hidden or deleted pages
-		$this->extra_where_sql = "visibility != 'none' AND visibility != 'hidden' AND visibility != 'deleted'";
-		// Set extra private sql code
-		if($this->is_authenticated()==false) {
-			// if user is not authenticated, don't show private pages either
-			$this->extra_where_sql .= " AND visibility != 'private'";
-			// and 'registered' without frontend login doesn't make much sense!
-			if (FRONTEND_LOGIN==false) {
-				$this->extra_where_sql .= " AND visibility != 'registered'";
-			}
-		}
-		$this->extra_where_sql .= $this->sql_where_language;
-
-		// Work-out if any possible in-line search boxes should be shown
-		if(SEARCH == 'public') {
-			define('SHOW_SEARCH', true);
-		} elseif(SEARCH == 'private' AND VISIBILITY == 'private') {
-			define('SHOW_SEARCH', true);
-		} elseif(SEARCH == 'private' AND $wb->is_authenticated() == true) {
-			define('SHOW_SEARCH', true);
-		} else {
-			define('SHOW_SEARCH', false);
-		}
-		// Work-out if menu should be shown
-		if(!defined('SHOW_MENU')) {
-			define('SHOW_MENU', true);
-		}
-		// Work-out if login menu constants should be set
-		if(FRONTEND_LOGIN) {
-			// Set login menu constants
-			define('LOGIN_URL', WB_URL.'/account/login'.PAGE_EXTENSION);
-			define('LOGOUT_URL', WB_URL.'/account/logout'.PAGE_EXTENSION);
-			define('FORGOT_URL', WB_URL.'/account/forgot'.PAGE_EXTENSION);
-			define('PREFERENCES_URL', WB_URL.'/account/preferences'.PAGE_EXTENSION);
-			define('SIGNUP_URL', WB_URL.'/account/signup'.PAGE_EXTENSION);
-		}
-	}
-	
-	function preprocess(&$content) {
-		global $database;
-		// Replace [wblink--PAGE_ID--] with real link
-		$pattern = '/\[wblink(.+?)\]/s';
-		preg_match_all($pattern,$content,$ids);
-		foreach($ids[1] AS $page_id) {
-			$pattern = '/\[wblink'.$page_id.'\]/s';
-			// Get page link
-			$get_link = $database->query("SELECT link FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id' LIMIT 1");
-			$fetch_link = $get_link->fetchRow();
-			$link = $this->page_link($fetch_link['link']);
-			$content = preg_replace($pattern,$link,$content);
-		}
-	}
-	
-	function menu() {
-		global $wb;
-	   if (!isset($wb->menu_number)) {
-	   	$wb->menu_number = 1;
-	   }
-	   if (!isset($wb->menu_start_level)) {
-	   	$wb->menu_start_level = 0;
-	   }
-	   if (!isset($wb->menu_recurse)) {
-	   	$wb->menu_recurse = -1;
-	   }
-	   if (!isset($wb->menu_collapse)) {
-	   	$wb->menu_collapse = true;
-	   }
-	   if (!isset($wb->menu_item_template)) {
-	   	$wb->menu_item_template = '<li><span[class]>[a] [menu_title] [/a]</span>';
-	   }
-	   if (!isset($wb->menu_item_footer)) {
-	   	$wb->menu_item_footer = '</li>';
-	   }
-	   if (!isset($wb->menu_header)) {
-	   	$wb->menu_header = '<ul>';
-	   }
-	   if (!isset($wb->menu_footer)) {
-	   	$wb->menu_footer = '</ul>';
-	   }
-	   if (!isset($wb->menu_default_class)) {
-	   	$wb->menu_default_class = ' class="menu_default"';
-	   }
-	   if (!isset($wb->menu_current_class)) {
-	   	$wb->menu_current_class = ' class="menu_current"';
-	   }
-	   if (!isset($wb->menu_parent)) {
-	   	$wb->menu_parent = 0;
-	   }
-	   $wb->show_menu();
-	}
-	
-	function show_menu() {
-		global $database;
-		if ($this->menu_start_level>0) {
-			$key_array=array_keys($this->page_trail);
-			if (isset($key_array[$this->menu_start_level-1])) {
-				$real_start=$key_array[$this->menu_start_level-1];
-				$this->menu_parent=$real_start;
-				$this->menu_start_level=0;
-			} else {
-				return;
-			}
-		}
-	   if ($this->menu_recurse==0)
-	       return;
-	   // Check if we should add menu number check to query
-	   if($this->menu_parent == 0) {
-	       $menu_number = "menu = '$this->menu_number'";
-	   } else {
-	      $menu_number = '1';
-	   }
-	   // Query pages
-	   $query_menu = $database->query("SELECT page_id,menu_title,page_title,link,target,level,visibility FROM ".
-	TABLE_PREFIX."pages WHERE parent = '$this->menu_parent' AND $menu_number AND $this->extra_where_sql ORDER BY position ASC");
-	   // Check if there are any pages to show
-	   if($query_menu->numRows() > 0) {
-	   	  // Print menu header
-	   	  echo "\n".$this->menu_header;
-	      // Loop through pages
-	      while($page = $query_menu->fetchRow()) {
-	      	 // Check if this page should be shown
-	         // Create vars
-	         $vars = array('[class]','[a]', '[/a]', '[menu_title]', '[page_title]');
-	         // Work-out class
-	         if($page['page_id'] == PAGE_ID) {
-	            $class = $this->menu_current_class;
-	         } else {
-	            $class = $this->menu_default_class;
-	         }
-	         // Check if link is same as first page link, and if so change to WB URL
-	         if($page['link'] == $this->default_link AND !INTRO_PAGE) {
-	            $link = WB_URL;
-	         } else {
-	            $link = $this->page_link($page['link']);
-	         }
-	         // Create values
-	         $values = array($class,'<a href="'.$link.'" target="'.$page['target'].'" '.$class.'>', '</a>', htmlentities($page['menu_title']), htmlentities($page['page_title']));
-	         // Replace vars with value and print
-	         echo "\n".str_replace($vars, $values, $this->menu_item_template);
-	         // Generate sub-menu
-	         if($this->menu_collapse==false OR ($this->menu_collapse==true AND isset($this->page_trail[$page['page_id']]))) {
-	            $this->menu_recurse--;
-	            $this->menu_parent=$page['page_id'];
-	            $this->show_menu();
-	         }
-	         echo "\n".$this->menu_item_footer;
-	      }
-	      // Print menu footer
-	      echo "\n".$this->menu_footer;
-	   }
-	}
-
-
-	// Function to show the "Under Construction" page
-	function print_under_construction() {
-		global $MESSAGE;
-		require_once(WB_PATH.'/languages/'.DEFAULT_LANGUAGE.'.php');
-		echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-		<head><title>'.$MESSAGE['GENERIC']['WEBSITE_UNDER_CONSTRUCTION'].'</title>
-		<style type="text/css"><!-- body { font-family: Verdana, Arial, Helvetica, sans-serif;
-		font-size: 12px; color: #000000;	background-color: #FFFFFF;	margin: 20px; text-align: center; }
-		h1 { margin: 0; padding: 0; }--></style></head><body>
-		<h1>'.$MESSAGE['GENERIC']['WEBSITE_UNDER_CONSTRUCTION'].'</h1><br />
-		'.$MESSAGE['GENERIC']['PLEASE_CHECK_BACK_SOON'].'</body></html>';
-	}
-}
-
+<?php
+
+// $Id$
+
+/*
+
+ Website Baker Project <http://www.websitebaker.org/>
+ Copyright (C) 2004-2007, 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
+
+*/
+
+/*
+
+Frontend class
+
+*/
+
+if(!defined('WB_PATH')) {
+	header('Location: ../index.php');
+	exit(0);
+}
+
+
+require_once(WB_PATH.'/framework/class.wb.php');
+
+class frontend extends wb {
+	// defaults
+	var $default_link,$default_page_id;
+	// when multiple blocks are used, show home page blocks on 
+	// pages where no content is defined (search, login, ...)
+	var $default_block_content=true;
+
+	// page details
+	// page database row
+	var $page;
+	var $page_id,$page_title,$menu_title,$parent,$root_parent,$level,$visibility;
+	var $page_description,$page_keywords,$page_link;
+	var $page_trail=array();
+	
+	var $page_access_denied;
+	
+	// website settings
+	var $website_title,$website_description,$website_keywords,$website_header,$website_footer;
+
+	// ugly database stuff
+	var $extra_where_sql, $sql_where_language;
+
+	function page_select() {
+		global $page_id,$no_intro;
+		global $database;
+		// We have no page id and are supposed to show the intro page
+		if((INTRO_PAGE AND !isset($no_intro)) AND (!isset($page_id) OR !is_numeric($page_id))) {
+			// Since we have no page id check if we should go to intro page or default page
+			// Get intro page content
+			$filename = WB_PATH.PAGES_DIRECTORY.'/intro.php';
+			if(file_exists($filename)) {
+				$handle = @fopen($filename, "r");
+				$content = @fread($handle, filesize($filename));
+				@fclose($handle);
+				$this->preprocess($content);
+				header("Location: pages/intro.php");   // send intro.php as header to allow parsing of php statements
+				echo ($content);
+				return false;
+			}
+		}
+		// Check if we should add page language sql code
+		if(PAGE_LANGUAGES) {
+			$this->sql_where_language = " AND language = '".LANGUAGE."'";
+		}
+		// Get default page
+		// Check for a page id
+		$query_default = "SELECT page_id,link FROM ".TABLE_PREFIX."pages WHERE parent = '0' AND visibility = 'public'$this->sql_where_language ORDER BY position ASC LIMIT 1";
+		$get_default = $database->query($query_default);
+		$default_num_rows = $get_default->numRows();
+		if(!isset($page_id) OR !is_numeric($page_id)){
+			// Go to or show default page
+			if($default_num_rows > 0) {
+				$fetch_default = $get_default->fetchRow();
+				$this->default_link = $fetch_default['link'];
+				$this->default_page_id = $fetch_default['page_id'];
+				// Check if we should redirect or include page inline
+				if(HOMEPAGE_REDIRECTION) {
+					// Redirect to page
+					header("Location: ".$this->page_link($this->default_link));
+					exit();
+				} else {
+					// Include page inline
+					$this->page_id = $this->default_page_id;
+				}
+			} else {
+		   		// No pages have been added, so print under construction page
+				$this->print_under_construction();
+				exit();
+			}
+		} else {
+			$this->page_id=$page_id;
+		}
+		// Get default page link
+		if(!isset($fetch_default)) {
+		  	$fetch_default = $get_default->fetchRow();
+	 		$this->default_link = $fetch_default['link'];
+			$this->default_page_id = $fetch_default['page_id'];
+		}
+		return true;
+	}
+
+	function get_page_details() {
+		global $database;
+	    if($this->page_id != 0) {
+			// Query page details
+			$query_page = "SELECT * FROM ".TABLE_PREFIX."pages WHERE page_id = '{$this->page_id}'";
+			$get_page = $database->query($query_page);
+			// Make sure page was found in database
+			if($get_page->numRows() == 0) {
+				// Print page not found message
+				exit("Page not found");
+			}
+			// Fetch page details
+			$this->page = $get_page->fetchRow();
+			// Check if the page language is also the selected language. If not, send headers again.
+			if ($this->page['language']!=LANGUAGE) {
+				header('Location: '.$this->page_link($this->page['link']).'?lang='.$this->page['language']);
+				exit();
+			}
+			// Begin code to set details as either variables of constants
+			// Page ID
+			define('PAGE_ID', $this->page['page_id']);
+			// Page Title
+			define('PAGE_TITLE', $this->page['page_title']);
+			$this->page_title=PAGE_TITLE;
+			// Menu Title
+			$menu_title = $this->page['menu_title'];
+			if($menu_title != '') {
+				define('MENU_TITLE', $menu_title);
+			} else {
+				define('MENU_TITLE', PAGE_TITLE);
+			}
+			$this->menu_title=MENU_TITLE;
+			// Page parent
+			define('PARENT', $this->page['parent']);
+			$this->parent=$this->page['parent'];
+			// Page root parent
+			define('ROOT_PARENT', $this->page['root_parent']);
+			$this->root_parent=$this->page['root_parent'];
+			// Page level
+			define('LEVEL', $this->page['level']);
+			$this->level=$this->page['level'];
+			// Page visibility
+			define('VISIBILITY', $this->page['visibility']);
+			$this->visibility=$this->page['visibility'];
+			// Page trail
+			foreach(explode(',', $this->page['page_trail']) AS $pid) {
+				$this->page_trail[$pid]=$pid;
+			}
+			// Page description
+			$this->page_description=$this->page['description'];
+			if($this->page_description != '') {
+				define('PAGE_DESCRIPTION', $this->page_description);
+			} else {
+				define('PAGE_DESCRIPTION', WEBSITE_DESCRIPTION);
+			}
+			// Page keywords
+			$this->page_keywords=$this->page['keywords'];
+			// Page link
+			$this->link=$this->page_link($this->page['link']);
+
+		// End code to set details as either variables of constants
+		}
+
+		// Figure out what template to use
+		if(!defined('TEMPLATE')) {
+			if(isset($this->page['template']) AND $this->page['template'] != '') {
+				if(file_exists(WB_PATH.'/templates/'.$this->page['template'].'/index.php')) {
+					define('TEMPLATE', $this->page['template']);
+				} else {
+					define('TEMPLATE', DEFAULT_TEMPLATE);
+				}
+			} else {
+				define('TEMPLATE', DEFAULT_TEMPLATE);
+			}
+		}
+		// Set the template dir
+		define('TEMPLATE_DIR', WB_URL.'/templates/'.TEMPLATE);
+
+		// Check if user is allowed to view this page
+		if(VISIBILITY == 'private' OR VISIBILITY == 'registered') {
+			// Check if the user is authenticated
+			if($this->is_authenticated() == false) {
+				// User needs to login first
+				header("Location: ".WB_URL."/account/login".PAGE_EXTENSION.'?redirect='.$this->link);
+				exit(0);
+			}
+			// Check if we should show this page
+			if($this->show_page($this->page) == false) {
+				$this->page_access_denied=true;
+			}
+		} elseif(VISIBILITY == 'deleted' OR VISIBILITY == 'none') {
+			// User isnt allowed on this page so tell them
+			$this->page_access_denied=true;
+		}
+	}
+
+	function get_website_settings() {
+		global $database;
+
+		// set visibility SQL code
+		// never show no-vis, hidden or deleted pages
+		$this->extra_where_sql = "visibility != 'none' AND visibility != 'hidden' AND visibility != 'deleted'";
+		// Set extra private sql code
+		if($this->is_authenticated()==false) {
+			// if user is not authenticated, don't show private pages either
+			$this->extra_where_sql .= " AND visibility != 'private'";
+			// and 'registered' without frontend login doesn't make much sense!
+			if (FRONTEND_LOGIN==false) {
+				$this->extra_where_sql .= " AND visibility != 'registered'";
+			}
+		}
+		$this->extra_where_sql .= $this->sql_where_language;
+
+		// Work-out if any possible in-line search boxes should be shown
+		if(SEARCH == 'public') {
+			define('SHOW_SEARCH', true);
+		} elseif(SEARCH == 'private' AND VISIBILITY == 'private') {
+			define('SHOW_SEARCH', true);
+		} elseif(SEARCH == 'private' AND $wb->is_authenticated() == true) {
+			define('SHOW_SEARCH', true);
+		} else {
+			define('SHOW_SEARCH', false);
+		}
+		// Work-out if menu should be shown
+		if(!defined('SHOW_MENU')) {
+			define('SHOW_MENU', true);
+		}
+		// Work-out if login menu constants should be set
+		if(FRONTEND_LOGIN) {
+			// Set login menu constants
+			define('LOGIN_URL', WB_URL.'/account/login'.PAGE_EXTENSION);
+			define('LOGOUT_URL', WB_URL.'/account/logout'.PAGE_EXTENSION);
+			define('FORGOT_URL', WB_URL.'/account/forgot'.PAGE_EXTENSION);
+			define('PREFERENCES_URL', WB_URL.'/account/preferences'.PAGE_EXTENSION);
+			define('SIGNUP_URL', WB_URL.'/account/signup'.PAGE_EXTENSION);
+		}
+	}
+	
+	function preprocess(&$content) {
+		global $database;
+		// Replace [wblink--PAGE_ID--] with real link
+		$pattern = '/\[wblink(.+?)\]/s';
+		preg_match_all($pattern,$content,$ids);
+		foreach($ids[1] AS $page_id) {
+			$pattern = '/\[wblink'.$page_id.'\]/s';
+			// Get page link
+			$get_link = $database->query("SELECT link FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id' LIMIT 1");
+			$fetch_link = $get_link->fetchRow();
+			$link = $this->page_link($fetch_link['link']);
+			$content = preg_replace($pattern,$link,$content);
+		}
+	}
+	
+	function menu() {
+		global $wb;
+	   if (!isset($wb->menu_number)) {
+	   	$wb->menu_number = 1;
+	   }
+	   if (!isset($wb->menu_start_level)) {
+	   	$wb->menu_start_level = 0;
+	   }
+	   if (!isset($wb->menu_recurse)) {
+	   	$wb->menu_recurse = -1;
+	   }
+	   if (!isset($wb->menu_collapse)) {
+	   	$wb->menu_collapse = true;
+	   }
+	   if (!isset($wb->menu_item_template)) {
+	   	$wb->menu_item_template = '<li><span[class]>[a] [menu_title] [/a]</span>';
+	   }
+	   if (!isset($wb->menu_item_footer)) {
+	   	$wb->menu_item_footer = '</li>';
+	   }
+	   if (!isset($wb->menu_header)) {
+	   	$wb->menu_header = '<ul>';
+	   }
+	   if (!isset($wb->menu_footer)) {
+	   	$wb->menu_footer = '</ul>';
+	   }
+	   if (!isset($wb->menu_default_class)) {
+	   	$wb->menu_default_class = ' class="menu_default"';
+	   }
+	   if (!isset($wb->menu_current_class)) {
+	   	$wb->menu_current_class = ' class="menu_current"';
+	   }
+	   if (!isset($wb->menu_parent)) {
+	   	$wb->menu_parent = 0;
+	   }
+	   $wb->show_menu();
+	}
+	
+	function show_menu() {
+		global $database;
+		if ($this->menu_start_level>0) {
+			$key_array=array_keys($this->page_trail);
+			if (isset($key_array[$this->menu_start_level-1])) {
+				$real_start=$key_array[$this->menu_start_level-1];
+				$this->menu_parent=$real_start;
+				$this->menu_start_level=0;
+			} else {
+				return;
+			}
+		}
+	   if ($this->menu_recurse==0)
+	       return;
+	   // Check if we should add menu number check to query
+	   if($this->menu_parent == 0) {
+	       $menu_number = "menu = '$this->menu_number'";
+	   } else {
+	      $menu_number = '1';
+	   }
+	   // Query pages
+	   $query_menu = $database->query("SELECT page_id,menu_title,page_title,link,target,level,visibility FROM ".
+	TABLE_PREFIX."pages WHERE parent = '$this->menu_parent' AND $menu_number AND $this->extra_where_sql ORDER BY position ASC");
+	   // Check if there are any pages to show
+	   if($query_menu->numRows() > 0) {
+	   	  // Print menu header
+	   	  echo "\n".$this->menu_header;
+	      // Loop through pages
+	      while($page = $query_menu->fetchRow()) {
+	      	 // Check if this page should be shown
+	         // Create vars
+	         $vars = array('[class]','[a]', '[/a]', '[menu_title]', '[page_title]');
+	         // Work-out class
+	         if($page['page_id'] == PAGE_ID) {
+	            $class = $this->menu_current_class;
+	         } else {
+	            $class = $this->menu_default_class;
+	         }
+	         // Check if link is same as first page link, and if so change to WB URL
+	         if($page['link'] == $this->default_link AND !INTRO_PAGE) {
+	            $link = WB_URL;
+	         } else {
+	            $link = $this->page_link($page['link']);
+	         }
+	         // Create values
+	         $values = array($class,'<a href="'.$link.'" target="'.$page['target'].'" '.$class.'>', '</a>', $page['menu_title'], $page['page_title']);
+	         // Replace vars with value and print
+	         echo "\n".str_replace($vars, $values, $this->menu_item_template);
+	         // Generate sub-menu
+	         if($this->menu_collapse==false OR ($this->menu_collapse==true AND isset($this->page_trail[$page['page_id']]))) {
+	            $this->menu_recurse--;
+	            $this->menu_parent=$page['page_id'];
+	            $this->show_menu();
+	         }
+	         echo "\n".$this->menu_item_footer;
+	      }
+	      // Print menu footer
+	      echo "\n".$this->menu_footer;
+	   }
+	}
+
+
+	// Function to show the "Under Construction" page
+	function print_under_construction() {
+		global $MESSAGE;
+		require_once(WB_PATH.'/languages/'.DEFAULT_LANGUAGE.'.php');
+		echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+		<head><title>'.$MESSAGE['GENERIC']['WEBSITE_UNDER_CONSTRUCTION'].'</title>
+		<style type="text/css"><!-- body { font-family: Verdana, Arial, Helvetica, sans-serif;
+		font-size: 12px; color: #000000;	background-color: #FFFFFF;	margin: 20px; text-align: center; }
+		h1 { margin: 0; padding: 0; }--></style></head><body>
+		<h1>'.$MESSAGE['GENERIC']['WEBSITE_UNDER_CONSTRUCTION'].'</h1><br />
+		'.$MESSAGE['GENERIC']['PLEASE_CHECK_BACK_SOON'].'</body></html>';
+	}
+}
+
 ?>
\ No newline at end of file
Index: branches/2.6.x/wb/framework/frontend.functions.php
===================================================================
--- branches/2.6.x/wb/framework/frontend.functions.php	(revision 451)
+++ branches/2.6.x/wb/framework/frontend.functions.php	(revision 452)
@@ -1,278 +1,365 @@
-<?php
-
-// $Id$
-
-/*
-
- Website Baker Project <http://www.websitebaker.org/>
- Copyright (C) 2004-2007, 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
-
-*/
-
-/*
-	This file is purely for ensuring compatibility with 3rd party
-	contributions made for WB version 2.5.2 or below
-*/
-if(!defined('WB_URL')) {
-	header('Location: ../index.php');
-	exit(0);
-}
-
-// references to objects and variables that changed their names
-
-$admin = &$wb;
-
-$default_link=&$wb->default_link;
-
-$page_trail=&$wb->page_trail;
-$page_description=&$wb->page_description;
-$page_keywords=&$wb->page_keywords;
-$page_link=&$wb->link;
-
-// extra_sql is not used anymore - this is basically a register_globals exploit prevention...
-$extra_sql=&$wb->extra_sql;
-$extra_where_sql=&$wb->extra_where_sql;
-
-$query="SELECT directory FROM ".TABLE_PREFIX."addons WHERE type = 'module' AND function = 'snippet'";
-$query_result=$database->query($query);
-if ($query_result->numRows()>0) {
-	while ($row = $query_result->fetchRow()) {
-		$module_dir = $row['directory'];
-		if (file_exists(WB_PATH.'/modules/'.$module_dir.'/include.php')) {
-			include(WB_PATH.'/modules/'.$module_dir.'/include.php');
-		}
-	}
-}
-
-// Frontend functions
-if (!function_exists('page_link')) {
-	function page_link($link) {
-		global $wb;
-		return $wb->page_link($link);
-	}
-}
-
-// Old menu call invokes new menu function
-if (!function_exists('page_menu')) {
-	function page_menu($parent = 0, $menu_number = 1, $item_template = '<li[class]>[a] [menu_title] [/a]</li>', $menu_header = '<ul>', $menu_footer = '</ul>', $default_class = ' class="menu_default"', $current_class = ' class="menu_current"', $recurse = LEVEL) {
-		global $wb;
-		$wb->menu_number=$menu_number;
-		$wb->menu_item_template=$item_template;
-		$wb->menu_item_footer='';
-		$wb->menu_parent = $parent;
-		$wb->menu_header = $menu_header; 
-		$wb->menu_footer = $menu_footer;
-		$wb->menu_default_class = $default_class;
-		$wb->menu_current_class = $current_class;
-		$wb->menu_recurse = $recurse+2; 	
-		$wb->menu();
-		unset($wb->menu_parent);
-		unset($wb->menu_number);
-		unset($wb->menu_item_template);
-		unset($wb->menu_item_footer);
-		unset($wb->menu_header);
-		unset($wb->menu_footer);
-		unset($wb->menu_default_class);
-		unset($wb->menu_current_class);
-		unset($wb->menu_start_level);
-		unset($wb->menu_collapse);
-		unset($wb->menu_recurse);
-	}
-}
-
-if (!function_exists('show_menu')) {
-	function show_menu($menu_number = NULL, $start_level=NULL, $recurse = NULL, $collapse = NULL, $item_template = NULL, $item_footer = NULL, $menu_header = NULL, $menu_footer = NULL, $default_class = NULL, $current_class = NULL, $parent = NULL) {
-		global $wb;
-		if (isset($menu_number))
-			$wb->menu_number=$menu_number;
-		if (isset($start_level))
-			$wb->menu_start_level=$start_level;
-		if (isset($recurse))
-			$wb->menu_recurse=$recurse;
-		if (isset($collapse))
-			$wb->menu_collapse=$collapse;
-		if (isset($item_template))
-			$wb->menu_item_template=$item_template;
-		if (isset($item_footer))
-			$wb->menu_item_footer=$item_footer;
-		if (isset($menu_header))
-			$wb->menu_header=$menu_header;
-		if (isset($menu_footer))
-			$wb->menu_footer=$menu_footer;
-		if (isset($default_class))
-			$wb->menu_default_class=$default_class;
-		if (isset($current_class))
-			$wb->menu_current_class=$current_class;
-		if (isset($parent))
-			$wb->menu_parent=$parent;
-		$wb->menu();
-		unset($wb->menu_recurse);
-		unset($wb->menu_parent);
-		unset($wb->menu_start_level);
-	}
-}
-
-if (!function_exists('page_content')) {
-	function page_content($block = 1) {
-		// Get outside objects
-		global $TEXT,$MENU,$HEADING,$MESSAGE;
-		global $globals;
-		global $database;
-		global $wb;
-		$admin = & $wb;
-		if ($wb->page_access_denied==true) {
-	        echo $MESSAGE['FRONTEND']['SORRY_NO_VIEWING_PERMISSIONS'];
-			exit();
-		}
-		if(isset($globals) AND is_array($globals)) { foreach($globals AS $global_name) { global $$global_name; } }
-		// Make sure block is numeric
-		if(!is_numeric($block)) { $block = 1; }
-		// Include page content
-		if(!defined('PAGE_CONTENT') OR $block!=1) {
-			$page_id=$wb->page_id;
-			// First get all sections for this page
-			$query_sections = $database->query("SELECT section_id,module FROM ".TABLE_PREFIX."sections WHERE page_id = '".$page_id."' AND block = '$block' ORDER BY position");
-			// If none were found, check if default content is supposed to be shown
-			if($query_sections->numRows() == 0) {
-				if ($wb->default_block_content=='none') {
-					return;
-				}
-				if (is_numeric($wb->default_block_content)) {
-					$page_id=$wb->default_block_content;
-				} else {
-					$page_id=$wb->default_page_id;
-				}				
-				$query_sections = $database->query("SELECT section_id,module FROM ".TABLE_PREFIX."sections WHERE page_id = '".$page_id."' AND block = '$block' ORDER BY position");
-				// Still no cotent found? Give it up, there's just nothing to show!
-				if($query_sections->numRows() == 0) {
-					return;
-				}
-			}
-			// Loop through them and include their module file
-			while($section = $query_sections->fetchRow()) {
-				$section_id = $section['section_id'];
-				$module = $section['module'];
-				require(WB_PATH.'/modules/'.$module.'/view.php');
-			}
-		} else {
-			require(PAGE_CONTENT);
-		}
-	}
-}
-
-if (!function_exists('show_content')) {
-	function show_content($block=1) {
-		page_content($block);
-	}
-}
-
-if (!function_exists('show_breadcrumbs')) {
-	function show_breadcrumbs($sep=' > ',$tier=1,$links=true,$depth=-1) {
-		global $wb;
-		$page_id=$wb->page_id;
-		if ($page_id!=0)
-		{
-	 		global $database;
-			$bca=$wb->page_trail;
-			$counter=0;
-			foreach ($bca as $temp)
-			{
-		        if ($counter>=($tier-1) AND ($depth<0 OR $tier+$depth>$counter))
-		        {
-					if ($counter>=$tier) echo $sep;
-					$query_menu=$database->query("SELECT menu_title,link FROM ".TABLE_PREFIX."pages WHERE page_id=$temp");
-					$page=$query_menu->fetchRow();
-					if ($links==true AND $temp!=$page_id)
-						echo '<a href="'.page_link($page['link']).'">'.htmlentities($page['menu_title']).'</a>';
-					else
-					    echo htmlentities($page['menu_title']);
-		        }
-	            $counter++;
-			}
-		}
-	}
-}
-
-// Function for page title
-if (!function_exists('page_title')) {
-	function page_title($spacer = ' - ', $template = '[WEBSITE_TITLE][SPACER][PAGE_TITLE]') {
-		$vars = array('[WEBSITE_TITLE]', '[PAGE_TITLE]', '[MENU_TITLE]', '[SPACER]');
-		$values = array(WEBSITE_TITLE, PAGE_TITLE, MENU_TITLE, $spacer);
-		echo str_replace($vars, $values, $template);
-	}
-}
-
-// Function for page description
-if (!function_exists('page_description')) {
-	function page_description() {
-		global $wb;
-		if ($wb->page_description!='') {
-			echo $wb->page_description;
-		} else {
-			echo WEBSITE_DESCRIPTION;
-		}
-	}
-}
-
-// Function for page keywords
-if (!function_exists('page_keywords')) {
-	function page_keywords() {
-		global $wb;
-		if ($wb->page_keywords!='') {
-			echo $wb->page_keywords;
-		} else {
-			echo WEBSITE_KEYWORDS;
-		}
-	}
-}
-// Function for page header
-if (!function_exists('page_header')) {
-	function page_header($date_format = 'Y') {
-		echo WEBSITE_HEADER;
-	}
-}
-
-// Function for page footer
-if (!function_exists('page_footer')) {
-	function page_footer($date_format = 'Y') {
-		global $starttime;
-		$vars = array('[YEAR]', '[PROCESS_TIME]');
-		$processtime=array_sum(explode(" ",microtime()))-$starttime;
-		$values = array(date($date_format),$processtime);
-		echo str_replace($vars, $values, WEBSITE_FOOTER);
-	}
-}
-
-// Begin WB < 2.4.x template compatibility code
-	// Make extra_sql accessable through private_sql
-	$private_sql = $extra_sql;
-	$private_where_sql = $extra_where_sql;
-	// Query pages for menu
-	$menu1 = $database->query("SELECT page_id,menu_title,page_title,link,target,visibility$extra_sql FROM ".TABLE_PREFIX."pages WHERE parent = '0' AND $extra_where_sql ORDER BY position ASC");
-	// Check if current pages is a parent page and if we need its submenu
-	if(PARENT == 0) {
-		// Get the pages submenu
-		$menu2 = $database->query("SELECT page_id,menu_title,page_title,link,target,visibility$extra_sql FROM ".TABLE_PREFIX."pages WHERE parent = '".PAGE_ID."' AND $extra_where_sql ORDER BY position ASC");
-	} else {
-		// Get the pages submenu
-		$menu2 = $database->query("SELECT page_id,menu_title,page_title,link,target,visibility$extra_sql FROM ".TABLE_PREFIX."pages WHERE parent = '".PARENT."' AND $extra_where_sql ORDER BY position ASC");
-	}
-// End WB < 2.4.x template compatibility code
-// Include template file
-
-
+<?php
+
+// $Id$
+
+/*
+
+ Website Baker Project <http://www.websitebaker.org/>
+ Copyright (C) 2004-2007, 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
+
+*/
+
+/*
+	This file is purely for ensuring compatibility with 3rd party
+	contributions made for WB version 2.5.2 or below
+*/
+if(!defined('WB_URL')) {
+	header('Location: ../index.php');
+	exit(0);
+}
+
+// references to objects and variables that changed their names
+
+$admin = &$wb;
+
+$default_link=&$wb->default_link;
+
+$page_trail=&$wb->page_trail;
+$page_description=&$wb->page_description;
+$page_keywords=&$wb->page_keywords;
+$page_link=&$wb->link;
+
+// extra_sql is not used anymore - this is basically a register_globals exploit prevention...
+$extra_sql=&$wb->extra_sql;
+$extra_where_sql=&$wb->extra_where_sql;
+
+$query="SELECT directory FROM ".TABLE_PREFIX."addons WHERE type = 'module' AND function = 'snippet'";
+$query_result=$database->query($query);
+if ($query_result->numRows()>0) {
+	while ($row = $query_result->fetchRow()) {
+		$module_dir = $row['directory'];
+		if (file_exists(WB_PATH.'/modules/'.$module_dir.'/include.php')) {
+			include(WB_PATH.'/modules/'.$module_dir.'/include.php');
+		}
+	}
+}
+
+// Frontend functions
+if (!function_exists('page_link')) {
+	function page_link($link) {
+		global $wb;
+		return $wb->page_link($link);
+	}
+}
+
+//function to highlight search results
+function search_highlight($foo='', $arr_string=array()) {
+	require_once(WB_PATH.'/framework/functions.php');
+	require(WB_PATH.'/search/search_convert.php');
+	$foo = entities_to_umlauts($foo, 'UTF-8');
+	foreach($arr_string as $string) {
+		$string = strtr($string, $string_htmlspecialchars_decode);
+		$string = entities_to_umlauts($string, 'UTF-8');
+		$string = preg_quote($string, '/');
+		$string = strtr($string, $string_ul_umlauts);
+		$foo = preg_replace('/('.$string.')(?=[^>]*<)/iUS', '<span class="highlight">$1</span>',$foo);
+	}
+	$foo = umlauts_to_entities($foo, 'UTF-8', 0);
+	return $foo;
+}
+
+// Old menu call invokes new menu function
+if (!function_exists('page_menu')) {
+	function page_menu($parent = 0, $menu_number = 1, $item_template = '<li[class]>[a] [menu_title] [/a]</li>', $menu_header = '<ul>', $menu_footer = '</ul>', $default_class = ' class="menu_default"', $current_class = ' class="menu_current"', $recurse = LEVEL) {
+		global $wb;
+		$wb->menu_number=$menu_number;
+		$wb->menu_item_template=$item_template;
+		$wb->menu_item_footer='';
+		$wb->menu_parent = $parent;
+		$wb->menu_header = $menu_header; 
+		$wb->menu_footer = $menu_footer;
+		$wb->menu_default_class = $default_class;
+		$wb->menu_current_class = $current_class;
+		$wb->menu_recurse = $recurse+2; 	
+		$wb->menu();
+		unset($wb->menu_parent);
+		unset($wb->menu_number);
+		unset($wb->menu_item_template);
+		unset($wb->menu_item_footer);
+		unset($wb->menu_header);
+		unset($wb->menu_footer);
+		unset($wb->menu_default_class);
+		unset($wb->menu_current_class);
+		unset($wb->menu_start_level);
+		unset($wb->menu_collapse);
+		unset($wb->menu_recurse);
+	}
+}
+
+if (!function_exists('show_menu')) {
+	function show_menu($menu_number = NULL, $start_level=NULL, $recurse = NULL, $collapse = NULL, $item_template = NULL, $item_footer = NULL, $menu_header = NULL, $menu_footer = NULL, $default_class = NULL, $current_class = NULL, $parent = NULL) {
+		global $wb;
+		if (isset($menu_number))
+			$wb->menu_number=$menu_number;
+		if (isset($start_level))
+			$wb->menu_start_level=$start_level;
+		if (isset($recurse))
+			$wb->menu_recurse=$recurse;
+		if (isset($collapse))
+			$wb->menu_collapse=$collapse;
+		if (isset($item_template))
+			$wb->menu_item_template=$item_template;
+		if (isset($item_footer))
+			$wb->menu_item_footer=$item_footer;
+		if (isset($menu_header))
+			$wb->menu_header=$menu_header;
+		if (isset($menu_footer))
+			$wb->menu_footer=$menu_footer;
+		if (isset($default_class))
+			$wb->menu_default_class=$default_class;
+		if (isset($current_class))
+			$wb->menu_current_class=$current_class;
+		if (isset($parent))
+			$wb->menu_parent=$parent;
+		$wb->menu();
+		unset($wb->menu_recurse);
+		unset($wb->menu_parent);
+		unset($wb->menu_start_level);
+	}
+}
+
+if (!function_exists('page_content')) {
+	function page_content($block = 1) {
+		// Get outside objects
+		global $TEXT,$MENU,$HEADING,$MESSAGE;
+		global $globals;
+		global $database;
+		global $wb;
+		$admin = & $wb;
+		if ($wb->page_access_denied==true) {
+	        echo $MESSAGE['FRONTEND']['SORRY_NO_VIEWING_PERMISSIONS'];
+			exit();
+		}
+		if(isset($globals) AND is_array($globals)) { foreach($globals AS $global_name) { global $$global_name; } }
+		// Make sure block is numeric
+		if(!is_numeric($block)) { $block = 1; }
+		// Include page content
+		if(!defined('PAGE_CONTENT') OR $block!=1) {
+			$page_id=$wb->page_id;
+			// First get all sections for this page
+			$query_sections = $database->query("SELECT section_id,module FROM ".TABLE_PREFIX."sections WHERE page_id = '".$page_id."' AND block = '$block' ORDER BY position");
+			// If none were found, check if default content is supposed to be shown
+			if($query_sections->numRows() == 0) {
+				if ($wb->default_block_content=='none') {
+					return;
+				}
+				if (is_numeric($wb->default_block_content)) {
+					$page_id=$wb->default_block_content;
+				} else {
+					$page_id=$wb->default_page_id;
+				}				
+				$query_sections = $database->query("SELECT section_id,module FROM ".TABLE_PREFIX."sections WHERE page_id = '".$page_id."' AND block = '$block' ORDER BY position");
+				// Still no cotent found? Give it up, there's just nothing to show!
+				if($query_sections->numRows() == 0) {
+					return;
+				}
+			}
+			// Loop through them and include their module file
+			while($section = $query_sections->fetchRow()) {
+				$section_id = $section['section_id'];
+				$module = $section['module'];
+				// highlights searchresults
+				if (isset($_GET['searchresult']) AND is_numeric($_GET['searchresult']) ) {
+					if (isset($_GET['sstring']) AND !empty($_GET['sstring']) ){
+						$arr_string = explode(" ", $_GET['sstring']);
+						if($_GET['searchresult'] == 2) {
+							// exact match
+							$arr_string[0] = strtr($arr_string[0], "_"," ");
+						}
+						ob_start(); //start output buffer
+						require(WB_PATH.'/modules/'.$module.'/view.php');
+						$foo = ob_get_contents();    // put outputbuffer in $foo
+						ob_end_clean();             // clear outputbuffer
+						echo search_highlight($foo, $arr_string);
+					}
+				} else {
+					require(WB_PATH.'/modules/'.$module.'/view.php');
+				}
+			}
+		} else {
+			require(PAGE_CONTENT);
+		}
+	}
+}
+
+if (!function_exists('show_content')) {
+	function show_content($block=1) {
+		page_content($block);
+	}
+}
+
+if (!function_exists('show_breadcrumbs')) {
+	function show_breadcrumbs($sep=' > ',$tier=1,$links=true,$depth=-1) {
+		global $wb;
+		$page_id=$wb->page_id;
+		if ($page_id!=0)
+		{
+	 		global $database;
+			$bca=$wb->page_trail;
+			$counter=0;
+			foreach ($bca as $temp)
+			{
+		        if ($counter>=($tier-1) AND ($depth<0 OR $tier+$depth>$counter))
+		        {
+					if ($counter>=$tier) echo $sep;
+					$query_menu=$database->query("SELECT menu_title,link FROM ".TABLE_PREFIX."pages WHERE page_id=$temp");
+					$page=$query_menu->fetchRow();
+					if ($links==true AND $temp!=$page_id)
+						echo '<a href="'.page_link($page['link']).'">'.$page['menu_title'].'</a>';
+					else
+					    echo $page['menu_title'];
+		        }
+	            $counter++;
+			}
+		}
+	}
+}
+
+// Function for page title
+if (!function_exists('page_title')) {
+	function page_title($spacer = ' - ', $template = '[WEBSITE_TITLE][SPACER][PAGE_TITLE]') {
+		$vars = array('[WEBSITE_TITLE]', '[PAGE_TITLE]', '[MENU_TITLE]', '[SPACER]');
+		$values = array(WEBSITE_TITLE, PAGE_TITLE, MENU_TITLE, $spacer);
+		echo str_replace($vars, $values, $template);
+	}
+}
+
+// Function for page description
+if (!function_exists('page_description')) {
+	function page_description() {
+		global $wb;
+		if ($wb->page_description!='') {
+			echo $wb->page_description;
+		} else {
+			echo WEBSITE_DESCRIPTION;
+		}
+	}
+}
+
+// Function for page keywords
+if (!function_exists('page_keywords')) {
+	function page_keywords() {
+		global $wb;
+		if ($wb->page_keywords!='') {
+			echo $wb->page_keywords;
+		} else {
+			echo WEBSITE_KEYWORDS;
+		}
+	}
+}
+
+// Function for page header
+if (!function_exists('page_header')) {
+	function page_header($date_format = 'Y') {
+		echo WEBSITE_HEADER;
+	}
+}
+
+// Function for page footer
+if (!function_exists('page_footer')) {
+	function page_footer($date_format = 'Y') {
+		global $starttime;
+		$vars = array('[YEAR]', '[PROCESS_TIME]');
+		$processtime=array_sum(explode(" ",microtime()))-$starttime;
+		$values = array(date($date_format),$processtime);
+		echo str_replace($vars, $values, WEBSITE_FOOTER);
+	}
+}
+
+// Function to include optional module CSS stylesheets (module.css) into the <head> section
+if (!function_exists('page_css')) {
+	function page_css() {
+    global $wb, $database;
+    $css_head = "";
+
+    // obtain list of modules used for actual displayed page
+		$page_id=$wb->page_id;
+    $query_modules = $database->query("SELECT module FROM " .TABLE_PREFIX ."sections WHERE page_id=$page_id AND module<>'wysiwyg'");
+    while($row = $query_modules->fetchRow()) {
+      if(file_exists(WB_PATH .'/modules/' .$row['module'] .'/module.css')) {
+        // build css link for current module.css
+        $css_link = "<link href=\"" .WB_URL ."/modules/" .$row['module'];
+        $css_link .= "/module.css\" rel=\"stylesheet\" type=\"text/css\" media=\"screen\" />\n";
+        // ensure that module.css is not added twice (e.g. if 2 sections include the same module)
+        $css_head = str_replace($css_link, "", $css_head);
+        $css_head .= $css_link;
+      }
+    }
+    // write out links to all external module stylesheets (module.css)
+    if($css_head != "") {
+      $css_head = "<!-- Include external module CSS stylesheets -->\n" .$css_head;
+      echo $css_head;
+    }
+	}
+}
+
+// Function to include optional module javascript files (module.js) into the <head> section
+if (!function_exists('page_javascript')) {
+	function page_javascript() {
+    global $wb, $database;
+    $js_head = "";
+
+    // obtain list of modules used for actual displayed page
+		$page_id=$wb->page_id;
+    $query_modules = $database->query("SELECT module FROM " .TABLE_PREFIX ."sections WHERE page_id=$page_id AND module<>'wysiwyg'");
+    while($row = $query_modules->fetchRow()) {
+      if(file_exists(WB_PATH .'/modules/' .$row['module'] .'/module.js')) {
+        // build javascript link for current module.js
+        $js_link = "<script type=\"text/javascript\" src=\"" .WB_URL ."/modules/" .$row['module'];
+        $js_link .= "/module.js\"></script>\n";
+        // ensure that module.js is not added twice (e.g. if 2 sections include the same module)
+        $js_head = str_replace($js_link, "", $js_head);
+        $js_head .= $js_link;
+      }
+    }
+    // write out links to all external module javascript files (module.js)
+    if($js_head != "") {
+      $js_head = "<!-- Include external module javascript files -->\n" .$js_head;
+      echo $js_head;
+    }
+	}
+}
+
+// Begin WB < 2.4.x template compatibility code
+	// Make extra_sql accessable through private_sql
+	$private_sql = $extra_sql;
+	$private_where_sql = $extra_where_sql;
+	// Query pages for menu
+	$menu1 = $database->query("SELECT page_id,menu_title,page_title,link,target,visibility$extra_sql FROM ".TABLE_PREFIX."pages WHERE parent = '0' AND $extra_where_sql ORDER BY position ASC");
+	// Check if current pages is a parent page and if we need its submenu
+	if(PARENT == 0) {
+		// Get the pages submenu
+		$menu2 = $database->query("SELECT page_id,menu_title,page_title,link,target,visibility$extra_sql FROM ".TABLE_PREFIX."pages WHERE parent = '".PAGE_ID."' AND $extra_where_sql ORDER BY position ASC");
+	} else {
+		// Get the pages submenu
+		$menu2 = $database->query("SELECT page_id,menu_title,page_title,link,target,visibility$extra_sql FROM ".TABLE_PREFIX."pages WHERE parent = '".PARENT."' AND $extra_where_sql ORDER BY position ASC");
+	}
+// End WB < 2.4.x template compatibility code
+// Include template file
+
+
 ?>
\ No newline at end of file
Index: branches/2.6.x/wb/framework/functions.php
===================================================================
--- branches/2.6.x/wb/framework/functions.php	(revision 451)
+++ branches/2.6.x/wb/framework/functions.php	(revision 452)
@@ -338,11 +338,95 @@
 	return $subs;
 }
 
+// Function as replecement for php's htmlspecialchars()
+function my_htmlspecialchars($string) {
+	$string = umlauts_to_entities($string);
+	$string = entities_to_umlauts($string);
+	return($string);
+}
+
+// Function to convert a string from $from- to $to-encoding, using mysql
+function my_mysql_iconv($string, $from, $to) {
+	// keep current character set values:
+	$character_set_database = mysql_result(mysql_query("SELECT @@character_set_client"),0,0);
+	$character_set_results = mysql_result(mysql_query("SELECT @@character_set_results"),0,0);
+	$collation_results = mysql_result(mysql_query("SELECT @@collation_connection"),0,0);
+	mysql_query("SET character_set_client=$from");
+	mysql_query("SET character_set_results=$to");
+	mysql_query("SET collation_connection=utf8_unicode_ci");
+	$string_escaped = mysql_real_escape_string($string);
+	$converted_string = mysql_result(mysql_query("SELECT '$string_escaped'"),0,0);
+	// restore previous character set values:
+	mysql_query("SET character_set_client=$character_set_database");
+	mysql_query("SET character_set_results=$character_set_results");
+	mysql_query("SET collation_connection=$collation_results");
+	return $converted_string;
+}
+
+// Function to convert a string from mixed html-entities/umlauts to pure utf-8-umlauts
+function string_to_utf8($string, $charset=DEFAULT_CHARSET) {
+	$charset = strtoupper($charset);
+	if ($charset == '') { $charset = 'ISO-8859-1'; }
+
+	// there's no GB2312 or ISO-8859-11 encoding in php's mb_* functions
+	if ($charset == "GB2312") {
+		$string=my_mysql_iconv($string, 'gb2312', 'utf8');
+	} elseif ($charset == "ISO-8859-11") {
+		$string=my_mysql_iconv($string, 'tis620', 'utf8');
+	} else {
+		$string=mb_convert_encoding($string, 'UTF-8', $charset);
+	}
+	$string=mb_convert_encoding($string, 'HTML-ENTITIES', 'UTF-8');
+	$string=mb_convert_encoding($string, 'UTF-8', 'HTML-ENTITIES');
+	return($string);
+}
+
+// Function to convert a string from mixed html-entities/umlauts to pure $charset_out-umlauts
+function entities_to_umlauts($string, $charset_out=DEFAULT_CHARSET, $convert_htmlspecialchars=0) {
+	$charset_out = strtoupper($charset_out);
+	if ($charset_out == '') {
+		$charset_out = 'ISO-8859-1';
+	}
+	$string = string_to_utf8($string);
+	if($charset_out != 'UTF-8') {
+		if ($charset_out == "GB2312") {
+			$string=my_mysql_iconv($string, 'utf8', 'gb2312');
+		} elseif ($charset_out == "ISO-8859-11") {
+			$string=my_mysql_iconv($string, 'utf8', 'tis620');
+		} else {
+			$string=mb_convert_encoding($string, $charset_out, 'UTF-8');
+		}
+	}
+	if($convert_htmlspecialchars == 1) {
+		$string=htmlspecialchars($string);
+	}
+	return($string);
+}
+
+// Function to convert a string from mixed html-entitites/$charset_in-umlauts to pure html-entities
+function umlauts_to_entities($string, $charset_in=DEFAULT_CHARSET, $convert_htmlspecialchars=1) {
+	$charset_in = strtoupper($charset_in);
+	if ($charset_in == "") {
+		$charset_in = 'ISO-8859-1';
+	}
+	$string = string_to_utf8($string, $charset_in);
+	if($convert_htmlspecialchars == 1) {
+		$string=htmlspecialchars($string,ENT_QUOTES);
+	}
+	$string=mb_convert_encoding($string,'HTML-ENTITIES','UTF-8');
+	return($string);
+}
+
+// translate any latin/greek/cyrillic html-entities to their plain 7bit equivalents
+function entities_to_7bit($string) {
+	require(WB_PATH.'/framework/convert.php');
+	$string = strtr($string, $conversion_array);
+	return($string);
+}
+
 // 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);
+	$string = entities_to_7bit(umlauts_to_entities($string));
 	// Now replace spaces with page spcacer
 	$string = str_replace(' ', PAGE_SPACER, $string);
 	// Now remove all bad characters
@@ -371,9 +455,7 @@
 
 // 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);
+	$string = entities_to_7bit(umlauts_to_entities($string));
 	// Now remove all bad characters
 	$bad = array(
 	'\'', // '
@@ -667,7 +749,7 @@
 	$directory = WB_PATH.PAGES_DIRECTORY.$link;
 	$filename = $directory.'.php';
 	$directory .= '/';
-	if(file_exists($filename)) {
+	if(file_exists($filename) && substr($filename,0,1<>'.')) {
 		if(!is_writable(WB_PATH.PAGES_DIRECTORY.'/')) {
 			$admin->print_error($MESSAGE['PAGES']['CANNOT_DELETE_ACCESS_FILE']);
 		} else {
Index: branches/2.6.x/wb/templates/allcss/index.php
===================================================================
--- branches/2.6.x/wb/templates/allcss/index.php	(revision 451)
+++ branches/2.6.x/wb/templates/allcss/index.php	(revision 452)
@@ -52,7 +52,7 @@
 		<?php if(SHOW_SEARCH) { ?>
 		<form name="search" action="<?php echo WB_URL.'/search/index'.PAGE_EXTENSION; ?>" method="get">
 		<input type="text" name="string" class="search_string" />
-		<input type="submit" name="submit" value="Search" class="search_submit" />
+		<input type="submit" name="submit" value="<?php echo $TEXT['SEARCH']; ?>" class="search_submit" />
 		</form>
 		<?php } ?>
 	</div>
Index: branches/2.6.x/wb/templates/round/index.php
===================================================================
--- branches/2.6.x/wb/templates/round/index.php	(revision 451)
+++ branches/2.6.x/wb/templates/round/index.php	(revision 452)
@@ -86,8 +86,7 @@
 				</tr>
 				<tr>
 					<td class="login">
-
-						<input type="submit" name="submit" value="<?php if(isset($TEXT['SUBMIT'])) { echo $TEXT['SEARCH']; } else { echo 'Search'; } ?>" />
+						<input type="submit" name="submit" value="<?php echo $TEXT['SEARCH']; ?>" />
 					</td>
 				</tr>
 				<tr>
Index: branches/2.6.x/wb/templates/simple/info.php
===================================================================
--- branches/2.6.x/wb/templates/simple/info.php	(revision 451)
+++ branches/2.6.x/wb/templates/simple/info.php	(revision 452)
@@ -1,6 +1,6 @@
 <?php
 
-// $Id$
+// $Id: info.php 412 2007-01-02 22:15:03Z Ruebenwurzel $
 
 /*
 
Index: branches/2.6.x/wb/templates/simple/index.php
===================================================================
--- branches/2.6.x/wb/templates/simple/index.php	(revision 451)
+++ branches/2.6.x/wb/templates/simple/index.php	(revision 452)
@@ -1,6 +1,6 @@
 <?php
 
-// $Id$
+// $Id: index.php 440 2007-03-12 14:25:39Z Ruebenwurzel $
 
 /*
 
@@ -64,7 +64,7 @@
 			Search: <br />
 			<form name="search" action="<?php echo WB_URL; ?>/search/index<?php echo PAGE_EXTENSION; ?>" method="get">
 				<input type="text" name="string" style="width: 100%;" />
-				<input type="submit" name="submit" value="Search" style="width: 100%;" />
+				<input type="submit" name="submit" value="<?php echo $TEXT['SEARCH']; ?>" style="width: 100%;" />
 			</form>
 		<?php } ?>
 		
