diff options
Diffstat (limited to 'pages/dashboard.php')
-rw-r--r-- | pages/dashboard.php | 299 |
1 files changed, 299 insertions, 0 deletions
diff --git a/pages/dashboard.php b/pages/dashboard.php new file mode 100644 index 0000000..622cd20 --- /dev/null +++ b/pages/dashboard.php @@ -0,0 +1,299 @@ +<?php + +require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.php"; global $isLoggedIn; +if (!$isLoggedIn) header("Location: /-/login") and die(); + +$title = "Dashboard"; require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.php'; global $_PROFILE; +use om\IcalParser; + +$poniesHavingSex = []; + +$actions = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/actions.json"), true); + +foreach ($actions as $action) { + if ($action["type"] !== "sexual") continue; + + foreach ($action["ponies"] as $ponies) { + $id = implode("", $ponies["members"]); + + $member = getMemberWithoutSystem($ponies["members"][0]); + $otherMember = getMemberWithoutSystem($ponies["members"][1]); + + $parts = [ + $member["id"], + $otherMember["id"] + ]; + + asort($parts); + $poniesHavingSex[] = $parts[0]; + $poniesHavingSex[] = $parts[1]; + } +} + +$fronter = array_map(function ($i) { + return $i["id"]; +}, ($_PROFILE["login"] === "raindrops" ? json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd-fronters.json"), true) : json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/ynmuc-fronters.json"), true))["members"])[0]; + +$viewingPonyHasSex = in_array($fronter, $poniesHavingSex) || isset($_GET['toys']); + +?> + +<br> +<div class="container"> + <div id="page-content"> + <h3 id="date" style="text-align: center;margin-bottom:20px;">Date</h3> + <script> + function _Date() { + let d = new Date(); + let m = d.getMonth(); + let w = d.getDay(); + + switch (m) { + case 0: m = "Jan"; break; + case 1: m = "Feb"; break; + case 2: m = "Mar"; break; + case 3: m = "Apr"; break; + case 4: m = "May"; break; + case 5: m = "Jun"; break; + case 6: m = "Jul"; break; + case 7: m = "Aug"; break; + case 8: m = "Sep"; break; + case 9: m = "Oct"; break; + case 10: m = "Nov"; break; + case 11: m = "Dec"; break; + } + + switch (w) { + case 0: w = "Sun"; break; + case 1: w = "Mon"; break; + case 2: w = "Tue"; break; + case 3: w = "Wed"; break; + case 4: w = "Thu"; break; + case 5: w = "Fri"; break; + case 6: w = "Sat"; break; + } + + function fixed(number) { + if (number < 10) { + return "0" + number; + } else { + return number.toString(); + } + } + + document.getElementById("date").innerText = `${w} ${d.getDate()} ${m} ${d.getHours()}:${fixed(d.getMinutes())}`; + } + + setInterval(_Date); + </script> + + <div class="peh-row" style="<?php if (!$viewingPonyHasSex): ?>grid-template-columns: repeat(6, 1fr) !important;<?php endif; ?>"> + <div class="column"> + <div class="card"> + <a href="/-/actions" class="card-body" style="text-align:center;color: white !important; text-decoration: none !important;"> + <img src="/assets/icons/actions.svg" style="width:32px;height:32px;filter:invert(1);"><br> + <h6 class="app-name">Actions</h6> + </a> + </div> + </div> + <div class="column"> + <div class="card"> + <a href="/-/rules" class="card-body" style="text-align:center;color: white !important; text-decoration: none !important;"> + <img src="/assets/icons/rules.svg" style="width:32px;height:32px;filter:invert(1);"><br> + <h6 class="app-name">Rules</h6> + </a> + </div> + </div> + <div class="column"> + <div class="card"> + <a href="/-/nicknames" class="card-body" style="text-align:center;color: white !important; text-decoration: none !important;"> + <img src="/assets/icons/nicknames.svg" style="width:32px;height:32px;filter:invert(1);"><br> + <h6 class="app-name">Nicknames</h6> + </a> + </div> + </div> + <div class="column"> + <div class="card"> + <a href="/-/together" class="card-body" style="text-align:center;color: white !important; text-decoration: none !important;"> + <img src="/assets/icons/together.svg" style="width:32px;height:32px;filter:invert(1);"><br> + <h6 class="app-name">Watch Together</h6> + </a> + </div> + </div> + <div class="column"> + <div class="card"> + <a href="/-/splitting" class="card-body" style="text-align:center;color: white !important; text-decoration: none !important;"> + <img src="/assets/icons/form.svg" style="width:32px;height:32px;filter:invert(1);"><br> + <h6 class="app-name">Splits</h6> + </a> + </div> + </div> + <div class="column"> + <div class="card"> + <a href="/-/bitset" class="card-body" style="text-align:center;color: white !important; text-decoration: none !important;"> + <img src="/assets/icons/bitset.svg" style="width:32px;height:32px;filter:invert(1);"><br> + <h6 class="app-name">Bitset</h6> + </a> + </div> + </div> + <?php if ($viewingPonyHasSex): ?> + <div class="column"> + <div class="card"> + <a href="/-/toys" class="card-body" style="text-align:center;color: white !important; text-decoration: none !important;"> + <img src="/assets/icons/toys.svg" style="width:32px;height:32px;filter:invert(1);"><br> + <h6 class="app-name">Toys</h6> + </a> + </div> + </div> + <?php endif; ?> + </div> + + <hr> + <h4>Next fronters <span class="small"><a href="/-/fronting">(edit)</a></span></h4> + <?php + + $scheduleCloudburstToday = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/ynmuc-planner.json"), true)[date('Y-m-d')] ?? []; + $scheduleRaindropsToday = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd-planner.json"), true)[date('Y-m-d')] ?? []; + + $scheduleCloudburstTomorrow = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/ynmuc-planner.json"), true)[date('Y-m-d', time() + 86400)] ?? []; + $scheduleRaindropsTomorrow = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd-planner.json"), true)[date('Y-m-d', time() + 86400)] ?? []; + + $today1 = $_PROFILE["login"] === "raindrops" ? $scheduleRaindropsToday : $scheduleCloudburstToday; + $today2 = $_PROFILE["login"] === "raindrops" ? $scheduleCloudburstToday : $scheduleRaindropsToday; + $tomorrow1 = $_PROFILE["login"] === "raindrops" ? $scheduleRaindropsTomorrow : $scheduleCloudburstTomorrow; + $tomorrow2 = $_PROFILE["login"] === "raindrops" ? $scheduleCloudburstTomorrow : $scheduleRaindropsTomorrow; + + ?> + + <h5>Fronters today</h5> + <ul> + <?php foreach ($today1 as $index => $id): $member = getSystemMember($_PROFILE["login"] === "raindrops" ? "gdapd" : "ynmuc", $id); ?> + <li> + <img alt="" src="/assets/uploads/pt-<?= $member["name"] ?>.png" style="width:24px; height: 24px; vertical-align: middle;"> <b style="vertical-align: middle;"><?= getMiniName($member["display_name"] ?? $member["name"]) ?></b> + <?php if (isset($today2[$index])): $member2 = getSystemMember($_PROFILE["login"] === "raindrops" ? "ynmuc" : "gdapd", $today2[$index]); ?><span style="vertical-align: middle;">with</span> <img alt="" src="/assets/uploads/pt-<?= $member2["name"] ?>.png" style="width:24px; height: 24px; vertical-align: middle;"> <span style="vertical-align: middle;"><?= getMiniName($member2["display_name"] ?? $member2["name"]) ?></span><?php endif; ?> + </li> + <?php endforeach; ?> + </ul> + + <h5>Fronters tomorrow</h5> + <ul> + <?php foreach ($tomorrow1 as $index => $id): $member = getSystemMember($_PROFILE["login"] === "raindrops" ? "gdapd" : "ynmuc", $id); ?> + <li> + <img alt="" src="/assets/uploads/pt-<?= $member["name"] ?>.png" style="width:24px; height: 24px; vertical-align: middle;"> <b style="vertical-align: middle;"><?= getMiniName($member["display_name"] ?? $member["name"]) ?></b> + <?php if (isset($tomorrow2[$index])): $member2 = getSystemMember($_PROFILE["login"] === "raindrops" ? "ynmuc" : "gdapd", $tomorrow2[$index]); ?><span style="vertical-align: middle;">with</span> <img alt="" src="/assets/uploads/pt-<?= $member2["name"] ?>.png" style="width:24px; height: 24px; vertical-align: middle;"> <span style="vertical-align: middle;"><?= getMiniName($member2["display_name"] ?? $member2["name"]) ?></span><?php endif; ?> + </li> + <?php endforeach; ?> + </ul> + + <hr> + <h4>Next events</h4> + <?php + + $cal = new IcalParser(); + $results = $cal->parseFile($_SERVER['DOCUMENT_ROOT'] . "/includes/data/calendar.ics"); + $events = []; + + foreach ($cal->getEvents()->sorted() as $event) { + $events[] = [ + "id" => $event['UID'], + "date" => [ + "created" => $event['CREATED']->format('c'), + "modified" => $event['LAST-MODIFIED']->format('c'), + "start" => $event['DTSTART']->format('c'), + "end" => $event['DTEND']->format('c'), + "duration" => strtotime($event['DTEND']->format('c')) - strtotime($event['DTSTART']->format('c')), + "full_day" => strtotime($event['DTEND']->format('c')) - strtotime($event['DTSTART']->format('c')) >= 86400, + "days" => ( + strtotime($event['DTEND']->format('c')) - strtotime($event['DTSTART']->format('c')) >= 86400 ? + round((strtotime($event['DTEND']->format('c')) - strtotime($event['DTSTART']->format('c'))) / 86400) : + null + ) + ], + "name" => $event['SUMMARY'], + "description" => $event['DESCRIPTION'], + ]; + } + + $events = array_values(array_filter($events, function ($i) { + return ( + strtotime($i["date"]["end"]) > time() && + strtotime($i["date"]["start"]) < time() + 2629800 + ); + })); + + ?> + <ul> + <?php foreach ($events as $event): ?> + <li> + <?php if ($event["date"]["full_day"]): ?> + <b> + <?php if (strtotime($event["date"]["start"]) < time()): ?> + Started <?= timeAgo($event["date"]["start"]) ?>, ends <?= timeIn($event["date"]["end"]) ?> + <?php else: ?> + <?= ucfirst(relativeDate($event["date"]["start"], false)) ?> + <?php endif; ?> + · + </b> + <?php else: ?> + <b> + <?= ucfirst(relativeDate($event["date"]["start"])) ?> + · + </b> + <?php endif; ?> + for <?= duration($event["date"]["duration"]) ?> + · + <?= $event["name"] ?> + </li> + <?php endforeach; ?> + </ul> + </div> +</div> + +<style> + .peh-row { + display: grid; + grid-template-columns: repeat(7, 1fr); + } + + .column .card { + border-right: none !important; + border-radius: 0 !important; + } + + .column:nth-child(1) .card { + border-bottom-left-radius: 0.25rem !important; + border-top-left-radius: 0.25rem !important; + } + + .column:nth-last-child(1) .card { + border-right: 1px solid rgba(255, 255, 255, .125) !important; + border-bottom-right-radius: 0.25rem !important; + border-top-right-radius: 0.25rem !important; + } + + @media (max-width: 1199px) { + .app-name { + display: none; + } + } + + @media (max-width: 991px) { + .column { + padding-right: calc(var(--bs-gutter-x) * .25); + padding-left: calc(var(--bs-gutter-x) * .25); + } + } + + @media (max-width: 576px) { + .card-body { + padding: 0.5rem 0.5rem !important; + } + + .column { + padding-right: calc(var(--bs-gutter-x) * .175) !important; + padding-left: calc(var(--bs-gutter-x) * .175) !important; + } + } +</style> + +<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/footer.php'; ?> |