コード例 #1
0
ファイル: Auth.php プロジェクト: Vatia13/dancesport
 /**
  * Try to initialize Hybrid_Auth with given $config hash or file
  */
 public static function initialize($config)
 {
     if (!is_array($config) && !file_exists($config)) {
         throw new Exception("Hybriauth config does not exist on the given path.", 1);
     }
     if (!is_array($config)) {
         $config = (include $config);
     }
     // build some need'd paths
     $path_base = realpath(dirname(__FILE__)) . "/";
     # load hybridauth required files
     require_once $path_base . "Error.php";
     require_once $path_base . "Exception.php";
     require_once $path_base . "Provider_Adapter.php";
     require_once $path_base . "Provider_Model.php";
     require_once $path_base . "Provider_Model_OpenID.php";
     require_once $path_base . "Provider_Model_OAuth1.php";
     require_once $path_base . "Provider_Model_OAuth2.php";
     require_once $path_base . "User.php";
     require_once $path_base . "User_Profile.php";
     require_once $path_base . "User_Contact.php";
     require_once $path_base . "User_Activity.php";
     require_once $path_base . "Storage.php";
     // hash given config
     Hybrid_Auth::$config = $config;
     // instance of errors mng
     Hybrid_Auth::$error = new Hybrid_Error();
     // start session storage mng
     Hybrid_Auth::$store = new Hybrid_Storage();
     if (Hybrid_Error::hasError()) {
         $m = Hybrid_Error::getErrorMessage();
         $c = Hybrid_Error::getErrorCode();
         Hybrid_Error::clearError();
         throw new Exception($m, $c);
     }
     // Endof initialize
 }
コード例 #2
0
ファイル: Auth.php プロジェクト: OneataBogdan/lead_coriolan
 /**
  * Try to initialize Hybrid_Auth with given $config hash or file
  */
 public static function initialize($config)
 {
     if (!is_array($config) && !file_exists($config)) {
         throw new Exception("Hybriauth config does not exist on the given path.", 1);
     }
     if (!is_array($config)) {
         $config = (include $config);
     }
     // build some need'd paths
     $config["path_base"] = realpath(dirname(__FILE__)) . "/";
     $config["path_libraries"] = $config["path_base"] . "thirdparty/";
     $config["path_resources"] = $config["path_base"] . "resources/";
     $config["path_providers"] = $config["path_base"] . "Providers/";
     // reset debug mode
     if (!isset($config["debug_mode"])) {
         $config["debug_mode"] = false;
         $config["debug_file"] = null;
     }
     # load hybridauth required files, a autoload is on the way...
     require_once $config["path_base"] . "Error.php";
     require_once $config["path_base"] . "Logger.php";
     require_once $config["path_base"] . "Storage.php";
     require_once $config["path_base"] . "Provider_Adapter.php";
     require_once $config["path_base"] . "Provider_Model.php";
     require_once $config["path_base"] . "Provider_Model_OpenID.php";
     require_once $config["path_base"] . "Provider_Model_OAuth1.php";
     require_once $config["path_base"] . "Provider_Model_OAuth2.php";
     require_once $config["path_base"] . "User.php";
     require_once $config["path_base"] . "User_Profile.php";
     require_once $config["path_base"] . "User_Contact.php";
     require_once $config["path_base"] . "User_Activity.php";
     // hash given config
     Hybrid_Auth::$config = $config;
     // instace of log mng
     Hybrid_Auth::$logger = new Hybrid_Logger();
     // instace of errors mng
     Hybrid_Auth::$error = new Hybrid_Error();
     // start session storage mng
     Hybrid_Auth::$store = new Hybrid_Storage();
     Hybrid_Logger::info("Enter Hybrid_Auth::initialize()");
     Hybrid_Logger::info("Hybrid_Auth::initialize(). PHP version: " . PHP_VERSION);
     Hybrid_Logger::info("Hybrid_Auth::initialize(). Hybrid_Auth version: " . Hybrid_Auth::$version);
     Hybrid_Logger::info("Hybrid_Auth::initialize(). Hybrid_Auth called from: " . Hybrid_Auth::getCurrentUrl());
     // PHP Curl extension [http://www.php.net/manual/en/intro.curl.php]
     if (!function_exists('curl_init')) {
         Hybrid_Logger::error('Hybridauth Library needs the CURL PHP extension.');
         throw new Exception('Hybridauth Library needs the CURL PHP extension.');
     }
     // PHP JSON extension [http://php.net/manual/en/book.json.php]
     if (!function_exists('json_decode')) {
         Hybrid_Logger::error('Hybridauth Library needs the JSON PHP extension.');
         throw new Exception('Hybridauth Library needs the JSON PHP extension.');
     }
     // session.name
     if (session_name() != "PHPSESSID") {
         Hybrid_Logger::info('PHP session.name diff from default PHPSESSID. http://php.net/manual/en/session.configuration.php#ini.session.name.');
     }
     // safe_mode is on
     if (ini_get('safe_mode')) {
         Hybrid_Logger::info('PHP safe_mode is on. http://php.net/safe-mode.');
     }
     // open basedir is on
     if (ini_get('open_basedir')) {
         Hybrid_Logger::info('PHP open_basedir is on. http://php.net/open-basedir.');
     }
     Hybrid_Logger::debug("Hybrid_Auth initialize. dump used config: ", serialize($config));
     Hybrid_Logger::debug("Hybrid_Auth initialize. dump current session: ", Hybrid_Auth::storage()->getSessionData());
     Hybrid_Logger::info("Hybrid_Auth initialize: check if any error is stored on the endpoint...");
     if (Hybrid_Error::hasError()) {
         $m = Hybrid_Error::getErrorMessage();
         $c = Hybrid_Error::getErrorCode();
         $p = Hybrid_Error::getErrorPrevious();
         Hybrid_Logger::error("Hybrid_Auth initialize: A stored Error found, Throw an new Exception and delete it from the store: Error#{$c}, '{$m}'");
         Hybrid_Error::clearError();
         // try to provide the previous if any
         // Exception::getPrevious (PHP 5 >= 5.3.0) http://php.net/manual/en/exception.getprevious.php
         if (version_compare(PHP_VERSION, '5.3.0', '>=') && $p instanceof Exception) {
             throw new Exception($m, $c, $p);
         } else {
             throw new Exception($m, $c);
         }
     }
     Hybrid_Logger::info("Hybrid_Auth initialize: no error found. initialization succeed.");
     // Endof initialize
 }
コード例 #3
0
ファイル: Auth.php プロジェクト: ValenokPC/tabernacms
 /**
  * Try to initialize Hybrid_Auth with given $config hash or file
  */
 public static function initialize($config)
 {
     if (!session_id()) {
         throw new Exception("Hybriauth require the use of 'session_start()' at the start of your script.", 1);
     }
     if (!is_array($config) && !file_exists($config)) {
         throw new Exception("Hybriauth config does not exist on the given path.", 1);
     }
     if (!is_array($config)) {
         $config = (include $config);
     }
     // build some need'd paths
     $config["path_base"] = realpath(dirname(__FILE__)) . "/";
     $config["path_libraries"] = $config["path_base"] . "thirdparty/";
     $config["path_resources"] = $config["path_base"] . "resources/";
     $config["path_providers"] = $config["path_base"] . "Providers/";
     // reset debug mode
     if (!isset($config["debug_mode"])) {
         $config["debug_mode"] = false;
         $config["debug_file"] = null;
     }
     # load hybridauth required files, a autoload is on the way...
     require_once $config["path_base"] . "Error.php";
     require_once $config["path_base"] . "Logger.php";
     require_once $config["path_base"] . "Storage.php";
     require_once $config["path_base"] . "Provider_Adapter.php";
     require_once $config["path_base"] . "Provider_Model.php";
     require_once $config["path_base"] . "Provider_Model_OpenID.php";
     require_once $config["path_base"] . "Provider_Model_OAuth1.php";
     require_once $config["path_base"] . "Provider_Model_OAuth2.php";
     require_once $config["path_base"] . "User.php";
     require_once $config["path_base"] . "User_Profile.php";
     require_once $config["path_base"] . "User_Contact.php";
     require_once $config["path_base"] . "User_Activity.php";
     // hash given config
     Hybrid_Auth::$config = $config;
     // start session storage mng
     Hybrid_Auth::$store = new Hybrid_Storage();
     // instace of errors mng
     Hybrid_Auth::$error = new Hybrid_Error();
     // instace of log mng
     Hybrid_Auth::$logger = new Hybrid_Logger();
     // store php session and version..
     $_SESSION["HA::PHP_SESSION_ID"] = session_id();
     $_SESSION["HA::VERSION"] = Hybrid_Auth::$version;
     // almost done, check for errors then move on
     Hybrid_Logger::info("Enter Hybrid_Auth::initialize()");
     Hybrid_Logger::info("Hybrid_Auth::initialize(). Hybrid_Auth used version: " . Hybrid_Auth::$version);
     Hybrid_Logger::info("Hybrid_Auth::initialize(). Hybrid_Auth called from: " . Hybrid_Auth::getCurrentUrl());
     Hybrid_Logger::debug("Hybrid_Auth initialize. dump used config: ", serialize($config));
     Hybrid_Logger::debug("Hybrid_Auth initialize. dump current session: ", serialize($_SESSION));
     Hybrid_Logger::info("Hybrid_Auth initialize: check if any error is stored on the endpoint...");
     if (Hybrid_Error::hasError()) {
         $m = Hybrid_Error::getErrorMessage();
         $c = Hybrid_Error::getErrorCode();
         $p = Hybrid_Error::getErrorPrevious();
         Hybrid_Logger::error("Hybrid_Auth initialize: A stored Error found, Throw an new Exception and delete it from the store: Error#{$c}, '{$m}'");
         Hybrid_Error::clearError();
         if (!$p instanceof Exception) {
             $p = null;
         }
         //TODO: Is this check realy needed?
         throw new Exception($m, $c, $p);
     }
     Hybrid_Logger::info("Hybrid_Auth initialize: no error found. initialization succeed.");
     // Endof initialize
 }