.: epsylon :.
Team Dev Maximus

Inscrit le: Apr 28, 2005 Messages: 11699
74233 points
Lieu de résidence
|
Sujet du message: Tutorial: mise à jour manuel du forum 2.0.18
Posté le: Jeu 24 Nov, 2005 4:26 pm |
|
|
Salut
voila le tutorial complet pour la mise à jour manuel du forum
BBtoNuke 2.0.18 patché 2.9 (by nukeresources)
Spécial Maximus et Fuzion Français/Anglais
| Citation: | | Nota les numéros de lignes sont donnés à titre indicatif en fonction des modifications eventuels que vous avez apporter à vos forums |
Aucun fichier à télécharger
Le tutorial à été corrigé par rapport à la mise à jour manuel
quelques modifications on ete apporte cote langue* et quelques lignes de code ajouter par rapport au version fuzion et maximus 7.7 et 7.7.1
*: merci à guicorps pour la correction française
Temps estimé: 1h30 à 2h
Fichier à modifier:
Edition des fichiers:
/include:
| Code: | include/bbcode.php
include/constant.php
include/emailer.php
includes/functions
includes/functions_admin.php
includes/functions_post.php
includes/functions_search.php
include/functions_validate.php
include/page_header.php
include/page_tail.php
include/sessions.php
includes/smtp.php
includes/usercp_activate.php
include/usercp_avatar.php
includes/usercp_register.php
includes/usercp_sendpasswd.php
includes/usercp_viewprofile.php |
/modules/Forums:
| Code: |
modules/Forums/common.php
modules/Forums/groupcp.php
modules/Forums/index.php
modules/Forums/login.php
modules/Forums/modcp.php
modules/Forums/posting.php
modules/Forums/search.php
modules/Forums/viewtopic.php
|
/modules/Forums/admin:
| Code: |
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
|
/modules/Forums/language/lang_english/email:
| Code: | | modules/Forums/language/lang_english/email/topic_notify.tpl |
/modules/Forums/language/lang_english:
| Code: | | modules/Forums/language/lang_english/lang_admin.php |
/modules/Forums/language/lang_french/email:
| Code: | | modules/Forums/language/lang_french/email/topic_notify.tpl |
/modules/Forums/language/lang_french:
| Code: | | modules/Forums/language/lang_french/lang_admin.php |
/modules/Forums/templates/subSilver/admin:
| Code: | 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/smile_list_body.tpl
|
/modules/Forums/templates/subSilver:
et ou
/themes/votre_theme/Forums:
| Code: | modules/Forums/templates/subSilver/bbcode.tpl
modules/Forums/templates/subSilver/user_edit_body.tpl
modules/Forums/templates/subSilver/groupcp_info_body.tpl
modules/Forums/templates/subSilver/profile_add_body.tpl
modules/Forums/templates/subSilver/search_body.tpl
modules/Forums/templates/subSilver/subSilver.cfg
modules/Forums/templates/subSilver/login_body.tpl |
/modules/Private_Messages:
| Code: | | modules/Private_Messages/index.php |
/modules\Private_Messages\index.php
| Code: | | modules/Members_List/index.php |
/db:
| Code: | db/db.php
db/mysql.php |
Requette SQL à mettre dans phpmyadmin:
| Code: |
CREATE TABLE nuke_bbsessions_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)
);
UPDATE nuke_users SET user_active = 0 WHERE user_id = '1';
INSERT INTO nuke_bbconfig (config_name, config_value) VALUES ('allow_autologin', '1');
INSERT INTO nuke_bbconfig (config_name, config_value) VALUES ('max_autologin_time', '0');
DELETE FROM nuke_bbsessions;
UPDATE nuke_bbconfig SET config_value='.0.18' where config_name='version';
|
Fichier a modifier
Ouvrer include/bbcode.php
Ligne 319
Trouver
| Code: | | if (!$close_tag_new || (empty($close_tag_new))) |
Remplacer par
| Code: | | if (!$close_tag_new || ($close_tag_new == '')) |
Ligne 328
Trouver
| Code: | | $use_function_pointer = ($func && (!empty($func))); |
Remplacer par
| Code: | | $use_function_pointer = ($func && ($func != '')); |
Ligne 434
Trouver
| Code: | | bbcode_array_push($stack, $match); |
Remplacer par
| Code: | | array_push($stack, $match); |
Ligne 456
Trouver
| Code: | | $match = bbcode_array_pop($stack); |
Remplacer par
| Code: | | $match = array_pop($stack); |
Ligne 522
Trouver
| Code: | | $match = bbcode_array_pop($stack); |
Remplacer par
| Code: | | $match = array_pop($stack); |
Ligne 699
Trouver
| Code: | * 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.
|
Juste après ajouter
| Code: | | * This function was deprecated in phpBB 2.0.18 |
Ligne 710
Trouver
| Code: | * 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.
|
Juste après ajouter
| Code: | | * This function was deprecated in phpBB 2.0.18 |
Ligne 763
Trouver
| Code: | | $orig[] = "/(?<=.\W|\W.|^\W)" . phpbb_preg_quote($smilies[$i]['code'], "/") . "(?=.\W|\W.|\W$)/"; |
Remplacer par
| Code: | | $orig[] = "/(?<=.\W|\W.|^\W)" . preg_quote($smilies[$i]['code'], "/") . "(?=.\W|\W.|\W$)/"; |
Sauvegarder et fermer
Ouvrer include/constant.php
Ligne 63
Trouver
| Code: |
// SQL codes
define('BEGIN_TRANSACTION', 1);
if(!defined('END_TRANSACTION')) {
define('END_TRANSACTION', 2);
}
|
Remplacer par
| Code: |
// SQL codes
define('BEGIN_TRANSACTION', 1);
define('END_TRANSACTION', 2);
|
Ligne 140
Trouver
| Code: | | define('SESSIONS_TABLE', $prefix.'_bbsessions'); |
Juste apres ajouter
| Code: | | define('SESSIONS_KEYS_TABLE', $prefix.'_bbsessions_keys'); |
Sauvergarder et fermer
Ouvrer includes/emailer.php
Ligne 209
Trouver
| Code: | | $drop_header .= '[\r\n]*?' . phpbb_preg_quote($match[1], '#'); |
Remplacer par
| Code: | | $drop_header .= '[\r\n]*?' . preg_quote($match[1], '#'); |
Ligne 219
Trouver
| Code: | | $drop_header .= '[\r\n]*?' . phpbb_preg_quote($match[1], '#'); |
Remplacer par
| Code: | | $drop_header .= '[\r\n]*?' . preg_quote($match[1], '#'); |
Ligne 305
Trouver
| Code: | | $str = preg_replace('#' . phpbb_preg_quote($spacer, '#') . '$#', '', $str); |
Remplacer par
| Code: | | $str = preg_replace('#' . preg_quote($spacer, '#') . '$#', '', $str); |
Sauvegarder et fermer
Ouvrer includes/functions.php
Ligne 82
Trouver
| Code: |
// added at phpBB 2.0.11 to properly format the username
function phpbb_clean_username($username)
{
$username = substr(htmlspecialchars(str_replace("\'", "'", trim($username))), 0, 25);
$username = phpbb_rtrim($username, "\\");
$username = str_replace("'", "\'", $username);
return $username;
}
|
Ajouter juste apres
| Code: |
/**
* 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);
}
$php_version = explode('.', PHP_VERSION);
// php version < 4.1.0
if ((int) $php_version[0] < 4 || ((int) $php_version[0] == 4 && (int) $php_version[1] < 1))
{
while ($str{0} == $charlist)
{
$str = substr($str, 1);
}
}
else
{
$str = ltrim($str, $charlist);
}
return $str;
}
|
Ligne 212
Trouver
| Code: | | if ( !empty($boxstring_forums) ) |
Remplacer par
| Code: |
if ( $boxstring_forums != '' ) |
Ligne 565
Trouver
| Code: | | $orig_word[] = '#\b(' . str_replace('\*', '\w*?', phpbb_preg_quote($row['word'], '#')) . ')\b#i'; |
Remplacer par
| Code: | | $orig_word[] = '#\b(' . str_replace('\*', '\w*?', preg_quote($row['word'], '#')) . ')\b#i'; |
Ligne 617
Trouver
| Code: |
if ( !empty($sql_error['message']) )
{
$debug_text .= '<br /><br />SQL Error : ' . $sql_error['code'] . ' ' . $sql_error['message'];
}
if ( !empty($sql_store) )
{
$debug_text .= "<br /><br />$sql_store";
}
if ( !empty($err_line) && !empty($err_file) )
{
$debug_text .= '</br /><br />Line : ' . $err_line . '<br />File : ' . basename($err_file);
}
|
Remplacer par
| Code: |
if ( $sql_error['message'] != '' )
{
$debug_text .= '<br /><br />SQL Error : ' . $sql_error['code'] . ' ' . $sql_error['message'];
}
if ( $sql_store != '' )
{
$debug_text .= "<br /><br />$sql_store";
}
if ( $err_line != '' && $err_file != '' )
{
$debug_text .= '</br /><br />Line : ' . $err_line . '<br />File : ' . basename($err_file);
}
|
Ligne 685
Trouver
| Code: |
case GENERAL_MESSAGE:
if ( empty($msg_title) )
{
$msg_title = $lang['Information'];
}
break;
case CRITICAL_MESSAGE:
if ( empty($msg_title) )
{
$msg_title = $lang['Critical_Information'];
}
break;
case GENERAL_ERROR:
if ( empty($msg_text) )
{
$msg_text = $lang['An_error_occured'];
}
if ( empty($msg_title) )
{
$msg_title = $lang['General_Error'];
}
break;
case CRITICAL_ERROR:
//
// Critical errors mean we cannot rely on _ANY_ DB information being
// available so we're going to dump out a simple echo'd statement
//
include($phpbb_root_path . 'language/lang_english/lang_main.'.$phpEx);
if ( empty($msg_text) )
{
$msg_text = $lang['A_critical_error'];
}
if ( empty($msg_title) )
{
$msg_title = 'phpBB : <b>' . $lang['Critical_Error'] . '</b>';
}
break;
}
//
// Add on DEBUG info if we've enabled debug mode and this is an error. This
// prevents debug info being output for general messages should DEBUG be
// set TRUE by accident (preventing confusion for the end user!)
//
if ( DEBUG && ( $msg_code == GENERAL_ERROR || $msg_code == CRITICAL_ERROR ) )
{
if ( !empty($debug_text) )
{
$msg_text = $msg_text . '<br /><br /><b><u>DEBUG MODE</u></b>' . $debug_text;
}
}
|
Remplacer par
| Code: |
case GENERAL_MESSAGE:
if ( $msg_title == '' )
{
$msg_title = $lang['Information'];
}
break;
case CRITICAL_MESSAGE:
if ( $msg_title == '' )
{
$msg_title = $lang['Critical_Information'];
}
break;
case GENERAL_ERROR:
if ( $msg_text == '' )
{
$msg_text = $lang['An_error_occured'];
}
if ( $msg_title == '' )
{
$msg_title = $lang['General_Error'];
}
break;
case CRITICAL_ERROR:
//
// Critical errors mean we cannot rely on _ANY_ DB information being
// available so we're going to dump out a simple echo'd statement
//
include($phpbb_root_path . 'language/lang_english/lang_main.'.$phpEx);
if ( $msg_text == '' )
{
$msg_text = $lang['A_critical_error'];
}
if ( $msg_title == '' )
{
$msg_title = 'phpBB : <b>' . $lang['Critical_Error'] . '</b>';
}
break;
}
|
Sauvergarder et fermer
Ouvrer includes/functions_admin.php
Ligne 74
Trouver
| Code: |
$is_auth_ary = auth(AUTH_READ, AUTH_LIST_ALL, $userdata);
$sql = "SELECT forum_id, forum_name
FROM " . FORUMS_TABLE . "
ORDER BY cat_id, forum_order";
if ( !($result = $db->sql_query($sql)) )
|
Remplacer par
| Code: |
$sql = 'SELECT f.forum_id, f.forum_name
FROM ' . CATEGORIES_TABLE . ' c, ' . FORUMS_TABLE . ' f
WHERE f.cat_id = c.cat_id
ORDER BY c.cat_order, f.forum_order';
if ( !($result = $db->sql_query($sql)) )
|
Ligne 139
Trouver
| Code: |
WHERE forum_id = '$id'";
|
Remplacer par
| Code: |
WHERE forum_id = $id";
|
Ligne 166
Trouver
| Code: |
$sql = "UPDATE " . FORUMS_TABLE . "
SET forum_last_post_id = '$last_post', forum_posts = '$total_posts', forum_topics = '$total_topics'
WHERE forum_id = '$id'";
if ( !$db->sql_query($sql) )
|
Remplacer par
| Code: |
$sql = "UPDATE " . FORUMS_TABLE . "
SET forum_last_post_id = $last_post, forum_posts = $total_posts, forum_topics = $total_topics
WHERE forum_id = $id";
if ( !$db->sql_query($sql) )
|
Ligne 178
Trouver
| Code: |
WHERE topic_id = '$id'";
|
Remplacer par
| Code: |
WHERE topic_id = $id";
|
Ligne 185
Trouver
| Code: |
{
$sql = ( $row['total_posts'] ) ? "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'" : "DELETE FROM " . TOPICS_TABLE . " WHERE topic_id = '$id'";
if ( !$db->sql_query($sql) )
{
message_die(GENERAL_ERROR, 'Could not update topic', '', __LINE__, __FILE__, $sql);
}
}
break;
|
Remplacer par
| Code: |
{
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);
}
}
break;
|
Sauvegarder et fermer
Ouvrer includes/functions_post.php
Ligne 579
Trouver
| Code: |
if ($mode == 'delete')
{
$delete_sql = (!$post_data['first_post'] && !$post_data['last_post']) ? " AND user_id = " . $userdata['user_id'] : '';
$sql = "DELETE FROM " . TOPICS_WATCH_TABLE . " WHERE topic_id = '$topic_id'" . $delete_sql;
if (!$db->sql_query($sql))
{
message_die(GENERAL_ERROR, 'Could not change topic notify data', '', __LINE__, __FILE__, $sql);
}
}
else
{
if ($mode == 'reply')
{
|
Remplacer par
| Code: |
if ($mode != 'delete')
{
if ($mode == 'reply')
{
|
Ligne 769
Trouver
| Code: |
$page_title = $lang['Emoticons'] . " - $topic_title";
if ( defined('IN_ADMIN') )
{
include("./page_header_admin.php");
}
else
{
include("includes/page_header_review.php");
}
$template->set_filenames(array(
'smiliesbody' => 'posting_smilies.tpl')
);
}
$sql = "SELECT emoticon, code, smile_url
FROM " . SMILIES_TABLE . "
ORDER BY smilies_id";
if ($result = $db->sql_query($sql))
{
$num_smilies = 0;
$rowset = array();
while ($row = $db->sql_fetchrow($result))
{
if (empty($rowset[$row['smile_url']]))
{
$rowset[$row['smile_url']]['code'] = str_replace("'", "\\'", str_replace('\\', '\\\\', $row['code']));
$rowset[$row['smile_url']]['emoticon'] = $row['emoticon'];
$num_smilies++;
}
}
if ($num_smilies)
{
$smilies_count = ($mode == 'inline') ? min(19, $num_smilies) : $num_smilies;
$smilies_split_row = ($mode == 'inline') ? $inline_columns - 1 : $window_columns - 1;
$s_colspan = 0;
$row = 0;
$col = 0;
while (list($smile_url, $data) = @each($rowset))
{
if (!$col)
{
$template->assign_block_vars('smilies_row', array());
}
$template->assign_block_vars('smilies_row.smilies_col', array(
'SMILEY_CODE' => $data['code'],
'SMILEY_IMG' => $board_config['smilies_path'] . '/' . $smile_url,
'SMILEY_DESC' => $data['emoticon'])
);
$s_colspan = max($s_colspan, $col + 1);
if ($col == $smilies_split_row)
{
if ($mode == 'inline' && $row == $inline_rows - 1)
{
break;
}
$col = 0;
$row++;
}
else
{
$col++;
}
|
Remplacer par
| Code: |
$page_title = $lang['Emoticons'];
include("includes/page_header.$php");
$template->set_filenames(array(
'smiliesbody' => 'posting_smilies.tpl')
);
}
$sql = "SELECT emoticon, code, smile_url
FROM " . SMILIES_TABLE . "
ORDER BY smilies_id";
if ($result = $db->sql_query($sql))
{
$num_smilies = 0;
$rowset = array();
while ($row = $db->sql_fetchrow($result))
{
if (empty($rowset[$row['smile_url']]))
{
$rowset[$row['smile_url']]['code'] = str_replace("'", "\\'", str_replace('\\', '\\\\', $row['code']));
$rowset[$row['smile_url']]['emoticon'] = $row['emoticon'];
$num_smilies++;
}
}
if ($num_smilies)
{
$smilies_count = ($mode == 'inline') ? min(19, $num_smilies) : $num_smilies;
$smilies_split_row = ($mode == 'inline') ? $inline_columns - 1 : $window_columns - 1;
$s_colspan = 0;
$row = 0;
$col = 0;
while (list($smile_url, $data) = @each($rowset))
{
if (!$col)
{
$template->assign_block_vars('smilies_row', array());
}
$template->assign_block_vars('smilies_row.smilies_col', array(
'SMILEY_CODE' => $data['code'],
'SMILEY_IMG' => $board_config['smilies_path'] . '/' . $smile_url,
'SMILEY_DESC' => $data['emoticon'])
);
$s_colspan = max($s_colspan, $col + 1);
if ($col == $smilies_split_row)
{
if ($mode == 'inline' && $row == $inline_rows - 1)
{
break;
}
$col = 0;
$row++;
}
else
{
$col++;
}
|
Sauvegarder et fermer
Ouvrer
includes/functions_search.php
Ligne 95
Trouver
| Code: |
function split_words(&$entry, $mode = 'post') |
Remplacer par
| Code: |
function split_words($entry, $mode = 'post') |
Sauvergarder et fermer
Ouvrir include/functions_validate.php
Ligne 46
Trouver
| Code: |
if ($row = $db->sql_fetchrow($result)) |
Remplacer par
| Code: |
while ($row = $db->sql_fetchrow($result)) |
Ligne 78
trouver
| Code: |
if (preg_match("#\b(" . str_replace("\*", ".*?", phpbb_preg_quote($row['disallow_username'], '#')) . ")\b#i", $username))
|
Remplacer par
| Code: |
if (preg_match("#\b(" . str_replace("\*", ".*?", preg_quote($row['disallow_username'], '#')) . ")\b#i", $username))
|
Ligne 125
Trouver
| Code: |
if (!empty($email)) |
Remplacer par
Sauvergarder et fermer
Ouvrir include/page_header.php
Ligne 398
Supprimer
| Code: |
'U_MEMBERSLIST' => append_sid('memberlist.'.$phpEx),
|
Ligne 457
Trouver
| Code: |
$template->assign_block_vars('switch_user_logged_out', array());
}
else
{
|
Juste avant
Ajouter
| Code: |
//
// Allow autologin?
//
if (!isset($board_config['allow_autologin']) || $board_config['allow_autologin'] )
{
$template->assign_block_vars('switch_allow_autologin', array());
$template->assign_block_vars('switch_user_logged_out.switch_allow_autologin', array());
}
|
Sauvegarder et fermer
Ouvrir include/page_tail.php
Ligne 23
Trouver
| Code: |
if ( !defined('IN_PHPBB') )
{
die('Hacking attempt');
}
|
Juste apres ajouter
| Code: | | global $do_gzip_compress; |
ligne 41
Trouver
| Code: |
'TRANSLATION_INFO' => ( isset($lang['TRANSLATION_INFO']) ) ? $lang['TRANSLATION_INFO'] : '',
|
Remplacer par
| Code: |
'TRANSLATION_INFO' => (isset($lang['TRANSLATION_INFO'])) ? $lang['TRANSLATION_INFO'] : ((isset($lang['TRANSLATION'])) ? $lang['TRANSLATION'] : ''),
|
Sauvegarer et fermer
Ouvrir include/sessions.php
Ligne 63
Trouver
| Code: |
$current_time = time();
$expiry_time = $current_time - $board_config['session_length'];
//
// 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;
$sql = 'SELECT * FROM ' . USERS_TABLE . ' WHERE user_id = ' . ANONYMOUS;
$result = $db->sql_query($sql);
$userdata = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
}
}
else
{
$login = 1;
}
}
else
{
$login = 0;
$enable_autologin = 0;
}
|
Remplacer par
| Code: |
$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);
}
$userdata = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
$enable_autologin = $login = 1;
}
else if (!$auto_create)
{
$sessiondata['autologinid'] = '';
$sessiondata['userid'] = $user_id;
$sql = 'SELECT *
FROM ' . USERS_TABLE . '
WHERE user_id = ' . (int) $user_id . '
AND user_active = 1';
if (!($result = $db->sql_query($sql)))
{
message_die(CRITICAL_ERROR, 'Error doing DB query userdata row fetch', '', __LINE__, __FILE__, $sql);
}
$userdata = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
$login = 1;
}
}
//
// 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);
}
$userdata = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
}
|
Ligne 191
Trouver
| Code: |
if ( !$db->sql_query($sql) )
{
$error = TRUE;
if (SQL_LAYER == "mysql" || SQL_LAYER == "mysql4")
{
$sql_error = $db->sql_error($result);
if ($sql_error["code"] == 1114)
{
$result = $db->sql_query('SHOW TABLE STATUS LIKE "'.SESSIONS_TABLE.'"');
$row = $db->sql_fetchrow($result);
if ($row["Type"] == "HEAP")
{
if ($row["Rows"] > 2500)
{
$delete_order = (SQL_LAYER=="mysql4") ? " ORDER BY session_time ASC" : "";
$db->sql_query("DELETE QUICK FROM ".SESSIONS_TABLE."$delete_order LIMIT 50");
}
else
{
$db->sql_query("ALTER TABLE ".SESSIONS_TABLE." MAX_ROWS=".($row["Rows"]+50));
}
if ($db->sql_query($sql))
{
$error = FALSE;
}
}
}
}
if ($error)
{
message_die(CRITICAL_ERROR, "Error creating new session", "", __LINE__, __FILE__, $sql);
}
}
}
if ( $user_id != ANONYMOUS )
{// ( $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)
|
Remplacer par
| Code: |
if ( !$db->sql_query($sql) )
{
message_die(CRITICAL_ERROR, 'Error creating new session', '', __LINE__, __FILE__, $sql);
}
}
if ( $user_id != ANONYMOUS )
{
$last_visit = ( $userdata['user_session_time'] > 0 ) ? $userdata['user_session_time'] : $current_time;
if (!$admin)
|
Ligne 203
Trouver
| Code: |
$sql = "UPDATE " . USERS_TABLE . "
SET user_session_time = $current_time, user_session_page = $page_id, user_lastvisit = $last_visit
WHERE user_id = '$user_id'";
if ( !$db->sql_query($sql) )
{
message_die(CRITICAL_ERROR, 'Error updating last visit time', '', __LINE__, __FILE__, $sql);
}
}
$userdata['user_lastvisit'] = $last_visit;
$sessiondata['autologinid'] = (!$admin) ? (( $enable_autologin && $sessionmethod == SESSION_METHOD_COOKIE ) ? $auto_login_key : '') : $sessiondata['autologinid'];
$sessiondata['userid'] = $user_id;
}
|
Remplacer par
| Code: |
$sql = "UPDATE " . USERS_TABLE . "
SET user_session_time = $current_time, user_session_page = $page_id, user_lastvisit = $last_visit
WHERE user_id = '$user_id'";
if ( !$db->sql_query($sql) )
{
message_die(CRITICAL_ERROR, 'Error updating last visit time', '', __LINE__, __FILE__, $sql);
}
}
$userdata['user_lastvisit'] = $last_visit;
//
// Regenerate the auto-login key
//
if ($enable_autologin)
{
list($sec, $usec) = explode(' ', microtime());
mt_srand(hexdec(substr($session_id, 0, 8)) + (float) $sec + ((float) $usec * 1000000));
$auto_login_key = uniqid(mt_rand(), true);
if (isset($sessiondata['autologinid']) && (string) $sessiondata['autologinid'] != '')
{
$sql = 'UPDATE ' . SESSIONS_KEYS_TABLE . "
SET last_ip = '$user_ip', key_id = '" . md5($auto_login_key) . "', last_login = $current_time
WHERE key_id = '" . md5($sessiondata['autologinid']) . "'";
}
else
{
$sql = 'INSERT INTO ' . SESSIONS_KEYS_TABLE . "(key_id, user_id, last_ip, last_login)
VALUES ('" . md5($auto_login_key) . "', $user_id, '$user_ip', $current_time)";
}
if ( !$db->sql_query($sql) )
{
message_die(CRITICAL_ERROR, 'Error updating session key', '', __LINE__, __FILE__, $sql);
}
$sessiondata['autologinid'] = $auto_login_key;
unset($auto_login_key);
}
else
{
$sessiondata['autologinid'] = '';
}
// $sessiondata['autologinid'] = (!$admin) ? (( $enable_autologin && $sessionmethod == SESSION_METHOD_COOKIE ) ? $auto_login_key : '') : $sessiondata['autologinid'];
$sessiondata['userid'] = $user_id;
}
|
Ligne 259
Trouver
| Code: |
$userdata['session_admin'] = $admin; |
Juste apres ajouter
| Code: |
$userdata['session_key'] = $sessiondata['autologinid']; |
Ligne 374
Trouver
| Code: |
//
// Delete expired sessions
//
$expiry_time = $current_time - $board_config['session_length'];
$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);
}
|
Remplacer par
| Code: |
session_clean($userdata['session_id']); |
Ligne 400
Trouver
| Code: |
//
// 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, $HTTP_COOKIE_VARS, $HTTP_GET_VARS, $SID;
|
Remplacer par
| Code: |
/**
* Terminates the specified session
* It will delete the entry in the sessions table for this session,
* remove the corresponding auto-login key and reset the cookies
*/
function session_end($session_id, $user_id)
{
global $db, $lang, $board_config, $userdata, $HTTP_COOKIE_VARS, $HTTP_GET_VARS, $SID;
|
Ligne 414
Trouver
| Code: |
$current_time = time();
//
// Pull cookiedata or grab the URI propagated sid
//
if ( isset($HTTP_COOKIE_VARS[$cookiename . '_sid']) )
{
$session_id = isset( $HTTP_COOKIE_VARS[$cookiename . '_sid'] ) ? $HTTP_COOKIE_VARS[$cookiename . '_sid'] : '';
$sessionmethod = SESSION_METHOD_COOKIE;
}
else
{
$session_id = ( isset($HTTP_GET_VARS['sid']) ) ? $HTTP_GET_VARS['sid'] : '';
$sessionmethod = SESSION_METHOD_GET;
}
if (!preg_match('/^[A-Za-z0-9]*$/', $session_id))
{
return;
}
//
// Delete existing session
//
$sql = "DELETE FROM " . SESSIONS_TABLE . "
WHERE session_id = '$session_id'
AND session_user_id = '$user_id'";
if ( !$db->sql_query($sql) )
{
message_die(CRITICAL_ERROR, 'Error removing user session', '', __LINE__, __FILE__, $sql);
}
setcookie($cookiename . '_data', '', $current_time - 31536000, $cookiepath, $cookiedomain, $cookiesecure);
setcookie($cookiename . '_sid', '', $current_time - 31536000, $cookiepath, $cookiedomain, $cookiesecure);
return true;
} |
Remplacer par
| Code: |
$current_time = time();
if (!preg_match('/^[A-Za-z0-9]*$/', $session_id))
{
return;
}
//
// Delete existing session
//
$sql = 'DELETE FROM ' . SESSIONS_TABLE . "
WHERE session_id = '$session_id'
AND session_user_id = $user_id";
if ( !$db->sql_query($sql) )
{
message_die(CRITICAL_ERROR, 'Error removing user session', '', __LINE__, __FILE__, $sql);
}
//
// Remove this auto-login entry (if applicable)
//
if ( isset($userdata['session_key']) && $userdata['session_key'] != '' )
{
$autologin_key = md5($userdata['session_key']);
$sql = 'DELETE FROM ' . SESSIONS_KEYS_TABLE . '
WHERE user_id = ' . (int) $user_id . "
AND key_id = '$autologin_key'";
if ( !$db->sql_query($sql) )
{
message_die(CRITICAL_ERROR, 'Error removing auto-login key', '', __LINE__, __FILE__, $sql);
}
}
//
// We expect that message_die will be called after this function,
// but just in case it isn't, reset $userdata to the details for a guest
//
$sql = 'SELECT *
FROM ' . USERS_TABLE . '
WHERE user_id = ' . ANONYMOUS;
if ( !($result = $db->sql_query($sql)) )
{
message_die(CRITICAL_ERROR, 'Error obtaining user details', '', __LINE__, __FILE__, $sql);
}
if ( !($userdata = $db->sql_fetchrow($result)) )
{
message_die(CRITICAL_ERROR, 'Error obtaining user details', '', __LINE__, __FILE__, $sql);
}
$db->sql_freeresult($result);
setcookie($cookiename . '_data', '', $current_time - 31536000, $cookiepath, $cookiedomain, $cookiesecure);
setcookie($cookiename . '_sid', '', $current_time - 31536000, $cookiepath, $cookiedomain, $cookiesecure);
return true;
}
/**
* Removes expired sessions and auto-login keys from the database
*/
function session_clean($session_id)
{
global $board_config |
|
|