PluginProbe
Authorizer / 3.6.0
Authorizer v3.6.0
3.16.0 3.15.3 3.15.2 3.15.1 3.15.0 3.14.3 3.14.4 3.14.2 3.14.1 2.8.1 2.8.2 2.8.3 2.8.4 2.8.5 2.8.6 2.8.7 2.8.8 2.9.0 2.9.1 2.9.10 2.9.11 2.9.12 2.9.13 2.9.2 2.9.3 All 127 releases
authorizer / vendor / apereo / phpcas / source / CAS / Autoload.php

Autoload.php in Authorizer 3.6.0, at vendor/apereo/phpcas/source/CAS/Autoload.php

96 lines 2.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Autoloader Class
5 *
6 * PHP Version 7
7 *
8 * @file CAS/Autoload.php
9 * @category Authentication
10 * @package SimpleCAS
11 * @author Brett Bieber <[email protected]>
12 * @copyright 2008 Regents of the University of Nebraska
13 * @license http://www1.unl.edu/wdn/wiki/Software_License BSD License
14 * @link http://code.google.com/p/simplecas/
15 **/
16
17 /**
18 * Autoload a class
19 *
20 * @param string $class Classname to load
21 *
22 * @return bool
23 */
24 function CAS_autoload($class)
25 {
26 // Static to hold the Include Path to CAS
27 static $include_path;
28 // Check only for CAS classes
29 if (substr($class, 0, 4) !== 'CAS_' && substr($class, 0, 7) !== 'PhpCas\\') {
30 return false;
31 }
32
33 // Setup the include path if it's not already set from a previous call
34 if (empty($include_path)) {
35 $include_path = array(dirname(__DIR__));
36 }
37
38 // Declare local variable to store the expected full path to the file
39 foreach ($include_path as $path) {
40 $class_path = str_replace('_', DIRECTORY_SEPARATOR, $class);
41 // PhpCas namespace mapping
42 if (substr($class_path, 0, 7) === 'PhpCas\\') {
43 $class_path = 'CAS' . DIRECTORY_SEPARATOR . substr($class_path, 7);
44 }
45
46 $file_path = $path . DIRECTORY_SEPARATOR . $class_path . '.php';
47 $fp = @fopen($file_path, 'r', true);
48 if ($fp) {
49 fclose($fp);
50 include $file_path;
51 if (!class_exists($class, false) && !interface_exists($class, false)) {
52 die(
53 new Exception(
54 'Class ' . $class . ' was not present in ' .
55 $file_path .
56 ' [CAS_autoload]'
57 )
58 );
59 }
60 return true;
61 }
62 }
63
64 $e = new Exception(
65 'Class ' . $class . ' could not be loaded from ' .
66 $file_path . ', file does not exist (Path="'
67 . implode(':', $include_path) .'") [CAS_autoload]'
68 );
69 $trace = $e->getTrace();
70 if (isset($trace[2]) && isset($trace[2]['function'])
71 && in_array($trace[2]['function'], array('class_exists', 'interface_exists', 'trait_exists'))
72 ) {
73 return false;
74 }
75 if (isset($trace[1]) && isset($trace[1]['function'])
76 && in_array($trace[1]['function'], array('class_exists', 'interface_exists', 'trait_exists'))
77 ) {
78 return false;
79 }
80 die ((string) $e);
81 }
82
83 // Set up autoload if not already configured by composer.
84 if (!class_exists('CAS_Client'))
85 {
86 trigger_error('phpCAS autoloader is deprecated. Install phpCAS using composer instead.', E_USER_DEPRECATED);
87 spl_autoload_register('CAS_autoload');
88 if (function_exists('__autoload')
89 && !in_array('__autoload', spl_autoload_functions())
90 ) {
91 // __autoload() was being used, but now would be ignored, add
92 // it to the autoload stack
93 spl_autoload_register('__autoload');
94 }
95 }
96