PHPFusion\Authenticate::setAdminLogin PHP Method

setAdminLogin() public static method

public static setAdminLogin ( )
    public static function setAdminLogin()
    {
        global $locale;
        if (isset($_GET['logout'])) {
            self::expireAdminCookie();
            $user = fusion_get_userdata("user_id");
            if (!empty($user)) {
                redirect(BASEDIR . "index.php");
            }
        }
        if (isset($_POST['admin_password'])) {
            $admin_password = form_sanitizer($_POST['admin_password'], '', 'admin_password');
            if (\PHPFusion\Authenticate::validateAuthAdmin($admin_password)) {
                if (Authenticate::setAdminCookie($admin_password)) {
                    unset($_SESSION['notices']);
                    redirect(FUSION_REQUEST);
                } else {
                    addNotice("danger", $locale['cookie_error'], $locale['cookie_error_description']);
                }
            } else {
                addNotice("danger", $locale['password_invalid'], $locale['password_invalid_description']);
            }
        }
        if (defined('ADMIN_PANEL') && !isset($_COOKIE[COOKIE_PREFIX . "admin"])) {
            setNotice("danger", $locale['cookie_title'], $locale['cookie_description']);
        }
    }

Usage Example

Example #1
0
                        unset($valid_mimetype);
                    } else {
                        if ($mime_types[$extension] != $each['type']) {
                            die('Prevented an unwanted file upload attempt!');
                        }
                    }
                }
                unset($file_info, $extension);
            }
        }
        unset($mime_types);
    }
}
$defender = new defender();
// Set admin login procedures
Authenticate::setAdminLogin();
$defender->debug_notice = FALSE;
// turn this off after beta.
$defender->sniff_token();
$dynamic = new dynamics();
$dynamic->boot();
$fusion_page_head_tags =& \PHPFusion\OutputHandler::$pageHeadTags;
$fusion_page_footer_tags =& \PHPFusion\OutputHandler::$pageFooterTags;
$fusion_jquery_tags =& \PHPFusion\OutputHandler::$jqueryTags;
// Set theme using $_GET as well.
// Set theme
if ($userdata['user_level'] == USER_LEVEL_SUPER_ADMIN && isset($_GET['themes']) && theme_exists($_GET['themes'])) {
    $newUserTheme = array("user_id" => $userdata['user_id'], "user_theme" => stripinput($_GET['themes']));
    dbquery_insert(DB_USERS, $newUserTheme, "update");
    redirect(clean_request("", array("themes"), FALSE));
}