Ejemplo n.º 1
0
 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;
 }
Ejemplo n.º 2
0
 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;
 }
Ejemplo n.º 3
0
 public static function getAdapter($network_name = null)
 {
     Social_Logger::info("###Social_Auth::getAdapter( {$network_name} )");
     return Social_Auth::prepare($network_name);
 }