<div class="panel panel-default">
    <div class="panel-body">
        <center>
            <img src="<?= base_url() ?>assets/frontend/images/slogo.jpg" width="60%" class="img-responsive" style="padding-top: 10px;">
        </center>
        <br/>
        <p>
            Assalamu'alaikum Wr Wb 
            Selamat datang di situs resmi SD Hati Beriman, Kota Salatiga.
            Jika ada hal yang ingin diketahui lebih lanjut, silakan dapat menghubungi kami atau datang langsung ke tempat kami
            Terimakasih.
            Wassalamu'alaikum Wr Wb
        </p>
        <br/>
    </div>
</div>

<div class="panel panel-default">
    <div class="panel-heading flag">
        <h3 class="panel-title"><i class="fa fa-bar-chart"></i> Statistik Sekolah</h3>
    </div>
    <div class="panel-body">
        <?php
        // Detect Browser
        $browser = $_SERVER['HTTP_USER_AGENT'];
        $chrome = '/Chrome/';
        $firefox = '/Firefox/';
        $ie = '/MSIE/';
        if (preg_match($chrome, $browser))
            $data = "Chrome/Opera";
        if (preg_match($firefox, $browser))
            $data = "Firefox";
        if (preg_match($ie, $browser))
            $data = "IE";

// Ambil Informasi Yang diperlukan dari Pengunjung
        $ipaddress = $_SERVER['REMOTE_ADDR'] . "";
        $browser = $data;
        $tanggal = date('Y-m-d');
        $kunjungan = 1;
// Daftarkan Kedalam Session Lalu Simpan Ke Database
        if (!isset($_SESSION['visitor'])) {
            $_SESSION['visitor'] = $ipaddress;
            mysql_query("INSERT INTO visitor (tanggal,ip_address,counter,browser) VALUES ('" . $tanggal . "','" . $ipaddress . "','" . $kunjungan . "','" . $browser . "')");
        }
// Hitung Jumlah Visitor
        $kemarin = date("Y-m-d", mktime(0, 0, 0, date('m'), date('d') - 1, date('Y')));
        $hari_ini = mysql_fetch_array(mysql_query('SELECT sum(counter) AS hari_ini FROM visitor WHERE tanggal="' . date("Y-m-d") . '"'));
        $kemarin = mysql_fetch_array(mysql_query('SELECT sum(counter) AS kemarin FROM visitor WHERE tanggal="' . $kemarin . '"'));
        $sql = mysql_fetch_array(mysql_query('SELECT sum(counter) as total FROM visitor'));
        ?>
        <p style="padding-left: 15px;">
            <i class="fa fa-laptop"></i> IP Anda : <?php echo $_SERVER['REMOTE_ADDR'] ?><br/>
            <i class="fa fa-globe"></i> Browser Anda : <?php
            switch ($browser) {
                case "Firefox" : echo "" . $browser . " 
";
                    break;
                case "Chrome/Opera" : echo "" . $browser . " 
";
                    break;
                case "IE" : echo "" . $browser . " 
";
                    break;
            }
            ?>
            <br/>
            <i class="fa fa-calendar-o"></i> Jumlah Pengunjung Hari ini : <?php echo $hari_ini['hari_ini'] ?><br/>
            <i class="fa fa-calendar-o"></i> Jumlah Pengunjung Kemarin : <?php echo $kemarin['kemarin'] ?><br/>
            <i class="fa fa-calendar-o"></i> Jumlah Total Pengunjung : <?php echo $sql['total'] ?><br/>
        </p>


    </div>
</div>