-
-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathindex.php
250 lines (212 loc) · 9 KB
/
index.php
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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
<?php
include "header.php";
// Display notice message based on query parameters
if (isset($_GET['notice'])) {
$notice = htmlspecialchars($_GET['notice']);
if ($notice == 'cancel') {
echo '<div class="notice-message">Your transaction was canceled.</div>';
} elseif ($notice == 'thanks') {
echo '<div class="notice-message">Thank you for helping this great service continue to exist!</div>';
}
}
?>
<h1 id="fancyboi">welcome to tilde.club</h1>
<p><a href="/wiki/faq.html">Questions? See the official FAQ.</a></p>
<!-- <p class="advisory">GMAIL USERS: We no longer accept gmail.com addresses for signups since you would not receive your account information email.</p> -->
<!-- Active Users Scrolling List -->
<div id="active-users">
<h2>Currently Active Users:</h2>
<?php
$activeUsers = json_decode(file_get_contents('/usr/share/nginx/html/online-users.json'), true);
if (!empty($activeUsers))
{
echo '<marquee scrollamount="2">';
foreach ($activeUsers as $user)
{
$username = htmlspecialchars($user);
echo "<a href='/~$username'>$username</a> ";
}
echo '</marquee>';
}
else
{
echo "<li>No active users at the moment.</li>";
}
?>
</div>
<div class="grid">
<div class="row">
<div class="col">
<?php
$news = json_decode(file_get_contents('news.json'), true);
// Sort news items by date, most recent first
usort($news, function ($a, $b) {
return strtotime($b['date']) - strtotime($a['date']);
});
// Determine the year filter if present
$selectedYear = isset($_GET['year']) ? $_GET['year'] : null;
$filteredNews = [];
$currentDate = new DateTime();
foreach ($news as $newsItem) {
$newsDate = new DateTime($newsItem['date']);
// Only add to filteredNews if the current date is on or after the news date
if ($newsDate <= $currentDate) {
if ($selectedYear) {
// If filtering by year, add items from the selected year only
if (date('Y', strtotime($newsItem['date'])) == $selectedYear) {
$filteredNews[] = $newsItem;
}
} else {
// Otherwise, show the most recent 2 items
$filteredNews[] = $newsItem;
}
}
if (!$selectedYear && count($filteredNews) >= 2) {
break;
}
}
// Display news items
foreach ($filteredNews as $newsItem) {
echo '<h2>' . htmlspecialchars($newsItem['title']) . ':</h2>';
echo '<h3>' . htmlspecialchars($newsItem['heading']) . '</h3>';
echo '<p>' . htmlspecialchars($newsItem['content']) . '</p>';
if (isset($newsItem['details']) && is_array($newsItem['details'])) {
echo '<ul>';
foreach ($newsItem['details'] as $detail) {
echo '<li>' . htmlspecialchars($detail) . '</li>';
}
echo '</ul>';
}
if (isset($newsItem['note'])) {
echo '<p><strong>' . htmlspecialchars($newsItem['note']) . '</strong></p>';
}
if (isset($newsItem['additional_content'])) {
echo '<p>' . htmlspecialchars($newsItem['additional_content']) . '</p>';
}
echo '<hr>';
}
// Display year links for filtering
$years = array_unique(array_map(function ($newsItem) {
return date('Y', strtotime($newsItem['date']));
}, $news));
sort($years);
echo '<div><strong>View news by year:</strong> ';
foreach ($years as $year) {
echo '<a href="?year=' . $year . '">' . $year . '</a> ';
}
echo '</div>';
?>
</div>
<div class="col">
<p>
tilde.club is not a social network it is one tiny totally
standard unix computer that people respectfully use together
in their shared quest to build awesome web pages
</p>
<p>
If you would like a list of <a href="http://tilde.club/tilde.24h.php">
RECENTLY CHANGED PAGES</a> you can see that too
</p>
<p>
Or Check out the <a href="https://tilde.club/~tweska/gallery" target="blank">tilde.club gallery</a> created by <a href="/~tweska" target="_blank">~tweska</a>
</p>
<hr>
<h2>tilde.club gold star supporters</h2>
<p>Tilde.Club is supported by a global community of
good people. We don't rank people by the amount
they give, only by the fact that they gave.
Here's who has donated! When you're on the
server, THANK THEM.</p>
<?php
$supporters = json_decode(file_get_contents('supporters.json'), true);
usort($supporters, function($a, $b) {
return strtotime($b['date']) - strtotime($a['date']);
});
$showAll = isset($_GET['show_all']) && $_GET['show_all'] == 'true';
$supportersToShow = $showAll ? $supporters : array_slice($supporters, 0, 10);
?>
<ul>
<?php foreach ($supportersToShow as $supporter): ?>
<li><?= htmlspecialchars($supporter['date']) ?> | <a href="<?= htmlspecialchars($supporter['url']) ?>"><?= htmlspecialchars($supporter['name']) ?></a></li>
<?php endforeach; ?>
</ul>
<?php if (!$showAll): ?>
<p><a href="?show_all=true">Show all supporters</a></p>
<?php else: ?>
<p><a href="?show_all=false">Show only the 10 most recent supporters</a></p>
<?php endif; ?>
</div>
</div>
<div class="row">
<div class="col">
<h3>here are the home pages of our users</h3>
<p>this list does not include people who haven't changed their page yet.</p>
<p>if you're not seeing yourself listed here, change your page from the default.</p>
<p>users with recently updated pages within the last month are highlighted in a lighter color.</p>
<p><a href="/users/">list all users</a></p>
<?php
// these are the hashes of previous and current default pages
$page_shas = [
"0eb53dab435e2e6e401921146bed85a80e9ad3a1",
"61eff8202777bae134ac4b11f1e16ec23dfc97d3",
"e9d41eab6edb7cd375c63ecb4a23bca928992547",
"cb2ce535ab34edebc225e88a321f972ba55763c3",
"13af6898f536265af7dbbe2935b591f5e2ee0d7d",
"b0eb2bf442e52b98714456b2f8a6662ba4c1f443",
"0b4f272852e3391e97f0ebb7b5d734a765958eeb",
"59e857ec585d6d34ed21e027164b3c3c36a95f0f",
"9da422e8759799cce29327024fc77b6aa2ace484",
"e5da596bd5f72aa583839bcefd28e988c9d4fcbe",
"adc83b19e793491b1c6ea0fd8b46cd9f32e592fc",
"3f51b25206c137593124a16d8b881079352cd1c4",
"051b45fb2da9b15c523dfafd2a1dd33cc8b54e87",
"5a1cf2f88acb15da43f5d18a13fe638d175a44cc",
"0066d512c24f4ada7ad925fd0856b6b68334a93c",
"da39a3ee5e6b4b0d3255bfef95601890afd80709",
"f032fa07b3f4d9c1264a5a9369bff19f231bff45",
"259969faeba97eb16a675bb66427efd168406c92",
"75b7ce715379312bcc0b24696b9406e10b97cedc",
"e28aa091c26528a4084b8fad2a2ddb72bee3db75",
"12608ff7f6d222d97d2e02c1a13496e1d79713bb",
"22d29b83dc93b925bee08d090b0ea0fffdeb57f2",
"4706d8acdd74efd5c6d8f9e69ec215928d9ff165",
"385212d5ea557a21b77af992ea1b3c1ea71d22c9",
"b51a889545b5f065fd1ac2b8760cab0088a9dc22"
];
$oneMonthAgo = strtotime('-1 month');
// Retrieve from cache file if available
$cache_file = 'cache/homepages_list.html';
if (file_exists($cache_file) and time() - filemtime($cache_file) < 86400)
{
$homepages_list = file_get_contents($cache_file);
}
// Cache not available or expired
else
{
$homepages_list = '<div class="user-list">';
foreach (glob("/home/*") as $user) {
// Look for index files with common extensions
$indexFiles = glob("$user/public_html/index.{html,htm,php}", GLOB_BRACE);
$index = count($indexFiles) > 0 ? $indexFiles[0] : null;
if (!$index || in_array(sha1_file($index), $page_shas)) continue;
// Check if the index pages were updated in the last month
$recentChange = false;
foreach ($indexFiles as $file) {
if (filemtime($file) > $oneMonthAgo) {
$recentChange = true;
break;
}
}
$user = basename($user);
$homepages_list .= '<a href="/~'.$user.'/">'.(($recentChange) ? '<b>~'.$user.'</b>' : '~'.$user).'</a>';
}
$homepages_list .= '</div>';
// Save cache file
$save_cache = file_put_contents($cache_file, $homepages_list);
}
echo $homepages_list;
?>
</div>
</div>
</div>
<?php include "footer.php";