<?php
require_once("admin/inc/protecao-final.php");
require_once("app/wideimage/WideImage.php");
@mysqli_query($conexao,"ALTER TABLE `streamings` ADD `app_certificado` VARCHAR(255) NOT NULL DEFAULT 'padrao'");

$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 login = '".$dados_stm["login"]."'"));
$total_avisos_exibir = ($total_avisos_ativos > $checar_status_aviso) ? $total_avisos_ativos-$checar_status_aviso : 0;


//Funções
function formatar_nome_radio2($nome){$characteres=array('S'=>'S','s'=>'s','Ð'=>'Dj','Z'=>'Z','z'=>'z','À'=>'A','Á'=>'A','Â'=>'A','Ã'=>'A','Ä'=>'A','Å'=>'A','Æ'=>'A','Ç'=>'C','È'=>'E','É'=>'E','Ê'=>'E','Ë'=>'E','Ì'=>'I','Í'=>'I','Î'=>'I','Ï'=>'I','Ñ'=>'N','Ò'=>'O','Ó'=>'O','Ô'=>'O','Õ'=>'O','Ö'=>'O','Ø'=>'O','Ù'=>'U','Ú'=>'U','Û'=>'U','Ü'=>'U','Ý'=>'Y','Þ'=>'B','ß'=>'Ss','à'=>'a','á'=>'a','â'=>'a','ã'=>'a','ä'=>'a','å'=>'a','æ'=>'a','ç'=>'c','è'=>'e','é'=>'e','ê'=>'e','ë'=>'e','ì'=>'i','í'=>'i','î'=>'i','ï'=>'i','ð'=>'o','ñ'=>'n','ò'=>'o','ó'=>'o','ô'=>'o','õ'=>'o','ö'=>'o','ø'=>'o','ù'=>'u','ú'=>'u','û'=>'u','ý'=>'y','ý'=>'y','þ'=>'b','ÿ'=>'y','f'=>'f','¹'=>'','²'=>'','&'=>'e','³'=>'','£'=>'','$'=>'','%'=>'','¨'=>'','§'=>'','º'=>'','ª'=>'','©'=>'','Ã£'=>'','('=>'',')'=>'',"'"=>'','@'=>'','='=>'',':'=>'','!'=>'','?'=>'','...'=>'','®'=>'','/'=>'','´'=>'','+'=>'','*'=>'','['=>'',']'=>'');return strtr($nome,$characteres);}function nome_app_play2($texto){$characteres=array('S'=>'S','s'=>'s','Ð'=>'Dj','Z'=>'Z','z'=>'z','À'=>'A','Á'=>'A','Â'=>'A','Ã'=>'A','Ä'=>'A','Å'=>'A','Æ'=>'A','Ç'=>'C','È'=>'E','É'=>'E','Ê'=>'E','Ë'=>'E','Ì'=>'I','Í'=>'I','Î'=>'I','Ï'=>'I','Ñ'=>'N','Ò'=>'O','Ó'=>'O','Ô'=>'O','Õ'=>'O','Ö'=>'O','Ø'=>'O','Ù'=>'U','Ú'=>'U','Û'=>'U','Ü'=>'U','Ý'=>'Y','Þ'=>'B','ß'=>'Ss','à'=>'a','á'=>'a','â'=>'a','ã'=>'a','ä'=>'a','å'=>'a','æ'=>'a','ç'=>'c','è'=>'e','é'=>'e','ê'=>'e','ë'=>'e','ì'=>'i','í'=>'i','î'=>'i','ï'=>'i','ð'=>'o','ñ'=>'n','ò'=>'o','ó'=>'o','ô'=>'o','õ'=>'o','ö'=>'o','ø'=>'o','ù'=>'u','ú'=>'u','û'=>'u','ý'=>'y','ý'=>'y','þ'=>'b','ÿ'=>'y','f'=>'f','¹'=>'','²'=>'','&'=>'e','³'=>'','£'=>'','$'=>'','%'=>'','¨'=>'','§'=>'','º'=>'','ª'=>'','©'=>'','Ã£'=>'','('=>'',')'=>'',"'"=>'','@'=>'','='=>'',':'=>'','!'=>'','?'=>'','...'=>'',' '=>'','-'=>'','^'=>'','~'=>'','.'=>'','|'=>'',','=>'','<'=>'','>'=>'','{'=>'','}'=>'','®'=>'','/'=>'','´'=>'','+'=>'','*'=>'','['=>'',']'=>'');return strtolower(strtr($texto,$characteres));}function nome_app_apk2($texto){$characteres=array('S'=>'S','s'=>'s','Ð'=>'Dj','Z'=>'Z','z'=>'z','À'=>'A','Á'=>'A','Â'=>'A','Ã'=>'A','Ä'=>'A','Å'=>'A','Æ'=>'A','Ç'=>'C','È'=>'E','É'=>'E','Ê'=>'E','Ë'=>'E','Ì'=>'I','Í'=>'I','Î'=>'I','Ï'=>'I','Ñ'=>'N','Ò'=>'O','Ó'=>'O','Ô'=>'O','Õ'=>'O','Ö'=>'O','Ø'=>'O','Ù'=>'U','Ú'=>'U','Û'=>'U','Ü'=>'U','Ý'=>'Y','Þ'=>'B','ß'=>'Ss','à'=>'a','á'=>'a','â'=>'a','ã'=>'a','ä'=>'a','å'=>'a','æ'=>'a','ç'=>'c','è'=>'e','é'=>'e','ê'=>'e','ë'=>'e','ì'=>'i','í'=>'i','î'=>'i','ï'=>'i','ð'=>'o','ñ'=>'n','ò'=>'o','ó'=>'o','ô'=>'o','õ'=>'o','ö'=>'o','ø'=>'o','ù'=>'u','ú'=>'u','û'=>'u','ý'=>'y','ý'=>'y','þ'=>'b','ÿ'=>'y','f'=>'f','¹'=>'','²'=>'','&'=>'e','³'=>'','£'=>'','$'=>'','%'=>'','¨'=>'','§'=>'','º'=>'','ª'=>'','©'=>'','Ã£'=>'','('=>'',')'=>'',"'"=>'','@'=>'','='=>'',':'=>'','!'=>'','?'=>'','...'=>'',' '=>'','-'=>'','^'=>'','~'=>'','.'=>'','|'=>'',','=>'','<'=>'','>'=>'','{'=>'','}'=>'',' '=>'','®'=>'','/'=>'','´'=>'','+'=>'','*'=>'','['=>'',']'=>'');return strtr($texto,$characteres);}function copiar_source2($DirFont,$DirDest){mkdir($DirDest);if($dd=opendir($DirFont)){while(false!==($Arq=readdir($dd))){if($Arq!="."&&$Arq!=".."){$PathIn="$DirFont/$Arq";$PathOut="$DirDest/$Arq";if(is_dir($PathIn)){copiar_source2($PathIn,$PathOut);chmod($PathOut,0777);}elseif(is_file($PathIn)){copy($PathIn,$PathOut);chmod($PathOut,0777);}}}closedir($dd);}}function criar_arquivo_config2($arquivo,$conteudo){$fd=fopen($arquivo,"w");fputs($fd,$conteudo);fclose($fd);}function browse2($dir){global $filenames;if($handle=opendir($dir)){while(false!==($file=readdir($handle))){if($file!="."&&$file!=".."&&is_file($dir.'/'.$file)){$filenames[]=$dir.'/'.$file;}else if($file!="."&&$file!=".."&&is_dir($dir.'/'.$file)){browse2($dir.'/'.$file);}}closedir($handle);}return $filenames;}function replace2($arquivo,$string_atual,$string_nova){$str=file_get_contents($arquivo);$str=str_replace($string_atual,$string_nova,$str);file_put_contents($arquivo,$str);}function remover_source_app2($Dir){if($dd=@opendir($Dir)){while(false!==($Arq=@readdir($dd))){if($Arq!="."&&$Arq!=".."){$Path="$Dir/$Arq";if(is_dir($Path)){remover_source_app2($Path);}elseif(is_file($Path)){@unlink($Path);}}}@closedir($dd);}@rmdir($Dir);}function mudar_permissao2($Dir){if($dd=opendir($Dir)){while(false!==($Arq=readdir($dd))){if($Arq!="."&&$Arq!=".."){$Path="$Dir/$Arq";@chmod($Path,0777);}}closedir($dd);}}

$dados_config = mysqli_fetch_array(mysqli_query($conexao,"SELECT * FROM configuracoes"));
$dados_stm = mysqli_fetch_array(mysqli_query($conexao,"SELECT * FROM streamings where login = '".$_SESSION["login_logado"]."'"));
$dados_servidor = mysqli_fetch_array(mysqli_query($conexao,"SELECT * FROM servidores where codigo = '".$dados_stm["codigo_servidor"]."'"));

$url_player = (!empty($dados_revenda["dominio_padrao"])) ? "playerv.".$dados_revenda["dominio_padrao"]."" : "playerv.".$dados_config["dominio_padrao"]."";

$dados_app_criado = mysqli_fetch_array(mysqli_query($conexao,"SELECT * FROM apps where codigo_stm = '".$dados_stm["codigo"]."'"));

if($_POST["acao_form"] == "criar") {

// Valida extensão
if($_FILES["logo"]["type"] != "image/png") {
die ("<script> alert(\"Logo deve ser PNG\\n\\nLogo must be PNG\");
       window.location = 'javascript:history.back(-1)'; </script>");
}

if($_FILES["icone"]["type"] != "image/png") {
die ("<script> alert(\"Icone deve ser PNG\\n\\nIcon must be PNG\");
       window.location = 'javascript:history.back(-1)'; </script>");
}

if($_FILES["fundo"]["type"] != "image/jpeg") {
die ("<script> alert(\"Fundo deve ser JPG\\n\\nBackground must be JPG\");
       window.location = 'javascript:history.back(-1)'; </script>");
}

if(strlen($_POST["webtv_nome"]) > 30) {
die ("<script> alert(\"Nome da radio deve ter maximo 30 caracteres.\\n\\nRadio name max 30 character.\");
       window.location = 'javascript:history.back(-1)'; </script>");
}

if(empty($_POST["webtv_nome"])) {
die ("<script> alert(\"Nome da radio esta vazio.\\n\\nRadio name is empty.\");
       window.location = 'javascript:history.back(-1)'; </script>");
}

// Verifica se o primeiro caracter é numérico
if(preg_match('/^\d/',$_POST["webtv_nome"])) {
die ("<script> alert(\"Nome da radio não pode iniciar com numeros.\\n\\nRadio name cant stat with number.\");
       window.location = 'javascript:history.back(-1)'; </script>");
}

$webtv_nome = $_POST["webtv_nome"];
$login = $_POST["login"];
$ponto = ($_POST["ponto"]) ? $_POST["ponto"] : 1;

$source = "source-app-player";

$hash = nome_app_play2($webtv_nome)."_".md5($webtv_nome);
$package = "com.stmvideo.webtv.".nome_app_play2($webtv_nome)."";
$package_path = str_replace(".","/",$package);

$patch_dir_apps = "/home/painelvideo/public_html/app/apps";
$patch_app = "/home/painelvideo/public_html/app/apps/".$hash."";
$patch_tmp = "/home/painelvideo/public_html/app/apps/tmp";
$patch_player = "/home/painelvideo/public_html/player/app";


//Bug fix - Remove pasta do app caso exista
remover_source_app2("/home/painelvideo/public_html/app/apps/".$hash."/");
@unlink("/home/painelvideo/public_html/app/apps/".$hash.".zip");
@unlink("/home/painelvideo/public_html/player/app/logo-".$dados_stm["login"].".png");
@unlink("/home/painelvideo/public_html/player/app/icone-".$dados_stm["login"].".png");
@unlink("/home/painelvideo/public_html/player/app/background-".$dados_stm["login"].".jpg");


@copy($_FILES["logo"]["tmp_name"],"".$patch_tmp."/logo_".$hash.".png");
@copy($_FILES["icone"]["tmp_name"],"".$patch_tmp."/icone_".$hash.".png");
@copy($_FILES["fundo"]["tmp_name"],"".$patch_tmp."/fundo_".$hash.".jpg");

// Valida a dimensão(largura x altura) das imagens
list($logo_width, $logo_height, $logo_type, $logo_attr) = getimagesize("".$patch_tmp."/logo_".$hash.".png");
list($icone_width, $icone_height, $icone_type, $icone_attr) = getimagesize("".$patch_tmp."/icone_".$hash.".png");
list($fundo_width, $fundo_height, $fundo_type, $fundo_attr) = getimagesize("".$patch_tmp."/fundo_".$hash.".jpg");

if($logo_width != 300 || $logo_height != 300) {
die ("<script> alert(\"Ooops!\\n\\nA logomarca esta com dimensão inválida!\\n\\nEnvie uma logomarca com 300 pixels de largura e 300 pixels de altura.\");
       window.location = 'javascript:history.back(-1)'; </script>");
}

if($icone_width != 144 || $icone_height != 144) {
die ("<script> alert(\"Ooops!\\n\\nO ícone esta com dimensão inválida!\\n\\nEnvie um ícone com 144 pixels de largura e 144 pixels de altura.\");
       window.location = 'javascript:history.back(-1)'; </script>");
}

if($fundo_width != 640 || $fundo_height != 1136) {
die ("<script> alert(\"Ooops!\\n\\nO fundo esta com dimensão inválida!\\n\\nEnvie um fundo com 640 pixels de largura e 1136 pixels de altura.\");
       window.location = 'javascript:history.back(-1)'; </script>");
}

copiar_source2("/home/painelvideo/public_html/app/".$source."/", $patch_app);

@rename("".$patch_app."/app/src/main/java/com/stmvideo/webtv/webtv_nome","".$patch_app."/app/src/main/java/com/stmvideo/webtv/".nome_app_play2($webtv_nome)."");

// Copia o ícone
$icone = WideImage::load("".$patch_tmp."/icone_".$hash.".png");
$icone = $icone->resize(72, 72);
$icone->saveToFile("".$patch_app."/app/src/main/res/drawable-hdpi/icone.png");

$icone = WideImage::load("".$patch_tmp."/icone_".$hash.".png");
$icone = $icone->resize(72, 72);
$icone->saveToFile("".$patch_app."/app/src/main/res/drawable-mdpi/icone.png");

$icone = WideImage::load("".$patch_tmp."/icone_".$hash.".png");
$icone = $icone->resize(96, 96);
$icone->saveToFile("".$patch_app."/app/src/main/res/drawable-xhdpi/icone.png");

$icone = WideImage::load("".$patch_tmp."/icone_".$hash.".png");
$icone = $icone->resize(144, 144);
$icone->saveToFile("".$patch_app."/app/src/main/res/drawable-xxhdpi/icone.png");

$icone = WideImage::load("".$patch_tmp."/icone_".$hash.".png");
$icone = $icone->resize(192, 192);
$icone->saveToFile("".$patch_app."/app/src/main/res/drawable-xxxhdpi/icone.png");

$icone = WideImage::load("".$patch_tmp."/icone_".$hash.".png");
$icone = $icone->resize(32, 32);
$icone->saveToFile("".$patch_player."/icone-".$dados_stm["login"].".png");

// Copia a logo
$logo = WideImage::load("".$patch_tmp."/logo_".$hash.".png");
$logo = $logo->resize(300, 300);
$logo->saveToFile("".$patch_player."/logo-".$dados_stm["login"].".png");

// Copia o fundo
$fundo = WideImage::load("".$patch_tmp."/fundo_".$hash.".jpg");
$fundo = $fundo->resize(640, 1136);
$fundo->saveToFile("".$patch_player."/background-".$dados_stm["login"].".jpg");

// Cria icone para o Play
$play_icone = WideImage::load("".$patch_tmp."/logo_".$hash.".png");
$play_icone = $play_icone->resize(512, 512);
$play_icone->saveToFile("".$patch_app."/arquivos_google_play/img-play-logo.png");

// Cria a imagem de destaque para o Play com a logo da radio
$destaque = WideImage::load("".$patch_app."/arquivos_google_play/img-play-destaque.jpg");
$logo_destaque = WideImage::load("".$patch_tmp."/logo_".$hash.".png");
$play_destaque = $destaque->merge($logo_destaque, 'center', 'center', 100);
$play_destaque->saveToFile("".$patch_app."/arquivos_google_play/img-play-destaque.jpg");

// Cria o print do app para o Play com a logo da radio
$printapp_base = WideImage::load("".$patch_app."/arquivos_google_play/img-play-app.png");
$printapp_fundo = WideImage::load("".$patch_tmp."/fundo_".$hash.".jpg");
$printapp_logo = WideImage::load("".$patch_tmp."/logo_".$hash.".png");

$play_printapp = $printapp_fundo->merge($printapp_base, 'center', 'center', 100);
$play_printapp = $play_printapp->merge($printapp_logo, 'center', 'top+120', 100);
$play_printapp->saveToFile("".$patch_app."/arquivos_google_play/img-play-app.png");

// Escreve nome da radio no print do app
$printapp = WideImage::load("".$patch_app."/arquivos_google_play/img-play-app.png");
$printapp_canvas = $printapp->getCanvas();
$printapp_canvas->useFont("".$patch_app."/Roboto-Regular.ttf", 25, $printapp->allocateColor(255, 255, 255));
$printapp_canvas->writeText("center", "top+620", formatar_nome_radio2($webtv_nome));
$printapp->saveToFile("".$patch_app."/arquivos_google_play/img-play-app.png");

// Cria tamanhos diferenciados par google play
$printapp_800x1280 = WideImage::load("".$patch_app."/arquivos_google_play/img-play-app.png");
$printapp_800x1280 = $printapp_800x1280->resize(800, 1280, 'fill');
$printapp_800x1280->saveToFile("".$patch_app."/arquivos_google_play/img-play-app-800x1280.png");

// Muda o package
replace2("".$patch_app."/app/src/main/java/com/stmvideo/webtv/".nome_app_play2($webtv_nome)."/MainActivity.java","com.stmvideo.webtv.webtv_nome",$package);
replace2("".$patch_app."/app/src/main/java/com/stmvideo/webtv/".nome_app_play2($webtv_nome)."/Player.java","com.stmvideo.webtv.webtv_nome",$package);

// Dados da Radio
replace2("".$patch_app."/app/src/main/res/values/strings.xml","WEBTV_NOME",utf8_encode(str_replace("&","&amp;",$webtv_nome)));
replace2("".$patch_app."/app/src/main/res/values/strings.xml","URL_PLAYER","https://".$url_player."/player-app/".$dados_stm["login"]."");

replace2("".$patch_app."/app/build.gradle","com.stmvideo.webtv.webtv_nome",$package);
replace2("".$patch_app."/app/src/main/AndroidManifest.xml","com.stmvideo.webtv.webtv_nome",$package);

if($_POST["versao"] == '1.0') {
$codigo_versao = 1;
} elseif($_POST["versao"] == '1.1') {
$codigo_versao = 2;
} elseif($_POST["versao"] == '1.2') {
$codigo_versao = 3;
} elseif($_POST["versao"] == '1.3') {
$codigo_versao = 4;
} elseif($_POST["versao"] == '1.4') {
$codigo_versao = 5;
} elseif($_POST["versao"] == '1.5') {
$codigo_versao = 6;
} elseif($_POST["versao"] == '1.6') {
$codigo_versao = 7;
} elseif($_POST["versao"] == '1.7') {
$codigo_versao = 8;
} elseif($_POST["versao"] == '1.8') {
$codigo_versao = 9;
} elseif($_POST["versao"] == '1.9') {
$codigo_versao = 10;
} elseif($_POST["versao"] == '1.10') {
$codigo_versao = 11;
} elseif($_POST["versao"] == '1.11') {
$codigo_versao = 12;
} elseif($_POST["versao"] == '1.12') {
$codigo_versao = 13;
} elseif($_POST["versao"] == '1.13') {
$codigo_versao = 14;
} elseif($_POST["versao"] == '1.14') {
$codigo_versao = 15;
} elseif($_POST["versao"] == '1.15') {
$codigo_versao = 16;
} elseif($_POST["versao"] == '1.16') {
$codigo_versao = 17;
} elseif($_POST["versao"] == '1.17') {
$codigo_versao = 18;
} elseif($_POST["versao"] == '1.18') {
$codigo_versao = 19;
} elseif($_POST["versao"] == '1.19') {
$codigo_versao = 20;
} elseif($_POST["versao"] == '1.20') {
$codigo_versao = 21;
} elseif($_POST["versao"] == '1.20') {
$codigo_versao = 21;
} elseif($_POST["versao"] == '1.20') {
$codigo_versao = 21;
} elseif($_POST["versao"] == '1.20') {
$codigo_versao = 21;
} elseif($_POST["versao"] == '1.20') {
$codigo_versao = 21;
} elseif($_POST["versao"] == '1.20') {
$codigo_versao = 21;
} elseif($_POST["versao"] == '1.20') {
$codigo_versao = 21;
} elseif($_POST["versao"] == '1.20') {
$codigo_versao = 21;
} elseif($_POST["versao"] == '1.20') {
$codigo_versao = 21;
} elseif($_POST["versao"] == '1.20') {
$codigo_versao = 21;
} elseif($_POST["versao"] == '1.20') {
$codigo_versao = 21;
} elseif($_POST["versao"] == '1.20') {
$codigo_versao = 21;
} elseif($_POST["versao"] == '2.0') {
$codigo_versao = 22;
} elseif($_POST["versao"] == '2.1') {
$codigo_versao = 23;
} elseif($_POST["versao"] == '2.2') {
$codigo_versao = 24;
} elseif($_POST["versao"] == '2.3') {
$codigo_versao = 25;
} elseif($_POST["versao"] == '2.4') {
$codigo_versao = 26;
} elseif($_POST["versao"] == '2.5') {
$codigo_versao = 27;
} elseif($_POST["versao"] == '2.6') {
$codigo_versao = 28;
} elseif($_POST["versao"] == '2.7') {
$codigo_versao = 29;
} elseif($_POST["versao"] == '2.8') {
$codigo_versao = 30;
} elseif($_POST["versao"] == '2.9') {
$codigo_versao = 31;
} elseif($_POST["versao"] == '3.0') {
$codigo_versao = 32;
} elseif($_POST["versao"] == '4.0') {
$codigo_versao = 33;
} elseif($_POST["versao"] == '5.0') {
$codigo_versao = 34;
} else {
$codigo_versao = 1;
}

replace2("".$patch_app."/app/build.gradle","codigo_versao",$codigo_versao);
replace2("".$patch_app."/app/build.gradle","numero_versao",$_POST["versao"]);

// Muda o idioma do app conforme o idioma do painel
if($_POST["idioma_painel"] == "pt-br") {

replace2("".$patch_app."/app/src/main/res/values/strings.xml","MSG_SHARE","Gostaria de compartilhar meu app favorito com você.");

} elseif($_POST["idioma_painel"] == "en-us") {

replace2("".$patch_app."/app/src/main/res/values/strings.xml","MSG_SHARE","I want to share my favorite app with you.");

} else {

replace2("".$patch_app."/app/src/main/res/values/strings.xml","MSG_SHARE","Me gustaria compartir mi app favorito con tu.");

}

// Remove o source do app
@unlink("".$patch_tmp."/logo_".$hash.".png");
@unlink("".$patch_tmp."/icone_".$hash.".png");
@unlink("".$patch_tmp."/fundo_".$hash.".jpg");

// Compila o app
$nome_apk = nome_app_apk2($_POST["webtv_nome"]);

//Bug fix
remover_source_app2("/home/painelvideo/public_html/app/apps/".$hash."/app/src/main/java/com/stmvideo/webtv/webtv_nome");

// Compila o App
shell_exec("export JAVA_HOME=/usr;export PATH=\$JAVA_HOME/bin:\$PATH;cd ".$_SERVER['DOCUMENT_ROOT']."/app/apps/".$hash.";./gradlew bundleRelease;./gradlew assembleRelease");

// Assina o app com certificado
if($_POST["certificado"] == "padrao") {

shell_exec("export JAVA_HOME=/usr;export PATH=\$JAVA_HOME/bin:\$PATH;/opt/android-sdk-linux/build-tools/28.0.3/apksigner sign --ks-pass pass:EE4F5AD2D81078B62EBA6EA5E8 --ks /home/painelvideo/public_html/app/apps/".$hash."/certificado.jks --out /home/painelvideo/public_html/app/apps/".$hash."/arquivos_google_play/App-".$nome_apk.".apk /home/painelvideo/public_html/app/apps/".$hash."/app/build/outputs/apk/release/app-release-unsigned.apk;jarsigner -verbose -sigalg SHA256withRSA -digestalg SHA-256 -keystore /home/painelvideo/public_html/app/apps/".$hash."/certificado.jks -storepass EE4F5AD2D81078B62EBA6EA5E8 -keypass EE4F5AD2D81078B62EBA6EA5E8 /home/painelvideo/public_html/app/apps/".$hash."/app/build/outputs/bundle/release/app.aab chave;cp -f /home/painelvideo/public_html/app/apps/".$hash."/app/build/outputs/bundle/release/app.aab /home/painelvideo/public_html/app/apps/".$hash."/arquivos_google_play/App-".$nome_apk.".aab");

}

if($_POST["certificado"] == "novo") {

//Cria o certificado
$nome_certificado = md5($nome_apk);

shell_exec("export JAVA_HOME=/usr;export PATH=\$JAVA_HOME/bin:\$PATH;keytool -genkey -alias streaming -keyalg RSA -keystore /home/painelvideo/public_html/app/keys/".$nome_certificado.".jks -dname 'CN=Streaming, OU=Streaming, O=Streaming, L=Streaming, S=Brasil, C=BR' -storepass ".$nome_certificado." -keypass ".$nome_certificado." -validity 365000");

// Assina o app com certificado
shell_exec("export JAVA_HOME=/usr;export PATH=\$JAVA_HOME/bin:\$PATH;/opt/android-sdk-linux/build-tools/28.0.3/apksigner sign --ks-pass pass:".$nome_certificado." --ks /home/painelvideo/public_html/app/keys/".$nome_certificado.".jks --out /home/painelvideo/public_html/app/apps/".$hash."/arquivos_google_play/App-".$nome_apk.".apk /home/painelvideo/public_html/app/apps/".$hash."/app/build/outputs/apk/release/app-release-unsigned.apk;jarsigner -verbose -sigalg SHA256withRSA -digestalg SHA-256 -keystore /home/painelvideo/public_html/app/keys/".$nome_certificado.".jks -storepass ".$nome_certificado." -keypass ".$nome_certificado." /home/painelvideo/public_html/app/apps/".$hash."/app/build/outputs/bundle/release/app.aab streaming;cp -f /home/painelvideo/public_html/app/apps/".$hash."/app/build/outputs/bundle/release/app.aab /home/painelvideo/public_html/app/apps/".$hash."/arquivos_google_play/App-".$nome_apk.".aab");

mysqli_query($conexao,"Update streamings set app_certificado = '".$nome_certificado."' where codigo = '".$dados_stm["codigo"]."'");

}

if($_POST["certificado"] == "personalizado") {

shell_exec("export JAVA_HOME=/usr;export PATH=\$JAVA_HOME/bin:\$PATH;/opt/android-sdk-linux/build-tools/28.0.3/apksigner sign --ks-pass pass:".$dados_stm["app_certificado"]." --ks /home/painelvideo/public_html/app/keys/".$dados_stm["app_certificado"].".jks --out /home/painelvideo/public_html/app/apps/".$hash."/arquivos_google_play/App-".$nome_apk.".apk /home/painelvideo/public_html/app/apps/".$hash."/app/build/outputs/apk/release/app-release-unsigned.apk;jarsigner -verbose -sigalg SHA256withRSA -digestalg SHA-256 -keystore /home/painelvideo/public_html/app/keys/".$dados_stm["app_certificado"].".jks -storepass ".$dados_stm["app_certificado"]." -keypass ".$dados_stm["app_certificado"]." /home/painelvideo/public_html/app/apps/".$hash."/app/build/outputs/bundle/release/app.aab streaming;cp -f /home/painelvideo/public_html/app/apps/".$hash."/app/build/outputs/bundle/release/app.aab /home/painelvideo/public_html/app/apps/".$hash."/arquivos_google_play/App-".$nome_apk.".aab");

}

if(file_exists("/home/painelvideo/public_html/app/apps/".$hash."/arquivos_google_play/App-".$nome_apk.".apk") && file_exists("/home/painelvideo/public_html/app/apps/".$hash."/arquivos_google_play/App-".$nome_apk.".aab")) {

// Cria o zip com o conteudo para publicação no google play
$zip = new ZipArchive();
if ($zip->open("/home/painelvideo/public_html/app/apps/".$hash.".zip", ZIPARCHIVE::CREATE)!==TRUE) {
    die("Não foi possível criar o arquivo ZIP: ".$hash.".zip");
}

$zip->addEmptyDir("".$nome_apk."");
$zip->addFile("/home/painelvideo/public_html/app/apps/".$hash."/arquivos_google_play/App-".$nome_apk.".apk","".$nome_apk."/App-".$nome_apk.".apk");
$zip->addFile("/home/painelvideo/public_html/app/apps/".$hash."/arquivos_google_play/App-".$nome_apk.".aab","".$nome_apk."/App-".$nome_apk.".aab");
$zip->addFile("/home/painelvideo/public_html/app/apps/".$hash."/arquivos_google_play/img-play-logo.png","".$nome_apk."/img-play-logo.png");
$zip->addFile("/home/painelvideo/public_html/app/apps/".$hash."/arquivos_google_play/img-play-destaque.jpg","".$nome_apk."/img-play-destaque.jpg");
$zip->addFile("/home/painelvideo/public_html/app/apps/".$hash."/arquivos_google_play/img-play-app.png","".$nome_apk."/img-play-app.png");
$zip->addFile("/home/painelvideo/public_html/app/apps/".$hash."/arquivos_google_play/img-play-app-800x1280.png","".$nome_apk."/img-play-app-800x1280.png");
$status=$zip->getStatusString();
$zip->close();

if(!file_exists("/home/painelvideo/public_html/app/apps/".$hash.".zip")) {
shell_exec("cd "."/home/painelvideo/public_html/app/apps/;/usr/bin/zip -1 ".$hash.".zip ".$hash.";/usr/bin/zip -1 ".$hash.".zip ".$hash."/arquivos_google_play/*");
}

// Remove source
if($hash != "") {
remover_source_app2("/home/painelvideo/public_html/app/apps/".$hash."");
}

// Insere os dados no banco de dados
mysqli_query($conexao,"INSERT INTO apps (codigo_stm,package,data,hash,zip,compilado,status) VALUES ('".$dados_stm["codigo"]."','".$package."',NOW(),'".$hash."','".$hash.".zip','sim','1')");

// Atualiza configuracoes do app com logo e fundo
mysqli_query($conexao,"Update streamings set app_nome = '".$_POST["webtv_nome"]."', app_url_logo = '/app/logo-".$dados_stm["login"].".png', app_url_icone = '/app/icone-".$dados_stm["login"].".jpg', app_url_background = '/app/background-".$dados_stm["login"].".jpg' where codigo = '".$dados_stm["codigo"]."'");

} 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_info_streaming_app_android_requisicao_em_andamento'].'</div>';

}

header("Location: /app-android-web");
exit();

}

if($_POST["acao_form"] == "configurar") {

if($_FILES["logo"]["tmp_name"]) {
@copy($_FILES["logo"]["tmp_name"],"/home/painelvideo/public_html/player/app/logo-".$dados_stm["login"].".png");
}
if($_FILES["fundo"]["tmp_name"]) {
@copy($_FILES["fundo"]["tmp_name"],"/home/painelvideo/public_html/player/app/background-".$dados_stm["login"].".jpg");
}

$app_url_chat = ($_POST["ativar_chat"]) ? $_POST["app_url_chat"] : "";
$app_url_camera_studio = ($_POST["ativar_camera_studio"]) ? $_POST["app_url_camera_studio"] : "";
$app_url_pedir_musica = ($_POST["ativar_pedido_musica"]) ? $_POST["app_url_pedir_musica"] : "";

$app_whatsapp = str_replace("+", "", $_POST["app_whatsapp"]);
$app_whatsapp = str_replace(" ", "", $_POST["app_whatsapp"]);
$app_whatsapp = str_replace("(", "", $_POST["app_whatsapp"]);
$app_whatsapp = str_replace(")", "", $_POST["app_whatsapp"]);

// Atualiza configuracoes do app com logo e fundo
mysqli_query($conexao,"Update streamings set app_email = '".$_POST["app_email"]."', app_whatsapp = '".$app_whatsapp."', app_url_facebook = '".$_POST["app_url_facebook"]."', app_url_instagram = '".$_POST["app_url_instagram"]."', app_url_twitter = '".$_POST["app_url_twitter"]."', app_url_site = '".$_POST["app_url_site"]."', app_cor_texto = '".$_POST["app_cor_texto"]."', app_cor_menu_claro = '".$_POST["app_cor_menu_claro"]."', app_cor_menu_escuro = '".$_POST["app_cor_menu_escuro"]."', app_url_logo = '/app/logo-".$dados_stm["login"].".png', app_url_icone = '/app/icone-".$dados_stm["login"].".jpg', app_url_background = '/app/background-".$dados_stm["login"].".jpg', app_url_chat = '".$app_url_chat."', app_text_prog = '".$_POST["app_text_prog"]."', app_text_hist = '".$_POST["app_text_hist"]."', app_url_youtube = '".$_POST["app_url_youtube"]."' where codigo = '".$dados_stm["codigo"]."'");

$_SESSION["status_acao"] = '<div class="alert alert-success text-center" role="alert">'.$lang['lang_info_config_painel_resultado_ok'].'</div>';

header("Location: /app-android-web");
exit();
}

/////////////////////////////////////////////////
/////////////////// Idioma //////////////////////
/////////////////////////////////////////////////

if($dados_stm["idioma_painel"] == "pt-br") {

$lang[ 'lang_info_streaming_app_android_tab_app_pronto' ] = 'App Pronto' ;
$lang[ 'lang_info_streaming_app_android_tab_criar_app' ] = 'Criar App' ;
$lang[ 'lang_info_streaming_app_android_tab_configurar_app' ] = 'Configurar App' ;
$lang[ 'lang_info_streaming_app_android_info_configuracoes' ] = 'As demais configura&ccedil;&otilde;es do app, como site, redes sociais e outros ser&atilde;o configurados aqui ap&oacute;s criar o app.' ;
$lang[ 'lang_info_streaming_app_android_info_configuracoes2' ] = 'Ao alterar as configura&ccedil;&otilde;es abaixo, as mesmas ser&atilde;o atualizadas automaticamente no app sem precisar criar um novo.' ;
$lang[ 'lang_info_streaming_app_android_info_desativar_campo' ] = '(deixe este campo em branco para desativa-lo)';
$lang[ 'lang_info_streaming_app_android_app_cor_texto' ] = 'Cor Texto';
$lang[ 'lang_info_streaming_app_android_app_cor_menu_claro' ] = 'Cor Menu Claro';
$lang[ 'lang_info_streaming_app_android_app_cor_menu_escuro' ] = 'Cor Menu Escuro';

} else if($dados_stm["idioma_painel"] == "en") {

$lang[ 'lang_info_streaming_app_android_tab_app_pronto' ] = 'App Created' ;
$lang[ 'lang_info_streaming_app_android_tab_criar_app' ] = 'Create App' ;
$lang[ 'lang_info_streaming_app_android_tab_configurar_app' ] = 'Configure App' ;
$lang[ 'lang_info_streaming_app_android_info_configuracoes' ] = 'The other settings of the app, such as website, social networks and others will be configured here after creating the app.' ;
$lang[ 'lang_info_streaming_app_android_info_configuracoes2' ] = 'When changing the settings below, they will be updated automatically in the app without having to create a new one.' ;
$lang[ 'lang_info_streaming_app_android_info_desativar_campo' ] = '(leave empty to disable displaying)';
$lang[ 'lang_info_streaming_app_android_app_cor_texto' ] = 'Text Color';
$lang[ 'lang_info_streaming_app_android_app_cor_menu_claro' ] = 'Menu Color Light';
$lang[ 'lang_info_streaming_app_android_app_cor_menu_escuro' ] = 'Menu Color Dark';

} else {

$lang[ 'lang_info_streaming_app_android_tab_app_pronto' ] = 'App Listo' ;
$lang[ 'lang_info_streaming_app_android_tab_criar_app' ] = 'Crear App' ;
$lang[ 'lang_info_streaming_app_android_tab_configurar_app' ] = 'Configurar App' ;
$lang[ 'lang_info_streaming_app_android_info_configuracoes' ] = 'Las otras configuraciones de la aplicación, como sitio web, redes sociales y otras, se configurarán aquí después de crear la aplicación.' ;
$lang[ 'lang_info_streaming_app_android_info_configuracoes2' ] = 'Al cambiar la configuración a continuación, los datos se actualizarán automáticamente en la aplicación sin tener que crear uno nuevo.' ;
$lang[ 'lang_info_streaming_app_android_info_desativar_campo' ] = '(deje este campo en blanco para deshabilitarlo)';
$lang[ 'lang_info_streaming_app_android_app_cor_texto' ] = 'Color Texto';
$lang[ 'lang_info_streaming_app_android_app_cor_menu_claro' ] = 'Color Menu Claro';
$lang[ 'lang_info_streaming_app_android_app_cor_menu_escuro' ] = 'Color Menu Oscuro';

}
?>
<!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["login"]; ?></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 href="https://cdn.jsdelivr.net/npm/summernote@0.8.18/dist/summernote.min.css" rel="stylesheet">
  <?php if($dados_stm["tema_dark"] == "sim") { ?>
  <link rel="stylesheet" href="/inc/theme-dark.css">
  <?php } else { ?>
  <link rel="stylesheet" href="/inc/theme.css">
  <?php } ?>
  <link rel="shortcut icon" href="/img/favicon.ico" />
  <script type="text/javascript" src="/inc/ajax-streaming.js"></script>
  <script type="text/javascript" src="/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="/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"><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 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 $login_code; ?>');"> <?php echo $lang['lang_botao_titulo_ligar']; ?> Streaming</a>
              <a class="dropdown-item text-warning" href="javascript:reiniciar_streaming('<?php echo $login_code; ?>');"> <?php echo $lang['lang_botao_titulo_reiniciar']; ?> Streaming</a>
            </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 $login_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>
    <div class="container-fluid page-body-wrapper">
      <?php require_once("menu.php"); ?>
      <!-- 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">            
            <?php if($dados_app_criado["codigo"] > 0) { ?>
            <div class="col-lg-12">
              <div class="card">
                  <div class="card-header">
                    <header>App Android</header>
                  </div>
                <div class="card-body">
                    <table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td width="50%" height="500" align="center"><iframe src="https://<?php echo $url_player; ?>/player-app/<?php echo $dados_stm["login"]; ?>" style="width:70%; height:490px" frameborder="0" onmousewheel=""></iframe></td>
    <td width="50%" align="center"><div class="alert alert-info text-center" role="alert"><?php echo $lang['lang_info_streaming_app_android_requisicao_concluida']; ?><br /><br />
      <br />
        <a href="/app/apps/<?php echo $dados_app_criado["zip"]; ?>" target="_blank"><img src="data:image/png;base64, " alt="Download" width="96" height="96" border="0" /></a><br>
    <br>
    <a href="javascript:remover_app_android('<?php echo code_decode($dados_app_criado["codigo"],"E"); ?>');"><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAFgklEQVR42sVXW0xdRRRdB+6j2Is8bUVQCgQ1amJJizH+WFqlxZpqY/2z0dRXQIxI2lCjaPFHsRVbJFCtNtEY+4N+tApCtNjERyJYEp+phiKxLbby7OVC79s158xczrmcy0ObuJOVmXPP3Flr79mzZ46G/9m0JY7PJtYRa4gC4ko5xyQxSPQTPcTfl1OAGLOZqHYAG0oAh2AvlmqSiBHid6KPOAmEQoaIFuIYEf0vAsiH1jzg9ofYuZ/IdQOe5YCTzMlSQJgIRoBpH3DOD3zM5/eJP4Hv2FQR3/8bATXkenUH4N5OprwMIFUQkiBEokjEcE1BzJTsYcM/zfBxeIIiGIpDQIB/eY4/NS1FQNNKCmjg+zszgRwyRMathAvBmQ5MMDxfjQH1/GkYaBZOLUbAi9cAexod0Mo4iWdsrrea6Y/qNw5BSLaxqFBAhA58y2jsDCF6DqBPOhIKKOfyduxzInkrO+4J02RxxIlMiPDLNvZfOvIFl60miLDPSOguOwEpxC/VGlbVcXN5Jq3kS7UgjFxQEQmnMZu9wIEI/uDjTfK1RcAz1wP7j5C88KI1tJaQuVyIBgK2pPHvxH99MHaJmGucc2/n3L8ZuXDALEC0p+rdKK7l6GhIqo6LwBW7dsG9bRsmN25EZGLCQp6Uno60ri7429sxvXevRcSUbDUWkg+4o172Cw24UUyvBKyhuN4TKdDyZwxSlVDKlpPc09gITdMQ7O3FuBAxPm6QZ2Qgg+TO0lJEo1FM1dXBZxIhlmNaOjPGhd40g6jXqKb9SkDtHUl4/SizVgsZxOYge0ieKsmVBShirLxc72d2d8NFcmVChJcipkwifNIpMAqPkeCbCJ7l034147vVTuxoCBoqAzL8unepqVjR3w9HUdGcNRcihJnJlYUGBnChpAQRr9eSlGL+ZifwdhDvsPu4EvDJvmRsfiRsDFADlTny87Hi+HE4CguxGAudPo0L69cjNDQ0GxWZC6L9iHmwJ6yfE1uUgM6DGjY9EDXCP20zqRCxsqcHzoKCecmDg4M4X1ZmIVc2LSPbQdbdUXzGbkVMwFvMja1ywHSCyYWIHEbCmSASQXo+HOe52Wbk/J3EblgFHOPZee+DcoAvgYBkZnsOE27Z2rW27y/19WGYiRmWu2POezm/iH09rEtw6AUmZzWMJfDakXOf5wpym4SzkDAxzwoRcXVCCRDzHybe1A9KPKEE1PCsf6MNRpJ4Ya0BwvM87vOUBchjoaaIM6wT5kiIef2yZfjRzcrLplkJWM3bzUnep7QkuVZ++SLJ40E+192OPDA4qLcum8QUIoaYjBGfsaAi9CEJVo8o47Oa3R/MpfjX94AbNkjvL0q1ovhc3dKCzMpKayFiwg0y4YQVUKDLlJiiEI21teGv6mq9D8xW1hNELQ89NjcrYmVP38aQtJvWa0a9IXEuRWRVVemPfkkekNnu4u4QItxSxGhrK86SHJI8YsKjwm2gks3BeAHLiJ+ZHIVbpPcieIGYBkNEakUFBhjaQNxWEyKKWCe8nZ06ufJcCRBPnxIvGffXW9TU8feLu3lsdx5l3l2XQERyVhZCIyO2yefIzkZ4dDRGrmH2WBdyH+ZKsBreJVcCdgKE1TOlGo7w3VWm7FVbaDEWf2U7TzzJ7hljA7wWP9bOmq7l1mR11IoxezEJwHpQxVuShNnzU8RO41L6CrvP24lNZDVMikZeXVzim8AB6y0pjLn3RfPFVQj9kKATlwJ64qMtUbTmM3FpaGM+lHL9cA+Mb7H5ruOi/nVIct6Cv4aR8T/Ot1yLWdL7iKcYhXW3MhgihblE8EhSUTP4FYSfDKYgo/M59GqrnzsLTr4U4/eK/nEqPtlWEWlSg/o45achvoTxubgoW6qAy27/ABy1Jj/tibxvAAAAAElFTkSuQmCC" alt="Remover" width="32" height="32" border="0" /></a></div><br><br><div class="alert alert-warning text-center" role="alert"><?php echo $lang['lang_info_streaming_app_android_info_configuracoes2']; ?></div></td>
  </tr>
</table>
                </div>
              </div>
            </div>
            <?php } ?>            
            <?php if(!isset($dados_app_criado["codigo"]) || $dados_app_criado["status"] == 2) { ?>
            <div class="col-lg-12">
              <div class="card">
                  <div class="card-header">
                    <header><?php echo $lang['lang_info_streaming_app_android_tab_criar_app']; ?></header>
                  </div>
                <div class="card-body">
                    <form method="post" action="/app-android-web" style="padding:0px; margin:0px" enctype="multipart/form-data" name="criar">
                    <table width="100%" border="0" cellpadding="0" cellspacing="0">
    <tr>
      <td width="20%" height="50" class="texto_padrao_destaque"><?php echo $lang['lang_info_streaming_app_android_tv_nome']; ?></td>
      <td width="80%" class="texto_padrao_pequeno">
        <input name="webtv_nome" type="text" id="webtv_nome" style="width:100%" value="" class="form-control" />
        <?php echo $lang['lang_info_streaming_app_android_info_tv_nome']; ?></td>
    </tr>
    <tr>
      <td height="50" class="texto_padrao_destaque"><?php echo $lang['lang_info_streaming_app_android_versao']; ?></td>
      <td class="texto_padrao_pequeno">
        <select name="versao" id="versao" class="form-control">
          <option value="1.0" selected="selected">1.0</option>
          <option value="1.1">1.1</option>
          <option value="1.2">1.2</option>
          <option value="1.3">1.3</option>
          <option value="1.4">1.4</option>
          <option value="1.5">1.5</option>
          <option value="1.6">1.6</option>
          <option value="1.7">1.7</option>
          <option value="1.8">1.8</option>
          <option value="1.9">1.9</option>
          <option value="1.10">1.10</option>
          <option value="1.11">1.11</option>
          <option value="1.12">1.12</option>
          <option value="1.13">1.13</option>
          <option value="1.14">1.14</option>
          <option value="1.15">1.15</option>
          <option value="1.16">1.16</option>
          <option value="1.17">1.17</option>
          <option value="1.18">1.18</option>
          <option value="1.19">1.19</option>
          <option value="1.20">1.20</option>
          <option value="2.0">2.0</option>
          <option value="2.1">2.1</option>
          <option value="2.2">2.2</option>
          <option value="2.3">2.3</option>
          <option value="2.4">2.4</option>
          <option value="2.5">2.5</option>
          <option value="2.6">2.6</option>
          <option value="2.7">2.7</option>
          <option value="2.8">2.8</option>
          <option value="2.9">2.9</option>
          <option value="3.0">3.0</option>
          <option value="4.0">4.0</option>
          <option value="5.0">5.0</option>
        </select>
        <?php echo $lang['lang_info_streaming_app_android_info_versao']; ?></td>
    </tr>
    <tr>
      <td height="50" class="texto_padrao_destaque">Certificado</td>
      <td class="texto_padrao_pequeno"><?php if($dados_stm["app_certificado"] == "padrao") { ?>
        <input name="certificado" type="radio" id="radio" value="padrao" checked="checked" />
        &nbsp;Usa el estándar&nbsp;<input type="radio" name="certificado" id="radio" value="novo" />&nbsp;Crea tu propio certificado(solo si está creando la aplicación por primera vez)&nbsp;<?php } ?><?php if($dados_stm["app_certificado"] != "padrao") { ?><input name="certificado" type="radio" id="certificado" value="personalizado" checked="checked" />
        &nbsp;Usa el Certificado propio<?php } ?></td>
    </tr>
    <tr>
      <td width="20%" height="50" class="texto_padrao_destaque"><?php echo $lang['lang_info_streaming_app_android_tv_logo']; ?></td>
      <td width="80%" class="texto_padrao_pequeno"><div class="input-group"><input name="logo" type="file" id="logo" style="width:60%" class="form-control" /><span class="input-group-append" id="basic-addon3"><label class="input-group-text">PNG / 300x300</label></span></div></td>
    </tr>
    <tr>
      <td height="50" class="texto_padrao_destaque"><?php echo $lang['lang_info_streaming_app_android_tv_icone']; ?></td>
      <td class="texto_padrao_pequeno"><div class="input-group"><input name="icone" type="file" id="icone" style="width:60%" class="form-control" /><span class="input-group-append" id="basic-addon3"><label class="input-group-text">PNG / 144x144</label></span></div></td>
    </tr>
    <tr>
      <td height="50" class="texto_padrao_destaque">Background</td>
      <td class="texto_padrao_pequeno"><div class="input-group"><input name="fundo" type="file" id="fundo" style="width:60%" class="form-control" /><span class="input-group-append" id="basic-addon3"><label class="input-group-text">JPG / 640x1136</label></span></div></td>
    </tr>
    <tr>
            <td height="40" colspan="2" align="center"><button type="submit" class="btn btn-info"><?php echo $lang['lang_info_streaming_app_android_botao_submit']; ?></button><input name="acao_form" type="hidden" id="acao_form" value="criar" /><input name="idioma_painel" type="hidden" value="<?php echo $dados_stm["idioma_painel"]; ?>" /><input name="login" type="hidden" value="<?php echo $dados_stm["login"]; ?>" /></td>
          </tr>
  </table>
  </form>
                </div>
              </div>
            </div>            
            <?php } ?>
            <?php if($dados_app_criado["codigo"] == 0 || empty($dados_app_criado["codigo"])) { ?>
            <div class="col-lg-12">
              <div class="card">
                  <div class="card-header">
                    <header><?php echo $lang['lang_info_streaming_app_android_tab_configurar_app']; ?></header>
                  </div>
                <div class="card-body">
                    <div class="alert alert-warning text-center" role="alert"><?php echo $lang['lang_info_streaming_app_android_info_configuracoes']; ?></div>
                </div>
              </div>
            </div>            
            <?php } else { ?>
            <div class="col-lg-12">
              <div class="card">
                  <div class="card-header">
                    <header><?php echo $lang['lang_info_streaming_app_android_tab_configurar_app']; ?></header>
                  </div>
                <div class="card-body">
                    <form method="post" action="/app-android-web" style="padding:0px; margin:0px" enctype="multipart/form-data" name="configuracoes">
                                        <div class="alert alert-info text-center" role="alert"><?php echo $lang['lang_info_streaming_app_android_info_configuracoes2']; ?></div>
     <table width="100%" border="0" cellpadding="0" cellspacing="0">
    <tr>
      <td width="20%" height="50" class="texto_padrao_destaque">E-mail</td>
      <td width="80%" class="texto_padrao_pequeno">
        <input name="app_email" type="text" id="app_email" style="width:350px" value="<?php echo $dados_stm["app_email"]; ?>" class="form-control" /></td>
    </tr>
    <tr>
      <td width="20%" height="50" class="texto_padrao_destaque">Site</td>
      <td width="80%" class="texto_padrao_pequeno">
        <input name="app_url_site" type="text" id="app_url_site" style="width:350px" value="<?php echo $dados_stm["app_url_site"]; ?>" class="form-control" />
        <?php echo $lang['lang_info_streaming_app_android_info_desativar_campo']; ?></td>
    </tr>
    <tr>
      <td width="20%" height="50" class="texto_padrao_destaque">FaceBook</td>
      <td width="80%" class="texto_padrao_pequeno">
        <input name="app_url_facebook" type="text" id="app_url_facebook" style="width:350px" value="<?php echo $dados_stm["app_url_facebook"]; ?>" class="form-control" />
        <?php echo $lang['lang_info_streaming_app_android_info_desativar_campo']; ?></td>
    </tr>
    <tr>
      <td width="20%" height="50" class="texto_padrao_destaque">Twitter</td>
      <td width="80%" class="texto_padrao_pequeno">
        <input name="app_url_twitter" type="text" id="app_url_twitter" style="width:350px" value="<?php echo $dados_stm["app_url_twitter"]; ?>" class="form-control" />
        <?php echo $lang['lang_info_streaming_app_android_info_desativar_campo']; ?></td>
    </tr>    
    <tr>
      <td width="20%" height="50" class="texto_padrao_destaque">Instagram</td>
      <td width="80%" class="texto_padrao_pequeno">
        <input name="app_url_instagram" type="text" id="app_url_instagram" style="width:350px" value="<?php echo $dados_stm["app_url_instagram"]; ?>" class="form-control" />
        <?php echo $lang['lang_info_streaming_app_android_info_desativar_campo']; ?></td>
    </tr>
    <tr>
      <td width="20%" height="50" class="texto_padrao_destaque">Canal YouTube</td>
      <td width="80%" class="texto_padrao_pequeno">
        <input name="app_url_youtube" type="text" id="app_url_youtube" style="width:350px" value="<?php echo $dados_stm["app_url_youtube"]; ?>" class="form-control" />
        <?php echo $lang['lang_info_streaming_app_android_info_desativar_campo']; ?></td>
    </tr>
    <tr>
      <td width="20%" height="50" class="texto_padrao_destaque">WhatsApp</td>
      <td width="80%" class="texto_padrao_pequeno">
        <input name="app_whatsapp" type="text" id="app_whatsapp" style="width:350px" value="<?php echo $dados_stm["app_whatsapp"]; ?>" class="form-control" />
        +00 00000000000 <?php echo $lang['lang_info_streaming_app_android_info_desativar_campo']; ?></td>
    </tr>
    <tr>
      <td width="20%" height="100" class="texto_padrao_destaque">Texto Programa&ccedil;&atilde;o</td>
      <td width="80%" class="texto_padrao_pequeno"><textarea name="app_text_prog" id="app_text_prog" style="width:350px" rows="5"><?php echo $dados_stm["app_text_prog"]; ?></textarea></td>
    </tr>
    <tr>
      <td width="20%" height="100" class="texto_padrao_destaque">Texto Hist&oacute;ria</td>
      <td width="80%" class="texto_padrao_pequeno"><textarea name="app_text_hist" id="app_text_hist" style="width:350px" rows="5"><?php echo $dados_stm["app_text_hist"]; ?></textarea></td>
    </tr>
    <tr>
      <td height="50" class="texto_padrao_destaque"><?php echo $lang['lang_info_streaming_app_android_app_cor_texto']; ?></td>
      <td class="texto_padrao_pequeno">
        <input type="color" name="app_cor_texto" style="width:100px; height:30px" value="<?php echo $dados_stm['app_cor_texto']; ?>" class="form-control" /></td>
    </tr>
    <tr>
      <td height="50" class="texto_padrao_destaque"><?php echo $lang['lang_info_streaming_app_android_app_cor_menu_claro']; ?></td>
      <td class="texto_padrao_pequeno">
        <input type="color" name="app_cor_menu_claro" style="width:100px; height:30px" value="<?php echo $dados_stm['app_cor_menu_claro']; ?>" class="form-control" /></td>
    </tr>
    <tr>
      <td height="50" class="texto_padrao_destaque"><?php echo $lang['lang_info_streaming_app_android_app_cor_menu_escuro']; ?></td>
      <td class="texto_padrao_pequeno">
        <input type="color" name="app_cor_menu_escuro" style="width:100px; height:30px" value="<?php echo $dados_stm['app_cor_menu_escuro']; ?>" class="form-control" /></td>
    </tr>
    <tr>
      <td width="20%" height="50" class="texto_padrao_destaque"><?php echo $lang['lang_info_streaming_app_android_tv_logo']; ?></td>
      <td width="80%" class="texto_padrao_pequeno"><div class="input-group"><input name="logo" type="file" id="logo" style="width:60%" class="form-control" /><span class="input-group-append" id="basic-addon3"><label class="input-group-text">PNG / 300x300</label></span></div></td>
    </tr>
    <tr>
      <td height="50" class="texto_padrao_destaque">Background</td>
      <td class="texto_padrao_pequeno"><div class="input-group"><input name="fundo" type="file" id="fundo" style="width:60%" class="form-control" /><span class="input-group-append" id="basic-addon3"><label class="input-group-text">JPG / 640x1136</label></span></div></td>
    </tr>
          <tr>
            <td height="40" colspan="2" align="center"><button type="submit" class="btn btn-info"><?php echo $lang['lang_botao_titulo_alterar_config']; ?></button><input name="acao_form" type="hidden" id="acao_form" value="configurar" /></td>
          </tr>
  </table>
  </form>
                </div>
              </div>
            </div>
            <?php } ?>
          </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 src="https://cdn.jsdelivr.net/npm/summernote@0.8.18/dist/summernote.min.js"></script>
  <script>
  status_streaming('<?php echo $login_code; ?>');
  setInterval("status_streaming('<?php echo $login_code; ?>')",60000);
  $('#app_text_prog').summernote({
            height: 100,
            tabsize: 2
        });
        $('#app_text_hist').summernote({
            height: 100,
            tabsize: 2
        });
  </script>
</body>
</html>