aboutsummaryrefslogtreecommitdiff
path: root/admin/panes/kartik.php
blob: 10b47f5bf4766d07581abb1103e3ebbfe2b0a07d (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
<?php require_once $_SERVER['DOCUMENT_ROOT'] . "/admin/private/header.php";/** @var array $_DATA */ ?>

<style>
    ::-webkit-scrollbar {
        width: 5px;
    }

    ::-webkit-scrollbar-track {
        border-radius: 9999px;
        background: transparent;
    }

    ::-webkit-scrollbar-thumb {
        border-radius: 9999px;
        background-color: rgba(136, 136, 136, 0.5);
        transition: background 200ms;
    }

    ::-webkit-scrollbar-thumb:hover {
        background-color: rgba(85, 85, 85, 0.75);
    }

    ::-webkit-scrollbar-thumb:active {
        background-color: #222;
    }

    .list-group-item {
        background: #34373c;
    }
</style>

<div class="container" style="color:white;padding-top:15vh;padding-bottom:15vh;">
    <div>
        <h2 style="text-align:center;">Kartik Online</h2>
        <h4 style="text-align:center;"><?php

            $uca = scandir("/mnt/kartik/online/private/stats");
            $uct4 = [];

            foreach ($uca as $art) {
                if (is_file("/mnt/kartik/online/private/stats/" . $art)) {
                    $uct4[] = $art;
                }
            }

            echo(count($uct4));

            ?> player·s</h4>

        <ul class="list-group">
            <?php

            $uca = scandir("/mnt/kartik/online/private/stats");
            $uct4 = [];

            foreach ($uca as $art) {
                if (is_file("/mnt/kartik/online/private/stats/" . $art)): ?>

                <li class="list-group-item"><?= $art ?> <?php

                    $osession = 0;
                    $gsession = 0;
                    $tsession = 0;

                    $webs = scandir("/mnt/kartik/online/private/tokens");
                    $ings = scandir("/mnt/kartik/online/private/gametokens");

                    foreach ($webs as $webt) {
                        if (!is_dir("/mnt/kartik/online/private/tokens/" . $webt)) {
                            $d = json_decode(file_get_contents("/mnt/kartik/online/private/tokens/" . $webt), true);
                            if ($d["id"] === $art) {
                                $osession++;
                            }
                        }
                    }

                    foreach ($ings as $webt) {
                        if (!is_dir("/mnt/kartik/online/private/gametokens/" . $webt)) {
                            $d = json_decode(file_get_contents("/mnt/kartik/online/private/gametokens/" . $webt), true);
                            if ($d["id"] === $art) {
                                $gsession++;
                            }
                        }
                    }

                    $tsession = $osession + $gsession;
                    if ($tsession > 1) {
                        $tsessions = "s";
                    } else {
                        $tsessions = "";
                    }

                    if ($osession > 0) {
                        echo("<span class='badge text-warning border-warning' style='border:1px solid;vertical-align: middle;'>{$tsession} session{$tsessions} ({$gsession}:{$osession})</span>");
                    } else if ($gsession > 0) {
                        echo("<span class='badge text-success border-success' style='border:1px solid;vertical-align: middle;'>{$tsession} session{$tsessions} ({$gsession}:0)</span>");
                    } else {
                        echo("<span class='badge text-light border-light' style='border:1px solid;vertical-align: middle;'>Offline (0:0)</span>");
                    }

                    ?> <span style="float:right;"><a href="/admin/api/terminateWebSessions.php?_=<?= $art ?>">Terminate Web</a> · <a href="/admin/api/terminateGameSessions.php?_=<?= $art ?>">Terminate Game</a> · <a href="/admin/api/terminateAllSessions.php?_=<?= $art ?>">Terminate All</a></span></li>

                <?php endif;
            }

            ?>
        </ul>
    </div>
</div>

<?php require_once $_SERVER['DOCUMENT_ROOT'] . "/admin/private/footer.php"; ?>