diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/partials.php | 26 | ||||
| -rw-r--r-- | lib/utils.php | 18 |
2 files changed, 44 insertions, 0 deletions
diff --git a/lib/partials.php b/lib/partials.php index 489acae..c35fe43 100644 --- a/lib/partials.php +++ b/lib/partials.php @@ -28,6 +28,32 @@ function html_big_navbar() <?php ; } +function html_mini_navbar() +{ + echo '' ?> + <section class="row align-center gap-8 navbar"> + <a href="/" class="row gap-8 align-bottom" style="text-decoration:none;color:inherit;"> + <img src="/static/img/brand/mini.webp" alt=""> + <h2><?= INSTANCE_NAME ?></h2> + </a> + + <div class="row gap-8 align-bottom" style="height: 100%"> + <a href="/"> + <button>Home</button> + </a> + <?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> + </div> + </section> + <?php ; +} + function html_footer() { $files = glob(FILE_UPLOAD_DIRECTORY . "/*.*"); diff --git a/lib/utils.php b/lib/utils.php index 2dab763..31d8778 100644 --- a/lib/utils.php +++ b/lib/utils.php @@ -21,4 +21,22 @@ function generate_random_char_sequence(array $chars, int $length): string } return $o; +} + +function format_timestamp(int $timestamp_secs) +{ + $days = (int) floor($timestamp_secs / (60.0 * 60.0 * 24.0)); + $hours = (int) floor(round($timestamp_secs / (60 * 60)) % 24); + $minutes = (int) floor(round($timestamp_secs % (60 * 60)) / 60); + $seconds = (int) floor($timestamp_secs % 60); + + if ($days == 0 && $hours == 0 && $minutes == 0) { + return "$seconds second" . ($seconds > 1 ? "s" : ""); + } else if ($days == 0 && $hours == 0) { + return "$minutes minute" . ($minutes > 1 ? "s" : ""); + } else if ($days == 0) { + return "$hours hour" . ($hours > 1 ? "s" : ""); + } else { + return "$days day" . ($days > 1 ? "s" : ""); + } }
\ No newline at end of file |
