Added 403 Error Files
Improved maker
This commit is contained in:
2012-09-07 15:33:50 -05:00
parent f17d80c079
commit d6e8a4ccd4
7 changed files with 88 additions and 6 deletions

View File

@@ -22,24 +22,28 @@ ob_start();
$uri = new Uri_library($_SERVER['REQUEST_URI']);
$uri_array = $uri->getFullArray();
$class_name = (!isset($uri_array[0]) || empty($uri_array[0]))?$default_controller:array_shift($uri_array);
while($starting_token-- > 0) { array_shift($uri_array); }
// Check if $uri->getItem(0) is a controller
if(file_exists(APP_ROOT.'/controllers/'.$uri_array[0].'_controller.php')) {
if(file_exists(APP_ROOT.'/controllers/'.$class_name.'_controller.php')) {
// File exists, set the cc_name and pop the uri_array
$class_name = array_shift($uri_array);
$cc_name = $class_name."_controller";
} else {
// Not a valid controller, so hit the default
$cc_name = $default_controller."_controller";
// Not a valid controller, so 404d!
header("HTTP/1.0 404 Not Found");
echo "Page Not Found";
exit;
// $cc_name = $default_controller."_controller";
}
// Pull in the requested Controller
require_once(APP_ROOT.'/controllers/'.$cc_name.'.php');
$c_class = new $cc_name;
// Were we provided a method?
$c_func = $uri_array[0];
$c_func = (!isset($uri_array[0]) || empty($uri_array[0]))?"index":array_shift($uri_array);
if($c_func!==false && method_exists($c_class, $c_func)) {
$c_func = array_shift($uri_array);
call_user_func_array(array($c_class, $c_func), $uri_array);
} else {
// Nope, hit the controller's index