コード例 #1
0
ファイル: Client.php プロジェクト: albertoneto/localhost
 public static function finishAuth()
 {
     Social_Client::init();
     $network_name = trim(strip_tags(Social_Client::$request["sa_login_finish"]));
     $network = Social_Auth::prepare($network_name);
     if (!$network) {
         Social_Logger::error("Invalid parameter given on sa_login_finish");
         $network->adapter->disconnectUser();
         header("HTTP/1.0 404 Not Found");
         die("Invalid parameter given on sa_login_finish. Try login again");
     }
     try {
         Social_Logger::info("Login finish: {$network_name}");
         $network->adapter->finishLogin();
         $user_profile = $network->adapter->getUserProfile();
         if ($network_name == 'facebook') {
             $user_profile->photoURL = $user_profile->photoURL . '&ts=' . getTimeStamp();
         }
         $user_profile->network_name = $network_name;
         $userid = socialLogin($user_profile);
         Social_Auth::session()->set("SA_USER", $user_profile);
     } catch (Exception $e) {
         $network->adapter->disconnectUser();
     }
     Social_Logger::info("Returned to callback");
     $network->goToCallbackPage();
     die;
 }
コード例 #2
0
ファイル: Client.php プロジェクト: hughnguy/php
 public static function finishAuth()
 {
     Social_Client::init();
     $network_name = trim(strip_tags(Social_Client::$request["sa_login_finish"]));
     $network = Social_Auth::prepare($network_name);
     if (!$network) {
         Social_Logger::error("Invalid parameter given on sa_login_finish");
         $network->adapter->disconnectUser();
         header("HTTP/1.0 404 Not Found");
         die("Invalid parameter given on sa_login_finish. Try login again");
     }
     try {
         Social_Logger::info("Login finish: {$network_name}");
         $network->adapter->finishLogin();
         $user_profile = $network->adapter->getUserProfile();
         if ($network_name == 'facebook') {
             $user_profile->photoURL = $user_profile->photoURL . '&ts=' . getTimeStamp();
         }
         $sql = "select " . DB_USERTABLE . "." . DB_USERTABLE_USERID . " from " . DB_USERTABLE . " where " . DB_USERTABLE . "." . DB_USERTABLE_USERNAME . " = '" . mysqli_real_escape_string($GLOBALS['dbh'], $network_name) . "_" . mysqli_real_escape_string($GLOBALS['dbh'], $user_profile->identifier) . "'";
         $result = mysqli_query($GLOBALS['dbh'], $sql);
         if ($row = mysqli_fetch_assoc($result)) {
             $sql = "update " . DB_USERTABLE . " set " . DB_USERTABLE . "." . DB_USERTABLE_NAME . "='" . mysqli_real_escape_string($GLOBALS['dbh'], $user_profile->firstName) . "'," . DB_AVATARFIELD . "='" . mysqli_real_escape_string($GLOBALS['dbh'], $user_profile->photoURL) . "'," . DB_USERTABLE . "." . DB_LINKFIELD . "='" . mysqli_real_escape_string($GLOBALS['dbh'], $user_profile->profileURL) . "' where " . DB_USERTABLE . "." . DB_USERTABLE_USERNAME . "='" . mysqli_real_escape_string($GLOBALS['dbh'], $network_name) . "_" . mysqli_real_escape_string($GLOBALS['dbh'], $user_profile->identifier) . "'";
             mysqli_query($GLOBALS['dbh'], $sql);
             if (!empty($row[DB_USERTABLE_USERID])) {
                 $userid = $row[DB_USERTABLE_USERID];
             }
         } else {
             $sql = "insert into " . DB_USERTABLE . " (" . DB_USERTABLE . "." . DB_USERTABLE_USERNAME . "," . DB_USERTABLE . "." . DB_USERTABLE_NAME . "," . DB_AVATARFIELD . "," . DB_USERTABLE . "." . DB_LINKFIELD . "," . DB_USERTABLE . "." . DB_GROUPFIELD . ") values ( '" . mysqli_real_escape_string($GLOBALS['dbh'], $network_name) . "_" . mysqli_real_escape_string($GLOBALS['dbh'], $user_profile->identifier) . "','" . mysqli_real_escape_string($GLOBALS['dbh'], $user_profile->firstName) . "','" . mysqli_real_escape_string($GLOBALS['dbh'], $user_profile->photoURL) . "','" . mysqli_real_escape_string($GLOBALS['dbh'], $user_profile->profileURL) . "','" . mysqli_real_escape_string($GLOBALS['dbh'], ucfirst($network_name)) . "')";
             mysqli_query($GLOBALS['dbh'], $sql);
             $userid = mysqli_insert_id($GLOBALS['dbh']);
         }
         $_SESSION['cometchat']['userid'] = $userid;
         $_SESSION['cometchat']['ccauth'] = '1';
         Social_Auth::session()->set("SA_USER", $user_profile);
     } catch (Exception $e) {
         $network->adapter->disconnectUser();
     }
     Social_Logger::info("Returned to callback");
     $network->goToCallbackPage();
     die;
 }
コード例 #3
0
ファイル: Adapter.php プロジェクト: hughnguy/php
 function login()
 {
     Social_Logger::info("###Social_Adapter::login( {$this->network_name} ) ");
     if (!$this->adapter) {
         throw new Social_Exception("Social_Adapter::login() cannot be used directly");
     }
     foreach (Social_Auth::$config["networks"] as $network => $params) {
         Social_Auth::session()->deleteByKey("sa_session.{$network}.sa_callback");
         Social_Auth::session()->deleteByKey("sa_session.{$network}.sa_client");
         Social_Auth::session()->deleteByKey("sa_session.{$network}.network_params");
     }
     $this->logout();
     $social_auth_base_url = Social_Auth::$config["base_url"];
     $this->params["sa_token"] = session_id();
     $this->params["sa_time"] = time();
     $this->params["sa_login"] = $social_auth_base_url . (strpos($social_auth_base_url, '?') ? '&' : '?') . "sa_login={$this->network_name}&sa_time={$this->params["sa_time"]}";
     $this->params["sa_login_finish"] = $social_auth_base_url . (strpos($social_auth_base_url, '?') ? '&' : '?') . "sa_login_finish={$this->network_name}";
     Social_Auth::session()->set("sa_session.{$this->network_name}.sa_callback", $this->params["sa_callback_url"]);
     Social_Auth::session()->set("sa_session.{$this->network_name}.sa_client", $this->params["sa_login_finish"]);
     Social_Auth::session()->set("sa_session.{$this->network_name}.network_params", $this->params);
     Social_Auth::session()->set("sa_config", Social_Auth::$config);
     Social_Logger::debug("Social_Adapter::login( {$this->network_name} ), redirecting sa_login url.");
     Social_Auth::redirect($this->params["sa_login"]);
 }
コード例 #4
0
ファイル: Auth.php プロジェクト: albertoneto/localhost
 public static function isNetworkConnected($network_name)
 {
     return (bool) Social_Auth::session()->get("sa_session.{$network_name}.logged_in");
 }
コード例 #5
0
ファイル: Base.php プロジェクト: hughnguy/php
 public function clearTokens()
 {
     Social_Auth::session()->deleteByNetwork("sa_session.{$this->network_name}.");
 }
コード例 #6
0
ファイル: logout.php プロジェクト: hughnguy/php
<?php

$config = dirname(__FILE__) . '/config.php';
require_once "Social/Auth.php";
try {
    $socialAuth = new Social_Auth($config);
    Social_Auth::session()->deleteByKey("SA_USER");
    @session_start();
    unset($_SESSION['cometchat']);
    if (!empty($_GET['callback'])) {
        echo $_GET['callback'] . '(' . json_encode(array(1)) . ')';
    } else {
        echo '1';
    }
} catch (Exception $ex) {
    echo "Error occured: " . $ex->getMessage();
}