summaryrefslogtreecommitdiffstats
path: root/index.php
diff options
context:
space:
mode:
authorMaksymilian Jopek <maks@jopek.eu>2023-04-13 15:47:15 +0200
committerMaksymilian Jopek <maks@jopek.eu>2023-04-13 15:47:15 +0200
commit87ffa36c1bfa49259e48d94f09e64f83632f0071 (patch)
tree87a5f2157474c6b31a2efddaf8df5aad886ff070 /index.php
downloadcms-87ffa36c1bfa49259e48d94f09e64f83632f0071.tar.gz
cms-87ffa36c1bfa49259e48d94f09e64f83632f0071.tar.zst
cms-87ffa36c1bfa49259e48d94f09e64f83632f0071.zip
Diffstat (limited to 'index.php')
-rw-r--r--index.php91
1 files changed, 91 insertions, 0 deletions
diff --git a/index.php b/index.php
new file mode 100644
index 0000000..0a1d9b2
--- /dev/null
+++ b/index.php
@@ -0,0 +1,91 @@
+<?php
+session_start();
+if ($_SESSION["logged"] === true) {
+ header("HTTP/1.0 307 Teapot is waiting for you :>");
+ header("Location: main.php");
+}
+?>
+<!doctype html>
+<html lang="en">
+
+<head>
+ <!-- Required meta tags -->
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+
+ <!-- Bootstrap CSS -->
+ <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-wEmeIV1mKuiNpC+IOBjI7aAzPcEZeedi5yW5f2yOq55WWLwNGmvvx4Um1vskeMj0" crossorigin="anonymous">
+
+ <title>CMS - Login</title>
+</head>
+
+<body class="bg-dark text-white">
+ <form method="POST" action="login.php" class="container" style="margin: 0 auto; width: fit-content">
+ <h1 class="text-center fw-bold">Login</h1>
+ <div>
+ <label for="username" class="m-1">Username:</label><br>
+ <input type="text" name="username" id="username" size="30"><br>
+ </div>
+ <div style="margin-top: 30px;">
+ <label for="password" class="m-1">Password:</label><br>
+ <input type="password" name="password" id="password" size="30">
+ </div>
+ <div style="margin-top: 15px;">
+ <div style="float: left;">
+ <input type="checkbox" name="remember" id="remember">
+ <label for="remember">Remember me</label>
+ </div>
+ <div style="float: right;">
+ <a href="#">Forgot password?</a>
+ </div>
+ </div>
+ <div class="text-center" style="margin-top: 70px;">
+ <button type="submit" class="btn btn-primary btn-lg">Log in</button>
+ </div>
+ <div style="margin-top: 30px;">
+ <div style="float: right;">
+ <a href="#">You don't have an account?</a>
+ </div>
+ </div>
+ </form>
+ <div class="modal fade" id="errorModal" tabindex="-1" aria-labelledby="errorModalLabel" aria-hidden="true">
+ <div class="modal-dialog">
+ <div class="modal-content">
+ <div class="modal-header">
+ <h5 class="modal-title text-dark" id="errorModalLabel">Error</h5>
+ <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
+ </div>
+ <div class="modal-body text-dark">
+ <?= $_SESSION["error"] ?>
+ </div>
+ <div class="modal-footer">
+ <button type="button" class="btn btn-danger" data-bs-dismiss="modal">Close</button>
+ </div>
+ </div>
+ </div>
+ </div>
+ <button type="button" style="display: none;" id="btnErrorModal" data-bs-toggle="modal" data-bs-target="#errorModal">
+ </button>
+ <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0/dist/js/bootstrap.bundle.min.js" integrity="sha384-p34f1UUtsS3wqzfto5wAAmdvj+osOnFyQFpp4Ua3gs/ZVWx6oOypYoCJhGGScy+8" crossorigin="anonymous"></script>
+ <script>
+ let errorModal = new bootstrap.Modal(document.getElementById('errorModal'));
+ let show = <?= isset($_SESSION["error"]) === true ? 1 : 0 ?>;
+ if (show === 1)
+ errorModal.show();
+
+ function getCookie(name) {
+ const parts = `; ${document.cookie}`.split(`; ${name}=`);
+ if (parts.length === 2) return parts.pop().split(';').shift();
+ else return null;
+ }
+ let username = getCookie("username");
+ console.log(username)
+ if(username !== null) {
+ document.getElementById("username").value = getCookie("username");
+ document.getElementById("remember").checked = true;
+ }
+ </script>
+</body>
+<?php unset($_SESSION["error"]); ?>
+
+</html> \ No newline at end of file