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

if (!file_exists(CFG_PATH)) {
    header('Location: /system/config.php');
    exit("You have to set up the instance first!");
}

include_once "{$_SERVER['DOCUMENT_ROOT']}/lib/accounts.php";
include_once "{$_SERVER['DOCUMENT_ROOT']}/lib/version.php";

authorize_user();

?>
<html>

<head>
    <title><?= CONFIG['instance']['name'] ?></title>
    <link rel="stylesheet" href="/static/style.css">
    <link rel="shortcut icon" href="/static/favicon.ico" type="image/x-icon">
</head>

<body>
    <div class="container">
        <div class="wrapper center big-gap">
            <h1><img src="/static/img/brand/big.webp" alt="<?= CONFIG['instance']['name']; ?>"></h1>

            <div class="items row" style="gap:32px;">
                <a href="/emotes">Emotes</a>

                <?php if (CONFIG['emoteset']['public']): ?>
                    <a href="/emotesets/">Emotesets</a>
                <?php endif; ?>

                <?php if (CONFIG['account']['publiclist']): ?>
                    <a href="/users.php">Users</a>
                <?php endif; ?>

                <?php if (CONFIG['emote']['upload'] && (CONFIG['anonymous']['upload'] || (isset($_SESSION["user_role"]) && $_SESSION["user_role"]["permission_upload"]))) {
                    echo '<a href="/emotes/upload.php">Upload</a>';
                } ?>
                <a href="/account">Account</a>
                <a href="/software.php">Chat clients & Tools</a>
            </div>

            <form action="/emotes" method="get" class="row">
                <input type="text" name="q">
                <button type="submit">Search</button>
            </form>

            <div class="counter">
                <?php
                $db = new PDO(CONFIG['database']['url'], CONFIG['database']['user'], CONFIG['database']['pass']);
                $results = $db->query("SELECT COUNT(*) FROM emotes WHERE visibility = 1");
                $count = $results->fetch()[0];

                foreach (str_split($count) as $c) {
                    echo "<img src=\"/static/img/counter/$c.png\" alt=\"$c\" />";
                }
                ?>
            </div>

            <p class="font-small">
                <?php
                // cv pasted from https://gist.github.com/eusonlito/5099936
                function size($dir)
                {
                    $size = 0;

                    foreach (glob(rtrim($dir, '/') . '/*') as $each) {
                        $size += is_file($each) ? filesize($each) : size($each);
                    }

                    return $size;
                }

                echo "Serving $count gorillion emotes and ";

                echo sprintf("%.2f", size("./static/userdata") / 1024 / 1024) . 'MB of active content - Running ';

                echo '<a href="' . TINYEMOTES_LINK . '">';
                echo sprintf("%s v%s", TINYEMOTES_NAME, TINYEMOTES_VERSION);
                echo '</a> ';

                if (TINYEMOTES_COMMIT != null) {
                    echo '<a href="' . sprintf("%s/commit/?id=%s", TINYEMOTES_LINK, TINYEMOTES_COMMIT) . '">(Commit ';
                    echo substr(TINYEMOTES_COMMIT, 0, 7);
                    echo ')</a>';
                }
                ?>

                - <a href="/tos.php">Terms of Service</a>
                - <a href="/privacy.php">Privacy Policy</a>
            </p>
        </div>
    </div>
</body>

</html>