#################################################################
## MOD Title: phpBB 2.0.17 to phpBB 2.0.18 Code Changes
## MOD Author: markus_petrux < N/A > (Markus) N/A
## MOD Description: These are the Changes from phpBB 2.0.17 to phpBB 2.0.18 summed up into a little
## Mod. This might be very helpful if you want to update your Board and have installed a bunch
## of Mods. Then it's normally easier to apply the Code Changes than to install all Mods again.
##
## MOD Version: 1.0.1
##
## Installation Level: Advanced
## Installation Time: 2 Hours
## Files To Edit:
## modules/Forums/common.php
## modules/Forums/groupcp.php
## modules/Forums/index.php
## modules/Forums/login.php
## modules/Forums/memberlist.php
## modules/Forums/modcp.php
## modules/Forums/posting.php
## modules/Forums/privmsg.php
## modules/Forums/search.php
## modules/Forums/viewtopic.php
## modules/Forums/admin/admin_board.php
## modules/Forums/admin/admin_disallow.php
## modules/Forums/admin/admin_smilies.php
## modules/Forums/admin/admin_styles.php
## modules/Forums/admin/admin_ug_auth.php
## modules/Forums/admin/admin_user_ban.php
## modules/Forums/admin/admin_users.php
## modules/Forums/admin/index.php
## modules/Forums/admin/page_footer_admin.php
## db/mysql.php
## db/mysql4.php
## includes/bbcode.php
## includes/constants.php
## includes/db.php
## includes/emailer.php
## includes/functions.php
## includes/functions_admin.php
## includes/functions_post.php
## includes/functions_search.php
## includes/functions_validate.php
## includes/page_header.php
## includes/page_tail.php
## includes/sessions.php
## includes/smtp.php
## includes/usercp_activate.php
## includes/usercp_avatar.php
## includes/usercp_register.php
## includes/usercp_sendpasswd.php
## includes/usercp_viewprofile.php
## modules/Forums/language/lang_english/lang_admin.php
## modules/Forums/language/lang_english/lang_main.php
## modules/Forums/language/lang_english/email/topic_notify.tpl
## modules/Forums/templates/subSilver/bbcode.tpl
## modules/Forums/templates/subSilver/groupcp_info_body.tpl
## modules/Forums/templates/subSilver/index_body.tpl
## modules/Forums/templates/subSilver/login_body.tpl
## modules/Forums/templates/subSilver/overall_header.tpl
## modules/Forums/templates/subSilver/profile_add_body.tpl
## modules/Forums/templates/subSilver/search_body.tpl
## modules/Forums/templates/subSilver/search_results_posts.tpl
## modules/Forums/templates/subSilver/subSilver.cfg
## modules/Forums/templates/subSilver/admin/board_config_body.tpl
## modules/Forums/templates/subSilver/admin/forum_admin_body.tpl
## modules/Forums/templates/subSilver/admin/index_frameset.tpl
## modules/Forums/templates/subSilver/admin/page_header.tpl
## modules/Forums/templates/subSilver/admin/styles_addnew_body.tpl
## modules/Forums/templates/subSilver/admin/styles_edit_body.tpl
## modules/Forums/templates/subSilver/admin/styles_list_body.tpl
## modules/Forums/templates/subSilver/admin/user_edit_body.tpl
##
## Included Files: install/update_to_latest.php
## License: http://opensource.org/licenses/gpl-license.php GNU General Public License v2
##############################################################
## For security purposes, please check: http://www.phpbb.com/mods/
## for the latest version of this MOD. Although MODs are checked
## before being allowed in the MODs Database there is no guarantee
## that there are no security problems within the MOD. No support
## will be given for MODs not found within the MODs Database which
## can be found at http://www.phpbb.com/mods/
##############################################################
## Author Notes:
##
## Since this MOD is somehow complex, it is recommended to proceed as follows:
##
## 1) Disable the board from the ACP (General Admin, Configuration).
##
## 2) Make backups of your files and Database.
##
## 3) Upload and execute the file install/update_to_latest.php.
##
## 4) Remove the file install/update_to_latest.php from your webspace.
##
## 4) Install the MOD.
##
## 5) Enable the board from the ACP, back online.
##
##
## It is recommended to use EasyMOD to install this MOD ;-)
##
## Please, be sure to understand the MOD Templace actions.
## http://www.phpbb.com/kb/article.php?article_id=39
##
##
##############################################################
## MOD History:
##
## 2005-10-31 - Version 1.0.1
## - adjusted for the repackage
##
## 2005-10-30 - Version 1.0.0
##
##############################################################
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD
##############################################################
#
#-----[ DIY INSTRUCTIONS ]---------------------------------------------
#
BEFORE installing this MOD, you have to upload the file
install/update_to_latest.php, execute it and then delete it
from your webspace.
It will execute the following SQL statements:
CREATE TABLE phpbb_sessions_keys (
key_id varchar(32) DEFAULT '0' NOT NULL,
user_id mediumint(8) DEFAULT '0' NOT NULL,
last_ip varchar(8) DEFAULT '0' NOT NULL,
last_login int(11) DEFAULT '0' NOT NULL,
PRIMARY KEY (key_id, user_id),
KEY last_login (last_login)
);
INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_autologin','1');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_autologin_time','0');
UPDATE phpbb_users SET user_active = 0 WHERE user_id = -1;
UPDATE phpbb_config SET config_value = '.0.18' WHERE config_name = 'version';
#
#-----[ OPEN ]---------------------------------------------
#
modules/Forums/common.php
#
#-----[ FIND ]---------------------------------------------
#
// The following code (unsetting globals) was contributed by Matt Kavanagh
#
#-----[ REPLACE WITH ]---------------------------------------------
#
// The following code (unsetting globals)
// Thanks to Matt Kavanagh and Stefan Esser for providing feedback as well as patch files
// _SESSION is the only superglobal which is conditionally set
if (isset($_SESSION))
{
$HTTP_SESSION_VARS = $_SESSION;
}
}
// Protect against GLOBALS tricks
if (isset($HTTP_POST_VARS['GLOBALS']) || isset($HTTP_POST_FILES['GLOBALS']) || isset($HTTP_GET_VARS['GLOBALS']) || isset($HTTP_COOKIE_VARS['GLOBALS']))
{
die("Hacking attempt");
}
// Protect against HTTP_SESSION_VARS tricks
if (isset($HTTP_SESSION_VARS) && !is_array($HTTP_SESSION_VARS))
{
die("Hacking attempt");
}
#
#-----[ FIND ]---------------------------------------------
#
if (@phpversion() < '4.0.0')
{
// PHP3 path; in PHP3, globals are _always_ registered
// We 'flip' the array of variables to test like this so that
// we can validate later with isset($test[$var]) (no in_array())
$test = array('HTTP_GET_VARS' => NULL, 'HTTP_POST_VARS' => NULL, 'HTTP_COOKIE_VARS' => NULL, 'HTTP_SERVER_VARS' => NULL, 'HTTP_ENV_VARS' => NULL, 'HTTP_POST_FILES' => NULL, 'phpEx' => NULL, 'phpbb_root_path' => NULL);
// Loop through each input array
@reset($test);
while (list($input,) = @each($test))
{
while (list($var,) = @each($$input))
{
// Validate the variable to be unset
if (!isset($test[$var]) && $var != 'test' && $var != 'input')
{
unset($$var);
}
}
}
}
else if (@ini_get('register_globals') == '1' || strtolower(@ini_get('register_globals')) == 'on')
{
#
#-----[ REPLACE WITH ]---------------------------------------------
#
if (@ini_get('register_globals') == '1' || strtolower(@ini_get('register_globals')) == 'on')
{
// Merge all into one extremely huge array; unset
// this later
$input = array_merge($HTTP_GET_VARS, $HTTP_POST_VARS, $HTTP_COOKIE_VARS, $HTTP_SERVER_VARS, $HTTP_SESSION_VARS, $HTTP_ENV_VARS, $HTTP_POST_FILES);
while (list($var,) = @each($input))
{
if (!in_array($var, $not_unset))
{
unset($$var);
}
}
unset($input);
}
#
#-----[ REPLACE WITH ]---------------------------------------------
#
if (!isset($HTTP_SESSION_VARS) || !is_array($HTTP_SESSION_VARS))
{
$HTTP_SESSION_VARS = array();
}
// Merge all into one extremely huge array; unset
// this later
$input = array_merge($HTTP_GET_VARS, $HTTP_POST_VARS, $HTTP_COOKIE_VARS, $HTTP_SERVER_VARS, $HTTP_SESSION_VARS, $HTTP_ENV_VARS, $HTTP_POST_FILES);
// We do not need this any longer, unset for safety purposes
unset($dbpasswd);
#
#-----[ OPEN ]---------------------------------------------
#
modules/Forums/groupcp.php
#
#-----[ FIND ]---------------------------------------------
# NOTE --- This is a partial match, the whole line on a fresh installation looks like this:
# $temp_url = append_sid("search.$phpEx?search_author=" . urlencode($username) . "&showresults=posts");
#
$temp_url = append_sid("search
#
#-----[ IN-LINE REPLACE WITH ]---------------------------------------------
#
. sprintf($lang['Search_user_posts'], $row['username'])
#
#-----[ FIND ]---------------------------------------------
# NOTE --- This is a partial match, the whole line on a fresh installation looks like this:
# $search = '<a href="' . $temp_url . '">' . $lang['Search_user_posts'] . '</a>';
#
$search = '<a href="'
#
#-----[ OPEN ]---------------------------------------------
#
modules/Forums/index.php
#
#-----[ FIND ]---------------------------------------------
# NOTE --- There's no explicit action to take place here. This FIND is just aimed to point you to the right place the next action.
#
//
// Obtain a list of topic ids which contain
// posts made since user last visited
//
#
#-----[ FIND ]---------------------------------------------
#
if ( $userdata['session_logged_in'] )
{
#
#-----[ REPLACE WITH ]---------------------------------------------
#
if ($userdata['session_logged_in'])
{
// 60 days limit
if ($userdata['user_lastvisit'] < (time() - 5184000))
{
$userdata['user_lastvisit'] = time() - 5184000;
}
#
#-----[ OPEN ]---------------------------------------------
#
login.php
#
#-----[ REPLACE WITH ]---------------------------------------------
#
make_jumpbox('viewforum.'.$phpEx);
#
#-----[ OPEN ]---------------------------------------------
#
modules/Members_List/memberlist.php
#
#-----[ FIND ]---------------------------------------------
# NOTE --- This is a partial match, the whole line on a fresh installation looks like this:
# $mode_types = array('joindate', 'username', 'location', 'posts', 'email', 'website', 'topten');
#
$mode_types = array('joindate',
#
#-----[ IN-LINE REPLACE WITH ]---------------------------------------------
#
. sprintf($lang['Search_user_posts'], $username_from)
#
#-----[ FIND ]---------------------------------------------
# NOTE --- This is a partial match, the whole line on a fresh installation looks like this:
# $search = '<a href="' . $temp_url . '">' . $lang['Search_user_posts'] . '</a>';
#
$search = '<a href="'
#
#-----[ IN-LINE REPLACE WITH ]---------------------------------------------
#
(!$post_id)
#
#-----[ FIND ]---------------------------------------------
# NOTE --- This is a partial match, the whole line on a fresh installation looks like this:
# $join_sql = ( empty($post_id) ) ? "t.topic_id = $topic_id" : "p.post_id = $post_id AND t.topic_id = p.topic_id AND p2.topic_id = p.topic_id AND p2.post_id <= $post_id";
#
$join_sql = ( empty($post_id) )
#
#-----[ IN-LINE REPLACE WITH ]---------------------------------------------
#
(!$post_id)
#
#-----[ FIND ]---------------------------------------------
# NOTE --- This is a partial match, the whole line on a fresh installation looks like this:
# $count_sql = ( empty($post_id) ) ? '' : ", COUNT(p2.post_id) AS prev_posts";
#
$count_sql = ( empty($post_id) )
#
#-----[ OPEN ]---------------------------------------------
#
modules/Forums/admin/admin_user_ban.php
#
#-----[ FIND ]---------------------------------------------
# NOTE --- This is a partial match, the whole line on a fresh installation looks like this:
# if (preg_match('#^(([a-z0-9&.-_+])|(\*))+@[a-z0-9\-]+\.([a-z0-9\-]+\.)*?[a-z]+$#is', trim($email_list_temp[$i])))
#
'#^(([a-z0-9&.-_+])|(\*))+@[a-z0-9\-]+\.([a-z0-9\-]+\.)*?[a-z]+$#is'
#
#-----[ REPLACE WITH ]---------------------------------------------
#
$match = array_pop($stack);
#
#-----[ FIND ]---------------------------------------------
#
/**
* This function does exactly what the PHP4 function array_push() does
* however, to keep phpBB compatable with PHP 3 we had to come up with our own
* method of doing it.
*/
#
#-----[ REPLACE WITH ]---------------------------------------------
#
/**
* This function does exactly what the PHP4 function array_push() does
* however, to keep phpBB compatable with PHP 3 we had to come up with our own
* method of doing it.
* This function was deprecated in phpBB 2.0.18
*/
#
#-----[ FIND ]---------------------------------------------
#
/**
* This function does exactly what the PHP4 function array_pop() does
* however, to keep phpBB compatable with PHP 3 we had to come up with our own
* method of doing it.
*/
#
#-----[ REPLACE WITH ]---------------------------------------------
#
/**
* This function does exactly what the PHP4 function array_pop() does
* however, to keep phpBB compatable with PHP 3 we had to come up with our own
* method of doing it.
* This function was deprecated in phpBB 2.0.18
*/
#
#-----[ REPLACE WITH ]---------------------------------------------
#
$username = phpbb_rtrim($username, "\\");
#
#-----[ FIND ]---------------------------------------------
#
// added at phpBB 2.0.12 to fix a bug in PHP 4.3.10 (only supporting charlist in php >= 4.1.0)
function phpbb_rtrim($str, $charlist = false)
#
#-----[ BEFORE, ADD ]---------------------------------------------
#
/**
* This function is a wrapper for ltrim, as charlist is only supported in php >= 4.1.0
* Added in phpBB 2.0.18
*/
function phpbb_ltrim($str, $charlist = false)
{
if ($charlist === false)
{
return ltrim($str);
}
#
#-----[ REPLACE WITH ]---------------------------------------------
#
if ($row['total_posts'])
{
// Correct the details of this topic
$sql = 'UPDATE ' . TOPICS_TABLE . '
SET topic_replies = ' . ($row['total_posts'] - 1) . ', topic_first_post_id = ' . $row['first_post'] . ', topic_last_post_id = ' . $row['last_post'] . "
WHERE topic_id = $id";
if (!$db->sql_query($sql))
{
message_die(GENERAL_ERROR, 'Could not update topic', '', __LINE__, __FILE__, $sql);
}
}
else
{
// There are no replies to this topic
// Check if it is a move stub
$sql = 'SELECT topic_moved_id
FROM ' . TOPICS_TABLE . "
WHERE topic_id = $id";
if (!($result = $db->sql_query($sql)))
{
message_die(GENERAL_ERROR, 'Could not get topic ID', '', __LINE__, __FILE__, $sql);
}
if ($row = $db->sql_fetchrow($result))
{
if (!$row['topic_moved_id'])
{
$sql = 'DELETE FROM ' . TOPICS_TABLE . " WHERE topic_id = $id";
if (!$db->sql_query($sql))
{
message_die(GENERAL_ERROR, 'Could not remove topic', '', __LINE__, __FILE__, $sql);
}
}
}
$db->sql_freeresult($result);
}
#
#-----[ OPEN ]---------------------------------------------
#
includes/functions_post.php
#
#-----[ FIND ]---------------------------------------------
# NOTE --- This is a partial match, the whole line on a fresh installation looks like this:
# function submit_post($mode, &$post_data, &$message, &$meta, &$forum_id, &$topic_id, &$post_id, &$poll_id, &$topic_type, &$bbcode_on, &$html_on, &$smilies_on, &$attach_sig, &$bbcode_uid, &$post_username, &$post_subject, &$post_message, &$poll_title, &$poll_options, &$poll_length)
#
function submit_post(
//
// Try and pull the last time stored in a cookie, if it exists
//
$sql = "SELECT *
FROM " . USERS_TABLE . "
WHERE user_id = $user_id";
if ( !($result = $db->sql_query($sql)) )
{
message_die(CRITICAL_ERROR, 'Could not obtain lastvisit data from user table', '', __LINE__, __FILE__, $sql);
}
$userdata = $db->sql_fetchrow($result);
if ( $user_id != ANONYMOUS )
{
$auto_login_key = $userdata['user_password'];
if ( $auto_create )
{
if ( isset($sessiondata['autologinid']) && $userdata['user_active'] )
{
// We have to login automagically
if( $sessiondata['autologinid'] === $auto_login_key )
{
// autologinid matches password
$login = 1;
$enable_autologin = 1;
}
else
{
// No match; don't login, set as anonymous user
$login = 0;
$enable_autologin = 0;
$user_id = $userdata['user_id'] = ANONYMOUS;
$sql = 'SELECT * FROM ' . USERS_TABLE . ' WHERE user_id = ' . ANONYMOUS;
$result = $db->sql_query($sql);
$userdata = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
}
}
else
{
// Autologin is not set. Don't login, set as anonymous user
$login = 0;
$enable_autologin = 0;
$user_id = $userdata['user_id'] = ANONYMOUS;
#
#-----[ REPLACE WITH ]---------------------------------------------
#
$current_time = time();
//
// Are auto-logins allowed?
// If allow_autologin is not set or is true then they are
// (same behaviour as old 2.0.x session code)
//
if (isset($board_config['allow_autologin']) && !$board_config['allow_autologin'])
{
$enable_autologin = $sessiondata['autologinid'] = false;
}
//
// First off attempt to join with the autologin value if we have one
// If not, just use the user_id value
//
$userdata = array();
if ($user_id != ANONYMOUS)
{
if (isset($sessiondata['autologinid']) && (string) $sessiondata['autologinid'] != '' && $user_id)
{
$sql = 'SELECT u.*
FROM ' . USERS_TABLE . ' u, ' . SESSIONS_KEYS_TABLE . ' k
WHERE u.user_id = ' . (int) $user_id . "
AND u.user_active = 1
AND k.user_id = u.user_id
AND k.key_id = '" . md5($sessiondata['autologinid']) . "'";
if (!($result = $db->sql_query($sql)))
{
message_die(CRITICAL_ERROR, 'Error doing DB query userdata row fetch', '', __LINE__, __FILE__, $sql);
}
//
// At this point either $userdata should be populated or
// one of the below is true
// * Key didn't match one in the DB
// * User does not exist
// * User is inactive
//
if (!sizeof($userdata) || !is_array($userdata) || !$userdata)
{
$sessiondata['autologinid'] = '';
$sessiondata['userid'] = $user_id = ANONYMOUS;
$enable_autologin = $login = 0;
$sql = 'SELECT *
FROM ' . USERS_TABLE . '
WHERE user_id = ' . (int) $user_id;
if (!($result = $db->sql_query($sql)))
{
message_die(CRITICAL_ERROR, 'Error doing DB query userdata row fetch', '', __LINE__, __FILE__, $sql);
}
$sql = "DELETE FROM " . SESSIONS_TABLE . "
WHERE session_time < $expiry_time
AND session_id <> '$session_id'";
if ( !$db->sql_query($sql) )
{
message_die(CRITICAL_ERROR, 'Error clearing sessions table', '', __LINE__, __FILE__, $sql);
}
#
#-----[ REPLACE WITH ]---------------------------------------------
#
session_clean($userdata['session_id']);
#
#-----[ FIND ]---------------------------------------------
#
//
// session_end closes out a session
// deleting the corresponding entry
// in the sessions table
//
function session_end($session_id, $user_id)
{
global $db, $lang, $board_config;
global $HTTP_COOKIE_VARS, $HTTP_GET_VARS, $SID;