__autoload

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
function __autoload($class_name){
$paths[]=ABS_PATH.'core/classes/'.strtolower($class_name).'.php';
$paths[]=ABS_PATH.'core/classes/'.strtolower($class_name).'/'.strtolower($class_name).'.php';
$paths[]=ABS_PATH.'core/modules/'.strtolower($class_name).".php";
$paths[]=ABS_PATH.'core/modules/'.strtolower($class_name)."/".strtolower($class_name).".mod.php";
foreach($paths as $path){
if(file_exists($path)){
require_once($path);
logger::AddEvent("class '$class_name' success loaded");
return true;
};
}
$str="Ooops, i can't load class '$class_name', I searched this in paths:\n ".implode(";\n ",$paths);
if(class_exists('logger')&&$class_name!='logger'){
logger::AddEvent($str, 'err');
}
else{
die($str);
}
}