From 8b55b69339146f0b03b01dd1c12501754cbd9de0 Mon Sep 17 00:00:00 2001 From: Silvio Date: Mon, 18 Oct 2010 10:28:56 -0200 Subject: Enhancing autoloader --- index.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'index.php') diff --git a/index.php b/index.php index 392fa28..357d918 100644 --- a/index.php +++ b/index.php @@ -5,17 +5,23 @@ // Autoloader. function cinisis_autoload($class) { + $base = dirname(__FILE__) .'/'; + if (strstr($class, 'Db')) { - require_once 'classes/backends/'. $class .'.php'; + $file = 'classes/backends/'. $class .'.php'; } elseif (strstr($class, 'Iterator')) { - require_once 'classes/iterators/'. $class .'.php'; + $file = 'classes/iterators/'. $class .'.php'; } elseif (strstr($class, 'Helper')) { - require_once 'classes/helpers/'. $class .'.php'; + $file = 'classes/helpers/'. $class .'.php'; } else { - require_once 'classes/'. $class .'.php'; + $file = 'classes/'. $class .'.php'; + } + + if (file_exists($base . $file)) { + require_once $base . $file; } } -- cgit v1.2.3