Vergleich admin/modules/home/preferences.php - 1.8.0 - 1.8.4

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 18Zeile 18

$plugins->run_hooks("admin_home_preferences_begin");



$plugins->run_hooks("admin_home_preferences_begin");


 
if($mybb->input['action'] == "recovery_codes")
{
$page->add_breadcrumb_item($lang->recovery_codes, "index.php?module=home-preferences&action=recovery_codes");

// First: regenerate the codes
$codes = generate_recovery_codes();
$db->update_query("adminoptions", array("recovery_codes" => $db->escape_string(my_serialize($codes))), "uid='{$mybb->user['uid']}'");

// And now display them
$page->output_header($lang->recovery_codes);

$table = new Table;
$table->construct_header($lang->recovery_codes);

$table->construct_cell($lang->recovery_codes_warning);
$table->construct_row();

$table->construct_cell(implode("<br />", $codes));
$table->construct_row();

$table->output($lang->recovery_codes);

$page->output_footer();
}

if(!$mybb->input['action'])
{

if(!$mybb->input['action'])
{

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


	$plugins->run_hooks("admin_home_preferences_start");

	$plugins->run_hooks("admin_home_preferences_start");





	if($mybb->request_method == "post")
{

	if($mybb->request_method == "post")
{

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

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

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

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

 

$secret = $adminopts['2fasecret'];
// Was the option changed? empty = disabled so ==
if($mybb->input['2fa'] == empty($secret))
{
// 2FA was enabled -> create secret and log
if($mybb->input['2fa'])
{
$secret = $auth->createSecret();
// We don't want to close this session now
$db->update_query("adminsessions", array("authenticated" => 1), "sid='".$db->escape_string($mybb->cookies['adminsid'])."'");
log_admin_action("enabled");
}
// 2FA was disabled -> clear secret
else
{
$secret = "";
$adminopts['recovery_codes'] = "";
log_admin_action("disabled");
}
}


$sqlarray = array(
"notes" => $db->escape_string($mybb->input['notes']),


$sqlarray = array(
"notes" => $db->escape_string($mybb->input['notes']),

Zeile 34Zeile 82
			"permissions" => $db->escape_string($adminopts['permissions']),
"defaultviews" => $db->escape_string($adminopts['defaultviews']),
"uid" => $mybb->user['uid'],

			"permissions" => $db->escape_string($adminopts['permissions']),
"defaultviews" => $db->escape_string($adminopts['defaultviews']),
"uid" => $mybb->user['uid'],

			"codepress" => (int)$mybb->input['codepress'], // It's actually CodeMirror but for compatibility purposes lets leave it codepress



			"codepress" => $mybb->get_input('codepress', MyBB::INPUT_INT), // It's actually CodeMirror but for compatibility purposes lets leave it codepress
"2fasecret" => $db->escape_string($secret),
"recovery_codes" => $db->escape_string($adminopts['recovery_codes']),

		);

$db->replace_query("adminoptions", $sqlarray, "uid");

$plugins->run_hooks("admin_home_preferences_start_commit");

		);

$db->replace_query("adminoptions", $sqlarray, "uid");

$plugins->run_hooks("admin_home_preferences_start_commit");





		flash_message($lang->success_preferences_updated, 'success');
admin_redirect("index.php?module=home-preferences");
}

		flash_message($lang->success_preferences_updated, 'success');
admin_redirect("index.php?module=home-preferences");
}

Zeile 55Zeile 105

$page->output_nav_tabs($sub_tabs, 'preferences');



$page->output_nav_tabs($sub_tabs, 'preferences');


	$query = $db->simple_select("adminoptions", "notes, cpstyle, cplanguage, codepress", "uid='".$mybb->user['uid']."'", array('limit' => 1));

	$query = $db->simple_select("adminoptions", "notes, cpstyle, cplanguage, codepress, 2fasecret", "uid='".$mybb->user['uid']."'", array('limit' => 1));

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

$form = new Form("index.php?module=home-preferences", "post");

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

$form = new Form("index.php?module=home-preferences", "post");

Zeile 73Zeile 123
	ksort($folders);
$setting_code = $form->generate_select_box("cpstyle", $folders, $admin_options['cpstyle']);


	ksort($folders);
$setting_code = $form->generate_select_box("cpstyle", $folders, $admin_options['cpstyle']);


	$languages = $lang->get_languages(1);

	$languages = array_merge(array('' => $lang->use_default), $lang->get_languages(1));

	$language_code = $form->generate_select_box("cplanguage", $languages, $admin_options['cplanguage']);

$table = new Table;

	$language_code = $form->generate_select_box("cplanguage", $languages, $admin_options['cplanguage']);

$table = new Table;

Zeile 87Zeile 137

$table->construct_cell("<strong>{$lang->codemirror}</strong><br /><small>{$lang->use_codemirror_desc}</small><br /><br />".$form->generate_on_off_radio('codepress', $admin_options['codepress']));
$table->construct_row();


$table->construct_cell("<strong>{$lang->codemirror}</strong><br /><small>{$lang->use_codemirror_desc}</small><br /><br />".$form->generate_on_off_radio('codepress', $admin_options['codepress']));
$table->construct_row();

 

// If 2FA is enabled we need to display a link to the recovery codes page
if(!empty($admin_options['2fasecret']))
{
$lang->use_2fa_desc .= "<br />".$lang->recovery_codes_desc." ".$lang->recovery_codes_warning;
}

$table->construct_cell("<strong>{$lang->my2fa}</strong><br /><small>{$lang->use_2fa_desc}</small><br /><br />".$form->generate_on_off_radio('2fa', (int)!empty($admin_options['2fasecret'])));
$table->construct_row();

if(!empty($admin_options['2fasecret']))
{
$qr = $auth->getQRCodeGoogleUrl($mybb->user['username']."@".str_replace(" ", "", $mybb->settings['bbname']), $admin_options['2fasecret']);
$table->construct_cell("<strong>{$lang->my2fa_qr}</strong><br /><img src=\"{$qr}\"");
$table->construct_row();
}


$table->output($lang->preferences);



$table->output($lang->preferences);


Zeile 103Zeile 169
	$form->end();

$page->output_footer();

	$form->end();

$page->output_footer();

 
}

function generate_recovery_codes()
{
$t = array();
while(count($t) < 10)
{
$g = random_str(6);
if(!in_array($g, $t))
{
$t[] = $g;
}
}
return $t;

}

}