<?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()
{
}

function qrcode($url, $size)
{
	return 'http://chart.apis.google.com/chart?cht=qr&chl=' . $url . '&chs=' . $size . 'x' . $size . '&chtt=H&choe=UTF-8';
}

$db = new SQLite3('./api/data/.boxbr_info.db');
$db->exec('CREATE TABLE IF NOT EXISTS act(id INTEGER PRIMARY KEY NOT NULL,' . "\r\n\t" . 'title VARCHAR(50),' . "\r\n\t" . 'activecode VARCHAR(50),' . "\r\n\t" . 'macAddress VARCHAR(50),' . "\r\n\t" . 'uid VARCHAR(50),' . "\r\n\t" . 'username VARCHAR(50),' . "\r\n\t" . 'password VARCHAR(50),' . "\r\n\t" . 'url VARCHAR(50),' . "\r\n\t" . 'apptype VARCHAR(50),' . "\r\n\t" . 'appname VARCHAR(50),' . "\r\n\t" . 'status VARCHAR(50))');
$res = $db->query('SELECT * FROM act');

if (isset($_GET['delete'])) {
	$db->exec('DELETE FROM act WHERE id=' . $_GET['delete']);
	header('Location: act.php');
}

include 'includes/header.php';
echo '<div class="modal fade" id="confirm-delete" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">' . "\r\n" . '    <div class="modal-dialog">' . "\r\n" . '        <div class="modal-content">' . "\r\n" . '            <div class="modal-header">' . "\r\n" . '                <h2>Confirm</h2>' . "\r\n" . '            </div>' . "\r\n" . '            <div class="modal-body">' . "\r\n" . '               Do you really want to delete?' . "\r\n" . '            </div>' . "\r\n" . '            <div class="modal-footer">' . "\r\n" . '                <button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>' . "\r\n" . '                <a class="btn btn-danger btn-ok">Delete</a>' . "\r\n" . '            </div>' . "\r\n" . '        </div>' . "\r\n" . '    </div>' . "\r\n" . '</div>' . "\r\n" . ' <script>' . "\r\n" . '$(\'#confirm-delete\').on(\'show.bs.modal\', function(e) {' . "\r\n" . '    $(this).find(\'.btn-ok\').attr(\'href\', $(e.relatedTarget).data(\'href\'));' . "\r\n" . '});' . "\r\n" . '$(\'#confirm-deleteall\').on(\'show.bs.modal\', function(e) {' . "\r\n" . '    $(this).find(\'.btn-ok\').attr(\'href\', $(e.relatedTarget).data(\'href\'));' . "\r\n" . '});' . "\r\n" . '    </script>' . "\r\n" . '<!-- [ Main Content ] start -->' . "\r\n" . '    <div class="pcoded-main-container">' . "\r\n" . '        <div class="pcoded-wrapper">' . "\r\n" . '            <div class="pcoded-content">' . "\r\n" . '                <div class="pcoded-inner-content">' . "\r\n" . '                    <div class="main-body">' . "\r\n" . '                        <div class="page-wrapper">' . "\r\n" . '                            <!-- [ Main Content ] start -->' . "\r\n" . '                            <div class="row">' . "\r\n" . '                    <!-- Column -->' . "\r\n" . '                    <div class="col-lg-12">' . "\r\n" . '                        <div class="card mb-4">' . "\r\n\t\t\t\t\t\t\t" . '<div class="card-header bg-primary py-3">' . "\r\n" . '                ' . "\t\t\t\t" . '<h4 align="center" class="m-0 font-weight-bold text-white"><i class="fas fa-server" style="font-size:20px">&nbsp;&nbsp;</i> ActiveCode Management</h4>' . "\r\n" . '                ' . "\t\t\t" . '</div>' . "\r\n\r\n" . '                         <div class="card-body">' . "\r\n\r\n\t\t\t\t\t\t\t" . ' <br>' . "\r\n\t\t\t\t\t\t\t\t\r\n" . ' <div class="card-body">' . "\r\n" . '<div class="input-group ">' . "\r\n" . '    <div class="input-group-prepend "><a  href="./add_act.php"><button class="btn btn-primary btn-icon-split" name="submit" type="submit"><span class="icon text-white-50"><i class="fa fa-plus"></i></span>&nbsp;&nbsp;<span class="text"> Add A Code</span></button></a>' . "\r\n" . '    ' . "\t\t\t\t\t\t\t\r\n" . '    <span class="input-group-text " style="font-size:24px;color:#1cc88a"><i class="fas fa-search"></i></span></div>' . "\r\n" . '    <input class="form-control" type="text" maxlength="240" id="search" placeholder="Search for: ActiveCode / Name / App / Dns / User / Pass ..."  name="search_value" />' . "\r\n\t" . '<!--' . "\t\t" . 'Show Numbers Of Rows ' . "\t\t" . '-->' . "\r\n\r\n\t\t\t" . ' ' . "\t\t" . '<select class  ="input-group-text" name="state" id="maxRows"  style="width:150px;">' . "\r\n\t\t\t\t\t\t" . ' <option value="5000">Show ALL Rows</option>' . "\r\n\t\t\t\t\t\t" . ' <option value="5">Show 5 Rows</option>' . "\r\n\t\t\t\t\t\t" . ' <option value="10">Show 10 Rows</option>' . "\r\n\t\t\t\t\t\t" . ' <option value="15">Show 15 Rows</option>' . "\r\n\t\t\t\t\t\t" . ' <option value="20">Show 20 Rows</option>' . "\r\n\t\t\t\t\t\t" . ' <option value="50">Show 50 Rows</option>' . "\r\n\t\t\t\t\t\t" . ' <option value="70">Show 70 Rows</option>' . "\r\n\t\t\t\t\t\t" . ' <option value="100">Show 100 Rows</option>' . "\r\n\t\t\t\t\t\t" . '</select>' . "\r\n" . '</div>' . "\r\n" . '                    </div>' . "\r\n\r\n" . '<div class="table-responsive">' . "\r\n" . '<table id="myTable" cellpadding="0" cellspacing="0" border="0" class="table stable-striped table-sm datatable stable-bordered">' . "\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t" . '<thead align="center" class="text-primary table table-striped table-sm ">' . "\r\n\t\t\t\t\t\t\t\t" . '<tr class="text-primary table table-striped table-sm ">' . "\r\n\t\t\t\t\t\t\t\t" . '<th><strong>Service Status/Name/DNS</strong></th>' . "\r\n\t\t\t\t\t\t\t\t" . '<th><strong>Username/Password</strong></th>' . "\r\n\t\t\t\t\t\t\t\t" . '<th><strong>ActiveCode</strong></th>' . "\r\n\t\t\t\t\t\t\t\t" . '<th><strong>MacAddress/UID</strong></th>' . "\r\n\t\t\t\t\t\t\t\t" . '<th><strong>App Name/Type</strong></th>' . "\r\n\t\t\t\t\t\t\t\t" . '<th><strong>Edit</strong></th>' . "\r\n\t\t\t\t\t\t\t\t" . '<th><strong>Delete</strong></th>' . "\r\n\t\t\t\t\t\t\t\t" . '</tr>' . "\r\n\t\t\t\t\t\t\t" . '</thead>' . "\r\n\t\t\t\t\t\t\t";

while ($row = $res->fetchArray()) {
	echo "\t\t\t\t\t\t\t" . '<tbody align="center" class="text-primary table table-striped table-sm ">' . "\r\n\t\t\t\t\t\t\t\t" . '<tr class="text-primary">' . "\r\n\t\t\t\t\t\t\t\t" . '    ';

	if ($row['status'] == '1') {
		$sta = 'Code Activated';
		$sts = '<span class="label label-success" style="font-size:15px;"><i class="fas fa-check" style="font-size:15px;"></i></span>';
		$sts2 = '<span class="label label-success" style="font-size:15px;"><i class="fas fa-serverss" style="font-size:15px;">&nbsp;&nbsp;&nbsp;&nbsp;</i></span>';
	}
	else {
		$sta = 'Code Inactivated';
		$sts = '<span class="label label-danger" style="font-size:15px;"><i class="fas fa-times" style="font-size:15px;"></i></span>';
		$sts2 = '<span class="label label-danger" style="font-size:15px;"><i class="fas fa-serverss" style="font-size:15px;">&nbsp;&nbsp;&nbsp;</i></span>';
	}

	$activeimg = $row['activecode'];
	$imgsize = '300';
	echo "\t\t\t\t\t\t\t\t" . '<td title="';
	echo $sta;
	echo '" style="text-align: left">';
	echo $sts;
	echo '&nbsp;&nbsp;';
	echo $row['title'];
	echo '<br>';
	echo $sts2;
	echo '&nbsp;&nbsp;';
	echo $row['url'];
	echo '</td>' . "\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t" . '<td>User:&nbsp;&nbsp;';
	echo $row['username'];
	echo '<br>Pass:&nbsp;&nbsp;';
	echo $row['password'];
	echo '</td>' . "\r\n\t\t\t\t\t\t\t\t" . '<td title="';
	echo 'QR Code for: ( ' . $row['activecode'] . ' ) - Click me for zoom';
	echo '">' . "\r\n\t\t\t\t\t\t\t\t" . '    ' . "\r\n\t\t\t\t\t\t\t\t" . '    <a href="#" parametro="';
	echo qrcode($row['activecode'], '300');
	echo '" class="abrirModal">' . "\r\n\t\t\t\t\t\t\t\t" . ' <img width="50" height="50" ' . "\r\n\t\t\t\t\t\t\t\t" . ' style="-webkit-user-select: none; max-width:50px;max-height:50px" ' . "\r\n\t\t\t\t\t\t\t\t" . ' src="';
	echo qrcode($activeimg, $imgsize);
	echo '"  ' . "\r\n\t\t\t\t\t\t\t\t" . ' name="';
	echo $row['appname'];
	echo '"' . "\r\n\t\t\t\t\t\t\t\t" . ' code="';
	echo $row['activecode'];
	echo '"' . "\r\n\t\t\t\t\t\t\t\t" . ' link="';
	echo qrcode($row['activecode'], '300');
	echo '">' . "\r\n\t" . '              </a>' . "\r\n\t" . '             <br>';
	echo $row['activecode'];
	echo "\t" . '             ' . "\r\n\t" . '             ' . "\r\n\t" . '             </td>' . "\r\n\t\t\t\t\t\t\t\t" . '<td>';
	echo isset($row['macAddress']) ? 'MAC: ' . $row['macAddress'] : '';
	echo ' <br>' . "\r\n\t\t\t\t\t\t\t\t" . ' ';
	echo isset($row['uid']) ? 'UID: ' . $row['uid'] : '';
	echo ' </td>' . "\r\n\t\t\t\t\t\t\t\t" . '<td>';
	echo $row['appname'];
	echo '<br>' . "\r\n\t\t\t\t\t\t\t\t";
	echo $row['apptype'] == '0' ? 'Dual TV/Vod' : '';
	echo "\t\t\t\t\t\t\t\t\t";
	echo $row['apptype'] == '1' ? 'Only TV' : '';
	echo "\t\t\t\t\t\t\t\t\t" . ' ';
	echo $row['apptype'] == '2' ? 'Only Vod' : '';
	echo "\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t" . '</td>' . "\r\n\t\t\t\t\t\t\t\t" . '<td>' . "\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t" . '<a class="btn btn-success text-white-20" href="./edit_act.php?update=';
	echo $row['id'];
	echo '">' . "\r\n\t\t\t\t\t\t" . '<span style="font-size:15px;" class="icon text-white-10"><i class="fa fa-edit"></i> </span></a>' . "\r\n\t\t\t\t\t\t" . '</td>' . "\t\t\t\t\t" . '<td>' . "\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t" . '<a class="btn btn-danger text-white-20" href="#" data-href="./act.php?delete=';
	echo $row['id'];
	echo '" data-toggle="modal" data-target="#confirm-delete">' . "\r\n\t\t\t\t\t\t" . '<span style="font-size:15px;" class="icon text-white-10"><i class="fa fa-trash"></i> </span></a>' . "\r\n\t\t\t\t\t\t" . '</td>' . "\r\n\t\t\t\t\t\t\t\t" . '</tr>' . "\r\n\t\t\t\t\t\t\t" . '</tbody>' . "\r\n\t\t\t\t\t\t\t";
}

echo "\t\t\t\t\t\t\t" . '<script src="//cdnjs.cloudflare.com/ajax/libs/datatables/1.9.4/jquery.dataTables.min.js"></script>' . "\r\n\t\t" . '<script src="js/datatables/datatables.js"></script>' . "\r\n\t\t" . '<script type="text/javascript">' . "\r\n\t\t" . '$(document).ready(function() {' . "\r\n\t\t\t" . '$(\'.datatable\').dataTable({' . "\r\n\t\t\t\t" . '"sPaginationType": "bs_four_button"' . "\r\n\t\t\t" . '});' . "\t\r\n\t\t\t" . '$(\'.datatable\').each(function(){' . "\r\n\t\t\t\t" . 'var datatable = $(this);' . "\r\n\t\t\t\t" . '// SEARCH - Add the placeholder for Search and Turn this into in-line form control' . "\r\n\t\t\t\t" . 'var search_input = datatable.closest(\'.dataTables_wrapper\').find(\'div[id$=_filter] input\');' . "\r\n\t\t\t\t" . 'search_input.attr(\'placeholder\', \'Search\');' . "\r\n\t\t\t\t" . 'search_input.addClass(\'form-control input-sm\');' . "\r\n\t\t\t\t" . '// LENGTH - Inline-Form control' . "\r\n\t\t\t\t" . 'var length_sel = datatable.closest(\'.dataTables_wrapper\').find(\'div[id$=_length] select\');' . "\r\n\t\t\t\t" . 'length_sel.addClass(\'form-control input-sm\');' . "\r\n\t\t\t" . '});' . "\r\n\t\t" . '});' . "\r\n\t\t" . '</script>' . "\r\n\t\t\t\t\t\t\t" . '</table>' . "\r\n\r\n" . '<script src="http://netdna.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>' . "\r\n" . '<center>' . "\r\n\t" . '<div class="pagination-container">' . "\r\n" . '   <nav>' . "\r\n" . '    <ul class="pagination pagination-lgn">' . "\r\n" . '      <li class="page-item" data-page="prev">' . "\r\n" . '      <a class="page-link" href="#"> < &nbsp;&nbsp;&nbsp; <span class="sr-only ">(current)</span></a>' . "\r\n" . '      </li>' . "\r\n" . '      <li class="page-item" data-page="next" id="prev">' . "\r\n" . '      <a class="page-link" href="#"> &nbsp;&nbsp;&nbsp; > <span class="sr-only">(current)</span></a>' . "\r\n" . '      </li>' . "\r\n" . '    </ul>' . "\r\n" . '  </nav>' . "\r\n" . '  ' . "\r\n" . '</div></center>' . "\r\n\t\t\t\t\t\t" . '</div>' . "\r\n" . '                            </div>' . "\r\n" . '                        </div>' . "\r\n\r\n" . '                    </div>' . "\r\n" . '                    <!-- Column -->' . "\r\n" . '                </div>' . "\r\n\r\n\r\n" . '            </div>' . "\r\n" . '            <!-- ============================================================== -->' . "\r\n" . '            <!-- End Container fluid  -->' . "\r\n" . '            <!-- ============================================================== -->' . "\r\n" . '        </div>' . "\r\n\r\n" . '        <!-- ============================================================== -->' . "\r\n" . '        <!-- End Page wrapper  -->' . "\r\n" . '        <!-- ============================================================== -->' . "\r\n" . '    </div>' . "\r\n" . '<script type="text/javascript"src="//code.jquery.com/jquery-2.1.0.js"></script>' . "\r\n\r\n\r\n\r\n" . ' <!-- Modal -->' . "\r\n" . '<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">' . "\r\n" . '  <div class="modal-dialog" role="document">' . "\r\n" . '    <div class="modal-content">' . "\r\n" . '      <div class="modal-header">' . "\r\n" . '        <h4 class="modal-title" id="myModalLabel">User QR Code Image View</h4>' . "\r\n" . '        <button type="button" class="close btn-danger" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>' . "\r\n" . '      </div>' . "\r\n" . '      <div class="modal-body text-center">' . "\r\n" . '        <img src="" />' . "\r\n" . '        <input class="copy" type="hidden" id="codelink" value="" />' . "\r\n" . '        <input class="copyurl" type="hidden" id="urllink" value="" />' . "\r\n" . '      </div>' . "\r\n" . '      <div class="modal-footer">' . "\r\n" . '          <a href="" target="_blank" class="link1 btn btn-success btn-icon-split"><span class="icon text-white-50"><i class="fa fa-paper-plane"></i></span>&nbsp;&nbsp;<span class="text"> Send to Whatsapp </span></a>' . "\r\n" . '          ' . "\r\n" . '          <button onclick="myFunction()" id="btncopy" class="btncopy btn btn-primary btn-icon-split"><span class="icon text-white-50"><i class="fa fa-copy"></i></span>&nbsp;&nbsp;<span class="text"> Copy QR Code </span></button>' . "\r\n" . '          ' . "\r\n" . '          <button onclick="myFunction2()" id="btncopy2" class="btncopy2 btn btn-warning btn-icon-split"><span class="icon text-white-50"><i class="fa fa-copy"></i></span>&nbsp;&nbsp;<span class="text"> Copy QR Image Link </span></button>' . "\r\n" . '          &nbsp;&nbsp;&nbsp;&nbsp;' . "\r\n" . '          <button class="btn btn-danger btn-icon-split" data-dismiss="modal"><span class="icon text-white-50"><i class="fa fa-times"></i></span>&nbsp;&nbsp;<span class="text"> Close </span></button>' . "\r\n" . '      </div>' . "\r\n" . '    </div>' . "\r\n" . '  </div>' . "\r\n" . '</div>   ' . "\r\n\r\n" . ' ' . "\t" . '<script type="text/javascript">' . "\r\n\t\t\t\t\t" . 'getPagination(\'#table-id\');' . "\r\n\t\t\t\t\t" . '//getPagination(\'.table-class\');' . "\r\n\t\t\t\t\t" . 'getPagination(\'table\');' . "\r\n\r\n\t\t\t\t" . '</script>' . "\r\n" . '<script>' . "\r\n" . '$("#search").keyup(function () {' . "\r\n" . '    var value = this.value.toLowerCase().trim();' . "\r\n\r\n" . '    $("table tr").each(function (index) {' . "\r\n" . '        if (!index) return;' . "\r\n" . '        $(this).find("td").each(function () {' . "\r\n" . '            var id = $(this).text().toLowerCase().trim();' . "\r\n" . '            var not_found = (id.indexOf(value) == -1);' . "\r\n" . '            $(this).closest(\'tr\').toggle(!not_found);' . "\r\n" . '            return not_found;' . "\r\n" . '        });' . "\r\n" . '    });' . "\r\n" . '});' . "\r\n" . '</script>' . "\r\n" . ' <script type="text/javascript">' . "\r\n" . '   $(".abrirModal").click(function() {' . "\r\n\r\n" . '  var url = $(this).find("img").attr("src");' . "\r\n" . '  var url2 = $(this).find("img").attr("link");' . "\r\n" . '  var urln = $(this).find("img").attr("name");' . "\r\n" . '  var urlc = $(this).find("img").attr("code");' . "\r\n" . '  var urlw = \'*Access Data for the APP:* \\n\' + urln  + \' \\n\\n *User Access ActiveCode:* \\n \' +urlc+ \' \\n\\n *QRCode Image Scan:* \\n\' + url2;' . "\r\n" . '  var LinkTextToShare = \'https://api.whatsapp.com/send?phone=&text=\' + encodeURIComponent(urlw) ;' . "\r\n" . '  ' . "\r\n" . '  //alert(url)' . "\r\n" . '  ' . "\r\n" . '  $("#myModal img").attr("src", url);' . "\r\n" . '  $("#myModal a.link1").attr("href", LinkTextToShare);' . "\r\n" . '  $("#myModal a.link2").attr("href", url);' . "\r\n" . '  $("#myModal input.copy").attr("value", url2);' . "\r\n" . '  $("#myModal input.copyurl").attr("value", urlc);' . "\r\n" . '  $("#myModal").modal("show");' . "\r\n" . '});' . "\r\n" . '    </script>' . "\r\n" . '    ' . "\r\n" . '    <script>' . "\r\n" . 'function myFunction() {' . "\r\n\r\n" . ' var copyText = document.getElementById("urllink");' . "\r\n" . ' copyText.value' . "\r\n" . ' ' . "\r\n" . '  $("#myModal input.copyurl").attr("type", "text"); ' . "\r\n" . '  copyText.select();' . "\r\n" . '  document.execCommand("copy");' . "\r\n" . '  //this function copies the text of the input with ID "copy"' . "\r\n\r\n" . '    //alert(copyText.value);' . "\r\n" . '    ' . "\r\n" . '  $("#myModal input.copyurl").attr("type", "hidden");' . "\r\n" . '  ' . "\r\n" . '  text = \'<span class="icon text-white-50"><i class="fa fa-copy"></i></span>&nbsp;&nbsp;<span class="text"> QR Copied OK! </span>\';' . "\r\n" . '  textToChangeBackTo = \'<span class="icon text-white-50"><i class="fa fa-copy"></i></span>&nbsp;&nbsp;<span class="text"> Copy QR Code </span>\';' . "\r\n" . '  ' . "\r\n" . '  document.getElementById("btncopy").innerHTML = text;' . "\r\n" . ' setTimeout(function() { document.getElementById("btncopy").innerHTML = textToChangeBackTo; }, 5000);' . "\r\n\r\n\r\n" . '}' . "\r\n\r\n" . 'function myFunction2() {' . "\r\n\r\n" . ' var copyText = document.getElementById("codelink");' . "\r\n" . ' copyText.value' . "\r\n" . ' ' . "\r\n" . '  $("#myModal input.copy").attr("type", "text"); ' . "\r\n" . '  copyText.select();' . "\r\n" . '  document.execCommand("copy");' . "\r\n" . '  //this function copies the text of the input with ID "copy"' . "\r\n\r\n" . '    //alert(copyText.value);' . "\r\n" . '    ' . "\r\n" . '  $("#myModal input.copy").attr("type", "hidden");' . "\r\n" . '  ' . "\r\n" . '  text = \'<span class="icon text-white-50"><i class="fa fa-copy"></i></span>&nbsp;&nbsp;<span class="text">  QR Image Copied OK! </span>\';' . "\r\n" . '  textToChangeBackTo = \'<span class="icon text-white-50"><i class="fa fa-copy"></i></span>&nbsp;&nbsp;<span class="text"> Copy QR Image Link </span>\';' . "\r\n" . '  ' . "\r\n" . '  document.getElementById("btncopy2").innerHTML = text;' . "\r\n" . ' setTimeout(function() { document.getElementById("btncopy2").innerHTML = textToChangeBackTo; }, 5000);' . "\r\n\r\n\r\n" . '}' . "\r\n" . '    </script>   ' . "\r\n" . '    ' . "\r\n";
include 'includes/functions.php';

?>