| 1 |
<?php |
| 2 |
/** |
| 3 |
* Basic autoloader for Hybridauth library which you may use as it is or as a template |
| 4 |
* to suit your application's environment. |
| 5 |
* |
| 6 |
* Note that you'd ONLY need this file if you are not using composer. |
| 7 |
*/ |
| 8 |
|
| 9 |
if (version_compare(PHP_VERSION, '5.4.0', '<')) { |
| 10 |
throw new Exception('Hybridauth 3 requires PHP version 5.4 or higher.'); |
| 11 |
} |
| 12 |
|
| 13 |
/** |
| 14 |
* Register the autoloader for Hybridauth classes. |
| 15 |
* |
| 16 |
* Based off the official PSR-4 autoloader example found at |
| 17 |
* http://www.php-fig.org/psr/psr-4/examples/ |
| 18 |
* |
| 19 |
* @param string $class The fully-qualified class name. |
| 20 |
* |
| 21 |
* @return void |
| 22 |
*/ |
| 23 |
spl_autoload_register( |
| 24 |
function ($class) { |
| 25 |
// project-specific namespace prefix. Will only kicks in for Hybridauth's namespace. |
| 26 |
$prefix = 'Hybridauth\\'; |
| 27 |
|
| 28 |
// base directory for the namespace prefix. |
| 29 |
$base_dir = __DIR__; // By default, it points to this same folder. |
| 30 |
// You may change this path if having trouble detecting the path to |
| 31 |
// the source files. |
| 32 |
|
| 33 |
// does the class use the namespace prefix? |
| 34 |
$len = strlen($prefix); |
| 35 |
if (strncmp($prefix, $class, $len) !== 0) { |
| 36 |
// no, move to the next registered autoloader. |
| 37 |
return; |
| 38 |
} |
| 39 |
|
| 40 |
// get the relative class name. |
| 41 |
$relative_class = substr($class, $len); |
| 42 |
|
| 43 |
// replace the namespace prefix with the base directory, replace namespace |
| 44 |
// separators with directory separators in the relative class name, append |
| 45 |
// with .php |
| 46 |
$file = $base_dir . DIRECTORY_SEPARATOR . str_replace('\\', DIRECTORY_SEPARATOR, $relative_class) . '.php'; |
| 47 |
|
| 48 |
// if the file exists, require it |
| 49 |
if (file_exists($file)) { |
| 50 |
require $file; |
| 51 |
|
| 52 |
return; |
| 53 |
} |
| 54 |
|
| 55 |
if(!defined('LOGINIZER_PRO_DIR')) { |
| 56 |
return; |
| 57 |
} |
| 58 |
|
| 59 |
$file = LOGINIZER_PRO_DIR . 'lib/hybridauth/'. str_replace('\\', DIRECTORY_SEPARATOR, $relative_class) . '.php'; |
| 60 |
|
| 61 |
if(file_exists($file)){ |
| 62 |
require $file; |
| 63 |
} |
| 64 |
|
| 65 |
} |
| 66 |
); |
| 67 |
|