mirror of
https://github.com/NNTmux/newznab-tmux.git
synced 2026-08-29 01:08:56 +00:00
62 lines
1.7 KiB
PHP
62 lines
1.7 KiB
PHP
<?php
|
|
/**
|
|
* PSR-0 compliant autoloader for libs
|
|
*
|
|
* @param string $class The fully-qualified class name.
|
|
*
|
|
* @return void
|
|
*/
|
|
spl_autoload_register(
|
|
function ($class) {
|
|
// Only continue if the class is in our namespace.
|
|
if (strpos($class, 'libs\\') === 0) {
|
|
// Replace namespace separators with directory separators in the class name, append
|
|
// with .php
|
|
$file = NN_ROOT . str_replace('\\', DIRECTORY_SEPARATOR, $class) . '.php';
|
|
|
|
// if the file exists, require it
|
|
if (file_exists($file)) {
|
|
require_once $file;
|
|
}
|
|
}
|
|
}
|
|
);
|
|
|
|
/**
|
|
*
|
|
* @param string $class The fully-qualified class name.
|
|
*
|
|
* @return void
|
|
*/
|
|
spl_autoload_register(
|
|
function($class) {
|
|
// base directory for the namespace prefix
|
|
$base_dir = __DIR__ . DIRECTORY_SEPARATOR;
|
|
|
|
// replace the namespace prefix with the base directory, replace namespace
|
|
// separators with directory separators in the relative class name, append
|
|
// with .php
|
|
$file = $base_dir . str_replace('\\', DIRECTORY_SEPARATOR, $class) . '.php';
|
|
|
|
// if the file exists, require it
|
|
if (file_exists($file) && is_readable($file)) {
|
|
require_once $file;
|
|
} else {
|
|
// Let's try the old style format with 'class.' prefixed to the lower-cased filename.
|
|
// This bypasses the concept of a Vendor namespace as older libs don't use it.
|
|
|
|
$filename = 'class.' . strtolower($class) . '.php';
|
|
$DirIterator = new \DirectoryIterator($base_dir);
|
|
foreach ($DirIterator as $fileInfo) {
|
|
if ($fileInfo->isDir() && !$fileInfo->isDot()) {
|
|
$file = $fileInfo->getPathname() . DIRECTORY_SEPARATOR . $filename;
|
|
if (file_exists($file) && is_readable($file)) {
|
|
require_once $file;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
);
|
|
|
|
?>
|