function autoloader($class)
{
global $g;
$class = strtolower($class);
if ($class =='chtml')
{
$file = $g['path']['url_main'] . '_include/lib/' . substr($class,1) . '.php';
}
else if (strpos($class, 'chtml') === 0)
{
$file = $g['path']['url_main'] . '_include/lib/' . substr($class,5) . '.php';
}
else if (strpos($class, 'db_') === 0)
{
$file = $g['path']['url_main'] . '_include/lib/' . $class . '.php';
}
else if ($class =='cbanner')
{
$file = $g['path']['url_main'] . '_include/current/' . substr($class,1) . '.class.php';
}
else if ($class =='userfields')
{
$file = $g['path']['url_main'] . '_include/current/user_fields.class.php';
}
else
{
$file = $g['path']['url_main'] . '_include/current/' . $class . '.class.php';
}
//print_r($file);
if (file_exists($file))
{
require $file;
return true;
}
return false;
}
spl_autoload_register('autoloader');
this in autoloader.php