Vergleich admin/index.php - 1.8.4 - 1.8.7

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 19Zeile 19
$shutdown_queries = $shutdown_functions = array();

send_page_headers();

$shutdown_queries = $shutdown_functions = array();

send_page_headers();

 

header('X-Frame-Options: SAMEORIGIN');


if(!isset($config['admin_dir']) || !file_exists(MYBB_ROOT.$config['admin_dir']."/inc/class_page.php"))
{


if(!isset($config['admin_dir']) || !file_exists(MYBB_ROOT.$config['admin_dir']."/inc/class_page.php"))
{

Zeile 50Zeile 52

// Load global language phrases
$lang->load("global");


// Load global language phrases
$lang->load("global");

 
$lang->load("messages", true);


if(function_exists('mb_internal_encoding') && !empty($lang->settings['charset']))
{
@mb_internal_encoding($lang->settings['charset']);


if(function_exists('mb_internal_encoding') && !empty($lang->settings['charset']))
{
@mb_internal_encoding($lang->settings['charset']);

}


}


header("Content-type: text/html; charset={$lang->settings['charset']}");

$time = TIME_NOW;

header("Content-type: text/html; charset={$lang->settings['charset']}");

$time = TIME_NOW;

Zeile 107Zeile 110
		if(!$user['uid'])
{
$error = $lang->error_invalid_username;

		if(!$user['uid'])
{
$error = $lang->error_invalid_username;

		}
}

		}
}

	else if($mybb->input['uid'])
{
$user = get_user($mybb->input['uid']);

	else if($mybb->input['uid'])
{
$user = get_user($mybb->input['uid']);

Zeile 117Zeile 120
			$error = $lang->error_invalid_uid;
}
}

			$error = $lang->error_invalid_uid;
}
}





	// Do we have the token? If so let's process it
if($mybb->input['token'] && $user['uid'])
{

	// Do we have the token? If so let's process it
if($mybb->input['token'] && $user['uid'])
{

Zeile 125Zeile 128

// If we're good to go
if($db->fetch_field($query, "num") > 0)


// If we're good to go
if($db->fetch_field($query, "num") > 0)

		{

		{

			$db->delete_query("awaitingactivation", "uid='".(int)$user['uid']."' AND code='".$db->escape_string($mybb->input['token'])."' AND type='l'");
$db->update_query("adminoptions", array('loginlockoutexpiry' => 0, 'loginattempts' => 0), "uid='".(int)$user['uid']."'");

			$db->delete_query("awaitingactivation", "uid='".(int)$user['uid']."' AND code='".$db->escape_string($mybb->input['token'])."' AND type='l'");
$db->update_query("adminoptions", array('loginlockoutexpiry' => 0, 'loginattempts' => 0), "uid='".(int)$user['uid']."'");





			admin_redirect("index.php");

			admin_redirect("index.php");

		}

		}

		else
{
$error = $lang->error_invalid_token;

		else
{
$error = $lang->error_invalid_token;

Zeile 143Zeile 146
{
// We have an adminsid cookie?
if(isset($mybb->cookies['adminsid']))

{
// We have an adminsid cookie?
if(isset($mybb->cookies['adminsid']))

	{

	{

		// Check admin session
$query = $db->simple_select("adminsessions", "sid", "sid='".$db->escape_string($mybb->cookies['adminsid'])."'");
$admin_session = $db->fetch_field($query, 'sid');

// Session found: redirect to index
if($admin_session)

		// Check admin session
$query = $db->simple_select("adminsessions", "sid", "sid='".$db->escape_string($mybb->cookies['adminsid'])."'");
$admin_session = $db->fetch_field($query, 'sid');

// Session found: redirect to index
if($admin_session)

		{

		{

			admin_redirect("index.php");

			admin_redirect("index.php");

		}

		}

	}

	}





	require_once MYBB_ROOT."inc/datahandlers/login.php";
$loginhandler = new LoginDataHandler("get");

// Validate PIN first
if(!empty($config['secret_pin']) && (empty($mybb->input['pin']) || $mybb->input['pin'] != $config['secret_pin']))
{

	require_once MYBB_ROOT."inc/datahandlers/login.php";
$loginhandler = new LoginDataHandler("get");

// Validate PIN first
if(!empty($config['secret_pin']) && (empty($mybb->input['pin']) || $mybb->input['pin'] != $config['secret_pin']))
{

		$default_page->show_login($lang->error_invalid_secret_pin, "error");
















































		$login_user = get_user_by_username($mybb->input['username'], array('fields' => array('email', 'username')));

if($login_user['uid'] > 0)
{
$db->update_query("adminoptions", array("loginattempts" => "loginattempts+1"), "uid='".(int)$login_user['uid']."'", '', true);
}

$loginattempts = login_attempt_check_acp($login_user['uid'], true);

// Have we attempted too many times?
if($loginattempts['loginattempts'] > 0)
{
// Have we set an expiry yet?
if($loginattempts['loginlockoutexpiry'] == 0)
{
$db->update_query("adminoptions", array("loginlockoutexpiry" => TIME_NOW+((int)$mybb->settings['loginattemptstimeout']*60)), "uid='".(int)$login_user['uid']."'");
}

// Did we hit lockout for the first time? Send the unlock email to the administrator
if($loginattempts['loginattempts'] == $mybb->settings['maxloginattempts'])
{
$db->delete_query("awaitingactivation", "uid='".(int)$login_user['uid']."' AND type='l'");
$lockout_array = array(
"uid" => $login_user['uid'],
"dateline" => TIME_NOW,
"code" => random_str(),
"type" => "l"
);
$db->insert_query("awaitingactivation", $lockout_array);

$subject = $lang->sprintf($lang->locked_out_subject, $mybb->settings['bbname']);
$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']);
my_mail($login_user['email'], $subject, $message);
}

log_admin_action(array(
'type' => 'admin_locked_out',
'uid' => (int)$login_user['uid'],
'username' => $login_user['username'],
)
);

$default_page->show_lockedout();
}
else
{
$default_page->show_login($lang->error_invalid_secret_pin, "error");
}

	}

$loginhandler->set_data(array(

	}

$loginhandler->set_data(array(

Zeile 190Zeile 240

$db->delete_query("adminsessions", "uid='{$mybb->user['uid']}'");



$db->delete_query("adminsessions", "uid='{$mybb->user['uid']}'");


		$sid = md5(uniqid(microtime(true), true));

		$sid = md5(random_str(50));


$useragent = $_SERVER['HTTP_USER_AGENT'];


$useragent = $_SERVER['HTTP_USER_AGENT'];

		if(my_strlen($useragent) > 100)

		if(my_strlen($useragent) > 200)

		{

		{

			$useragent = my_substr($useragent, 0, 100);

			$useragent = my_substr($useragent, 0, 200);

		}

// Create a new admin session for this user

		}

// Create a new admin session for this user

Zeile 213Zeile 263
		$admin_session['data'] = array();

// Only reset the loginattempts when we're really logged in and the user doesn't need to enter a 2fa code

		$admin_session['data'] = array();

// Only reset the loginattempts when we're really logged in and the user doesn't need to enter a 2fa code

		$query = $db->simple_select("adminoptions", "2fasecret", "uid='{$mybb->user['uid']}'");

		$query = $db->simple_select("adminoptions", "authsecret", "uid='{$mybb->user['uid']}'");

		$admin_options = $db->fetch_array($query);

		$admin_options = $db->fetch_array($query);

		if(empty($admin_options['2fasecret']))

		if(empty($admin_options['authsecret']))

		{
$db->update_query("adminoptions", array("loginattempts" => 0, "loginlockoutexpiry" => 0), "uid='{$mybb->user['uid']}'");
}

		{
$db->update_query("adminoptions", array("loginattempts" => 0, "loginlockoutexpiry" => 0), "uid='{$mybb->user['uid']}'");
}

Zeile 425Zeile 475
		$cp_language = $admin_options['cplanguage'];
$lang->set_language($cp_language, "admin");
$lang->load("global"); // Reload global language vars

		$cp_language = $admin_options['cplanguage'];
$lang->set_language($cp_language, "admin");
$lang->load("global"); // Reload global language vars

 
		$lang->load("messages", true);

	}

if(!empty($admin_options['cpstyle']) && file_exists(MYBB_ADMIN_DIR."/styles/{$admin_options['cpstyle']}/main.css"))

	}

if(!empty($admin_options['cpstyle']) && file_exists(MYBB_ADMIN_DIR."/styles/{$admin_options['cpstyle']}/main.css"))

Zeile 531Zeile 582
	require_once MYBB_ROOT."inc/3rdparty/2fa/GoogleAuthenticator.php";
$auth = new PHPGangsta_GoogleAuthenticator;


	require_once MYBB_ROOT."inc/3rdparty/2fa/GoogleAuthenticator.php";
$auth = new PHPGangsta_GoogleAuthenticator;


	$test = $auth->verifyCode($admin_options['2fasecret'], $mybb->get_input('code'));

	$test = $auth->verifyCode($admin_options['authsecret'], $mybb->get_input('code'));


// Either the code was okay or it was a recovery code
if($test === true || $recovery === true)


// Either the code was okay or it was a recovery code
if($test === true || $recovery === true)

Zeile 597Zeile 648
}

// Show our 2FA page

}

// Show our 2FA page

if(!empty($admin_options['2fasecret']) && $admin_session['authenticated'] != 1)

if(!empty($admin_options['authsecret']) && $admin_session['authenticated'] != 1)

{
$page->show_2fa();
}

{
$page->show_2fa();
}