Soniks
10.06.2006, 00:45
Инструкция по ручному обновлению встроенного форума phpbb в php-nuke с версии 2.0.20 до версии 2.0.21
Открываем modules/Forums/admin/admin_ranks.php
Находим (34):
//
$phpbb_root_path = "./../";
require($phpbb_root_path . 'extension.inc');
Ниже добавляем:
$cancel = ( isset($HTTP_POST_VARS['cancel']) ) ? true : false;
$no_page_header = $cancel;
Находим (39):
require('./pagestart.' . $phpEx);
Ниже добавляем:
if ($cancel)
{
redirect('admin/' . append_sid("admin_ranks.$phpEx", true));
}
Открываем modules/Forums/admin/admin_smilies.php
Находим (50):
$phpbb_root_path = "./../";
require($phpbb_root_path . 'extension.inc');
Ниже добавляем:
$cancel = ( isset($HTTP_POST_VARS['cancel']) ) ? true : false;
$no_page_header = $cancel;
Находим (54):
require('./pagestart.' . $phpEx);
Ниже добавляем:
if ($cancel)
{
redirect('admin/' . append_sid("admin_smilies.$phpEx", true));
}
Открываем modules/Forums/admin/admin_styles.php
Находим (840):
$template->set_filenames(array(
"confirm" => "confirm_body.tpl")
);
Заменяем на:
$template->set_filenames(array(
"confirm" => "admin/confirm_body.tpl")
);
Открываем modules/Forums/admin/admin_words.php
Находим (33):
$phpbb_root_path = "./../";
require($phpbb_root_path . 'extension.inc');
Ниже добавляем:
$cancel = ( isset($HTTP_POST_VARS['cancel']) ) ? true : false;
$no_page_header = $cancel;
Находим (37):
require('./pagestart.' . $phpEx);
Ниже добавляем:
if ($cancel)
{
redirect('admin/' . append_sid("admin_words.$phpEx", true));
}
Открываем includes/functions.php
Находим (176):
return substr($val, 16);
Заменяем на:
return substr($val, 4, 16);
Находим (316):
global $board_config, $theme, $images, $template, $lang, $phpEx, $phpbb_root_path, $nav_links;
Заменяем на:
global $board_config, $theme, $images, $template, $lang, $phpEx, $phpbb_root_path, $nav_links, $db;
Находим (322):
$board_config['default_lang'] = $userdata['user_lang'];
Заменяем на:
$default_lang = phpbb_ltrim(basename(phpbb_rtrim($userdata['user_lang'])), "'");
Находим (336):
if ( !file_exists(@phpbb_realpath($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_main.'.$phpEx)) )
{
$board_config['default_lang'] = 'english';
}
Заменяем на:
else
{
$default_lang = phpbb_ltrim(basename(phpbb_rtrim($board_config['default_lang'])), "'");
}
if ( !file_exists(@phpbb_realpath($phpbb_root_path . 'language/lang_' . $default_lang . '/lang_main.'.$phpEx)) )
{
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;
Находим (459):
$sql = "SELECT *
FROM " . THEMES_TABLE . "
WHERE themes_id = '$style'";
Заменяем на:
$sql = 'SELECT *
FROM ' . THEMES_TABLE . '
WHERE themes_id = ' . (int) $style;
Открываем includes/functions_post.php
Находим (67):
$message .= htmlspecialchars($part) . clean_html($tag);
}
$message = addslashes($message);
Заменяем на:
$message .= preg_replace($html_entities_match, $html_entities_replace, $part) . clean_html($tag);
}
$message = addslashes($message);
$message = str_replace('"', '\"', $message);
Находим (420):
$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 ($mode != 'poll_delete')
{
$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);
}
}
Открываем includes/sessions.php
Находим (368):
setcookie($cookiename . '_data', serialize($sessiondata), $current_time + 31536000, $cookiepath, $cookiedomain, $cookiesecure);
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'];
}
Находим (505):
function session_reset_keys($user_id, $user_ip)
{
global $db, $userdata;
Заменяем на:
function session_reset_keys($user_id, $user_ip)
{
global $db, $userdata, $board_config;
Находим (544):
// And now rebuild the cookie
$sessiondata['userid'] = $user_id;
$sessiondata['autologinid'] = $autologin_id;
Заменяем на:
// And now rebuild the cookie
$sessiondata['userid'] = $user_id;
$sessiondata['autologinid'] = $auto_login_key;
Открываем modules/Forums/admin/admin_ranks.php
Находим (34):
//
$phpbb_root_path = "./../";
require($phpbb_root_path . 'extension.inc');
Ниже добавляем:
$cancel = ( isset($HTTP_POST_VARS['cancel']) ) ? true : false;
$no_page_header = $cancel;
Находим (39):
require('./pagestart.' . $phpEx);
Ниже добавляем:
if ($cancel)
{
redirect('admin/' . append_sid("admin_ranks.$phpEx", true));
}
Открываем modules/Forums/admin/admin_smilies.php
Находим (50):
$phpbb_root_path = "./../";
require($phpbb_root_path . 'extension.inc');
Ниже добавляем:
$cancel = ( isset($HTTP_POST_VARS['cancel']) ) ? true : false;
$no_page_header = $cancel;
Находим (54):
require('./pagestart.' . $phpEx);
Ниже добавляем:
if ($cancel)
{
redirect('admin/' . append_sid("admin_smilies.$phpEx", true));
}
Открываем modules/Forums/admin/admin_styles.php
Находим (840):
$template->set_filenames(array(
"confirm" => "confirm_body.tpl")
);
Заменяем на:
$template->set_filenames(array(
"confirm" => "admin/confirm_body.tpl")
);
Открываем modules/Forums/admin/admin_words.php
Находим (33):
$phpbb_root_path = "./../";
require($phpbb_root_path . 'extension.inc');
Ниже добавляем:
$cancel = ( isset($HTTP_POST_VARS['cancel']) ) ? true : false;
$no_page_header = $cancel;
Находим (37):
require('./pagestart.' . $phpEx);
Ниже добавляем:
if ($cancel)
{
redirect('admin/' . append_sid("admin_words.$phpEx", true));
}
Открываем includes/functions.php
Находим (176):
return substr($val, 16);
Заменяем на:
return substr($val, 4, 16);
Находим (316):
global $board_config, $theme, $images, $template, $lang, $phpEx, $phpbb_root_path, $nav_links;
Заменяем на:
global $board_config, $theme, $images, $template, $lang, $phpEx, $phpbb_root_path, $nav_links, $db;
Находим (322):
$board_config['default_lang'] = $userdata['user_lang'];
Заменяем на:
$default_lang = phpbb_ltrim(basename(phpbb_rtrim($userdata['user_lang'])), "'");
Находим (336):
if ( !file_exists(@phpbb_realpath($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_main.'.$phpEx)) )
{
$board_config['default_lang'] = 'english';
}
Заменяем на:
else
{
$default_lang = phpbb_ltrim(basename(phpbb_rtrim($board_config['default_lang'])), "'");
}
if ( !file_exists(@phpbb_realpath($phpbb_root_path . 'language/lang_' . $default_lang . '/lang_main.'.$phpEx)) )
{
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;
Находим (459):
$sql = "SELECT *
FROM " . THEMES_TABLE . "
WHERE themes_id = '$style'";
Заменяем на:
$sql = 'SELECT *
FROM ' . THEMES_TABLE . '
WHERE themes_id = ' . (int) $style;
Открываем includes/functions_post.php
Находим (67):
$message .= htmlspecialchars($part) . clean_html($tag);
}
$message = addslashes($message);
Заменяем на:
$message .= preg_replace($html_entities_match, $html_entities_replace, $part) . clean_html($tag);
}
$message = addslashes($message);
$message = str_replace('"', '\"', $message);
Находим (420):
$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 ($mode != 'poll_delete')
{
$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);
}
}
Открываем includes/sessions.php
Находим (368):
setcookie($cookiename . '_data', serialize($sessiondata), $current_time + 31536000, $cookiepath, $cookiedomain, $cookiesecure);
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'];
}
Находим (505):
function session_reset_keys($user_id, $user_ip)
{
global $db, $userdata;
Заменяем на:
function session_reset_keys($user_id, $user_ip)
{
global $db, $userdata, $board_config;
Находим (544):
// And now rebuild the cookie
$sessiondata['userid'] = $user_id;
$sessiondata['autologinid'] = $autologin_id;
Заменяем на:
// And now rebuild the cookie
$sessiondata['userid'] = $user_id;
$sessiondata['autologinid'] = $auto_login_key;