diff -ruN _currtarball/admin/admin_ranks.php phpBB2/admin/admin_ranks.php
--- _currtarball/admin/admin_ranks.php	2006-05-16 16:51:10.000000000 -0500
+++ phpBB2/admin/admin_ranks.php	2006-06-09 09:29:41.000000000 -0500
@@ -6,7 +6,7 @@
  *   copyright            : (C) 2001 The phpBB Group
  *   email                : support@phpbb.com
  *
- *   $Id: admin_ranks.php,v 1.13.2.7 2006/01/23 19:47:19 grahamje Exp $
+ *   $Id: admin_ranks.php,v 1.13.2.8 2006/04/13 09:56:48 grahamje Exp $
  *
  ***************************************************************************/
 
@@ -33,8 +33,17 @@
 //
 $phpbb_root_path = "./../";
 require($phpbb_root_path . 'extension.inc');
+
+$cancel = ( isset($HTTP_POST_VARS['cancel']) ) ? true : false;
+$no_page_header = $cancel;
+
 require('./pagestart.' . $phpEx);
 
+if ($cancel)
+{
+	redirect('admin/' . append_sid("admin_ranks.$phpEx", true));
+}
+
 if( isset($HTTP_GET_VARS['mode']) || isset($HTTP_POST_VARS['mode']) )
 {
 	$mode = (isset($HTTP_GET_VARS['mode'])) ? $HTTP_GET_VARS['mode'] : $HTTP_POST_VARS['mode'];
diff -ruN _currtarball/admin/admin_smilies.php phpBB2/admin/admin_smilies.php
--- _currtarball/admin/admin_smilies.php	2006-05-16 16:51:10.000000000 -0500
+++ phpBB2/admin/admin_smilies.php	2006-06-09 09:29:41.000000000 -0500
@@ -6,7 +6,7 @@
 *     copyright            : (C) 2001 The phpBB Group
 *     email                : support@phpbb.com
 *
-*     $Id: admin_smilies.php,v 1.22.2.17 2006/01/28 12:46:53 grahamje Exp $
+*     $Id: admin_smilies.php,v 1.22.2.18 2006/04/13 09:56:48 grahamje Exp $
 *
 ****************************************************************************/
 
@@ -49,8 +49,17 @@
 
 $phpbb_root_path = "./../";
 require($phpbb_root_path . 'extension.inc');
+
+$cancel = ( isset($HTTP_POST_VARS['cancel']) ) ? true : false;
+$no_page_header = $cancel;
+
 require('./pagestart.' . $phpEx);
 
+if ($cancel)
+{
+	redirect('admin/' . append_sid("admin_smilies.$phpEx", true));
+}
+
 //
 // Check to see what mode we should operate in.
 //
diff -ruN _currtarball/admin/admin_styles.php phpBB2/admin/admin_styles.php
--- _currtarball/admin/admin_styles.php	2006-05-16 16:44:25.000000000 -0500
+++ phpBB2/admin/admin_styles.php	2006-06-09 09:29:41.000000000 -0500
@@ -6,7 +6,7 @@
  *   copyright            : (C) 2001 The phpBB Group
  *   email                : support@phpbb.com
  *
- *   $Id: admin_styles.php,v 1.27.2.16 2005/12/18 13:57:50 grahamje Exp $
+ *   $Id: admin_styles.php,v 1.27.2.17 2006/04/20 13:34:15 grahamje Exp $
  *
  *
  ***************************************************************************/
@@ -836,7 +836,7 @@
 			// Set template files
 			//
 			$template->set_filenames(array(
-				"confirm" => "confirm_body.tpl")
+				"confirm" => "admin/confirm_body.tpl")
 			);
 
 			$template->assign_vars(array(
diff -ruN _currtarball/admin/admin_words.php phpBB2/admin/admin_words.php
--- _currtarball/admin/admin_words.php	2006-05-16 16:51:10.000000000 -0500
+++ phpBB2/admin/admin_words.php	2006-06-09 09:29:41.000000000 -0500
@@ -6,7 +6,7 @@
  *   copyright            : (C) 2001 The phpBB Group
  *   email                : support@phpbb.com
  *
- *   $Id: admin_words.php,v 1.10.2.5 2006/01/23 21:24:40 grahamje Exp $
+ *   $Id: admin_words.php,v 1.10.2.6 2006/04/13 09:56:48 grahamje Exp $
  *
  *
  ***************************************************************************/
@@ -34,8 +34,17 @@
 //
 $phpbb_root_path = "./../";
 require($phpbb_root_path . 'extension.inc');
+
+$cancel = ( isset($HTTP_POST_VARS['cancel']) ) ? true : false;
+$no_page_header = $cancel;
+
 require('./pagestart.' . $phpEx);
 
+if ($cancel)
+{
+	redirect('admin/' . append_sid("admin_words.$phpEx", true));
+}
+
 if( isset($HTTP_GET_VARS['mode']) || isset($HTTP_POST_VARS['mode']) )
 {
 	$mode = (isset($HTTP_GET_VARS['mode'])) ? $HTTP_GET_VARS['mode'] : $HTTP_POST_VARS['mode'];
diff -ruN _currtarball/common.php phpBB2/common.php
--- _currtarball/common.php	2006-05-16 16:51:10.000000000 -0500
+++ phpBB2/common.php	2006-06-09 09:29:42.000000000 -0500
@@ -6,7 +6,7 @@
  *   copyright            : (C) 2001 The phpBB Group
  *   email                : support@phpbb.com
  *
- *   $Id: common.php,v 1.74.2.23 2006/02/26 17:34:50 grahamje Exp $
+ *   $Id: common.php,v 1.74.2.25 2006/05/26 17:46:59 grahamje Exp $
  *
  ***************************************************************************/
 
@@ -82,10 +82,11 @@
 
 	while (list($var,) = @each($input))
 	{
-		if (!in_array($var, $not_unset))
+		if (in_array($var, $not_unset))
 		{
-			unset($$var);
+			die('Hacking attempt!');
 		}
+		unset($$var);
 	}
 
 	unset($input);
diff -ruN _currtarball/contrib/dbinformer.php phpBB2/contrib/dbinformer.php
--- _currtarball/contrib/dbinformer.php	1969-12-31 18:00:00.000000000 -0600
+++ phpBB2/contrib/dbinformer.php	2004-07-10 13:16:12.000000000 -0500
@@ -0,0 +1,475 @@
+<?php 
+/*************************************************************************** 
+*                               dbinformer.php 
+*                            ------------------- 
+*   begin                : Saturday, May 05, 2002 
+*   copyright            : (C) 2002 The phpBB Group 
+*   email                : n/a 
+* 
+*   $Id: dbinformer.php,v 1.65 2002/05/04 12:15:00 Blade Exp $ 
+* 
+*   Coded by AL, Techie-Micheal, Blade, and Black Fluffy Lion. 
+*   http://www.phpbb.com/phpBB/groupcp.php?g=7330 
+* 
+***************************************************************************/ 
+/*************************************************************************** 
+* 
+*   This program 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. 
+* 
+***************************************************************************/ 
+
+/* magic quotes, borrowed from install.php */ 
+set_magic_quotes_runtime(0); 
+if (!get_magic_quotes_gpc()) 
+{ 
+    if (is_array($HTTP_POST_VARS)) 
+    { 
+        while (list($k, $v) = each($HTTP_POST_VARS)) 
+        { 
+            if (is_array($HTTP_POST_VARS[$k])) 
+            { 
+                while (list($k2, $v2) = each($HTTP_POST_VARS[$k])) 
+                { 
+                    $HTTP_POST_VARS[$k][$k2] = addslashes($v2); 
+                } 
+                @reset($HTTP_POST_VARS[$k]); 
+            } 
+            else 
+            { 
+                $HTTP_POST_VARS[$k] = addslashes($v); 
+            } 
+        } 
+        @reset($HTTP_POST_VARS); 
+    } 
+} 
+
+$all_connected = false; 
+$error = false; 
+$error_msg = ''; 
+$select = false; 
+$connect = false; 
+
+function make_config($dbms, $dbhost, $dbname, $dbuser, $dbpasswd, $table_prefix) 
+{ 
+    $config_file = '&lt;?php<br />' . "\n"; 
+    $config_file .= '<br />' . "\n"; 
+    $config_file .= '//<br />' . "\n"; 
+    $config_file .= '// phpBB 2.x auto-generated config file<br />' . "\n"; 
+    $config_file .= '// Do not change anything in this file!<br />' . "\n"; 
+    $config_file .= '//<br />' . "\n"; 
+    $config_file .= '<br />' . "\n"; 
+    $config_file .= '$dbms = \'' . $dbms . '\';<br /><br />' . "\n\n"; 
+    $config_file .= '$dbhost = \'' . $dbhost . '\';<br />' . "\n"; 
+    $config_file .= '$dbname = \'' . $dbname . '\';<br />' . "\n"; 
+    $config_file .= '$dbuser = \'' . $dbuser . '\';<br />' . "\n"; 
+    $config_file .= '$dbpasswd = \'' . $dbpasswd . '\';<br /><br />' . "\n\n"; 
+    $config_file .= '$table_prefix = \'' . $table_prefix . '\';<br /><br />' . "\n\n"; 
+    $config_file .= 'define(\'PHPBB_INSTALLED\', true);<br /><br />' . "\n\n"; 
+    $config_file .= '?>'; 
+
+    return $config_file; 
+} 
+
+function make_download($dbms, $dbhost, $dbname, $dbuser, $dbpasswd, $table_prefix)  
+{  
+    $config_file = '<?php' . "\n\n";  
+    $config_file .= '//' . "\n"; 
+    $config_file .= '// phpBB 2.x auto-generated config file' . "\n";  
+    $config_file .= '// Do not change anything in this file!' . "\n";  
+    $config_file .= '//' . "\n\n";  
+    $config_file .= '$dbms = \'' . $dbms . '\';' . "\n\n";  
+    $config_file .= '$dbhost = \'' . $dbhost . '\';' . "\n";  
+    $config_file .= '$dbname = \'' . $dbname . '\';' . "\n";  
+    $config_file .= '$dbuser = \'' . $dbuser . '\';' . "\n";  
+    $config_file .= '$dbpasswd = \'' . $dbpasswd . '\';' . "\n\n";  
+    $config_file .= '$table_prefix = \'' . $table_prefix . '\';' . "\n\n"; 
+    $config_file .= 'define(\'PHPBB_INSTALLED\', true);' . "\n\n"; 
+    $config_file .= '?>'; 
+     
+    return $config_file; 
+} 
+
+/* make all the vars safe to display in form inputs and on the user's screen. Borrowed from usercp_register.php */ 
+$check_var_list = array('dbms' => 'dbms', 'dbhost' => 'dbhost', 'dbname' => 'dbname', 'dbuser' => 'dbuser', 'dbpasswd' => 'dbpasswd', 'table_prefix' => 'table_prefix'); 
+
+while (list($var, $param) = each($check_var_list)) 
+{ 
+    if (!empty($HTTP_POST_VARS[$param])) 
+    { 
+        $$var = stripslashes(htmlspecialchars(strip_tags($HTTP_POST_VARS[$param]))); 
+    } 
+} 
+
+$available_dbms = array( 
+    'mysql' => 'MySQL 3.x', 
+    'mysql4' => 'MySQL 4.x', 
+    'postgres' => 'PostgreSQL 7.x', 
+    'mssql' => 'MS SQL Server 7/2000', 
+    'msaccess' => 'MS Access [ ODBC ]', 
+    'mssql-odbc' => 'MS SQL Server [ OBDC ]', 
+); 
+
+if (isset($HTTP_POST_VARS['download_config']) && $HTTP_POST_VARS['download_config'] == true && isset($HTTP_POST_VARS['submit_download_config']) && $HTTP_POST_VARS['submit_download_config'] == 'Download') 
+{ 
+    /* borrowed from install.php */ 
+    header('Content-Type: text/x-delimtext; name="config.php"'); 
+    header('Content-disposition: attachment; filename=config.php'); 
+    echo make_download($dbms, $dbhost, $dbname, $dbuser, $dbpasswd, $table_prefix); 
+    return; 
+} 
+?> 
+
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 
+<html> 
+<head> 
+<meta http-equiv="Content-Type" content="text/html" /> 
+<meta http-equiv="Content-Style-Type" content="text/css" /> 
+<title>phpBB :: dbinformer.php</title> 
+<link rel="stylesheet" href="../templates/subSilver/subSilver.css" type="text/css" /> 
+<style type="text/css"> 
+<!-- 
+p,ul,td {font-size:10pt;} 
+h3 {font-size:12pt;color:blue} 
+//--> 
+</style> 
+</head> 
+<body> 
+<table width="100%" border="0" cellspacing="0" cellpadding="10" align="center"> 
+<tr> 
+<td class="bodyline"><table width="100%" border="0" cellspacing="0" cellpadding="0"> 
+<tr> 
+<td> 
+<table width="100%" border="0" cellspacing="0" cellpadding="0"> 
+<tr> 
+<td><img src="../templates/subSilver/images/logo_phpBB.gif" border="0" alt="phpBB2 : Creating Communities" vspace="1" /></a></td> 
+<td align="center" width="100%" valign="middle"><span class="maintitle">dbinformer.php</span> 
+</td> 
+</tr> 
+</table> 
+
+<br /><b><div align="center"> 
+<a href="#what">What you entered</a> | 
+<a href="#connect">Connection to database</a> | 
+<a href="#tables">Tables in database</a> | 
+<a href="#config">Config file</a> 
+</b></div> 
+
+<table width="100%" border="0" cellspacing="0" cellpadding="10" align="center"> 
+<tr> 
+<td align="center" width="100%" valign="middle"><span class="maintitle"></span></td> 
+</tr> 
+<tr> 
+<td width="100%"> 
+<table width="100%" cellpadding="2" cellspacing="1" border="0" class="forumline"> 
+<tr> 
+<th colspan="2">Database Configuration</th> 
+</tr> 
+<tr> 
+<td class="row1" align="right"><span class="gen">Database type: </span></td> 
+<td class="row2"> 
+<form action="<?php echo $HTTP_SERVER_VARS['PHP_SELF']; ?>" method="post"> 
+<select name="dbms"> 
+<?php 
+/* loop through the dbms, with the correct one selected (hopefully!) */ 
+while (list($var, $param) = each($available_dbms)) 
+{ 
+    $selected = ($dbms == $var) ? ' selected="selected"' : ''; 
+    echo '<option value="' . $var . '"' . $selected . '>' . $param . '</option>'; 
+} 
+?> 
+</select></td> 
+</tr> 
+<tr> 
+<td class="row1" align="right"><span class="gen">Database Server Hostname / DSN: </span></td> 
+<td class="row2"><input type="text" name="dbhost" value="<?php echo @$dbhost; ?>" /></td> 
+</tr> 
+<tr> 
+<td class="row1" align="right"><span class="gen">Your Database Name: </span></td> 
+<td class="row2"><input type="text" name="dbname" value="<?php echo @$dbname; ?>" /></td> 
+</tr> 
+<tr> 
+<td class="row1" align="right"><span class="gen">Database Username: </span></td> 
+<td class="row2"><input type="text" name="dbuser" value="<?php echo @$dbuser; ?>" /></td> 
+</tr> 
+<tr> 
+<td class="row1" align="right"><span class="gen">Database Password: </span></td> 
+<td class="row2"><input type="password" name="dbpasswd" value="<?php echo @$dbpasswd; ?>" /></td> 
+</tr> 
+<tr> 
+<td class="row1" align="right"><span class="gen">Chosen Prefix: </span></td> 
+<td class="row2"><input type="text" name="table_prefix" value="<?php echo @$table_prefix; ?>" /></td> 
+</tr> 
+<tr> 
+<td class="row1" align="right"><span class="gen">Generate a config file: </span></td> 
+</td> 
+<td class="row2"><input type="checkbox" name="generate_config" value="true" <?php $checked = (isset($HTTP_POST_VARS['generate_config']) && $HTTP_POST_VARS['generate_config'] == true) ? 'checked="checked"' : ''; echo $checked; ?> /></td> 
+</tr> 
+<tr> 
+<td class="catbottom" align="center" colspan="2"> 
+<input class="mainoption" type="submit" name="submit" value="Submit" /></td> 
+</tr> 
+</form></td> 
+</tr> 
+</table> 
+<?php 
+if (!isset($HTTP_POST_VARS['submit'])) 
+{ 
+    echo '<br />Please enter your data.<br />'; 
+} 
+else 
+{ 
+    /* dbal added by Techie-Micheal [and then obliterated by BFL]. weeeeeee! */ 
+    switch ($dbms) 
+    { 
+        case 'mysql': 
+            if (function_exists(@mysql_connect)) 
+            { 
+                $db = array( 
+                    'choice' => 'MySQL 3.x', 
+                    'connect' => @mysql_connect($dbhost, $dbuser, $dbpasswd), 
+                    'select' => @mysql_select_db($dbname), 
+                    'error' => @mysql_error(), 
+                    'list' => @mysql_list_tables($dbname), 
+                    'fetch' => @mysql_fetch_row, 
+                    'close' => @mysql_close() 
+                ); 
+            } 
+            else 
+            { 
+                $error = true; 
+                $error_msg = 'You do not have the needed functions available for ' . $available_dbms[$dbms] . '.'; 
+            } 
+        break; 
+
+        case 'mysql4': 
+            if (function_exists(@mysql_connect)) 
+            { 
+                $db = array( 
+                    'choice' => 'MySQL 4.x', 
+                    'connect' => @mysql_connect($dbhost, $dbuser, $dbpasswd), 
+                    'select' => @mysql_select_db($dbname), 
+                    'error' => @mysql_error(), 
+                    'list' => @mysql_list_tables($dbname), 
+                    'fetch' => @mysql_fetch_row, 
+                    'close' => @mysql_close() 
+                ); 
+            } 
+            else 
+            { 
+                $error = true; 
+                $error_msg = 'You do not have the needed functions available for ' . $available_dbms[$dbms] . '.'; 
+            } 
+        break; 
+             
+        case 'msaccess': 
+            if (function_exists(@odbc_connect)) 
+            { 
+                $db = array( 
+                    'choice' => 'MS Access [ ODBC ]', 
+                    'connect' => @odbc_connect($dbhost, $dbuser, $dbpasswd), 
+                    'select' => 'na', 
+                    'error' => @odbc_errormsg(), 
+                    'list' => 'na', /* odbc_tables() */ 
+                    'fetch' => 'na', /* odbc_fetch_row(), odbc_result_all() */ 
+                    'close' => @odbc_close() 
+                ); 
+            } 
+            else 
+            { 
+                $error = true; 
+                $error_msg = 'You do not have the needed functions available for ' . $available_dbms[$dbms] . '.'; 
+            } 
+        break; 
+              
+        case 'postgres': 
+            if (function_exists(@pg_connect)) 
+            { 
+                $db = array( 
+                    'choice' => 'PostgreSQL 7.x', 
+                    'connect' => @pg_connect('host=' . $dbhost . ' user=' . $dbuser . ' dbname=' . $dbname . ' password=' . $dbpasswd), 
+                    'select' => 'na', 
+                    'error' => @pg_last_error(), 
+                    'list' => @pg_exec("SELECT relname FROM pg_class WHERE relkind = 'r' AND relname NOT LIKE 'pg\_%'"), /* provided by SuGa */ 
+                    'fetch' => @pg_fetch_row, 
+                    'close' => @pg_close() 
+                ); 
+            } 
+            else 
+            { 
+                $error = true; 
+                $error_msg = 'You do not have the needed functions available for ' . $available_dbms[$dbms] . '.'; 
+            } 
+        break;                 
+        case 'mssql': 
+            if (function_exists(@mssql_connect)) 
+            { 
+                $db = array( 
+                    'choice' => 'MS SQL Server 7/2000', 
+                    'connect' => @mssql_connect($dbhost, $dbuser, $dbpasswd), 
+                    'select' => @mssql_select_db($dbname), 
+                    'error' => @mssql_get_last_message(), 
+                    'list' => 'na', 
+                    'fetch' => 'na', /* mssql_fetch_row() */ 
+                    'close' => @mssql_close() 
+                ); 
+            } 
+            else 
+            { 
+                $error = true; 
+                $error_msg = 'You do not have the needed functions available for ' . $available_dbms[$dbms] . '.'; 
+            } 
+        break;  
+
+        case 'mssql-odbc': 
+            if (function_exists(@odbc_connect)) 
+            { 
+                $db = array( 
+                    'choice' => 'MS SQL Server [ ODBC ]', 
+                    'connect' => @odbc_connect($dbhost, $dbuser, $dbpasswd), 
+                    'select' => 'na', 
+                    'error' => @odbc_errormsg(), 
+                    'list' => 'na', /* odbc_tables() */ 
+                    'fetch' => 'na', /* odbc_fetch_row(), odbc_result_all() */ 
+                    'close' => @odbc_close() 
+                ); 
+            } 
+            else 
+            { 
+                $error = true; 
+                $error_msg = 'You do not have the needed functions available for ' . $available_dbms[$dbms] . '.'; 
+            } 
+        break;  
+
+        default: 
+            $error = true; 
+            $error_msg = 'Unrecognised DBMS.'; 
+        break; 
+    } 
+     
+    if ($error == true && $error_msg != '') 
+    { 
+        echo '<br /><b>ERROR:</b> ' . $error_msg . '<br />'; 
+    } 
+    else 
+    { 
+        echo '<a name="what"><h3><u>What you entered</u></h3></a>'; 
+        echo 'Database Type: <b>' . $db['choice']  . '</b><br />'; 
+        echo 'Database Server Hostname / DSN: <b>' . $dbhost . '</b><br />'; 
+        echo 'Your Database Name: <b>' . $dbname . '</b><br />'; 
+        echo 'Database Username: <b>' . $dbuser .   '</b><br />'; 
+        echo 'Database Password: <b>' . $dbpasswd   . '</b><br />'; 
+
+        echo '<a name="connect"><h3><u>Connection to database</u></h3></a>'; 
+         
+        if (!$db['connect']) 
+        { 
+            echo 'You have not established a connection to <b>' . $db['choice'] . '</b>.<br />'; 
+            echo '<b>ERROR:</b> <i>' . $db['error'] . '</i><br /><br />'; 
+        } 
+        else 
+        { 
+            echo 'You have established a connection to <b>' . $db['choice'] . '</b>.<br /><br />'; 
+            $connect = true; 
+        } 
+
+        if ($dbms == 'msaccess' || $dbms == 'postgres' || $dbms == 'mssql-odbc')  
+        {         
+            /* for dbmses which have no db select function */ 
+            $select = true; 
+        } 
+        else 
+        { 
+            if (!$db['select']) 
+            { 
+                echo 'Your database was not found.<br />'; 
+                echo '<b>ERROR:</b> <i>' . $db['error'] . '</i><br />'; 
+            } 
+            else 
+            { 
+                echo 'Your database was found.<br />'; 
+                $select = true; 
+            } 
+        } 
+
+        if ($connect == true && $select == true) 
+        { 
+            echo '<a name="tables"><h3><u>Tables in database</u></h3></a>'; 
+            if ($dbms == 'mysql' || $dbms == 'mysql4' || $dbms == 'postgres') 
+            { 
+                echo '<i>Tables with the table prefix you specified are in bold.</i>'; 
+                echo '<ul>'; 
+                while ($table = $db['fetch']($db['list'])) 
+                {    
+                    /* Highlight tables with the table_prefix specified */ 
+                    if (preg_match("/^$HTTP_POST_VARS[table_prefix]/i", $table[0])) 
+                    { 
+                        echo '<li><b>' . $table[0] . '</b></li><br />'; 
+                    } 
+                    else 
+                    { 
+                        echo '<li>' . $table[0] . '</li><br />'; 
+                    } 
+                } 
+                echo '</ul>'; 
+            } 
+            else 
+            { 
+                echo 'Sorry, this feature isn\'t available with ' . $db['choice'] . '.'; 
+            } 
+
+            /* defined a var which is only there if successfully connected to the database and the database is found */ 
+            $all_connected = true; 
+        } 
+
+        /* Create a config file if checked and if the connection went OK */ 
+        if (isset($HTTP_POST_VARS['generate_config']) && $HTTP_POST_VARS['generate_config'] == true) 
+        { 
+            echo '<a name="config"><h3><u>Config file</u></h3></a>'; 
+            if ($all_connected != true) 
+            { 
+                echo 'The database has not been successfully connected to so no config file has been generated.<br />'; 
+            } 
+            else 
+            { 
+                echo 'Either copy the <b>19</b> lines below and save them as <u>config.php</u> or click on the <u>Download</u> button below. Then upload the file to your phpBB2 root directory (phpBB2/ by default). Make sure that there is nothing (this includes blank spaces) after the <u>?></u>.<br /><br />'; 
+
+                /* Create our config file */ 
+                echo '<form action="' . $HTTP_SERVER_VARS['PHP_SELF'] . '" method="post"><table cellspacing="1" cellpadding="3" border="0"><tr><td class="code">'; 
+                echo make_config($dbms, $dbhost, $dbname, $dbuser, $dbpasswd, $table_prefix); 
+                echo '</td></tr></table>'; 
+                echo '<input type="hidden" name="dbms" value="' . $dbms . '" />'; 
+                echo '<input type="hidden" name="dbhost" value="' . $dbhost . '" />'; 
+                echo '<input type="hidden" name="dbname" value="' . $dbname . '" />'; 
+                echo '<input type="hidden" name="dbuser" value="' . $dbuser . '" />'; 
+                echo '<input type="hidden" name="dbpasswd" value="' . $dbpasswd . '" />'; 
+                echo '<input type="hidden" name="table_prefix" value="' . $table_prefix . '" />'; 
+                echo '<input type="hidden" name="download_config" value="true" />'; 
+                echo '<br /><input type="submit" name="submit_download_config" value="Download" class="mainoption" /><br />'; 
+            } 
+        } 
+
+        /* close the connection */ 
+        if ($all_connected == true) 
+        { 
+            $db['close']; 
+        } 
+    } 
+} 
+
+/* And they all lived happily ever after... 
+The End */ 
+?> 
+
+<br /><a href="javascript:scrollTo('0','0');"><b>Return to top</b></a> 
+</td> 
+</tr> 
+</table> 
+<div align="center"><span class="copyright">&copy; Copyright 2002 The <a href="http://www.phpbb.com/about.php" target="_phpbb" class="copyright">phpBB Group</a></span></div> 
+</td> 
+</tr> 
+</table> 
+</body> 
+</html> 
\ No newline at end of file
diff -ruN _currtarball/contrib/fixfiles.sh phpBB2/contrib/fixfiles.sh
--- _currtarball/contrib/fixfiles.sh	1969-12-31 18:00:00.000000000 -0600
+++ phpBB2/contrib/fixfiles.sh	2004-03-25 10:56:11.000000000 -0600
@@ -0,0 +1,28 @@
+#!/bin/bash
+# 
+# Remove all those annoying ^M characters that Winblows editor's like to add
+# from all files in the current directory and all subdirectories.
+#
+# Written by: Jonathan Haase.
+#
+# UPDATE: 7/31/2001: fix so that it doesn't touch things in the images directory
+#
+# UPDATE: 12/15/2003: Fix so that it doesn't touch any "non-text" files
+#
+
+find . > FILELIST.$$
+grep -sv FILELIST FILELIST.$$ > FILELIST2.$$
+grep -sv $(basename $0) FILELIST2.$$ > FILELIST.$$
+grep -sv "^\.$" FILELIST.$$ > FILELIST2.$$
+file -f FILELIST2.$$  |grep text | sed -e 's/^\([^\:]*\)\:.*$/\1/' > FILELIST
+file -f FILELIST2.$$  |grep -sv text | sed -e 's/^\([^\:]*\)\:.*$/Not Modifying file: \1/'
+rm FILELIST2.$$
+rm FILELIST.$$
+
+for i in $(cat FILELIST); do
+	if [ -f $i ]; then  	 
+		sed -e s/
//g $i > $i.tmp
+  		mv $i.tmp $i
+	fi	
+done
+rm FILELIST
diff -ruN _currtarball/contrib/README.html phpBB2/contrib/README.html
--- _currtarball/contrib/README.html	1969-12-31 18:00:00.000000000 -0600
+++ phpBB2/contrib/README.html	2006-01-28 06:25:29.000000000 -0600
@@ -0,0 +1,194 @@
+<!-- saved from url=(0022)http://internet.e-mail -->
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html">
+<meta http-equiv="Content-Style-Type" content="text/css">
+<title>phpBB 2.0.x :: Contrib</title>
+<link rel="stylesheet" href="../templates/subSilver/subSilver.css" type="text/css" />
+<style type="text/css">
+<!--
+p,ul,td {font-size:10pt;}
+h2 {font-size:15pt;font-weight:bold;}
+h3 {font-size:12pt;}
+//-->
+</style>
+</head>
+<body bgcolor="#E5E5E5" text="#000000" link="#006699" vlink="#006699">
+
+<table width="100%" border="0" cellspacing="0" cellpadding="10" align="center">
+	<tr>
+		<td class="bodyline"><table width="100%" border="0" cellspacing="0" cellpadding="0">
+			<tr>
+				<td>
+
+<table width="100%" border="0" cellspacing="0" cellpadding="0">
+	<tr>
+		<td><img src="../templates/subSilver/images/logo_phpBB.gif" border="0" alt="phpBB2 : Creating Communities" vspace="1" /></a></td>
+		<td align="center" width="100%" valign="middle"><span class="maintitle">phpBB 2.0.x Contrib</span></td>
+	</tr>
+</table>
+
+<p>This directory contains a couple extra <i>add-ons</i> for phpBB 2.0.x.</p>
+
+<p align="center"><u>Please note none of these are directly supported by phpBB Group</u></p>
+
+<p>You should contact the author/s (via our forums) if you want further information. A large number of additional mods are available introducing increased funtionality to the standard phpBB2 release. You can find many additional mods at our main site:</p>
+
+<p><a href="http://www.phpbb.com/mods/" target="_new">http://www.phpbb.com/mods/</a></p>
+
+<p><b>NOTE</b>: Once you have made use of files contained in this directory it should be deleted from your server. You should <b>NOT</b> leave this directory in place!</p>
+
+<h2><u>Template caching</u></h2>
+
+<p><b>Authors: Crimsonbane, psoTFX and nathan</b></p>
+
+<p align="center"><b>File Caching Updated</b></p>
+
+<p>During development of phpBB2 a recurring issue of server load has cropped up. phpBB 2.0.0 differs from many of its contemporaries by doing many more tasks at runtime. While this allows for simpler upgrade and modification paths it also leads to a greater strain being placed on the server. To help reduce this issue a caching template system was created based on work by Crimsonbane. This stores a compiled version of each template resulting in a generally significant reduction in server load and perhaps page generation time.</p>
+
+<p>Two versions of the caching system are contained in this directory, one uses flat files the other a MySQL database. Testing has shown that, in general, the average virtual host seems to show better performance with the flat file solution. However this may not be the case for your system, so please feel free to try both.</p>
+
+<p>In both cases you need to rename your existing template.php script (in includes/) and replace it with whichever template_*.php you want to try.</p>
+
+<h3>template_file_cache.php</h3>
+
+<p>To use the flat file system you need to create a directory called 'cache' in your phpBB root directory (it may already exist and contain some default files, do not delete these). This directory must be writeable by the web server, e.g. global write access. Under UNIX systems this is typically achieved by using <i>chmod a+w cache</i> or <i>chmod 777 cache</i>. Many FTP applications also allow you to change permission properties. See your applications manual for details on how to do this.</p>
+
+<p><b>Please note</b> that creating a world writeable directory is of course a potential security issue. Most of the time this is not a great issue, however on virtual hosting accounts there may be users who have nothing better to do than cause problems. Therefore you should monitor the status of this directory regularly and report any problems to your hosting provider (who will be in a position to take action against any offending user).</p>
+
+<p>NB: The directory required for this version of the file caching template system differs from previous releases. You can safely delete the old caching directories.</p>
+
+<h3>template_db_cache.php</h3>
+
+<p>To use the database system (note that this is <b>only</b> compatible with MySQL at present) you need to create the following table (replacing the phpbb_ prefix with your own if you used something different):</p>
+
+<pre>
+CREATE TABLE phpbb_template_cache (
+  template_name char(255) NOT NULL default '',
+  template_handle char(50) NOT NULL default '',
+  template_cached int(11) NOT NULL default '0',
+  template_echo tinyint(1) NOT NULL default '1',
+  template_compile text NOT NULL,
+  PRIMARY KEY  (template_name)
+)
+</pre>
+
+<p>These files should not be incorporated into any mod or other plug-in, etc. They have been tested quite thoroughly but we cannot guarantee their stability in all cases. The system is based on work by Crimsonbane and of course Nathan's original templating system.</p>
+
+<h2><u>Visual Confirmation System</u></h2>
+
+<p><b>Author: psoTFX</b></p>
+
+<p><b>The visual confirmation system is part of phpBB 2.0.x since version 2.0.11. For historical purposes, the instructions below are left untouched.</b></p>
+
+<p>Unfortunately there are people "out there" who have nothing better to do than cause other people trouble. Even worse are groups that write applications which cause problems. One very annoying (and pointless) way in which people can cause you trouble is by mass registering users. This Mod, back-ported from the forthcoming phpBB 2.2 helps eliminate or reduce this problem. It generates a random series of six alphanumeric characters as a png image. The user must then input these characters before they can register a new user. Should they fail three times in a row they will be locked out for the rest of that session </p>
+
+<p>To get the best from this Mod you should be running PHP4 and have the <b>zlib</b> module installed and loaded. It is quite common for zlib to be installed by default. If you are unsure whether it is please check with your hosting provider or review the output of phpinfo();. This Mod does <b>not</b> require GD, Imagemagick, NetPBM or any other module or utility. If you do not have zlib available the Mod will fall-back to a simpler output method. However this will still deter the majority of would be trouble makers.</p>
+
+<p>phpBB 2.0.6 is shipped with various bits of the visual confirmation system already installed. To complete installation you should unzip the contents of the visual_confirmation.zip archive into your phpBB root directory. Allow it to overwrite any existing files. <b>Please Note</b> that if you have any Mods installed which have altered; <U>profile.php</U>, <U>includes/usercp_register.php</U>, <U>admin/admin_board.php</U> or <U>templates/subSilver/admin/board_config_body.tpl</U> you <b>will lose</b> these changes. In this situation you are advised to manually diff the files and make the changes yourself.</p>
+
+<p>The default English language pack includes the necessary new strings for this mod. Other languages may be updated in time. However you can easily add the strings yourself, they are listed below. Please do not translate the %s present in one of these strings. This is a placeholder for additional text that will be inserted by phpBB.</p>
+
+<form>
+
+<p><b>lang_main.php</b></p>
+<textarea style="font-family: monospace;font-size: 10pt" rows="9" cols="80">
+$lang['Confirm_code_wrong'] = 'The confirmation code you entered was incorrect';
+$lang['Too_many_registers'] = 'You have exceeded the number of registration attempts for this session. Please try again later.';
+$lang['Confirm_code_impaired'] = 'If you are visually impaired or cannot otherwise read this code please contact the %sAdministrator%s for help.';
+$lang['Confirm_code'] = 'Confirmation code';
+$lang['Confirm_code_explain'] = 'Enter the code exactly as you see it. The code is case sensitive and zero has a diagonal line through it.';
+</textarea>
+
+<p><b>lang_admin.php</b></p>
+<textarea style="font-family: monospace;font-size: 10pt" rows="3" cols="80">
+$lang['Visual_confirm'] = 'Enable Visual Confirmation';
+$lang['Visual_confirm_explain'] = 'Requires users enter a code defined by an image when registering.';
+</textarea>
+
+<p>If you use a style other than subSilver you will need to make changes to two templates. The changes are quite straightforward, see below for details.</p>
+
+
+<p><b>profile_add_body.tpl</b></p>
+
+<p>Find similar:</p>
+
+<textarea style="font-family: monospace;font-size: 10pt" rows="9" cols="80">
+	&lt;tr&gt;
+	  &lt;td class="row1"&gt;&lt;span class="gen"&gt;{L_CONFIRM_PASSWORD}: * &lt;/span&gt;&lt;br /&gt;
+		&lt;span class="gensmall"&gt;{L_PASSWORD_CONFIRM_IF_CHANGED}&lt;/span&gt;&lt;/td&gt;
+	  &lt;td class="row2"&gt;
+		&lt;input type="password" class="post" style="width: 200px" name="password_confirm" size="25" maxlength="32" value="{PASSWORD_CONFIRM}" /&gt;
+	  &lt;/td&gt;
+	&lt;/tr&gt;
+</textarea>
+
+<p>Add after:</p>
+
+<textarea style="font-family: monospace;font-size: 10pt" rows="9" cols="80">
+	&lt;!-- BEGIN switch_confirm --&gt;
+	&lt;tr&gt;
+		&lt;td class="row1" colspan="2" align="center"&gt;&lt;span class="gensmall"&gt;{L_CONFIRM_CODE_IMPAIRED}&lt;/span&gt;<br /&gt;<br /&gt;{CONFIRM_IMG}<br /&gt;<br /&gt;</td&gt;
+	</tr&gt;
+	<tr&gt;
+	  &lt;td class="row1"&gt;<span class="gen">{L_CONFIRM_CODE}: * &lt;/span&gt;&lt;br /&gt;&lt;span class="gensmall"&gt;{L_CONFIRM_CODE_EXPLAIN}&lt;/span>&lt;/td&gt;
+	  &lt;td class="row2"&gt;&lt;input type="text" class="post" style="width: 200px" name="confirm_code" size="6" maxlength="6" value="" /&gt;&lt;/td&gt;
+	&lt;/tr&gt;
+	&lt;!-- END switch_confirm --&gt;
+</textarea>
+
+<p><b>admin/board_config_body.tpl</b></p>
+
+<p>Find similar:</p>
+
+<textarea style="font-family: monospace;font-size: 10pt" rows="9" cols="80">
+	&lt;tr&gt;
+		&lt;td class="row1"&gt;{L_ACCT_ACTIVATION}&lt;/td&gt;
+		&lt;td class="row2"&gt;vinput type="radio" name="require_activation" value="{ACTIVATION_NONE}" {ACTIVATION_NONE_CHECKED} /&gt;{L_NONE}&nbsp; &nbsp;&lt;input type="radio" name="require_activation" value="{ACTIVATION_USER}" {ACTIVATION_USER_CHECKED} /&gt;{L_USER}&nbsp; &nbsp;&lt;input type="radio" name="require_activation" value="{ACTIVATION_ADMIN}" {ACTIVATION_ADMIN_CHECKED} /&gt;{L_ADMIN}&lt;/td&gt;
+	&lt;/tr&gt;
+</textarea>
+
+<p>Add after:</p>
+
+<textarea style="font-family: monospace;font-size: 10pt" rows="9" cols="80">
+	&lt;tr&gt;
+		&lt;td class="row1"&gt;{L_VISUAL_CONFIRM}&lt;br /&gt;&lt;span class="gensmall"&gt;{L_VISUAL_CONFIRM_EXPLAIN}&lt;/span&gt;&lt;/td&gt;
+		&lt;td class="row2">&lt;input type="radio" name="enable_confirm" value="1" {CONFIRM_ENABLE} /&gt;{L_YES}&nbsp; &nbsp;&lt;input type="radio" name="enable_confirm" value="0" {CONFIRM_DISABLE} /&gt;{L_NO}&lt;/td&gt;
+	&lt;/tr&gt;
+</textarea>
+</form>
+
+<p>PLEASE NOTE: Templates can vary greatly and the above code should only be used as a guide. You may want to contact the template designer if you do not feel comfortable making the changes yourself.</p>
+
+<p>Once these tasks have been completed you should visit your Administration Control Panel. Under General -> Configuration you will find a new option "Enable Visual Confirmation", check the yes box to switch the system on. Because some of your visitors may be visually impaired a message is output along with the image noting the board email address as a point of contact should they be unable to read the code.</p>
+
+<p>While the Mod is designed to be relatively light in terms of load a very busy board with dozens of registrations a minute may see some affect from it. We would be interested in your experiences in this respect.</p>
+
+
+<h2><u>Database Informer</u></h2>
+
+<p><b>Authors: Blade, AL, Techie-Michael, Black Fluffy Lion</b></p>
+
+<h3>dbinformer.php</h3>
+
+<p><b>NOTE:</b> dbinformer.php now works with all of phpBB's supported DBMSes.</p>
+
+<p>Following a large number of people reporting <i>could not connect to database</i> errors with phpBB, especially on installations, this script has been compiled by the Support Team. To use it, enter your database server hostname / DSN, database name, database username, database password, and the table prefix you would like dbinformer.php to use (e.g. <i>phpbb_</i>) and select your database type in the space provided. Also specify whether you wish to generate a config.php file with the data entered and then press <u>Submit</u>.</p>
+
+<p>The script will then report whether connections to the database server and your database were established. If they were not, then it will display descriptive error messages. If the connection was successful then it will list the tables in your database; tables which start with your chosen prefix will appear in bold. If you choose to generate a new config file (useful if your file was accidently deleted, was not sent, etc) the code for that will appear at the bottom of the page. Simply copy that code over and save it as config.php or click on <u>Download</u> to download the file. Make sure it has only 19 lines in it and then upload it to your phpBB root directory.</p>
+
+<p>Please also note that this file (in common with the contrib directory as a whole) should be <b>deleted</b> after use. Do not leave this file in place if it is not needed.</p>
+
+<h2><u>Copyright and disclaimer</u></h2>
+
+<p>This application is opensource software released under the <a href="http://www.gnu.org/licenses/gpl.html" target="_new">GPL</a>. Please see source code and the <u>docs/</u> directory for more details. The phpBB2 package, its contents and the template caching files are Copyright  2002 <a href="http://www.phpbb.com/" target="_new">phpBB Group</a>, All Rights Reserved. Other packages are the copyright of their respective authors.</p>
+
+				</td>
+			</tr>
+		</table></td>
+	</tr>
+</table>
+
+</body>
+</html>
\ No newline at end of file
diff -ruN _currtarball/contrib/template_db_cache.php phpBB2/contrib/template_db_cache.php
--- _currtarball/contrib/template_db_cache.php	1969-12-31 18:00:00.000000000 -0600
+++ phpBB2/contrib/template_db_cache.php	2004-07-10 13:16:12.000000000 -0500
@@ -0,0 +1,536 @@
+<?php
+/***************************************************************************
+ *                              template.inc
+ *                            -------------------
+ *   begin                : Saturday, Feb 13, 2001
+ *   copyright            : (C) 2001 The phpBB Group
+ *   email                : support@phpbb.com
+ *
+ *   $Id: template.php,v 1.7 2002/01/28 19:12:37 psotfx Exp $
+ *
+ *
+ ***************************************************************************/
+
+/***************************************************************************
+ *
+ *   This program 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.
+ *
+ ***************************************************************************/
+
+/**
+ * Template class. By Nathan Codding of the phpBB group.
+ * The interface was originally inspired by PHPLib templates,
+ * and the template file formats are quite similar.
+ *
+ */
+
+class Template {
+	var $classname = "Template";
+
+	// variable that holds all the data we'll be substituting into
+	// the compiled templates.
+	// ...
+	// This will end up being a multi-dimensional array like this:
+	// $this->_tpldata[block.][iteration#][child.][iteration#][child2.][iteration#][variablename] == value
+	// if it's a root-level variable, it'll be like this:
+	// $this->_tpldata[.][0][varname] == value
+	var $_tpldata = array();
+
+	// Hash of filenames for each template handle.
+	var $files = array();
+
+	// Root template directory.
+	var $root = "";
+
+	// this will hash handle names to the compiled code for that handle.
+	var $compiled_code = array();
+
+	// This will hold the uncompiled code for that handle.
+	var $uncompiled_code = array();
+
+	/**
+	 * Constructor. Simply sets the root dir.
+	 *
+	 */
+	function Template($root = '.')
+	{
+		global $db;
+
+		$this->set_rootdir($root);
+		$this->db = &$db;
+
+		$this->pparse_order = array();
+	}
+
+	/**
+	 * Destroys this template object. Should be called when you're done with it, in order
+	 * to clear out the template data so you can load/parse a new template set.
+	 */
+	function destroy()
+	{
+		$this->_tpldata = array();
+	}
+
+	/**
+	 * Sets the template root directory for this Template object.
+	 */
+	function set_rootdir($dir)
+	{
+		if (!is_dir($dir))
+		{
+			return false;
+		}
+
+		$this->root = $dir;
+		return true;
+	}
+
+	/**
+	 * Sets the template filenames for handles. $filename_array
+	 * should be a hash of handle => filename pairs.
+	 */
+	function set_filenames($filename_array)
+	{
+		global $table_prefix;
+
+		if ( !is_array($filename_array) )
+		{
+			return false;
+		}
+
+		$template_names = '';
+		@reset($filename_array);
+		while ( list($handle, $filename) = @each($filename_array) )
+		{
+			$this->files[$handle] = $this->make_filename($filename);
+			$template_names .= ( $template_names != '' ) ? ", '" . addslashes($this->files[$handle]) . "'" : "'" . addslashes($this->files[$handle]) . "'";
+		}
+
+		$sql = "SELECT * 
+			FROM " . $table_prefix . "template_cache 
+			WHERE template_name IN ($template_names)";
+		if ( $result = $this->db->sql_query($sql) )
+		{
+			while( $row = $this->db->sql_fetchrow($result) )
+			{
+				if( $row['template_cached'] == filemtime($row['template_name']) )
+				{
+					$this->compiled_code[$row['template_handle']] = $row['template_compile'];
+					$this->echo_compiled[$row['template_handle']] = $row['template_echo'];
+				}
+			} 
+		} 
+
+		$this->db->sql_freeresult();
+
+		return true;
+	}
+
+
+	/**
+	 * Load the file for the handle, compile the file,
+	 * and run the compiled code. This will print out
+	 * the results of executing the template.
+	 */
+	function pparse($handle)
+	{
+		global $table_prefix;
+
+		if( empty($this->compiled_code[$handle]) )
+		{
+			if ( !$this->loadfile($handle) )
+			{
+				die("Template->pparse(): Couldn't load template file for handle $handle");
+			}
+
+			//
+			// Actually compile the code now.
+			//
+			$this->echo_compiled[$handle] = 1;
+			$this->compiled_code[$handle] = $this->compile($this->uncompiled_code[$handle]);
+
+			$sql = "REPLACE INTO " . $table_prefix . "template_cache (template_name, template_handle, template_cached, template_compile) VALUES ('" . addslashes($this->files[$handle]) . "', '" . addslashes($handle) . "', " . filemtime($this->files[$handle]) . ", '" . addslashes($this->compiled_code[$handle]) . "')";
+			if ( !($result = $this->db->sql_query($sql)) )
+			{
+				die("Couldn't insert template into cache!");
+			}
+
+		}
+
+		$_str = "";
+		eval($this->compiled_code[$handle]);
+
+		if( $_str != "" ) 
+		{
+			echo $_str;
+		}
+
+		return true;
+	}
+
+	/**
+	 * Inserts the uncompiled code for $handle as the
+	 * value of $varname in the root-level. This can be used
+	 * to effectively include a template in the middle of another
+	 * template.
+	 * Note that all desired assignments to the variables in $handle should be done
+	 * BEFORE calling this function.
+	 */
+	function assign_var_from_handle($varname, $handle)
+	{
+		global $table_prefix;
+
+		if( empty($this->compiled_code[$handle]) )
+		{
+			if ( !$this->loadfile($handle) )
+			{
+				die("Template->pparse(): Couldn't load template file for handle $handle");
+			}
+
+			$code = $this->compile($this->uncompiled_code[$handle], true, '_str');
+
+			$sql = "REPLACE INTO " . $table_prefix . "template_cache (template_name, template_handle, template_echo, template_cached, template_compile) VALUES ('" . addslashes($this->files[$handle]) . "', '" . addslashes($handle) . "', 0, " . filemtime($this->files[$handle]) . ", '" . addslashes($code) . "')";
+			if ( !($result = $this->db->sql_query($sql)) )
+			{
+				die("Couldn't insert template into cache!");
+			}
+		}
+		else
+		{
+			$code = $this->compiled_code[$handle];
+		}
+
+		// Compile It, With The "no Echo Statements" Option On.
+		$_str = "";
+		// evaluate the variable assignment.
+		eval($code);
+		// assign the value of the generated variable to the given varname.
+		$this->assign_var($varname, $_str);
+
+		return true;
+	}
+
+	/**
+	 * Block-level variable assignment. Adds a new block iteration with the given
+	 * variable assignments. Note that this should only be called once per block
+	 * iteration.
+	 */
+	function assign_block_vars($blockname, $vararray)
+	{
+		if (strstr($blockname, '.'))
+		{
+			// Nested block.
+			$blocks = explode('.', $blockname);
+			$blockcount = sizeof($blocks) - 1;
+			$str = '$this->_tpldata';
+			for ($i = 0; $i < $blockcount; $i++)
+			{
+				$str .= '[\'' . $blocks[$i] . '.\']';
+				eval('$lastiteration = sizeof(' . $str . ') - 1;');
+				$str .= '[' . $lastiteration . ']';
+			}
+			// Now we add the block that we're actually assigning to.
+			// We're adding a new iteration to this block with the given
+			// variable assignments.
+			$str .= '[\'' . $blocks[$blockcount] . '.\'][] = $vararray;';
+
+			// Now we evaluate this assignment we've built up.
+			eval($str);
+		}
+		else
+		{
+			// Top-level block.
+			// Add a new iteration to this block with the variable assignments
+			// we were given.
+			$this->_tpldata[$blockname . '.'][] = $vararray;
+		}
+
+		return true;
+	}
+
+	/**
+	 * Root-level variable assignment. Adds to current assignments, overriding
+	 * any existing variable assignment with the same name.
+	 */
+	function assign_vars($vararray)
+	{
+		reset ($vararray);
+		while (list($key, $val) = each($vararray))
+		{
+			$this->_tpldata['.'][0][$key] = $val;
+		}
+
+		return true;
+	}
+
+	/**
+	 * Root-level variable assignment. Adds to current assignments, overriding
+	 * any existing variable assignment with the same name.
+	 */
+	function assign_var($varname, $varval)
+	{
+		$this->_tpldata['.'][0][$varname] = $varval;
+
+		return true;
+	}
+
+
+	/**
+	 * Generates a full path+filename for the given filename, which can either
+	 * be an absolute name, or a name relative to the rootdir for this Template
+	 * object.
+	 */
+	function make_filename($filename)
+	{
+		// Check if it's an absolute or relative path.
+		if (substr($filename, 0, 1) != '/')
+		{
+			$filename = $this->root . '/' . $filename;
+		}
+
+		if (!file_exists($filename))
+		{
+			die("Template->make_filename(): Error - file $filename does not exist");
+		}
+
+		return $filename;
+	}
+
+
+	/**
+	 * If not already done, load the file for the given handle and populate
+	 * the uncompiled_code[] hash with its code. Do not compile.
+	 */
+	function loadfile($handle)
+	{
+		// If the file for this handle is already loaded and compiled, do nothing.
+		if ( !empty($this->uncompiled_code[$handle]) )
+		{
+			return true;
+		}
+
+		// If we don't have a file assigned to this handle, die.
+		if (!isset($this->files[$handle]))
+		{
+			die("Template->loadfile(): No file specified for handle $handle");
+		}
+
+		$filename = $this->files[$handle];
+
+		$str = implode("", @file($filename));
+		if (empty($str))
+		{
+			die("Template->loadfile(): File $filename for handle $handle is empty");
+		}
+
+		$this->uncompiled_code[$handle] = $str;
+
+		return true;
+	}
+
+
+
+	/**
+	 * Compiles the given string of code, and returns
+	 * the result in a string.
+	 * If "do_not_echo" is true, the returned code will not be directly
+	 * executable, but can be used as part of a variable assignment
+	 * for use in assign_code_from_handle().
+	 */
+	function compile($code, $do_not_echo = false, $retvar = '')
+	{
+		// replace \ with \\ and then ' with \'.
+		$code = str_replace('\\', '\\\\', $code);
+		$code = str_replace('\'', '\\\'', $code);
+
+		// change template varrefs into PHP varrefs
+
+		// This one will handle varrefs WITH namespaces
+		$varrefs = array();
+		preg_match_all('#\{(([a-z0-9\-_]+?\.)+?)([a-z0-9\-_]+?)\}#is', $code, $varrefs);
+		$varcount = sizeof($varrefs[1]);
+		for ($i = 0; $i < $varcount; $i++)
+		{
+			$namespace = $varrefs[1][$i];
+			$varname = $varrefs[3][$i];
+			$new = $this->generate_block_varref($namespace, $varname);
+
+			$code = str_replace($varrefs[0][$i], $new, $code);
+		}
+
+		// This will handle the remaining root-level varrefs
+		$code = preg_replace('#\{([a-z0-9\-_]*?)\}#is', '\' . ( ( isset($this->_tpldata[\'.\'][0][\'\1\']) ) ? $this->_tpldata[\'.\'][0][\'\1\'] : \'\' ) . \'', $code);
+
+		// Break it up into lines.
+		$code_lines = explode("\n", $code);
+
+		$block_nesting_level = 0;
+		$block_names = array();
+		$block_names[0] = ".";
+
+		// Second: prepend echo ', append ' . "\n"; to each line.
+		$line_count = sizeof($code_lines);
+		for ($i = 0; $i < $line_count; $i++)
+		{
+			$code_lines[$i] = chop($code_lines[$i]);
+			if (preg_match('#<!-- BEGIN (.*?) -->#', $code_lines[$i], $m))
+			{
+				$n[0] = $m[0];
+				$n[1] = $m[1];
+
+				// Added: dougk_ff7-Keeps templates from bombing if begin is on the same line as end.. I think. :)
+				if ( preg_match('#<!-- END (.*?) -->#', $code_lines[$i], $n) )
+				{
+					$block_nesting_level++;
+					$block_names[$block_nesting_level] = $m[1];
+					if ($block_nesting_level < 2)
+					{
+						// Block is not nested.
+						$code_lines[$i] = '$_' . $a[1] . '_count = ( isset($this->_tpldata[\'' . $n[1] . '.\']) ) ?  sizeof($this->_tpldata[\'' . $n[1] . '.\']) : 0;';
+						$code_lines[$i] .= "\n" . 'for ($_' . $n[1] . '_i = 0; $_' . $n[1] . '_i < $_' . $n[1] . '_count; $_' . $n[1] . '_i++)';
+						$code_lines[$i] .= "\n" . '{';
+					}
+					else
+					{
+						// This block is nested.
+
+						// Generate a namespace string for this block.
+						$namespace = implode('.', $block_names);
+						// strip leading period from root level..
+						$namespace = substr($namespace, 2);
+						// Get a reference to the data array for this block that depends on the
+						// current indices of all parent blocks.
+						$varref = $this->generate_block_data_ref($namespace, false);
+						// Create the for loop code to iterate over this block.
+						$code_lines[$i] = '$_' . $a[1] . '_count = ( isset(' . $varref . ') ) ? sizeof(' . $varref . ') : 0;';
+						$code_lines[$i] .= "\n" . 'for ($_' . $n[1] . '_i = 0; $_' . $n[1] . '_i < $_' . $n[1] . '_count; $_' . $n[1] . '_i++)';
+						$code_lines[$i] .= "\n" . '{';
+					}
+
+					// We have the end of a block.
+					unset($block_names[$block_nesting_level]);
+					$block_nesting_level--;
+					$code_lines[$i] .= '} // END ' . $n[1];
+					$m[0] = $n[0];
+					$m[1] = $n[1];
+				}
+				else
+				{
+					// We have the start of a block.
+					$block_nesting_level++;
+					$block_names[$block_nesting_level] = $m[1];
+					if ($block_nesting_level < 2)
+					{
+						// Block is not nested.
+						$code_lines[$i] = '$_' . $m[1] . '_count = ( isset($this->_tpldata[\'' . $m[1] . '.\']) ) ? sizeof($this->_tpldata[\'' . $m[1] . '.\']) : 0;';
+						$code_lines[$i] .= "\n" . 'for ($_' . $m[1] . '_i = 0; $_' . $m[1] . '_i < $_' . $m[1] . '_count; $_' . $m[1] . '_i++)';
+						$code_lines[$i] .= "\n" . '{';
+					}
+					else
+					{
+						// This block is nested.
+
+						// Generate a namespace string for this block.
+						$namespace = implode('.', $block_names);
+						// strip leading period from root level..
+						$namespace = substr($namespace, 2);
+						// Get a reference to the data array for this block that depends on the
+						// current indices of all parent blocks.
+						$varref = $this->generate_block_data_ref($namespace, false);
+						// Create the for loop code to iterate over this block.
+						$code_lines[$i] = '$_' . $m[1] . '_count = ( isset(' . $varref . ') ) ? sizeof(' . $varref . ') : 0;';
+						$code_lines[$i] .= "\n" . 'for ($_' . $m[1] . '_i = 0; $_' . $m[1] . '_i < $_' . $m[1] . '_count; $_' . $m[1] . '_i++)';
+						$code_lines[$i] .= "\n" . '{';
+					}
+				}
+			}
+			else if (preg_match('#<!-- END (.*?) -->#', $code_lines[$i], $m))
+			{
+				// We have the end of a block.
+				unset($block_names[$block_nesting_level]);
+				$block_nesting_level--;
+				$code_lines[$i] = '} // END ' . $m[1];
+			}
+			else
+			{
+				// We have an ordinary line of code.
+				if (!$do_not_echo)
+				{
+					$code_lines[$i] = 'echo \'' . $code_lines[$i] . '\' . "\\n";';
+				}
+				else
+				{
+					$code_lines[$i] = '$' . $retvar . '.= \'' . $code_lines[$i] . '\' . "\\n";'; 
+				}
+			}
+		}
+
+		// Bring it back into a single string of lines of code.
+		$code = implode("\n", $code_lines);
+		return $code	;
+
+	}
+
+
+	/**
+	 * Generates a reference to the given variable inside the given (possibly nested)
+	 * block namespace. This is a string of the form:
+	 * ' . $this->_tpldata['parent'][$_parent_i]['$child1'][$_child1_i]['$child2'][$_child2_i]...['varname'] . '
+	 * It's ready to be inserted into an "echo" line in one of the templates.
+	 * NOTE: expects a trailing "." on the namespace.
+	 */
+	function generate_block_varref($namespace, $varname)
+	{
+		// Strip the trailing period.
+		$namespace = substr($namespace, 0, strlen($namespace) - 1);
+
+		// Get a reference to the data block for this namespace.
+		$varref = $this->generate_block_data_ref($namespace, true);
+		// Prepend the necessary code to stick this in an echo line.
+
+		// Append the variable reference.
+		$varref .= '[\'' . $varname . '\']';
+
+		$varref = '\' . ( ( isset(' . $varref . ') ) ? ' . $varref . ' : \'\' ) . \'';
+
+		return $varref;
+
+	}
+
+
+	/**
+	 * Generates a reference to the array of data values for the given
+	 * (possibly nested) block namespace. This is a string of the form:
+	 * $this->_tpldata['parent'][$_parent_i]['$child1'][$_child1_i]['$child2'][$_child2_i]...['$childN']
+	 *
+	 * If $include_last_iterator is true, then [$_childN_i] will be appended to the form shown above.
+	 * NOTE: does not expect a trailing "." on the blockname.
+	 */
+	function generate_block_data_ref($blockname, $include_last_iterator)
+	{
+		// Get an array of the blocks involved.
+		$blocks = explode(".", $blockname);
+		$blockcount = sizeof($blocks) - 1;
+		$varref = '$this->_tpldata';
+		// Build up the string with everything but the last child.
+		for ($i = 0; $i < $blockcount; $i++)
+		{
+			$varref .= '[\'' . $blocks[$i] . '.\'][$_' . $blocks[$i] . '_i]';
+		}
+		// Add the block reference for the last child.
+		$varref .= '[\'' . $blocks[$blockcount] . '.\']';
+		// Add the iterator for the last child if requried.
+		if ($include_last_iterator)
+		{
+			$varref .= '[$_' . $blocks[$blockcount] . '_i]';
+		}
+
+		return $varref;
+	}
+
+}
+
+?>
\ No newline at end of file
diff -ruN _currtarball/contrib/template_file_cache.php phpBB2/contrib/template_file_cache.php
--- _currtarball/contrib/template_file_cache.php	1969-12-31 18:00:00.000000000 -0600
+++ phpBB2/contrib/template_file_cache.php	2004-07-10 13:16:12.000000000 -0500
@@ -0,0 +1,535 @@
+<?php
+/***************************************************************************
+ *                              template.php
+ *                            -------------------
+ *   begin                : Saturday, Feb 13, 2001
+ *   copyright            : (C) 2001 The phpBB Group
+ *   email                : support@phpbb.com
+ *
+ *   $Id: template.php,v 1.7 2002/01/28 19:12:37 psotfx Exp $
+ *
+ ***************************************************************************/
+
+/***************************************************************************
+ *
+ *   This program 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.
+ *
+ ***************************************************************************/
+
+/**
+ * Template class. By Nathan Codding of the phpBB group.
+ * The interface was originally inspired by PHPLib templates,
+ * and the template file formats are quite similar.
+ *
+ * Updated 9th June 2003 - psoTFX
+ * Backported various aspects of 2.2 template class
+ *
+ */
+
+class Template {
+	var $classname = 'Template';
+
+	// variable that holds all the data we'll be substituting into
+	// the compiled templates.
+	var $_tpldata = array();
+
+	// Hash of filenames for each template handle.
+	var $files = array();
+
+	// Root template directories
+	var $cache_root = 'cache/';
+	var $root = '';
+
+	// this will hash handle names to the compiled code for that handle.
+	var $compiled_code = array();
+
+	// This will hold the uncompiled code for that handle.
+	var $uncompiled_code = array();
+
+	/**
+	 * Constructor. Simply sets the root dir.
+	 *
+	 */
+	function Template($root = '.')
+	{
+		global $board_config, $db;
+
+		$this->set_rootdir($root);
+		$this->db = $db;
+	}
+
+	/**
+	 * Destroys this template object. Should be called when you're done with it, in order
+	 * to clear out the template data so you can load/parse a new template set.
+	 */
+	function destroy()
+	{
+		$this->_tpldata = array();
+	}
+
+	/**
+	 * Sets the template root directory for this Template object.
+	 */
+	function set_rootdir($dir)
+	{
+		global $phpbb_root_path;
+
+		if (is_file($dir) || is_link($dir))
+		{
+			return false;
+		}
+
+		$this->root = phpbb_realpath($dir);
+		$this->cachedir = phpbb_realpath($phpbb_root_path . $this->cache_root) . substr($dir, strrpos($dir, '/')) . '/';
+
+		if (!file_exists($this->cachedir . 'admin/'))
+		{
+			@umask(0);
+			if (!file_exists($this->cachedir))
+			{
+				mkdir($this->cachedir, 0777);
+			}
+			mkdir($this->cachedir . 'admin/', 0777);
+		}
+
+		return true;
+	}
+
+	/**
+	 * Sets the template filenames for handles. $filename_array
+	 * should be a hash of handle => filename pairs.
+	 */
+	function set_filenames($filename_array)
+	{
+		if (!is_array($filename_array))
+		{
+			return false;
+		}
+
+		$template_names = '';
+		@reset($filename_array);
+		while (list($handle, $filename) = @each($filename_array))
+		{
+			$this->filename[$handle] = $filename;
+			$this->files[$handle] = $this->make_filename($filename);
+		}
+
+		return true;
+	}
+
+
+	/**
+	 * Load the file for the handle, compile the file,
+	 * and run the compiled code. This will print out
+	 * the results of executing the template.
+	 */
+	function pparse($handle)
+	{
+		global $phpEx;
+
+		$cache_file = $this->cachedir . $this->filename[$handle] . '.' . $phpEx;
+
+		if(@filemtime($cache_file) == @filemtime($this->files[$handle]))
+		{
+			$_str = '';
+			include($cache_file);
+
+			if ($_str != '')
+			{
+				echo $_str;
+			}
+		}
+		else 
+		{
+			if (!$this->loadfile($handle))
+			{
+				die("Template->pparse(): Couldn't load template file for handle $handle");
+			}
+
+			// Actually compile the code now.
+			$this->compiled_code[$handle] = $this->compile($this->uncompiled_code[$handle]);
+
+			$fp = fopen($cache_file, 'w+');
+			fwrite ($fp, '<?php' . "\n" . $this->compiled_code[$handle] . "\n?" . '>');
+			fclose($fp);
+
+			touch($cache_file, filemtime($this->files[$handle]));
+			@chmod($cache_file, 0777);
+
+			eval($this->compiled_code[$handle]);
+		}
+	
+		return true;
+	}
+
+	/**
+	 * Inserts the uncompiled code for $handle as the
+	 * value of $varname in the root-level. This can be used
+	 * to effectively include a template in the middle of another
+	 * template.
+	 * Note that all desired assignments to the variables in $handle should be done
+	 * BEFORE calling this function.
+	 */
+	function assign_var_from_handle($varname, $handle)
+	{
+		global $phpEx;
+
+		$cache_file = $this->cachedir . $this->filename[$handle] . '.' . $phpEx;
+
+		if(@filemtime($cache_file) == @filemtime($this->files[$handle]))
+		{
+			$_str = '';
+			include($cache_file);
+		}
+		else 
+		{
+			if (!$this->loadfile($handle))
+			{
+				die("Template->pparse(): Couldn't load template file for handle $handle");
+			}
+
+			$code = $this->compile($this->uncompiled_code[$handle], true, '_str');
+
+			$fp = fopen($cache_file, 'w+');
+			fwrite ($fp, '<?php' . "\n" . $code . "\n?" . '>');
+			fclose($fp);
+
+			touch($cache_file, filemtime($this->files[$handle]));
+			@chmod($cache_file, 0777);
+
+			// Compile It, With The "no Echo Statements" Option On.
+			$_str = '';
+			// evaluate the variable assignment.
+			eval($code);
+		
+		}
+
+		// assign the value of the generated variable to the given varname.
+		$this->assign_var($varname, $_str);
+
+		return true;
+	}
+
+	/**
+	 * Block-level variable assignment. Adds a new block iteration with the given
+	 * variable assignments. Note that this should only be called once per block
+	 * iteration.
+	 */
+	function assign_block_vars($blockname, $vararray)
+	{
+		if (strstr($blockname, '.'))
+		{
+			// Nested block.
+			$blocks = explode('.', $blockname);
+			$blockcount = sizeof($blocks) - 1;
+
+			$str = &$this->_tpldata; 
+			for ($i = 0; $i < $blockcount; $i++) 
+			{
+				$str = &$str[$blocks[$i]]; 
+				$str = &$str[sizeof($str) - 1]; 
+			} 
+
+			// Now we add the block that we're actually assigning to.
+			// We're adding a new iteration to this block with the given
+			// variable assignments.
+			$str[$blocks[$blockcount]][] = $vararray;
+		}
+		else
+		{
+			// Top-level block.
+			// Add a new iteration to this block with the variable assignments
+			// we were given.
+			$this->_tpldata[$blockname][] = $vararray;
+		}
+
+		return true;
+	}
+
+	/**
+	 * Root-level variable assignment. Adds to current assignments, overriding
+	 * any existing variable assignment with the same name.
+	 */
+	function assign_vars($vararray)
+	{
+		reset ($vararray);
+		while (list($key, $val) = each($vararray))
+		{
+			$this->_tpldata['.'][0][$key] = $val;
+		}
+
+		return true;
+	}
+
+	/**
+	 * Root-level variable assignment. Adds to current assignments, overriding
+	 * any existing variable assignment with the same name.
+	 */
+	function assign_var($varname, $varval)
+	{
+		$this->_tpldata['.'][0][$varname] = $varval;
+
+		return true;
+	}
+
+
+	/**
+	 * Generates a full path+filename for the given filename, which can either
+	 * be an absolute name, or a name relative to the rootdir for this Template
+	 * object.
+	 */
+	function make_filename($filename)
+	{
+		// Check if it's an absolute or relative path.
+		if (substr($filename, 0, 1) != '/')
+		{
+			$filename = phpbb_realpath($this->root . '/' . $filename);
+		}
+
+		if (!file_exists($filename))
+		{
+			die("Template->make_filename(): Error - file $filename does not exist");
+		}
+
+		return $filename;
+	}
+
+
+	/**
+	 * If not already done, load the file for the given handle and populate
+	 * the uncompiled_code[] hash with its code. Do not compile.
+	 */
+	function loadfile($handle)
+	{
+		// If the file for this handle is already loaded and compiled, do nothing.
+		if (!empty($this->uncompiled_code[$handle]))
+		{
+			return true;
+		}
+
+		// If we don't have a file assigned to this handle, die.
+		if (!isset($this->files[$handle]))
+		{
+			die("Template->loadfile(): No file specified for handle $handle");
+		}
+
+		$filename = $this->files[$handle];
+
+		$str = implode('', @file($filename));
+		if (empty($str))
+		{
+			die("Template->loadfile(): File $filename for handle $handle is empty");
+		}
+
+		$this->uncompiled_code[$handle] = $str;
+
+		return true;
+	}
+
+
+
+	/**
+	 * Compiles the given string of code, and returns
+	 * the result in a string.
+	 * If "do_not_echo" is true, the returned code will not be directly
+	 * executable, but can be used as part of a variable assignment
+	 * for use in assign_code_from_handle().
+	 */
+	function compile($code, $do_not_echo = false, $retvar = '')
+	{
+		$concat = (!$do_not_echo) ? ',' : '.';
+
+		// replace \ with \\ and then ' with \'.
+		$code = str_replace('\\', '\\\\', $code);
+		$code = str_replace('\'', '\\\'', $code);
+
+		// change template varrefs into PHP varrefs
+
+		// This one will handle varrefs WITH namespaces
+		$varrefs = array();
+		preg_match_all('#\{(([a-z0-9\-_]+?\.)+?)([a-z0-9\-_]+?)\}#is', $code, $varrefs);
+		$varcount = sizeof($varrefs[1]);
+		for ($i = 0; $i < $varcount; $i++)
+		{
+			$namespace = $varrefs[1][$i];
+			$varname = $varrefs[3][$i];
+			$new = $this->generate_block_varref($namespace, $varname, $concat);
+
+			$code = str_replace($varrefs[0][$i], $new, $code);
+		}
+
+		// This will handle the remaining root-level varrefs
+		$code = preg_replace('#\{([a-z0-9\-_]*?)\}#is', "' $concat ((isset(\$this->_tpldata['.'][0]['\\1'])) ? \$this->_tpldata['.'][0]['\\1'] : '') $concat '", $code);
+
+		// Break it up into lines.
+		$code_lines = explode("\n", $code);
+
+		$block_nesting_level = 0;
+		$block_names = array();
+		$block_names[0] = '.';
+
+		// Second: prepend echo ', append ' . "\n"; to each line.
+		$line_count = sizeof($code_lines);
+		for ($i = 0; $i < $line_count; $i++)
+		{
+			$code_lines[$i] = chop($code_lines[$i]);
+			if (preg_match('#<!-- BEGIN (.*?) -->#', $code_lines[$i], $m))
+			{
+				$n[0] = $m[0];
+				$n[1] = $m[1];
+
+				// Added: dougk_ff7-Keeps templates from bombing if begin is on the same line as end.. I think. :)
+				if (preg_match('#<!-- END (.*?) -->#', $code_lines[$i], $n))
+				{
+					$block_nesting_level++;
+					$block_names[$block_nesting_level] = $m[1];
+					if ($block_nesting_level < 2)
+					{
+						// Block is not nested.
+						$code_lines[$i] = '$_' . $a[1] . '_count = (isset($this->_tpldata[\'' . $n[1] . '\'])) ?  sizeof($this->_tpldata[\'' . $n[1] . '\']) : 0;';
+						$code_lines[$i] .= 'for ($_' . $n[1] . '_i = 0; $_' . $n[1] . '_i < $_' . $n[1] . '_count; $_' . $n[1] . '_i++)';
+						$code_lines[$i] .= '{';
+					}
+					else
+					{
+						// This block is nested.
+
+						// Generate a namespace string for this block.
+						$namespace = substr(implode('.', $block_names), 0, -1);
+						// strip leading period from root level..
+						$namespace = substr($namespace, 2);
+						// Get a reference to the data array for this block that depends on the
+						// current indices of all parent blocks.
+						$varref = $this->generate_block_data_ref($namespace, false);
+						// Create the for loop code to iterate over this block.
+						$code_lines[$i] = '$_' . $a[1] . '_count = (isset(' . $varref . ')) ? sizeof(' . $varref . ') : 0;';
+						$code_lines[$i] .= 'for ($_' . $n[1] . '_i = 0; $_' . $n[1] . '_i < $_' . $n[1] . '_count; $_' . $n[1] . '_i++)';
+						$code_lines[$i] .= '{';
+					}
+
+					// We have the end of a block.
+					unset($block_names[$block_nesting_level]);
+					$block_nesting_level--;
+					$code_lines[$i] .= '} // END ' . $n[1];
+					$m[0] = $n[0];
+					$m[1] = $n[1];
+				}
+				else
+				{
+					// We have the start of a block.
+					$block_nesting_level++;
+					$block_names[$block_nesting_level] = $m[1];
+					if ($block_nesting_level < 2)
+					{
+						// Block is not nested.
+						$code_lines[$i] = '$_' . $m[1] . '_count = (isset($this->_tpldata[\'' . $m[1] . '\'])) ? sizeof($this->_tpldata[\'' . $m[1] . '\']) : 0;';
+						$code_lines[$i] .= 'for ($_' . $m[1] . '_i = 0; $_' . $m[1] . '_i < $_' . $m[1] . '_count; $_' . $m[1] . '_i++)';
+						$code_lines[$i] .= '{';
+					}
+					else
+					{
+						// This block is nested.
+
+						// Generate a namespace string for this block.
+						$namespace = implode('.', $block_names);
+						// strip leading period from root level..
+						$namespace = substr($namespace, 2);
+						// Get a reference to the data array for this block that depends on the
+						// current indices of all parent blocks.
+						$varref = $this->generate_block_data_ref($namespace, false);
+						// Create the for loop code to iterate over this block.
+						$code_lines[$i] = '$_' . $m[1] . '_count = (isset(' . $varref . ')) ? sizeof(' . $varref . ') : 0;';
+						$code_lines[$i] .= 'for ($_' . $m[1] . '_i = 0; $_' . $m[1] . '_i < $_' . $m[1] . '_count; $_' . $m[1] . '_i++)';
+						$code_lines[$i] .= '{';
+					}
+				}
+			}
+			else if (preg_match('#<!-- END (.*?) -->#', $code_lines[$i], $m))
+			{
+				// We have the end of a block.
+				unset($block_names[$block_nesting_level]);
+				$block_nesting_level--;
+				$code_lines[$i] = '} // END ' . $m[1];
+			}
+			else
+			{
+				// We have an ordinary line of code.
+				if (!$do_not_echo)
+				{
+					$code_lines[$i] = "echo '" . $code_lines[$i] . "\n';\n";
+				}
+				else
+				{
+					$code_lines[$i] = '$' . $retvar . ".= '" . $code_lines[$i] . "\n';\n"; 
+				}
+			}
+		}
+
+		// Bring it back into a single string of lines of code.
+		$code = implode("\n", $code_lines);
+		return $code;
+	}
+
+
+	/**
+	 * Generates a reference to the given variable inside the given (possibly nested)
+	 * block namespace. This is a string of the form:
+	 * ' . $this->_tpldata['parent'][$_parent_i]['$child1'][$_child1_i]['$child2'][$_child2_i]...['varname'] . '
+	 * It's ready to be inserted into an "echo" line in one of the templates.
+	 * NOTE: expects a trailing "." on the namespace.
+	 */
+	function generate_block_varref($namespace, $varname, $concat)
+	{
+		// Strip the trailing period.
+		$namespace = substr($namespace, 0, strlen($namespace) - 1);
+
+		// Get a reference to the data block for this namespace.
+		$varref = $this->generate_block_data_ref($namespace, true);
+		// Prepend the necessary code to stick this in an echo line.
+
+		// Append the variable reference.
+		$varref .= "['$varname']";
+
+		$varref = "' $concat ((isset($varref)) ? $varref : '') $concat '";
+
+		return $varref;
+
+	}
+
+
+	/**
+	 * Generates a reference to the array of data values for the given
+	 * (possibly nested) block namespace. This is a string of the form:
+	 * $this->_tpldata['parent'][$_parent_i]['$child1'][$_child1_i]['$child2'][$_child2_i]...['$childN']
+	 *
+	 * If $include_last_iterator is true, then [$_childN_i] will be appended to the form shown above.
+	 * NOTE: does not expect a trailing "." on the blockname.
+	 */
+	function generate_block_data_ref($blockname, $include_last_iterator)
+	{
+		// Get an array of the blocks involved.
+		$blocks = explode('.', $blockname);
+		$blockcount = sizeof($blocks) - 1;
+		$varref = '$this->_tpldata';
+		// Build up the string with everything but the last child.
+		for ($i = 0; $i < $blockcount; $i++)
+		{
+			$varref .= "['" . $blocks[$i] . "'][\$_" . $blocks[$i] . '_i]';
+		}
+		// Add the block reference for the last child.
+		$varref .= "['" . $blocks[$blockcount] . "']";
+		// Add the iterator for the last child if requried.
+		if ($include_last_iterator)
+		{
+			$varref .= '[$_' . $blocks[$blockcount] . '_i]';
+		}
+
+		return $varref;
+	}
+
+}
+
+?>
\ No newline at end of file
diff -ruN _currtarball/docs/CHANGELOG.html phpBB2/docs/CHANGELOG.html
--- _currtarball/docs/CHANGELOG.html	2006-05-16 16:44:25.000000000 -0500
+++ phpBB2/docs/CHANGELOG.html	2006-06-09 09:29:41.000000000 -0500
@@ -32,6 +32,8 @@
 <ol>
 <li><a href="#changelog">Changelog</a></li>
 <ol type="i">
+	<li><a href="#2020">Changes since 2.0.20</a></li>
+	<li><a href="#2019">Changes since 2.0.19</a></li>
 	<li><a href="#2018">Changes since 2.0.18</a></li>
 	<li><a href="#2017">Changes since 2.0.17</a></li>
 	<li><a href="#2016">Changes since 2.0.16</a></li>
@@ -64,7 +66,57 @@
 
 <p>This is a non-exhaustive (but still near complete) changelog for phpBB 2.0.x including beta and release candidate versions. Our thanks to all those people who've contributed bug reports and code fixes.</p>
 
-<a name="2018"></a><h3 class="h3">l.i. Changes since 2.0.18</h3>
+<a name="2020"></a><h3 class="h3">l.i. Changes since 2.0.20</h3>
+
+<ul>
+<li>[Fix] Changes to random number generator code to explicitly truncate the length of the string</li>
+<li>[Fix] Quoting on boards with HTML enabled</li>
+<li>[Fix] Special characters on boards with HTML enabled</li>
+<li>[Fix] Redirect to list if cancelling deletion of ranks, smilies or word censors</li>
+<li>[Fix] Missing error message if an inactive user tried to login (Bug #1598)</li>
+<li>[Fix] Do not alter post counts when just removing a poll (Bug #1602)</li>
+<li>[Fix] Correct error in removal of old session keys</li>
+<li>[Fix] Changed filtering of short search terms</li>
+<li>[Sec] Improved filtering on language selection (also addresses a number of bug reports related to missing languages)</li>
+<li>[Change] Backported more efficient highlighting code from Olympus</li>
+<li>[Change] Backported zlib emulation code so that there is only a single confirmation image even if zlib is not available</li>
+</ul>
+
+
+<a name="2019"></a><h3 class="h3">l.ii. Changes since 2.0.19</h3>
+
+<ul>
+<li>[Fix] Prevent login attempts from incrementing for inactive users</li>
+<li>[Fix] Do not check maximum login attempts on re-authentication to the admin panel - tomknight</li>
+<li>[Fix] Regenerate session keys on password change</li>
+<li>[Fix] retrieving category rows in index.php (Bug #90)</li>
+<li>[Fix] improved index performance by determining the permissions before iterating through all forums (Bug #91)</li>
+<li>[Fix] Better handling of short usernames within the search (bug #105)</li>
+<li>[Fix] Send a no-cache header on admin pages as well as normal board pages (Bug #149)</li>
+<li>[Fix] Apply word censors to the message when quoting it (Bug #405)</li>
+<li>[Fix] Improved performance of query in admin_groups (Bug #753)</li>
+<li>[Fix] Workaround for an issue in either PHP or MSSQL resulting in a space being returned instead of an empty string (bug #830)</li>
+<li>[Fix] Correct use of default_style config value (Bug #861)</li>
+<li>[Fix] Replace unneeded unset calls in admin_db_utilities.php - vanderaj</li>
+<li>[Fix] Improved error handling in modcp.php</li>
+<li>[Fix] Improved handling of forums to which the user does not have any explicit permissions - vanderaj</li>
+<li>[Fix] Assorted fixes and cleanup of admin_ranks.php, now requires confirmation of deletions</li>
+<li>[Fix] Assorted fixes and cleanup of admin_words.php, now requires confirmation of deletions</li>
+<li>[Fix] Addition and editing of smilies can no longer be performed via GET, now requires confirmation of deletions</li>
+<li>[Fix] Escape group names in admin_groups.php</li>
+<li>[Sec] Replace strip_tags with htmlspecialchars in private message subject</li>
+<li>[Sec] Some changes to HTML handling if enabled</li>
+<li>[Sec] Escape any special characters in reverse dns - Anthrax101</li>
+<li>[Sec] Typecast poll id values - Anthrax101</li>
+<li>[Sec] Added configurable search flood control to reduce the effect of DoS style attacks</li>
+<li>[Sec] Changed the way we create "random" values for use as keys - chinchilla/Anthrax101</li>
+<li>[Change] Changed handling of the case where a selected style doesn't exist in the database</li>
+<li>[Change] Changed handling of topic pruning to improve performance</li>
+<li>[Change] Changed default forum permissions to only allow registered users to post in new forums</li>
+</ul>
+
+
+<a name="2018"></a><h3 class="h3">l.iii. Changes since 2.0.18</h3>
 
 <ul>
 <li>[Fix] corrected index on session keys table under MS SQL</li>
@@ -78,17 +130,15 @@
 <li>[Fix] fixed captcha for those not having the zlib extension enabled</li>
 <li>[Change] Placed version information above who is online in admin panel for better visual presence</li>
 <li>[Sec] fixed XSS issue (only valid for Internet Explorer) within the url bbcode</li>
-<li>[Sec] fixed XSS issue (only valid for Internet Explorer) if html tags are allowed and enabled</li>
+<li>[Sec] fixed XSS issue if html tags are allowed and enabled</li>
 <li>[Sec] added configurable maximum login attempts to prevent dictionary attacks</li>
 </ul>
 
 
-<a name="2017"></a><h3 class="h3">l.ii. Changes since 2.0.17</h3>
+<a name="2017"></a><h3 class="h3">l.iv. Changes since 2.0.17</h3>
 
 <ul>
 <li>[Fix] incorrect handling of password resets if admin activation is enabled (Bug #88)</li>
-<li>[Fix] retrieving category rows in index.php (Bug #90)</li>
-<li>[Fix] improved index performance by determining the permissions before iterating through all forums (Bug #91)</li>
 <li>[Fix] wrong topic redirection after login redirect (Bug #94)</li>
 <li>[Fix] improved handling of username lists in admin_ug_auth.php (Bug #98)</li>
 <li>[Fix] incorrect removal of bbcode_uid values if bbcode has been turned off (Bug #100)</li>
@@ -133,7 +183,7 @@
 <li>[Sec] compare imagetype on avatar uploading to match the file extension from uploaded file</li>
 </ul>
 
-<a name="2016"></a><h3 class="h3">l.iii. Changes since 2.0.16</h3>
+<a name="2016"></a><h3 class="h3">l.v. Changes since 2.0.16</h3>
 
 <ul>
 <li>Added extra checks to the deletion code in privmsg.php - reported by party_fan</li>
@@ -149,7 +199,7 @@
 <li>Correctly set username on posts when deleting a user from the admin panel</li>
 </ul>
 
-<a name="2015"></a><h3 class="h3">l.iv. Changes since 2.0.15</h3>
+<a name="2015"></a><h3 class="h3">l.vi. Changes since 2.0.15</h3>
 
 <ul>
 <li>Fixed critical issue with highlighting - <b>Discovered and fix provided by Ron van Daal</b></li>
@@ -161,7 +211,7 @@
 <li>Fixed bug in admin re-authentication redirect for servers not having index.php as one of their default files set</li>
 </ul>
 
-<a name="2014"></a><h3 class="h3">l.v. Changes since 2.0.14</h3>
+<a name="2014"></a><h3 class="h3">l.vii. Changes since 2.0.14</h3>
 
 <ul>
 <li>Fixed moderator status removal in groupcp.php</li>
@@ -183,7 +233,7 @@
 <li>Empty url/img bbcodes no longer get parsed</li>
 </ul>
 
-<a name="2013"></a><h3 class="h3">l.vi. Changes since 2.0.13</h3>
+<a name="2013"></a><h3 class="h3">l.viii. Changes since 2.0.13</h3>
 
 <ul>
 <li>Hardened author and keyword search a bit to not allow very server intensive searches</li>
@@ -200,7 +250,7 @@
 <li>Fixed case-sensitivity issues in postgres7.php - <b>R45</b></li>
 </ul>
 
-<a name="2012"></a><h3 class="h3">l.vii. Changes since 2.0.12</h3>
+<a name="2012"></a><h3 class="h3">l.ix. Changes since 2.0.12</h3>
 
 <ul>
 <li>Ommitted preg_replace warning in viewtopic due to improper working of preg_quote in PHP - originally reported by matrix_killer, fix submitted by another party</li>
@@ -208,7 +258,7 @@
 <li>Minimum requirements raised to PHP 4.0.3 or above due to fixing vulnerability issues breaking PHP3 compatibility.</li>
 </ul>
 
-<a name="2011"></a><h3 class="h3">l.viii. Changes since 2.0.11</h3>
+<a name="2011"></a><h3 class="h3">l.x. Changes since 2.0.11</h3>
 
 <ul>
 <li>Added confirm table to admin_db_utilities.php</li>
@@ -223,7 +273,7 @@
 <li>Fixed path disclosure bug in viewtopic.php caused by a PHP 4.3.10 bug - <b>matrix_killer</b></li>
 </ul>
 
-<a name="2010"></a><h3 class="h3">l.ix. Changes since 2.0.10</h3>
+<a name="2010"></a><h3 class="h3">l.xi. Changes since 2.0.10</h3>
 
 <ul>
 <li>Fixed vulnerability in highlighting code (<b>very high severity, please update your installation as soon as possible</b>)</li>
@@ -234,7 +284,7 @@
 <li>Added visual confirmation mod to code base</li>
 </ul>
 
-<a name="209"></a><h3 class="h3">l.x. Changes since 2.0.9</h3>
+<a name="209"></a><h3 class="h3">l.xii. Changes since 2.0.9</h3>
 
 <ul>
 <li>Fixed deleting of styles in admin_styles.php</li>
@@ -247,7 +297,7 @@
 <li>Fixed visual confirmation code. The image was not created due to a wrong regular expression.</li>
 </ul>
 
-<a name="208"></a><h3 class="h3">l.xi. Changes since 2.0.8</h3>
+<a name="208"></a><h3 class="h3">l.xiii. Changes since 2.0.8</h3>
 
 <ul>
 <li>Fixed one vulnerability in admin_board.php - <b>Xore</b></li>
@@ -266,7 +316,7 @@
 <li>Fixed problem with SID not delivered to next page in groupcp.php</li>
 </ul>
 
-<a name="207"></a><h3 class="h3">l.xii. Changes since 2.0.7</h3>
+<a name="207"></a><h3 class="h3">l.xiv. Changes since 2.0.7</h3>
 
 <ul>
 <li>Fixed several vulnerabilities in admin pages</li>
@@ -278,7 +328,7 @@
 <li>Fixed sql injection vulnerability in privmsg - 2.0.8a</li>
 </ul>
 
-<a name="206"></a><h3 class="h3">1.xiii. Changes since 2.0.6</h3>
+<a name="206"></a><h3 class="h3">1.xv. Changes since 2.0.6</h3>
 
 <ul>
 <li>Fixed several vulnerabilities in modcp - <b>Robert Lavierck</b></li>
@@ -292,7 +342,7 @@
 <li>Fixed potential vulnerability in avatar gallery</li>
 </ul>
 
-<a name="205"></a><h3 class="h3">1.xiv. Changes since 2.0.5</h3>
+<a name="205"></a><h3 class="h3">1.xvi. Changes since 2.0.5</h3>
 
 <ul>
 <li>Fixed various email issues</li>
@@ -308,7 +358,7 @@
 <li>Fixed sql injection with reset date format field in profile - <b>tendor</b></li>
 </ul>
 
-<a name="204"></a><h3 class="h3">1.xv. Changes since 2.0.4</h3>
+<a name="204"></a><h3 class="h3">1.xvii. Changes since 2.0.4</h3>
 
 <ul>
 <li>Removed user facing session_id checks</li>
@@ -380,7 +430,7 @@
 <li>Default English support for visual confirmation - translators are encouraged to support this</li>
 </ul>
 
-<a name="203"></a><h3 class="h3">1.xvi. Changes since 2.0.3</h3>
+<a name="203"></a><h3 class="h3">1.xviii. Changes since 2.0.3</h3>
 
 <ul>
 <li>Fixed cross-browser scripting issue with highlight param</li>
@@ -507,7 +557,7 @@
 <li>Fixed potential SQL vulnerability with marking of private messages - <b>Ulf Harnhammar</b></li>
 </ul>
 
-<a name="202"></a><h3 class="h3">1.xvii. Changes since 2.0.2</h3>
+<a name="202"></a><h3 class="h3">1.xix. Changes since 2.0.2</h3>
 
 <ul>
 <li>Fixed potential cross-site scripting vulnerability with avatars - <b>Showscout</b></li>
@@ -516,7 +566,7 @@
 <li>Fixed (hopefully) issue with MS Access and multiple pages</li>
 </ul>
 
-<a name="201"></a><h3 class="h3">1.xviii. Changes since 2.0.1</h3>
+<a name="201"></a><h3 class="h3">1.xx. Changes since 2.0.1</h3>
 
 <ul>
 <li>Fixed missing "username" lang variable in user admin template</li>
@@ -551,7 +601,7 @@
 <li>Fix emailer to allow sending emails with language-specific character sets</li>
 </ul>
 
-<a name="200"></a><h3 class="h3">1.xix. Changes since 2.0.0</h3>
+<a name="200"></a><h3 class="h3">1.xxi. Changes since 2.0.0</h3>
 
 <ul>
 <li>Fixed delete image bug for normal users</li>
@@ -608,7 +658,7 @@
 <li>Added database closure to admin frameset page</li>
 </ul>
 
-<a name="final"></a><h3 class="h3">1.xx. Changes since RC-4</h3>
+<a name="final"></a><h3 class="h3">1.xxii. Changes since RC-4</h3>
 
 <ul>
 <li>Fixed improper report of general error when posting messages containing errors</li>
@@ -638,7 +688,7 @@
 <li>Fixed various remaining usergroup display issues</li>
 </ul>
 
-<a name="rc4"></a><h3 class="h3">1.xxi. Changes since RC-3</h3>
+<a name="rc4"></a><h3 class="h3">1.xxiii. Changes since RC-3</h3>
 
 <ul>
 <li>Addressed serious security issue with included files</li>
@@ -669,7 +719,7 @@
 <li>Fix (hopefully) remaining ICQ overlay issue with view profile in subSilver</li>
 </ul>
 
-<a name="rc3"></a><h3 class="h3">1.xxii. Changes since RC-2</h3>
+<a name="rc3"></a><h3 class="h3">1.xxiv. Changes since RC-2</h3>
 
 <ul>
 <li>Fixed infamous install parse error</li>
@@ -702,7 +752,7 @@
 <li>Hidden usergroups are now completely hidden from view</li>
 </ul>
 
-<a name="rc2"></a><h3 class="h3">1.xxiii. Changes since RC-1</h3>
+<a name="rc2"></a><h3 class="h3">1.xxv. Changes since RC-1</h3>
 
 <ul>
 <li>Fixed numerous PostgreSQL related issues</li>
@@ -722,7 +772,7 @@
 <li>Various other fixes and updates</li>
 </ul>
 
-<a name="rc1"></a><h3 class="h3">1.xxiv. Changes since RC-1 (pre)</h3>
+<a name="rc1"></a><h3 class="h3">1.xxvi. Changes since RC-1 (pre)</h3>
 
 <ul>
 <li>Upgrade script completed for initial fully functional release</li>
diff -ruN _currtarball/docs/FAQ.html phpBB2/docs/FAQ.html
--- _currtarball/docs/FAQ.html	2006-05-16 16:44:25.000000000 -0500
+++ phpBB2/docs/FAQ.html	2006-06-09 09:29:41.000000000 -0500
@@ -164,14 +164,16 @@
 
 <li><b>Can I suggest a feature for phpBB 3.0?</b>
 
-<p>No, the feature list for phpBB 3.0 is now frozen and no new features will be added to that list. You may however add requests for the next release after that, 3.2, in our feature tracker:</p>
+<p>No, the feature list for phpBB 3.0 is now frozen and no new features will be added to that list. At the moment we do not accept new feature requests.</p>
+<!--
+You may however add requests for the next release after that, 3.2, in our feature tracker:</p>
 
 <p><a href="http://sourceforge.net/tracker/?atid=580201&group_id=7885&func=browse" target="_new">http://sourceforge.net/tracker/?atid=580201&group_id=7885&func=browse</a></p>
 
 <p>Before submitting your idea please <b>ensure</b> you have read through the entries in that list. If your idea is similar to an existing one please feel free to add a comment to it. Please <b>do not</b> submit duplicate suggestions!</p>
 
 <p>We make no promises to the inclusion of features but we will endeavour to introduce the most requested or most interesting ones.</p></li>
-
+//-->
 <p>If you wish to follow the progress of phpBB 3.0 you may like to visit our development forum to see how things are progressing:</p>
 
 <p><a href="http://area51.phpbb.com/phpBB/" target="_new">http://area51.phpbb.com/phpBB/</a></p>
diff -ruN _currtarball/docs/INSTALL.html phpBB2/docs/INSTALL.html
--- _currtarball/docs/INSTALL.html	2006-05-16 16:44:25.000000000 -0500
+++ phpBB2/docs/INSTALL.html	2006-06-09 09:29:41.000000000 -0500
@@ -194,7 +194,7 @@
 
 <a name="upgradeSTABLE_files"></a><h3 class="h3">7.ii. Changed files only</h3>
 
-<p>This package contains a number of archives, each contains the files changed from a given release to the latest version. You should select the appropriate archive for your current version, e.g. if you currently have 2.0.18 you should select the phpBB-2.0.18_to_2.0.19.zip/tar.gz file.</p>
+<p>This package contains a number of archives, each contains the files changed from a given release to the latest version. You should select the appropriate archive for your current version, e.g. if you currently have 2.0.20 you should select the phpBB-2.0.20_to_2.0.21.zip/tar.gz file.</p>
 
 <p>The directory structure has been preserved enabling you (if you wish) to simply upload the contents of the archive to the appropriate location on your server, i.e. simply overwrite the existing files with the new versions. Do not forget that if you have installed any Mods these files will overwrite the originals possibly destroying them in the process. You will need to re-add Mods to any affected file before uploading.</p>
 
@@ -204,7 +204,7 @@
 
 <p>The patch file is probably the best solution for those with many Mods or other changes who do not want to re-add them back to all the changed files. To use this you will need command line access to a standard UNIX type <b>patch</b> application.</p>
 
-<p>A number of patch files are provided to allow you to upgrade from previous stable releases. Select the correct patch, e.g. if your current version is 2.0.18 you need the phpBB-2.0.18_to_2.0.19.patch. Place the correct patch in the parent directory containing the phpBB 2 core files (i.e. index.php, viewforum.php, etc.). With this done you should run the following command: <b>patch -cl -d [PHPBB DIRECTORY] -p1 &lt; [PATCH NAME]</b> (where PHPBB DIRECTORY is the directory name your phpBB Installation resides in, for example phpBB2, and where PATCH NAME is the relevant filename of the selected patch file). This should complete quickly, hopefully without any HUNK FAILED comments.</p>
+<p>A number of patch files are provided to allow you to upgrade from previous stable releases. Select the correct patch, e.g. if your current version is 2.0.20 you need the phpBB-2.0.20_to_2.0.21.patch. Place the correct patch in the parent directory containing the phpBB 2 core files (i.e. index.php, viewforum.php, etc.). With this done you should run the following command: <b>patch -cl -d [PHPBB DIRECTORY] -p1 &lt; [PATCH NAME]</b> (where PHPBB DIRECTORY is the directory name your phpBB Installation resides in, for example phpBB2, and where PATCH NAME is the relevant filename of the selected patch file). This should complete quickly, hopefully without any HUNK FAILED comments.</p>
 
 <p>If you do get failures you should look at using the <a href="#upgradeSTABLE_files">Changed files only</a> package to replace the files which failed to patch, please note that you will need to manually re-add any Mods to these particular files. Alternatively if you know how you can examine the .rej files to determine what failed where and make manual adjustments to the relevant source.</p>
 
diff -ruN _currtarball/includes/functions.php phpBB2/includes/functions.php
--- _currtarball/includes/functions.php	2006-05-16 16:51:10.000000000 -0500
+++ phpBB2/includes/functions.php	2006-06-09 09:29:41.000000000 -0500
@@ -6,7 +6,7 @@
  *   copyright            : (C) 2001 The phpBB Group
  *   email                : support@phpbb.com
  *
- *   $Id: functions.php,v 1.133.2.44 2006/02/26 19:37:50 grahamje Exp $
+ *   $Id: functions.php,v 1.133.2.47 2006/06/08 21:11:04 grahamje Exp $
  *
  *
  ***************************************************************************/
@@ -168,7 +168,7 @@
 		$dss_seeded = true;
 	}
 
-	return substr($val, 16);
+	return substr($val, 4, 16);
 }
 //
 // Get Userdata, $user can be username or user_id. If force_str is true, the username will be forced.
@@ -309,14 +309,14 @@
 function init_userprefs($userdata)
 {
 	global $board_config, $theme, $images;
-	global $template, $lang, $phpEx, $phpbb_root_path;
+	global $template, $lang, $phpEx, $phpbb_root_path, $db;
 	global $nav_links;
 
 	if ( $userdata['user_id'] != ANONYMOUS )
 	{
 		if ( !empty($userdata['user_lang']))
 		{
-			$board_config['default_lang'] = $userdata['user_lang'];
+			$default_lang = phpbb_ltrim(basename(phpbb_rtrim($userdata['user_lang'])), "'");
 		}
 
 		if ( !empty($userdata['user_dateformat']) )
@@ -329,12 +329,61 @@
 			$board_config['board_timezone'] = $userdata['user_timezone'];
 		}
 	}
+	else
+	{
+		$default_lang = phpbb_ltrim(basename(phpbb_rtrim($board_config['default_lang'])), "'");
+	}
 
-	if ( !file_exists(@phpbb_realpath($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_main.'.$phpEx)) )
+	if ( !file_exists(@phpbb_realpath($phpbb_root_path . 'language/lang_' . $default_lang . '/lang_main.'.$phpEx)) )
 	{
-		$board_config['default_lang'] = 'english';
+		if ( $userdata['user_id'] != ANONYMOUS )
+		{
+			// For logged in users, try the board default language next
+			$default_lang = phpbb_ltrim(basename(phpbb_rtrim($board_config['default_lang'])), "'");
+		}
+		else
+		{
+			// For guests it means the default language is not present, try english
+			// This is a long shot since it means serious errors in the setup to reach here,
+			// but english is part of a new install so it's worth us trying
+			$default_lang = 'english';
+		}
+
+		if ( !file_exists(@phpbb_realpath($phpbb_root_path . 'language/lang_' . $default_lang . '/lang_main.'.$phpEx)) )
+		{
+			message_die(CRITICAL_ERROR, 'Could not locate valid language pack');
+		}
 	}
 
+	// If we've had to change the value in any way then let's write it back to the database
+	// before we go any further since it means there is something wrong with it
+	if ( $userdata['user_id'] != ANONYMOUS && $userdata['user_lang'] !== $default_lang )
+	{
+		$sql = 'UPDATE ' . USERS_TABLE . "
+			SET user_lang = '" . $default_lang . "'
+			WHERE user_lang = '" . $userdata['user_lang'] . "'";
+
+		if ( !($result = $db->sql_query($sql)) )
+		{
+			message_die(CRITICAL_ERROR, 'Could not update user language info');
+		}
+
+		$userdata['user_lang'] = $default_lang;
+	}
+	elseif ( $userdata['user_id'] === ANONYMOUS && $board_config['default_lang'] !== $default_lang )
+	{
+		$sql = 'UPDATE ' . CONFIG_TABLE . "
+			SET config_value = '" . $default_lang . "'
+			WHERE config_name = 'default_lang'";
+
+		if ( !($result = $db->sql_query($sql)) )
+		{
+			message_die(CRITICAL_ERROR, 'Could not update user language info');
+		}
+	}
+
+	$board_config['default_lang'] = $default_lang;
+
 	include($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_main.' . $phpEx);
 
 	if ( defined('IN_ADMIN') )
@@ -393,9 +442,9 @@
 {
 	global $db, $board_config, $template, $images, $phpbb_root_path;
 
-	$sql = "SELECT *
-		FROM " . THEMES_TABLE . "
-		WHERE themes_id = $style";
+	$sql = 'SELECT *
+		FROM ' . THEMES_TABLE . '
+		WHERE themes_id = ' . (int) $style;
 	if ( !($result = $db->sql_query($sql)) )
 	{
 		message_die(CRITICAL_ERROR, 'Could not query database for theme info');
@@ -410,7 +459,7 @@
 		{
 			$sql = 'SELECT *
 				FROM ' . THEMES_TABLE . '
-				WHERE themes_id = ' . $board_config['default_style'];
+				WHERE themes_id = ' . (int) $board_config['default_style'];
 			if ( !($result = $db->sql_query($sql)) )
 			{
 				message_die(CRITICAL_ERROR, 'Could not query database for theme info');
@@ -421,7 +470,7 @@
 				$db->sql_freeresult($result);
 
 				$sql = 'UPDATE ' . USERS_TABLE . '
-					SET user_style = ' . $board_config['default_style'] . "
+					SET user_style = ' . (int) $board_config['default_style'] . "
 					WHERE user_style = $style";
 				if ( !($result = $db->sql_query($sql)) )
 				{
diff -ruN _currtarball/includes/functions_post.php phpBB2/includes/functions_post.php
--- _currtarball/includes/functions_post.php	2006-05-16 16:51:10.000000000 -0500
+++ phpBB2/includes/functions_post.php	2006-06-09 09:29:41.000000000 -0500
@@ -6,7 +6,7 @@
  *   copyright            : (C) 2001 The phpBB Group
  *   email                : support@phpbb.com
  *
- *   $Id: functions_post.php,v 1.9.2.49 2006/03/14 20:40:32 grahamje Exp $
+ *   $Id: functions_post.php,v 1.9.2.52 2006/05/06 13:38:55 grahamje Exp $
  *
  *
  ***************************************************************************/
@@ -61,10 +61,11 @@
 		foreach ($message_split as $part)
 		{
 			$tag = array(array_shift($matches[0]), array_shift($matches[1]), array_shift($matches[2]));
-			$message .= htmlspecialchars($part) . clean_html($tag);
+			$message .= preg_replace($html_entities_match, $html_entities_replace, $part) . clean_html($tag);
 		}
 
 		$message = addslashes($message);
+		$message = str_replace('&quot;', '\&quot;', $message);
 	}
 	else
 	{
@@ -412,12 +413,15 @@
 		$topic_update_sql .= 'topic_vote = 0';
 	}
 
-	$sql = "UPDATE " . FORUMS_TABLE . " SET 
-		$forum_update_sql 
-		WHERE forum_id = $forum_id";
-	if (!$db->sql_query($sql))
+	if ($mode != 'poll_delete')
 	{
-		message_die(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql);
+		$sql = "UPDATE " . FORUMS_TABLE . " SET 
+			$forum_update_sql 
+			WHERE forum_id = $forum_id";
+		if (!$db->sql_query($sql))
+		{
+			message_die(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql);
+		}
 	}
 
 	if ($topic_update_sql != '')
diff -ruN _currtarball/includes/sessions.php phpBB2/includes/sessions.php
--- _currtarball/includes/sessions.php	2006-05-16 16:51:10.000000000 -0500
+++ phpBB2/includes/sessions.php	2006-06-09 09:29:41.000000000 -0500
@@ -6,7 +6,7 @@
  *   copyright            : (C) 2001 The phpBB Group
  *   email                : support@phpbb.com
  *
- *   $Id: sessions.php,v 1.58.2.23 2006/04/05 12:42:23 grahamje Exp $
+ *   $Id: sessions.php,v 1.58.2.25 2006/05/18 19:23:07 grahamje Exp $
  *
  *
  ***************************************************************************/
@@ -367,6 +367,12 @@
 					setcookie($cookiename . '_sid', $session_id, 0, $cookiepath, $cookiedomain, $cookiesecure);
 				}
 
+				// Add the session_key to the userdata array if it is set
+				if ( isset($sessiondata['autologinid']) && $sessiondata['autologinid'] != '' )
+				{
+					$userdata['session_key'] = $sessiondata['autologinid'];
+				}
+
 				return $userdata;
 			}
 		}
@@ -498,7 +504,7 @@
 */
 function session_reset_keys($user_id, $user_ip)
 {
-	global $db, $userdata;
+	global $db, $userdata, $board_config;
 
 	$key_sql = ($user_id == $userdata['user_id'] && !empty($userdata['session_key'])) ? "AND key_id != '" . md5($userdata['session_key']) . "'" : '';
 
@@ -537,7 +543,7 @@
 
 		// And now rebuild the cookie
 		$sessiondata['userid'] = $user_id;
-		$sessiondata['autologinid'] = $autologin_id;
+		$sessiondata['autologinid'] = $auto_login_key;
 		$cookiename = $board_config['cookie_name'];
 		$cookiepath = $board_config['cookie_path'];
 		$cookiedomain = $board_config['cookie_domain'];
diff -ruN _currtarball/includes/usercp_avatar.php phpBB2/includes/usercp_avatar.php
--- _currtarball/includes/usercp_avatar.php	2006-05-16 16:51:10.000000000 -0500
+++ phpBB2/includes/usercp_avatar.php	2006-06-09 09:29:41.000000000 -0500
@@ -6,7 +6,7 @@
  *   copyright            : (C) 2001 The phpBB Group
  *   email                : support@phpbb.com
  *
- *   $Id: usercp_avatar.php,v 1.8.2.23 2006/01/27 21:23:22 grahamje Exp $
+ *   $Id: usercp_avatar.php,v 1.8.2.24 2006/05/23 21:09:27 grahamje Exp $
  *
  *
  ***************************************************************************/
@@ -122,7 +122,7 @@
 	$width = $height = 0;
 	$type = '';
 
-	if ( $avatar_mode == 'remote' && preg_match('/^(http:\/\/)?([\w\-\.]+)\:?([0-9]*)\/(.*)$/', $avatar_filename, $url_ary) )
+	if ( $avatar_mode == 'remote' && preg_match('/^(http:\/\/)?([\w\-\.]+)\:?([0-9]*)\/([^ \?&=\#\"\n\r\t<]*?(\.(jpg|jpeg|gif|png)))$/', $avatar_filename, $url_ary) )
 	{
 		if ( empty($url_ary[4]) )
 		{
diff -ruN _currtarball/includes/usercp_confirm.php phpBB2/includes/usercp_confirm.php
--- _currtarball/includes/usercp_confirm.php	2006-05-16 16:51:10.000000000 -0500
+++ phpBB2/includes/usercp_confirm.php	2006-06-09 09:29:41.000000000 -0500
@@ -6,7 +6,7 @@
  *   copyright            : (C) 2001 The phpBB Group
  *   email                : support@phpbb.com
  *
- *   $Id: usercp_confirm.php,v 1.1.2.3 2006/03/25 14:22:43 grahamje Exp $
+ *   $Id: usercp_confirm.php,v 1.1.2.4 2006/05/30 19:29:43 grahamje Exp $
  *
  ***************************************************************************/
 
@@ -66,108 +66,89 @@
 	exit;
 }
 
-// If we can we will generate a single filtered png else we will have to simply
-// output six seperate original pngs ... first way is preferable!
-if (@extension_loaded('zlib'))
-{
-	$_png = define_filtered_pngs();
-
-	$total_width = 320;
-	$total_height = 50;
-	$img_height = 40;
-	$img_width = 0;
-	$l = 0;
+// We can we will generate a single filtered png 
+// Thanks to DavidMJ for emulating zlib within the code :)
+$_png = define_filtered_pngs();
 
-	list($usec, $sec) = explode(' ', microtime()); 
-	mt_srand($sec * $usec); 
+$total_width = 320;
+$total_height = 50;
+$img_height = 40;
+$img_width = 0;
+$l = 0;
 
-	$char_widths = array();
-	for ($i = 0; $i < strlen($code); $i++)
-	{
-		$char = $code{$i};
+list($usec, $sec) = explode(' ', microtime()); 
+mt_srand($sec * $usec); 
 
-		$width = mt_rand(0, 4);
-		$char_widths[] = $width;
-		$img_width += $_png[$char]['width'] - $width;
-	}
+$char_widths = array();
+for ($i = 0; $i < strlen($code); $i++)
+{
+	$char = $code{$i};
 
-	$offset_x = mt_rand(0, $total_width - $img_width);
-	$offset_y = mt_rand(0, $total_height - $img_height);
+	$width = mt_rand(0, 4);
+	$char_widths[] = $width;
+	$img_width += $_png[$char]['width'] - $width;
+}
 
-	$image = '';
-	$hold_chars = array();
-	for ($i = 0; $i < $total_height; $i++)
-	{
-		$image .= chr(0);
+$offset_x = mt_rand(0, $total_width - $img_width);
+$offset_y = mt_rand(0, $total_height - $img_height);
 
-		if ($i > $offset_y && $i < $offset_y + $img_height)
-		{
-			$j = 0;
+$image = '';
+$hold_chars = array();
+for ($i = 0; $i < $total_height; $i++)
+{
+	$image .= chr(0);
 
-			for ($k = 0; $k < $offset_x; $k++)
-			{
-				$image .= chr(mt_rand(140, 255));
-			}
+	if ($i > $offset_y && $i < $offset_y + $img_height)
+	{
+		$j = 0;
 
-			for ($k = 0; $k < strlen($code); $k++)
-			{
-				$char = $code{$k};
+		for ($k = 0; $k < $offset_x; $k++)
+		{
+			$image .= chr(mt_rand(140, 255));
+		}
 
-				if (empty($hold_chars[$char]))
-				{
-					$hold_chars[$char] = explode("\n", chunk_split(base64_decode($_png[$char]['data']), $_png[$char]['width'] + 1, "\n"));
-				}
-				$image .= randomise(substr($hold_chars[$char][$l], 1), $char_widths[$j]);
-				$j++;
-			}
+		for ($k = 0; $k < strlen($code); $k++)
+		{
+			$char = $code{$k};
 
-			for ($k = $offset_x + $img_width; $k < $total_width; $k++)
+			if (empty($hold_chars[$char]))
 			{
-				$image .= chr(mt_rand(140, 255));
+				$hold_chars[$char] = explode("\n", chunk_split(base64_decode($_png[$char]['data']), $_png[$char]['width'] + 1, "\n"));
 			}
-
-			$l++;
+			$image .= randomise(substr($hold_chars[$char][$l], 1), $char_widths[$j]);
+			$j++;
 		}
-		else
+
+		for ($k = $offset_x + $img_width; $k < $total_width; $k++)
 		{
-			for ($k = 0; $k < $total_width; $k++)
-			{
-				$image .= chr(mt_rand(140, 255));
-			}
+			$image .= chr(mt_rand(140, 255));
 		}
 
+		$l++;
+	}
+	else
+	{
+		for ($k = 0; $k < $total_width; $k++)
+		{
+			$image .= chr(mt_rand(140, 255));
+		}
 	}
-	unset($hold);
-
-	$image = create_png(gzcompress($image), $total_width, $total_height);
-
-	// Output image
-	header('Content-Type: image/png');
-	header('Cache-control: no-cache, no-store');
-	echo $image;
-
-	unset($image);
-	unset($_png);
-	exit;
 
 }
-else
-{
-	$_png = define_raw_pngs();
+unset($hold);
 
-	$c = intval($HTTP_GET_VARS['c']);
-	$char = substr($code, $c - 1, 1);
-	
-	header('Content-Type: image/png');
-	header('Cache-control: no-cache, no-store');
-	echo base64_decode($_png[$char]);
+$image = create_png($image, $total_width, $total_height);
 
-	unset($_png);
-	exit;
-}
+// Output image
+header('Content-Type: image/png');
+header('Cache-control: no-cache, no-store');
+echo $image;
 
+unset($image);
+unset($_png);
 exit;
 
+
 // This is designed to randomise the pixels of the image data within
 // certain limits so as to keep it readable. It also varies the image
 // width a little
@@ -214,7 +195,7 @@
 // http://www.libpng.org/pub/png/spec/PNG-Contents.html we use
 // png because it's a fully recognised open standard and supported
 // by practically all modern browsers and OSs
-function create_png($gzimage, $width, $height)
+function create_png($raw_image, $width, $height)
 {
 	// SIG
 	$image = pack('C8', 137, 80, 78, 71, 13, 10, 26, 10);
@@ -223,8 +204,53 @@
 	$raw .= pack('C4', $height >> 24, $height >> 16, $height >> 8, $height);
 	$raw .= pack('C5', 8, 0, 0, 0, 0);
 	$image .= png_chunk(13, 'IHDR', $raw);
+
+	if (@extension_loaded('zlib'))
+	{
+		$raw_image = gzcompress($raw_image);
+		$length = strlen($raw_image);
+	}
+	else
+	{
+		// The total length of this image, uncompressed, is just a calculation of pixels
+		$length = ($width + 1) * $height;
+
+		// Adler-32 hash generation
+		// Optimized Adler-32 loop ported from the GNU Classpath project
+		$temp_length = $length;
+		$s1 = 1;
+		$s2 = $index = 0;
+
+		while ($temp_length > 0)
+		{
+			// We can defer the modulo operation:
+			// s1 maximally grows from 65521 to 65521 + 255 * 3800
+			// s2 maximally grows by 3800 * median(s1) = 2090079800 < 2^31
+			$substract_value = ($temp_length < 3800) ? $temp_length : 3800;
+			$temp_length -= $substract_value;
+
+			while (--$substract_value >= 0)
+			{
+				$s1 += ord($raw_image[$index]);
+				$s2 += $s1;
+
+				$index++;
+			}
+
+			$s1 %= 65521;
+			$s2 %= 65521;
+		}
+		$adler_hash = pack('N', ($s2 << 16) | $s1);
+
+		// This is the same thing as gzcompress($raw_image, 0) but does not need zlib
+		$raw_image = pack('C3v2', 0x78, 0x01, 0x01, $length, ~$length) . $raw_image . $adler_hash;
+
+		// The Zlib header + Adler hash make us add on 11
+		$length += 11;
+	}
+
 	// IDAT
-	$image .= png_chunk(strlen($gzimage), 'IDAT', $gzimage);
+	$image .= png_chunk($length, 'IDAT', $raw_image);
 	// IEND
 	$image .= png_chunk(0, 'IEND', '');
 
diff -ruN _currtarball/includes/usercp_register.php phpBB2/includes/usercp_register.php
--- _currtarball/includes/usercp_register.php	2006-05-16 16:51:10.000000000 -0500
+++ phpBB2/includes/usercp_register.php	2006-06-09 09:29:41.000000000 -0500
@@ -6,7 +6,7 @@
  *   copyright            : (C) 2001 The phpBB Group
  *   email                : support@phpbb.com
  *
- *   $Id: usercp_register.php,v 1.20.2.74 2006/04/05 12:42:23 grahamje Exp $
+ *   $Id: usercp_register.php,v 1.20.2.76 2006/05/30 19:29:43 grahamje Exp $
  *
  *
  ***************************************************************************/
@@ -991,7 +991,7 @@
 		// Generate the required confirmation code
 		// NB 0 (zero) could get confused with O (the letter) so we make change it
 		$code = dss_rand();
-		$code = strtoupper(str_replace('0', 'o', substr($code, 6)));
+		$code = substr(str_replace('0', 'Z', strtoupper(base_convert($code, 16, 35))), 2, 6);
 
 		$confirm_id = md5(uniqid($user_ip));
 
@@ -1004,7 +1004,7 @@
 
 		unset($code);
 		
-		$confirm_image = (@extension_loaded('zlib')) ? '<img src="' . append_sid("profile.$phpEx?mode=confirm&amp;id=$confirm_id") . '" alt="" title="" />' : '<img src="' . append_sid("profile.$phpEx?mode=confirm&amp;id=$confirm_id&amp;c=1") . '" alt="" title="" /><img src="' . append_sid("profile.$phpEx?mode=confirm&amp;id=$confirm_id&amp;c=2") . '" alt="" title="" /><img src="' . append_sid("profile.$phpEx?mode=confirm&amp;id=$confirm_id&amp;c=3") . '" alt="" title="" /><img src="' . append_sid("profile.$phpEx?mode=confirm&amp;id=$confirm_id&amp;c=4") . '" alt="" title="" /><img src="' . append_sid("profile.$phpEx?mode=confirm&amp;id=$confirm_id&amp;c=5") . '" alt="" title="" /><img src="' . append_sid("profile.$phpEx?mode=confirm&amp;id=$confirm_id&amp;c=6") . '" alt="" title="" />';
+		$confirm_image = '<img src="' . append_sid("profile.$phpEx?mode=confirm&amp;id=$confirm_id") . '" alt="" title="" />';
 		$s_hidden_fields .= '<input type="hidden" name="confirm_id" value="' . $confirm_id . '" />';
 
 		$template->assign_block_vars('switch_confirm', array());
diff -ruN _currtarball/login.php phpBB2/login.php
--- _currtarball/login.php	2006-05-16 16:51:10.000000000 -0500
+++ phpBB2/login.php	2006-06-09 09:29:42.000000000 -0500
@@ -6,7 +6,7 @@
  *   copyright            : (C) 2001 The phpBB Group
  *   email                : support@phpbb.com
  *
- *   $Id: login.php,v 1.47.2.23 2006/01/13 20:10:02 grahamje Exp $
+ *   $Id: login.php,v 1.47.2.24 2006/04/22 20:28:42 grahamje Exp $
  *
  *
  ***************************************************************************/
@@ -118,23 +118,23 @@
 							WHERE user_id = ' . $row['user_id'];
 						$db->sql_query($sql);
 					}
-					
-					$redirect = ( !empty($HTTP_POST_VARS['redirect']) ) ? str_replace('&amp;', '&', htmlspecialchars($HTTP_POST_VARS['redirect'])) : '';
-					$redirect = str_replace('?', '&', $redirect);
+				}
 
-					if (strstr(urldecode($redirect), "\n") || strstr(urldecode($redirect), "\r"))
-					{
-						message_die(GENERAL_ERROR, 'Tried to redirect to potentially insecure url.');
-					}
+				$redirect = ( !empty($HTTP_POST_VARS['redirect']) ) ? str_replace('&amp;', '&', htmlspecialchars($HTTP_POST_VARS['redirect'])) : '';
+				$redirect = str_replace('?', '&', $redirect);
 
-					$template->assign_vars(array(
-						'META' => "<meta http-equiv=\"refresh\" content=\"3;url=login.$phpEx?redirect=$redirect\">")
-					);
+				if (strstr(urldecode($redirect), "\n") || strstr(urldecode($redirect), "\r"))
+				{
+					message_die(GENERAL_ERROR, 'Tried to redirect to potentially insecure url.');
+				}
 
-					$message = $lang['Error_login'] . '<br /><br />' . sprintf($lang['Click_return_login'], "<a href=\"login.$phpEx?redirect=$redirect\">", '</a>') . '<br /><br />' .  sprintf($lang['Click_return_index'], '<a href="' . append_sid("index.$phpEx") . '">', '</a>');
+				$template->assign_vars(array(
+					'META' => "<meta http-equiv=\"refresh\" content=\"3;url=login.$phpEx?redirect=$redirect\">")
+				);
 
-					message_die(GENERAL_MESSAGE, $message);
-				}
+				$message = $lang['Error_login'] . '<br /><br />' . sprintf($lang['Click_return_login'], "<a href=\"login.$phpEx?redirect=$redirect\">", '</a>') . '<br /><br />' .  sprintf($lang['Click_return_index'], '<a href="' . append_sid("index.$phpEx") . '">', '</a>');
+
+				message_die(GENERAL_MESSAGE, $message);
 			}
 		}
 		else
diff -ruN _currtarball/privmsg.php phpBB2/privmsg.php
--- _currtarball/privmsg.php	2006-05-16 16:51:11.000000000 -0500
+++ phpBB2/privmsg.php	2006-06-09 09:29:43.000000000 -0500
@@ -6,7 +6,7 @@
  *   copyright            : (C) 2001 The phpBB Group
  *   email                : support@phpbb.com
  *
- *   $Id: privmsg.php,v 1.96.2.48 2006/03/18 12:33:06 grahamje Exp $
+ *   $Id: privmsg.php,v 1.96.2.49 2006/04/10 21:08:15 grahamje Exp $
  *
  *
  ***************************************************************************/
@@ -1508,7 +1508,7 @@
 			}
 
 			$orig_word = $replacement_word = array();
-			obtain_word_list($orig_word, $replace_word);
+			obtain_word_list($orig_word, $replacement_word);
 
 			$privmsg_subject = ( ( !preg_match('/^Re:/', $privmsg['privmsgs_subject']) ) ? 'Re: ' : '' ) . $privmsg['privmsgs_subject'];
 			$privmsg_subject = preg_replace($orig_word, $replacement_word, $privmsg_subject);
diff -ruN _currtarball/profile.php phpBB2/profile.php
--- _currtarball/profile.php	2006-05-16 16:51:11.000000000 -0500
+++ phpBB2/profile.php	2006-06-09 09:29:43.000000000 -0500
@@ -6,7 +6,7 @@
  *   copyright            : (C) 2001 The phpBB Group
  *   email                : support@phpbb.com
  *
- *   $Id: profile.php,v 1.193.2.6 2006/02/26 17:34:50 grahamje Exp $
+ *   $Id: profile.php,v 1.193.2.7 2006/04/09 16:17:27 grahamje Exp $
  *
  *
  ***************************************************************************/
@@ -62,7 +62,7 @@
 {
 	$rand_str = dss_rand();
 
-	return ( $hash ) ? md5($rand_str) : substr($rand_str, 8);
+	return ( $hash ) ? md5($rand_str) : substr($rand_str, 0, 8);
 }
 //
 // End page specific functions
diff -ruN _currtarball/search.php phpBB2/search.php
--- _currtarball/search.php	2006-05-16 16:51:11.000000000 -0500
+++ phpBB2/search.php	2006-06-09 09:29:43.000000000 -0500
@@ -6,7 +6,7 @@
  *   copyright            : (C) 2001 The phpBB Group
  *   email                : support@phpbb.com
  *
- *   $Id: search.php,v 1.72.2.19 2006/02/05 15:59:48 grahamje Exp $
+ *   $Id: search.php,v 1.72.2.20 2006/05/20 14:01:48 grahamje Exp $
  *
  *
  ***************************************************************************/
@@ -218,7 +218,7 @@
 			{
 				$search_author = str_replace('*', '%', trim($search_author));
 
-				if( ( strpos($search_author, '%') !== false ) && ( strlen(str_replace('%', '', $search_author)) < 3 ) )
+				if( ( strpos($search_author, '%') !== false ) && ( strlen(str_replace('%', '', $search_author)) < $board_config['search_min_chars'] ) )
 				{
 					$search_author = '';
 				}
@@ -290,7 +290,7 @@
 
 			for($i = 0; $i < count($split_search); $i++)
 			{
-				if (preg_match('#^[\*%]+$#', trim($split_search[$i])) || preg_match('#^[^\*]{1,2}$#', str_replace(array('*', '%'), '', trim($split_search[$i]))))
+				if ( strlen(str_replace(array('*', '%'), '', trim($split_search[$i]))) < $board_config['search_min_chars'] )
 				{
 					$split_search[$i] = '';
 					continue;
@@ -441,7 +441,7 @@
 		{
 			$search_author = str_replace('*', '%', trim($search_author));
 
-			if( ( strpos($search_author, '%') !== false ) && ( strlen(str_replace('%', '', $search_author)) < 3 ) )
+			if( ( strpos($search_author, '%') !== false ) && ( strlen(str_replace('%', '', $search_author)) < $board_config['search_min_chars'] ) )
 			{
 				$search_author = '';
 			}
diff -ruN _currtarball/viewtopic.php phpBB2/viewtopic.php
--- _currtarball/viewtopic.php	2006-05-16 16:44:25.000000000 -0500
+++ phpBB2/viewtopic.php	2006-06-09 09:29:43.000000000 -0500
@@ -6,7 +6,7 @@
  *   copyright            : (C) 2001 The phpBB Group
  *   email                : support@phpbb.com
  *
- *   $Id: viewtopic.php,v 1.186.2.45 2005/10/05 17:42:04 grahamje Exp $
+ *   $Id: viewtopic.php,v 1.186.2.46 2006/04/21 19:07:46 grahamje Exp $
  *
  *
  ***************************************************************************/
@@ -1103,9 +1103,8 @@
 	//
 	if ($highlight_match)
 	{
-		// This was shamelessly 'borrowed' from volker at multiartstudio dot de
-		// via php.net's annotated manual
-		$message = str_replace('\"', '"', substr(@preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "@preg_replace('#\b(" . str_replace('\\', '\\\\', addslashes($highlight_match)) . ")\b#i', '<span style=\"color:#" . $theme['fontcolor3'] . "\"><b>\\\\1</b></span>', '\\0')", '>' . $message . '<'), 1, -1));
+		// This has been back-ported from 3.0 CVS
+		$message = preg_replace('#(?!<.*)(?<!\w)(' . $highlight_match . ')(?!\w|[^<>]*>)#i', '<b style="color:#'.$theme['fontcolor3'].'">\1</b>', $message);
 	}
 
 	//
