diff options
author | RaindropsSys <contact@minteck.org> | 2023-05-27 17:44:38 +0200 |
---|---|---|
committer | RaindropsSys <contact@minteck.org> | 2023-05-27 17:44:38 +0200 |
commit | f90bff2e7e6ecae78c786f22dd63a895e2c3d6ee (patch) | |
tree | 80302ace9a43d718af0ae07c36344de9563aa84c | |
parent | 752e3f98142b191b77ec58ac85c7a9aacf64eb11 (diff) | |
download | delta-f90bff2e7e6ecae78c786f22dd63a895e2c3d6ee.tar.gz delta-f90bff2e7e6ecae78c786f22dd63a895e2c3d6ee.tar.bz2 delta-f90bff2e7e6ecae78c786f22dd63a895e2c3d6ee.zip |
Updated 7 files (automated)
-rw-r--r-- | home/family.php | 2 | ||||
-rw-r--r-- | home/history.php | 25 | ||||
-rw-r--r-- | includes/functions.php | 71 | ||||
-rw-r--r-- | includes/header.php | 3 | ||||
-rw-r--r-- | includes/oobe.php | 22 | ||||
-rw-r--r-- | plus/index.php | 6 | ||||
-rw-r--r-- | plus/subscribe/index.php | 7 |
7 files changed, 121 insertions, 15 deletions
diff --git a/home/family.php b/home/family.php index cce4fcb..d431218 100644 --- a/home/family.php +++ b/home/family.php @@ -7,7 +7,7 @@ global $_PROFILE; global $_USER; ?> -<?php $results = array_values(array_filter(search($_PROFILE["first_name"] . " " . $_PROFILE["last_name"], true, true), function ($i) use ($_PROFILE) { return str_ends_with($i["value"]["name"], " " . $_PROFILE["last_name"]); })); if (count($results)): ?> +<?php $results = array_values(array_filter(findRelated($_USER), function ($i) use ($_PROFILE) { return str_ends_with($i["value"]["name"], " " . $_PROFILE["last_name"]); })); if (count($results)): ?> <h3 style="margin-bottom: 15px; margin-top: 30px;"><?= l("lang_home_family") ?></h3> <div class="list-group"> <?php $index = 0; foreach ($results as $entry): if ($index <= 4): ?> diff --git a/home/history.php b/home/history.php index 0f96858..534e4db 100644 --- a/home/history.php +++ b/home/history.php @@ -9,7 +9,26 @@ global $_PROFILE; global $_USER; <?php if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/history/" . $_USER . ".json")): - $history = json_decode(pf_utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/history/" . $_USER . ".json")), true); + $history = array_filter(json_decode(pf_utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/history/" . $_USER . ".json")), true), function ($i) { + global $_PROFILE; + global $_USER; + + if (getFileFromId($i) === null) { + return false; + } + + $personData = json_decode(file_get_contents(getFileFromId($i)), true); + + if ($personData["first_name"] === $_PROFILE["first_name"] && $personData["last_name"] === $_PROFILE["last_name"]) { + return false; + } + + if ($i === $_USER) { + return false; + } + + return true; + }, ARRAY_FILTER_USE_KEY); if (count(array_keys($history)) > 0): @@ -17,12 +36,12 @@ global $_PROFILE; global $_USER; $top = array_keys($history)[rand(0, count($history) >= 3 ? 2 : count($history) - 1)]; $topName = getNameFromId($top); - if (count(search($topName, true)) > 0): + if (count(findRelated($top)) > 0): ?> <h3 style="margin-bottom: 15px; margin-top: 30px;"><?= str_replace("%1", $topName, l("lang_home_because")) ?></h3> <div class="list-group"> - <?php $index = 0; foreach (search($topName, true) as $entry): if ($index <= 4): ?> + <?php $index = 0; foreach (findRelated($top) as $entry): if ($index <= 4): ?> <a href="<?= $entry["value"]["url"] ?>" class="list-group-item-action list-group-item"> <p style="margin-bottom:.5rem;"> <img class="icon" src="/icons/<?= $entry["value"]["type"] ?>.svg" style="margin-right:5px;"><b style="vertical-align: middle;"><?= $entry["value"]["name"] ?></b> diff --git a/includes/functions.php b/includes/functions.php index 26284b3..5129837 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -522,4 +522,75 @@ function isJson($string): bool { return (json_last_error() === JSON_ERROR_NONE); } +function resolveRealID($id) { + if (!str_contains($id, ".")) { + return $id; + } + + $parts = explode(".", $id); + + if (count($parts) === 2) { + foreach (array_filter(scandir($_SERVER["DOCUMENT_ROOT"] . "/includes/data/people"), function ($i) { return !str_starts_with($i, "."); }) as $_id) { + $_d = json_decode(file_get_contents($_SERVER["DOCUMENT_ROOT"] . "/includes/data/people/" . $_id), true); + + if (strtolower(trim($_d["first_name"])) === strtolower(trim($parts[0])) && strtolower(trim($_d["last_name"])) === strtolower(trim($parts[1]))) { + $id = substr($_id, 0, -5); + } + } + } + + return $id; +} + +function findRelated($id) { + if (getTypeFromId($id) === "people" || getTypeFromId($id) === "profiles") { + $relations = []; + + if (getTypeFromId($id) === "people") { + $relations = array_filter(array_map(function ($i) { + return resolveRealID($i['id']); + }, json_decode(file_get_contents(getFileFromId($id)), true)["relations"] ?? []), function ($i) { + return getNameFromId($i) !== $i; + }); + } else { + $profile = json_decode(file_get_contents(getFileFromId($id)), true); + + foreach (scandir($_SERVER['DOCUMENT_ROOT'] . "/includes/data/people") as $person) { + if (str_starts_with($person, ".")) continue; + + $personData = json_decode(file_get_contents(getFileFromId(substr($person, 0, -5))), true); + + if ($personData["first_name"] === $profile["first_name"] && $personData["last_name"] === $profile["last_name"]) { + $relations = array_filter(array_map(function ($i) { + return resolveRealID($i['id']); + }, $personData["relations"] ?? []), function ($i) { + return getNameFromId($i) !== $i; + }); + } + } + } + + if (count($relations) < 3) { + return search(getNameFromId($id), true, true); + } else { + return array_map(function ($i) { + return [ + "score" => -1, + "breakdown" => [], + "value" => [ + "id" => $i, + "type" => getTypeFromId($i), + "url" => getUrlFromId($i), + "name" => getNameFromId($i), + "alts" => [], + "extract" => strip_tags(json_decode(file_get_contents(getFileFromId($i)), true)["contents"] ?? "") + ] + ]; + }, $relations); + } + } else { + return search(getNameFromId($id), true, true); + } +} + require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/linking.php";
\ No newline at end of file diff --git a/includes/header.php b/includes/header.php index 482eda3..b850bd3 100644 --- a/includes/header.php +++ b/includes/header.php @@ -46,7 +46,8 @@ if (isset($_PROFILE)) { $betaEligible = false; if (isset($_PROFILE)) { - $betaEligible = true || (isset($_PROFILE["plus"]) && $_PROFILE["plus"]); + $betaEligible = isset($_PROFILE["plus"]) && $_PROFILE["plus"]; + //$betaEligible = true || (isset($_PROFILE["plus"]) && $_PROFILE["plus"]); } $userPalette = $palettes["list"][$palettes["default"]]["light"]; diff --git a/includes/oobe.php b/includes/oobe.php index 8abf079..892664d 100644 --- a/includes/oobe.php +++ b/includes/oobe.php @@ -8,7 +8,7 @@ <img style="width: 64px;" src="/icons/wave.svg"> <h3 style="margin-top: 5px;"><?= l("lang_oobe_pages_0_title") ?></h3> - <div style="height: 228px;"> + <div class="oobe-container" style="height: 228px;"> <p style="margin-top: 10px;"> <?= l("lang_oobe_pages_0_description") ?> </p> @@ -35,7 +35,7 @@ <img style="width: 64px;" src="/icons/content.svg"> <h3 style="margin-top: 5px;"><?= l("lang_oobe_pages_1_title") ?></h3> - <div style="height: 228px;"> + <div class="oobe-container" style="height: 228px;"> <p style="margin-top: 10px;"> <img src="/icons/people.svg" style="width: 24px; vertical-align: middle;"><span style="vertical-align: middle; margin-left: 5px;"><?= l("lang_oobe_pages_1_items_0") ?></span><br> <img src="/icons/articles.svg" style="width: 24px; vertical-align: middle;"><span style="vertical-align: middle; margin-left: 5px;"><?= l("lang_oobe_pages_1_items_1") ?></span><br> @@ -66,7 +66,7 @@ <img style="width: 64px;" src="/icons/profiles.svg"> <h3 style="margin-top: 5px;"><?= l("lang_oobe_pages_2_title") ?></h3> - <div style="height: 228px;"> + <div class="oobe-container" style="height: 228px;"> <p style="margin-top: 10px;"> <?= l("lang_oobe_pages_2_description") ?> </p> @@ -99,7 +99,7 @@ <img style="width: 64px;" src="/icons/dashboard.svg"> <h3 style="margin-top: 5px;"><?= l("lang_oobe_pages_3_title") ?></h3> - <div style="height: 228px;"> + <div class="oobe-container" style="height: 228px;"> <p style="margin-top: 10px;"> <?= l("lang_oobe_pages_3_description") ?> </p> @@ -132,7 +132,7 @@ <img style="width: 64px;" src="/icons/smartphone.svg"> <h3 style="margin-top: 5px;"><?= l("lang_oobe_pages_4_title") ?></h3> - <div style="height: 228px;"> + <div class="oobe-container" style="height: 228px;"> <p style="margin-top: 10px;"> <?= l("lang_oobe_pages_4_description") ?> </p> @@ -165,7 +165,7 @@ <img style="width: 64px;" src="/icons/subscription.svg"> <h3 style="margin-top: 5px;"><?= l("lang_oobe_pages_5_title") ?></h3> - <div style="height: 228px;"> + <div class="oobe-container" style="height: 228px;"> <p style="margin-top: 10px;"> <?= l("lang_oobe_pages_5_description") ?> </p> @@ -212,7 +212,7 @@ <img style="width: 64px;" src="/icons/magic.svg"> <h3 style="margin-top: 5px;"><?= l("lang_oobe_pages_6_title") ?></h3> - <div style="height: 228px;"> + <div class="oobe-container" style="height: 228px;"> <p style="margin-top: 10px;"> <?= l("lang_oobe_pages_6_description") ?> </p> @@ -222,7 +222,7 @@ <div style="display: flex; justify-content: start; width: 100%;"></div> <div style="display: flex; justify-content: center; align-items: center; width: 100%;"></div> <div style="display: flex; justify-content: end; width: 100%;"> - <a onclick="document.cookie = 'DeltaOOBECompleted=1; Path=/';" data-bs-dismiss="modal" class="btn btn-primary"><?= l("lang_oobe_finish") ?></a> + <a onclick="document.cookie = 'DeltaOOBECompleted=1; path=/; max-age=31536000';" data-bs-dismiss="modal" class="btn btn-primary"><?= l("lang_oobe_finish") ?></a> </div> </div> </div> @@ -233,6 +233,12 @@ </div> <style> + @media (max-width: 500px) { + .oobe-container { + height: calc(100vh - 196px) !important; + } + } + @keyframes fade-out { 0% { left: 0; diff --git a/plus/index.php b/plus/index.php index 4fbc963..d10778d 100644 --- a/plus/index.php +++ b/plus/index.php @@ -7,6 +7,8 @@ require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/header.php"; require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/navigation.php"; global $_PROFILE; +$age = (int)(explode(" ", timeAgo($_PROFILE["birth"] ?? "1990-01-01", false, true))[0]); + ?> <style> @@ -52,10 +54,10 @@ global $_PROFILE; <div style="text-align: center; margin-top: 20px;"> <?php if ($_PROFILE["plus"]): ?> - <a href="/plus/subscribe" class="btn btn-outline-light"><?= l("lang_plus_change") ?></a><br> + <a href="/plus/subscribe" class="btn btn-outline-light <?= $age < 16 ? "disabled" : "" ?>"><?= l("lang_plus_change") ?></a><br> <small class="text-muted" style="margin-top: 10px;display: block;"><?= str_replace("%1", $_PROFILE['ultra'] ? "Delta Ultra" : "Delta Plus", l("lang_plus_notice")) ?></small> <?php else: ?> - <a href="/plus/subscribe" class="btn btn-outline-light"><?= str_replace("%1", "<sup>1</sup>", str_replace("%2", $price, l("lang_plus_buy"))) ?></a><br> + <a href="/plus/subscribe" class="btn btn-outline-light <?= $age < 16 ? "disabled" : "" ?>"><?= str_replace("%1", "<sup>1</sup>", str_replace("%2", $price, l("lang_plus_buy"))) ?></a><br> <small class="text-muted" style="margin-top: 10px;display: block;"><?= l("lang_plus_terms") ?></small> <?php endif; ?> </div> diff --git a/plus/subscribe/index.php b/plus/subscribe/index.php index 7a9939c..599f5c3 100644 --- a/plus/subscribe/index.php +++ b/plus/subscribe/index.php @@ -5,6 +5,13 @@ require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.php"; global $_PROFI require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/functions.php"; require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/email.php"; +$age = (int)(explode(" ", timeAgo($_PROFILE["birth"] ?? "1990-01-01", false, true))[0]); + +if ($age < 16) { + header("Location: /"); + die(); +} + $planTarget = -1; $planTargetName = "Delta Free"; $updateCost = 0; |