コード例 #1
0
    $db2 = new SmrMySqlDatabase();
    // ********************************
    // *
    // * C r e a t e   S e s s i o n
    // *
    // ********************************
    if (SmrSession::$account_id == 0) {
        if (isset($_REQUEST['loginType'])) {
            require_once LIB . 'Login/SocialLogin.class.inc';
            $socialLogin = new SocialLogin($_REQUEST['loginType']);
            if (!$socialLogin->isValid()) {
                $msg = 'Error validating login.';
                header('Location: ' . URL . '/login.php?msg=' . rawurlencode(htmlspecialchars($msg, ENT_QUOTES)));
                exit;
            }
            $loginType = $socialLogin->getLoginType();
            $authKey = $socialLogin->getUserID();
            $db->query('SELECT account_id,old_account_id FROM account JOIN account_auth USING(account_id)
						WHERE login_type = ' . $db->escapeString($loginType) . '
						   AND auth_key = ' . $db->escapeString($authKey) . ' LIMIT 1');
            if ($db->nextRecord()) {
                // register session
                SmrSession::$account_id = $db->getInt('account_id');
                SmrSession::$old_account_id = $db->getInt('old_account_id');
            } else {
                if ($socialLogin->getEmail() != null) {
                    $db->query('SELECT account_id,old_account_id FROM account ' . 'WHERE email = ' . $db->escapeString($socialLogin->getEmail()) . ' LIMIT 1');
                }
                if ($socialLogin->getEmail() != null && $db->nextRecord()) {
                    //Email already has an account so let's link.
                    $account =& SmrAccount::getAccount($db->getField('account_id'));