Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/ExeBy/smexe_ro.../var/softacul.../mybb
File: index.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* MyBB 1.8
[2] Fix | Delete
* Copyright 2014 MyBB Group, All Rights Reserved
[3] Fix | Delete
*
[4] Fix | Delete
* Website: http://www.mybb.com
[5] Fix | Delete
* License: http://www.mybb.com/about/license
[6] Fix | Delete
*
[7] Fix | Delete
*/
[8] Fix | Delete
[9] Fix | Delete
define("IN_MYBB", 1);
[10] Fix | Delete
define("IN_ADMINCP", 1);
[11] Fix | Delete
[12] Fix | Delete
// Here you can change how much of an Admin CP IP address must match in a previous session for the user is validated (e.g. 3 means a.b.c need to match)
[13] Fix | Delete
define("ADMIN_IP_SEGMENTS", 0);
[14] Fix | Delete
define("ADMIN_IPV6_SEGMENTS", 0);
[15] Fix | Delete
[16] Fix | Delete
require_once dirname(dirname(__FILE__))."/inc/init.php";
[17] Fix | Delete
[18] Fix | Delete
$shutdown_queries = $shutdown_functions = array();
[19] Fix | Delete
[20] Fix | Delete
send_page_headers();
[21] Fix | Delete
[22] Fix | Delete
header('X-Frame-Options: SAMEORIGIN');
[23] Fix | Delete
header('Referrer-Policy: no-referrer');
[24] Fix | Delete
[25] Fix | Delete
if(!isset($config['admin_dir']) || !file_exists(MYBB_ROOT.$config['admin_dir']."/inc/class_page.php"))
[26] Fix | Delete
{
[27] Fix | Delete
$config['admin_dir'] = basename(dirname(__FILE__));
[28] Fix | Delete
}
[29] Fix | Delete
[30] Fix | Delete
define('MYBB_ADMIN_DIR', MYBB_ROOT.$config['admin_dir'].'/');
[31] Fix | Delete
[32] Fix | Delete
define('COPY_YEAR', my_date('Y', TIME_NOW));
[33] Fix | Delete
[34] Fix | Delete
require_once MYBB_ADMIN_DIR."inc/class_page.php";
[35] Fix | Delete
require_once MYBB_ADMIN_DIR."inc/class_form.php";
[36] Fix | Delete
require_once MYBB_ADMIN_DIR."inc/class_table.php";
[37] Fix | Delete
require_once MYBB_ADMIN_DIR."inc/functions.php";
[38] Fix | Delete
require_once MYBB_ROOT."inc/functions_user.php";
[39] Fix | Delete
[40] Fix | Delete
// Set cookie path to our admin dir temporarily, i.e. so that it affects the ACP only
[41] Fix | Delete
$loc = get_current_location('', '', true);
[42] Fix | Delete
$mybb->settings['cookiepath'] = substr($loc, 0, strrpos($loc, "/{$config['admin_dir']}/"))."/{$config['admin_dir']}/";
[43] Fix | Delete
[44] Fix | Delete
if(!isset($cp_language))
[45] Fix | Delete
{
[46] Fix | Delete
$lang->set_language($mybb->settings['cplanguage'], "admin");
[47] Fix | Delete
}
[48] Fix | Delete
[49] Fix | Delete
// Load global language phrases
[50] Fix | Delete
$lang->load("global");
[51] Fix | Delete
$lang->load("messages", true);
[52] Fix | Delete
[53] Fix | Delete
if(function_exists('mb_internal_encoding') && !empty($lang->settings['charset']))
[54] Fix | Delete
{
[55] Fix | Delete
@mb_internal_encoding($lang->settings['charset']);
[56] Fix | Delete
}
[57] Fix | Delete
[58] Fix | Delete
header("Content-type: text/html; charset={$lang->settings['charset']}");
[59] Fix | Delete
[60] Fix | Delete
$time = TIME_NOW;
[61] Fix | Delete
$errors = null;
[62] Fix | Delete
[63] Fix | Delete
if(is_dir(MYBB_ROOT."install") && !file_exists(MYBB_ROOT."install/lock"))
[64] Fix | Delete
{
[65] Fix | Delete
$mybb->trigger_generic_error("install_directory");
[66] Fix | Delete
}
[67] Fix | Delete
[68] Fix | Delete
$ip_address = get_ip();
[69] Fix | Delete
unset($user);
[70] Fix | Delete
[71] Fix | Delete
// Load Admin CP style
[72] Fix | Delete
if(!isset($cp_style))
[73] Fix | Delete
{
[74] Fix | Delete
if(!empty($mybb->settings['cpstyle']) && file_exists(MYBB_ADMIN_DIR."/styles/".$mybb->settings['cpstyle']."/main.css"))
[75] Fix | Delete
{
[76] Fix | Delete
$cp_style = $mybb->settings['cpstyle'];
[77] Fix | Delete
}
[78] Fix | Delete
else
[79] Fix | Delete
{
[80] Fix | Delete
$cp_style = "default";
[81] Fix | Delete
}
[82] Fix | Delete
}
[83] Fix | Delete
[84] Fix | Delete
$default_page = new DefaultPage;
[85] Fix | Delete
[86] Fix | Delete
$logged_out = false;
[87] Fix | Delete
$fail_check = 0;
[88] Fix | Delete
$post_verify = true;
[89] Fix | Delete
[90] Fix | Delete
foreach(array('action', 'do', 'module') as $input)
[91] Fix | Delete
{
[92] Fix | Delete
if(!isset($mybb->input[$input]))
[93] Fix | Delete
{
[94] Fix | Delete
$mybb->input[$input] = '';
[95] Fix | Delete
}
[96] Fix | Delete
}
[97] Fix | Delete
[98] Fix | Delete
if($mybb->input['action'] == "unlock")
[99] Fix | Delete
{
[100] Fix | Delete
$user = array();
[101] Fix | Delete
$error = '';
[102] Fix | Delete
[103] Fix | Delete
$plugins->run_hooks("admin_unlock_start");
[104] Fix | Delete
[105] Fix | Delete
if($mybb->input['username'])
[106] Fix | Delete
{
[107] Fix | Delete
$user = get_user_by_username($mybb->input['username'], array('fields' => '*'));
[108] Fix | Delete
[109] Fix | Delete
if(!$user)
[110] Fix | Delete
{
[111] Fix | Delete
$error = $lang->error_invalid_username;
[112] Fix | Delete
}
[113] Fix | Delete
}
[114] Fix | Delete
else if($mybb->input['uid'])
[115] Fix | Delete
{
[116] Fix | Delete
$user = get_user($mybb->input['uid']);
[117] Fix | Delete
if(!$user)
[118] Fix | Delete
{
[119] Fix | Delete
$error = $lang->error_invalid_uid;
[120] Fix | Delete
}
[121] Fix | Delete
}
[122] Fix | Delete
[123] Fix | Delete
// Do we have the token? If so let's process it
[124] Fix | Delete
if($mybb->input['token'] && $user['uid'])
[125] Fix | Delete
{
[126] Fix | Delete
$query = $db->simple_select("awaitingactivation", "COUNT(aid) AS num", "uid='".(int)$user['uid']."' AND code='".$db->escape_string($mybb->input['token'])."' AND type='l'");
[127] Fix | Delete
[128] Fix | Delete
$plugins->run_hooks("admin_unlock_end");
[129] Fix | Delete
[130] Fix | Delete
// If we're good to go
[131] Fix | Delete
if($db->fetch_field($query, "num") > 0)
[132] Fix | Delete
{
[133] Fix | Delete
$db->delete_query("awaitingactivation", "uid='".(int)$user['uid']."' AND code='".$db->escape_string($mybb->input['token'])."' AND type='l'");
[134] Fix | Delete
$db->update_query("adminoptions", array('loginlockoutexpiry' => 0, 'loginattempts' => 0), "uid='".(int)$user['uid']."'");
[135] Fix | Delete
[136] Fix | Delete
admin_redirect("index.php");
[137] Fix | Delete
}
[138] Fix | Delete
else
[139] Fix | Delete
{
[140] Fix | Delete
$error = $lang->error_invalid_token;
[141] Fix | Delete
}
[142] Fix | Delete
}
[143] Fix | Delete
[144] Fix | Delete
$default_page->show_lockout_unlock($error, 'error');
[145] Fix | Delete
}
[146] Fix | Delete
elseif($mybb->input['do'] == "login")
[147] Fix | Delete
{
[148] Fix | Delete
$plugins->run_hooks("admin_login");
[149] Fix | Delete
[150] Fix | Delete
// We have an adminsid cookie?
[151] Fix | Delete
if(isset($mybb->cookies['adminsid']))
[152] Fix | Delete
{
[153] Fix | Delete
// Check admin session
[154] Fix | Delete
$query = $db->simple_select("adminsessions", "sid", "sid='".$db->escape_string($mybb->cookies['adminsid'])."'");
[155] Fix | Delete
$admin_session = $db->fetch_field($query, 'sid');
[156] Fix | Delete
[157] Fix | Delete
// Session found: redirect to index
[158] Fix | Delete
if($admin_session)
[159] Fix | Delete
{
[160] Fix | Delete
admin_redirect("index.php");
[161] Fix | Delete
}
[162] Fix | Delete
}
[163] Fix | Delete
[164] Fix | Delete
require_once MYBB_ROOT."inc/datahandlers/login.php";
[165] Fix | Delete
$loginhandler = new LoginDataHandler("get");
[166] Fix | Delete
[167] Fix | Delete
// Determine login method
[168] Fix | Delete
$login_lang_string = $lang->error_invalid_username_password;
[169] Fix | Delete
switch($mybb->settings['username_method'])
[170] Fix | Delete
{
[171] Fix | Delete
case 0: // Username only
[172] Fix | Delete
$login_lang_string = $lang->sprintf($login_lang_string, $lang->login_username);
[173] Fix | Delete
break;
[174] Fix | Delete
case 1: // Email only
[175] Fix | Delete
$login_lang_string = $lang->sprintf($login_lang_string, $lang->login_email);
[176] Fix | Delete
break;
[177] Fix | Delete
case 2: // Username and email
[178] Fix | Delete
default:
[179] Fix | Delete
$login_lang_string = $lang->sprintf($login_lang_string, $lang->login_username_and_password);
[180] Fix | Delete
break;
[181] Fix | Delete
}
[182] Fix | Delete
[183] Fix | Delete
// Validate PIN first
[184] Fix | Delete
if(!empty($config['secret_pin']) && (empty($mybb->input['pin']) || $mybb->input['pin'] != $config['secret_pin']))
[185] Fix | Delete
{
[186] Fix | Delete
$login_user = get_user_by_username($mybb->input['username'], array('fields' => array('email', 'username')));
[187] Fix | Delete
[188] Fix | Delete
$plugins->run_hooks("admin_login_incorrect_pin");
[189] Fix | Delete
[190] Fix | Delete
if($login_user['uid'] > 0)
[191] Fix | Delete
{
[192] Fix | Delete
$db->update_query("adminoptions", array("loginattempts" => "loginattempts+1"), "uid='".(int)$login_user['uid']."'", '', true);
[193] Fix | Delete
}
[194] Fix | Delete
[195] Fix | Delete
$loginattempts = login_attempt_check_acp($login_user['uid'], true);
[196] Fix | Delete
[197] Fix | Delete
// Have we attempted too many times?
[198] Fix | Delete
if($loginattempts !== false && $loginattempts['loginattempts'] > 0)
[199] Fix | Delete
{
[200] Fix | Delete
// Have we set an expiry yet?
[201] Fix | Delete
if($loginattempts['loginlockoutexpiry'] == 0)
[202] Fix | Delete
{
[203] Fix | Delete
$db->update_query("adminoptions", array("loginlockoutexpiry" => TIME_NOW+((int)$mybb->settings['loginattemptstimeout']*60)), "uid='".(int)$login_user['uid']."'");
[204] Fix | Delete
}
[205] Fix | Delete
[206] Fix | Delete
// Did we hit lockout for the first time? Send the unlock email to the administrator
[207] Fix | Delete
if($loginattempts['loginattempts'] == $mybb->settings['maxloginattempts'])
[208] Fix | Delete
{
[209] Fix | Delete
$db->delete_query("awaitingactivation", "uid='".(int)$login_user['uid']."' AND type='l'");
[210] Fix | Delete
$lockout_array = array(
[211] Fix | Delete
"uid" => $login_user['uid'],
[212] Fix | Delete
"dateline" => TIME_NOW,
[213] Fix | Delete
"code" => random_str(),
[214] Fix | Delete
"type" => "l"
[215] Fix | Delete
);
[216] Fix | Delete
$db->insert_query("awaitingactivation", $lockout_array);
[217] Fix | Delete
[218] Fix | Delete
$subject = $lang->sprintf($lang->locked_out_subject, $mybb->settings['bbname']);
[219] Fix | Delete
$message = $lang->sprintf($lang->locked_out_message, htmlspecialchars_uni($mybb->input['username']), $mybb->settings['bbname'], $mybb->settings['maxloginattempts'], $mybb->settings['bburl'], $mybb->config['admin_dir'], $lockout_array['code'], $lockout_array['uid']);
[220] Fix | Delete
my_mail($login_user['email'], $subject, $message);
[221] Fix | Delete
}
[222] Fix | Delete
[223] Fix | Delete
log_admin_action(array(
[224] Fix | Delete
'type' => 'admin_locked_out',
[225] Fix | Delete
'uid' => (int)$login_user['uid'],
[226] Fix | Delete
'username' => $login_user['username'],
[227] Fix | Delete
)
[228] Fix | Delete
);
[229] Fix | Delete
[230] Fix | Delete
$default_page->show_lockedout();
[231] Fix | Delete
}
[232] Fix | Delete
else
[233] Fix | Delete
{
[234] Fix | Delete
$default_page->show_login($login_lang_string, "error");
[235] Fix | Delete
}
[236] Fix | Delete
}
[237] Fix | Delete
[238] Fix | Delete
$loginhandler->set_data(array(
[239] Fix | Delete
'username' => $mybb->input['username'],
[240] Fix | Delete
'password' => $mybb->input['password']
[241] Fix | Delete
));
[242] Fix | Delete
[243] Fix | Delete
if($loginhandler->validate_login() == true)
[244] Fix | Delete
{
[245] Fix | Delete
$mybb->user = get_user($loginhandler->login_data['uid']);
[246] Fix | Delete
}
[247] Fix | Delete
[248] Fix | Delete
if(!empty($mybb->user['uid']))
[249] Fix | Delete
{
[250] Fix | Delete
if(login_attempt_check_acp($mybb->user['uid']) == true)
[251] Fix | Delete
{
[252] Fix | Delete
log_admin_action(array(
[253] Fix | Delete
'type' => 'admin_locked_out',
[254] Fix | Delete
'uid' => (int)$mybb->user['uid'],
[255] Fix | Delete
'username' => $mybb->user['username'],
[256] Fix | Delete
)
[257] Fix | Delete
);
[258] Fix | Delete
[259] Fix | Delete
$default_page->show_lockedout();
[260] Fix | Delete
}
[261] Fix | Delete
[262] Fix | Delete
$plugins->run_hooks("admin_login_success");
[263] Fix | Delete
[264] Fix | Delete
$db->delete_query("adminsessions", "uid='{$mybb->user['uid']}'");
[265] Fix | Delete
[266] Fix | Delete
$sid = md5(random_str(50));
[267] Fix | Delete
[268] Fix | Delete
$useragent = $_SERVER['HTTP_USER_AGENT'];
[269] Fix | Delete
if(my_strlen($useragent) > 200)
[270] Fix | Delete
{
[271] Fix | Delete
$useragent = my_substr($useragent, 0, 200);
[272] Fix | Delete
}
[273] Fix | Delete
[274] Fix | Delete
// Create a new admin session for this user
[275] Fix | Delete
$admin_session = array(
[276] Fix | Delete
"sid" => $sid,
[277] Fix | Delete
"uid" => $mybb->user['uid'],
[278] Fix | Delete
"loginkey" => $mybb->user['loginkey'],
[279] Fix | Delete
"ip" => $db->escape_binary(my_inet_pton(get_ip())),
[280] Fix | Delete
"dateline" => TIME_NOW,
[281] Fix | Delete
"lastactive" => TIME_NOW,
[282] Fix | Delete
"data" => my_serialize(array()),
[283] Fix | Delete
"useragent" => $db->escape_string($useragent),
[284] Fix | Delete
"authenticated" => 0,
[285] Fix | Delete
);
[286] Fix | Delete
$db->insert_query("adminsessions", $admin_session);
[287] Fix | Delete
$admin_session['data'] = array();
[288] Fix | Delete
[289] Fix | Delete
// Only reset the loginattempts when we're really logged in and the user doesn't need to enter a 2fa code
[290] Fix | Delete
$query = $db->simple_select("adminoptions", "authsecret", "uid='{$mybb->user['uid']}'");
[291] Fix | Delete
$admin_options = $db->fetch_array($query);
[292] Fix | Delete
if(empty($admin_options['authsecret']))
[293] Fix | Delete
{
[294] Fix | Delete
$db->update_query("adminoptions", array("loginattempts" => 0, "loginlockoutexpiry" => 0), "uid='{$mybb->user['uid']}'");
[295] Fix | Delete
}
[296] Fix | Delete
[297] Fix | Delete
my_setcookie("adminsid", $sid, '', true, "strict");
[298] Fix | Delete
my_setcookie('acploginattempts', 0);
[299] Fix | Delete
$post_verify = false;
[300] Fix | Delete
[301] Fix | Delete
$mybb->request_method = "get";
[302] Fix | Delete
[303] Fix | Delete
if(!empty($mybb->input['module']))
[304] Fix | Delete
{
[305] Fix | Delete
// $query_string should contain the module
[306] Fix | Delete
$query_string = '?module='.htmlspecialchars_uni($mybb->input['module']);
[307] Fix | Delete
[308] Fix | Delete
// Now we look for any paramters passed in $_SERVER['QUERY_STRING']
[309] Fix | Delete
if($_SERVER['QUERY_STRING'])
[310] Fix | Delete
{
[311] Fix | Delete
$qstring = '?'.preg_replace('#adminsid=(.{32})#i', '', $_SERVER['QUERY_STRING']);
[312] Fix | Delete
$qstring = str_replace('action=logout', '', $qstring);
[313] Fix | Delete
$qstring = preg_replace('#&+#', '&', $qstring);
[314] Fix | Delete
$qstring = str_replace('?&', '?', $qstring);
[315] Fix | Delete
[316] Fix | Delete
// So what do we do? We know that parameters are devided by ampersands
[317] Fix | Delete
// That means we must get to work!
[318] Fix | Delete
$parameters = explode('&', $qstring);
[319] Fix | Delete
[320] Fix | Delete
// Remove our first member if it's for the module
[321] Fix | Delete
if(substr($parameters[0], 0, 8) == '?module=')
[322] Fix | Delete
{
[323] Fix | Delete
unset($parameters[0]);
[324] Fix | Delete
}
[325] Fix | Delete
[326] Fix | Delete
foreach($parameters as $key => $param)
[327] Fix | Delete
{
[328] Fix | Delete
$params = explode("=", $param);
[329] Fix | Delete
[330] Fix | Delete
$query_string .= '&'.htmlspecialchars_uni($params[0]);
[331] Fix | Delete
[332] Fix | Delete
if(isset($params[1]))
[333] Fix | Delete
{
[334] Fix | Delete
$query_string .= "=".htmlspecialchars_uni($params[1]);
[335] Fix | Delete
}
[336] Fix | Delete
}
[337] Fix | Delete
}
[338] Fix | Delete
[339] Fix | Delete
admin_redirect("index.php".$query_string);
[340] Fix | Delete
}
[341] Fix | Delete
}
[342] Fix | Delete
else
[343] Fix | Delete
{
[344] Fix | Delete
$login_user = get_user_by_username($mybb->input['username'], array('fields' => array('email', 'username')));
[345] Fix | Delete
[346] Fix | Delete
$plugins->run_hooks("admin_login_fail");
[347] Fix | Delete
[348] Fix | Delete
$loginattempts = false;
[349] Fix | Delete
if(!empty($login_user['uid']) && $login_user['uid'] > 0)
[350] Fix | Delete
{
[351] Fix | Delete
$db->update_query("adminoptions", array("loginattempts" => "loginattempts+1"), "uid='".(int)$login_user['uid']."'", '', true);
[352] Fix | Delete
$loginattempts = login_attempt_check_acp($login_user['uid'], true);
[353] Fix | Delete
}
[354] Fix | Delete
[355] Fix | Delete
// Have we attempted too many times?
[356] Fix | Delete
if($loginattempts !== false && $loginattempts['loginattempts'] > 0)
[357] Fix | Delete
{
[358] Fix | Delete
// Have we set an expiry yet?
[359] Fix | Delete
if($loginattempts['loginlockoutexpiry'] == 0)
[360] Fix | Delete
{
[361] Fix | Delete
$db->update_query("adminoptions", array("loginlockoutexpiry" => TIME_NOW+((int)$mybb->settings['loginattemptstimeout']*60)), "uid='".(int)$login_user['uid']."'");
[362] Fix | Delete
}
[363] Fix | Delete
[364] Fix | Delete
$plugins->run_hooks("admin_login_lockout");
[365] Fix | Delete
[366] Fix | Delete
// Did we hit lockout for the first time? Send the unlock email to the administrator
[367] Fix | Delete
if($loginattempts['loginattempts'] == $mybb->settings['maxloginattempts'])
[368] Fix | Delete
{
[369] Fix | Delete
$db->delete_query("awaitingactivation", "uid='".(int)$login_user['uid']."' AND type='l'");
[370] Fix | Delete
$lockout_array = array(
[371] Fix | Delete
"uid" => $login_user['uid'],
[372] Fix | Delete
"dateline" => TIME_NOW,
[373] Fix | Delete
"code" => random_str(),
[374] Fix | Delete
"type" => "l"
[375] Fix | Delete
);
[376] Fix | Delete
$db->insert_query("awaitingactivation", $lockout_array);
[377] Fix | Delete
[378] Fix | Delete
$subject = $lang->sprintf($lang->locked_out_subject, $mybb->settings['bbname']);
[379] Fix | Delete
$message = $lang->sprintf($lang->locked_out_message, htmlspecialchars_uni($mybb->input['username']), $mybb->settings['bbname'], $mybb->settings['maxloginattempts'], $mybb->settings['bburl'], $mybb->config['admin_dir'], $lockout_array['code'], $lockout_array['uid']);
[380] Fix | Delete
my_mail($login_user['email'], $subject, $message);
[381] Fix | Delete
}
[382] Fix | Delete
[383] Fix | Delete
log_admin_action(array(
[384] Fix | Delete
'type' => 'admin_locked_out',
[385] Fix | Delete
'uid' => (int)$login_user['uid'],
[386] Fix | Delete
'username' => $login_user['username'],
[387] Fix | Delete
)
[388] Fix | Delete
);
[389] Fix | Delete
[390] Fix | Delete
$default_page->show_lockedout();
[391] Fix | Delete
}
[392] Fix | Delete
[393] Fix | Delete
$fail_check = 1;
[394] Fix | Delete
}
[395] Fix | Delete
}
[396] Fix | Delete
else
[397] Fix | Delete
{
[398] Fix | Delete
// No admin session - show message on the login screen
[399] Fix | Delete
if(!isset($mybb->cookies['adminsid']))
[400] Fix | Delete
{
[401] Fix | Delete
$login_message = "";
[402] Fix | Delete
}
[403] Fix | Delete
// Otherwise, check admin session
[404] Fix | Delete
else
[405] Fix | Delete
{
[406] Fix | Delete
$query = $db->simple_select("adminsessions", "*", "sid='".$db->escape_string($mybb->cookies['adminsid'])."'");
[407] Fix | Delete
$admin_session = $db->fetch_array($query);
[408] Fix | Delete
[409] Fix | Delete
// No matching admin session found - show message on login screen
[410] Fix | Delete
if(empty($admin_session) || !$admin_session['sid'])
[411] Fix | Delete
{
[412] Fix | Delete
$login_message = $lang->error_invalid_admin_session;
[413] Fix | Delete
}
[414] Fix | Delete
else
[415] Fix | Delete
{
[416] Fix | Delete
$admin_session['data'] = my_unserialize($admin_session['data']);
[417] Fix | Delete
[418] Fix | Delete
// Fetch the user from the admin session
[419] Fix | Delete
$mybb->user = get_user($admin_session['uid']);
[420] Fix | Delete
[421] Fix | Delete
// Login key has changed - force logout
[422] Fix | Delete
if(!$mybb->user['uid'] || $mybb->user['loginkey'] !== $admin_session['loginkey'])
[423] Fix | Delete
{
[424] Fix | Delete
unset($mybb->user);
[425] Fix | Delete
}
[426] Fix | Delete
else
[427] Fix | Delete
{
[428] Fix | Delete
// Admin CP sessions 2 hours old are expired
[429] Fix | Delete
if($admin_session['lastactive'] < TIME_NOW-7200)
[430] Fix | Delete
{
[431] Fix | Delete
$login_message = $lang->error_admin_session_expired;
[432] Fix | Delete
$db->delete_query("adminsessions", "sid='".$db->escape_string($mybb->cookies['adminsid'])."'");
[433] Fix | Delete
unset($mybb->user);
[434] Fix | Delete
}
[435] Fix | Delete
// If IP matching is set - check IP address against the session IP
[436] Fix | Delete
else if(ADMIN_IP_SEGMENTS > 0 && strpos($ip_address, ':') === false)
[437] Fix | Delete
{
[438] Fix | Delete
$exploded_ip = explode(".", $ip_address);
[439] Fix | Delete
$exploded_admin_ip = explode(".", my_inet_ntop($admin_session['ip']));
[440] Fix | Delete
$matches = 0;
[441] Fix | Delete
$valid_ip = false;
[442] Fix | Delete
for($i = 0; $i < ADMIN_IP_SEGMENTS; ++$i)
[443] Fix | Delete
{
[444] Fix | Delete
if($exploded_ip[$i] == $exploded_admin_ip[$i])
[445] Fix | Delete
{
[446] Fix | Delete
++$matches;
[447] Fix | Delete
}
[448] Fix | Delete
if($matches == ADMIN_IP_SEGMENTS)
[449] Fix | Delete
{
[450] Fix | Delete
$valid_ip = true;
[451] Fix | Delete
break;
[452] Fix | Delete
}
[453] Fix | Delete
}
[454] Fix | Delete
[455] Fix | Delete
// IP doesn't match properly - show message on logon screen
[456] Fix | Delete
if(!$valid_ip)
[457] Fix | Delete
{
[458] Fix | Delete
$login_message = $lang->error_invalid_ip;
[459] Fix | Delete
unset($mybb->user);
[460] Fix | Delete
}
[461] Fix | Delete
}
[462] Fix | Delete
else if(ADMIN_IPV6_SEGMENTS > 0 && strpos($ip_address, ':') !== false)
[463] Fix | Delete
{
[464] Fix | Delete
// Expand IPv6 addresses
[465] Fix | Delete
$hex = unpack("H*hex", my_inet_pton($ip_address));
[466] Fix | Delete
$expanded_ip = substr(preg_replace("/([A-f0-9]{4})/", "$1:", $hex['hex']), 0, -1);
[467] Fix | Delete
$hex_admin = unpack("H*hex", $admin_session['ip']);
[468] Fix | Delete
$expanded_admin_ip = substr(preg_replace("/([A-f0-9]{4})/", "$1:", $hex_admin['hex']), 0, -1);
[469] Fix | Delete
[470] Fix | Delete
$exploded_ip = explode(":", $expanded_ip);
[471] Fix | Delete
$exploded_admin_ip = explode(":", $expanded_admin_ip);
[472] Fix | Delete
$matches = 0;
[473] Fix | Delete
$valid_ip = false;
[474] Fix | Delete
for($i = 0; $i < ADMIN_IPV6_SEGMENTS; ++$i)
[475] Fix | Delete
{
[476] Fix | Delete
if($exploded_ip[$i] == $exploded_admin_ip[$i])
[477] Fix | Delete
{
[478] Fix | Delete
++$matches;
[479] Fix | Delete
}
[480] Fix | Delete
if($matches == ADMIN_IPV6_SEGMENTS)
[481] Fix | Delete
{
[482] Fix | Delete
$valid_ip = true;
[483] Fix | Delete
break;
[484] Fix | Delete
}
[485] Fix | Delete
}
[486] Fix | Delete
[487] Fix | Delete
// IP doesn't match properly - show message on logon screen
[488] Fix | Delete
if(!$valid_ip)
[489] Fix | Delete
{
[490] Fix | Delete
$login_message = $lang->error_invalid_ip;
[491] Fix | Delete
unset($mybb->user);
[492] Fix | Delete
}
[493] Fix | Delete
}
[494] Fix | Delete
}
[495] Fix | Delete
}
[496] Fix | Delete
}
[497] Fix | Delete
}
[498] Fix | Delete
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function