<?php
require_once("inc/protecao-revenda.php");

?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
        <title>[<?php echo $dados_revenda["id"]; ?>] Revenda - Reseller</title>
  <link rel="stylesheet" href="/inc/materialdesignicons.min.css">
  <link rel="stylesheet" href="/inc/font-awesome.min.css">
  <link rel="stylesheet" href="/inc/vendor.bundle.base.css">
  <link rel="stylesheet" href="/inc/vendor.bundle.addons.css">  
  <?php if($dados_revenda["tema_dark"] == "sim") { ?>
  <link rel="stylesheet" href="/inc/theme-dark.css">
  <?php } else { ?>
  <?php if($dados_revenda["tema_dark"] == "sim") { ?>
  <link rel="stylesheet" href="/inc/theme-dark.css">
  <?php } else { ?>
  <link rel="stylesheet" href="/inc/theme.css">
  <?php } ?>
  <?php } ?>
  <link rel="shortcut icon" href="/img/favicon.ico" />
  <script type="text/javascript" src="/admin/inc/ajax-revenda.js"></script>
  <script type="text/javascript" src="/admin/inc/javascript.js"></script>
</head>
<body>
  <div class="container-scroller">
    <nav class="navbar col-lg-12 col-12 p-0 fixed-top d-flex flex-row">
      <div class="text-center navbar-brand-wrapper d-flex align-items-center justify-content-center">
        <?php if($dados_revenda["url_logo"]) { ?>
        <a class="navbar-brand brand-logo" href="/admin/revenda"><img id="logo" src="<?php echo $dados_revenda["url_logo"]; ?>" title="Painel" height="60" border="0"></a>
        <?php } else { ?>
        <a class="navbar-brand brand-logo" href="/admin/revenda"><span>Painel Revenda</span></a>
        <?php } ?>
        <a class="navbar-brand brand-logo-mini" href="/admin/revenda"><i class="fa fa-video-camera text-muted"></i></a>
      </div>
      <div class="navbar-menu-wrapper d-flex align-items-center justify-content-end justify-content-lg-start">
        <button class="navbar-toggler navbar-toggler align-self-center" type="button" data-toggle="minimize">
          <span class="mdi mdi-menu text-icones"></span>
        </button>
        <ul class="navbar-nav mr-lg-2">
          <li class="nav-item nav-search d-none d-lg-block">
            <div class="input-group">
              <div class="input-group-prepend">
                <span class="input-group-text" id="search">
                  <i class="mdi mdi-magnify"></i>
                </span>
              </div>
              <input type="text" class="form-control" id="busca_chave" placeholder="Busca" aria-label="search" aria-describedby="search">
            </div>
          </li>
        </ul>
        <ul class="navbar-nav navbar-nav-right">
          <li class="nav-item dropdown">
            <a class="nav-link count-indicator dropdown-toggle" id="notificationDropdown" href="#" data-toggle="dropdown">
              <i class="mdi mdi-bell-outline mx-0"></i>
              <span class="count"></span>            
            </a>
            <div class="dropdown-menu dropdown-menu-right navbar-dropdown preview-list" aria-labelledby="notificationDropdown" style="min-width: 300px">
              <a class="dropdown-item">
                <p class="mb-0 font-weight-normal float-left"><?php echo lang_info_pagina_informacoes_revenda_tab_avisos; ?></p>
              </a>
              <div class="dropdown-divider"></div>
              <?php carregar_avisos_revenda($conexao); ?>
            </div>
          </li>
          <li class="nav-item">
            <a class="nav-link" href="/admin/sair"><i class="mdi mdi-logout f-22 text-icones" data-toggle="tooltip" data-placement="bottom" title="Sair/logout"></i></a>
          </li>
        </ul>
        <button class="navbar-toggler navbar-toggler-right d-lg-none align-self-center" type="button" data-toggle="offcanvas">
          <span class="mdi mdi-menu text-icones"></span>
        </button>
      </div>
    </nav>
    <div class="container-fluid page-body-wrapper">
      <nav class="sidebar sidebar-offcanvas" id="sidebar">
        <ul class="nav">
          <li class="nav-item">
            <a class="nav-link" href="/admin/revenda">
              <i class="fa fa-home text-icones"></i>
              <span class="menu-title">Dashboard</span>
            </a>
          </li>
          <li class="nav-item">
            <a class="nav-link" href="/admin/revenda-streamings">
              <i class="fa fa-video-camera text-icones"></i>
              <span class="menu-title"><?php echo lang_menu_streaming; ?></span>
            </a>
          </li>
          <?php if($dados_revenda["subrevendas"] > 0 && ($dados_revenda["tipo"] == 1 || $dados_revenda["tipo"] == 2)) { ?>
          <li class="nav-item">
            <a class="nav-link" href="/admin/revenda-subrevendas">
              <i class="fa fa-users text-icones"></i>
              <span class="menu-title"><?php echo lang_menu_subrevenda; ?></span>
            </a>
          </li>
          <?php } ?>
          <li class="nav-item">
            <a class="nav-link" href="/admin/revenda-busca-avancada">
              <i class="fa fa-search text-icones"></i>
              <span class="menu-title"><?php echo lang_menu_busca_avancada; ?></span>
            </a>
          </li>
          <li class="nav-item">
            <a class="nav-link" data-toggle="collapse" href="#integracao" aria-expanded="false" aria-controls="integracao">
              <i class="fa fa-tasks text-icones"></i>
              <span class="menu-title"><?php echo lang_menu_integracao; ?></span>
              <i class="menu-arrow"></i>
            </a>
            <div class="collapse" id="integracao">
              <ul class="nav flex-column sub-menu">
                <li class="nav-item"> <a class="nav-link" href="/admin/revenda-api"> <?php echo lang_menu_integracao_api; ?></a></li>
                <li class="nav-item"> <a class="nav-link" href="/admin/revenda-modulo-whmcs"> <?php echo lang_menu_integracao_modulo_whmcs; ?></a></li>
              </ul>
            </div>
          </li>
          <li class="nav-item">
            <a class="nav-link" href="/admin/revenda-configuracoes">
              <i class="fa fa-cog text-icones"></i>
              <span class="menu-title"><?php echo lang_menu_configuracoes; ?></span>
            </a>
          </li>   
        </ul>
        </ul>
      </nav>
      <!-- partial -->
      <div class="main-panel">
        <div class="content-wrapper">
          <div id="local-status-acoes"><?php echo $_SESSION['status_acao'];unset($_SESSION['status_acao']); ?></div>
          <div class="row">            

            <div class="col-lg-12">
              <div class="card">
                  <div class="card-header">
                    <header><?php echo lang_info_pagina_api_tab_titulo; ?></header>
                  </div>
                <div class="card-body">
                    <?php echo lang_info_pagina_api_info; ?><br /><br />
<input type="text" value="<?php echo $dados_revenda["chave_api"]; ?>" style="width:100%; height:30px;"  onclick="this.select()" readonly="readonly" /><br />
<br /> 
<?php echo lang_info_pagina_api_info2; ?>
<br />
<br />
<span class="texto_padrao_destaque"><?php echo lang_info_pagina_api_acao_cadastrar; ?></span><br />
<br />
<textarea readonly="readonly" style="width:100%; height:700px;"  onclick="this.select()">
// Funcao para cadastrar um streaming
// Function to create a streaming
// f para agregar uno streaming
function cadastrar_streaming($chave,$espectadores,$bitrate,$espaco,$senha,$idioma_painel) {

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://<?php echo $_SERVER['HTTP_HOST']; ?>/admin/api/".$chave."/cadastrar/".$espectadores."/".$bitrate."/".$espaco."/".$senha."/".$idioma_painel."");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2);
curl_setopt($ch, CURLOPT_TIMEOUT, 2);
curl_setopt($ch, CURLOPT_USERAGENT, "API 1.0 (<?php echo $_SERVER['HTTP_HOST']; ?>)");
$resultado = curl_exec($ch);
curl_close($ch);

if($resultado === false) {
return "<?php echo lang_info_pagina_api_acao_info_erro; ?>";
} else {

list($status,$login,$msg) = explode("|",$resultado);

if($status == 1) {
//Sucesso
return $login;
} else {
//Erro
return $msg;
}

}

}

// Formato: chave / espectadores / bitrate(numero apenas) / espaço autodj(megabytes) / senha / Idioma (pt-br / en / es)
echo cadastrar_streaming("<?php echo $dados_revenda["chave_api"]; ?>","100","256","1000","xxxxxx","pt-br");</textarea>
<br />
<br />
<span class="texto_padrao_destaque"><?php echo lang_info_pagina_api_acao_bloquear; ?></span><br />
<br />
<textarea readonly="readonly" style="width:100%; height:650px"  onclick="this.select()">
// Funcao para bloquear o streaming
// Function to suspend the streaming
// Funcion para bloquear el streaming
function bloquear_streaming($chave,$login) {

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://<?php echo $_SERVER['HTTP_HOST']; ?>/admin/api/".$chave."/bloquear/".$login."");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2);
curl_setopt($ch, CURLOPT_TIMEOUT, 2);
curl_setopt($ch, CURLOPT_USERAGENT, "API 1.0 (<?php echo $_SERVER['HTTP_HOST']; ?>)");
$resultado = curl_exec($ch);
curl_close($ch);

if($resultado === false) {
return "<?php echo lang_info_pagina_api_acao_info_erro; ?>";
} else {

list($status,$login,$msg) = explode("|",$resultado);

if($status == 1) {
//Sucesso
return $msg;
} else {
//Erro
return $msg;
}

}

}

// Formato: chave / login
echo bloquear_streaming("<?php echo $dados_revenda["chave_api"]; ?>","LOGIN");</textarea>
<br />
<br />
<span class="texto_padrao_destaque"><?php echo lang_info_pagina_api_acao_debloquear; ?></span><br />
<br />
<textarea readonly="readonly" style="width:100%; height:650px"  onclick="this.select()">
// Funcao para desbloquear o streaming
// Function to unsuspend the streaming
// Funcion para desbloquear el streaming
function desbloquear_streaming($chave,$login) {

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://<?php echo $_SERVER['HTTP_HOST']; ?>/admin/api/".$chave."/desbloquear/".$login."");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2);
curl_setopt($ch, CURLOPT_TIMEOUT, 2);
curl_setopt($ch, CURLOPT_USERAGENT, "API 1.0 (<?php echo $_SERVER['HTTP_HOST']; ?>)");
$resultado = curl_exec($ch);
curl_close($ch);

if($resultado === false) {
return "<?php echo lang_info_pagina_api_acao_info_erro; ?>";
} else {

list($status,$login,$msg) = explode("|",$resultado);

if($status == 1) {
//Sucesso
return $msg;
} else {
//Erro
return $msg;
}

}

}

// Formato: chave / login
echo desbloquear_streaming("<?php echo $dados_revenda["chave_api"]; ?>","LOGIN");</textarea>
<br />
<br />
<span class="texto_padrao_destaque"><?php echo lang_info_pagina_api_acao_alterar_senha; ?></span><br />
<br />
<textarea readonly="readonly" style="width:100%; height:650px"  onclick="this.select()">
// Funcao para alterar senha do streaming
// Function to change password of streaming
// Funcion para cambiar la contraseña de streaming
function alterar_senha($chave,$login,$senha) {

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://<?php echo $_SERVER['HTTP_HOST']; ?>/admin/api/".$chave."/alterar_senha/".$login."/".$senha."");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2);
curl_setopt($ch, CURLOPT_TIMEOUT, 2);
curl_setopt($ch, CURLOPT_USERAGENT, "API 1.0 (<?php echo $_SERVER['HTTP_HOST']; ?>)");
$resultado = curl_exec($ch);
curl_close($ch);

if($resultado === false) {
return "<?php echo lang_info_pagina_api_acao_info_erro; ?>";
} else {

list($status,$login,$msg) = explode("|",$resultado);

if($status == 1) {
//Sucesso
return $msg;
} else {
//Erro
return $msg;
}

}

}

// Formato: chave / login / nova senha
echo alterar_senha("<?php echo $dados_revenda["chave_api"]; ?>","LOGIN","xxxx");</textarea>
<br />
<br />
<span class="texto_padrao_destaque"><?php echo lang_info_pagina_api_acao_remover; ?></span><br />
<br />
<textarea readonly="readonly" style="width:100%; height:650px"  onclick="this.select()">
// Funcao para remover o streaming
// Function to remove the streaming
// Funcion para eliminar el streaming
function remover_streaming($chave,$login) {

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://<?php echo $_SERVER['HTTP_HOST']; ?>/admin/api/".$chave."/remover/".$login."");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2);
curl_setopt($ch, CURLOPT_TIMEOUT, 2);
curl_setopt($ch, CURLOPT_USERAGENT, "API 1.0 (<?php echo $_SERVER['HTTP_HOST']; ?>)");
$resultado = curl_exec($ch);
curl_close($ch);

if($resultado === false) {
return "<?php echo lang_info_pagina_api_acao_info_erro; ?>";
} else {

list($status,$login,$msg) = explode("|",$resultado);

if($status == 1) {
//Sucesso
return $msg;
} else {
//Erro
return $msg;
}

}

}

// Formato: chave / login
echo remover_streaming("<?php echo $dados_revenda["chave_api"]; ?>","LOGIN");</textarea>
                </div>
              </div>
            </div>

          </div>
        </div>
      </div>
      <!-- modal -->
      <div class="modal fade" id="avisos" tabindex="-1" role="dialog" aria-hidden="true">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title"><?php echo $lang['lang_info_pagina_informacoes_tab_avisos']; ?></h5>
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                </div>
                <div class="modal-body" id="avisos-conteudo"><img src="/img/ajax-loader.gif" align="center" /></div>
            </div>
        </div>
        </div>
                
        <div class="modal fade" id="log-sistema" tabindex="-1" role="dialog" aria-hidden="true">
        <div class="modal-dialog modal-dialog-centered" role="document">
            <div class="modal-content">
                <div class="modal-body" id="log-sistema-conteudo" style="text-align:center"><img src="/img/ajax-loader.gif" /></div>
            </div>
        </div>
      </div>
    </div>
  </div>
  <script src="/inc/vendor.bundle.base.js"></script>
  <script src="/inc/vendor.bundle.addons.js"></script>
  <script src="/inc/theme.js"></script>
  <script>
  $('#busca_chave').keypress(function (e) {
    if (e.which == 13) {
       window.location = "/admin/revenda-streamings/resultado/porta/"+document.getElementById("busca_chave").value;
    }
  }); 
  </script>
</body>
</html>