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.

601 lines
32 KiB

<!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/jquery.min.js" type="text/javascript"></script>
<script src="admin/js/jquery.validationEngine.js" type="text/javascript"></script>
<script src="admin/js/jquery.validationEngine-en.js" type="text/javascript"></script>
<script src="admin/js/pbxAjax.js" type="text/javascript"></script>
<script>
$(document).ready(function () {
$("#form1").validationEngine({
sucess: function () {
document.form1.submit();
},
failure: function () {}
})
});
function seleciona_tudo(val) {
for (i = 0; i < document.form1.elements.length; i++)
if (document.form1.elements[i].type == "checkbox")
if (document.form1.elements[i].name == "allow[]")
document.form1.elements[i].checked = val;
}
function TodosMarcados()
{
for (i = 0; i < document.form1.elements.length; i++)
{
if (document.form1.elements[i].type == "checkbox")
if (document.form1.elements[i].name == "allow[]")
if ((document.form1.elements[i].name != 'marcaTodos') && (!document.form1.elements[i].checked))
return 0;
}
return 1;
}
function SetContext(user)
{
var usuario = '';
for (var i = 0; i < user.length; i++)
{
if (!(user.substr(i, 1) == ' '))
usuario += user.substr(i, 1);
}
if (document.getElementById('acao').value.toUpperCase() == 'INSERI')
{
if (user)
document.getElementById('context').value = 'entrada-' + usuario;
else
document.getElementById('context').value = "";
}
document.getElementById('username').value = usuario;
}
function valida_voice() {
for (i = 0; i < document.form1.elements.length; i++)
if (document.form1.elements[i].name == "gera_voice")
if (document.form1.elements[i].checked == 0) {
document.form1.v_numero.value = '';
document.form1.v_numero.disabled = false;
} else {
document.form1.v_numero.value = '';
document.form1.v_numero.disabled = true;
}
}
</script>
<link href="admin/css/forms.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
body {
background-color: #EAEAEA;
}
-->
</style></head>
<body>
<?php
$acao = $_GET["acao"];
$acao2 = $_GET["acao2"];
/*
* Parametros necessarios para manter a pagina<EFBFBD><EFBFBD>o.
*/
$param = sprintf('&numRamal=%s&pgn=%s&bloco=%s&pg=%s', $_REQUEST['numRamal'], $_REQUEST['pgn'], $_REQUEST['bloco'], $_REQUEST['pg']);
if ($acao2 == "salva") {
if(md5($_SESSION['SSKeepPassword']) == $_POST["secret"]){
$secret = $_SESSION['SSKeepPassword'];
} else {
$secret = trim($_POST["secret"]);
}
$id = $_POST["id"];
$trunk = $_POST["trunk"];
$nome = LimpaString($_POST["nome"], true);
$nomeOld = trim($_POST["nomeOld"]);
$type = trim($_POST["type"]);
$qualify = trim($_POST["qualify"]);
$port = soNumero($_POST["port"]);
$pickupgroup = trim($_POST["pickupgroup"]);
$permit = trim($_POST["permit"]);
$nat = trim($_POST["nat"]);
$mailbox = trim($_POST["mailbox"]);
$host = trim($_POST["host"]);
$dtmfmode = trim($_POST["dtmfmode"]);
$context = trim($_POST["context"]);
$canreinvite = 'no';
$callerid = trim($_POST["callerid"]);
$registro = trim($_POST["registro"]);
$callgroup = trim($_POST["callgroup"]);
$accountcode = trim($_POST["accountcode"]);
$call_limit = trim($_POST["call-limit"]);
$disallow = 'all';
$deny = $_POST["deny"];
$fromuser = $_POST["fromuser"];
$fromdomain = $_POST["fromdomain"];
$insecure = $_POST["insecure"];
$t38pt_udptl = $_POST["t38pt_udptl"];
$max_ligacoes = $_POST["max_ligacoes"];
$username = $_POST['username'];
$pedido_registro = $_POST['pedido_registro'];
$contrato = $_POST['contrato'] ? $_POST['contrato'] : '0';
$portabilidade = $_POST['portabilidade'];
$allow = $_POST["allow"];
$allow2 = '';
$g = 0;
if (isset($allow)) {
foreach ($allow as $al) {
$g++;
$allow2 .= $al;
if ((count($allow) > 1)and ( count($allow) > $g)) {
$allow2 .= ',';
}
}
}
$existeRamal = $nomeOld <> $nome ? _VerificaNomeTronco($dbcon, $nome) : false;
if ($existeRamal) {
$msg = $existeRamal;
} else if (VerificaContrato($dbcon, $contrato, $id)) {
$msg = "Este contrato j<EFBFBD> esta associado a outro \"Tronco\"!";
} else {
if ($acao == "inseri") {
/* Alan Pablo - 2011-01-16
* Removendo espa<EFBFBD>o em branco do nome do tronco
*/
$nome = str_replace(' ', '', $nome);
$query = "INSERT INTO pbx_troncos_iax(
nome, username, secret, \"type\", context, callerid, host,
port, deny, permit, qualify, nat, canreinvite, disallow, allow,
dtmfmode, fromuser, fromdomain, max_ligacoes, pedido_registro,trunk, registro,contrato, portabilidade)
VALUES ('$nome', '$username', '$secret', '$type', '$context', '$callerid', '$host',
'$port', '0.0.0.0/0.0.0.0', '$permit', '$qualify', '', '$canreinvite', 'all', '$allow2',
'', '$fromuser', '$fromdomain', '$max_ligacoes', '$pedido_registro','$trunk', '$registro', '$contrato', '$portabilidade');";
pg_query($dbcon, $query);
}
if ($acao == "edita") {
//REALIZA BACKUP BO BANCO
//($dbcon,'pbx_troncos_iax','U',$id,'update','TRONCOS_SIP');
$query = "UPDATE pbx_troncos_iax
SET nome='$nome', username='$username', secret='$secret', \"type\"='$type', context='$context', callerid='$callerid',
host='$host', port='$port', deny='0.0.0.0/0.0.0.0', permit='$permit', qualify='$qualify', canreinvite='$canreinvite',
disallow='all', allow='$allow2', fromuser='$fromuser', fromdomain='$fromdomain', max_ligacoes='$max_ligacoes',
pedido_registro='$pedido_registro',trunk='$trunk', registro='$registro', contrato='$contrato', portabilidade='$portabilidade'
WHERE id=$id";
pg_query($dbcon, $query);
}
if (!$msg) {
//executa inser<EFBFBD><EFBFBD>o na base interna do asterisk
//CommandAsterisk2($dbcon,'TRONCO',$nome,'IAX2/'.$nome);//gera arquivos e executa o reload dos dados no asterisk
gera_arquivos($dbcon, 'IAX_PBX');
echo "<script type=\"text/javascript\">
//fecha a janela presa no meio do sistema
fecha_popup(0,'index.php?idProg=10015&pbxRequest=1$param&acao=$acao');
</script>";
}
}
}
if ($msg) {
echo "<script type=\"text/javascript\">alert('$msg');</script>";
$dados = array();
foreach ($_POST as $key => $value)
$dados[$key] = ($key == 'allow') ? $allow2 : $value;
} else {
if ($acao == "edita") {
$id = $_GET["id"] ?? "0";
$query = "SELECT * FROM pbx_troncos_iax where id=$id";
$result = pg_query($dbcon, $query);
$dados = pg_fetch_array($result);
} else {
$query = "SELECT * FROM pbx_troncos_iax where id is null";
$result = pg_query($dbcon, $query);
$dados = pg_fetch_array($result);
$dados["allow"] = 'ulaw,alaw';
}
}
$_SESSION['SSKeepPassword'] = $dados["secret"];
$secret = md5($dados["secret"]);
$id = $dados["id"];
$nome = $dados["nome"];
$nomeOld = isset($dados["nomeOld"]) ? $dados["nomeOld"] : $dados["nome"];
$type = $dados["type"];
$qualify = $dados["qualify"];
$port = $dados["port"];
$pickupgroup = $dados["pickupgroup"];
$permit = $dados["permit"];
$nat = trim($dados["nat"]);
$mailbox = $dados["mailbox"];
$host = $dados["host"];
$dtmfmode = $dados["dtmfmode"];
$context = $dados["context"];
$canreinvite = $dados["canreinvite"];
$callerid = $dados["callerid"];
$registro = $dados["registro"];
$callgroup = $dados["callgroup"];
$accountcode = $dados["accountcode"];
$call_limit = $dados["call-limit"];
$allow = $dados["allow"];
$dtmfmode = $dados["dtmfmode"];
$deny = $dados["deny"];
$fromuser = $dados["fromuser"];
$fromdomain = $dados["fromdomain"];
$insecure = $dados["insecure"];
$t38pt_udptl = $dados["t38pt_udptl"];
$disallow = $dados["disallow"];
$max_ligacoes = $dados["max_ligacoes"];
$username = $dados["username"];
$pedido_registro = $dados['pedido_registro'];
$trunk = $dados['trunk'];
$contrato = $dados['contrato'];
$portabilidade = $dados['portabilidade'];
$displayValue = ($acao == 'edita') || (!empty($msg));
?>
<form name="form1" method="post" action="index.php?idProg=11015&pbxRequest=1&acao=<?php echo $acao; ?>&acao2=salva<?php echo $param ?>" id="form1">
<table border="1" align="center" cellpadding="0" cellspacing="0" class="tabela">
<tr bordercolor="#EAEAEA" bgcolor="#EAEAEA" class="labels" background="img/button03.gif">
<td class="cabecalho"><div align="center">CADASTRO DE tRONCOS IAX
<input name="id" type="hidden" id="id" value="<?php
if ($displayValue) {
echo $id;
}
?>" />
<input name="acao" type="hidden" id="acao" value="<?php echo $acao; ?>" />
<input name="nomeOld" type="hidden" id="acao" value="<?php echo $nomeOld; ?>" />
</div></td>
</tr>
<?php if ($acao == 'inseri') { ?>
<?php } ?>
<tr bordercolor="#EAEAEA" bgcolor="#EAEAEA">
<td bgcolor="#EAEAEA" class="labels"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<fieldset>
<legend class="labels">Nome:</legend>
<input name="nome" type="text" class="validate[required,length[0,100]] caixas" id="nome" value="<?php
if ($displayValue) {
echo $nome;
}
?>" size="20" maxlength="60" />
</fieldset>
</td>
<td>
<fieldset>
<legend class="labels"><span class="style5">Senha IAX:</span></legend>
<input name="secret" type="password" class="caixas" id="secret" value="<?php
if ($displayValue) {
echo $secret;
}
?>" size="20" maxlength="20" />
</fieldset>
</td>
<td>
<div align="left">
<fieldset>
<legend class="labels"><span class="style5">Tarifa<EFBFBD><EFBFBD>o</span></legend>
<select name="contrato" id="contrato" style="width: 150px;">
<?php
echo PbxContratos($contrato);
?>
</select>
</fieldset>
</div>
</td>
<td>
<div align="left">
<fieldset>
<legend class="labels"><span class="style5">Portabilidade</span></legend>
<select name="portabilidade" id="portabilidade" style="width: 150px;">
<?php
echo PbxOperadoras($portabilidade);
?>
</select>
</fieldset>
</div>
</td>
</tr>
</table>
</td>
</tr>
<tr bordercolor="#EAEAEA" bgcolor="#EAEAEA">
<td bgcolor="#EAEAEA" class="labels"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<fieldset>
<legend class="labels">
<span class="style5">Codecs Habilitados:</span>
</legend>
<span class="labels2">
<?php
$numCodec = 0;
foreach (GetCodecs() as $codec) {
$check = ((strpos($allow, $codec) !== false)) ? ' checked="checked"' : '';
echo sprintf('<input name="allow[]" type="checkbox" id="allow%s" value="%s"%s>', ++$numCodec, $codec, $check);
echo ucfirst($codec);
}
?>
<input name="marcaTodos" type="checkbox" id="marcaTodos" value="all" onclick="seleciona_tudo(this.checked);" />
all</span>
</fieldset>
</td>
</tr>
</table>
</td>
</tr>
<tr bordercolor="#EAEAEA" bgcolor="#EAEAEA">
<td bgcolor="#EAEAEA" class="labels"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<fieldset>
<legend class="labels">Tipo:</legend>
<span class="style5">
<input name="type" type="radio" value="user" <?php
if ($displayValue) {
if ($type == 'user') {
echo "checked";
}
}
?> />
</span>Faz liga&ccedil;&otilde;es<span class="style5">
<input name="type" type="radio" value="peer" <?php
if ($displayValue) {
if ($type == 'peer') {
echo "checked";
}
}
?> />
Recebe Liga&ccedil;&otilde;es
<input name="type" type="radio" value="friend" <?php
if ($displayValue) {
if ($type == 'friend') {
echo "checked";
}
} else {
echo "checked";
}
?> />
Ambos</span>
</fieldset>
</td>
<td>
<fieldset>
<legend class="labels"><span class="style5">Monitorar:</span></legend>
<span class="style5">
<input name="qualify" type="radio" value="yes" <?php
if ($displayValue) {
if ($qualify == 'yes') {
echo "checked";
}
} else {
echo "checked";
}
?> />
Sim
<input name="qualify" type="radio" value="no" <?php
if ($displayValue) {
if ($qualify == 'no') {
echo "checked";
}
}
?> />
N&atilde;o<span class="labels2"></span></span>
</fieldset>
</td>
<td>
<fieldset>
<legend class="labels"><span class="style5">Trunk:</span></legend>
<span class="style5">
<input name="trunk" type="radio" value="yes" <?php
if ($displayValue) {
if ($trunk == 'yes') {
echo "checked";
}
} else {
echo "checked";
}
?> />
Sim
<input name="trunk" type="radio" value="no" <?php
if ($displayValue) {
if ($trunk == 'no') {
echo "checked";
}
}
?> />
N&atilde;o</span>
</fieldset>
</td>
</tr>
</table>
</td>
</tr>
<tr bordercolor="#EAEAEA" bgcolor="#EAEAEA">
<td bgcolor="#EAEAEA" class="labels">
<div align="right"></div>
<div align="right">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<div align="left">
<fieldset>
<legend class="labels">Servidor:</legend>
<input name="permit" type="text" class="caixas" id="permit" value="<?php
if ($displayValue) {
echo $permit;
} else {
echo "";
}
?>" size="30" maxlength="30" />
</fieldset>
</div>
</td>
<td>
<div align="left">
<fieldset>
<legend class="labels">Porta:</legend>
<input name="port" type="text" class="caixas" id="port" value="<?php
if ($displayValue) {
echo $port;
} else {
echo "4569";
}
?>" size="10" maxlength="10" />
<span class="style5"></span>
</fieldset>
</div></td>
<td><div align="left">
<fieldset>
<legend class="labels">Usu&aacute;rio:</legend>
<input name="username" type="text" class="caixas" id="username" value="<?php
if ($displayValue) {
echo $username;
} else {
echo "";
}
?>" onchange="SetContext(this.value)"/>
</fieldset>
</div></td>
</tr>
</table>
</div></td>
</tr>
<tr bordercolor="#EAEAEA" bgcolor="#EAEAEA">
<td bgcolor="#EAEAEA" class="labels"><div align="right">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><fieldset>
<legend class="labels"><span class="style5">Endere<EFBFBD>o IP:</span></legend>
<input name="host" type="text" class="caixas" id="host" value="<?php
if ($displayValue) {
echo $host;
} else {
echo "dynamic";
}
?>" size="20" maxlength="29" />
<span class="labels2"></span>
</fieldset></td>
<td><fieldset>
<legend class="labels"><span class="style5">Bina:</span></legend>
<input name="callerid" type="text" class="caixas" id="callerid" value="<?php
if ($displayValue) {
echo $callerid;
}
?>" size="20" maxlength="30" />
<span class="labels2"></span>
</fieldset></td>
<td><fieldset>
<legend class="labels"><span class="style5">Contexto:</span></legend>
<input name="context" type="text" class="validate[required] caixas" id="context" value="<?php
if ($displayValue) {
echo $context;
}
?>" size="20" maxlength="30" />
</fieldset></td>
<td><fieldset>
<legend class="labels">Limite de Liga&ccedil;&atilde;o:</legend>
<input name="max_ligacoes" type="text" class="validate[required,custom[onlyNumber]] caixas" id="max_ligacoes" value="<?php
if ($displayValue) {
echo $max_ligacoes;
} else {
echo "50";
}
?>" size="10" maxlength="10" />
<span class="style5"></span>
</fieldset></td>
</tr>
</table>
</div> </td>
</tr>
<tr bordercolor="#EAEAEA" bgcolor="#EAEAEA">
<td bgcolor="#EAEAEA" class="labels"><div align="right"></div> <span class="style5">
</span> <div align="right"><span class="style5"> </span></div>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<fieldset>
<legend class="labels"><span class="style5">Registro:</span></legend>
<input name="registro" type="text" class="caixas" id="registro" value="<?php
if ($displayValue) {
echo $registro;
} else {
echo "usuario_contrato:senha_contrato@endereco_servidor/usuario_local";
}
?>" size="70" maxlength="100" />
<span class="labels2"></span>
</fieldset>
</td>
<td><fieldset>
<legend class="labels"><span class="style5">Pedido Registro :</span></legend>
<span class="style5">
<input name="pedido_registro" type="radio" value="yes" <?php
if ($displayValue) {
if ($pedido_registro == 'yes') {
echo "checked";
}
}
?> />
Sim
<input name="pedido_registro" type="radio" value="no" <?php
if ($displayValue) {
if ($pedido_registro == 'no') {
echo "checked";
}
} else {
echo "checked";
}
?> />
N&atilde;o</span>
</fieldset></td>
<td>
</td>
</tr>
</table> </td>
</tr>
<tr bordercolor="#EAEAEA" bgcolor="#EAEAEA">
<td><div align="center"><span class="style1"></span><span class="style1"></span><span class="style1"></span><span class="style1">
<input name="Submit2" type="button" class="labels" value="Fechar" id="Submit2" onclick="fecha_popup();"/>
<input name="Submit" type="submit" class="labels" value="Salvar" />
</span></div></td>
</tr>
</table>
</form>
<script type="text/javascript">
if (TodosMarcados())
{
document.getElementById('marcaTodos').checked = 'checked';
}
</script>
</body>
</html>