Example #1
0
}
// register class autoloader function
spl_autoload_register("ClassAutoloader");
// purge expired chart cache images
$cachedir = dir(CHART_CACHE);
while (($img = $cachedir->read()) !== false) {
    if ($img != "." && $img != ".." && substr($img, -4, 4) == ".png") {
        if (filemtime(CHART_CACHE . "/{$img}") < time() - CHART_CACHE_EXPIRE) {
            unlink(CHART_CACHE . "/{$img}");
        }
    }
}
// create router and run requested controller
$router = new Router();
$router->setPath(APP_PATH . "/controllers");
$router->loader();
/**
 * Class autoloader function saves having to manually include each class and model file.
 * 
 * @param string $class		- class or model
 * 
 * @return void
 */
function ClassAutoloader($class)
{
    foreach (array("classes", "models") as $dir) {
        if (file_exists(APP_PATH . "/{$dir}/{$class}.php")) {
            require_once APP_PATH . "/{$dir}/{$class}.php";
        }
    }
}