1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
|
<?php
if (isset($_GET["ec"])) {
header("HTTP/1.1 " . $_GET["ec"] . " Error");
}
require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/init.inc"; require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/header.inc'; global $readOnly; global $isNormallyLoggedIn; global $_PROFILE; global $lang; global $pages; global $isLowerLoggedIn; global $app; global $isLoggedIn;
function banner() { global $isLoggedIn; global $isLowerLoggedIn; $byColor = getMembersByColor(false, true); global $lang; ?>
<div style="text-align: center;">
<img alt="" src="/assets/logo/newlogo<?= $isLoggedIn || $isLowerLoggedIn ? "3" : "" ?>.png" style="width:128px;">
<p style="z-index:999;position:relative;background:transparent;margin: 20px -10px 0 -20px;padding-right:30px;height:32px;text-align: center;display:grid;grid-template-columns: repeat(<?= count($byColor) ?>, 1fr);">
<?php foreach ($byColor as $member): ?><a class="rainbow-item" style="overflow: hidden;"><img src="<?= getAsset($member["_system"], $member["id"], "heads") ?>" style="height:32px;position:absolute;z-index:99;"></a><?php endforeach; ?>
</p>
<div style="margin-top:-33px;margin-bottom:0;margin-left:-20px;margin-right:20px;height:32px;text-align: center;display:grid;grid-template-columns: repeat(<?= count($byColor) ?>, 1fr);position:relative;left:10px;">
<?php foreach ($byColor as $member): ?><div>
<span style="display: inline-block;background: transparent;position:absolute;width: 0;height: 0;margin-top: 17px;box-shadow: 0 6px 20px 20px #<?= $member["color"] ?>;z-index: 9;margin-left: 8px;opacity: .75;"></span>
</div><?php endforeach; ?>
</div>
<div style="padding:5px 10px;background:#3332328a;position:relative;z-index: 999;backdrop-filter: blur(30px);">
<h2 style="margin-top: 20px;">Cold Haze</h2>
<?php if ($isLoggedIn || $isLowerLoggedIn): ?>
<p><?= count($byColor) ?> ponies in 3 plural systems</p>
<?php else: ?>
<p><?= count($byColor) ?> <?= $lang["home"]["intro"] ?></p>
<?php endif; ?>
</div>
</div>
<?php }
function members() { global $isLoggedIn; global $isLowerLoggedIn; global $app; ?>
<div id="new-homepage" style="margin-top:20px;">
<div id="new-homepage-systems" <?php if ($isLoggedIn || $isLowerLoggedIn): ?>style="grid-template-columns: repeat(3, 1fr);"<?php endif; ?>>
<?php newHomepage("ynmuc", "cloudburst", true); ?>
<?php newHomepage("gdapd", "raindrops", true); ?>
<?php if ($isLoggedIn || $isLowerLoggedIn) newHomepage($app["other"]["id"], $app["other"]["slug"], true); ?>
</div>
</div>
<div id="hpd-legacy" style="margin-top: 20px; background:rgba(255, 255, 255, .1);border-radius:10px;padding:10px 10px 10px 20px;display:grid;grid-template-columns: 128px 1fr;margin-bottom:10px;">
<a style="display:flex;margin: -10px -20px;align-items:center;justify-content:center;text-align:center;padding: 10px 20px;border-radius: 10px;background: #77777755;width: 148px;text-decoration:none;color:white;filter:none !important;" class="hpd-system">
<div style="text-align:center;"><img src="/assets/icons/legacy.svg" style="width:64px;"><br>Pony Legacy</div>
</a>
<div style="display:grid;grid-template-columns:repeat(6, 1fr);padding-left:10px;grid-gap:10px;">
<?php foreach (array_filter(scandir($_SERVER['DOCUMENT_ROOT'] . "/includes/data/legacy"), function ($i) {
return !str_starts_with($i, ".");
}) as $id):
$id = substr($id, 0, -5);
$member = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/legacy/" . $id . ".json"), true);
echo('<a style="text-decoration:none !important;filter:none !important;"><div class="hpd-item-card" style="background-color:rgba(255, 255, 255, .1);border:1px solid ' . (isset($member['color']) ? "#" . $member['color'] . "55" : "transparent") . ';outline-color:' . (isset($member['color']) ? "#" . $member['color'] . "55" : "transparent") . ';border-radius:10px;text-align:center;display:flex;align-items:center;justify-content:center;padding:5px;opacity:5;"><div>
<img alt="" src="' . $member["avatar"] . '" style="border-radius:999px;background-color:rgba(0, 0, 0, .25);height:48px;display:block;margin-left:auto;margin-right:auto;">
<div style="text-decoration:none;color:white;margin-top:5px;">' . ($member['name'] ?? $id) . '</div>
<div style="text-decoration:none !important;color:white !important;">' . (isset($member['prefix']) ? "<code style='color:white;'>" . $member['prefix'] . "</code> · " : "") . date('j M Y', strtotime($member["date"])) . '</div>
</div></div></a>');
endforeach; ?>
</div>
</div>
<?php } ?>
<br>
<div class="container">
<?php if (isset($_GET['em'])): ?>
<div class="alert alert-danger alert-dismissible">
<button onclick='window.history.pushState({"html":null,"pageTitle":document.title},"", "/");' type="button" class="btn-close" data-bs-dismiss="alert"></button>
<b><?= $lang["home"]["error"] ?> </b><?= strip_tags(base64_decode($_GET['em'])) ?>
</div>
<?php endif; ?>
<div class="alert alert-warning alert-dismissible" id="gpuWarning" style="display: none;">
<button onclick='window.history.pushState({"html":null,"pageTitle":document.title},"", "/");' type="button" class="btn-close" data-bs-dismiss="alert"></button>
<b>GPU acceleration is turned off or not supported.</b> A lot of visual effects on this website rely on GPU acceleration, which is currently disabled on your browser, meaning the website's overall look will be affected. Please enable GPU acceleration in your browser settings.
</div>
<?php if ($readOnly && $isNormallyLoggedIn || $readOnly && $isLowerLoggedIn): ?>
<div class="alert alert-warning">
<b>Notice: </b>This website is temporarily under maintenance and the administrators have locked the database. Although you are logged in as <?= $_PROFILE['name'] ?>, you cannot access any of the logged-in features while the website is under maintenance. <a href="/-/emergency">Alerts dispatching</a> remains possible in case of an emergency.
</div>
<?php endif; ?>
<?php
$cache = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/home.json"), true);
if (!isset($cache["banner"])) $cache["banner"] = [];
if (!isset($cache["members"])) $cache["members"] = [];
if (!isset($cache["banner"]["public"])) {
ob_start();
$isLoggedInOldState = $isLoggedIn;
$isLowerLoggedInOldState = $isLowerLoggedIn;
$isLoggedIn = false;
$isLowerLoggedIn = false;
banner();
$isLoggedIn = $isLoggedInOldState;
$isLowerLoggedIn = $isLowerLoggedInOldState;
$cache["banner"]["public"] = ob_get_contents();
ob_end_clean();
}
if (!isset($cache["banner"]["private"])) {
ob_start();
$isLoggedInOldState = $isLoggedIn;
$isLowerLoggedInOldState = $isLowerLoggedIn;
$isLoggedIn = true;
$isLowerLoggedIn = true;
banner();
$isLoggedIn = $isLoggedInOldState;
$isLowerLoggedIn = $isLowerLoggedInOldState;
$cache["banner"]["private"] = ob_get_contents();
ob_end_clean();
}
if (!isset($cache["members"]["public"])) {
ob_start();
$isLoggedInOldState = $isLoggedIn;
$isLowerLoggedInOldState = $isLowerLoggedIn;
$isLoggedIn = false;
$isLowerLoggedIn = false;
members();
$isLoggedIn = $isLoggedInOldState;
$isLowerLoggedIn = $isLowerLoggedInOldState;
$cache["members"]["public"] = ob_get_contents();
ob_end_clean();
}
if (!isset($cache["members"]["private"])) {
ob_start();
$isLoggedInOldState = $isLoggedIn;
$isLowerLoggedInOldState = $isLowerLoggedIn;
$isLoggedIn = true;
$isLowerLoggedIn = true;
members();
$isLoggedIn = $isLoggedInOldState;
$isLowerLoggedIn = $isLowerLoggedInOldState;
$cache["members"]["private"] = ob_get_contents();
ob_end_clean();
}
if ($isLowerLoggedIn || $isLoggedIn) {
echo($cache["banner"]["private"]);
} else {
echo($cache["banner"]["public"]);
}
?>
<div style="background: #3332328a;padding: 5px 10px;border-top:1px solid rgba(255,255,255,.1);border-bottom-left-radius: 10px;border-bottom-right-radius: 10px;">
<div id="timeline"></div>
<script>
async function refreshTimeline() {
document.getElementById("timeline").innerHTML = await (await fetch("/api/timeline?gdapd&ynmuc<?= ($isLowerLoggedIn || $isLoggedIn) ? "&" . $app["other"]["id"] : "" ?>")).text();
Array.from(document.getElementsByClassName("dynamic-time")).forEach((el) => {
let time = el.getAttribute("data-time");
el.innerText = new Date(parseInt(time) * 1000).toTimeString().split(":").splice(0, 2).join(":");
});
Array.from(document.getElementsByClassName("dynamic-time-mobile")).forEach((el) => {
let time = el.getAttribute("data-time");
el.innerText = new Date(parseInt(time) * 1000).toTimeString().split(":")[0] + ":";
});
}
setInterval(refreshTimeline, 10000);
refreshTimeline();
</script>
</div>
<!--<div class="alert alert-warning" style="margin-top:20px;">
<b>Notice:</b> The administrators are currently trying a new optimisation technique based on a virtual file system (chvfs). Data loss, corruption or inconsistency may happen and should be reported on <a href="https://bugs.equestria.dev/issues/CH" target="_blank">bugs.equestria.dev</a>.
</div>-->
<?php if (isset($_COOKIE["PEH2_SESSION_TOKEN"]) && $_COOKIE["PEH2_SESSION_TOKEN"] !== "" && !$isLoggedIn && !$isLowerLoggedIn): ?>
<div class="alert alert-warning" style="margin-top:20px;">
<b>You were previously logged in to Cold Haze, </b>however you have been logged out due to inactivity, due to your device being removed, or due to switching to a new authentication system. Please log in again. <a href="https://bugs.equestria.dev/issue/CH-56/Better-session-security" target="_blank">Learn more.</a>
</div>
<?php endif; ?>
<?php
if ($isLowerLoggedIn || $isLoggedIn) {
echo($cache["members"]["private"]);
} else {
echo($cache["members"]["public"]);
}
?>
</div>
<?php file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/home.json", json_encode($cache)); require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/footer.inc'; ?>
|