<?php
require_once("inc/protecao-admin.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>Administra&ccedil;&atilde;o</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">  
  <link rel="stylesheet" href="/inc/theme.css">
  <link rel="shortcut icon" href="/img/favicon.ico" />
  <script type="text/javascript" src="/admin/inc/ajax.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">
        <a class="navbar-brand brand-logo" href="/dashboard"><span>Administra&ccedil;&atilde;o</span></a>
        <a class="navbar-brand brand-logo-mini" href="/dashboard"><i class="fa fa-lock text-yellow"></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">
            <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/admin-streamings">
              <i class="fa fa-headphones text-icones"></i>
              <span class="menu-title"><?php echo lang_menu_streaming; ?></span>
            </a>
          </li>
          <li class="nav-item">
            <a class="nav-link" href="/admin/admin-revendas">
              <i class="fa fa-users text-icones"></i>
              <span class="menu-title"><?php echo lang_menu_revenda; ?></span>
            </a>
          </li>
          <li class="nav-item">
            <a class="nav-link" href="/admin/admin-servidores">
              <i class="fa fa-tasks text-icones"></i>
              <span class="menu-title"><?php echo lang_menu_servidor; ?></span>
            </a>
          </li>
          <li class="nav-item">
            <a class="nav-link" href="/admin/admin-avisos">
              <i class="fa fa-info-circle text-icones"></i>
              <span class="menu-title"><?php echo lang_menu_avisos; ?></span>
            </a>
          </li>
          <li class="nav-item">
            <a class="nav-link" href="/admin/admin-tutoriais">
              <i class="fa fa-life-bouy text-icones"></i>
              <span class="menu-title"><?php echo lang_menu_tutoriais; ?></span>
            </a>
          </li>
          <li class="nav-item">
            <a class="nav-link" href="/admin/admin-apps">
              <i class="fa fa-android text-icones"></i>
              <span class="menu-title"><?php echo lang_menu_apps; ?></span>
            </a>
          </li>
          <li class="nav-item">
            <a class="nav-link" href="/admin/admin-logs-acoes">
              <i class="fa fa-file-text-o text-icones"></i>
              <span class="menu-title"><?php echo lang_menu_logs_acoes; ?></span>
            </a>
          </li>
          <li class="nav-item">
            <a class="nav-link" href="/admin/admin-backup">
              <i class="fa fa-shield text-icones"></i>
              <span class="menu-title">Backup</span>
            </a>
          </li>    
          <li class="nav-item">
            <a class="nav-link" href="/admin/admin-estatisticas">
              <i class="fa fa-bar-chart-o text-icones"></i>
              <span class="menu-title"><?php echo lang_menu_estatisticas; ?></span>
            </a>
          </li>
          <li class="nav-item">
            <a class="nav-link" href="/admin/admin-configuracoes">
              <i class="fa fa-cog text-icones"></i>
              <span class="menu-title"><?php echo lang_menu_configuracoes; ?></span>
            </a>
          </li>   
        </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_cadastrar_streaming_titulo; ?></header>
                  </div>
                <div class="card-body">
                    <form method="post" action="/admin/admin-cadastra-streaming" name="cadastrar">
                                        <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
                                          <tr>
                                            <td width="150" height="50" align="left" style="padding-left:5px;"><strong><?php echo lang_info_pagina_cadastrar_streaming_servidor; ?></strong></td>
                                            <td align="left">
                                            <select name="servidor" class="form-control" id="servidor" style="width:100%;">
                                    <?php

                                    $query_servidor = mysqli_query($conexao,"SELECT * FROM servidores ORDER by codigo ASC");
                                    while ($dados_servidor = mysqli_fetch_array($query_servidor)) {

                                    $total_streamings = mysqli_num_rows(mysqli_query($conexao,"SELECT * FROM streamings where codigo_servidor = '".$dados_servidor["codigo"]."'"));

                                    if($dados_config["codigo_servidor_atual"] == $dados_servidor["codigo"]) {
                                    echo '<option value="'.$dados_servidor["codigo"].'" selected="selected">'.$dados_servidor["nome"].' - '.$dados_servidor["ip"].' ('.$total_streamings.')</option>';
                                    } else {
                                    echo '<option value="'.$dados_servidor["codigo"].'">'.$dados_servidor["nome"].' - '.$dados_servidor["ip"].' ('.$total_streamings.')</option>';
                                    }

                                    }
                                    ?>
                                            </select>        </td>
                                          </tr>
                                          <tr>
                                            <td align="left" style="padding-left:5px;"><strong><?php echo lang_info_pagina_cadastrar_streaming_login; ?></strong></td>
                                            <td align="left"><input name="login" type="text" class="form-control" id="login" style="width:100%;" value="" /></td>
                                          </tr>
                                          <tr>
                                            <td height="50" align="left" style="padding-left:5px;"><strong><?php echo lang_info_pagina_cadastrar_streaming_espectadores; ?></strong></td>
                                            <td align="left"><input name="espectadores" type="text" class="form-control" id="espectadores" style="width:100%;" value="" /></td>
                                          </tr>
                                          <tr>
                                            <td height="50" align="left" style="padding-left:5px;"><strong><?php echo lang_info_pagina_cadastrar_streaming_bitrate; ?></strong></td>
                                            <td align="left"><div class="input-group"><input name="bitrate" type="text" class="form-control" id="bitrate" style="width:60%;" value="" /><span class="input-group-append" id="basic-addon3"><label class="input-group-text">Kbps</label></span></div>
                                         </td>
                                          </tr>
                                          <tr>
                                            <td height="50" align="left" style="padding-left:5px;"><strong><?php echo lang_info_pagina_cadastrar_streaming_espaco_ftp; ?></strong></td>
                                            <td align="left"><div class="input-group"><input name="espaco" type="text" class="form-control" id="espaco" style="width:90%;" value="" /><span class="input-group-append" id="basic-addon3"><label class="input-group-text">MB</label></span></div></td>
                                          </tr>
                                          <tr>
                                            <td height="50" align="left" style="padding-left:5px;"><strong><?php echo lang_info_pagina_cadastrar_streaming_senha; ?></strong></td>
                                            <td align="left"><div class="input-group"><input name="senha" type="text" class="form-control" id="senha" style="width:90%; vertical-align:middle" value="" /><span class="input-group-append" id="basic-addon3" onclick="gerar_senha('senha');"><label class="input-group-text" style="cursor: pointer;"><i class="fa fa-lock text-yellow">&nbsp;</i></label></span></div></td>
                                          </tr>
                                          <tr>
                                            <td height="50" align="left" style="padding-left:5px;"><strong><?php echo lang_info_pagina_cadastrar_streaming_identificacao; ?></strong></td>
                                            <td align="left"><input name="identificacao" type="text" class="form-control" id="identificacao" style="width:100%;" value="" />
                                              &nbsp;</td>
                                          </tr>
                                          <tr>
                                            <td height="50" align="left" style="padding-left:5px;"><strong><?php echo lang_info_pagina_cadastrar_streaming_email; ?></strong></td>
                                            <td align="left"><input name="email" type="text" class="form-control" id="email" style="width:100%;" value="" />
                                              &nbsp;</td>
                                          </tr>
                                          <tr>
                                            <td width="150" height="30" align="left" style="padding-left:5px;"><strong><?php echo lang_info_pagina_cadastrar_streaming_aplicacao; ?></strong></td>
                                            <td align="left">
                                              <select name="aplicacao" id="aplicacao" class="form-control" style="width:100%;">
                                              <option value="tvstation" selected="selected">Tv Station (live & playlist)</option>
                                              <option value="webrtc">WebRTC(baixo delay ao vivo)</option>
                                              <option value="live">Live</option>
                                              <option value="vod">OnDemand</option>
                                              <option value="ipcamera">IP Camera</option>
                                            </select></td>
                                          </tr>
                                          <tr>
                                            <td height="50" align="left" style="padding-left:5px;"><strong><?php echo lang_info_pagina_cadastrar_streaming_idioma; ?></strong></td>
                                            <td align="left">
                                            <select name="idioma_painel" id="idioma_painel" class="form-control" style="width:100%;" data-toggle="tooltip" data-placement="bottom" title="<?php echo lang_info_pagina_cadastrar_streaming_idioma_ajuda; ?>">
                                              <option value="pt-br" selected="selected">Portugu&ecirc;s(Brasil)</option>
                                              <option value="es">Espa&ntilde;ol</option>
                                              <option value="en-us">English(USA)</option>
                                            </select></td>
                                          </tr>
                                          <tr>
                                            <td height="50" align="left" style="padding-left:5px;"><strong><?php echo lang_info_pagina_cadastrar_streaming_autenticar_live; ?></strong></td>
                                                <td align="left"><input type="checkbox" id="autenticar_live" name="autenticar_live" value="sim" checked /></td>
                                            </tr>
                                          <tr>
                                            <td height="35" align="left" style="padding-left:5px;"><strong><?php echo lang_info_pagina_cadastrar_streaming_lives; ?></strong></td>
                                            <td align="left"><input type="checkbox" id="lives" name="lives" value="sim" checked />
                                            </td>
                                          </tr>
                                          <tr>
                                            <td height="35" align="left" style="padding-left:5px;"><strong>Transcoder</strong></td>
                                            <td align="left"><input type="checkbox" id="transcoder" name="transcoder" value="sim" />
                                            </td>
                                          </tr>
                                          <tr>
                                            <td height="50" colspan="2" align="right"><button type="button" class="btn btn-info" onClick="document.cadastrar.submit();"><?php echo lang_botao_titulo_cadastrar; ?></button></td>
                                          </tr>
                                        </table>
                                      </form>
                </div>
              </div>
            </div>

          </div>
        </div>
      </div>
      <!-- modal -->                
        <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/admin-streamings/resultado/"+document.getElementById("busca_chave").value;
    }
  }); 

  </script>
</body>
</html>