diff options
author | Minteck <contact@minteck.org> | 2022-08-21 17:31:56 +0200 |
---|---|---|
committer | Minteck <contact@minteck.org> | 2022-08-21 17:31:56 +0200 |
commit | a2df9a69dcc14cb70118cda2ded499055e7ee358 (patch) | |
tree | 6dd283e4e9452d38bce81ddaaae49b5335755842 /pages/travelling.php | |
parent | 84dd0735820b16b60f600284d35183d76547a71f (diff) | |
download | pluralconnect-a2df9a69dcc14cb70118cda2ded499055e7ee358.tar.gz pluralconnect-a2df9a69dcc14cb70118cda2ded499055e7ee358.tar.bz2 pluralconnect-a2df9a69dcc14cb70118cda2ded499055e7ee358.zip |
m. update
Diffstat (limited to 'pages/travelling.php')
-rw-r--r-- | pages/travelling.php | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/pages/travelling.php b/pages/travelling.php new file mode 100644 index 0000000..260ea15 --- /dev/null +++ b/pages/travelling.php @@ -0,0 +1,101 @@ +<?php + +require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.php"; global $isLoggedIn; +if (!$isLoggedIn) header("Location: /login") and die(); +$travelling = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/travelling.json"), true); + +if (isset($_GET['toggleTravel'])) { + if (isset($travelling[$_GET['member']])) { + if ($travelling[$_GET['member']]["travelling"]) { + $travelling[$_GET['member']]["travelling"] = false; + $travelling[$_GET['member']]["history"][count($travelling[$_GET['member']]["history"]) - 1]["end"] = date("c"); + } else { + $travelling[$_GET['member']]["travelling"] = true; + $travelling[$_GET['member']]["history"][] = [ + "start" => date("c"), + "end" => null + ]; + } + } + + header("Location: /-/travelling"); + file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/travelling.json", json_encode($travelling, JSON_PRETTY_PRINT)); + die(); +} + +$title = "System Travelling"; require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.php'; +global $travelling; + +?> + +<style> + .member-link:hover, .relation-intro:hover { + opacity: .75; + } + + .member-link:active, .relation-intro:active { + opacity: .5; + } +</style> + +<br> +<div class="container"> + <div> + <h2>System Travelling</h2> + <?php foreach (scoreOrderGlobal() as $member): ?> + <div class="relation" style="background-color:rgba(255, 255, 255, .1);margin-bottom:10px;padding:10px;border-radius:10px;display:grid;grid-template-columns: 1fr 2fr max-content;"> + <a class="relation-intro" style="background-color:rgba(255, 255, 255, .05);border-right:1px solid rgba(255, 255, 255, .1);margin:-10px;padding:10px;border-top-left-radius:10px;border-bottom-left-radius:10px;color: white;display:flex;align-items:center;text-decoration: none;" href="/<?= $member["_system"] === "gdapd" ? "raindrops" : "cloudburst" ?>/<?= $member["name"] ?>"> + <img src="/assets/uploads/pt<?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-" . $member['name'] . ".png") ? "-" . $member['name'] : "" ?>.png" style="width:24px;"> <?= $member["display_name"] ?? $member["name"] ?> + </a> + + <div class="relation-item" style="display:flex;align-items:center;margin-left:10px;padding:0 20px;"> + <div> + <b style="padding-right:5px;">Current System:</b><span class="list-separator-mobile"><br></span> + <?php $system = $member['_system'] === "gdapd" ? ($travelling[$member['id']]["travelling"] ? "ynmuc" : "gdapd") : ($travelling[$member['id']]["travelling"] ? "gdapd" : "ynmuc"); ?> + <a class="member-link" href="/<?= $system === "gdapd" ? "raindrops" : "cloudburst" ?>"><img style="width:24px;border-radius:5px;" src="/assets/uploads/<?= $system === "gdapd" ? "raindrops" : "cloudburst" ?>.png"> <?= $system === "gdapd" ? "Raindrops" : "Cloudburst" ?> System</a> + <?php if ($travelling[$member['id']]["travelling"]): ?> + <span class="text-muted">(<?= timeAgo($travelling[$member['id']]["history"][count($travelling[$member['id']]["history"]) - 1]["start"]) ?>)</span> + <?php endif; ?> + </div> + </div> + + <div> + <?php if ($travelling[$member['id']]["travelling"]): ?> + <a href="?toggleTravel&member=<?= $member['id'] ?>" class="btn btn-outline-danger">Stop travelling</a> + <?php else: ?> + <a href="?toggleTravel&member=<?= $member['id'] ?>" class="btn btn-outline-success">Start travelling</a> + <?php endif; ?> + </div> + </div> + <?php endforeach; ?> + </div> + + <style> + @media (max-width: 991px) { + .relation { + grid-template-columns: 1fr !important; + } + + .relation-intro { + text-align: center; + border-bottom-left-radius: 0 !important; + border-top-right-radius: 10px; + border-right: none !important; + border-bottom: 1px solid rgba(255, 255, 255, .1); + } + + .relation-item-marefriends { + margin-top: 20px !important; + } + + .relation-item { + margin-top: 10px; + margin-left: 0 !important; + padding: 10px 0 !important; + text-align: center; + } + } + </style> +</div> + +<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/footer.php'; ?> |