aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlonkaars <loek@pipeframe.xyz>2023-05-09 13:54:37 +0200
committerlonkaars <loek@pipeframe.xyz>2023-05-09 13:54:37 +0200
commit6d5c72f908e8f7c1c2b0defa696aad43c55fc1ba (patch)
treedc25b39f7f53b430e2d8eaccf5f077a1150beba8
parent770658c8434d7b7c0e716b7e375c733e79dc4a88 (diff)
add logout link to footer
-rw-r--r--public/footer.css8
-rw-r--r--public/footer.php7
-rw-r--r--public/logout.php9
3 files changed, 18 insertions, 6 deletions
diff --git a/public/footer.css b/public/footer.css
index 0483da2..7d0360f 100644
--- a/public/footer.css
+++ b/public/footer.css
@@ -1,12 +1,8 @@
-footer {
- margin-top: 48px;
-}
+footer { margin-top: 96px; }
footer .flex {
display: flex;
justify-content: space-between;
}
-footer .flex * {
- margin: 20px 0;
-}
+footer .inner { margin: 20px auto; }
diff --git a/public/footer.php b/public/footer.php
index 57831be..d42bef5 100644
--- a/public/footer.php
+++ b/public/footer.php
@@ -1,8 +1,15 @@
+<?php require_once "../lib/login.php" ?>
<footer>
<div class="inner limwidth">
<div class="flex">
<span class="left">de winkel website</span>
<span class="right">dit is een footer hoor</span>
</div>
+ <?php if ($logged_in) echo <<<"EOF"
+ <div class="flex">
+ <span class="left"></span>
+ <span class="right"><a href="/logout.php">LAAT ME ERUIT</a></span>
+ </div>
+ EOF; ?>
</div>
</footer>
diff --git a/public/logout.php b/public/logout.php
new file mode 100644
index 0000000..094ee22
--- /dev/null
+++ b/public/logout.php
@@ -0,0 +1,9 @@
+<?php
+$prev = $_COOKIE['prev'];
+if (!$prev) $prev = "/";
+http_response_code(302);
+setcookie("prev", null, -1, "/");
+setcookie("username", null, -1, "/");
+setcookie("password", null, -1, "/");
+header("Location: ".$prev);
+?>