PABX da Simples IP
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

207 lines
9.1 KiB

<?php
$acao = isset($_GET['acao']) ? trim($_GET['acao']) : 'select';
$id = isset($_GET['id']) ? trim($_GET['id']) : 0;
$filtro = isset($_GET["numRamal"]) ? trim($_GET["numRamal"]) : '';
$filtroNovo = !isset($_GET["pgn"]) ? '' : sprintf("&numRamal%s&pgn=%s&bloco=%s&pg=%s", $_GET["numRamal"], $_GET["pgn"], $_GET["bloco"], $_GET["pg"]);
$recontaPag = ($acao == 'inseri') || ($acao == "deleta") || isset($_GET['pesquisa']);
$org_id = GetOrganizacao();
if (isset($_GET["audioIndisp"]) && $_GET["audioIndisp"]) {
$fileExist = 0;
$fileDisp = $_GET["audioIndisp"];
$filepath = ($path_som) . GetDirArqSom($dbcon) . $_GET["audioIndisp"];
$fileExist = @file_exists($filepath);
if (!$fileExist) {
$jsStartup[] = "alert('Arquivo não encontrado!');";
} else {
ob_clean();
header("Pragma: public");
header('Cache-Control: no-cache, must-revalidate');
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Accept-Ranges: bytes');
header('Content-Type: ' . GetMimeContentType($fileDisp));
header('Content-Disposition: attachment; filename="' . $fileDisp . '";');
header('Content-Transfer-Encoding: binary');
header('Content-Length: ' . filesize($filepath));
header('Connection: close');
readfile($filepath);
exit;
}
}
if ($acao == 'deleta') {
try {
$inTran = 0;
/*
* Consulta o caminho dos arquivos.
*/
$query = "SELECT arq_path_origem, arq_path_destino FROM pbx_arquivo_som WHERE arq_id = '$id'";
$result = pg_query($dbcon, $query);
if (!$result) {
GeraExcept("Erro ao consultar arquivo!");
}
if (!pg_num_rows($result)) {
GeraExcept("Arquivo não encontrado!");
}
$dados = pg_fetch_array($result);
$origem = $dados['arq_path_origem'];
$destino = $dados['arq_path_destino'];
/*
* Verifica as dependencias do arquivo.
*/
$nome = basename($destino);
$query = "SELECT tipo from pbx_lista_arquivo_som WHERE arq_som = '$nome' AND org_id = $org_id;";
$result = pg_query($dbcon, $query);
if (!$result) {
GeraExcept("Erro ao verificar as dependência do arquivo!");
}
if (pg_num_rows($result)) {
GeraExcept("Arquivo não pode ser excluido porque esta sendo utilizado!");
}
/*
* Apaga os arquivos.
*/
$result = pg_query($dbcon, 'begin');
if (!$result) {
GeraExcept("Erro ao iniciar a operação!");
}
$inTran++;
$result = pg_query($dbcon, "DELETE FROM pbx_arquivo_som WHERE arq_id = '$id'");
if (!$result) {
GeraExcept("Erro ao excluir o arquivo no banco de dados!");
}
vai_comando("/bin/rm -Rf {$origem}", $dbcon);
unlink($destino);
if (file_exists($destino) && file_exists($origem)) {
GeraExcept("Erro ao excluir o arquivo!");
}
$result = pg_query($dbcon, 'commit');
if (!$result) {
GeraExcept("Erro ao finalizar a operação!");
}
Alert("Arquivo excluido com sucesso!");
} catch (Exception $ex) {
if ($inTran) {
pg_query($dbcon, 'rollback');
}
Alert($ex->getMessage());
}
}
$compl = '';
if (isset($_GET['pesquisa']) && $_GET['pesquisa']) {
$compl = PreparaLike($filtro, true);
$compl = sprintf("AND (a.arq_nome ilike %s OR a.arq_descricao ilike %s)", $compl, $compl);
}
$query = "SELECT arq_id, arq_data, arq_nome, arq_nome_sistema, arq_descricao, arq_orig_tamanho, arq_dest_tamanho
FROM pbx_arquivo_som a
WHERE 1=1 $compl
ORDER BY arq_id";
$params = "&pbxRequest=1&numRamal=$filtro";
$links = PaginaDados($idProg, $query, $params, $regPagina, $offSet, $pagMostra, true);
$query .= " LIMIT $regPagina OFFSET $offSet";
?>
<table width="99%" align="center" border="0" cellpadding="2" cellspacing="0" class="filtro">
<tr>
<td colspan="2">Ramal/Bina</td>
</tr>
<tr>
<td align="left" nowrap="nowrap">
<input name="numRamal" type="text" id="numRamal" value="<?php echo $_GET["numRamal"]; ?>" onkeyup="ConsultaRamal('index.php?idProg=10043&pbxRequest=1', event);" size="20">
<input name="locaRamal" type="button" id="locaRamal" value="Localizar" onClick="ConsultaRamal('index.php?idProg=10043&pbxRequest=1&pesquisa=1', 0);">
</td>
<td align="right" nowrap="nowrap">
<a href="#" onClick="abre_janela('475', '232', 'index.php?idProg=11043&pbxRequest=1<?php echo $filtroNovo; ?>');">
<img src="images/novo.gif" width="20" height="20" border="0" align="absmiddle">NOVO ARQUIVO
</a>
</td>
</tr>
<tr>
<td colspan="2">
<table width="100%" class="grid" border="0" cellspacing="0" cellpadding="2">
<tr>
<th align="center">Id</th>
<th align="center" width="50">Data</th>
<th align="center" width="200">Nome</th>
<th align="center" width="200">Sistema </th>
<th align="center">Descrição</th>
<th align="right" width="50">Tamanho</th>
<th align="center">Ações</th>
</tr>
<?php
$result = pg_query($dbcon, $query);
while ($dados = pg_fetch_array($result)) {
$id = $dados['arq_id'];
$data = FormataDBDataHora($dados['arq_data']);
$nome = basename($dados['arq_nome'], ".mp3");
$nomeSis = $dados['arq_nome_sistema'];
$descricao = $dados['arq_descricao'];
$tamOrig = ConvertSize($dados['arq_orig_tamanho']);
$tamDest = ConvertSize($dados['arq_dest_tamanho']);
?>
<tr>
<td align="center"><?php echo $id; ?></td>
<td align="center"><?php echo $data; ?></td>
<td align="left"><?php echo $nome; ?></td>
<td align="left"><?php echo $nomeSis; ?></td>
<td align="left"><?php echo $descricao; ?></td>
<td align="right"><?php echo $tamDest; ?></td>
<td width="40">
<table width="100%" border="0" cellpadding="3" cellspacing="0" bordercolor="#EAEAEA">
<tr>
<td style="border:0">
<div align="center">
<a href="#" onclick="excluir('', '<?php echo $file; ?>', 'DESEJA REALMENTE EXLUIR O ARQUIVO:<?php echo $file; ?>', 'index.php?idProg=10043&pbxRequest=1&acao=deleta&id=<?php echo $id; ?><?php echo $params; ?>', 'ANUNCIOS');">
<img src="images/delete.gif" alt="EDITAR O RAMAL:<?php echo $dados['nome']; ?>" width="16" height="16" border="0" />
</a>
</div>
<div align="center"></div>
</td>
<td style="border:0">
<a href="index.php?idProg=10043&pbxRequest=1&audioIndisp=<?php echo $nomeSis . ".mp3"; ?>">
<img src="imgSite/sound22.png" alt="Arquivo de Som!" width="16" height="16" border="0" align="absmiddle" />
</a>
</td>
</tr>
</table>
</td>
</tr>
<?php $z++; ?>
<?php } ?>
<?php if ($z == 0) { ?>
<tr align="center" valign="middle" bordercolor="#999999" class="labels">
<td colspan="8">
<div align="center" class="info"><img src="images/shutdown.gif" width="24" height="24" border="0" align="absmiddle" /> Não foram encontrados registros </div>
</td>
</tr>
<?php } ?>
<tr>
<th align="center" colspan="8">
<table width="100%" class="grid" border="0" cellspacing="0" cellpadding="2">
<tr>
<th align="center" style="width: 90%; border:0;"><?php echo $links; ?></th>
<th align="right" style="width: 10%; border:0;"><?php echo sprintf("%s/%s", $pagMostra, $totalReg); ?></th>
</tr>
</table>
</th>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>