/**
  * {@inheritdoc}
  */
 function loginFinish()
 {
     # if user don't grant access of their data to your site, halt with an Exception
     if ($this->api->mode == 'cancel') {
         throw new Exception("Authentication failed! User has canceled authentication!", 5);
     }
     # if something goes wrong
     if (!$this->api->validate()) {
         throw new Exception("Authentication failed. Invalid request received!", 5);
     }
     # fetch received user data
     $response = $this->api->getAttributes();
     # store the user profile
     $this->user->profile->identifier = $this->api->identity;
     $this->user->profile->firstName = array_key_exists("namePerson/first", $response) ? $response["namePerson/first"] : "";
     $this->user->profile->lastName = array_key_exists("namePerson/last", $response) ? $response["namePerson/last"] : "";
     $this->user->profile->displayName = array_key_exists("namePerson", $response) ? $response["namePerson"] : "";
     $this->user->profile->email = array_key_exists("contact/email", $response) ? $response["contact/email"] : "";
     $this->user->profile->language = array_key_exists("pref/language", $response) ? $response["pref/language"] : "";
     $this->user->profile->country = array_key_exists("contact/country/home", $response) ? $response["contact/country/home"] : "";
     $this->user->profile->zip = array_key_exists("contact/postalCode/home", $response) ? $response["contact/postalCode/home"] : "";
     $this->user->profile->gender = array_key_exists("person/gender", $response) ? $response["person/gender"] : "";
     $this->user->profile->photoURL = array_key_exists("media/image/default", $response) ? $response["media/image/default"] : "";
     $this->user->profile->birthDay = array_key_exists("birthDate/birthDay", $response) ? $response["birthDate/birthDay"] : "";
     $this->user->profile->birthMonth = array_key_exists("birthDate/birthMonth", $response) ? $response["birthDate/birthMonth"] : "";
     $this->user->profile->birthYear = array_key_exists("birthDate/birthDate", $response) ? $response["birthDate/birthDate"] : "";
     if (isset($response['namePerson/friendly']) && !empty($response['namePerson/friendly']) && !$this->user->profile->displayName) {
         $this->user->profile->displayName = $response["namePerson/friendly"];
     }
     if (isset($response['birthDate']) && !empty($response['birthDate']) && !$this->user->profile->birthDay) {
         list($birthday_year, $birthday_month, $birthday_day) = $response['birthDate'];
         $this->user->profile->birthDay = (int) $birthday_day;
         $this->user->profile->birthMonth = (int) $birthday_month;
         $this->user->profile->birthYear = (int) $birthday_year;
     }
     if (!$this->user->profile->displayName) {
         $this->user->profile->displayName = trim($this->user->profile->firstName . " " . $this->user->profile->lastName);
     }
     if ($this->user->profile->gender == "f") {
         $this->user->profile->gender = "female";
     }
     if ($this->user->profile->gender == "m") {
         $this->user->profile->gender = "male";
     }
     // set user as logged in
     $this->setUserConnected();
     // with openid providers we get the user profile only once, so store it
     Hybrid_Auth::storage()->set("hauth_session.{$this->providerId}.user", $this->user);
 }
function steamOauth()
{
    $openid = new LightOpenID(SB_HOST);
    if (!$openid->mode) {
        $openid->identity = 'http://steamcommunity.com/openid';
        header("Location: " . $openid->authUrl());
        exit;
    } elseif ($openid->mode == 'cancel') {
        // User canceled auth.
        return false;
    } else {
        if ($openid->validate()) {
            $id = $openid->identity;
            $ptn = "/^http:\\/\\/steamcommunity\\.com\\/openid\\/id\\/(7[0-9]{15,25}+)\$/";
            preg_match($ptn, $id, $matches);
            if (!empty($matches[1])) {
                return $matches[1];
            }
            return null;
        } else {
            // Not valid
            return false;
        }
    }
}
 /**
  * 處理 OpenID 登入
  * GET login/openid
  */
 public function openIDLogin()
 {
     try {
         // $openid = new LightOpenID('my-host.example.org');
         $openid = new LightOpenID('http://10.231.87.100:81/');
         if (!$openid->mode) {
             // 第一步驟
             // 設定
             $openid->identity = 'http://openid.ntpc.edu.tw/';
             // 要求取得之資料欄位
             $openid->required = array('namePerson', 'pref/timezone');
             // 會先到 輸入帳密登入頁面
             // 再到 同意 / 不同意 授權頁面
             return Redirect::to($openid->authUrl());
         } elseif ($openid->mode == 'cancel') {
             // 使用者取消(不同意授權)
             return Redirect::to('/');
             // 導回首頁
         } else {
             // 使用者同意授權
             // 此時 $openid->mode = "id_res"
             if ($openid->validate()) {
                 // 通過驗證,也同意授權
                 // 取得資料
                 $attr = $openid->getAttributes();
                 // return dd($attr);
                 // 將取得之資料帶到下一個步驟進行處理
                 // 要有相對應的路由設定
                 return Redirect::action('AuthController@showUserData', ['user' => $attr]);
             }
         }
     } catch (ErrorException $e) {
         echo $e->getMessage();
     }
 }
Beispiel #4
0
function steamlogin()
{
    try {
        // Change 'localhost' to your domain name.
        $openid = new LightOpenID('example.com');
        if (!$openid->mode) {
            if (isset($_GET['login'])) {
                $openid->identity = 'http://steamcommunity.com/openid';
                header('Location: ' . $openid->authUrl());
            }
            echo "<form action=\"?login\" method=\"post\"> <input type=\"image\" src=\"http://cdn.steamcommunity.com/public/images/signinthroughsteam/sits_large_border.png\"></form>";
        } elseif ($openid->mode == 'cancel') {
            echo 'User has canceled authentication!';
        } else {
            if ($openid->validate()) {
                $id = $openid->identity;
                $ptn = "/^http:\\/\\/steamcommunity\\.com\\/openid\\/id\\/(7[0-9]{15,25}+)\$/";
                preg_match($ptn, $id, $matches);
                session_start();
                $_SESSION['steamid'] = $matches[1];
                header('Location: ' . $_SERVER['REQUEST_URI']);
            } else {
                echo "User is not logged in.\n";
            }
        }
    } catch (ErrorException $e) {
        echo $e->getMessage();
    }
}
 public static function steamLogin()
 {
     if (!isset($_SESSION['steamId'])) {
         $openid = new LightOpenID('http://192.168.13.37/?/LoginRedirect/steamLogin');
         if (!$openid->mode && isset($_GET['login'])) {
             $openid->identity = 'http://steamcommunity.com/openid/?l=english';
             // This is forcing english because it has a weird habit of selecting a random language otherwise
             header('Location: ' . $openid->authUrl());
         } elseif ($openid->mode == 'cancel') {
             echo 'User has canceled authentication!';
         } elseif ($openid->validate()) {
             $id = $openid->identity;
             // identity is something like: http://steamcommunity.com/openid/id/76561197960435530
             // we only care about the unique account ID at the end of the URL.
             $ptn = "/^http:\\/\\/steamcommunity\\.com\\/openid\\/id\\/(7[0-9]{15,25}+)\$/";
             preg_match($ptn, $id, $matches);
             $_SESSION['steamId'] = $matches[1];
             // Looks like we have everything we need, so lets send him to userlanding
             return UserLanding::currentUserCheck();
         } else {
             echo "<a href='http://192.168.13.37/?/LoginRedirect/steamLogin'>Try again</a>";
         }
     } else {
         return UserLanding::currentUserCheck();
     }
 }
Beispiel #6
0
 public static function getUserEmail()
 {
     $encrypt_content = isset($_COOKIE[self::COOKIE_ID]) ? trim($_COOKIE[self::COOKIE_ID]) : null;
     if ($encrypt_content) {
         $content = self::decrypt($encrypt_content);
         list($email, $userName) = explode(self::USER_EMAIL_SPLITTER, $content);
         return array('email' => $email, 'userName' => $userName);
     }
     $openid = new LightOpenID($_SERVER['HTTP_HOST']);
     if (!$openid->mode) {
         $openid->identity = 'https://www.google.com/accounts/o8/id';
         $openid->required = array('contact/email', 'namePerson/first', 'namePerson/last');
         header('Location: ' . $openid->authUrl());
         die;
     } elseif ($openid->mode != 'cancel' && $openid->validate()) {
         $data = $openid->getAttributes();
         $email = $data['contact/email'];
         $userName = $data['namePerson/last'] . $data['namePerson/first'];
         $content = $email . self::USER_EMAIL_SPLITTER . $userName;
         $encrypt_content = self::encrypt($content);
         $_COOKIE[self::COOKIE_ID] = $encrypt_content;
         $expire = self::COOKIE_EXPIRE_TIME + time();
         setcookie(self::COOKIE_ID, $encrypt_content, $expire);
         return array('email' => $email, 'userName' => $userName);
     }
     return array();
 }
 /**
  * Service provider returns the user here.
  */
 public function returningProvider()
 {
     $openid = new LightOpenID('renshuu.paazmaya.com');
     if ($openid->mode) {
         $attr = $openid->getAttributes();
         if ($openid->validate()) {
             $_SESSION['email'] = $attr['contact/email'];
             // Not always set, specially Google, even if required...
             $_SESSION['username'] = isset($attr['namePerson']) ? $attr['namePerson'] : $attr['contact/email'];
             $_SESSION['identity'] = $openid->identity;
             // Check if the email has already existing access rights
             $sql = 'SELECT title, email, access FROM renshuu_user WHERE email = \'' . $_SESSION['email'] . '\'';
             $run = $this->pdo->query($sql);
             if ($run->rowCount() > 0) {
                 $res = $run->fetch(PDO::FETCH_ASSOC);
                 // So there was data, just login and use the site
                 $_SESSION['username'] = $res['title'];
                 $_SESSION['access'] = intval($res['access']);
                 // use as binary
             } else {
                 // Insert
                 $sql = 'INSERT INTO renshuu_user (title, email, identity, modified, access) VALUES (\'' . $attr['namePerson'] . '\', \'' . $attr['contact/email'] . '\', \'' . $openid->identity . '\', ' . time() . ', 1)';
                 $run = $this->pdo->query($sql);
                 $_SESSION['access'] = 1;
                 // Should you send an email telling about new user?
             }
         }
         header('Location: http://' . $_SERVER['HTTP_HOST']);
     }
 }
Beispiel #8
0
function steamlogin()
{
    try {
        require "settings.php";
        $openid = new LightOpenID($steamauth['domainname']);
        $button['small'] = "small";
        $button['large_no'] = "large_noborder";
        $button['large'] = "large_border";
        $button = $button[$steamauth['buttonstyle']];
        if (!$openid->mode) {
            if (isset($_GET['login'])) {
                $openid->identity = 'http://steamcommunity.com/openid';
                header('Location: ' . $openid->authUrl());
            }
            echo "<form action=\"?login\" method=\"post\"> <input class=\"design_login\" type=\"image\" src=\"img/Login.png\"></form>";
        } elseif ($openid->mode == 'cancel') {
            echo 'User has canceled authentication!';
        } 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($steamauth['loginpage'])) {
                    header('Location: index.php');
                }
            } else {
                echo "User is not logged in.\n";
            }
        }
    } catch (ErrorException $e) {
        echo $e->getMessage();
    }
}
 public function register(Application $app)
 {
     $app->before(function () use($app) {
         $app['session']->start();
         if ($app['request']->get('_route') == 'logout') {
             return;
         }
         if (!$app['session']->has('username')) {
             $openid = new \LightOpenID($_SERVER['SERVER_NAME']);
             if (!$openid->mode) {
                 $openid->identity = 'https://www.google.com/accounts/o8/id';
                 $openid->required = array('email' => 'contact/email', 'firstname' => 'namePerson/first', 'lastname' => 'namePerson/last');
                 return $app->redirect($openid->authUrl());
             } else {
                 if ($openid->validate()) {
                     $attributes = $openid->getAttributes();
                     $app['session']->set('username', $attributes['contact/email']);
                     $app['session']->set('fullname', $attributes['namePerson/first'] . ' ' . $attributes['namePerson/last']);
                 }
             }
         }
         $app['twig']->addGlobal('username', $app['session']->get('username'));
         $app['twig']->addGlobal('fullname', $app['session']->get('fullname'));
         if (isset($app['auth']) && !$app['auth']($app['session']->get('username'))) {
             $app['session']->remove('username');
             $app['session']->remove('fullname');
             return new Response($app['twig']->render('forbidden.html.twig'), 403);
         }
     });
 }
 public function prepare()
 {
     global $session;
     $this->template = '';
     if ($session->valid()) {
         $this->template = 'openid_success';
         return;
     }
     global $settings, $session;
     try {
         if (!isset($_GET['openid_mode'])) {
             $openid = new LightOpenID();
             $openid->identity = $settings['openid']['provider'];
             header('Location: ' . $openid->authUrl());
         } elseif ($_GET['openid_mode'] == 'cancel') {
             $this->template = 'openid_error';
         } else {
             $openid = new LightOpenID();
             if ($openid->validate()) {
                 $identity = $openid->identity;
                 $session->openid_login($identity);
                 //echo $identity;
                 //var_dump($session);
                 $this->template = 'openid_success';
                 global $SITE;
                 $SITE['head'] .= '<meta http-equiv="refresh" content="3;url=//tf2stats.net">';
             } else {
                 $this->template = 'openid_error';
             }
         }
     } catch (ErrorException $e) {
         $this->template = 'openid_error';
     }
 }
 public function getLogin()
 {
     if (!Auth::guest()) {
         return Redirect::action('HomeController@getIndex');
     }
     try {
         # Change 'localhost' to your domain name.
         $openid = new LightOpenID($_SERVER['HTTP_HOST']);
         if (!$openid->mode) {
             $openid->identity = 'http://steamcommunity.com/openid';
             return Redirect::to($openid->authUrl());
         } elseif ($openid->mode == 'cancel') {
             echo 'User has canceled authentication!';
         } else {
             if ($openid->validate()) {
                 $id = $openid->identity;
                 // identity is something like: http://steamcommunity.com/openid/id/76561197994761333
                 // we only care about the unique account ID at the end of the URL.
                 $ptn = "/^http:\\/\\/steamcommunity\\.com\\/openid\\/id\\/(7[0-9]{15,25}+)\$/";
                 preg_match($ptn, $id, $matches);
                 $steamid = $matches[1];
                 $this->fetch_username($steamid);
                 $this->fetch_backpack($steamid);
                 Auth::loginUsingId($steamid, true);
                 return Redirect::action('HomeController@getIndex');
             } else {
                 echo "User is not logged in.\n";
             }
         }
     } catch (ErrorException $e) {
         echo $e->getMessage();
     }
 }
 /**
  * 向 OpenID Provider 驗證資料是否正確
  * 若正確則擷取資料
  * 
  * @return bool
  */
 public function validate()
 {
     if (parent::validate()) {
         $this->fetchUserDataFromOpenID();
         return true;
     }
     return false;
 }
Beispiel #13
0
function index_openid_callback()
{
    $openid = new LightOpenID();
    if ($openid->validate()) {
        return index_api_login($_GET['openid_identity']);
    } else {
        return index_login();
    }
}
Beispiel #14
0
 static function LoadPage($PageName, $Wrapper = true)
 {
     if (KERNEL::IsValidPage($PageName) == false) {
         KERNEL::OnError("Attempt to load invalid page '" . $PageName . "'");
     }
     if (!is_null(KERNEL::$Pages[$PageName][2])) {
         $Result = call_user_func(KERNEL::$Pages[$PageName][2]);
         if ($Result !== true) {
             KERNEL::OnError("Access Denied - " . $Result);
             die("");
             // Force cancel just incase
         }
     }
     if ($Wrapper) {
         global $GMDConfig;
         $OpenID = new LightOpenID($GMDConfig["Domain"]);
         if ($OpenID->validate()) {
             $ID = $OpenID->identity;
             $URL_Parts = explode("/", $ID);
             // Get their SteamID
             $CommunityID = $URL_Parts[sizeof($URL_Parts) - 1];
             $SteamID = CommunityToSteam($CommunityID);
             // Try and authenticate them
             $User = User::GetByField("User", "SteamID", $SteamID);
             if ($User->IsReal()) {
                 $User->AuthToUser();
             } else {
                 User::RegisterUser($SteamID, $_SERVER['REMOTE_ADDR'])->AuthToUser();
             }
             KERNEL::HardNavigate("home");
         } elseif ($_GET["page"] == "login") {
             if (User::$ActiveUser != false) {
                 if (isset($_GET["logout"])) {
                     User::Logout();
                 }
                 KERNEL::HardNavigate("home");
             } else {
                 $OpenID->identity = 'http://steamcommunity.com/openid';
                 header('Location: ' . $OpenID->authUrl());
             }
         }
         LightOpenID::revalidate();
     }
     global $OutputData;
     $OutputData = "";
     if ($Wrapper) {
         require "includes/util/header.php";
     }
     require "pages/" . $PageName . "/_process.php";
     require "pages/" . $PageName . "/_display.php";
     echo $OutputData;
     if ($Wrapper) {
         require "includes/util/footer.php";
     }
 }
Beispiel #15
0
function LoginButton()
{
    if (isset($_POST['logout'])) {
        unset($_POST);
        session_destroy();
        return 'Logged out.';
    }
    if (!isset($_SESSION['sid']) && isset($_SERVER['REQUEST_METHOD'])) {
        try {
            // Change 'localhost' to your domain name.
            $openid = new LightOpenID('http://endgame.tf');
            //$openid = new LightOpenID('http://76.164.223.234');
            //elseif ( is_v4() ) $openid = new LightOpenID( 'http://65.111.166.150' );
            if (!$openid->mode) {
                if (isset($_GET['login'])) {
                    $openid->identity = 'http://steamcommunity.com/openid';
                    header('Location: ' . $openid->authUrl());
                }
                return '<form action="?login" method="post"><input class="steamlogin" type="image" src="img/sits.gif" alt="Login With Steam"></form>';
            } elseif ($openid->mode == 'cancel') {
                return 'User has canceled authentication!';
            } else {
                if ($openid->validate()) {
                    $id = $openid->identity;
                    // identity is something like: http://steamcommunity.com/openid/id/76561197994761333
                    // we only care about the unique account ID at the end of the URL.
                    $ptn = "/^http:\\/\\/steamcommunity\\.com\\/openid\\/id\\/(7[0-9]{15,25}+)\$/";
                    preg_match($ptn, $id, $matches);
                    if (strlen($matches[1]) < 16) {
                        return 'Invalid steamid.';
                    }
                    //echo "User is logged in (steamID: $matches[1])\n";
                    //session_start();
                    database_login((int) $matches[1]);
                    $_SESSION['sid'] = (int) $matches[1];
                    //This is where the user's steamID is set, IMPORTANT.
                    if (isset($_SESSION['sid']) && is_numeric($_SESSION['sid']) == TRUE && !isset($_SESSION['currentUserName'])) {
                        $playerURL = "http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=" . AKey() . "&steamids=" . $_SESSION['sid'] . "&format=json";
                        $playerData = json_decode(get_data($playerURL), true);
                        $_SESSION['currentUserName'] = $playerData['response']['players'][0]['personaname'];
                        //addUser( $_SESSION['sid'] );
                        header("Location: " . "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']);
                    }
                } else {
                    return 'User is not logged in.';
                }
            }
        } catch (ErrorException $e) {
            return $e->getMessage();
        }
    } else {
        return '<form action="' . $_SERVER['PHP_SELF'] . '" method="post"><INPUT TYPE = "Submit" Name = "logout" VALUE = "Log out"></form>';
    }
}
 /**
  * OpenID プロバイダから返却されたパラメータを受け取ります。
  * 
  * @return bool パラメータを正しく解析できた場合に TRUE を返します。
  *   リクエストの妥当性をチェックする場合は {@link isAuthenticated()} メソッドを使用して下さい。
  * @author Naomichi Yamakita <*****@*****.**>
  */
 public function receiveData()
 {
     $this->_attributeExchange = new Mars_OpenIDAttributeExchange($this->_openId->getAttributes());
     // レスポンスは GET、または POST で返される
     $data = $this->request->getParameter('openid_mode');
     if (null_or_empty($data)) {
         return FALSE;
     }
     if ($this->request->getQuery('openid_mode') != 'cancel' && $this->_openId->validate()) {
         $this->_identity = $this->request->getParameter('openid_identity');
     }
     return TRUE;
 }
 /**
  * @Route("/loginSteam")
  * @Method("GET")
  *
  * @param Request $request
  * @return RedirectResponse
  */
 public function loginSteamOpenIdAction(Request $request)
 {
     $steamUrl = $this->container->getParameter('steam_open_id_api')['url'];
     $backUrl = $this->generateUrl('avaw_steam_security_loginsteamopenid', array(), UrlGeneratorInterface::ABSOLUTE_URL);
     $steamOpenIdUrl = null;
     /** @var \Symfony\Component\HttpFoundation\Session\SessionInterface $session */
     $session = $request->getSession();
     $openId = new \LightOpenID($backUrl);
     if (!$openId->mode) {
         if ($request->query->get('login')) {
             $openId->identity = $steamUrl;
             return new RedirectResponse($openId->authUrl());
         }
         if (null !== $session->get('SteamId64')) {
             $this->redirectToRoute('avaw_steam_default_index');
         }
     } elseif ($openId->mode = 'id_res') {
         if (null === $session->get('SteamId64')) {
             if ($openId->validate()) {
                 $steamOpenIdUrl = $openId->identity;
             }
             if (null !== $steamOpenIdUrl) {
                 $steamId = str_replace($steamUrl . '/id/', '', $steamOpenIdUrl);
                 // Get info about steam user
                 /** @var SteamApi $steamApi */
                 $steamApi = $this->get('avaw.steam.http.steam_api');
                 $player = $steamApi->GetPlayerSummaries($steamId)[0];
                 // Check if user exist
                 /** @var SteamUserRepository $repository */
                 $repository = $this->getDoctrine()->getRepository('AvawSteamBundle:SteamUser');
                 /** @var SteamUser $steamUser */
                 $steamUser = $repository->findOneBy(array('steamId' => $steamId));
                 $em = $this->getDoctrine()->getManager();
                 if (null !== $steamUser) {
                     // Update entity
                     $steamUser->update($player);
                 } else {
                     // Prepare new entity
                     $em->persist($player);
                 }
                 $em->flush();
                 // Session
                 $session->set('SteamId64', $steamId);
             }
             return $this->redirect($this->generateUrl('home'));
         }
     }
     return $this->redirect($this->generateUrl('home'));
 }
Beispiel #18
0
 /**
  * Ask for OpenID identifer
  */
 public function request()
 {
     if (!$this->openid->mode) {
         $this->openid->identity = 'http://steamcommunity.com/openid';
         header('Location: ' . $this->openid->authUrl());
         exit;
     } else {
         if ($this->openid->mode == 'cancel') {
             $this->errorCallback(array('provider' => 'Steam', 'code' => 'cancel_authentication', 'message' => 'User has canceled authentication'));
         } else {
             if (!$this->openid->validate()) {
                 $this->errorCallback(array('provider' => 'Steam', 'code' => 'not_logged_in', 'message' => 'User has not logged in'));
             } else {
                 $steamId = '';
                 if (preg_match('/http:\\/\\/steamcommunity.com\\/openid\\/id\\/(\\d+)/', $this->openid->data['openid_identity'], $matches)) {
                     $steamId = $matches[1];
                 }
                 $userInfo = $this->userInfo($steamId);
                 $this->auth = array('provider' => 'Steam', 'uid' => $steamId, 'info' => $userInfo, 'credentials' => $this->openid->getAttributes(), 'raw' => $userInfo);
                 $this->callback();
             }
         }
     }
 }
 public function login()
 {
     $openId = new \LightOpenID($this->_getRequest()->getUri());
     if (!$openId->mode) {
         $openId->identity = 'https://steamcommunity.com/openid';
         return RedirectResponse::create($openId->authUrl());
     } else {
         if ($openId->validate()) {
             $id = basename($openId->identity);
             Session::set(Session::USER_ID, $id);
             return RedirectResponse::create('/users/' . $id);
         }
         return 'error';
     }
 }
Beispiel #20
0
function steamlogin()
{
    try {
        require "settings.php";
        $openid = new LightOpenID($steamauth['domainname']);
        $button['small'] = "small";
        $button['large_no'] = "large_noborder";
        $button['large'] = "large_border";
        $button = $button[$steamauth['buttonstyle']];
        if (!$openid->mode) {
            if (isset($_GET['login'])) {
                $openid->identity = 'http://steamcommunity.com/openid';
                header('Location: ' . $openid->authUrl());
            }
            return "<form action=\"?login\" method=\"post\" title=\"Usa tu cuenta de Steam para hacer uso de ciertas funcionalidades de la página, como realizar comentarios o escribir publicaciones. El proceso de autenticación se hace a través de Steam.\"> <input type=\"image\" src=\"http://cdn.steamcommunity.com/public/images/signinthroughsteam/sits_" . $button . ".png\" alt=\"Conexión a Steam\"></form>";
        } elseif ($openid->mode == 'cancel') {
            echo 'User has canceled authentication!';
        } 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];
                // First determine of the $steamauth['loginpage'] has been set, if yes then redirect there. If not redirect to where they came from
                if ($steamauth['loginpage'] !== "") {
                    $returnTo = $steamauth['loginpage'];
                } else {
                    //Determine the return to page. We substract "login&"" to remove the login var from the URL.
                    //"file.php?login&foo=bar" would become "file.php?foo=bar"
                    $returnTo = str_replace('login&', '', $_GET['openid_return_to']);
                    //If it didn't change anything, it means that there's no additionals vars, so remove the login var so that we don't get redirected to Steam over and over.
                    if ($returnTo === $_GET['openid_return_to']) {
                        $returnTo = str_replace('?login', '', $_GET['openid_return_to']);
                    }
                }
                if (!actualizarUsuarioActual()) {
                    include "steamauth/logout.php";
                    $_SESSION['error_conectando'] = true;
                }
                header('Location: ' . $returnTo);
            } else {
                echo "User is not logged in.\n";
            }
        }
    } catch (ErrorException $e) {
        echo $e->getMessage();
    }
}
Beispiel #21
0
 /**
  * Log a user in. This function handles both stages of the process.
  * Firstly goes to google to get the users id,
  * Secondly gets the returned google id and saves it
  *
  * @return void
  * @author Nick Sheffield
  **/
 function login()
 {
     $openid = new LightOpenID();
     // if the process hasn't been started yet, go to google and start it
     if (!$openid->mode) {
         $openid->identity = 'https://www.google.com/accounts/o8/id';
         header('Location: ' . $openid->authUrl());
         echo $openid->authUrl();
         // if the process has been started already, save the resulting id
     } else {
         $openid->validate();
         $_SESSION['id'] = $openid->identity;
         header('Location: /unread');
         exit;
     }
 }
Beispiel #22
0
 protected function authenticateOpenId($openidIdentity)
 {
     // 3rd-party library: http://gitorious.org/lightopenid
     // Required: PHP 5, curl
     $openid = new LightOpenID();
     $openid->required = array('namePerson/friendly', 'contact/email');
     $openid->optional = array('namePerson/first');
     if (isset($_GET['openid_mode'])) {
         $result = $openid->validate();
         $this->_openidIdentity = $openid->identity;
         $this->_attributes = $openid->getAttributes();
         return $result;
     }
     $openid->identity = $openidIdentity;
     header('Location: ' . $openid->authUrl());
     exit;
 }
Beispiel #23
0
function steamlogin()
{
    try {
        require "settings.php";
        $openid = new LightOpenID($steamauth['domainname']);
        $button['small'] = "small";
        $button['large_no'] = "large_noborder";
        $button['large'] = "large_border";
        $button = $button[$steamauth['buttonstyle']];
        if (!$openid->mode) {
            if (isset($_GET['login'])) {
                $openid->identity = 'http://steamcommunity.com/openid';
                header('Location: ' . $openid->authUrl());
            }
            return "<form action=\"?login\" method=\"post\">\n              <input type=\"image\" src=\"assets/images/steam_login.png\">\n            </form>";
        } elseif ($openid->mode == 'cancel') {
            echo 'User has canceled authentication!';
        } 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];
                // First determine of the $steamauth['loginpage'] has been set, if yes then redirect there. If not redirect to where they came from
                if ($steamauth['loginpage'] !== "") {
                    $returnTo = $steamauth['loginpage'];
                } else {
                    //Determine the return to page. We substract "login&"" to remove the login var from the URL.
                    //"file.php?login&foo=bar" would become "file.php?foo=bar"
                    $returnTo = str_replace('login&', '', $_GET['openid_return_to']);
                    //If it didn't change anything, it means that there's no additionals vars, so remove the login var so that we don't get redirected to Steam over and over.
                    if ($returnTo === $_GET['openid_return_to']) {
                        $returnTo = str_replace('?login', '', $_GET['openid_return_to']);
                    }
                }
                header('Location: ' . $returnTo);
            } else {
                echo "User is not logged in.\n";
            }
        }
    } catch (ErrorException $e) {
        echo $e->getMessage();
    }
}
Beispiel #24
0
function steamlogin()
{
    try {
        require "./steamauth/settings.php";
        $openid = new LightOpenID($steamauth['domainname']);
        $button['small'] = "small";
        $button['large_no'] = "large_noborder";
        $button['large'] = "large_border";
        //$button = $button[$steamauth['buttonstyle']];
        if (!$openid->mode) {
            if (isset($_GET['login'])) {
                $openid->identity = 'http://steamcommunity.com/openid';
                header('Location: ' . $openid->authUrl());
            }
            //echo "<form action=\"?login\" method=\"post\"> <input type=\"image\" src=\"http://cdn.steamcommunity.com/public/images/signinthroughsteam/sits_".$button.".png\"></form>";
        } else {
            if ($openid->mode == 'cancel') {
                echo 'User has canceled authentication!';
            } 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];
                    include_once "set.php";
                    $query = mysql_query("SELECT * FROM users WHERE steamid='" . $_SESSION['steamid'] . "'");
                    if (mysql_num_rows($query) == 0) {
                        mysql_query("INSERT INTO users (steamid) VALUES ('" . $_SESSION['steamid'] . "')") or die("MySQL ERROR: " . mysql_error());
                    }
                    if (isset($steamauth['loginpage'])) {
                        header('Location: ' . $steamauth['loginpage']);
                    }
                } else {
                    echo "User is not logged in.\n";
                }
            }
        }
    } catch (ErrorException $e) {
        echo $e->getMessage();
    }
}
 /**
  * Validates the OpenID provider's response and logs in the user.
  * 
  * If the user doesn't already exist, a new user account is created for them
  * and their attributes are saved.
  * 
  * @return void
  */
 public function _handleOpenIDResponse()
 {
     if ($this->LightOpenID->mode == 'cancel') {
         $this->Session->setFlash(__('Login canceled'), 'default', array(), 'auth');
     } else {
         if ($this->LightOpenID->validate()) {
             if (!$this->_existsOpenIDUser($this->LightOpenID->identity)) {
                 $this->_registerOpenIDUser($this->LightOpenID->identity, $this->LightOpenID->getAttributes());
             }
             $data = $this->_loadOpenIDUser($this->LightOpenID->identity);
             if ($data) {
                 $this->Auth->login($data['User']);
                 $this->redirect($this->Auth->redirect());
             } else {
                 $this->Session->setFlash("OpenID verified, but failed to load user data from the database");
             }
         } else {
             $this->Session->setFlash(__('OpenID verification failed'), 'default', array(), 'auth');
         }
     }
 }
 protected function doOpenId($identity)
 {
     require "vendor/lightopenid/openid.php";
     $openid = new \LightOpenID(Ntentan::$config['application']['domain']);
     if (!$openid->mode) {
         $identity = $openid->discover($identity);
         $openid->identity = $identity;
         $openid->required = array('contact/email', 'namePerson/first', 'namePerson/last', 'namePerson/friendly');
         header('Location: ' . $openid->authUrl());
     } elseif ($openid->mode == 'cancel') {
         return "cancelled";
     } else {
         if ($openid->validate()) {
             $oidStatus = $openid->getAttributes();
             $status = array('email' => $oidStatus['contact/email'], 'firstname' => $oidStatus['namePerson/first'], 'lastname' => $oidStatus['namePerson/last'], 'nickname' => $oidStatus['namePerson/friendly'], 'key' => $oidStatus['contact/email']);
             return $status;
         } else {
             return "failed";
         }
     }
 }
 public function actionMojeId()
 {
     $openId = new \LightOpenID($this->httpRequest->getUrl()->getAuthority());
     if (!$openId->mode) {
         $openId->identity = "https://mojeid.cz/endpoint/";
         $openId->required = array('namePerson', 'namePerson/first', 'namePerson/last', 'contact/email');
         $this->redirectUrl($openId->authUrl());
     } elseif ($openId->mode == 'cancel') {
         $this->flashMessage('Uživatel zrušil přihlašování.');
     } else {
         if ($openId->validate()) {
             $uzivatel = $this->uzivatele->add($openId);
             $role = $this->uzivatele->getRole($uzivatel->id);
             $identity = new \Nette\Security\Identity($openId->identity, $role, $uzivatel);
             $this->getUser()->login($identity);
             $this->flashMessage("Uživatel přihlášen");
         } else {
             $this->flashMessage("Přihlášení se nepodařilo.");
         }
     }
     $this->redirect(":Homepage:");
 }
Beispiel #28
0
 function action_finishAuth()
 {
     $openid = new LightOpenID();
     if (!$openid->validate()) {
         $this->request->redirect('auth/login');
         return;
     }
     $this->session->regenerate();
     $this->session->set('account_id', $_GET['openid_identity']);
     $attr = $openid->getAttributes();
     if (@$attr['contact/email']) {
         $this->session->set('account_email', $attr['contact/email']);
     }
     if (@$attr['namePerson/first'] && @$attr['namePerson/last']) {
         $this->session->set('account_displayName', implode(' ', array(@$attr['namePerson/first'], @$attr['namePerson/last'])));
     } else {
         if (@$attr['namePerson']) {
             $this->session->set('account_displayName', $attr['namePerson']);
         } else {
             if (@$attr['namePerson/friendly']) {
                 $this->session->set('account_displayName', $attr['namePerson/friendly']);
             }
         }
     }
     if (!($this->session->get('account_email') && $this->session->get('account_displayName'))) {
         echo "<br/><pre><xmp>";
         var_dump($openid);
         var_dump($openid->getAttributes());
         echo "</xmp></pre>";
         die;
     }
     $location = $this->session->get('redirected_from');
     $this->session->delete('redirected_from');
     if (!$location) {
         $location = "admin/index";
     }
     $this->request->redirect($location);
 }
Beispiel #29
0
               } */
     ?>
     <form action="?login" method="post">
         <button>Login with Google</button>
     </form>
     <!--
             <form action="" method="post">
                 OpenID: <input type="text" name="openid_identifier" /> <button>Submit</button>
             </form>
     -->
     <?php 
 } else {
     if ($openid->mode == 'cancel') {
         echo 'User has canceled authentication!';
     } else {
         if ($openid->validate()) {
             /*
              * Get attributes
              */
             $openID_data = $openid->getAttributes();
             /*
              * Store user information in user session
              */
             $_SESSION["email"] = $openID_data["contact/email"];
             $_SESSION["firstName"] = $openID_data["namePerson/first"];
             $_SESSION["lastName"] = $openID_data["namePerson/last"];
             $_SESSION["userName"] = $openID_data["namePerson/friendly"];
             /*
              * Store user information in mapshup database
              */
             // TODO
 public function handle_social_google()
 {
     global $xoouserultra;
     //require_once(ABSPATH . 'wp-includes/pluggable.php');
     require_once xoousers_path . "libs/openid/openid.php";
     //facebook libraries
     $web_url = site_url();
     $openid = new LightOpenID($web_url);
     if ($openid->mode) {
         $data = $openid->getAttributes();
         if ($openid->mode == 'cancel') {
         } elseif ($data["contact/email"] != "") {
             $openid->validate();
             $redir_url = "";
             //authentication authorized
             $data = $openid->getAttributes();
             $email = $data['contact/email'];
             $a = $openid->identity;
             //validate
             $type = 4;
             //google
             if (strpos($a, 'yahoo') !== false) {
                 $first = $data['namePerson'];
                 $type = 3;
                 //yahoo
                 $user_full_name = trim($first);
             } else {
                 $first = $data['namePerson/first'];
                 $last_n = $data['namePerson/last'];
                 $user_full_name = trim($first . " " . $last_n);
             }
             //save
             $u_user = $user_full_name;
             $u_name = $first;
             $u_email = $email;
             //check if already registered
             $exists = email_exists($u_email);
             if (!$exists) {
                 //generat random password
                 $user_pass = wp_generate_password(12, false);
                 //Sanitize Login
                 $user_login = str_replace('.', '-', $u_user);
                 $user_login = sanitize_user($u_user, true);
                 //Build user data
                 $user_data = array('user_login' => $user_login, 'display_name' => !empty($u_name) ? $u_name : $u_user, 'user_email' => $u_email, 'user_pass' => $user_pass);
                 // Create a new user
                 $user_id = wp_insert_user($user_data);
                 if (!$user_id) {
                 } else {
                     update_user_meta($user_id, 'xoouser_ultra_social_signup', $type);
                     $verify_key = $this->get_unique_verify_account_id();
                     update_user_meta($user_id, 'xoouser_ultra_very_key', $verify_key);
                     $this->user_account_status($user_id);
                     //update_user_meta ($user_id, 'xoouser_ultra_facebook_id', $u_fb_id);
                     //notify client
                     $xoouserultra->messaging->welcome_email($u_email, $user_login, $user_pass);
                     $creds['user_login'] = sanitize_user($u_user);
                     $creds['user_password'] = $user_pass;
                     $creds['remember'] = 1;
                     $noactive = false;
                     if (!$this->is_active($user_id) && !is_super_admin($user_id)) {
                         $noactive = true;
                     }
                     if (!$noactive) {
                         $user = wp_signon($creds, false);
                         do_action('wp_login', $user->user_login, $user);
                     }
                 }
             } else {
                 $noactive = false;
                 /*If alreayd exists*/
                 $user = get_user_by('login', $u_user);
                 $user_id = $user->ID;
                 if (!$this->is_active($user_id) && !is_super_admin($user_id)) {
                     $noactive = true;
                 }
                 if (!$noactive) {
                     $secure = "";
                     //already exists then we log in
                     wp_set_auth_cookie($user_id, true, $secure);
                     do_action('wp_login', $user->user_login, $user);
                 }
             }
         }
     }
     $this->login_registration_afterlogin();
 }