From d6e8a4ccd4703338638614caaa95e40ac813c05b Mon Sep 17 00:00:00 2001 From: br0xen Date: Fri, 7 Sep 2012 15:33:50 -0500 Subject: [PATCH] Various Added 403 Error Files Improved maker --- app/controllers/index.php | 13 +++++++++++++ app/core/index.php | 13 +++++++++++++ app/index.php | 13 +++++++++++++ app/libraries/index.php | 13 +++++++++++++ app/models/index.php | 13 +++++++++++++ app/views/index.php | 13 +++++++++++++ index.php | 16 ++++++++++------ 7 files changed, 88 insertions(+), 6 deletions(-) create mode 100644 app/controllers/index.php create mode 100644 app/core/index.php create mode 100644 app/index.php create mode 100644 app/libraries/index.php create mode 100644 app/models/index.php create mode 100644 app/views/index.php diff --git a/app/controllers/index.php b/app/controllers/index.php new file mode 100644 index 0000000..49ba3e9 --- /dev/null +++ b/app/controllers/index.php @@ -0,0 +1,13 @@ + + + + 403 Forbidden + + + +

Directory access is forbidden.

+ + + diff --git a/app/core/index.php b/app/core/index.php new file mode 100644 index 0000000..49ba3e9 --- /dev/null +++ b/app/core/index.php @@ -0,0 +1,13 @@ + + + + 403 Forbidden + + + +

Directory access is forbidden.

+ + + diff --git a/app/index.php b/app/index.php new file mode 100644 index 0000000..49ba3e9 --- /dev/null +++ b/app/index.php @@ -0,0 +1,13 @@ + + + + 403 Forbidden + + + +

Directory access is forbidden.

+ + + diff --git a/app/libraries/index.php b/app/libraries/index.php new file mode 100644 index 0000000..49ba3e9 --- /dev/null +++ b/app/libraries/index.php @@ -0,0 +1,13 @@ + + + + 403 Forbidden + + + +

Directory access is forbidden.

+ + + diff --git a/app/models/index.php b/app/models/index.php new file mode 100644 index 0000000..49ba3e9 --- /dev/null +++ b/app/models/index.php @@ -0,0 +1,13 @@ + + + + 403 Forbidden + + + +

Directory access is forbidden.

+ + + diff --git a/app/views/index.php b/app/views/index.php new file mode 100644 index 0000000..49ba3e9 --- /dev/null +++ b/app/views/index.php @@ -0,0 +1,13 @@ + + + + 403 Forbidden + + + +

Directory access is forbidden.

+ + + diff --git a/index.php b/index.php index 7fcd1a9..77eabe6 100644 --- a/index.php +++ b/index.php @@ -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