diff options
author | RaindropsSys <contact@minteck.org> | 2023-05-13 19:25:58 +0200 |
---|---|---|
committer | RaindropsSys <contact@minteck.org> | 2023-05-13 19:25:58 +0200 |
commit | 30c7a27273e2a023613bb2f2bd073460f3d136d1 (patch) | |
tree | 51f104ad27553fc68cfe2e886cd29aa1946ec102 /home | |
parent | d23fe2e21d02efb228593abf39faeef84e19a476 (diff) | |
download | delta-30c7a27273e2a023613bb2f2bd073460f3d136d1.tar.gz delta-30c7a27273e2a023613bb2f2bd073460f3d136d1.tar.bz2 delta-30c7a27273e2a023613bb2f2bd073460f3d136d1.zip |
Updated 15 files and added 6 files (automated)
Diffstat (limited to 'home')
-rw-r--r-- | home/_base.php | 8 | ||||
-rw-r--r-- | home/birthday.php | 26 | ||||
-rw-r--r-- | home/family.php | 22 | ||||
-rw-r--r-- | home/history.php | 35 | ||||
-rw-r--r-- | home/recent.php | 62 |
5 files changed, 153 insertions, 0 deletions
diff --git a/home/_base.php b/home/_base.php new file mode 100644 index 0000000..8c19e1d --- /dev/null +++ b/home/_base.php @@ -0,0 +1,8 @@ +<?php + +require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.php"; +require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/functions.php"; +initLang(); +global $_PROFILE; global $_USER; + +?>
\ No newline at end of file diff --git a/home/birthday.php b/home/birthday.php new file mode 100644 index 0000000..9037165 --- /dev/null +++ b/home/birthday.php @@ -0,0 +1,26 @@ +<?php + +require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.php"; +require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/functions.php"; +initLang(); +global $_PROFILE; global $_USER; + +$birthdays = array_values(array_filter(array_map(function ($i) { + $r = json_decode(pf_utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/profiles/$i")), true); + $r["_id"] = substr($i, 0, -5); + return $r; +}, array_values(array_filter(scandir($_SERVER['DOCUMENT_ROOT'] . "/includes/data/profiles"), function ($i) { return str_ends_with($i, ".json"); }))), function ($i) { + return hasProfileSetting("birth", true, $i) && substr($i["birth"], 5) === date('m-d'); +})); + +if (count($birthdays) > 0): ?> + <div class="alert alert-primary"> + <img class="icon" src="/icons/age-home.svg"><span style="vertical-align: middle; margin-left: 5px;"><?= str_replace("%1", enumerate(array_map(function ($i) { + return str_replace("%1", "<a href='/profile/" . $i["_id"] . "'>" . ($i["nick_name"] ?? $i["first_name"]) . "</a>", l("lang_home_name")); + }, $birthdays), l("lang_home_and")), l("lang_home_birthday")) ?></span> + </div> +<?php else: ?> + <div class="alert alert-secondary"> + <img class="icon" src="/icons/events.svg"><span style="vertical-align: middle; margin-left: 5px;"><?= str_replace("%1", formatDate(time()), l("lang_home_date")) ?></span> + </div> +<?php endif; ?>
\ No newline at end of file diff --git a/home/family.php b/home/family.php new file mode 100644 index 0000000..cce4fcb --- /dev/null +++ b/home/family.php @@ -0,0 +1,22 @@ +<?php + +require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.php"; +require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/functions.php"; +initLang(); +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)): ?> + <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): ?> + <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> + </p> + <span><?= trim($entry["value"]["extract"]) !== "" ? substr(trim($entry["value"]["extract"]), 0, 150) . (strlen(trim($entry["value"]["extract"])) > 150 ? "…" : "") : $entry["value"]["name"] ?></span> + </a> + <?php $index++; endif; endforeach; ?> + </div> +<?php endif; ?>
\ No newline at end of file diff --git a/home/history.php b/home/history.php new file mode 100644 index 0000000..0f96858 --- /dev/null +++ b/home/history.php @@ -0,0 +1,35 @@ +<?php + +require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.php"; +require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/functions.php"; +initLang(); +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); + + if (count(array_keys($history)) > 0): + + uasort($history, function ($a, $b) { return $b - $a; }); + $top = array_keys($history)[rand(0, count($history) >= 3 ? 2 : count($history) - 1)]; + $topName = getNameFromId($top); + + if (count(search($topName, true)) > 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): ?> + <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> + </p> + <span><?= trim($entry["value"]["extract"]) !== "" ? substr(trim($entry["value"]["extract"]), 0, 150) . (strlen(trim($entry["value"]["extract"])) > 150 ? "…" : "") : $entry["value"]["name"] ?></span> + </a> + <?php $index++; endif; endforeach; ?> + </div> + + <?php endif; endif; endif; ?> diff --git a/home/recent.php b/home/recent.php new file mode 100644 index 0000000..aa219fc --- /dev/null +++ b/home/recent.php @@ -0,0 +1,62 @@ +<?php + +require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.php"; +require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/functions.php"; +initLang(); +global $_PROFILE; global $_USER; + +function showPage($item) { ?> + + <a href="/<?= $item["_type"] ?>/<?= $item["_id"] ?>" class="list-group-item list-group-item-action"> + <p style="margin-bottom: 10px;"><img class="icon" src="/icons/<?= $item["_type"] ?>.svg" style="margin-right:5px;"><span style="vertical-align: middle;"><b><?= getNameFromId($item["_id"]) ?></b> <?= l("lang_home_update") ?> <b><?= timeAgo($item["update"]) ?></b></span></p><?= trim(strip_tags($item["contents"])) !== "" ? substr(trim(strip_tags($item["contents"])), 0, 150) . (strlen(trim(strip_tags($item["contents"]))) > 150 ? "…" : "") : "-" ?> + </a> + +<?php } ?> + +<h3 style="margin-bottom: 15px; margin-top: 30px;"><?= l("lang_home_recent") ?></h3> + +<div class="list-group"> + <?php + + $list = []; + + foreach (array_filter(scandir($_SERVER['DOCUMENT_ROOT'] . "/includes/data/articles"), function ($i) { return !str_starts_with($i, "."); }) as $id) { + $data = json_decode(pf_utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/articles/$id")), true); + $id = substr($id, 0, -5); + + $data["_type"] = "articles"; + $data["_id"] = $id; + + $list[$id] = $data; + } + + foreach (array_filter(scandir($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gallery"), function ($i) { return !str_starts_with($i, "."); }) as $id) { + $data = json_decode(pf_utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gallery/$id")), true); + $id = substr($id, 0, -5); + + $data["_type"] = "gallery"; + $data["_id"] = $id; + + $list[$id] = $data; + } + + foreach (array_filter(scandir($_SERVER['DOCUMENT_ROOT'] . "/includes/data/people"), function ($i) { return !str_starts_with($i, "."); }) as $id) { + $data = json_decode(pf_utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/people/$id")), true); + $id = substr($id, 0, -5); + + $data["_type"] = "people"; + $data["_id"] = $id; + + $list[$id] = $data; + } + + uasort($list, function ($a, $b) { + return strtotime($a["update"]) - strtotime($b["update"]); + }); + + $list = array_reverse($list); + + $index = 0; foreach ($list as $item): if ($index <= 4): ?> + <?php showPage($item); ?> + <?php $index++; endif; endforeach; ?> +</div> |