<?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
*
*/

function my_error_handler($code, $message)
{
	echo sprintf('sprintf', $code);
	echo 'sprintf';
	return 'sprintf';
}

function function_added_to_every_file()
{
}

date_default_timezone_set('America/Sao_Paulo');
$dbcc = new SQLite3('./api/data/.boxbr_conected.db');
$dbcc->exec('CREATE TABLE IF NOT EXISTS conected(id INTEGER PRIMARY KEY NOT NULL,' . "\r\t" . 'date VARCHAR(50),' . "\r\t" . 'device VARCHAR(50),' . "\r\t" . 'os VARCHAR(50),' . "\r\t" . 'activecode VARCHAR(50),' . "\r\t" . 'appname VARCHAR(50),' . "\r\t" . 'macAddress VARCHAR(50),' . "\r\t" . 'uid VARCHAR(50),' . "\r\t" . 'ipaddress VARCHAR(50),' . "\r\t" . 'isp VARCHAR(50),' . "\r\t" . 'state VARCHAR(50),' . "\r\t" . 'country VARCHAR(50),' . "\r\t" . 'block VARCHAR(50)' . "\r\t" . ')');
$rescc = $dbcc->query('SELECT * FROM conected');

if (isset($_GET['delete'])) {
	if ($_GET['delete'] == 'all') {
		$dbcc->exec('DELETE FROM conected');
	}
	else {
		$dbcc->exec('DELETE FROM conected WHERE id=' . $_GET['delete']);
	}

	$dbcc->close();
	header('Location: conected.php');
}

if (isset($_GET['block'])) {
	$idb = $_GET['id'];

	if ($_GET['block'] == '1') {
		$dbcc->exec('UPDATE conected SET block=\'1\'' . "\r\t\t\t\t\t\t" . '  WHERE ' . "\r\t\t\t\t\t\t\t" . '   id=\'' . $idb . '\'');
	}
	else {
		$dbcc->exec('UPDATE conected SET block=\'0\' ' . "\r\t\t\t\t\t\t" . '  WHERE ' . "\r\t\t\t\t\t\t\t" . '   id=\'' . $idb . '\'');
	}

	$dbcc->close();
	header('Location: conected.php');
}

include 'includes/header.php';
echo "\r" . '<div class="modal fade" id="confirm-block" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">' . "\r" . '    <div class="modal-dialog">' . "\r" . '        <div class="modal-content">' . "\r" . '            <div class="modal-header">' . "\r" . '                <h2>Confirm</h2>' . "\r" . '            </div>' . "\r" . '            <div class="modal-body">' . "\r" . '               Do you really want to Block?' . "\r" . '            </div>' . "\r" . '            <div class="modal-footer">' . "\r" . '                <button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>' . "\r" . '                <a class="btn btn-danger btn-ok">Block</a>' . "\r" . '            </div>' . "\r" . '        </div>' . "\r" . '    </div>' . "\r" . '</div>' . "\r" . '<div class="modal fade" id="confirm-unblock" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">' . "\r" . '    <div class="modal-dialog">' . "\r" . '        <div class="modal-content">' . "\r" . '            <div class="modal-header">' . "\r" . '                <h2>Confirm</h2>' . "\r" . '            </div>' . "\r" . '            <div class="modal-body">' . "\r" . '               Do you really want to UnBlock?' . "\r" . '            </div>' . "\r" . '            <div class="modal-footer">' . "\r" . '                <button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>' . "\r" . '                <a class="btn btn-danger btn-ok">UnBlock</a>' . "\r" . '            </div>' . "\r" . '        </div>' . "\r" . '    </div>' . "\r" . '</div>' . "\r\r" . '<div class="modal fade" id="confirm-delete" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">' . "\r" . '    <div class="modal-dialog">' . "\r" . '        <div class="modal-content">' . "\r" . '            <div class="modal-header">' . "\r" . '                <h2>Confirm</h2>' . "\r" . '            </div>' . "\r" . '            <div class="modal-body">' . "\r" . '               Do you really want to delete?' . "\r" . '            </div>' . "\r" . '            <div class="modal-footer">' . "\r" . '                <button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>' . "\r" . '                <a class="btn btn-danger btn-ok">Delete</a>' . "\r" . '            </div>' . "\r" . '        </div>' . "\r" . '    </div>' . "\r" . '</div>' . "\r" . '<div class="modal fade" id="confirm-deleteall" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">' . "\r" . '    <div class="modal-dialog">' . "\r" . '        <div class="modal-content">' . "\r" . '            <div class="modal-header">' . "\r" . '                <h2>Confirm</h2>' . "\r" . '            </div>' . "\r" . '            <div class="modal-body">' . "\r" . '               Do you really want to delete All?' . "\r" . '            </div>' . "\r" . '            <div class="modal-footer">' . "\r" . '                <button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>' . "\r" . '                <a class="btn btn-danger btn-ok">Delete All</a>' . "\r" . '            </div>' . "\r" . '        </div>' . "\r" . '    </div>' . "\r" . '</div>' . "\r" . '<!-- [ Main Content ] start -->' . "\r" . '    <div class="pcoded-main-container">' . "\r" . '        <div class="pcoded-wrapper">' . "\r" . '            <div class="pcoded-content">' . "\r" . '                <div class="pcoded-inner-content">' . "\r" . '                    <div class="main-body">' . "\r" . '                        <div class="page-wrapper">' . "\r" . '                            <!-- [ Main Content ] start -->' . "\r" . '                            <div class="row">' . "\r" . '                    <!-- Column -->' . "\r" . '                    <div class="col-lg-12">' . "\r" . '                        <div class="card mb-4">' . "\r\t\t\t\t\t\t\t" . '<div class="card-header bg-primary py-3">' . "\r" . '                ' . "\t\t\t\t" . '<h4 align="center" class="m-0 font-weight-bold text-white"><i class="fas fa-satellite-dish" style="font-size:20px">&nbsp;&nbsp;</i>API Connected Users Panel </h4>' . "\r" . '                ' . "\t\t\t" . '</div>' . "\r" . '                         <div class="card-body">' . "\r\t\t\t\t\t\t\t" . ' <br>' . "\r\r" . '<div class="input-group ">' . "\r" . '    <div class="input-group-prepend ">' . "\r" . '    <span class="input-group-text " style="font-size:24px;color:#1cc88a"><i class="fas fa-search"></i></span></div>' . "\r" . '    <input class="form-control" type="text" maxlength="240" id="search" placeholder="Search for: Date / ActiveCode / Username / Mac / UID / IP / Region ..."  name="search_value" />' . "\r\t" . '<!--' . "\t\t" . 'Show Numbers Of Rows ' . "\t\t" . '-->' . "\r\r\t\t\t" . ' ' . "\t\t" . '<select class  ="input-group-text" name="state" id="maxRows"  style="width:150px;">' . "\r\t\t\t\t\t\t" . ' <option value="5000">Show ALL Rows</option>' . "\r\t\t\t\t\t\t" . ' <option value="5">Show 5 Rows</option>' . "\r\t\t\t\t\t\t" . ' <option value="10">Show 10 Rows</option>' . "\r\t\t\t\t\t\t" . ' <option value="15">Show 15 Rows</option>' . "\r\t\t\t\t\t\t" . ' <option value="20">Show 20 Rows</option>' . "\r\t\t\t\t\t\t" . ' <option value="50">Show 50 Rows</option>' . "\r\t\t\t\t\t\t" . ' <option value="70">Show 70 Rows</option>' . "\r\t\t\t\t\t\t" . ' <option value="100">Show 100 Rows</option>' . "\r\t\t\t\t\t\t" . '</select> ' . "\r\t\t\t\t\t\t" . '<a class="btn btn-danger text-white-20" href="#" data-href="./conected.php?delete=all" data-toggle="modal" data-target="#confirm-deleteall">' . "\r\t\t\t\t\t\t" . '<span class="icon text-white-20"><i class="fa fa-user-trash" style="font-size:24px;color:red;display:flex; justify-content:flex-end; width:100%; padding:0;"></i> Delete All</span></a>' . "\r" . '        ' . "\r" . '                    </div>' . "\r" . '         </div><div class="table-responsive">' . "\r" . '<table id="myTable" cellpadding="0" cellspacing="0" border="0" class="table stable-striped table-sm datatable stable-bordered">' . "\r\t\t\t\t\t\t\t" . '<thead align="center" class="text-primary">' . "\r\t\t\t\t\t\t\t\t" . '<tr>' . "\r\t\t\t\t\t\t\t\t\t" . '<th>Entry date</th>' . "\r\t\t\t\t\t\t\t\t\t" . '<th>Device / OS</th>' . "\r\t\t\t\t\t\t\t\t\t" . '<th>ClientCode / AppName</th>' . "\r\t\t\t\t\t\t\t\t\t" . '<th>macAddress / Uid</th>' . "\r\t\t\t\t\t\t\t\t\t" . '<th>IP Address / ISP</th>' . "\r\t\t\t\t\t\t\t\t\t" . '<th>State / Country</th>' . "\r\t\t\t\t\t\t\t\t\t" . '<th>Access Status</th>' . "\r\t\t\t\t\t\t\t\t\t" . '<th>Delete</th>' . "\r\t\t\t\t\t\t\t\t" . '</tr>' . "\r\t\t\t\t\t\t\t" . '</thead>' . "\r\t\t\t\t\t\t\t\r\t\t\t\t\t\t\t";

while ($rowcc = $rescc->fetchArray()) {
	echo "\t\t\t\t\t\t\t" . '<tbody align="center">' . "\r\t\t\t\t\t\t\t\t" . '<tr class="text-primary">' . "\r\t\t\t\t\t\t\t\t" . '<td>';
	echo $rowcc['date'];
	echo '</td>' . "\r\t\t\t\t\t\t\t\t" . '<td>';
	echo $rowcc['device'];
	echo '<br>';
	echo $rowcc['os'];
	echo '</td>' . "\r\t\t\t\t\t\t\t\t" . '<td>';
	echo $rowcc['activecode'];
	echo '<br>';
	echo $rowcc['appname'];
	echo '</td>' . "\r\t\t\t\t\t\t\t\t" . '<td>';
	echo $rowcc['macAddress'];
	echo '<br>';
	echo $rowcc['uid'];
	echo '</td>' . "\r\t\t\t\t\t\t\t\t" . '<td>';
	echo $rowcc['ipaddress'];
	echo '<br>';
	echo $rowcc['isp'];
	echo '</td>' . "\r\t\t\t\t\t\t\t\t" . '<td>';
	echo $rowcc['state'];
	echo '<br>' . "\r\t\t\t\t\t\t\t\t";

	if (empty($rowcc['country'])) {
		echo 'Unknown';
	}
	else {
		echo "\t\t\t\t\t\t\t\t" . '    <img type="image" src="./assets/images/flags/';
		echo strtolower($rowcc['country']);
		echo '.png" alt="image">&nbsp;&nbsp;&nbsp;';
		echo $rowcc['country'];
		echo "\t\t\t\t\t\t\t\t";
	}

	echo "\t\t\t\t\t\t\t\t" . '    </td>' . "\r\r\t\t\t\t\t\t\t\t";

	if ($rowcc['block'] == '1') {
		$sta = 'Access Blocked';
	}
	else {
		$sta = 'Unlocked Access';
	}

	echo "\t\t\t\t\t\t\t\t" . '<td title="';
	echo $sta;
	echo '" style="text-align: left">' . "\r\t\t\t\t\t\t\t\t" . '<center>';
	echo $sts;
	echo ' </center>' . "\r\t\t\t\t\t\t\t\t";

	if ($rowcc['block'] == '1') {
		echo "\t\t\t\t\t\t\t\t\t" . '<a class="btn btn-danger text-white-15" href="#" data-href="./conected.php?block=0&id=';
		echo $rowcc['id'];
		echo '" data-toggle="modal" data-target="#confirm-unblock">' . "\r\t\t\t\t\t\t" . '<span class="icon text-white-20"><i class="fa fa-lock"></i> </span></a>' . "\r" . '        ' . "\t";
	}
	else {
		echo "\t\t\t\t\t\t\t\t\t\t" . '<a class="btn btn-success text-white-15" href="#" data-href="./conected.php?block=1&id=';
		echo $rowcc['id'];
		echo '" data-toggle="modal" data-target="#confirm-block">' . "\r\t\t\t\t\t\t" . '<span class="icon text-white-20"><i class="fa fa-unlock-alt"></i></span></a>' . "\r" . '        ' . "\t\t\t\t\r\t\t\t\t\t\t";
	}

	echo "\t\t\t\t\t\t\t\t" . '</td>' . "\r\t\t\t\t\t\t\t\t\r\t\t\t\t\t\t\t\t" . '<td>' . "\r\t\t\t\t\t\t\t\t\t" . '<a class="btn btn-danger text-white-15" href="#" data-href="./conected.php?delete=';
	echo $rowcc['id'];
	echo '" data-toggle="modal" data-target="#confirm-delete">' . "\r\t\t\t\t\t\t" . '<span class="icon text-white-20"><i class="fa fa-trash"></i> </span></a>' . "\r" . '        ' . "\t\r\t\t\t\t\t\t\t\t" . '</tr>' . "\r\t\t\t\t\t\t\t" . '</tbody>' . "\r\t\t\t\t\t\t\t";
}

echo '<script src="//cdnjs.cloudflare.com/ajax/libs/datatables/1.9.4/jquery.dataTables.min.js"></script>' . "\r\t\t" . '<script src="js/datatables/datatables.js"></script>' . "\r\t\t" . '<script type="text/javascript">' . "\r\t\t" . '$(document).ready(function() {' . "\r\t\t\t" . '$(\'.datatable\').dataTable({' . "\r\t\t\t\t" . '"sPaginationType": "bs_four_button"' . "\r\t\t\t" . '});' . "\t\r\t\t\t" . '$(\'.datatable\').each(function(){' . "\r\t\t\t\t" . 'var datatable = $(this);' . "\r\t\t\t\t" . '// SEARCH - Add the placeholder for Search and Turn this into in-line form control' . "\r\t\t\t\t" . 'var search_input = datatable.closest(\'.dataTables_wrapper\').find(\'div[id$=_filter] input\');' . "\r\t\t\t\t" . 'search_input.attr(\'placeholder\', \'Search\');' . "\r\t\t\t\t" . 'search_input.addClass(\'form-control input-sm\');' . "\r\t\t\t\t" . '// LENGTH - Inline-Form control' . "\r\t\t\t\t" . 'var length_sel = datatable.closest(\'.dataTables_wrapper\').find(\'div[id$=_length] select\');' . "\r\t\t\t\t" . 'length_sel.addClass(\'form-control input-sm\');' . "\r\t\t\t" . '});' . "\r\t\t" . '});' . "\r\t\t" . '</script>' . "\r\t\t\t\t\t\t\t" . '</table>' . "\r" . '<script src="http://netdna.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>' . "\r" . '<center>' . "\r\t" . '<div class="pagination-container">' . "\r" . '   <nav>' . "\r" . '    <ul class="pagination pagination-lgn">' . "\r" . '      <li class="page-item" data-page="prev">' . "\r" . '      <a class="page-link" href="#"> < &nbsp;&nbsp;&nbsp; <span class="sr-only ">(current)</span></a>' . "\r" . '      </li>' . "\r" . '      <li class="page-item" data-page="next" id="prev">' . "\r" . '      <a class="page-link" href="#"> &nbsp;&nbsp;&nbsp; > <span class="sr-only">(current)</span></a>' . "\r" . '      </li>' . "\r" . '    </ul>' . "\r" . '  </nav>' . "\r" . '  ' . "\r" . '</div></center>' . "\r\r\t" . '<script type="text/javascript">' . "\r\t\t\t\t\t" . 'getPagination(\'#table-id\');' . "\r\t\t\t\t\t" . '//getPagination(\'.table-class\');' . "\r\t\t\t\t\t" . 'getPagination(\'table\');' . "\r\r\t\t\t\t" . '</script>' . "\r" . '<script>' . "\r" . '$("#search").keyup(function () {' . "\r" . '    var value = this.value.toLowerCase().trim();' . "\r\r" . '    $("table tr").each(function (index) {' . "\r" . '        if (!index) return;' . "\r" . '        $(this).find("td").each(function () {' . "\r" . '            var id = $(this).text().toLowerCase().trim();' . "\r" . '            var not_found = (id.indexOf(value) == -1);' . "\r" . '            $(this).closest(\'tr\').toggle(!not_found);' . "\r" . '            return not_found;' . "\r" . '        });' . "\r" . '    });' . "\r" . '});' . "\r" . '</script>' . "\r" . ' <script>' . "\r" . '$(\'#confirm-delete\').on(\'show.bs.modal\', function(e) {' . "\r" . '    $(this).find(\'.btn-ok\').attr(\'href\', $(e.relatedTarget).data(\'href\'));' . "\r" . '});' . "\r" . '$(\'#confirm-deleteall\').on(\'show.bs.modal\', function(e) {' . "\r" . '    $(this).find(\'.btn-ok\').attr(\'href\', $(e.relatedTarget).data(\'href\'));' . "\r" . '});' . "\r" . '$(\'#confirm-block\').on(\'show.bs.modal\', function(e) {' . "\r" . '    $(this).find(\'.btn-ok\').attr(\'href\', $(e.relatedTarget).data(\'href\'));' . "\r" . '});' . "\r" . '$(\'#confirm-unblock\').on(\'show.bs.modal\', function(e) {' . "\r" . '    $(this).find(\'.btn-ok\').attr(\'href\', $(e.relatedTarget).data(\'href\'));' . "\r" . '});' . "\r\r\r" . '    </script>' . "\r" . '</div>' . "\r" . '</div>' . "\r" . '</div>' . "\r" . '</div>' . "\r" . '</div>' . "\r" . '</div>' . "\r" . '</div>' . "\r";
require 'includes/functions.php';

?>