summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authormoderndevslulw <moderndevslulw@alright.party>2025-07-06 02:06:25 +0500
committermoderndevslulw <moderndevslulw@alright.party>2025-07-06 02:06:25 +0500
commit65ef7bc6c9a18e7421468d0853d0c67369c01f97 (patch)
treeaeca097ec1d647daed354660957931062e582f0d /lib
parentbb920b117c33c8f78331aa1aea0470efece356a5 (diff)
feat: channel pages
Diffstat (limited to 'lib')
-rw-r--r--lib/partials.php5
-rw-r--r--lib/utils.php21
2 files changed, 26 insertions, 0 deletions
diff --git a/lib/partials.php b/lib/partials.php
index 0fec678..f957cb5 100644
--- a/lib/partials.php
+++ b/lib/partials.php
@@ -1,4 +1,6 @@
<?php
+include_once $_SERVER['DOCUMENT_ROOT'] . '/../config.php';
+
function html_navigation_bar()
{
echo '' ?>
@@ -11,6 +13,9 @@ function html_navigation_bar()
<section class="row gap-16">
<a href="/">home</a>
<a href="/wiki.php">wiki</a>
+ <?php if (SHOW_CHANNEL_LIST): ?>
+ <a href="/channels/">channels</a>
+ <?php endif; ?>
</section>
</header>
<?php ;
diff --git a/lib/utils.php b/lib/utils.php
new file mode 100644
index 0000000..6de3dfb
--- /dev/null
+++ b/lib/utils.php
@@ -0,0 +1,21 @@
+<?php
+function format_timestamp($timestamp)
+{
+ $days = (int) floor($timestamp / (60.0 * 60.0 * 24.0));
+ $years = (int) floor($days / 365);
+ $hours = (int) floor(round($timestamp / (60 * 60)) % 24);
+ $minutes = (int) floor(round($timestamp % (60 * 60)) / 60);
+ $seconds = (int) floor($timestamp % 60);
+
+ if ($years == 0 && $days == 0 && $hours == 0 && $minutes == 0) {
+ return "$seconds second" . ($seconds > 1 ? "s" : "");
+ } else if ($years == 0 && $days == 0 && $hours == 0) {
+ return "$minutes minute" . ($minutes > 1 ? "s" : "");
+ } else if ($years == 0 && $days == 0) {
+ return "$hours hour" . ($hours > 1 ? "s" : "");
+ } else if ($years == 0) {
+ return "$days day" . ($days > 1 ? "s" : "");
+ } else {
+ return "$years year" . ($years > 1 ? "s" : "");
+ }
+} \ No newline at end of file