<?php
// Helper functions
require "Common.php";
$TM =& load_class("Timer");
// Master Controller
require "Engine.php";
$EN = new Engine();
if(!function_exists('get_big_object')){
function &get_big_object(){
return Engine::get_big_object();
}
}
$DB =& load_class("Database");
// Fetch URL
// 0 -> class
// 1 -> method ( if not exist will be index)
// >2 -> Arguments
$URI = URL();
// Logic's
if($URI[0]=='/'){
// Load class
require CONTROLLER."Index.php";
$CL = new Index();
if(method_exists($CL, "index")){
$CL->index();
}else{
echo log_msg("Method Index doens't exists on Index");
exit;
}
}else if(isset($URI[0]) && $URI[0]!='/'){
// Other methods !index.php
$class = ucfirst($URI[0]);
$method = isset($URI[1]) ? strtolower($URI[1]) : 'Index' ;
if(!file_exists(CONTROLLER.ucfirst($URI[0]).".php")){
echo log_msg("File doens exists:: ".CONTROLLER.ucfirst($URI[0]).".php");
exit;
}
require CONTROLLER.ucfirst($class).".php";
$CL = new $class();
if(method_exists($CL, $method)){
$CL->$method();
}else{
echo log_msg("Method ".$method." doens't exists on ".$class);
exit;
}
}else{
// Ups, Erro!
echo log_msg("Unespect Erro it was found!");
}
?>
|