Skip to content

Commit

Permalink
fix: Fix routing issues
Browse files Browse the repository at this point in the history
  • Loading branch information
carlansell94 committed Dec 29, 2024
1 parent 1919743 commit 8353f90
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
10 changes: 5 additions & 5 deletions src/Router.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ public function getDefaultRoute(): string

public function getLoginPage(): void
{
header('Location: /' . SITE_ROOT . '/' . ADMIN_URL . '/login');
header('Location: /' . SITE_ROOT . '/' . ADMIN_URL . '/login/');
die();
}

public function logout(): void
{
header('Location: ' . SITE_ROOT . '/');
header('Location: /' . SITE_ROOT . '/');
Session::end();
die();
}
Expand All @@ -81,9 +81,9 @@ public function parseUrl(): void
$uri = str_replace(SITE_ROOT, '', $uri);
}

if (str_starts_with($uri, '/' . ADMIN_URL)) {
if (str_starts_with($uri, '/' . ADMIN_URL) || str_starts_with($uri, ADMIN_URL)) {
$this->is_admin_url = true;
$uri = str_replace('/' . ADMIN_URL, '', $uri);
$uri = str_replace(ADMIN_URL, '', $uri);
}

$route = array_filter(explode("/", parse_url(
Expand Down Expand Up @@ -215,7 +215,7 @@ private function executePostRequest(Controller $controller): void
}

Session::login();
header('Location: /' . SITE_ROOT . '/' . ADMIN_URL);
header('Location: /' . SITE_ROOT . '/' . ADMIN_URL . '/');
die();
}

Expand Down
2 changes: 1 addition & 1 deletion src/Session/login.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<header>
<h1><?= $title ?></h1>
</header>
<form name="login" action="login" method="post">
<form name="login" action="<?= $_SERVER['REQUEST_URI'] ?>" method="post">
<?php if (isset($_SESSION['login_fails'])) : ?>
<div id='login-error'>Incorrect Username/Password</div>
<?php endif; ?>
Expand Down
2 changes: 1 addition & 1 deletion themes/admin/head.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="/<?= SITE_ROOT . '/themes/admin/style.css' ?>">
<link rel="stylesheet" href="<?= '/' . SITE_ROOT . '/themes/admin/style.css' ?>">
<title><?= $this->getPageTitle() ?></title>
</head>
<body>
10 changes: 5 additions & 5 deletions themes/admin/nav.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,25 +34,25 @@
<nav id="main-header-nav">
<ul>
<li>
<a href="<?= $this->getRootUrl() ?>posts">
<a href="<?= $this->getRootUrl() ?>posts/">
<img src="<?= self::getAssetsUrl() ?>icons/post.svg" alt="Posts" />
Posts
</a>
</li>
<li>
<a href="<?= $this->getRootUrl() ?>categories">
<a href="<?= $this->getRootUrl() ?>categories/">
<img src="<?= self::getAssetsUrl() ?>icons/categories.svg" alt="categories" />
Categories
</a>
</li>
<li>
<a href="<?= $this->getRootUrl() ?>tags">
<a href="<?= $this->getRootUrl() ?>tags/">
<img src="<?= self::getAssetsUrl() ?>icons/tags.svg" alt="Tags" />
Tags
</a>
</li>
<li>
<a href="/<?= SITE_ROOT ?>">
<a href="/<?= SITE_ROOT ?>/">
<img src="<?= self::getAssetsUrl() ?>icons/preview.svg" alt="Preview" />
Preview Site
</a>
Expand All @@ -62,7 +62,7 @@
<nav id="account-controls">
<ul>
<li>
<a href="<?= $this->getRootUrl() ?>logout">
<a href="<?= $this->getRootUrl() ?>logout/">
<img src="<?= self::getAssetsUrl() ?>icons/logout.svg" alt="Logout" />
Logout
</a>
Expand Down

0 comments on commit 8353f90

Please sign in to comment.