Files

50 lines
1000 B
PHP
Raw Permalink Normal View History

2026-10-18 17:01:36 +00:00
<?php
Base_Autoloader::Register();
// ================
// Autoloader Class
// ================
class Base_Autoloader {
public static function Register() {
if (function_exists("__autoload")) {
spl_autoload_register("__autoload");
}
2026-10-18 19:27:17 -04:00
2026-10-18 17:01:36 +00:00
return spl_autoload_register(array("Base_Autoloader", "Load"), true, true);
2026-10-18 19:27:17 -04:00
2026-10-18 17:01:36 +00:00
}
public static function Load($pClassName) {
2026-10-18 19:27:17 -04:00
2026-10-18 17:01:36 +00:00
if (class_exists($pClassName, false)) {
return false;
}
2026-10-18 19:27:17 -04:00
if (!preg_match('/\A[A-Za-z_][A-Za-z0-9_]*\z/', $pClassName)) return false;
2026-10-18 17:01:36 +00:00
// Try for a "classes" Class first, then a "reports" Class.
2026-10-18 19:27:17 -04:00
$pClassFilePath = __DIR__ . "/{$pClassName}.php";
2026-10-18 17:01:36 +00:00
if ((file_exists($pClassFilePath) === false) || (is_readable($pClassFilePath) === false)) {
2026-10-18 19:27:17 -04:00
$pClassFilePath = __DIR__ . "/../reports/{$pClassName}.php";
2026-10-18 17:01:36 +00:00
if ((file_exists($pClassFilePath) === false) || (is_readable($pClassFilePath) === false)) {
return false;
}
2026-10-18 19:27:17 -04:00
2026-10-18 17:01:36 +00:00
}
require($pClassFilePath);
2026-10-18 19:27:17 -04:00
2026-10-18 17:01:36 +00:00
}
}
2026-10-18 19:27:17 -04:00
?>