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

session_start();
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
$ifofuser = $_SESSION['id'];
$jsondata_admin1 = file_get_contents('./includes/eggzie.json');
$data_admin1 = json_decode($jsondata_admin1, true);
$json_admin1 = $data_admin1['info'];
$col_admin1 = $json_admin1['mm'];
$hiideip1_admin1 = $json_admin1['ip'];

if ($col_admin1 == '0') {
	header('Location: dashboard.php');
}

$db1 = new SQLite3('a/.logs.db');
$db1->exec('CREATE TABLE IF NOT EXISTS logs(id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, date datetime, ipaddress TEXT)');
$res1 = $db1->query('SELECT * FROM logs');

if (isset($_GET['delete'])) {
	$db1->exec('DELETE FROM logs WHERE id=' . $_GET['delete']);
	$db1->close();
	header('Location: snoop.php?succes');
}

if (isset($_GET['delete_eggzie_style'])) {
	$db1->exec('DROP TABLE logs');
	header('Location: snoop.php?succes');
}

include 'includes/header.php';
echo '<div class="modal fade" id="confirm-delete" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">' . "\n";
echo '    <div class="modal-dialog">' . "\n";
echo '        <div class="modal-content">' . "\n";
echo '            <div class="modal-header">' . "\n";
echo '                <h2>Confirm</h2>' . "\n";
echo '            </div>' . "\n";
echo '            <div class="modal-body">' . "\n";
echo '                Do you really want to delete?' . "\n";
echo '            </div>' . "\n";
echo '            <div class="modal-footer">' . "\n";
echo '                <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>' . "\n";
echo '                <a class="btn btn-danger btn-ok">Delete</a>' . "\n";
echo '            </div>' . "\n";
echo '        </div>' . "\n";
echo '    </div>' . "\n";
echo '</div>' . "\n";
echo '    <div class="container-fluid">' . "\n";

if (isset($_GET['succes'])) {
	echo $msg_delete;
}

if (isset($_GET['success'])) {
	echo $msg_success;
}

echo '          <h1 class="h3 mb-1" style="color:' . $colour_head_16 . ';"> Snoop</h1>' . "\n";
echo "\n";
echo '                <div class="card border-left-primary shadow h-100 card shadow mb-4">' . "\n";
echo '                <div class="card-header py-3">' . "\n";
echo '                <h6 class="m-0 font-weight-bold" style="color:' . $colour_head_11 . ';"><i class="fa fa-clock"></i> Time Logs</h6>' . "\n";
echo '                </div>' . "\n";
echo '                    <div class="card-body">';

if ($ifofuser == '2') {
	echo '                    <a button class="btn btn-danger btn-icon-split" href="./snoop.php?delete_eggzie_style">' . "\n";
	echo '                            <span class="icon text-white-50"><i class="fas fa-ban"></i></span><span class="text"> REMOVE ALL</span>' . "\n";
	echo '                            </button></a>' . "\n";
}

echo '    ' . "\t\t\t\t\t" . '<hr>';
echo "\t\t\t\t\t\t" . '<div class="table-responsive">';
echo "\t\t\t\t\t\t\t" . '<table id="Dtable" class="table" style="width:100%">';
echo "\t\t\t\t\t\t\t" . '<thead>';
echo "\t\t\t" . '<tr style = "color:' . $colour_head_12 . ';">';
echo "\t\t\t" . '<th style = "display:none" >Index</th>';
echo "\t\t\t\t" . '<th>IP Address</th>' . "\n";
echo "\t\t\t\t" . '<th>Date</th>' . "\n";
echo "\t\t\t\t" . '<th>Delete</th>' . "\n";
echo "\t\t\t\t" . '</tr>';
echo "\t\t\t\t" . '</thead>';
echo "\t\t\t\t" . '<tbody style="color:' . $colour_head_2 . ';">';

while ($row1 = $res1->fetchArray()) {
	$id = $row1['id'];
	$ipad = $row1['ipaddress'];
	$date = $row1['date'];
	$ipad = str_replace($hiideip1_admin1, '--ADMIN LOGIN--', $ipad);
	echo "\t\t\t\t\t" . ' <tr style="background-color:' . $colour_head_3 . ';color:' . $colour_head_2 . ';">';
	echo "\t\t\t\t\t" . ' <td style = "display:none">' . $id . '</td>';
	echo '                  <td>' . $ipad . '</td>' . "\n";
	echo '                  <td>' . $date . '</td>' . "\n";
	echo "\t\t\t" . ' <td style="overflow:hidden;max-width: 40px;"><a class="btn btn-icon" href="#" data-href="./snoop.php?delete=' . $id . '" data-toggle="modal" data-target="#confirm-delete"><i class="fa fa-trash-o" style="font-size:15px;color:red"></i></a></td>';
	echo "\t\t\t\t\t" . '</tr>';
}

echo "\t\t\t\t\t\t\t" . '</tbody>';
echo "\t\t\t\t\t\t\t" . '</table>';
echo "\t\t\t\t\t\t" . '</div>';
echo "\t\t\t\t\t" . '</div>';
echo "\t\t\t\t" . '</div>';
echo "\t\t\t\t" . '</div>';
include 'includes/footer.php';
echo '</body>';
echo '</html>';
require 'includes/egz.php';

?>