summaryrefslogtreecommitdiffstats
path: root/index.php
diff options
context:
space:
mode:
authorMaksymilian Jopek <maks@jopek.eu>2022-03-16 23:20:59 +0100
committerMaksymilian Jopek <maks@jopek.eu>2022-03-16 23:20:59 +0100
commitbf7852bccce954aff2d7c94161f4d301a0f29684 (patch)
treefc3f2aac4f843990b02992e02903df22857a1928 /index.php
downloadmlos-bf7852bccce954aff2d7c94161f4d301a0f29684.tar.gz
mlos-bf7852bccce954aff2d7c94161f4d301a0f29684.tar.zst
mlos-bf7852bccce954aff2d7c94161f4d301a0f29684.zip
Initial commit w/ v1.0.0
Diffstat (limited to 'index.php')
-rw-r--r--index.php106
1 files changed, 106 insertions, 0 deletions
diff --git a/index.php b/index.php
new file mode 100644
index 0000000..ea19837
--- /dev/null
+++ b/index.php
@@ -0,0 +1,106 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8" />
+ <link rel="icon" type="image/svg+xml" href="favicon.svg" />
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+ <title>Markup Language of Saddness</title>
+ <link rel="stylesheet" href="src/style.css" />
+</head>
+
+<?php
+require_once "src/data.php";
+[$data, $count] = get_data();
+function is_pos(): bool
+{
+ return $_GET["m"] === "pos" || $_GET["m"] === "" || !$_GET["m"];
+}
+?>
+
+<body>
+ <header>
+ <button type="button"><a href="?m=pos">Positions</a></button>
+ <button type="button"><a href="?m=pre">Preview</a></button>
+ </header>
+ <table>
+ <thead>
+ <tr>
+ <th></th>
+ <th></th>
+ <th>Game name</th>
+ <th>Thumbnail</th>
+ <th>Author</th>
+ <th>Magazine</th>
+ <th></th>
+ <th></th>
+ </tr>
+ </thead>
+ <tbody>
+ <?php if (is_pos()) { ?>
+ <?php foreach ($data as $d) { ?>
+ <tr>
+ <form action="api/change-order.php" method="post">
+ <td>
+ <?php if ($d["order"] !== $count) { ?>
+ <input type="hidden" name="old-order" value="<?= $d["order"] ?>">
+ <input type="hidden" name="new-order" value="<?= intval($d["order"]) + 1 ?>">
+ <input type="submit" value="pos -" />
+ <?php } ?>
+ </td>
+ </form>
+ <form action="api/remove.php" method="post">
+ <td><input type="submit" onclick="edit(event)" value="E" data-id="<?= $d['id'] ?>"></td>
+ <td data-id="<?= $d['id'] ?>"><?= htmlspecialchars($d["name"]) ?></td>
+ <td data-id="<?= $d['id'] ?>"><?= htmlspecialchars($d["thumbnail"]) ?></td>
+ <td data-id="<?= $d['id'] ?>"><?= htmlspecialchars($d["author"]) ?></td>
+ <td data-id="<?= $d['id'] ?>"><?= $d["magazine"] ?></td>
+ <td><input type="submit" value="Remove" data-id="<?= $d['id'] ?>"></td>
+ <input type="hidden" name="id" value="<?= $d['id'] ?>" data-id="<?= $d['id'] ?>" />
+ </form>
+ <form action="api/change-order.php" method="post">
+ <td>
+ <?php if ($d["order"] !== "1") { ?>
+ <input type="hidden" name="old-order" value="<?= $d["order"] ?>">
+ <input type="hidden" name="new-order" value="<?= intval($d["order"]) - 1 ?>">
+ <input type="submit" value="pos +" />
+ <?php } ?>
+ </td>
+ </form>
+ </tr>
+ <?php } ?>
+ <?php } ?>
+ <?php if ($_GET["m"] === "pre") { ?>
+ <?php foreach ($data as $d) { ?>
+ <tr>
+ <form action="api/remove.php" method="post">
+ <td></td>
+ <td data-id="<?= $d['id'] ?>"><?= htmlspecialchars($d["name"]) ?></td>
+ <td data-id="<?= $d['id'] ?>"><img src="/imgs/<?= htmlspecialchars($d["thumbnail"]) ?>" width="200" /></td>
+ <td data-id="<?= $d['id'] ?>"><?= htmlspecialchars($d["author"]) ?></td>
+ <td data-id="<?= $d['id'] ?>"><?= $d["magazine"] ?></td>
+ <td></td>
+ </form>
+ </tr>
+ <?php } ?>
+ <?php } ?>
+ <?php if (is_pos()) { ?>
+ <tr>
+ <form action="api/add.php" method="post">
+ <td></td>
+ <td></td>
+ <td><input type="text" name="name"></td>
+ <td><input type="text" name="thumbnail"></td>
+ <td><input type="text" name="author"></td>
+ <td><input type="text" name="magazine"></td>
+ <td><input type="submit" value="Add"></td>
+ </form>
+ </tr>
+ <?php } ?>
+ </tbody>
+ </table>
+ <a href="/api/export.php">Export to xlsx</a>
+ <script src="/src/main.js"></script>
+</body>
+
+</html>