Example #1
0
$openid = new LightOpenID($config['core']['domain']);
if (!$openid->mode) {
    if (isset($_GET['login'])) {
        $_SESSION["persist_login"] = true;
        $openid->identity = 'http://steamcommunity.com/openid';
        $openid->returnUrl = $config['core']['uri'] . '/?return';
        header('Location: ' . $openid->authUrl());
    }
} else {
    if ($openid->validate()) {
        $id = $openid->identity;
        $ptn = "/^http:\\/\\/steamcommunity\\.com\\/openid\\/id\\/(7[0-9]{15,25}+)\$/";
        preg_match($ptn, $id, $matches);
        $_SESSION["steamid"] = $matches[1];
        if (isset($_SESSION["persist_login"])) {
            Application::generateToken($_SESSION["steamid"]);
        }
    }
}
if (isset($_COOKIE['authtoken']) && !isset($_SESSION['steamid'])) {
    $steamid_login = Application::checkLogin($_COOKIE['authtoken']);
    if ($steamid_login) {
        $_SESSION["steamid"] = $steamid_login;
    }
}
// check session privileges
if (isset($_SESSION['steamid'])) {
    $_SESSION['admin'] = Admin::checkAdminPrivilege($_SESSION['steamid']);
    // handle friends list
    $f = new Friends();
    $friends = $f->getFriendsForSteamId($_SESSION['steamid']);