blob: 288f66082f5bffe665a8250d2a6b1378e1bfe630 (
plain)
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
|
<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/../config.php';
function html_big_navbar()
{
$brand_url = '/static/img/brand/big.webp';
$static_folder = '/static/img/brand/big';
$brand_folder = $_SERVER['DOCUMENT_ROOT'] . $static_folder;
if (is_dir($brand_folder)) {
$files = glob("$brand_folder/*.*");
if (!empty($files)) {
$file = basename($files[random_int(0, count($files) - 1)]);
$brand_url = "$static_folder/$file";
}
}
$line = null;
$line_path = $_SERVER['DOCUMENT_ROOT'] . '/../MOTD.txt';
if (file_exists($line_path) && $contents = file_get_contents($line_path)) {
$lines = explode("\n", trim($contents));
$line_count = count($lines);
if ($line_count > 0) {
$line = $lines[intval(date('j')) % $line_count];
}
}
echo '' ?>
<section class="column justify-center align-center gap-8 navbar">
<div class="column align-center justify-center grow">
<a href="/">
<h1><img src="<?= $brand_url ?>" alt="<?= INSTANCE_NAME ?>"></h1>
</a>
<?php if (isset($line)): ?>
<p><i>"<?= $line ?>"</i></p>
<?php endif; ?>
</div>
<div class="row gap-8 justify-center">
<a href="/">
<button>Home</button>
</a>
<?php if (FILE_CATALOG_PUBLIC || isset($_SESSION['is_moderator'])): ?>
<a href="/catalogue.php">
<button>Catalogue</button>
</a>
<?php endif; ?>
<?php if (FILE_CATALOG_RANDOM): ?>
<a href="/?random">
<button>I'm Feeling Lucky</button>
</a>
<?php endif; ?>
<a href="/uploaders.php">
<button>Uploaders</button>
</a>
<?php if (isset($_SESSION['is_moderator'])): ?>
<a href="/mod.php">
<button>Moderation</button>
</a>
<?php endif; ?>
</div>
</section>
<?php ;
}
function html_mini_navbar(string|null $subtitle = null)
{
$brand_url = '/static/img/brand/mini.webp';
$static_folder = '/static/img/brand/mini';
$brand_folder = $_SERVER['DOCUMENT_ROOT'] . $static_folder;
if (is_dir($brand_folder)) {
$files = glob("$brand_folder/*.*");
if (!empty($files)) {
$file = basename($files[random_int(0, count($files) - 1)]);
$brand_url = "$static_folder/$file";
}
}
echo '' ?>
<section class="row align-bottom gap-8 navbar wrap">
<a href="/" class="row gap-8 align-bottom" style="text-decoration:none;color:inherit;">
<img src="<?= $brand_url ?>" alt="">
<div class="column">
<?php if ($subtitle): ?>
<p class="font-small"><?= $subtitle ?></p>
<?php endif; ?>
<h2><?= INSTANCE_NAME ?></h2>
</div>
</a>
<div class="row gap-8 align-bottom" style="height: 100%">
<a href="/">
<button>Home</button>
</a>
<?php if (FILE_CATALOG_PUBLIC || isset($_SESSION['is_moderator'])): ?>
<a href="/catalogue.php">
<button>Catalogue</button>
</a>
<?php endif; ?>
<?php if (FILE_CATALOG_RANDOM): ?>
<a href="/?random">
<button>I'm Feeling Lucky</button>
</a>
<?php endif; ?>
<a href="/uploaders.php">
<button>Uploaders</button>
</a>
<?php if (isset($_SESSION['is_moderator'])): ?>
<a href="/mod.php">
<button>Moderation</button>
</a>
<?php endif; ?>
</div>
</section>
<?php ;
}
function html_footer()
{
$db = new PDO(DB_URL, DB_USER, DB_PASS);
$stmt = $db->query('SELECT COUNT(*) AS file_count, SUM(size) AS file_overall_size FROM files WHERE id NOT IN (SELECT id FROM file_bans)');
$stmt->execute();
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$file_count = $row['file_count'];
$file_size = $row['file_overall_size'];
$suffix = 'MB';
$file_size /= 1024 * 1024; // MB
if ($file_size >= 1024) {
$file_size /= 1024;
$suffix = 'GB';
}
$file_size = sprintf('%.2f%s', $file_size, $suffix);
echo '' ?>
<footer class="column justify-center align-center gap-8">
<?php if (array_key_exists(INSTANCE_URL, INSTANCE_MIRRORS)): ?>
<p>You are using a mirror for <?= INSTANCE_MIRRORS[INSTANCE_URL] ?>. <a href="<?= INSTANCE_ORIGINAL_URL ?>">[ Check
out the origin website ]</a></p>
<?php elseif (!empty(INSTANCE_MIRRORS)): ?>
<div class="row gap-8">
<p>Mirrors:</p>
<ul class="row gap-4" style="list-style: none;">
<?php foreach (INSTANCE_MIRRORS as $url => $name): ?>
<li><a href="<?= $url ?>"><?= $name ?></a></li>
<?php endforeach; ?>
</ul>
</div>
<?php endif; ?>
<div class="row gap-8">
<?php foreach (INSTANCE_FOOTER_LINKS as $title => $link): ?>
<p><a href="<?= $link ?>"><?= $title ?></a></p>
<?php endforeach; ?>
</div>
<p>Serving <?= $file_count ?> files and <?= $file_size ?> of active content</p>
</footer>
<?php ;
}
|