From 5bfdac005fc690d4c5e9491b5a1395cd42d54d84 Mon Sep 17 00:00:00 2001 From: sorenpeter Date: Wed, 8 Nov 2023 20:58:00 +0100 Subject: [PATCH] somewhat broken... --- add_url.php => _wip_todo/add_url.php | 0 index_old.php => _wip_todo/index_old.php | 0 router.php => _wip_todo/router.php | 0 session.php => _wip_todo/session.php | 0 style_minimal.css => _wip_todo/style_minimal.css | 0 style_papermod.css => _wip_todo/style_papermod.css | 0 style_pixelblog.css => _wip_todo/style_pixelblog.css | 0 index.php | 12 ++++++++---- partials/header.php | 2 +- views/home.php | 6 +++--- 10 files changed, 12 insertions(+), 8 deletions(-) rename add_url.php => _wip_todo/add_url.php (100%) rename index_old.php => _wip_todo/index_old.php (100%) rename router.php => _wip_todo/router.php (100%) rename session.php => _wip_todo/session.php (100%) rename style_minimal.css => _wip_todo/style_minimal.css (100%) rename style_papermod.css => _wip_todo/style_papermod.css (100%) rename style_pixelblog.css => _wip_todo/style_pixelblog.css (100%) 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(); -} +}*/ ?>