<?php
/**
*
* @ This file is created by http://DeZender.Net
* @ deZender (PHP7 Decoder for SourceGuardian Encoder)
*
* @ Version			:	5.0.1.0
* @ Author			:	DeZender
* @ Release on		:	22.04.2022
* @ Official site	:	http://DeZender.Net
*
*/

require "includes/check.php";
$ifofuser_check = $_SESSION["id"];
$jsondata_admin = file_get_contents("./includes/brbox.json");
$data_admin = json_decode($jsondata_admin, true);
$json_admin = $data_admin["info"];
$col_admin = $json_admin["oo"];
if ($col_admin == "0") {
    header("Location: app.php");
}
$db1 = new SQLite3("./api/db/brbox_users_online.db");
$db1->exec("CREATE TABLE IF NOT EXISTS logging(id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, appid TEXT, version TEXT, device TEXT, pkg TEXT, app TEXT, cid TEXT, uid TEXT, status TEXT, d TEXT, time TEXT, last_online TEXT, ping TEXT, ip TEXT)");
$res1 = $db1->query("SELECT * FROM logging WHERE status='yes'");
if (isset($_GET["delete"])) {
    $db1->exec("DELETE FROM logging WHERE id=" . $_GET["delete"]);
    header("Location: users.php");
}
include "includes/header.php";
echo "<div class=\"modal fade\" id=\"confirm-delete\" tabindex=\"-1\" role=\"dialog\" aria-labelledby=\"myModalLabel\" aria-hidden=\"true\">\n    <div class=\"modal-dialog\">\n        <div class=\"modal-content\">\n            <div class=\"modal-header\">\n                <h2>Confirm</h2>\n            </div>\n            <div class=\"modal-body\">\n                Do you really want to delete?\n            </div>\n            <div class=\"modal-footer\">\n                <button type=\"button\" class=\"btn btn-default\" data-dismiss=\"modal\">Cancel</button>\n                <a class=\"btn btn-danger btn-ok\">Delete</a>\n            </div>\n        </div>\n    </div>\n</div>\n<main role=\"main\" class=\"col-15 pt-4 px-5\"><div class=\"row justify-text-center\"><div class=\"chartjs-size-monitor\" style=\"position:absolute ; left: 0px; top: 0px; right: 0px; bottom: 0px; overflow: hidden; pointer-events: none; visibility: hidden; z-index: -1;\"><div class=\"chartjs-size-monitor-expand\" style=\"position:absolute;left:0;top:0;right:0;bottom:0;overflow:hidden;pointer-events:none;visibility:hidden;z-index:-1;\"><div style=\"position:absolute;width:1000000px;height:1000000px;left:0;top:0\"></div></div><div class=\"chartjs-size-monitor-shrink\" style=\"position:absolute;left:0;top:0;right:0;bottom:0;overflow:hidden;pointer-events:none;visibility:hidden;z-index:-1;\"><div style=\"position:absolute;width:200%;height:200%;left:0; top:0\"></div></div></div>\n          <div id=\"main\">\n            \n\n";
if (isset($_GET["message"])) {
    echo $_GET["message"];
}
echo "          <!-- Page Heading -->\n          <h1 class=\" h3 mb-1 text-gray-800\">\n          <i class=\"fas fa-fw fa-user-plus\"></i>\n";
echo "          <span>" . $numRows_count . " Online Users\t</h1></span>" . "\n";
echo "                        <a button class=\"btn btn-primary btn-icon-split\" id=\"button\" href=\"./all_users.php\">\n                        <span class=\"icon text-white-50\"><i class=\"fas fa-arrow-left\"></i></span><span class=\"text\">All Users</span>\n                        </button></a>\n          </div>\n\t\t<div class=\"table-responsive\">\n\t\t\t<table class=\"table table-striped table-sm\">\n\t\t\t<thead class= \"text-primary\">\n\t\t\t\t<tr>\n\t\t\t\t<th>User ID</th>\n\t\t\t\t<th>IP Address</th>\n\t\t\t\t<th>Online</th>\n\t\t\t\t<th>Last Online</th>\n\t\t\t\t<th>App ID</th>\n\t\t\t\t<th>Version</th>\n\t\t\t\t<th>Device</th>\n\t\t\t\t<th>Package Name</th>\n\t\t\t\t<th>App Name</th>\n\t\t\t\t<th>Customer ID</th>\n\t\t\t\t<th>First Registered</th>\n\t\t\t\t<th>Last Connection</th>\n\t\t\t\t<th>Delete</th>\n\t\t\t\t</tr>\n\t\t\t</thead>\n";
while ($row1 = $res1->fetchArray()) {
    $id = $row1["id"];
    $userid = $row1["uid"];
    $appid = $row1["appid"];
    $status = $row1["status"];
    $version = $row1["version"];
    $device = $row1["device"];
    $app = $row1["app"];
    $pkg = $row1["pkg"];
    $cid = $row1["cid"];
    $time = $row1["time"];
    $last_online = $row1["last_online"];
    $ping = $row1["ping"];
    $ipadd = $row1["ip"];
    echo "\t\t\t<tbody>\n\t\t\t\t<tr>\n";
    echo "\t\t\t\t<td>" . $userid . "</td>" . "\n";
    echo "\t\t\t\t<td>" . $ipadd . "</td>" . "\n";
    echo "\t\t\t\t<td><center>";
    if ($status == "yes") {
        echo "<span class=\"icon text-white-50\"><i class=\"fas fa-fw fa fa-check\"style=\"font-size:20px;color:green\"></i></span>";
    } else {
        echo "<span class=\"icon text-white-50\"><i class=\"fas fa-fw fa fa-times\"style=\"font-size:20px;color:red\"></i></span>";
    }
    echo "\t\t\t\t<td>" . $last_online . "</td>" . "\n";
    echo "\t\t\t\t<td>" . $appid . "</td>" . "\n";
    echo "\t\t\t\t<td>" . $version . "</td>" . "\n";
    echo "\t\t\t\t<td>" . $device . "</td>" . "\n";
    echo "\t\t\t\t<td>" . $pkg . "</td>" . "\n";
    echo "\t\t\t\t<td>" . $app . "</td>" . "\n";
    echo "\t\t\t\t<td>" . $cid . "</td>" . "\n";
    echo "\t\t\t\t<td>" . $time . "</td>" . "\n";
    echo "\t\t\t\t<td>" . $ping . "</td>" . "\n";
    echo "             <td><a class=\"btn btn-icon\" href=\"#\" data-href=\"./users.php?delete=" . $id . "\" data-toggle=\"modal\" data-target=\"#confirm-delete\"><span class=\"icon text-white-50\"><i class=\"fas fa-fw fa fa-trash-o\"style=\"font-size:20px;color:red\"></i></span></a></td>" . "\n";
    echo "\t\t\t\t</tr>\n\t\t\t</tbody>\n";
}
echo "\t\t\t</table>\n\t\t</div>\n</main>\n\n    <br><br><br>";
include "includes/footer.php";
require "includes/brbox.php";
echo "</body>\n";

?>