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

$total_avisos_ativos = mysqli_num_rows(mysqli_query($conexao,"SELECT * FROM avisos WHERE area = 'streaming'"));
$checar_status_aviso = mysqli_num_rows(mysqli_query($conexao,"SELECT * FROM avisos_desativados WHERE area = 'streaming' AND codigo_usuario = '".$dados_stm["porta"]."'"));
$total_avisos_exibir = ($total_avisos_ativos > $checar_status_aviso) ? $total_avisos_ativos-$checar_status_aviso : 0;

$dados_playlist_selecionada = mysqli_fetch_array(mysqli_query($conexao,"SELECT * FROM playlists where codigo = '".code_decode(query_string('1'),"D")."'"));

// Salva a Playlist
if($_POST["playlist"]) {

$dados_playlist = mysqli_fetch_array(mysqli_query($conexao,"SELECT * FROM playlists where codigo = '".$_POST["playlist"]."'"));

// Remove as mÃºsicas atuais da playlist para gravar as novas mÃºsica
mysqli_query($conexao,"DELETE FROM playlists_musicas where codigo_playlist = '".$dados_playlist["codigo"]."'");

if(mysqli_error($conexao)) {
$_SESSION["status_acao"] = '<div class="alert alert-danger text-center" role="alert">'.$lang['lang_acao_gerenciador_playlists_resultado_erro'].' '.mysqli_error($conexao).'</div>';

header("Location: /gerenciar-playlists/".query_string('1')."");
exit();
}

if(count($_POST["musicas_adicionadas"]) > 0) {

// Adiciona as musicas da playlist ao banco de dados
foreach($_POST["musicas_adicionadas"] as $ordem => $musica) {

list($path, $musica, $duracao, $duracao_segundos, $tipo) = explode("|",$musica);

if($tipo == "temp") {
    $path = '#!/home/streaming/previsao_tempo/previsao_tempo '.$dados_stm["porta"].' temperatura';
    $musica = "Previsão do tempo - Temperatura";
    $tipo = 'temp';
}
if($tipo == "umd") {
    $path = '#!/home/streaming/previsao_tempo/previsao_tempo '.$dados_stm["porta"].' umidade';
    $musica = "Previsão do tempo - Umidade";
    $tipo = 'umd';
}

// Adiciona mÃºsica na playlist
mysqli_query($conexao,"INSERT INTO playlists_musicas (codigo_playlist,path_musica,musica,duracao,duracao_segundos,tipo,ordem) VALUES ('".$dados_playlist["codigo"]."','".addslashes($path)."','".addslashes($musica)."','".$duracao."','".$duracao_segundos."','".$tipo."','".$ordem."')");

if(mysqli_error($conexao)) {
$_SESSION["status_acao"] = '<div class="alert alert-danger text-center" role="alert">'.$lang['lang_acao_gerenciador_playlists_resultado_erro'].' '.mysqli_error($conexao).'</div>';

header("Location: /gerenciar-playlists/".query_string('1')."");
exit();
}

// Adiciona a música na lista para adicionar ao arquivo da playlist
if($tipo == "hc" || $tipo == "temp" || $tipo == "umd") {
     $lista_musicas .= $path."\n";
} elseif($tipo == "programa" || $tipo == "programas") {
     $lista_musicas .= "/home/streaming/programas/".$path."\n";
} elseif($tipo == "programete" || $tipo == "programetes") {
     $lista_musicas .= "/home/streaming/programetes/".$path."\n";
} elseif($tipo == "acervo_mp3") {
$lista_musicas .= "/home/streaming/acervo_mp3/".$path."\n";

} else {
     $lista_musicas .= "/home/streaming/".$dados_stm["porta"]."/".$path."\n";
}


}

// Cria o arquivo da playlist para enviar ao servidor do streaming
$config_playlist = gerar_playlist($dados_playlist["arquivo"],$lista_musicas);

// Envia o arquivo da playlist para o servidor do streaming
// ConexÃ£o SSH
$ssh = new SSH();
$ssh->conectar($dados_servidor["ip"],$dados_servidor["porta_ssh"]);
$ssh->autenticar("root",code_decode($dados_servidor["senha"],"D"));

$ssh->enviar_arquivo("".$_SERVER['DOCUMENT_ROOT']."/temp/".$config_playlist."","/home/streaming/playlists/".$dados_playlist["arquivo"]."",0777);

// Remove o arquivo temporÃ¡rio usado para criar a playlist
@unlink("".$_SERVER['DOCUMENT_ROOT']."/temp/".$config_playlist."");

// Cria o sessÃ£o do status das aÃ§Ãµes executadas e redireciona.
$_SESSION["status_acao"] = '<div class="alert alert-success text-center" role="alert">'.$lang['lang_acao_gerenciador_playlists_resultado_ok'].'</div>';

// Inicia a playlist
if($_POST["iniciar_playlist"] == "sim") {

// Verifica se o autodj esta ligado
$status_autodj = status_autodj($dados_servidor["ip"],$dados_stm["porta"],$dados_stm["senha"]);
    
if($status_autodj == "ligado") {
    
$resultado = $ssh->executar("cp -fv /home/streaming/playlists/".$dados_playlist["arquivo"]." /home/streaming/playlists/".$dados_stm["porta"].".pls;/home/streaming/gerenciar_autodj recarregar_playlist ".$dados_stm["porta"]." ".$dados_stm["porta_dj"]."");

if(preg_match('/'.$dados_stm["porta"].'/i',$resultado)) {
    
// Atualiza a Ãºltima playlist tocada e o bitrate do autodj
mysqli_query($conexao,"Update streamings set ultima_playlist = '".$dados_playlist["codigo"]."' where codigo = '".$dados_stm["codigo"]."'");

// Cria o sessÃ£o do status das aÃ§Ãµes executadas e redireciona.
$_SESSION["status_acao"] = '<div class="alert alert-success text-center" role="alert">'.$lang['lang_acao_trocar_playlist_autodj_resultado_ok'].'</div>';

} else {
// Cria o sessÃ£o do status das aÃ§Ãµes executadas e redireciona.
$_SESSION["status_acao"] = '<div class="alert alert-danger text-center" role="alert">'.$lang['lang_acao_trocar_playlist_autodj_resultado_erro'].'</div>';
}

} else {
// Cria o sessÃ£o do status das aÃ§Ãµes executadas e redireciona.
$_SESSION["status_acao"] = '<div class="alert alert-warning text-center" role="alert">'.$lang['lang_acao_trocar_playlist_autodj_resultado_alerta'].'</div>';
}
}

header("Location: /playlists");
exit();

}

}
?>
<!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>Streaming <?php echo $dados_stm["porta"]; ?></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="/inc/ajax-streaming.js"></script>
  <script type="text/javascript" src="/inc/ajax-streaming-playlists.js"></script>
  <script type="text/javascript" src="/inc/javascript.js"></script>
        <style type="text/css">.lista-musicas-playlist-acervo{background-color: #808000; padding:0;color:#FFFFFF;font-family:Tahoma,Arial,sans-serif;font-size:11px;font-weight:400;margin:0 auto}.lista-musicas-playlist-vinheta{background-color: #008000; padding:0;color:#FFFFFF;font-family:Tahoma,Arial,sans-serif;font-size:11px;font-weight:400;margin:0 auto}.lista-musicas-playlist-comercial{background-color: #008080; padding:0;color:#FFFFFF;font-family:Tahoma,Arial,sans-serif;font-size:11px;font-weight:400;margin:0 auto}.lista-musicas-playlist-hora-certa{background-color: #000080; padding:0;color:#FFFFFF;font-family:Tahoma,Arial,sans-serif;font-size:11px;font-weight:400;margin:0 auto}.lista-musicas-playlist-intercalado{background-color: #FFA500; padding:0;color:#FFFFFF;font-family:Tahoma,Arial,sans-serif;font-size:11px;font-weight:400;margin:0 auto}ul#lista-musicas-pasta{padding:0;color:#000;font-family:Tahoma,Arial,sans-serif;font-size:11px;font-weight:400;margin:0 auto}ul#lista-musicas-pasta li{list-style:none;display:block;padding-top:2px;padding-bottom:2px}.lista-musicas-playlist-programete{background-color: #800080; padding:0;color:#FFFFFF;font-family:Tahoma,Arial,sans-serif;font-size:11px;font-weight:400;margin:0 auto}.lista-musicas-playlist-programa{background-color: #0000FF; padding:0;color:#FFFFFF;font-family:Tahoma,Arial,sans-serif;font-size:11px;font-weight:400;margin:0 auto}ul#lista-musicas-pasta li:hover{background-color:#eee}ul#lista-musicas-pasta a{text-decoration:none;color:#000}ul#lista-musicas-pasta a:hover{text-decoration:underline}ul#lista-pastas{padding:0;color:#000;font-family:Tahoma,Arial,sans-serif;font-size:11px;font-weight:400;margin:0 auto}ul#lista-pastas li{list-style:none;display:block;padding-top:2px;padding-bottom:2px}ul#lista-pastas li:hover{background-color:#eee}ul#lista-pastas a{text-decoration:none;color:#000}ul#lista-pastas a:hover{text-decoration:underline}ul#lista-playlists{padding:0;color:#000;font-family:Tahoma,Arial,sans-serif;font-size:11px;font-weight:400;margin:0 auto}ul#lista-playlists li{list-style:none;display:block;padding-top:2px;padding-bottom:2px}ul#lista-playlists li:hover{background-color:#eee}ul#lista-playlists a{text-decoration:none;color:#000}ul#lista-playlists a:hover{text-decoration:underline}ul#lista-musicas-playlist{padding:0;color:#000;font-family:Tahoma,Arial,sans-serif;font-size:11px;font-weight:400;margin:0 auto}ul#lista-musicas-playlist li{list-style:none;display:block;padding-top:2px;padding-bottom:2px;position:relative;cursor:n-resize;border:#fff 1px dashed}ul#lista-musicas-playlist li:hover{background-color:#800000;border:#999 1px dashed;-moz-opacity:.7;opacity:.7}ul#lista-musicas-playlist a{text-decoration:none;color:#FFFFFF}ul#lista-musicas-playlist a:hover{text-decoration:underline}</style>
</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="/dashboard"><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="/dashboard"><span>Painel Streaming</span></a>
        <?php } ?>
        <a class="navbar-brand brand-logo-mini" href="/dashboard"><img src="/img/icones/img-icone-logo.png" title="Painel" width="32" height="32" border="0"></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 navbar-nav-right">
          <li class="nav-item nav-profile dropdown show">
            <a class="nav-link dropdown-toggle" href="#" data-toggle="dropdown" id="profileDropdown" aria-expanded="true">
              <i class="fa fa-power-off f-18 text-icones" data-toggle="tooltip" data-placement="bottom" title="<?php echo $lang['lang_botao_titulo_ligar']; ?>/<?php echo $lang['lang_botao_titulo_desligar']; ?>"></i>
            </a>
            <div class="dropdown-menu dropdown-menu-right navbar-dropdown" aria-labelledby="profileDropdown">
              <a class="dropdown-item text-success" href="javascript:ligar_streaming('<?php echo $porta_code; ?>');"> <?php echo $lang['lang_botao_titulo_ligar']; ?> Streaming</a>
              <a class="dropdown-item text-danger" href="javascript:desligar_streaming('<?php echo $porta_code; ?>');"> <?php echo $lang['lang_botao_titulo_desligar']; ?> Streaming</a>
              <?php if($dados_stm["autodj"] == "sim") { ?>
              <div class="dropdown-divider"></div>              
              <a class="dropdown-item text-success" href="javascript:carregar_opcoes_ligar_autodj('<?php echo $porta_code; ?>');"> <?php echo $lang['lang_botao_titulo_ligar']; ?> AutoDJ</a>
              <a class="dropdown-item text-danger" href="javascript:desligar_autodj('<?php echo $porta_code; ?>');"> <?php echo $lang['lang_botao_titulo_desligar']; ?> AutoDJ</a>
              <?php } ?>
            </div>
          </li>
          <li class="nav-item dropdown">
            <a class="nav-link count-indicator dropdown-toggle d-flex align-items-center justify-content-center" id="notificationDropdown" href="#" data-toggle="dropdown" aria-expanded="false">
              <i class="mdi mdi-bell f-22 text-icones" data-toggle="tooltip" data-placement="bottom" title="<?php echo $lang['lang_info_pagina_informacoes_tab_avisos']; ?>"></i>
              <?php if($total_avisos_exibir > 0) { ?><span class="count bg-success"><?php echo $total_avisos_exibir; ?></span><?php } ?>           
            </a>
            <div class="dropdown-menu dropdown-menu-right navbar-dropdown preview-list" aria-labelledby="notificationDropdown">
              <a class="dropdown-item">
                <p class="mb-0 font-weight-normal float-left"><?php echo $lang['lang_info_pagina_informacoes_tab_avisos']; ?></p>
              </a>
              <div class="dropdown-divider"></div>
              <?php carregar_avisos_streaming($conexao,$dados_stm["porta"],$dados_servidor["codigo"]); ?>
            </div>
          </li>
          <li class="nav-item">
            <a class="nav-link" href="/sair"><i class="mdi mdi-logout f-22 text-icones" data-toggle="tooltip" data-placement="bottom" title="Sair/logout"></i></a>
          </li>
          <li>
            <button type="button" class="btn btn-info" id="status-streaming" onClick="status_streaming('<?php echo $porta_code; ?>');" style="margin: 10px;min-width: 150px; min-height: 40px"><i class="fa fa-refresh"></i></button>
          </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>

    <!-- 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="playlists-autodj" 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">AutoDJ</h5>
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                </div>
                <div class="modal-body text-center" id="playlists-autodj-conteudo" style="text-align: center;"><img src="/img/ajax-loader.gif" /></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 class="container-fluid page-body-wrapper">      
    <?php require_once("menu.php"); ?>
      <div class="main-panel">
        <div class="content-wrapper">
          <div id="local-status-acoes"><?php echo $_SESSION['status_acao'];unset($_SESSION['status_acao']); ?></div>
          <form method="post" action="/gerenciar-playlists/<?php echo query_string('1'); ?>" name="gerenciador" enctype="multipart/form-data">
          <div class="row">

          <div class="col-12">
              <div class="row">
                <div class="col-12 col-sm-6 col-md-3">
                  <div class="card">
                    <div class="card-body">
                      <h4 class="card-title">Playlist</h4>
                      <div class="d-flex justify-content-between">
                        <i class="fa fa-file-audio-o f-32 text-blue"></i>
                        <?php echo $dados_playlist_selecionada["nome"]; ?>
                      </div>
                    </div>
                  </div>
                </div>
                <div class="col-12 col-sm-6 col-md-3">
                  <div class="card">
                    <div class="card-body">
                      <h4 class="card-title">Playlists</h4>                      
                      <div class="d-flex justify-content-between">
                        <i class="fa fa-external-link f-32 text-yellow"></i>
                        <div class="dropdown show">
                                                                  <button class="btn btn-light btn-sm dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">&nbsp;&nbsp;&nbsp;<?php echo $lang['lang_info_gerenciador_playlists_aba_playlists']; ?>&nbsp;</button>

                                                                  <div class="dropdown-menu" aria-labelledby="dropdownMenuLink">
                                                                    <?php

                                                                    $query = mysqli_query($conexao,"SELECT * FROM playlists where codigo_stm = '".$dados_stm["codigo"]."' ORDER by nome ASC");
                                                                    while ($dados_playlist_gerenciar = mysqli_fetch_array($query)) {

                                                                    $total_musicas = mysqli_num_rows(mysqli_query($conexao,"SELECT * FROM playlists_musicas where codigo_playlist = '".$dados_playlist_gerenciar["codigo"]."'"));

                                                                    $playlist_gerenciar_code = code_decode($dados_playlist_gerenciar["codigo"],"E");

                                                                    echo '<a class="dropdown-item" href="/gerenciar-playlists/' . $playlist_gerenciar_code . '">' . $dados_playlist_gerenciar["nome"] . ' (' . $total_musicas . ')</a>';
                                                                    
                                                                    }
                                                                    ?>
                                                                  </div>
                                                                </div>
                      </div>
                    </div>
                  </div>
                </div>
                <div class="col-12 col-sm-6 col-md-3">
                  <div class="card">
                    <div class="card-body">
                      <h4 class="card-title"><?php echo $lang['lang_info_gerenciador_playlists_basico_musicas_playlist']; ?></h4>
                      <div class="d-flex justify-content-between">
                        <i class="fa fa-music f-32 text-dribbble"></i>
                        <span id="quantidade_musicas_playlist"><?php echo $total_musicas_playlist; ?></span>
                      </div>
                    </div>
                  </div>
                </div>
                <div class="col-12 col-sm-6 col-md-3">
                  <div class="card">
                    <div class="card-body">
                      <h4 class="card-title"><?php echo $lang['lang_info_gerenciador_playlists_basico_tempo_execucao']; ?></h4>
                      <div class="d-flex justify-content-between">
                        <i class="fa fa-clock-o f-32 text-green"></i>
                        <span id="tempo_playlist"><?php echo gmdate("H:i:s", $duracao["total"]); ?></span><input name="tempo" type="hidden" id="tempo" value="0" /></p>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </div>    

            <div class="col-xl-6 col-md-6">
              <div class="card">
                  <div class="card-header">
                    <header><?php echo $lang['lang_info_gerenciador_playlists_pastas']; ?></header>
                  </div>
                <div class="card-body">
                    <div id="quadro_lista_pastas" style="background-color:#FFFFFF; border: #CCCCCC 1px solid; width:100%; height:200px; text-align:left; float:left; padding:5px; overflow: auto; resize: vertical"> <span id="status_lista_pastas"></span>
                                                    <ul id="lista-pastas">
                                                    </ul>
                                                </div>
                                                <div style="width:100%%; text-align:left; float:left; padding:5px 0px 5px 0px; overflow: auto;">
                                                <button type="button" class="btn btn-light" onClick="carregar_pastas('<?php echo $porta_code; ?>');"><i class="fa fa-refresh"></i><?php echo $lang['lang_info_gerenciador_playlists_botao_recarregar_pastas']; ?></button>
                                                <?php if($dados_stm["programetes"] == 'sim') { ?><button type="button" class="btn btn-light" onClick="carregar_pastas_programetes('<?php echo $porta_code; ?>');"><i class="fa fa-refresh"></i>Programetes</button><?php } ?>
                                                <?php if($dados_stm["programas"] == 'sim') { ?><button type="button" class="btn btn-light" onClick="carregar_pastas_programas('<?php echo $porta_code; ?>');"><i class="fa fa-refresh"></i>Programas</button><?php } ?><button type="button" class="btn btn-light" onClick="carregar_pastas_acervo_mp3('<?php echo $porta_code; ?>');"><i class="fa fa-refresh"></i>Acervo MP3</button>
                                              </div>
                </div>
              </div>
            </div>

            <div class="col-xl-6 col-md-6">
              <div class="card">
                  <div class="card-header">
                    <header><?php echo $lang['lang_info_gerenciador_playlists_musicas_pasta']; ?></header>
                                        <div class="card-header-right">
                                            <input name="ordenar_musicas_pasta" id="ordenar_musicas_pasta" type="checkbox" value="sim" style="vertical-align: middle;" checked="checked" />
                                                &nbsp;<small><?php echo $lang['lang_info_gerenciador_playlists_musicas_pasta_ordenar']; ?></small>
                                        </div>
                  </div>
                <div class="card-body">
                    <div id="musicas_ftp" style="background-color:#FFFFFF; border: #CCCCCC 1px solid; width:100%; height:200px; text-align:left; float:right; padding:5px; overflow: auto; resize: vertical"> <span id="msg_pasta"><?php echo $lang['lang_info_gerenciador_playlists_info_lista_musicas_pasta']; ?></span><span id="status_lista_musicas" style="display: none"><img src="/img/ajax-loader.gif" /></span>
                                                    <ul id="lista-musicas-pasta">
                                                    </ul>
                                              </div>
                                              <div style="width:100%; text-align:right; float:right; padding:5px 0px 5px 0px; overflow: auto;">
                                                <button type="button" class="btn btn-light" onClick="adicionar_tudo();"><i class="fa fa-plus-circle"></i><?php echo $lang['lang_info_gerenciador_playlists_botao_adicionar_tudo']; ?></button>&nbsp;<button type="button" class="btn btn-light" onClick="limpar_lista_musicas('ftp');"><i class="fa fa-trash-o"></i><?php echo $lang['lang_info_gerenciador_playlists_botao_limpar_lista']; ?></button>
                                            </div>
                </div>
              </div>
            </div>

            <div class="col-xl-12 col-md-12">
              <div class="card">
                  <div class="card-header">
                    <header><?php echo $lang['lang_info_gerenciador_playlists_musicas_playlist']; ?></header>
                  </div>
                <div class="card-body">
                    <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
                                          
                                          <tr>
                                            <td colspan="2"><div id="musicas_playlist" style="background-color:#FFFFFF; border: #CCCCCC 1px solid; width:100%; height:550px; text-align:left; float:left; padding:5px; overflow: auto; resize: vertical">
                                            <span id="msg_playlist"><?php echo $lang['lang_info_gerenciador_playlists_info_lista_musicas_playlists']; ?></span>
                                            <span id="msg_playlist_nova" style="display:none"><?php echo $lang['lang_info_gerenciador_playlists_info_lista_musicas_playlist_nova']; ?></span><span id="status_lista_musicas_playlist" style="display: none"><img src="/img/ajax-loader.gif" /></span>
                                            <ul id="lista-musicas-playlist">
                                            </ul>
                                            </div>                                            </td>
                                          </tr>
                                          <tr>
                                            <td width="70%" height="30" align="left">
                                                <button type="button" class="btn btn-light" onClick="carregar_musicas_playlist( '<?php echo $dados_playlist_selecionada["codigo"]; ?>' );"><i class="fa fa-refresh"></i><?php echo $lang['lang_info_gerenciador_playlists_botao_recarregar_playlists']; ?></button>
                                                <button type="button" class="btn btn-light" onClick="misturar_musicas('lista-musicas-playlist');"><i class="fa fa-retweet"></i><?php echo $lang['lang_info_gerenciador_playlists_botao_misturar_musicas']; ?></button>
                                                <button type="button" class="btn btn-light" onClick="limpar_lista_musicas('playlist');"><i class="fa fa-trash-o"></i><?php echo $lang['lang_info_gerenciador_playlists_botao_limpar_lista']; ?></button>                                            </td>
                                            <td width="30%" height="50" align="right">
                                                <button type="button" class="btn btn-success" onClick="salvar_playlist();"><i class="fa fa-save"></i> <?php echo $lang['lang_info_gerenciador_playlists_botao_salvar_playlist']; ?></button>
                                                <button type="button" class="btn btn-info" onClick="document.getElementById('iniciar_playlist').value = 'sim';salvar_playlist();"><i class="fa fa-play"></i> <?php echo $lang['lang_info_gerenciador_playlists_botao_salvar_playlist_iniciar']; ?></button>
                                            <input name="playlist" type="hidden" id="playlist" value="<?php echo $dados_playlist_selecionada["codigo"]; ?>" />
                                            <input name="iniciar_playlist" type="hidden" id="iniciar_playlist" value="nao" /></td>
                                          </tr>
                                        </table>
                </div>
              </div>
            </div>

            <div class="alert alert-warning text-center" role="alert"><?php echo $lang['lang_info_gerenciador_playlists_info_timezone']; ?></div>
            <div class="alert alert-warning text-center" role="alert"><?php echo $lang['lang_info_gerenciador_playlists_info_caracteres_especiais']; ?></div>
          </div>
          </form>
        </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>
  status_streaming('<?php echo $porta_code; ?>');
  setInterval("status_streaming('<?php echo $porta_code; ?>')",60000);
        carregar_pastas('<?php echo $porta_code; ?>');
        carregar_musicas_playlist( '<?php echo $dados_playlist_selecionada["codigo"]; ?>' );        
        $('#log-sistema').on('hidden.bs.modal', function () {
        document.getElementById("log-sistema-conteudo").innerHTML = '<img src="/img/ajax-loader.gif" />';
        });
  </script>
</body>
</html>