aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaindropsSys <contact@minteck.org>2023-04-20 16:20:00 +0200
committerRaindropsSys <contact@minteck.org>2023-04-20 16:20:00 +0200
commit67217883912688dfdf76ed11a99ed1006b733063 (patch)
treeeb0b3296ce63786b60ee3b8a25fe7744fab2088d
parent75ab09321848af770067640926cc25ed6be6bde0 (diff)
downloadbooru-67217883912688dfdf76ed11a99ed1006b733063.tar.gz
booru-67217883912688dfdf76ed11a99ed1006b733063.tar.bz2
booru-67217883912688dfdf76ed11a99ed1006b733063.zip
Updated 4 files and added 2 files (automated)
-rw-r--r--assets/explicit.svg1
-rw-r--r--includes/explicit.php131
-rw-r--r--includes/header.php9
-rw-r--r--includes/session.php3
-rw-r--r--nsfw/index.php28
-rw-r--r--saved/index.php6
6 files changed, 146 insertions, 32 deletions
diff --git a/assets/explicit.svg b/assets/explicit.svg
new file mode 100644
index 0000000..d901df6
--- /dev/null
+++ b/assets/explicit.svg
@@ -0,0 +1 @@
+<svg width="24" height="24" fill="none" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M5.25 3A2.25 2.25 0 0 0 3 5.25v13.5A2.25 2.25 0 0 0 5.25 21h5.8c.053-.26.147-.511.28-.744L13.48 16.5H11.25a.75.75 0 1 1 0-1.5h3.087l.996-1.742c.108-.19.238-.359.383-.508H11.25a.75.75 0 1 1 0-1.5h5.5a.75.75 0 0 1 .75.75 2.497 2.497 0 0 1 2.167 1.258L21 15.589V5.25A2.25 2.25 0 0 0 18.75 3H5.25Zm3.5 5.25a1 1 0 1 1-2 0 1 1 0 0 1 2 0Zm1.75 0a.75.75 0 0 1 .75-.75h5.5a.75.75 0 0 1 0 1.5h-5.5a.75.75 0 0 1-.75-.75ZM7.75 13a1 1 0 1 1 0-2 1 1 0 0 1 0 2Zm1 2.75a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z" fill="#ffffff"/><path d="M17.108 13.053a1.498 1.498 0 0 1 1.69.702l4.004 6.998c.205.36.246.768.145 1.139a1.493 1.493 0 0 1-1.444 1.107h-8.006c-.413 0-.787-.167-1.058-.44a1.495 1.495 0 0 1-.24-1.806l4.002-6.999a1.49 1.49 0 0 1 .907-.701Zm.888 2.447a.5.5 0 0 0-1 0v3a.5.5 0 0 0 1 0v-3Zm-.496 6a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5Z" fill="#ffffff"/></svg> \ No newline at end of file
diff --git a/includes/explicit.php b/includes/explicit.php
new file mode 100644
index 0000000..77f9cc4
--- /dev/null
+++ b/includes/explicit.php
@@ -0,0 +1,131 @@
+<?php global $userName; ?>
+<div class="modal" id="explicit-modal" data-bs-backdrop="static" data-bs-keyboard="false">
+ <div class="modal-dialog">
+ <div class="modal-content">
+ <div class="modal-body" style="text-align: center;">
+ <img alt="" style="width: 64px; height: 64px;" src="/assets/explicit.svg">
+ <h3>This content is sexually explicit</h3>
+
+ <p>This page shows uncensored graphically explicit sexual content that you may not want to see in some cases. Please refrain from visiting this part of the website in a public place.</p>
+ <p>By continuing, you agree to be presented with sexually explicit content that is not appropriate for everyone.</p>
+
+ <span onclick="explicitConfirm();" id="explicit-modal-confirm" class="btn btn-primary">Continue</span>
+ <span onclick="explicitCancel();" id="explicit-modal-cancel" class="btn btn-outline-secondary">Go back</span>
+
+ <label style="margin-top:10px; display: block; text-align: left; opacity: .5;">
+ <input checked type="checkbox" class="form-check-input" id="explicit-modal-hour">
+ Don't show for the next hour
+ </label>
+ </div>
+ </div>
+ </div>
+</div>
+
+<style>
+ #explicit-modal .modal-header {
+ border-bottom: 1px solid #353738;
+ }
+
+ #explicit-modal .modal-content {
+ border: 1px solid rgba(255, 255, 255, .2);
+ background-color: #111;
+ }
+</style>
+
+<!--suppress JSVoidFunctionReturnValueUsed -->
+<script>
+ window.explicitModal = new bootstrap.Modal(document.getElementById("explicit-modal"));
+ <?php if (file_exists("/peh/metadata")): ?>
+ window.ip = "<?= $_SERVER['HTTP_X_FORWARDED_FOR'] ?>";
+ window.front = "<?php
+
+ $front = [];
+ $id = null;
+
+ if ($userName === "raindrops") {
+ $id = "gdapd";
+ } else if ($userName === "cloudburst") {
+ $id = "ynmuc";
+ }
+
+ $fronters = json_decode(file_get_contents("/peh/$id/fronters.json"), true)["members"];
+ $front = array_map(function ($i) {
+ return $i["id"];
+ }, $fronters);
+
+ echo(implode(",", $front));
+
+ ?>";
+ window.age = <?php
+
+ if (isset($front[0]) && file_exists("/peh/metadata/" . $front[0] . ".json")) {
+ $metadata = json_decode(file_get_contents("/peh/metadata/" . $front[0] . ".json"), true);
+ $age = null;
+
+ if (isset($metadata["birth"]["age"]) && $metadata["birth"]["age"] !== 0) {
+ $age = $metadata["birth"]["age"];
+ } else if (isset($metadata["birth"]["year"]) && $metadata["birth"]["year"] > 1990) {
+ $age = (int)date('Y') - $metadata["birth"]["year"] + (strtotime(date('Y') . "-" . $metadata["birth"]["date"]) <= time() ? 0 : -1);
+ }
+
+ if (is_string($age) && isset(explode("-", $age)[1]) && is_numeric(explode("-", $age)[1])) {
+ $age = (int)explode("-", $age)[1];
+ }
+
+ echo($age);
+ }
+
+ ?>;
+ window.allowExplicit = true;
+ <?php else: ?>
+ window.allowExplicit = false;
+ <?php endif; ?>
+ window.explicitCancelAction = "back";
+
+ function requestExplicit(ifNotAgreed, allowUnderage) {
+ window.explicitCancelAction = ifNotAgreed;
+
+ if (!window.allowExplicit || (!allowUnderage && (window.age < 15 || !window.age))) {
+ document.getElementById("explicit-modal-confirm").classList.add("disabled");
+ document.getElementById("explicit-modal-hour").disabled = true;
+
+ window.explicitModal.show();
+ document.getElementById("explicit-modal").classList.add("fade");
+ return;
+ }
+
+ if (!localStorage.getItem("explicit-consent")) {
+ window.explicitModal.show();
+ document.getElementById("explicit-modal").classList.add("fade");
+ } else {
+ let parts = localStorage.getItem("explicit-consent").split("|");
+
+ if (parts[0] !== window.front || parts[1] !== window.ip || new Date().getTime() - parseInt(parts[2]) > 3600000) {
+ window.explicitModal.show();
+ document.getElementById("explicit-modal").classList.add("fade");
+ }
+ }
+ }
+
+ function explicitConfirm() {
+ window.explicitModal.hide();
+
+ if (document.getElementById("explicit-modal-hour").checked) {
+ localStorage.setItem("explicit-consent", window.front + "|" + window.ip + "|" + new Date().getTime());
+ }
+ }
+
+ function explicitCancel() {
+ if (window.explicitCancelAction === "refresh") {
+ location.reload();
+ } else {
+ if (history.length > 1) {
+ if (history.back() === undefined) {
+ location.href = "https://booru.equestria.dev";
+ }
+ } else {
+ location.href = "https://booru.equestria.dev";
+ }
+ }
+ }
+</script> \ No newline at end of file
diff --git a/includes/header.php b/includes/header.php
index ce15c56..29f35c6 100644
--- a/includes/header.php
+++ b/includes/header.php
@@ -259,6 +259,15 @@ function removeFromNsfw($tag) {
<?php endif; ?>
</head>
<body>
+<?php
+
+require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/explicit.php";
+
+if (str_starts_with($_SERVER['REQUEST_URI'], "/nsfw/") && $_SERVER['REQUEST_URI'] !== "/nsfw/" && !str_starts_with($_SERVER["REQUEST_URI"], "/nsfw/?") && $_SERVER['REQUEST_URI'] !== "/nsfw/icon/" && $_SERVER['REQUEST_URI'] !== "/nsfw/icon") {
+ echo("<script>requestExplicit('back', true);</script>");
+}
+
+?>
<nav class="navbar navbar-expand-sm bg-light navbar-light">
<div class="container-fluid">
<a class="navbar-brand" href="/"><img src="/icon.svg" alt="Booru" style="width: 32px; height: 32px;"></a>
diff --git a/includes/session.php b/includes/session.php
index 8559e81..3d79c0e 100644
--- a/includes/session.php
+++ b/includes/session.php
@@ -68,6 +68,7 @@ if (file_exists("/peh") && file_exists("/peh/gdapd") && file_exists("/peh/ynmuc"
if ($debug) echo("yes (" . count($fronters["members"]) . ")\n");
$name = $fronters["members"][0]["display_name"] ?? $fronters["members"][0]["name"];
$id = $fronters["members"][0]["id"];
+ $GLOBALS["ponyID"] = $id;
$originalName = $name;
@@ -180,8 +181,6 @@ if (function_exists("proprietary_nsfw_5")) {
if (str_starts_with($_SERVER['REQUEST_URI'], "/nsfw") && !$allowNsfwGeneral) {
header("Location: /") and die();
-} else if (str_starts_with($_SERVER['REQUEST_URI'], "/nsfw/") && $_SERVER['REQUEST_URI'] !== "/nsfw/" && !str_starts_with($_SERVER["REQUEST_URI"], "/nsfw/?") && $_SERVER['REQUEST_URI'] !== "/nsfw/icon/" && $_SERVER['REQUEST_URI'] !== "/nsfw/icon" && (!isset($_COOKIE["booru_consent"]) || time() - strtotime($_COOKIE["booru_consent"]) > 3600)) {
- header("Location: /nsfw/?return=" . rawurlencode($_SERVER["REQUEST_URI"])) and die();
}
if ($debug) {
diff --git a/nsfw/index.php b/nsfw/index.php
index 48a85d8..0215b96 100644
--- a/nsfw/index.php
+++ b/nsfw/index.php
@@ -1,29 +1,3 @@
<?php
-if (isset($_COOKIE["booru_consent"]) && time() - strtotime($_COOKIE["booru_consent"]) < 3600) {
- header("Location: /nsfw/home") and die();
-}
-
-$title = "Warning"; require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/header.php";
-
-?>
-
-<div style="margin: 20px 50px 0;" class="main-app">
- <h2>Explicit Warning</h2>
- <div class="alert alert-warning">
- <p>
- This section of the app presents uncensored graphically explicit sexual content that you may not want to see in some cases. Some of the content you see might be more explicit or realistic than the rest, and content filters might not be 100% perfect.
- </p>
- <p>
- We have determined you are allowed to view sexually explicit content, so you can continue if you wish to do so. Make sure you are in a safe place with no one eavesdropping on you. Please refrain from visiting this part of the website in a public place.
- </p>
- By continuing, you agree to be presented with sexually explicit content that is not appropriate for everyone.
- </div>
- <p>
- <a href="<?= $_GET["return"] ?? "/nsfw/home" ?>" class="btn btn-primary" onclick="document.cookie='booru_consent='+new Date().toISOString()">Agree and continue</a>
- <a href="/" class="btn btn-outline-danger">Cancel</a>
- </p>
-</div>
-
-
-<?php require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/footer.php"; ?>
+header("Location: /nsfw/home") and die(); \ No newline at end of file
diff --git a/saved/index.php b/saved/index.php
index f25595b..2f4d474 100644
--- a/saved/index.php
+++ b/saved/index.php
@@ -1,6 +1,6 @@
<?php
-require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.php"; global $userName; global $allowNsfw; global $id;
+require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.php"; global $userName; global $allowNsfw;
$saved = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/saved.json"), true)[$userName];
$title = "Saved";
@@ -22,7 +22,7 @@ if (isset($_GET["id"])) {
}
require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/header.php";
-$uid = $id;
+$uid = $GLOBALS["ponyID"];
?>
@@ -108,7 +108,7 @@ if (!isset($category)) die();
<div style="margin-bottom: 10px;<?php if (!isset($category["owner"]) && (!$allowNsfw || (function_exists("proprietary_nsfw_7") && proprietary_nsfw_7()))): ?>display:none;<?php endif; ?>">
<div class="form-check">
- <input class="form-check-input" type="checkbox" id="show-nsfw" name="show-nsfw" disabled onchange="toggleNSFW();">
+ <input class="form-check-input" type="checkbox" id="show-nsfw" name="show-nsfw" disabled onchange="requestExplicit('refresh', true); toggleNSFW();">
<label class="form-check-label" for="show-nsfw">Display NSFW images</label>
</div>
</div>