diff --git a/add_url.php b/_wip_todo/add_url.php similarity index 100% rename from add_url.php rename to _wip_todo/add_url.php diff --git a/index_old.php b/_wip_todo/index_old.php similarity index 100% rename from index_old.php rename to _wip_todo/index_old.php diff --git a/router.php b/_wip_todo/router.php similarity index 100% rename from router.php rename to _wip_todo/router.php diff --git a/session.php b/_wip_todo/session.php similarity index 100% rename from session.php rename to _wip_todo/session.php diff --git a/style_minimal.css b/_wip_todo/style_minimal.css similarity index 100% rename from style_minimal.css rename to _wip_todo/style_minimal.css diff --git a/style_papermod.css b/_wip_todo/style_papermod.css similarity index 100% rename from style_papermod.css rename to _wip_todo/style_papermod.css diff --git a/style_pixelblog.css b/_wip_todo/style_pixelblog.css similarity index 100% rename from style_pixelblog.css rename to _wip_todo/style_pixelblog.css diff --git a/index.php b/index.php index 2ac6c63..a18c429 100644 --- a/index.php +++ b/index.php @@ -1,8 +1,10 @@ 'post.php', // matches only twtHash of exactly 7 alphanumeric characters ]; + // Loop through the defined routes and try to match the request URI foreach ($routes as $pattern => $action) { - if (preg_match('#^' . $pattern . '$#', $path, $matches)) { + if (preg_match('#^' . $base.$pattern . '$#', $path, $matches)) { // Extract any matched parameters (e.g., username) if(!empty($matches[1])) { @@ -46,6 +49,7 @@ foreach ($routes as $pattern => $action) { // If no matching route is found, handle as a 404 http_response_code(404); echo "

Oops! Page not found.

"; +echo __DIR__ . $viewDir . $action; /* Credit: - PHP FOR BEGINNERS #4 - Create a dynamic Router: https://www.youtube.com/watch?v=eaHBK2XJ5Io diff --git a/partials/header.php b/partials/header.php index 7cceda7..f3ef67b 100644 --- a/partials/header.php +++ b/partials/header.php @@ -1,7 +1,7 @@ diff --git a/views/home.php b/views/home.php index 4039f51..5e5e619 100644 --- a/views/home.php +++ b/views/home.php @@ -33,12 +33,12 @@ if (!empty($_GET['twts'])) { // Show profile for some user if (isset($_SESSION['password'])) { include 'views/new_twt.php'; // TODO: Split up new_twt into a view and a partial } -else { +/*else { $twtsURL = $config['public_txt_url']; // $twtsURL = "http://darch.dk/twtxt.txt"; - header("Location: /profile?url=".$twtsURL); + header("Location: profile?url=".$twtsURL); // die(); -} +}*/ ?>