source-function-CAS_autoload

It appears that you are using AdBlocking software. The cost of running this website is covered by advertisements. If you like it please feel free to a small amount of money to secure the future of this website.
Overview

Classes

Interfaces

Exceptions

Functions

  1: <?php
  2: 
  3: /**
  4:  * Autoloader Class
  5:  *
  6:  *  PHP Version 5
  7:  *
  8:  * @file      CAS/Autoload.php
  9:  * @category  Authentication
 10:  * @package   SimpleCAS
 11:  * @author    Brett Bieber <brett.bieber@gmail.com>
 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_') {
 30:         return false;
 31:     }
 32:     // Setup the include path if it's not already set from a previous call
 33:     if (empty($include_path)) {
 34:         $include_path = array(dirname(dirname(__FILE__)), dirname(dirname(__FILE__)) . '/../test/' );
 35:     }
 36: 
 37:     // Declare local variable to store the expected full path to the file
 38: 
 39:     foreach ($include_path as $path) {
 40:         $file_path = $path . '/' . str_replace('_', '/', $class) . '.php';
 41:         $fp = @fopen($file_path, 'r', true);
 42:         if ($fp) {
 43:             fclose($fp);
 44:             include $file_path;
 45:             if (!class_exists($class, false) && !interface_exists($class, false)) {
 46:                 die(
 47:                     new Exception(
 48:                         'Class ' . $class . ' was not present in ' .
 49:                         $file_path .
 50:                         ' [CAS_autoload]'
 51:                     )
 52:                 );
 53:             }
 54:             return true;
 55:         }
 56:     }
 57:     $e = new Exception(
 58:         'Class ' . $class . ' could not be loaded from ' .
 59:         $file_path . ', file does not exist (Path="'
 60:         . implode(':', $include_path) .'") [CAS_autoload]'
 61:     );
 62:     $trace = $e->getTrace();
 63:     if (isset($trace[2]) && isset($trace[2]['function'])
 64:         && in_array($trace[2]['function'], array('class_exists', 'interface_exists'))
 65:     ) {
 66:         return false;
 67:     }
 68:     if (isset($trace[1]) && isset($trace[1]['function'])
 69:         && in_array($trace[1]['function'], array('class_exists', 'interface_exists'))
 70:     ) {
 71:         return false;
 72:     }
 73:     die ((string) $e);
 74: }
 75: 
 76: // set up __autoload
 77: if (function_exists('spl_autoload_register')) {
 78:     if (!(spl_autoload_functions())
 79:         || !in_array('CAS_autoload', spl_autoload_functions())
 80:     ) {
 81:         spl_autoload_register('CAS_autoload');
 82:         if (function_exists('__autoload')
 83:             && !in_array('__autoload', spl_autoload_functions())
 84:         ) {
 85:             // __autoload() was being used, but now would be ignored, add
 86:             // it to the autoload stack
 87:             spl_autoload_register('__autoload');
 88:         }
 89:     }
 90: } elseif (!function_exists('__autoload')) {
 91: 
 92:     /**
 93:      * Autoload a class
 94:      *
 95:      * @param string $class Class name
 96:      *
 97:      * @return bool
 98:      */
 99:     function __autoload($class)
100:     {
101:         return CAS_autoload($class);
102:     }
103: }
104: 
105: ?>
 

© 2004-2018 – Nicola Asuni - Tecnick.com - All rights reserved.
about - disclaimer - privacy