From ca82a9e0c80c7bf94350cc8426f57c4a351c92c1 Mon Sep 17 00:00:00 2001 From: Sven Slootweg Date: Sun, 9 Jun 2013 03:12:56 +0200 Subject: [PATCH] Add basic autoloader --- base.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/base.php b/base.php index e7e8123..a09d8cd 100644 --- a/base.php +++ b/base.php @@ -83,3 +83,20 @@ if(get_magic_quotes_gpc()) $var = stripslashes($var); } } + +if(!empty($cphp_config->autoloader)) +{ + function cphp_autoload_class($class_name) + { + global $_APP; + + $class_name = str_replace("\\", "/", strtolower($class_name)); + + if(file_exists("classes/{$class_name}.php")) + { + require_once("classes/{$class_name}.php"); + } + } + + spl_autoload_register('cphp_autoload_class'); +}