function __autoload($class)
{
    Autoload::initialize();
    $class = strtolower($class);
    $class = strtr($class, '\\_', '/.');
    if (strpos($class, 'apps/') === 0) {
        if (is_file($class . '.php')) {
            return require_once $class . '.php';
        } else {
            $class = substr($class, 4);
            foreach (Autoload::paths() as $path) {
                $file = $path . $class . '.php';
                if (!is_file($file)) {
                    continue;
                }
                return require_once $file;
            }
        }
    } else {
        if (is_file($class . '.php')) {
            return require_once $class . '.php';
        }
    }
    require_once $class . '.php';
}
Exemple #2
0
                if (file_exists($path . DIRECTORY_SEPARATOR . $file)) {
                    require $path . DIRECTORY_SEPARATOR . $file;
                    if (!class_exists($class, false) && !interface_exists($class, false)) {
                        die(new \Exception('Class ' . $class . ' was not present in ' . $path . DIRECTORY_SEPARATOR . $file . '") [PEAR2_Autoload-0.2.3]'));
                    }
                    return true;
                }
            }
            $e = new \Exception('Class ' . $class . ' could not be loaded from ' . $file . ', file does not exist (registered paths="' . implode(PATH_SEPARATOR, self::$paths) . '") [PEAR2_Autoload-0.2.3]');
            $trace = $e->getTrace();
            if (isset($trace[2]) && isset($trace[2]['function']) && in_array($trace[2]['function'], array('class_exists', 'interface_exists'))) {
                return false;
            }
            if (isset($trace[1]) && isset($trace[1]['function']) && in_array($trace[1]['function'], array('class_exists', 'interface_exists'))) {
                return false;
            }
            die((string) $e);
        }
        /**
         * return the array of paths PEAR2 autoload has registered
         * 
         * @return array
         */
        static function getPaths()
        {
            return self::$paths;
        }
    }
}
Autoload::initialize(dirname(__DIR__));
Exemple #3
0
<?php

$time = microtime();
$time = explode(' ', $time);
$time = $time[1] + $time[0];
$start = $time;
require 'core/config/config.php';
require 'app/config/config.php';
Autoload::initialize();
$session = Session::getInstance();
$session->set('start', $start);
Router::dispatch();