Ejemplo n.º 1
0
 public static function init()
 {
     if (!Social_Client::$finish) {
         Social_Client::$finish = true;
         try {
             require_once realpath(dirname(__FILE__)) . "/Session.php";
             $session = new Social_Session();
             if (!$session->get("sa_config")) {
                 header("HTTP/1.0 404 Not Found");
                 die("Direct access not allowed");
                 Social_Logger::error("Direct access not allowed, ");
             }
             Social_Auth::init($session->get("sa_config"));
         } catch (Exception $e) {
             Social_Logger::error("Error occured while Social_Auth init");
             header("HTTP/1.0 404 Not Found");
             die("Error occured!");
         }
     }
 }
Ejemplo n.º 2
0
 public static function redirect($url)
 {
     Social_Logger::info("###Social_Auth::redirect( {$url} )");
     header("Location: {$url}");
     die;
 }
Ejemplo n.º 3
0
 public function __call($name, $arguments)
 {
     Social_Logger::info("###Social_Adapter::{$name}(), Network: {$this->network_name}");
     if (!$this->isUserConnected()) {
         throw new Social_Exception("User not logged in to network:  {$this->network_name}");
     }
     if (!method_exists($this->adapter, $name)) {
         throw new Social_Exception("_call undefined function Social_Network_{$this->network_name}::{$name}()");
     }
     if (count($arguments)) {
         return $this->adapter->{$name}($arguments[0]);
     } else {
         return $this->adapter->{$name}();
     }
 }
Ejemplo n.º 4
0
 public function connectUser()
 {
     Social_Logger::info("###{$this->network_name}::connectUser()");
     Social_Auth::session()->set("sa_session.{$this->network_name}.logged_in", 1);
 }
Ejemplo n.º 5
0
 /**
  * Error log
  * @param $message
  * @param null $object
  */
 public static function error($message, $object = null)
 {
     if (Social_Auth::$config["debug_enabled"]) {
         Social_Logger::write_to_file("SOCIAL_AUTH_ERROR", $message, $object);
     }
 }
Ejemplo n.º 6
0
 function getUserContacts()
 {
     Social_Logger::error("Social_Auth do not provide users contacts for {$this->network_name}.");
     throw new Social_Exception("This feature has not been implemented");
 }
Ejemplo n.º 7
0
 /**
  * Make http request
  */
 function request($url, $method, $postfields = NULL, $auth_header = null)
 {
     Social_Logger::info("Enter OAuth1Client::request( {$method}, {$url} )");
     Social_Logger::debug("OAuth1Client::request(). dump post fields: ", serialize($postfields));
     $this->http_info = array();
     $ci = curl_init();
     /* Curl settings */
     curl_setopt($ci, CURLOPT_USERAGENT, $this->curl_useragent);
     curl_setopt($ci, CURLOPT_CONNECTTIMEOUT, $this->curl_connect_time_out);
     curl_setopt($ci, CURLOPT_TIMEOUT, $this->curl_time_out);
     curl_setopt($ci, CURLOPT_RETURNTRANSFER, TRUE);
     curl_setopt($ci, CURLOPT_HTTPHEADER, array('Expect:'));
     curl_setopt($ci, CURLOPT_SSL_VERIFYPEER, $this->curl_ssl_verifypeer);
     curl_setopt($ci, CURLOPT_HEADERFUNCTION, array($this, 'getHeader'));
     curl_setopt($ci, CURLOPT_HEADER, FALSE);
     if ($this->curl_proxy) {
         curl_setopt($ci, CURLOPT_PROXY, $this->curl_proxy);
     }
     switch ($method) {
         case 'POST':
             curl_setopt($ci, CURLOPT_POST, TRUE);
             if (!empty($postfields)) {
                 curl_setopt($ci, CURLOPT_POSTFIELDS, $postfields);
             }
             if (!empty($auth_header) && $this->curl_auth_header) {
                 curl_setopt($ci, CURLOPT_HTTPHEADER, array('Content-Type: application/atom+xml', $auth_header));
             }
             break;
         case 'DELETE':
             curl_setopt($ci, CURLOPT_CUSTOMREQUEST, 'DELETE');
             if (!empty($postfields)) {
                 $url = "{$url}?{$postfields}";
             }
     }
     curl_setopt($ci, CURLOPT_URL, $url);
     $response = curl_exec($ci);
     Social_Logger::debug("OAuth1Client::request(). dump request info: ", serialize(curl_getinfo($ci)));
     Social_Logger::debug("OAuth1Client::request(). dump request result: ", serialize($response));
     $this->http_code = curl_getinfo($ci, CURLINFO_HTTP_CODE);
     $this->http_info = array_merge($this->http_info, curl_getinfo($ci));
     curl_close($ci);
     return $response;
 }
Ejemplo n.º 8
0
 private function request($url, $params = false, $type = "GET")
 {
     Social_Logger::info("Enter OAuth2Client::request( {$url} )");
     Social_Logger::debug("OAuth2Client::request(). dump request params: ", serialize($params));
     if ($type == "GET") {
         $url = $url . (strpos($url, '?') ? '&' : '?') . http_build_query($params);
     }
     $this->http_info = array();
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $url);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_TIMEOUT, $this->curl_time_out);
     curl_setopt($ch, CURLOPT_USERAGENT, $this->curl_useragent);
     curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $this->curl_connect_time_out);
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, $this->curl_ssl_verifypeer);
     curl_setopt($ch, CURLOPT_HTTPHEADER, $this->curl_header);
     if ($this->curl_proxy) {
         curl_setopt($ch, CURLOPT_PROXY, $this->curl_proxy);
     }
     if ($type == "POST") {
         curl_setopt($ch, CURLOPT_POST, 1);
         if ($params) {
             curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
         }
     }
     $response = curl_exec($ch);
     Social_Logger::debug("OAuth2Client::request(). dump request info: ", serialize(curl_getinfo($ch)));
     Social_Logger::debug("OAuth2Client::request(). dump request result: ", serialize($response));
     $this->http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
     $this->http_info = array_merge($this->http_info, curl_getinfo($ch));
     curl_close($ch);
     return $response;
 }