|
|
|
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
|
|
|
|
<html>
|
|
|
|
|
|
|
|
|
|
<head>
|
|
|
|
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
|
|
|
|
<link rel="stylesheet" href="admin/css/validationEngine.jquery.css" type="text/css" media="screen" title="no title" charset="ISO-8859-1" />
|
|
|
|
|
<script type="text/javascript" src="admin/js/jquery-1.4.js"></script>
|
|
|
|
|
<script type="text/javascript" src="admin/js/jquery.blockUI.js?v2.29"></script>
|
|
|
|
|
<script src="admin/js/pbxAjax.js" type="text/javascript"></script>
|
|
|
|
|
<script>
|
|
|
|
|
function alerta_existe(mensagem) {
|
|
|
|
|
$.blockUI({
|
|
|
|
|
message: $('#alerta'),
|
|
|
|
|
css: {
|
|
|
|
|
width: '275px',
|
|
|
|
|
left: '10%',
|
|
|
|
|
top: '20%'
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
window.mens2.value = mensagem;
|
|
|
|
|
|
|
|
|
|
$('#volta').click(function() {
|
|
|
|
|
$.unblockUI();
|
|
|
|
|
history.back();
|
|
|
|
|
return false;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
<link href="admin/css/forms.css" rel="stylesheet" type="text/css">
|
|
|
|
|
</head>
|
|
|
|
|
|
|
|
|
|
<body>
|
|
|
|
|
<?php
|
|
|
|
|
$acao = $_GET['acao'];
|
|
|
|
|
$url = $_GET['url'];
|
|
|
|
|
$param = sprintf('&numRamal=%s&pgn=%s&bloco=%s&pg=%s', $_REQUEST['numRamal'], $_REQUEST['pgn'], $_REQUEST['bloco'], $_REQUEST['pg']);
|
|
|
|
|
$org_id = GetOrganizacao();
|
|
|
|
|
|
|
|
|
|
if ($acao == 'inseri') {
|
|
|
|
|
try {
|
|
|
|
|
foreach ($_FILES['arquivo']['name'] as $key => $v) {
|
|
|
|
|
/*
|
|
|
|
|
* Testa se as configura<EFBFBD><EFBFBD>es para acessar o sistema por ssh est<EFBFBD>o corretas.
|
|
|
|
|
*/
|
|
|
|
|
if (!vai_comando('ls /', $dbcon)) {
|
|
|
|
|
GeraExcept('N<EFBFBD>o foi poss<EFBFBD>vel realizar a opera<EFBFBD><EFBFBD>o, verifique as configura<EFBFBD><EFBFBD>es padr<EFBFBD>o!');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Verifica se o arquivo esta dispon<EFBFBD>vel no servidor.
|
|
|
|
|
*/
|
|
|
|
|
if (!is_uploaded_file($_FILES['arquivo']['tmp_name'][$key])) {
|
|
|
|
|
GeraExcept('Erro ao copiar arquivo!');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Remove caracteres inv<EFBFBD>lidos do nome do arquivo e pega a extens<EFBFBD>o.
|
|
|
|
|
*/
|
|
|
|
|
$nomeOrig = $_FILES['arquivo']['name'][$key];
|
|
|
|
|
$arquivo_tratado = strtolower(LimpaString(RemovePontoExt($nomeOrig)));
|
|
|
|
|
$arq = explode('.', $arquivo_tratado);
|
|
|
|
|
$extensao = $arq[1];
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Verifica o tamanho do nome do arquivo de som.
|
|
|
|
|
*/
|
|
|
|
|
if (strlen($arquivo_tratado) > 35) {
|
|
|
|
|
GeraExcept("Nome de arquivo muito grande");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Verifica se ja foi feito o upload do arquivo de som no servidor.
|
|
|
|
|
*/
|
|
|
|
|
if (RegistroInc($dbcon, "SELECT count(arq_nome_sistema) FROM pbx_arquivo_som WHERE arq_nome_sistema = '{$arq[0]}' AND org_id = $org_id;")) {
|
|
|
|
|
GeraExcept('Erro: Este arquivo de som ja existe!');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Verifica se o tipo do arquivo <EFBFBD> v<EFBFBD>lido.
|
|
|
|
|
*/
|
|
|
|
|
if (strtolower($extensao) != 'mp3') {
|
|
|
|
|
GeraExcept("Formato do arquivo: \"$nomeOrig\" <EFBFBD> inv<EFBFBD>lido!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Copia o arquivo para o diretorio de som
|
|
|
|
|
*/
|
|
|
|
|
if (!copy($_FILES['arquivo']['tmp_name'][$key], $path_som . $arquivo_tratado)) {
|
|
|
|
|
GeraExcept("N<EFBFBD>o foi poss<EFBFBD>vel mover o arquivo: \"$nomeOrig\" para o diret<EFBFBD>rio de som!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Converte arquivos mp3 para ulaw.
|
|
|
|
|
*/
|
|
|
|
|
$arqOrigem = $path_som . $arquivo_tratado;
|
|
|
|
|
$arqDestino = $path_som . $arq[0] . ".ulaw";
|
|
|
|
|
if ($extensao == 'mp3') {
|
|
|
|
|
$comando = "ffmpeg -i $arqOrigem -ar 8000 -ac 1 -ab 64 -f mulaw $arqDestino";
|
|
|
|
|
vai_comando($comando, $dbcon);
|
|
|
|
|
if (!file_exists($arqDestino)) {
|
|
|
|
|
GeraExcept("Erro ao converter o arquivo: \"$nomeOrig\"!");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Move o arquivo mp3 para possibilitar a escuta do mesmo.
|
|
|
|
|
*/
|
|
|
|
|
$nomeArq = $path_som . $arquivo_tratado;
|
|
|
|
|
if ($extensao == 'mp3') {
|
|
|
|
|
$mvFileSom = $path_som . GetDirArqSom($dbcon) . $arquivo_tratado;
|
|
|
|
|
$comando = "mv $nomeArq $mvFileSom";
|
|
|
|
|
vai_comando($comando, $dbcon);
|
|
|
|
|
if (!file_exists($mvFileSom)) {
|
|
|
|
|
GeraExcept("Erro ao mover o arquivo: \"$nomeOrig\"!");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Insere o arquivo no banco de dados da aplica<EFBFBD><EFBFBD>o.
|
|
|
|
|
*/
|
|
|
|
|
$login = QuotedStr(GetLogin());
|
|
|
|
|
$md5 = QuotedStr(md5_file($mvFileSom));
|
|
|
|
|
$nome = IsNull(basename($nomeOrig, ".mp3"), '', 1);
|
|
|
|
|
$nomeSistema = IsNull($arq[0], '', 1);
|
|
|
|
|
$desc = IsNull($_POST['arq_descricao'], $arq[0], 1);
|
|
|
|
|
$tamOrig = IsNull(filesize(($extensao == 'mp3') ? $mvFileSom : $arqOrigem), 0, 1);
|
|
|
|
|
$tamDest = IsNull(filesize($arqDestino), 0, 1);
|
|
|
|
|
$query = "INSERT INTO pbx_arquivo_som(arq_nome, arq_nome_sistema, arq_descricao, arq_path_origem, arq_path_destino, arq_orig_tamanho, arq_dest_tamanho, arq_md5, userreg, org_id) VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s);";
|
|
|
|
|
$query = sprintf($query, $nome, $nomeSistema, $desc, QuotedStr($mvFileSom), QuotedStr($arqDestino), $tamOrig, $tamDest, $md5, $login, $org_id);
|
|
|
|
|
$result = pg_query($dbcon, $query);
|
|
|
|
|
if (!$result) {
|
|
|
|
|
unlink($arqOrigem);
|
|
|
|
|
unlink($arqDestino);
|
|
|
|
|
GeraExcept("Erro ao adicionar o arquivo ao banco de dados!");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
echo "<script>
|
|
|
|
|
opener.location.reload();
|
|
|
|
|
fecha_popup(0,'index.php?idProg=10043&pbxRequest=1$param&acao=$acao');
|
|
|
|
|
</script>";
|
|
|
|
|
} catch (Exception $ex) {
|
|
|
|
|
Alert($ex->getMessage(), 1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
?>
|
|
|
|
|
|
|
|
|
|
<form action="index.php?idProg=11043&pbxRequest=1&acao=inseri<?php echo $param; ?>" method="post" enctype="multipart/form-data" name="form1">
|
|
|
|
|
<table border="0" align="center" cellpadding="8" cellspacing="0" class="tabela" width="98%">
|
|
|
|
|
<tr bordercolor="#EAEAEA" bgcolor="#EAEAEA" class="cabecalho2">
|
|
|
|
|
<td>
|
|
|
|
|
<div align="center" class="cabecalho">UPLOAD DE SONS</div>
|
|
|
|
|
</td>
|
|
|
|
|
</tr>
|
|
|
|
|
|
|
|
|
|
<tr class="labels" bordercolor="#EAEAEA" bgcolor="#EAEAEA">
|
|
|
|
|
<td>
|
|
|
|
|
<fieldset>
|
|
|
|
|
<legend class="labels">Arquivo(s)</legend>
|
|
|
|
|
<input name="arquivo[]" multiple="multiple" style="width:99%" class="validate[required] caixas" type="file" id="arquivo" size="70" style="font-size:14px; " />
|
|
|
|
|
<input type="text" class="custom-file-input" name="som[]" id="som" hidden />
|
|
|
|
|
<table id="filesend">
|
|
|
|
|
</table>
|
|
|
|
|
</fieldset>
|
|
|
|
|
|
|
|
|
|
</td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr class="labels" bordercolor="#EAEAEA" bgcolor="#EAEAEA" id="description">
|
|
|
|
|
<td>
|
|
|
|
|
<fieldset>
|
|
|
|
|
<legend class="labels">Descri<EFBFBD><EFBFBD>o</legend>
|
|
|
|
|
<input name="arq_descricao" style="width:99%" type="text" class="caixas" id="arq_descricao" value="" size="50" maxlength="255" />
|
|
|
|
|
</fieldset>
|
|
|
|
|
</td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr bordercolor="#EAEAEA" bgcolor="#EAEAEA">
|
|
|
|
|
<td align="center">
|
|
|
|
|
<input name="Submit" type="submit" class="labels" value="Salvar">
|
|
|
|
|
<input name="Submit2" type="button" class="labels" value="Cancelar" onclick="fecha_popup();" />
|
|
|
|
|
</td>
|
|
|
|
|
</tr>
|
|
|
|
|
</table>
|
|
|
|
|
</form>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
$(function() {
|
|
|
|
|
$("#arquivo").change(function() {
|
|
|
|
|
let file = []
|
|
|
|
|
let som = []
|
|
|
|
|
let filesup = $(this)[0].files
|
|
|
|
|
descriptionSound(filesup)
|
|
|
|
|
$("#filesend tr").remove()
|
|
|
|
|
Object.keys(filesup).forEach((value) => {
|
|
|
|
|
let size = formatSizeUnits(filesup[value].size.toString());
|
|
|
|
|
$("#filesend").append("<tr><td id=\"itens\"><img src='imgSite/Raise.png'> <strong>" + filesup[value].name + "</strong></td> <td> " + size + "</td> </tr>")
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
function descriptionSound(array) {
|
|
|
|
|
if (array.length > 1) {
|
|
|
|
|
$("#description").hide()
|
|
|
|
|
} else {
|
|
|
|
|
$("#description").show()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function formatSizeUnits(bytes) {
|
|
|
|
|
if (bytes >= 1073741824) {
|
|
|
|
|
bytes = (bytes / 1073741824).toFixed(2) + " GB";
|
|
|
|
|
} else if (bytes >= 1048576) {
|
|
|
|
|
bytes = (bytes / 1048576).toFixed(2) + " MB";
|
|
|
|
|
} else if (bytes >= 1024) {
|
|
|
|
|
bytes = (bytes / 1024).toFixed(2) + " KB";
|
|
|
|
|
} else if (bytes > 1) {
|
|
|
|
|
bytes = bytes + " bytes";
|
|
|
|
|
} else if (bytes == 1) {
|
|
|
|
|
bytes = bytes + " byte";
|
|
|
|
|
} else {
|
|
|
|
|
bytes = "0 bytes";
|
|
|
|
|
}
|
|
|
|
|
return bytes;
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
</body>
|
|
|
|
|
|
|
|
|
|
</html>
|