summaryrefslogtreecommitdiff
path: root/lib/partials.php
blob: c35fe43c2d66a133f32b8cb407390338bf9201b0 (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
<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/../config.php';

function html_big_navbar()
{
    echo '' ?>
    <section class="column justify-center align-center gap-8 navbar">
        <div class="column justify-center grow">
            <a href="/">
                <h1><img src="/static/img/brand/big.webp" alt="<?= INSTANCE_NAME ?>"></h1>
            </a>
        </div>

        <div class="row gap-8 justify-center">
            <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_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 . "/*.*");
    $file_size = 0;

    foreach ($files as $file) {
        $file_size += filesize($file);
    }

    $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; ?>
        <?php if (!empty(INSTANCE_DONATIONS) && is_array(INSTANCE_DONATIONS)): ?>
            <div class="row gap-8">
                <details>
                    <summary>Donate</summary>

                    <table class="vertical">
                        <?php foreach (INSTANCE_DONATIONS as $k => $v): ?>
                            <tr>
                                <th><?= $k ?></th>
                                <td><?= $v ?></td>
                            </tr>
                        <?php endforeach; ?>
                    </table>
                </details>
            </div>
        <?php elseif (!empty(INSTANCE_DONATIONS) && is_string(INSTANCE_DONATIONS)): ?>
            <p><a href="<?= INSTANCE_DONATIONS ?>">[Donate]</a></p>
        <?php endif; ?>
        <p>Serving <?= count($files) ?> files and <?= $file_size ?> of active content</p>
    </footer>
    <?php ;
}