Вход

View Full Version : Обновляем форум phpBB 2.0.14 до 2.0.15


BriaN
09.05.2005, 17:51
Обновляем форум phpBB 2.0.14 до 2.0.15.

Так как соника нету это написать решил я :smile:


Откройте modules/Forums/admin/admin_forums.php

Найдите:

if( $mode == "addforum" )
{
list($cat_id) = each($HTTP_POST_VARS['addforum']);

После добавьте:

$cat_id = intval($cat_id);


Откройте modules/Forums/admin/admin_smilies.php

Найдите:

$smile_code = ( isset($HTTP_POST_VARS['smile_code']) ) ? $HTTP_POST_VARS['smile_code'] : $HTTP_GET_VARS['smile_code'];
$smile_url = ( isset($HTTP_POST_VARS['smile_url']) ) ? $HTTP_POST_VARS['smile_url'] : $HTTP_GET_VARS['smile_url'];
$smile_emotion = ( isset($HTTP_POST_VARS['smile_emotion']) ) ? $HTTP_POST_VARS['smile_emotion'] : $HTTP_GET_VARS['smile_emotion'];

После добавьте:

$smile_code = trim($smile_code);
$smile_url = trim($smile_url);
$smile_emotion = trim($smile_emotion);


Откройте modules/Forums/admin/pagestart.php

Найдите:

*/
if ( empty($no_page_header) )

До этого добавьте:

if (!$userdata['session_admin'])
{
$header_location = ( @preg_match('/Microsoft|WebSTAR|Xitami/', $_SERVER['SERVER_SOFTWARE']) ) ? 'Refresh: 0; URL=' : 'Location: ';
header($header_location . '../../../' . append_sid("login.$phpEx?redirect=admin/&admin=1", true));
exit;
}


Откройте db/postgres7.php

Найдите:

$query = preg_replace('#(.*WHERE.*)(username|user_email|ban_email) = \'(.*)\'#ise', "\"\\1LOWER(\\2) = '\" . strtolower('\\3') . \"'\"", $query);



Замените на:

// $query = preg_replace('#(.*WHERE.*)(username|user_email|ban_email) = \'(.*)\'#ise', "\"\\1LOWER(\\2) = '\" . strtolower('\\3') . \"'\"", $query);


Откройте modules/Forums/groupcp.php

Найдите (340 строка):

if ( !($row = $db->sql_fetchrow($result)) )

Замените на:

if ( !($row = $db->sql_fetchrow($result)) || $row['is_auth_mod'] == 0 )


Откройте includes/bbcode.php

Найдите:

{
global $lang, $bbcode_tpl;

После добавьте:

$text = preg_replace('#(script|about|applet|activex|chrome):#is', "\\1:", $text);

Найдите:

// image_url_here code..
// This one gets first-passed..
$patterns[] = "#\[img:$uid\](.*?)\[/img:$uid\]#si";

Замените на:

// image_url_here code..
// This one gets first-passed..
$patterns[] = "#\[img:$uid\]([^?].*?)\[/img:$uid\]#i";

Найдите:

// phpBB (xxxx://www.phpbb.com) code..
$patterns[] = "#\+?://[^ \"\n\r\t<]*?)\](.*?)\[/url\]#is";
$replacements[] = $bbcode_tpl['url3'];

// [url=www.phpbb.com]phpBB (([\w) code.. (no xxxx:// prefix).
$patterns[] = "#\*?)\](.*?)\[/url\]#is";

Замените на:

// [url=xxxx://www.phpbb.com]phpBB (((www|ftp)\.[^ \"\n\r\t<) code..
$patterns[] = "#\+?://[^ \"\n\r\t<]*?)\]([^?].*?)\[/url\]#i";
$replacements[] = $bbcode_tpl['url3'];

// [url=www.phpbb.com]phpBB (([\w) code.. (no xxxx:// prefix).
$patterns[] = "#\[url=((www|ftp)\.[^ \"\n\r\t<]*?)\]([^?].*?)\[/url\]#i";

Найдите:

*/
function make_clickable($text)
{

После добавьте:

$text = preg_replace('#(script|about|applet|activex|chrome):#is', "\\1:", $text);


Откройте includes/sessions.php

Найдите:

function session_begin($user_id, $user_ip, $page_id, $auto_create = 0, $enable_autologin = 0)

Замените на:

function session_begin($user_id, $user_ip, $page_id, $auto_create = 0, $enable_autologin = 0, $admin = 0)

Найдите:

SET session_user_id = $user_id, session_start = $current_time, session_time = $current_time, session_page = $page_id, session_logged_in = $login
WHERE session_id = '" . $session_id . "'
AND session_ip = '$user_ip'";
if ( !$db->sql_query($sql) || !$db->sql_affectedrows() )
{
$session_id = md5(uniqid($user_ip));

$sql = "INSERT INTO " . SESSIONS_TABLE . "
(session_id, session_user_id, session_start, session_time, session_ip, session_page, session_logged_in)
VALUES ('$session_id', '$user_id', '$current_time', '$current_time', '$user_ip', '$page_id', '$login')";

Замените на:

SET session_user_id = $user_id, session_start = $current_time, session_time = $current_time, session_page = $page_id, session_logged_in = $login, session_admin = $admin
WHERE session_id = '" . $session_id . "'
AND session_ip = '$user_ip'";
if ( !$db->sql_query($sql) || !$db->sql_affectedrows() )
{
list($sec, $usec) = explode(' ', microtime());
mt_srand((float) $sec + ((float) $usec * 100000));
$session_id = md5(uniqid(mt_rand(), true));

$sql = "INSERT INTO " . SESSIONS_TABLE . "
(session_id, session_user_id, session_start, session_time, session_ip, session_page, session_logged_in, session_admin)
VALUES ('$session_id', '$user_id', '$current_time', '$current_time', '$user_ip', '$page_id', '$login', '$admin')";

Найдите:

{// ( $userdata['user_session_time'] > $expiry_time && $auto_create ) ? $userdata['user_lastvisit'] : (
$last_visit = ( $userdata['user_session_time'] > 0 ) ? $userdata['user_session_time'] : $current_time;

После добавьте:

if (!$admin)
{

Найдите:

$userdata['user_lastvisit'] = $last_visit;

$sessiondata['autologinid'] = ( $enable_autologin && $sessionmethod == SESSION_METHOD_COOKIE ) ? $auto_login_key : '';

Замените на:

}

$userdata['user_lastvisit'] = $last_visit;

$sessiondata['autologinid'] = (!$admin) ? (( $enable_autologin && $sessionmethod == SESSION_METHOD_COOKIE ) ? $auto_login_key : '') : $sessiondata['autologinid'];

Найдите:

$userdata['session_page'] = $page_id;
$userdata['session_start'] = $current_time;
$userdata['session_time'] = $current_time;

После добавьте:

$userdata['session_admin'] = $admin;

Найдите:

$sql = "UPDATE " . SESSIONS_TABLE . "
SET session_time = '$current_time', session_page = '$thispage_id'

Замените на:

// A little trick to reset session_admin on session re-usage
$update_admin = (!defined('IN_ADMIN') && $current_time - $userdata['session_time'] > ($board_config['session_length']+60)) ? ', session_admin = 0' : '';

$sql = "UPDATE " . SESSIONS_TABLE . "
SET session_time = $current_time, session_page = $thispage_id$update_admin


Откройте includes/smtp.php

Найдите:

if( !$socket = fsockopen($board_config['smtp_host'], 25, $errno, $errstr, 20) )

Замените на:

if( !$socket = @fsockopen($board_config['smtp_host'], 25, $errno, $errstr, 20) )


Откройте includes/usercp_viewprofile.php

Найдите:

}
$profiledata = get_userdata($HTTP_GET_VARS[POST_USERS_URL]);

После добавьте:

if (!$profiledata)
{
message_die(GENERAL_MESSAGE, $lang['No_user_id_specified']);
}


Откройте modules/Forums/language/lang_english/lang_main.php

Найдите:

$lang['An_error_occured'] = 'An Error Occurred';
$lang['A_critical_error'] = 'A Critical Error Occurred';

После добавьте:

$lang['Admin_reauthenticate'] = 'To administer the board you must re-authenticate yourself.';


Откройте modules/Forums/language/lang_russian/lang_main.php

Найдите:

$lang['An_error_occured'] = 'Произошла ошибка';
$lang['A_critical_error'] = 'Произошла критическая ошибка';

После добавьте:

$lang['Admin_reauthenticate'] = 'Для того, что бы зайти в панель администратора вы должны перезалогинится.';


Откройте modules/Forums/login.php

Найдите:

if( ( isset($HTTP_POST_VARS['login']) || isset($HTTP_GET_VARS['login']) ) && !$userdata['session_logged_in'] )

Замените на:

if( ( isset($HTTP_POST_VARS['login']) || isset($HTTP_GET_VARS['login']) ) && (!$userdata['session_logged_in'] || isset($HTTP_POST_VARS['admin'])) )

Найдите:

$session_id = session_begin($row['user_id'], $user_ip, PAGE_INDEX, FALSE, $autologin);

Замените на:

$admin = (isset($HTTP_POST_VARS['admin'])) ? 1 : 0;
$session_id = session_begin($row['user_id'], $user_ip, PAGE_INDEX, FALSE, $autologin, $admin);

Найдите:

if( !$userdata['session_logged_in'] )

Замените на:

if( !$userdata['session_logged_in'] || (isset($HTTP_GET_VARS['admin']) && $userdata['session_logged_in'] && $userdata['user_level'] == ADMIN))

Найдите:

make_jumpbox('viewforum.'.$phpEx, $forum_id);
$template->assign_vars(array(
'USERNAME' => $username,

'L_ENTER_PASSWORD' => $lang['Enter_password'],

Замените на:

$s_hidden_fields .= (isset($HTTP_GET_VARS['admin'])) ? '<input type="hidden" name="admin" value="1" />' : '';

make_jumpbox('viewforum.'.$phpEx, $forum_id);
$template->assign_vars(array(
'USERNAME' => $username,

'L_ENTER_PASSWORD' => (isset($HTTP_GET_VARS['admin'])) ? $lang['Admin_reauthenticate'] : $lang['Enter_password'],

Откройте modules/Forums/viewtopic.php

Найдите:

$message = str_replace('\"', '"', substr(@preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "@preg_replace('#\b(" . $highlight_match . ")\b#i', '<span style=\"color:#" . $theme['fontcolor3'] . "\"><b>\\\\1</b></span>', '\\0')", '>' . $message . '<'), 1, -1));

Замените на:

$message = str_replace('\"', '"', substr(@preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "@preg_replace('#\b(" . str_replace('\\', '\\\\', $highlight_match) . ")\b#i', '<span style=\"color:#" . $theme['fontcolor3'] . "\"><b>\\\\1</b></span>', '\\0')", '>' . $message . '<'), 1, -1));


Откройте modules/Forums/admin/admin_ug_auth.php

Найдите:

message_die(GENERAL_MESSAGE, $message);
}
}
else if ( ( $mode == 'user' && ( isset($HTTP_POST_VARS['username']) || $user_id ) ) || ( $mode == 'group' && $group_id ) )

До этого добавьте:

$sql = 'SELECT user_id FROM ' . USER_GROUP_TABLE . "
WHERE group_id = $group_id";
$result = $db->sql_query($sql);

$group_user = array();
while ($row = $db->sql_fetchrow($result))
{
$group_user[$row['user_id']] = $row['user_id'];
}
$db->sql_freeresult($result);

$sql = "SELECT ug.user_id, COUNT(auth_mod) AS is_auth_mod
FROM " . AUTH_ACCESS_TABLE . " aa, " . USER_GROUP_TABLE . " ug
WHERE ug.user_id IN (" . implode(', ', $group_user) . ")
AND aa.group_id = ug.group_id
AND aa.auth_mod = 1
GROUP BY ug.user_id";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not obtain moderator status', '', __LINE__, __FILE__, $sql);
}

while ($row = $db->sql_fetchrow($result))
{
if ($row['is_auth_mod'])
{
unset($group_user[$row['user_id']]);
}
}
$db->sql_freeresult($result);

if (sizeof($group_user))
{
$sql = "UPDATE " . USERS_TABLE . "
SET user_level = " . USER . "
WHERE user_id IN (" . implode(', ', $group_user) . ")";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not update user level', '', __LINE__, __FILE__, $sql);
}
}


Откройте includes/usercp_register.php

Найдите:

if (strtolower($username) != strtolower($userdata['username']))

Замените на:

if (strtolower($username) != strtolower($userdata['username']) || $mode == 'register')


Выполните SQL запрос:

UPDATE nuke_bbconfig SET config_value='.0.15' where config_name='version';
ALTER TABLE nuke_bbsessions ADD COLUMN session_admin tinyint(2) DEFAULT '0' NOT NULL;

заменив nuke_ на свой префикс!

Ну вот и закончено обновление форума. :cool:

Soniks
09.05.2005, 18:42
респект :wink:

Soniks
22.05.2005, 23:17
Появился небольшой баг в версии 2.0.15. Он связан с правами администратора, для устранения его в файле modules/Forums/admin/admin_ug_auth.php
найдите:

WHERE user_id IN (" . implode(', ', $group_user) . ")";

и замените на:
WHERE user_id IN (" . implode(', ', $group_user) . ") AND user_level = " . MOD;