<?php
include_once("../../lib/konfig.php");
session_start();
$MySQLi = new MySQLi($strDBHostName, $strDBUsername, $strDBPassword, $strDBName);
$query = "SELECT ID,strIPv4,strNmApp,case when stsIP = 1 then 'Public' else 'Private' end stsIP,
case when stsAktif = 0 then 'Offline' else 'Online' end stsAktif
FROM tpc_ip_allow;";
$result = $MySQLi->query($query);
?>
<main id="main" class="main">
    <div class="pagetitle">
        <h1>IP LIST</h1>
        <nav>
            <ol class="breadcrumb">

            </ol>
        </nav>
    </div><!-- End Page Title -->

    <section class="section">
        <div class="row">
            <div class="col-lg-12">

                <div class="card">
                    <div class="card-body">
                        <br>
                        <table class="table">
                            <thead>
                                <tr>
                                    <th scope="col">#</th>
                                    <th scope="col">IP</th>
                                    <th scope="col">Aplikasi</th>
                                    <th scope="col">Status IP</th>
                                    <th scope="col">Status Aktif</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php
                                $i = 1;
                                foreach ($result as $r) {
                                    echo "<tr>";
                                    echo "<td>" . $i . "</td>";
                                    echo "<td>" . $r['strIPv4'] . "</td>";
                                    echo "<td>" . $r['strNmApp'] . "</td>";
                                    echo "<td>" . $r['stsIP'] . "</td>";
                                    echo "<td>" . $r['stsAktif'] . "</td>";
                                    echo "</tr>";
                                    $i++;
                                }
                                ?>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </section>

</main>