These are the code changes introduced between phpBB 2.0.13 and phpBB 2.0.14. If you have installed many hacks on a forum, but wish to update it, these may help you. It is often easier to apply code changes such as these instead of replacing and rehacking your current files.
These code changes use the following instruction labels:
filename - The name of a file to be edited. Equivalent to an OPEN action in a hack or modification.
FIND - This indicates lines of code you should locate. Changes will be made in reference to this code.
REPLACE WITH - This code should completely replace the code in the preceding FIND instruction.
AFTER, ADD - The code in this instruction should be added on a new line after the last line of code in the preceding FIND instruction.
BEFORE, ADD - The code in this instruction should be added on a new line before the first line of code in the preceding FIND instruction.
Once you have completed the code changes, create an install/ directory in your forum's root directory, and upload the update_to_latest.php file that comes in any phpBB 2.0.14 download to the install/ directory. Run update_to_latest.php by opening it via your web browser, just as you would a normal forum page. Afterward, delete the file and the install/ directory so that your forum is accessible again.
Now, onward to the file changes!
modcp.php
FIND
Code:
$forum_topics = ( $topic_row['forum_topics'] == 0 ) ? 1 : $topic_row['forum_topics'];
$forum_id = $topic_row['forum_id'];
$forum_name = $topic_row['forum_name'];
BEFORE, ADD
Code:
if (!$topic_row)
{
message_die(GENERAL_MESSAGE, 'Topic_post_not_exist');
}
FIND
Code:
$forum_topics = ( $topic_row['forum_topics'] == 0 ) ? 1 : $topic_row['forum_topics'];
$forum_name = $topic_row['forum_name'];
BEFORE, ADD
Code:
if (!$topic_row)
{
message_die(GENERAL_MESSAGE, 'Topic_post_not_exist');
}
privmsg.php
FIND
Code:
if ( !$board_config['allow_html'] )
{
if ( $user_sig != '' && $privmsg['privmsgs_enable_sig'] && $userdata['user_allowhtml'] )
REPLACE WITH
Code:
if ( !$board_config['allow_html'] || !$userdata['user_allowhtml'])
{
if ( $user_sig != '')
FIND
Code:
if ( !$html_on )
{
if ( $user_sig != '' || !$userdata['user_allowhtml'] )
REPLACE WITH
Code:
if ( !$html_on || !$board_config['allow_html'] || !$userdata['user_allowhtml'] )
{
if ( $user_sig != '' )
search.php
FIND
Code:
$search_author = str_replace('*', '%', trim($search_author));
BEFORE, ADD
Code:
if (preg_match('#^[\*%]+$#', trim($search_author)) || preg_match('#^[^\*]{1,2}$#', str_replace(array('*', '%'), '', trim($search_author))))
{
$search_author = '';
}
FIND
Code:
for($i = 0; $i < count($split_search); $i++)
{
AFTER, ADD
Code:
if (preg_match('#^[\*%]+$#', trim($split_search[$i])) || preg_match('#^[^\*]{1,2}$#', str_replace(array('*', '%'), '', trim($split_search[$i]))))
{
$split_search[$i] = '';
continue;
}
FIND
Code:
if ( $search_author != '' )
{
AFTER, ADD
Code:
if (preg_match('#^[\*%]+$#', trim($search_author)) || preg_match('#^[^\*]{1,2}$#', str_replace(array('*', '%'), '', trim($search_author))))
{
$search_author = '';
}
viewtopic.php
FIND
Code:
if ( !$board_config['allow_html'] )
{
if ( $user_sig != '' && $userdata['user_allowhtml'] )
REPLACE WITH
Code:
if ( !$board_config['allow_html'] || !$userdata['user_allowhtml'])
{
if ( $user_sig != '' )
FIND
Code:
$user_sig = str_replace('\"', '"', substr(preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "preg_replace(\$orig_word, \$replacement_word, '\\0')", '>' . $user_sig . '<'), 1, -1));
REPLACE WITH
Code:
$user_sig = str_replace('\"', '"', substr(@preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "@preg_replace(\$orig_word, \$replacement_word, '\\0')", '>' . $user_sig . '<'), 1, -1));
FIND
Code:
$message = str_replace('\"', '"', substr(preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "preg_replace(\$orig_word, \$replacement_word, '\\0')", '>' . $message . '<'), 1, -1));
REPLACE WITH
Code:
$message = str_replace('\"', '"', substr(@preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "@preg_replace(\$orig_word, \$replacement_word, '\\0')", '>' . $message . '<'), 1, -1));
admin/admin_styles.php
FIND
Code:
include($phpbb_root_path. "templates/" . $install_to . "/theme_info.cfg");
REPLACE WITH
Code:
include($phpbb_root_path. "templates/" . basename($install_to) . "/theme_info.cfg");
FIND
Code:
$fp = @fopen($phpbb_root_path . 'templates/' . $template_name . '/theme_info.cfg', 'w');
REPLACE WITH
Code:
$fp = @fopen($phpbb_root_path . 'templates/' . basename($template_name) . '/theme_info.cfg', 'w');
db/postgres7.php
FIND
Code:
$query = preg_replace("/LIMIT ([0-9]+),([ 0-9]+)/", "LIMIT \\2 OFFSET \\1", $query);
AFTER, ADD
Code:
$query = preg_replace('#(.*WHERE.*)(username|user_email|ban_email) = \'(.*)\'#ise', "\"\\1LOWER(\\2) = '\" . strtolower('\\3') . \"'\"", $query);
includes/page_header.php
FIND
Code:
$useragent = (isset($_SERVER["HTTP_USER_AGENT"]) ) ? $_SERVER["HTTP_USER_AGENT"] : $HTTP_USER_AGENT;
REPLACE WITH
Code:
$useragent = (isset($HTTP_SERVER_VARS['HTTP_USER_AGENT'])) ? $HTTP_SERVER_VARS['HTTP_USER_AGENT'] : getenv('HTTP_USER_AGENT');
FIND
Code:
if (!empty($_SERVER['SERVER_SOFTWARE']) && strstr($_SERVER['SERVER_SOFTWARE'], 'Apache/2'))
REPLACE WITH
Code:
if (!empty($HTTP_SERVER_VARS['SERVER_SOFTWARE']) && strstr($HTTP_SERVER_VARS['SERVER_SOFTWARE'], 'Apache/2'))
includes/sessions.php
FIND
Code:
$last_visit = 0;
$current_time = time();
$expiry_time = $current_time - $board_config['session_length'];
BEFORE, ADD
Code:
$page_id = (int) $page_id;
FIND
Code:
// No match; don't login, set as anonymous user
$login = 0;
$enable_autologin = 0;
$user_id = $userdata['user_id'] = ANONYMOUS;
AFTER, ADD
Code:
$sql = 'SELECT * FROM ' . USERS_TABLE . ' WHERE user_id = ' . ANONYMOUS;
$result = $db->sql_query($sql);
$userdata = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
FIND
Code:
// Autologin is not set. Don't login, set as anonymous user
$login = 0;
$enable_autologin = 0;
$user_id = $userdata['user_id'] = ANONYMOUS;
AFTER, ADD
Code:
$sql = 'SELECT * FROM ' . USERS_TABLE . ' WHERE user_id = ' . ANONYMOUS;
$result = $db->sql_query($sql);
$userdata = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
FIND
Code:
{
$session_id = '';
}
//
// Does a session exist?
REPLACE WITH
Code:
{
$session_id = '';
}
$thispage_id = (int) $thispage_id;
//
// Does a session exist?
templates/subSilver/login_body.tpl
FIND
Code:
<input type="text" name="username" size="25" maxlength="40" value="{USERNAME}" />
REPLACE WITH
Code:
<input type="text" class="post" name="username" size="25" maxlength="40" value="{USERNAME}" />
FIND
Code:
<input type="password" name="password" size="25" maxlength="32" />
REPLACE WITH
Code:
<input type="password" class="post" name="password" size="25" maxlength="32" />