summaryrefslogtreecommitdiff
path: root/_gallery/index.php
diff options
context:
space:
mode:
Diffstat (limited to '_gallery/index.php')
-rw-r--r--_gallery/index.php122
1 files changed, 0 insertions, 122 deletions
diff --git a/_gallery/index.php b/_gallery/index.php
deleted file mode 100644
index 1ac8e23..0000000
--- a/_gallery/index.php
+++ /dev/null
@@ -1,122 +0,0 @@
-<?php
-
-require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/functions.php";
-require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.php";
-
-$id = array_values(array_filter(array_keys($_GET), function ($i) {
- return str_starts_with($i, "/") && strlen($i) > 1;
-}))[0] ?? null;
-
-if (isset($id)) {
- $id = substr($id, 1);
- if (!preg_match("/[a-zA-Z0-6]/m", $id)) {
- header("Location: /gallery");
- die();
- }
-
- if (!file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gallery/" . $id . ".json")) {
- header("Location: /gallery");
- die();
- }
-
- $data = json_decode(pf_utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gallery/" . $id . ".json")), true);
-
- $title_pre = getNameFromId($id);
- $title = "lang_gallery_title";
-} else {
- $title = "lang_gallery_title";
-}
-
-require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/header.php";
-require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/navigation.php";
-
-if (!isset($id)):
-?>
-
-<div class="container">
- <br><br>
- <h1><?= l("lang_gallery_title") ?></h1>
-
- <?php listAlbums(); ?>
-
- <br><br>
-</div>
-
-<?php else: ?>
-
-<div class="container">
- <br><br>
- <h1 id="btn-area-container" style="display: grid; grid-template-columns: 1fr max-content;">
- <span><?= getNameFromId($id) ?></span>
- <span id="btn-area" class="btn-group"><a style="height: 38px;" href="/upload/<?= $id ?>" class="btn btn-outline-primary btn-with-img" title="<?= l("lang_gallery_upload") ?>" data-bs-toggle="tooltip"><img src="/icons/upload.svg?p" style="width: 24px;"></a><a style="height: 38px;" href="/request/?type=rename&id=<?= $id ?>" class="btn btn-outline-dark btn-with-img" title="<?= l("lang_articles_rename") ?>" data-bs-toggle="tooltip"><img src="/icons/rename.svg" style="width: 24px;"></a><a style="height: 38px;" href="/edit/<?= $id ?>" class="btn btn-outline-dark btn-with-img" title="<?= l("lang_people_edit") ?>" data-bs-toggle="tooltip"><img src="/icons/edit.svg" style="width: 24px;"></a><a style="height: 38px;" onclick="copy('<?= uuidToId($id) ?>', true)" class="btn btn-outline-dark btn-with-img" title="<?= l("lang_shortener_copy") ?>" data-bs-toggle="tooltip"><img src="/icons/copy.svg" style="width: 24px;"></a></span>
- </h1>
-
- <div>
- <div>
- <?php if (isset($data["images"]) && count($data["images"]) > 0): ?>
- <?php if (isset($data["contents"]) && trim($data["contents"] !== "")): ?>
- <div>
- <?= doLinking($data["contents"]) ?>
- </div>
- <small class="print-ignore text-muted"><?= isset($data["update_user"]) ? str_replace("%2", "<a class='update-user' href='/profile/" . $data["update_user"] . "'>" . resolveUser($data["update_user"]) . "</a>", str_replace("%1", timeAgo($data["update"]), l("lang_time_update_user"))) : str_replace("%1", timeAgo($data["update"]), l("lang_time_update")) ?></small>
- <?php endif;
-
- $images = $data["images"];
- shuffle($images);
-
- ?>
-
- <div style="display: grid; grid-template-columns: repeat(3, 1fr); grid-gap: 20px;">
- <div>
- <?php $index = 1; foreach ($images as $image): if ($index % 3 === 1): ?>
- <a href="#" onclick="showGalleryItem(<?= $index ?>);"><img id="gallery-item-<?= $index ?>" title="<?= l("lang_gallery_uploader") . " " . resolveUser($image["author"]) . " " . timeAgo($image["date"]) ?>" src="/uploads/<?= $image["id"] ?>.webp" style="width: 100%; margin-top: 20px; border-radius: 10px;" data-bs-toggle="tooltip"></a>
- <?php endif; $index++; endforeach; ?>
- </div>
- <div>
- <?php $index = 1; foreach ($images as $image): if ($index % 3 === 2): ?>
- <a href="#" onclick="showGalleryItem(<?= $index ?>);"><img id="gallery-item-<?= $index ?>" title="<?= l("lang_gallery_uploader") . " " . resolveUser($image["author"]) . " " . timeAgo($image["date"]) ?>" src="/uploads/<?= $image["id"] ?>.webp" style="width: 100%; margin-top: 20px; border-radius: 10px;" data-bs-toggle="tooltip"></a>
- <?php endif; $index++; endforeach; ?>
- </div>
- <div>
- <?php $index = 1; foreach ($images as $image): if ($index % 3 === 0): ?>
- <a href="#" onclick="showGalleryItem(<?= $index ?>);"><img id="gallery-item-<?= $index ?>" title="<?= l("lang_gallery_uploader") . " " . resolveUser($image["author"]) . " " . timeAgo($image["date"]) ?>" src="/uploads/<?= $image["id"] ?>.webp" style="width: 100%; margin-top: 20px; border-radius: 10px;" data-bs-toggle="tooltip"></a>
- <?php endif; $index++; endforeach; ?>
- </div>
- </div>
- <?php else: ?>
- <p class="text-muted"><?= l("lang_gallery_empty") ?></p>
- <?php endif; ?>
- </div>
- </div>
-
- <div class="modal fade" id="gallery-view">
- <div class="modal-dialog modal-xl">
- <div class="modal-content">
- <div class="modal-header">
- <h4 class="modal-title" id="gallery-view-title">-</h4>
- <button type="button" class="btn-close" data-bs-dismiss="modal"></button>
- </div>
-
- <div class="modal-body">
- <div id="gallery-view-img" style="height: calc(100vh - 140px);width: calc(100% + 2rem);margin: -1rem;border-bottom-left-radius: 0.5rem;border-bottom-right-radius: 0.5rem;background-size: contain;background-position: center;background-repeat: no-repeat;"></div>
- </div>
- </div>
- </div>
- </div>
-
- <!--suppress JSUnresolvedVariable -->
- <script>
- function showGalleryItem(id) {
- let item = document.getElementById("gallery-item-" + id);
- document.getElementById("gallery-view-title").innerText = item.getAttribute("data-bs-original-title").replace(/ +/g, " ");
- document.getElementById("gallery-view-img").style.backgroundImage = 'url("' + item.src + '")';
- new bootstrap.Modal(document.getElementById("gallery-view")).show();
- }
- </script>
-
- <br><br>
-</div>
-
-<?php addToUserHistory($id); endif; ?>
-
-<?php require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/footer.php"; ?>