Updated 6 files, added 11 files and deleted 5 files (automated)

mane
Mia Raindrops 2 months ago
parent fd3df81a12
commit 42ff743c9b
Signed by: Mia Raindrops
GPG Key ID: EFBDC68435A574B7

3
.gitignore vendored

@ -0,0 +1,3 @@
includes/data
includes/oauth.json
includes/proprietary

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="PublishConfigData" autoUpload="Always" serverName="Minteck.org" remoteFilesAllowedToDisappearOnAutoupload="false">
<serverData>
<paths name="Minteck.org">
<serverdata>
<mappings>
<mapping deploy="/pool/web/booru" local="$PROJECT_DIR$" web="/" />
</mappings>
</serverdata>
</paths>
</serverData>
<option name="myAutoUpload" value="ALWAYS" />
</component>
</project>

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

@ -0,0 +1 @@
<svg width="24" height="24" fill="none" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M12 2v6a2 2 0 0 0 2 2h6v10a2 2 0 0 1-2 2h-6.81A6.5 6.5 0 0 0 4 11.498V4a2 2 0 0 1 2-2h6Zm1.5.5V8a.5.5 0 0 0 .5.5h5.5l-6-6ZM1 17.5a5.5 5.5 0 1 0 11 0 5.5 5.5 0 0 0-11 0Zm4.75 3.25a.75.75 0 1 1 1.5 0 .75.75 0 0 1-1.5 0ZM4.5 16a2 2 0 1 1 4 0c0 .73-.212 1.14-.754 1.708l-.264.27-.116.124C7.083 18.421 7 18.63 7 19a.5.5 0 0 1-1 0c0-.73.212-1.14.754-1.708l.264-.27.116-.124c.283-.319.366-.527.366-.898a1 1 0 1 0-2 0 .5.5 0 0 1-1 0Z" fill="#000000"/></svg>

After

Width:  |  Height:  |  Size: 553 B

@ -0,0 +1 @@
<svg width="24" height="24" fill="none" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M2 6a2 2 0 0 1 2-2h1v16H4a2 2 0 0 1-2-2V6ZM16 8.5h-4a.5.5 0 0 0-.5.5v1a.5.5 0 0 0 .5.5h4a.5.5 0 0 0 .5-.5V9a.5.5 0 0 0-.5-.5Z" fill="#000000"/><path d="M6.5 20H20a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2H6.5v16ZM12 7h4a2 2 0 0 1 2 2v1a2 2 0 0 1-2 2h-4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2Z" fill="#000000"/></svg>

After

Width:  |  Height:  |  Size: 399 B

@ -0,0 +1,54 @@
<?php
$server = "auth.equestria.horse";
header("Content-Type: text/plain");
if (!isset($_GET['code'])) {
die();
}
$appdata = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/oauth.json"), true);
$crl = curl_init('https://' . $server . '/hub/api/rest/oauth2/token');
curl_setopt($crl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($crl, CURLINFO_HEADER_OUT, true);
curl_setopt($crl, CURLOPT_POST, true);
curl_setopt($crl, CURLOPT_HTTPHEADER, [
"Authorization: Basic " . base64_encode($appdata["id"] . ":" . $appdata["secret"]),
"Content-Type: application/x-www-form-urlencoded",
"Accept: application/json"
]);
curl_setopt($crl, CURLOPT_POSTFIELDS, "grant_type=authorization_code&redirect_uri=" . urlencode("https://booru.equestria.dev/auth/callback") . "&code=" . $_GET['code']);
$result = curl_exec($crl);
$result = json_decode($result, true);
curl_close($crl);
if (isset($result["access_token"])) {
$crl = curl_init('https://' . $server . '/hub/api/rest/users/me');
curl_setopt($crl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($crl, CURLINFO_HEADER_OUT, true);
curl_setopt($crl, CURLOPT_HTTPHEADER, [
"Authorization: Bearer " . $result["access_token"],
"Accept: application/json"
]);
$result = curl_exec($crl);
$result = json_decode($result, true);
if (!in_array($result["id"], $appdata["allowed"])) {
header("Location: https://equestria.horse");
die();
}
if (!file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/tokens")) mkdir($_SERVER['DOCUMENT_ROOT'] . "/includes/data/tokens");
$token = bin2hex(random_bytes(32));
file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/tokens/" . $token, json_encode($result));
header("Set-Cookie: booru_auth=" . $token . "; SameSite=None; Path=/; Secure; HttpOnly; Expires=" . date("r", time() + (86400 * 730)));
header("Location: /");
die();
}

@ -1,17 +1,4 @@
<?php
if (isset($_GET["key"])) {
$token = bin2hex(random_bytes(64));
$data = json_decode(file_get_contents("https://ponies.equestria.horse/api/booru-check?key=" . $_GET["key"]), true);
if ($data["valid"]) {
file_put_contents($_SERVER["DOCUMENT_ROOT"] . "/includes/data/tokens/" . $token, json_encode([
"original" => trim($_GET["key"]),
"user" => $data["user"]
]));
setcookie("booru_auth", $token, 0, "/");
header("Location: /");
die();
}
}
header("Location: https://auth.equestria.horse/hub/api/rest/oauth2/auth?client_id=" . json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/oauth.json"), true)["id"] . "&response_type=code&redirect_uri=https://booru.equestria.dev/auth/callback&scope=Hub&request_credentials=default&access_type=offline");
die();

@ -0,0 +1,3 @@
<?php
require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.php"; global $userName; global $allowNsfw;

@ -1,8 +0,0 @@
{
"raindrops": [
"pipp petals",
"scootaloo",
"pegasus"
],
"cloudburst": []
}

@ -1,30 +0,0 @@
{
"cloudburst": {
"favorites": {
"name": "Favorites",
"items": []
}
},
"raindrops": {
"favorites": {
"name": "Favorites",
"items": {
"1": "3033146",
"2": "3033055",
"3": "3033262"
}
},
"6643018b4d83a1a0": {
"name": "Test category",
"items": [
"3033212"
]
},
"fcd20e62e153084f": {
"name": "Not cool stuff",
"items": [
"3033092"
]
}
}
}

File diff suppressed because it is too large Load Diff

@ -1 +0,0 @@
{"original":"dab877d2664c416d70db3af3c0ab8a519232381ee2cc413fe22a9e3d3ae521c41cedbe04","user":"raindrops"}

@ -1,4 +1,4 @@
<?php require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.php"; ?>
<?php require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.php"; global $allowNsfw; ?>
<!doctype html>
<html lang="en">
<head>
@ -69,9 +69,11 @@
<li class="nav-item">
<a class="nav-link" href="/saved">Saved</a>
</li>
<?php if ($allowNsfw): ?>
<li class="nav-item">
<a class="nav-link" href="/nsfw">NSFW</a>
</li>
<?php endif; ?>
</ul>
</div>
</div>

@ -1,19 +1,116 @@
<?php
$debug = false;
if ($_SERVER['REQUEST_URI'] === "/debug/") {
$debug = true;
header("Content-Type: text/plain");
echo("------------------------------\n");
echo("NSFW FILTER DEBUG\n\n");
}
if (!isset($_COOKIE["booru_auth"])) {
header("Location: /login");
header("Location: /auth");
die();
} else {
if (str_contains($_COOKIE['booru_auth'], ".") || str_contains($_COOKIE['booru_auth'], "/") || trim($_COOKIE["booru_auth"]) === "") {
header("Location: /login");
header("Location: /auth");
die();
}
if (!file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/tokens/" . str_replace(".", "", str_replace("/", "", $_COOKIE['booru_auth'])))) {
header("Location: /login");
header("Location: /auth");
die();
}
}
global $userName;
$userName = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/tokens/" . str_replace(".", "", str_replace("/", "", $_COOKIE['booru_auth']))), true)["user"];
$userName = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/tokens/" . str_replace(".", "", str_replace("/", "", $_COOKIE['booru_auth']))), true)["login"];
global $allowNsfw;
$allowNsfw = false;
$name = "-";
if ($debug) echo("Found PEH database: ");
if (file_exists("/peh") && file_exists("/peh/gdapd") && file_exists("/peh/ynmuc")) {
if ($debug) echo("yes\n");
$fronters = json_decode(file_get_contents("/peh/" . ($userName === "raindrops" ? "gdapd" : "ynmuc") . "/fronters.json"), true);
if ($debug) {
echo("Found fronters data: " . (isset($fronters) ? "yes (" . ($userName === "raindrops" ? "gdapd" : "ynmuc") . ")" : "no") . "\n");
}
if ($debug) echo("At least 1 pony at front: ");
if (count($fronters["members"]) > 0) {
if ($debug) echo("yes (" . count($fronters["members"]) . ")\n");
$name = $fronters["members"][0]["display_name"] ?? $fronters["members"][0]["name"];
$id = $fronters["members"][0]["id"];
if ($debug) echo("Pony has metadata: ");
if (file_exists("/peh/metadata/" . $id . ".json")) {
if ($debug) echo("yes (" . $id . ")\n");
$info = json_decode(file_get_contents("/peh/metadata/" . $id . ".json"), true);
if ($debug) echo("Defined fixed age: " . (isset($info["birth"]["age"]) && ($info["birth"]["age"] > 0 || $info["birth"]["age"] === -1) ? "yes (" . ($info["birth"]["age"] === -1 ? "eternal" : $info["birth"]["age"]) . ")" : "no") . "\n");
if ($debug) echo("Below 16 by fixed age: ");
if (isset($info["birth"]["age"]) && $info["birth"]["age"] < 16 && $info["birth"]["age"] > 0) {
if ($debug) echo("yes <--\n");
if ($debug) echo("Has set birth year: no\n");
if ($debug) echo("Calculated age over 16: no\n");
if ($debug) echo("Is otherwise permitted: no\n");
$allowNsfw = false;
} else if (isset($info["birth"]["year"]) && $info["birth"]["year"] > 1900) {
if ($debug) echo("no\n");
if (!isset($info["birth"]["date"])) $info["birth"]["date"] = "01-01";
$age = (int)date('Y') - $info["birth"]["year"] + (strtotime(date('Y') . "-" . $info["birth"]["date"]) <= time() ? 0 : -1);
if ($debug) echo("Has set birth year: yes (" . $info["birth"]["year"] . ", " . $age . ")\n");
if ($age < 16) {
if ($debug) echo("Calculated age over 16: no <--\n");
$allowNsfw = false;
} else {
if ($debug) echo("Calculated age over 16: yes <--\n");
$allowNsfw = true;
}
if ($debug) echo("Is otherwise permitted: no\n");
} else if ((!isset($info["birth"]["age"]) || $info["birth"]["age"] === 0) && (!isset($info["birth"]["year"]) || $info["birth"]["year"] > 1900)) {
echo("no\n");
if ($debug) echo("Has set birth year: no\n");
if ($debug) echo("Calculated age over 16: no\n");
if ($debug) echo("Is otherwise permitted: no <--\n");
$allowNsfw = false;
} else {
echo("no\n");
if ($debug) echo("Has set birth year: no\n");
if ($debug) echo("Calculated age over 16: no\n");
if ($debug) echo("Is otherwise permitted: yes <--\n");
$allowNsfw = true;
}
} else {
if ($debug) echo("no, stopping here\n");
}
} else {
if ($debug) echo("no, stopping here\n");
}
} else {
if ($debug) echo("no, stopping here\n");
}
if (str_starts_with($_SERVER['REQUEST_URI'], "/nsfw") && !$allowNsfw) {
header("Location: /") and die();
} else if (str_starts_with($_SERVER['REQUEST_URI'], "/nsfw/") && $_SERVER['REQUEST_URI'] !== "/nsfw/" && (!isset($_COOKIE["booru_consent"]) || time() - strtotime($_COOKIE["booru_consent"]) > 3600)) {
header("Location: /nsfw") and die();
}
if ($debug) {
echo("\nAllowing NSFW content: " . ($allowNsfw ? "yes" : "no"));
echo("\nReport generated for: " . $name . "\n");
echo("------------------------------\n");
}

@ -1,4 +0,0 @@
<?php
header("Location: https://ponies.equestria.horse/api/booru");
die();

@ -0,0 +1,26 @@
<?php $title = "NSFW Gallery"; require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/header.php";
$page = 1;
if (isset($_GET["page"]) && is_numeric($_GET["page"]) && (int)$_GET["page"] > 0) {
$page = $_GET["page"];
}
$filters = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/filters.json"), true);
?>
<div style="margin: 20px 50px 0;">
<div style="display: grid; grid-template-columns: repeat(6, 1fr); grid-gap: 10px;" id="grid">Loading...</div>
<p style="text-align: center; display: none;" id="pagination"><a href="/nsfw/home?page=<?= max($page - 1, 1) ?>"><</a> <b>Page <?= $page ?></b> <a href="/nsfw/home?page=<?= $page + 1 ?>">></a></p>
<script>
_display_filter = `<?= $filters['nsfw'] ?>`;
_display_page = <?= $page ?>;
</script>
<script src="/assets/display.js"></script>
</div>
<?php require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/footer.php"; ?>

@ -0,0 +1,37 @@
<?php $title = "NSFW"; require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/header.php";
?>
<div style="margin: 20px 50px 0;">
<h2>NSFW</h2>
<p>Select how you want to view NSFW pictures:</p>
<div style="display: grid; grid-template-columns: repeat(2, 1fr); grid-gap: 20px;">
<div class="card">
<div class="card-body">
<h4 class="card-title">
<img src="/assets/gallery.svg" style="vertical-align: middle; width: 36px; height: 36px; margin-right: 2px;">
<span style="vertical-align: middle;">Regular gallery</span>
</h4>
<p>View images in a gallery-like mode, similar to regular Booru. Useful when you are looking for something in particular or finding new ideas to reproduce.</p>
<a href="/nsfw/g" class="btn btn-primary">Open</a>
</div>
</div>
<?php if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/proprietary/card.php")): require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/proprietary/card.php"; else: ?>
<div class="card">
<div class="card-body">
<h4 class="card-title">
<img src="/assets/extension.svg" style="vertical-align: middle; width: 36px; height: 36px; margin-right: 2px;">
<span style="vertical-align: middle;" class="text-danger">Missing proprietary extension</span>
</h4>
<p>An additional option is available, but it requires a proprietary extension that is not currently installed. Install the extension and try again.</p>
<a href="#" class="btn btn-primary disabled">Open</a>
</div>
</div>
<?php endif; ?>
</div>
</div>
<?php require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/footer.php"; ?>

@ -0,0 +1,25 @@
<?php
$title = "Warning"; require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/header.php";
?>
<div style="margin: 20px 50px 0;">
<h2>NSFW 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 (old enough) 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="/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"; ?>

@ -0,0 +1 @@
<?php if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/proprietary/app.php")) require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/proprietary/app.php";

@ -1,4 +1,4 @@
<?php $title = "Saved"; require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/header.php"; global $userName;
<?php $title = "Saved"; require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/header.php"; global $userName; global $allowNsfw;
$saved = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/saved.json"), true)[$userName];
@ -84,7 +84,7 @@ if (!isset($category)) die();
<div style="margin: 20px 50px 0;">
<h2 <?= $_GET["id"] !== "favorites" ? "contenteditable" : "" ?> id="category-title"><?= $category["name"] ?></h2>
<p>
<p <?php if (!$allowNsfw): ?>style="display:none;"<?php endif; ?>>
<div class="form-check">
<input class="form-check-input" type="checkbox" id="show-nsfw" name="show-nsfw" disabled onchange="toggleNSFW();">
<label class="form-check-label" for="show-nsfw">Display NSFW images</label>

@ -1,10 +1,14 @@
<?php
$title = "Search"; require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/header.php";
$title = "Search"; require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/header.php"; global $allowNsfw;
$filters = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/filters.json"), true);
$page = 1;
if (isset($_GET['type']) && ($_GET['type'] === "nsfw" || $_GET['type'] === "all") && !$allowNsfw) {
$_GET['type'] = "sfw";
}
if (isset($_GET["page"]) && is_numeric($_GET["page"]) && (int)$_GET["page"] > 0) {
$page = $_GET["page"];
}
@ -13,11 +17,14 @@ if (isset($_GET["page"]) && is_numeric($_GET["page"]) && (int)$_GET["page"] > 0)
<div style="margin: 20px 50px 0;">
<h2>Search</h2>
<form style="display: grid; grid-template-columns: 1fr 3fr 0.25fr; grid-gap: 15px;" action="/search">
<form style="display: grid; grid-template-columns: <?php if (!$allowNsfw): ?>4fr 0.25fr<?php else: ?>1fr 3fr 0.25fr<?php endif; ?> ;grid-gap: 15px;" action="/search">
<?php if ($allowNsfw): ?>
<select name="type" class="form-select">
<option value="sfw" <?= isset($_GET['type']) && $_GET['type'] === "sfw" ? "selected" : "" ?>>Normal images</option>
<option value="nsfw" <?= isset($_GET['type']) && $_GET['type'] === "nsfw" ? "selected" : "" ?>>NSFW</option>
<option value="all" <?= isset($_GET['type']) && $_GET['type'] === "all" ? "selected" : "" ?>>Everything</option>
</select>
<?php endif; ?>
<input autocomplete="off" type="text" class="form-control" name="query" placeholder="Search query" value="<?= strip_tags($_GET['query'] ?? "") ?>">
<button type="submit" class="btn btn-primary">Search</button>
</form>

@ -1,8 +1,12 @@
<?php
require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.php"; global $userName;
require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.php"; global $userName; global $allowNsfw;
if (!isset($_GET['id'])) die();
if (isset($_GET["nsfw"]) && !$allowNsfw) {
unset($_GET["nsfw"]);
}
$follows = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/follows.json"), true);
if (isset($_GET['follow'])) {
@ -35,14 +39,14 @@ if (isset($_GET["page"]) && is_numeric($_GET["page"]) && (int)$_GET["page"] > 0)
<div style="margin: 20px 50px 0;">
<h2><?= $title ?></h2>
<p><a href="/tag?id=<?= $_GET['id'] ?>&follow"><?= in_array($_GET['id'], $follows[$userName]) ? 'Unfollow tag' : 'Follow tag' ?></a> ·
<p><a href="/tag?id=<?= $_GET['id'] ?>&follow"><?= in_array($_GET['id'], $follows[$userName]) ? 'Unfollow tag' : 'Follow tag' ?></a><?php if ($allowNsfw): ?> ·
<?php if (isset($_GET['nsfw']) && !isset($_GET['only_nsfw'])): ?>
<a href="/tag?id=<?= $_GET['id'] ?>&page=<?= $page ?>&nsfw&only_nsfw">Show only NSFW</a>
<?php elseif (isset($_GET['nsfw']) && isset($_GET['only_nsfw'])): ?>
<a href="/tag?id=<?= $_GET['id'] ?>&page=<?= $page ?>">Hide NSFW</a>
<?php else: ?>
<a href="/tag?id=<?= $_GET['id'] ?>&page=<?= $page ?>&nsfw">Show NSFW</a>
<?php endif; ?>
<?php endif; ?><?php endif; ?>
</p>
<div style="display: grid; grid-template-columns: repeat(6, 1fr); grid-gap: 10px;" id="grid">Loading...</div>

Loading…
Cancel
Save