<?php
/**
* @ PHP 5.6
* @ Decoder version : 1.0.0.5
* @ Release on : 22.05.2019
* @ Website    : http://EasyToYou.eu
*
* @ Zend guard decoder PHP 5.6
*/

include_once ('./sys/functions.php');
isLogged();
$logged_user = getLoggedUser();
$server_name = getServerProperty('server_name');
$fast_packages = json_decode(getServerProperty('fast_packages'), true);
echo '<!DOCTYPE html>' . "\n" . '<html>' . "\n" . '      <head>' . "\n" . '          <meta charset="utf-8">' . "\n" . '          <meta http-equiv="X-UA-Compatible" content="IE=edge">' . "\n" . '          <title>';
echo $server_name;
echo ' :: Office</title>' . "\n" . '          <!-- Tell the browser to be responsive to screen width -->' . "\n" . '          <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">' . "\n" . '          <!-- Bootstrap 3.3.7 -->' . "\n" . '          <link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.min.css">' . "\n" . '          <!-- DataTables -->' . "\n" . '          <link rel="stylesheet" href="bower_components/datatables.net-bs/css/dataTables.bootstrap.min.css">' . "\n" . '          <!-- Font Awesome -->' . "\n" . '          <link rel="stylesheet" href="bower_components/font-awesome/css/font-awesome.min.css">' . "\n" . '          <!-- Theme style -->' . "\n" . '          <link rel="stylesheet" href="dist/css/AdminLTE.min.css">' . "\n" . '          <!-- AdminLTE Skins. Choose a skin from the css/skins' . "\n" . '               folder instead of downloading all of them to reduce the load. -->' . "\n" . '          <link rel="stylesheet" href="dist/css/skins/_all-skins.min.css">' . "\n" . '          <!-- Morris chart -->' . "\n" . '          <link rel="stylesheet" href="bower_components/morris.js/morris.css">' . "\n" . '          <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->' . "\n" . '          <!-- WARNING: Respond.js doesn\'t work if you view the page via file:// -->' . "\n" . '          <!--[if lt IE 9]>' . "\n" . '          <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>' . "\n" . '          <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>' . "\n" . '          <![endif]-->' . "\n\n" . '          <!-- Google Font -->' . "\n" . '          <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">' . "\n" . '        ';
injectCustomCss();
echo '</head>' . "\n" . '      <body class="hold-transition ';
echo getServerProperty('theme_color', 'skin-red');
echo ' sidebar-mini">' . "\n" . '      <div class="wrapper">' . "\n" . '          <header class="main-header">' . "\n" . '    <!-- Logo -->' . "\n" . '    <a href="dashboard.php" class="logo">' . "\n" . '      <!-- mini logo for sidebar mini 50x50 pixels -->' . "\n" . '      <span class="logo-mini"><img src="dist/img/logo_small.png" width="50" height="50"></span>' . "\n" . '      <!-- logo for regular state and mobile devices -->' . "\n" . '      <span class="logo-lg"><img src="dist/img/logo_medium.png" height="50"></span>' . "\n" . '    </a>' . "\n" . '    <!-- Header Navbar: style can be found in header.less -->' . "\n" . '    <nav class="navbar navbar-static-top">' . "\n" . '      <!-- Sidebar toggle button-->' . "\n" . '      <a href="#" class="sidebar-toggle" data-toggle="push-menu" role="button">' . "\n" . '        <span class="sr-only">Toggle navigation</span>' . "\n" . '      </a>' . "\n\n" . '      <div class="navbar-custom-menu">' . "\n" . '        <ul class="nav navbar-nav">' . "\n" . '          <!-- User Credits -->' . "\n" . '          <li class="dropdown messages-menu">' . "\n" . '            <a href="#" class="dropdown-toggle">' . "\n" . '              <i class="fa fa-dollar"></i>' . "\n" . '              <span class="label label-success">';
echo $logged_user['credits'];
echo '</span>' . "\n" . '            </a>' . "\n" . '          </li>' . "\n" . '          <!-- Control Sidebar Toggle Button -->' . "\n" . '        ';

if (isAdmin($logged_user)) {
	echo '          <li>' . "\n" . '            <a href="settings.php"><i class="fa fa-gears"></i></a>' . "\n" . '          </li>' . "\n" . '        ';
}

echo '        </ul>' . "\n" . '      </div>' . "\n" . '    </nav>' . "\n" . '  </header>' . "\n" . '  <!-- Left side column. contains the logo and sidebar -->' . "\n" . '  <aside class="main-sidebar">' . "\n" . '    <!-- sidebar: style can be found in sidebar.less -->' . "\n" . '    <section class="sidebar">' . "\n" . '      <!-- sidebar menu: : style can be found in sidebar.less -->' . "\n" . '      <ul class="sidebar-menu" data-widget="tree">' . "\n" . '        <li class="header">MENU PRINCIPAL</li>' . "\n" . '        <li>' . "\n" . '          <a href="dashboard.php">' . "\n" . '            <i class="fa fa-dashboard"></i> <span>Painel</span>' . "\n" . '          </a>' . "\n" . '        </li>' . "\n" . '        <li>' . "\n" . '          <a href="informations.php">' . "\n" . '            <i class="fa fa-align-left"></i> <span>Informações</span>' . "\n" . '          </a>' . "\n" . '        </li>' . "\n" . '        <li class="treeview">' . "\n" . '          <a href="#">' . "\n" . '            <i class="fa fa-bug"></i>' . "\n" . '            <span>Criar teste</span>' . "\n" . '            <span class="pull-right-container">' . "\n" . '              <i class="fa fa-angle-left pull-right"></i>' . "\n" . '            </span>' . "\n" . '          </a>' . "\n" . '          <ul class="treeview-menu">' . "\n" . '            <li><a href="create_test.php"><i class="fa fa-circle-o"></i> Customizado</a></li>' . "\n" . '            ';
$packages = getPackages();

foreach ($fast_packages as $package_id) {
	$package_key = array_search($package_id, array_column($packages, 'id'));

	if ($package_key !== false) {
		$current_package = $packages[$package_key];

		if ($current_package['is_trial'] == 1) {
			echo '                    <li><a href="./sys/API.php?action=create_test&package_id=';
			echo $current_package['id'];
			echo '"><i class="fa fa-circle-o"></i> ';
			echo $current_package['package_name'];
			echo '</a></li>' . "\n" . '                    ';
		}
	}
}

echo '          </ul>' . "\n" . '        </li>' . "\n" . '        ';
if (isAdmin($logged_user) || isUltra($logged_user) || isMaster($logged_user)) {
	echo '        <li class="treeview">' . "\n" . '          <a href="#">' . "\n" . '            <i class="fa fa-users"></i>' . "\n" . '            <span>Sub-Revendas</span>' . "\n" . '            <span class="pull-right-container">' . "\n" . '              <i class="fa fa-angle-left pull-right"></i>' . "\n" . '            </span>' . "\n" . '          </a>' . "\n" . '          <ul class="treeview-menu">' . "\n" . '            <li><a href="resellers.php"><i class="fa fa-cogs"></i> Gerir Revendas</a></li>' . "\n" . '            <li><a href="create_reseller.php"><i class="fa fa-user-plus"></i> Criar Revenda</a></li>' . "\n" . '          </ul>' . "\n" . '        </li>' . "\n" . '        ';
}

echo '        <li class="treeview active">' . "\n" . '          <a href="#">' . "\n" . '            <i class="fa fa-users"></i>' . "\n" . '            <span>Usuários</span>' . "\n" . '            <span class="pull-right-container">' . "\n" . '              <i class="fa fa-angle-left pull-right"></i>' . "\n" . '            </span>' . "\n" . '          </a>' . "\n" . '          <ul class="treeview-menu">' . "\n" . '            <li><a href="online.php"><i class="fa fa-circle"></i> Usuários Online</a></li>' . "\n" . '            <li class="active"><a href="clients.php"><i class="fa fa-cogs"></i> Gerir Usuários</a></li>' . "\n" . '            <li><a href="create_client.php"><i class="fa fa-user-plus"></i> Criar Usuário</a></li>' . "\n" . '          </ul>' . "\n" . '        </li>' . "\n" . '        <li>' . "\n" . '          <a href="shortener.php">' . "\n" . '            <i class="fa fa-link"></i> <span>Encurtador</span>' . "\n" . '          </a>' . "\n" . '        </li>' . "\n" . '        <li>' . "\n" . '          <a href="tools.php">' . "\n" . '            <i class="fa fa-wrench"></i> <span>Ferramentas</span>' . "\n" . '          </a>' . "\n" . '        </li>' . "\n" . '        <li class="treeview">' . "\n" . '          <a href="#">' . "\n" . '            <i class="fa fa-film"></i>' . "\n" . '            <span>Conteúdo Novo</span>' . "\n" . '            <span class="pull-right-container">' . "\n" . '              <i class="fa fa-angle-left pull-right"></i>' . "\n" . '            </span>' . "\n" . '          </a>' . "\n" . '          <ul class="treeview-menu">' . "\n" . '            <li><a href="new_channels.php"><i class="fa fa-circle-o"></i> Novos Canais</a></li>' . "\n" . '            <li><a href="new_movies.php"><i class="fa fa-circle-o"></i> Novos Filmes</a></li>' . "\n" . '            <li><a href="new_series.php"><i class="fa fa-circle-o"></i> Novas Series</a></li>' . "\n" . '          </ul>' . "\n" . '        </li>' . "\n" . '        <li class="treeview">' . "\n" . '          <a href="#">' . "\n" . '            <i class="fa fa-ticket"></i>' . "\n" . '            <span>Ticket Suporte</span>' . "\n" . '            <span class="pull-right-container">' . "\n" . '              <i class="fa fa-angle-left pull-right"></i>' . "\n" . '            </span>' . "\n" . '          </a>' . "\n" . '          <ul class="treeview-menu">' . "\n" . '            <li><a href="create_ticket.php"><i class="fa fa-circle-o"></i> Criar Ticket</a></li>' . "\n" . '            <li><a href="manage_tickets.php"><i class="fa fa-circle-o"></i> Gerenciar Tickets</a></li>' . "\n" . '          </ul>' . "\n" . '        </li>' . "\n" . '        <li>' . "\n" . '          <a href="profile.php">' . "\n" . '            <i class="fa fa-user-circle"></i> <span>Perfil</span>' . "\n" . '          </a>' . "\n" . '        </li>' . "\n" . '        <li>' . "\n" . '          <a href="logout.php">' . "\n" . '            <i class="fa fa-power-off"></i> <span>Desconectar</span>' . "\n" . '          </a>' . "\n" . '        </li>' . "\n" . '      </ul>' . "\n" . '    </section>' . "\n" . '    <!-- /.sidebar -->' . "\n" . '  </aside>' . "\n\n" . '  <!-- Content Wrapper. Contains page content -->' . "\n" . '  <div class="content-wrapper">' . "\n" . '    <!-- Content Header (Page header) -->' . "\n" . '    <section class="content-header">' . "\n" . '      <h1>' . "\n" . '        Clientes' . "\n" . '        <small>Gerencie seus clientes com facilidade.</small>' . "\n" . '      </h1>' . "\n" . '      <ol class="breadcrumb">' . "\n" . '        <li><a href="dashboard.php"><i class="fa fa-dashboard"></i> Painel</a></li>' . "\n" . '        <li class="active"><i class="fa fa-users"></i> Usuários</li>' . "\n" . '      </ol>' . "\n" . '    </section>' . "\n" . '    <!-- Main content -->' . "\n" . '    <section class="content">' . "\n" . '      <!-- Main row -->' . "\n" . '      <div class="row">' . "\n" . '        <!-- Left col -->' . "\n" . '        <section class="col-md-12">' . "\n" . '          ';

if (isset($_GET['result'])) {
	$result = $_GET['result'];
	$result_message = 'Aconteceu um problema, tente novamente mais tarde!';
	$result_type = 'warning';

	switch ($result) {
	case 'test_created':
		$result_message = 'O teste rápido foi criado com sucesso.';
		$result_type = 'success';
		break;
	case 'no_min_credits':
		$result_message = 'Você não tem a quantidade minima de créditos para criar o teste rápido.';
		break;
	}

	echo '            <div class="alert alert-';
	echo $result_type;
	echo ' alert-dismissible">' . "\n" . '              <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>' . "\n" . '              <i class="icon fa fa-check"></i>' . "\n" . '              ';
	echo $result_message;
	echo '            </div>' . "\n" . '          ';
}

echo '          <div class="box">' . "\n" . '            <div class="box-body table-responsive">' . "\n" . '              <table id="table" class="table table-bordered table-striped" style="width: 100%!important">' . "\n" . '                <thead>' . "\n" . '                  <tr>' . "\n" . '                    <th>Id</th>' . "\n" . '                    <th>Login</th>' . "\n" . '                    <th>Senha</th>' . "\n" . '                    <th>Adicionado</th>' . "\n" . '                    <th>Vencimento</th>' . "\n" . '                    <th>Revendedor</th>' . "\n" . '                    <th>Conexões</th>' . "\n" . '                    <th>Notas</th>' . "\n" . '                    <th>Status</th>' . "\n" . '                    <th>Ações</th>' . "\n" . '                  </tr>' . "\n" . '                </thead>' . "\n" . '                <tbody>' . "\n" . '                </tbody>' . "\n" . '              </table>' . "\n" . '            </div>' . "\n" . '            <!-- /.box-body -->' . "\n" . '          </div>' . "\n" . '        </section>' . "\n" . '      </div>' . "\n" . '      <!-- /.box -->' . "\n" . '    </section>' . "\n" . '    <!-- /.content -->' . "\n" . '  </div>' . "\n" . '  <!-- /.content-wrapper -->' . "\n" . '  <footer class="main-footer">' . "\n" . '    <div class="row">' . "\n" . '      <div class="text-left col-md-6">' . "\n" . '        <strong>Copyright &copy; ';
echo date('Y');
echo ' <a href="#">';
echo $server_name;
echo '</a>.</strong> All rights reserved.' . "\n" . '      </div>' . "\n" . '      <div class="text-right col-md-6">kOffice Panel. ';
echo KOFFICE_PANEL_VERSION;
echo ' - office-panel.tk</div>' . "\n" . '    </div>' . "\n" . '  </footer>' . "\n" . '  <!-- Add the sidebar\'s background. This div must be placed' . "\n" . '       immediately after the control sidebar -->' . "\n" . '  <div class="control-sidebar-bg"></div>' . "\n" . '</div>' . "\n" . '<!-- ./wrapper -->' . "\n\n" . '<!-- jQuery 3 -->' . "\n" . '<script src="bower_components/jquery/dist/jquery.min.js"></script>' . "\n" . '<!-- jQuery UI 1.11.4 -->' . "\n" . '<script src="bower_components/jquery-ui/jquery-ui.min.js"></script>' . "\n" . '<!-- Resolve conflict in jQuery UI tooltip with Bootstrap tooltip -->' . "\n" . '<script>' . "\n" . '  $.widget.bridge(\'uibutton\', $.ui.button);' . "\n" . '</script>' . "\n" . '<!-- Clipboard -->' . "\n" . '<script src="bower_components/clipboard.min.js"></script>' . "\n" . '<!-- Bootbox -->' . "\n" . '<script src="bower_components/bootbox.min.js"></script>' . "\n" . '<!-- Bootstrap 3.3.7 -->' . "\n" . '<script src="bower_components/bootstrap/dist/js/bootstrap.min.js"></script>' . "\n" . '<!-- Morris.js charts -->' . "\n" . '<script src="bower_components/raphael/raphael.min.js"></script>' . "\n" . '<script src="bower_components/morris.js/morris.min.js"></script>' . "\n" . '<!-- FastClick -->' . "\n" . '<script src="bower_components/fastclick/lib/fastclick.js"></script>' . "\n" . '<!-- DataTables -->' . "\n" . '<script src="bower_components/datatables.net/js/jquery.dataTables.min.js"></script>' . "\n" . '<script src="bower_components/datatables.net-bs/js/dataTables.bootstrap.min.js"></script>' . "\n" . '<!-- AdminLTE App -->' . "\n" . '<script src="dist/js/adminlte.min.js"></script>' . "\n" . '<!-- AdminLTE dashboard demo (This is only for demo purposes) -->' . "\n" . '<script src="dist/js/pages/dashboard.js"></script>' . "\n" . '<!-- AdminLTE for demo purposes -->' . "\n" . '<script src="dist/js/demo.js"></script>' . "\n" . '<script type="text/javascript">' . "\n" . '  $(function () {' . "\n" . '    $(".alert").delay(3000).slideUp(200, function() {' . "\n" . '      $(this).alert(\'close\');' . "\n" . '    });' . "\n\n" . '    var table = $(\'#table\').DataTable({' . "\n" . '      "ajax": "./sys/API.php?action=get_clients",' . "\n" . '      "processing": true,' . "\n" . '      "serverSide": true,' . "\n" . '      "paging": true,' . "\n" . '      "columns": [' . "\n" . '        {"data": "id"},' . "\n" . '        {"data": "display_username"},' . "\n" . '        {"data": "password"},' . "\n" . '        {"data": "created_at"},' . "\n" . '        {"data": "exp_date"},' . "\n" . '        {"data": "reseller_name"},' . "\n" . '        {"data": "max_connections"},' . "\n" . '        {"data": "reseller_notes"},' . "\n" . '        {"data": "status"},' . "\n" . '        {"data": "action"}' . "\n" . '      ],' . "\n" . '      "order": [[ 0, "desc" ]],' . "\n" . '      "paging": true,' . "\n" . '      "lengthChange": true,' . "\n" . '      "searching": true,' . "\n" . '      "ordering": true,' . "\n" . '      "orderMulti": false,' . "\n" . '      "info": true,' . "\n" . '      "autoWidth": false,' . "\n" . '      "language": {' . "\n" . '        "processing": "Processando...",' . "\n" . '        "lengthMenu": "Mostrar _MENU_ registros",' . "\n" . '        "zeroRecords": "Não foram encontrados resultados",' . "\n" . '        "info": "Mostrando de _START_ até _END_ de _TOTAL_ registros",' . "\n" . '        "infoEmpty": "Mostrando de 0 até 0 de 0 registros",' . "\n" . '        "sInfoFiltered": "",' . "\n" . '        "sInfoPostFix": "",' . "\n" . '        "search": "Buscar:",' . "\n" . '        "url": "",' . "\n" . '        "loadingRecords": "Carregando...",' . "\n" . '        "paginate": {' . "\n" . '          "first": "Primeiro",' . "\n" . '          "previous": "Anterior",' . "\n" . '          "next": "Seguinte",' . "\n" . '          "last": "Último"' . "\n" . '        }' . "\n" . '      }, "drawCallback": function () {' . "\n" . '        $(\'[data-toggle="tooltip"]\').tooltip();' . "\n" . '      }, "createdRow": function (row, data) {' . "\n" . '        if (data[\'status\'].includes(\'Expirado\')) {' . "\n" . '          $(row).addClass(\'text-red\');' . "\n" . '        }' . "\n" . '      }' . "\n" . '    });' . "\n\n" . '    /* ADICIONAR TELA */' . "\n" . '    $(document).on(\'click\', \'.bttela\', function(e){ ' . "\n" . '      e.preventDefault();' . "\n" . '      const id = $(this).data("id");' . "\n\n" . '      bootbox.dialog({' . "\n" . '          title: "Tem certeza que deseja adicionar mais uma tela ?",' . "\n" . '          message: "<p>" + $(this).data("text") + "</p>",' . "\n" . '          buttons: {' . "\n" . '              cancel: {' . "\n" . '                  label: "Cancelar",' . "\n" . '                  className: \'btn-danger\',' . "\n" . '                  callback: function() {}' . "\n" . '              },' . "\n" . '              noclose: {' . "\n" . '                  label: "Confirmar",' . "\n" . '                  className: \'btn-success btnaddscreen\',' . "\n" . '                  callback: function() {' . "\n" . '                    $(\'.btnaddscreen\').hide();' . "\n" . '                    ' . "\n" . '                    $.get(\'./sys/API.php?action=add_screen&client_id=\'+id, function( data ) {' . "\n" . '                      if(data.result === \'success\'){' . "\n" . '                        table.ajax.reload();' . "\n" . '                        alert(\'Máximo de conexões aumentada com sucesso!\');' . "\n" . '                      } else {' . "\n" . '                        alert(\'Não foi possível aumentar o máximo de conexões do cliente.\');' . "\n" . '                      }' . "\n" . '                    }, "json");' . "\n" . '                  }' . "\n" . '              },' . "\n" . '          }' . "\n" . '      });' . "\n" . '    });' . "\n\n" . '    /* RENOVAR CLIENTE */' . "\n" . '    $(document).on(\'click\', \'.btrenew\', function(e){ ' . "\n" . '      e.preventDefault();' . "\n" . '      const id = $(this).data("id");' . "\n\n" . '      bootbox.dialog({' . "\n" . '          title: "Tem certeza que deseja renovar este cliente ?",' . "\n" . '          message: "<p>" + $(this).data("text") + "</p>",' . "\n" . '          buttons: {' . "\n" . '              cancel: {' . "\n" . '                  label: "Cancelar",' . "\n" . '                  className: \'btn-danger\',' . "\n" . '                  callback: function() {}' . "\n" . '              },' . "\n" . '              noclose: {' . "\n" . '                  label: "Confirmar",' . "\n" . '                  className: \'btn-success btnrenew\',' . "\n" . '                  callback: function() {' . "\n" . '                    $(\'.btnrenew\').hide();' . "\n" . '                    ' . "\n" . '                    $.get(\'./sys/API.php?action=renew_client&client_id=\'+id, function( data ) {' . "\n" . '                      if(data.result === \'success\'){' . "\n" . '                        table.ajax.reload();' . "\n" . '                        alert(\'Cliente renovado com sucesso!\');' . "\n" . '                      } else {' . "\n" . '                        alert(\'Não foi possível renovar o cliente.\');' . "\n" . '                      }' . "\n" . '                    }, "json");' . "\n" . '                  }' . "\n" . '              },' . "\n" . '          }' . "\n" . '      });' . "\n" . '    });' . "\n\n" . '    /* RENOVAR VARIOS MESES CLIENTE */' . "\n" . '    $(document).on(\'click\', \'.btrenewplus\', function(e){ ' . "\n" . '      e.preventDefault();' . "\n" . '      const id = $(this).data("id");' . "\n\n" . '      bootbox.dialog({' . "\n" . '          title: "Tem certeza que deseja renovar este cliente ?",' . "\n" . '          message: \'<p>\'+$(this).data("text")+\'</p><form class="form-horizontal">\' + \'<div class="form-group col-md-6"><label class="form-control-label">Quantidade de meses</label><div class="input-group"><span class="input-group-addon"><i class="fa fa-calendar-plus-o"></i></span><input type="number" class="form-control" required="" value="0" autocomplete="off" id="months" name="months"></div></div>\' + \'<div class="form-group row">\' + \'<div class="col-md-12"><span class="text-blue">Escolha a quantidade de meses.<br><b>*Fique atento, caso seja um usuario de 2 telas irá cobrar o dobro de créditos equivalente a quantidade de meses.</b></span></div>\' + \'</div></form>\',' . "\n" . '          buttons: {' . "\n" . '              cancel: {' . "\n" . '                  label: "Cancelar",' . "\n" . '                  className: \'btn-danger\',' . "\n" . '                  callback: function() {}' . "\n" . '              },' . "\n" . '              noclose: {' . "\n" . '                  label: "Confirmar",' . "\n" . '                  className: \'btn-success btnrenewplus\',' . "\n" . '                  callback: function() {' . "\n" . '                    $(\'.btnrenewplus\').hide();' . "\n\n" . '                    const months = $(\'#months\').val();' . "\n" . '                    if(months > 0){' . "\n" . '                      $.get(\'./sys/API.php?action=renew_client_plus&client_id=\' + id + \'&months=\' + months, function (data) {' . "\n" . '                          if (data.result === \'success\') {' . "\n" . '                            table.ajax.reload();' . "\n" . '                            alert(\'Cliente renovado com sucesso!\');' . "\n" . '                          } else {' . "\n" . '                            alert(\'Não foi possível renovar o cliente.\');' . "\n" . '                          }' . "\n" . '                      }, "json");' . "\n" . '                    }' . "\n" . '                    else {' . "\n" . '                      alert(\'Quantidade de meses invalido.\');' . "\n" . '                    }' . "\n" . '                  }' . "\n" . '              },' . "\n" . '          }' . "\n" . '      });' . "\n" . '    });' . "\n\n" . '    /* BLOQUEAR/DESBLOQUEAR */' . "\n" . '    $(document).on(\'click\', \'.btblock\', function (e) {' . "\n" . '        e.preventDefault();' . "\n" . '        const id = $(this).data("id");' . "\n" . '        bootbox.dialog({' . "\n" . '            title: "Tem certeza que deseja bloquear/desbloquear este usuário ?",' . "\n" . '            message: "<p>" + $(this).data("text") + "</p>",' . "\n" . '            buttons: {' . "\n" . '                cancel: {' . "\n" . '                    label: "Cancelar",' . "\n" . '                    className: \'btn-danger\',' . "\n" . '                    callback: function () {' . "\n" . '                    }' . "\n" . '                },' . "\n" . '                noclose: {' . "\n" . '                    label: "Confirmar",' . "\n" . '                    className: \'btn-success btnblock\',' . "\n" . '                    callback: function () {' . "\n" . '                        $(\'.btnblock\').hide();' . "\n" . '                        $.get(\'./sys/API.php?action=toggle_block_client&user_id=\' + id, function (data) {' . "\n" . '                            if (data.result === \'success\') {' . "\n" . '                                table.ajax.reload();' . "\n" . '                                alert(\'Usuário bloqueado/desbloqueado com sucesso!\');' . "\n" . '                            } else {' . "\n" . '                                alert(\'Não foi possível bloquear/desbloquear este usuário.\');' . "\n" . '                            }' . "\n" . '                        }, "json");' . "\n" . '                    }' . "\n" . '                },' . "\n" . '            }' . "\n" . '        });' . "\n" . '    });' . "\n\n" . '    /* DELETAR */' . "\n" . '    $(document).on(\'click\', \'.btdelete\', function (e) {' . "\n" . '        e.preventDefault();' . "\n" . '        const id = $(this).data("id");' . "\n" . '        bootbox.dialog({' . "\n" . '            title: "Tem certeza que deseja deletar este usuário ?",' . "\n" . '            message: "<p>" + $(this).data("text") + "</p>",' . "\n" . '            buttons: {' . "\n" . '                cancel: {' . "\n" . '                    label: "Cancelar",' . "\n" . '                    className: \'btn-danger\',' . "\n" . '                    callback: function () {' . "\n" . '                    }' . "\n" . '                },' . "\n" . '                noclose: {' . "\n" . '                    label: "Confirmar",' . "\n" . '                    className: \'btn-success btndelete\',' . "\n" . '                    callback: function () {' . "\n" . '                        $(\'.btndelete\').hide();' . "\n" . '                        $.get(\'./sys/API.php?action=delete_client&user_id=\' + id, function (data) {' . "\n" . '                            if (data.result === \'success\') {' . "\n" . '                                table.ajax.reload();' . "\n" . '                                alert(\'Usuário deletado com sucesso!\');' . "\n" . '                            } else {' . "\n" . '                                alert(\'Não foi possível deletar este usuário.\');' . "\n" . '                            }' . "\n" . '                        }, "json");' . "\n" . '                    }' . "\n" . '                },' . "\n" . '            }' . "\n" . '        });' . "\n" . '    });' . "\n\n" . '    const server_dns = "';
echo getServerDNS();
echo '";' . "\n" . '    const shortener_url = "';
echo SHORTENER_URL;
echo '";' . "\n" . '    const reseller_id = "';
echo $logged_user['id'];
echo '";' . "\n\n" . '    /* GERAR LINK */' . "\n" . '    $(document).on(\'click\', \'.btlink\', function(e){' . "\n" . '      e.preventDefault();' . "\n" . '      //var id = $(this).data("id");' . "\n" . '      const user = $(this).data("user");' . "\n" . '      const pass = $(this).data("pass");' . "\n\n" . '      const mpegts_link = server_dns + "/get.php?username=" + user + "&password=" + pass + "&type=m3u_plus&output=ts";' . "\n" . '      const hls_link = server_dns + "/get.php?username=" + user + "&password=" + pass + "&type=m3u_plus&output=m3u8";' . "\n\n" . '      bootbox.dialog({' . "\n" . '        size: \'large\',' . "\n" . '        title: "Encurtar Link",' . "\n" . '        message: "<p><strong>Link original (MPEGTS)</strong><br/> " + mpegts_link + "</p>" +' . "\n" . '                 "<p><strong>Link original (HLS)</strong> <i>ideal para roku, chromecast</i><br/> " + hls_link + "</p>",' . "\n" . '        buttons: {' . "\n" . '          noclose: {' . "\n" . '            label: "Encurtar (MPEGTS)",' . "\n" . '            className: \'btn-success btm3u\',' . "\n" . '            callback: function() {' . "\n" . '              $(".btm3u").hide();' . "\n" . '              $.get(shortener_url, {url: mpegts_link, creator_id: reseller_id, format: \'text\'}, function( data ) {' . "\n" . '                $(\'<div class="links mpegts"><strong class="text-red">Link lista (MPEGTS):</strong><br/>\' +' . "\n" . '                  \'<div class="form-group"><div class="input-group"><input type="text" class="form-control" value="\'+data+\'" id="copy_mpegts_content"><div class="input-group-btn"><button type="button" class="btn btn-danger" id="copy_mpegts_link" data-clipboard-target="#copy_mpegts_content">COPIAR LINK</button></div></div></div></div>\').appendTo(\'.bootbox-body\');' . "\n" . '                new ClipboardJS(\'#copy_mpegts_link\');' . "\n" . '              });' . "\n" . '              return false;' . "\n" . '            }' . "\n" . '          },' . "\n" . '          noclose2: {' . "\n" . '            label: "Encurtar (HLS)",' . "\n" . '            className: \'btn-success bthls\',' . "\n" . '            callback: function() {' . "\n" . '              $(".bthls").hide();' . "\n" . '              $.get(shortener_url, {url: hls_link, creator_id: reseller_id, format: \'text\'}, function( data ) {' . "\n" . '                $(\'<div class="links hls"><strong class="text-aqua">Link lista (HLS):</strong><br/>\' +' . "\n" . '                  \'<div class="form-group"><div class="input-group"><input type="text" class="form-control" value="\'+data+\'" id="copy_hls_content"><div class="input-group-btn"><button type="button" class="btn btn-info" id="copy_hls_link" data-clipboard-target="#copy_hls_content">COPIAR LINK</button></div></div></div></div>\').appendTo(\'.bootbox-body\');' . "\n" . '                new ClipboardJS(\'#copy_hls_link\');' . "\n" . '              });' . "\n" . '              return false;' . "\n" . '            }' . "\n" . '          },' . "\n" . '          cancel: {' . "\n" . '            label: "Fechar",' . "\n" . '            className: \'btn-danger\',' . "\n" . '            callback: function () {}' . "\n" . '          }' . "\n" . '        }' . "\n" . '      });' . "\n" . '    });' . "\n" . '  });' . "\n" . '</script>' . "\n" . '</body>' . "\n" . '</html>' . "\n";

?> 
