Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ini_set('display_errors', 1);
- require_once 'application/bootstrap.php';
- require_once 'core/Model.php';
- require_once 'core/View.php';
- require_once 'core/Controller.php';
- require_once 'core/Route.php';
- Route::start();
- RewriteEngine On
- RewriteCond %{REQUEST_FILENAME} !-f
- RewriteCond %{REQUEST_FILENAME} !-d
- RewriteRule .* index.php [L]
- static function start()
- {
- $controller_name = 'Main';
- $action_name = 'Index';
- $routes = explode('/', $_SERVER['REQUEST_URI']);
- var_dump($routes);
- if (!empty($routes[2])) {
- $controller_name = $routes[2];
- }
- if (!empty($routes[3])) {
- $action_name = $routes[3];
- }
- $model_name = 'Model' . $controller_name;
- $controller_name = 'Controller' . $controller_name;
- $action_name = 'action' . $action_name;
- $model_file = $model_name . '.php';
- $model_path = "application/models/" . $model_file;
- if (file_exists($model_path)) {
- include "application/models/" . $model_file;
- }
- $controller_file = $controller_name . '.php';
- $controller_path = "application/controllers/" . $controller_file;
- if (file_exists($controller_path)) {
- include "application/controllers/" . $controller_file;
- } else {
- Route::ErrorPage404();
- }
- $controller = new $controller_name;
- $action = $action_name;
- print $controller_name;
- echo "<br/>";
- print $action;
- if (method_exists($controller, $action)) {
- $controller->$action();
- } else {
- Route::ErrorPage404();
- }
- }
- function ErrorPage404()
- {
- print "trouble";
- $host = 'http://' . $_SERVER['HTTP_HOST'] . '/';
- header('HTTP/1.1 404 Not Found');
- header("Status: 404 Not Found");
- header('Location:' . $host . '404');
- }
Add Comment
Please, Sign In to add comment