Browse Source

multiempresa para cadastro de tronco e a funções de escrita do sip_ramais.conf para o tronco pronto

1.9
bruno 2 months ago
parent
commit
dafbecb029
  1. 11
      admin/cadTroncosSIP.php
  2. 6
      admin/funcoes.php

11
admin/cadTroncosSIP.php

@ -100,6 +100,7 @@
$id = $_POST["id"]; $id = $_POST["id"];
$nome = LimpaString($_POST["nome"], true); $nome = LimpaString($_POST["nome"], true);
$nome_asterisk = "$org_id$nome";
$nomeOld = trim($_POST["nomeOld"]); $nomeOld = trim($_POST["nomeOld"]);
$type = trim($_POST["type"]); $type = trim($_POST["type"]);
@ -112,6 +113,7 @@
$host = trim($_POST["host"]); $host = trim($_POST["host"]);
$dtmfmode = trim($_POST["dtmfmode"]); $dtmfmode = trim($_POST["dtmfmode"]);
$context = trim($_POST["context"]); $context = trim($_POST["context"]);
$context_asterisk = "$org_id$context";
$registro = trim($_POST["registro"]); $registro = trim($_POST["registro"]);
$canreinvite = 'no'; $canreinvite = 'no';
$callerid = trim($_POST["callerid"]); $callerid = trim($_POST["callerid"]);
@ -153,10 +155,10 @@
if ($acao == "inseri") { if ($acao == "inseri") {
$query = " INSERT INTO pbx_troncos_sip (nome, username, secret, \"type\", context, callerid, host, port, $query = " INSERT INTO pbx_troncos_sip (nome, username, secret, \"type\", context, callerid, host, port,
deny, permit, qualify, nat, canreinvite, disallow, allow, dtmfmode, fromuser, fromdomain, max_ligacoes, deny, permit, qualify, nat, canreinvite, disallow, allow, dtmfmode, fromuser, fromdomain, max_ligacoes,
pedido_registro, registro, contrato, portabilidade, org_id) pedido_registro, registro, contrato, portabilidade, org_id, nome_asterisk, context_asterisk)
VALUES ('$nome', '$username', '$secret', '$type', '$context', '$callerid', '$host', '$port', '0.0.0.0/0.0.0.0', VALUES ('$nome', '$username', '$secret', '$type', '$context', '$callerid', '$host', '$port', '0.0.0.0/0.0.0.0',
'$permit', '$qualify', '$nat', '$canreinvite', 'all', '$allow2', '$dtmfmode', '$fromuser', '$fromdomain', '$permit', '$qualify', '$nat', '$canreinvite', 'all', '$allow2', '$dtmfmode', '$fromuser', '$fromdomain',
'$max_ligacoes', '$pedido_registro', '$registro', '$contrato', '$portabilidade', $org_id);"; '$max_ligacoes', '$pedido_registro', '$registro', '$contrato', '$portabilidade', $org_id, '$nome_asterisk', '$context_asterisk');";
pg_query($dbcon, $query); pg_query($dbcon, $query);
} }
@ -165,8 +167,9 @@
SET nome = '$nome', username='$username', secret='$secret', \"type\"='$type', context='$context', callerid='$callerid', 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', nat='$nat', canreinvite='$canreinvite', host='$host', port='$port', deny='0.0.0.0/0.0.0.0', permit='$permit', qualify='$qualify', nat='$nat', canreinvite='$canreinvite',
disallow='all', allow='$allow2', dtmfmode='$dtmfmode', fromuser='$fromuser', fromdomain='$fromdomain', max_ligacoes='$max_ligacoes', disallow='all', allow='$allow2', dtmfmode='$dtmfmode', fromuser='$fromuser', fromdomain='$fromdomain', max_ligacoes='$max_ligacoes',
pedido_registro='$pedido_registro', registro='$registro', contrato='$contrato', portabilidade = '$portabilidade' pedido_registro='$pedido_registro', registro='$registro', contrato='$contrato', portabilidade = '$portabilidade', nome_asterisk = '$nome_asterisk',
WHERE id=$id"; context_asterisk = '$context_asterisk'
WHERE id=$id and org_id = $org_id";
pg_query($dbcon, $query); pg_query($dbcon, $query);
} }
if (!$msg) { if (!$msg) {

6
admin/funcoes.php

@ -968,7 +968,7 @@ function gera_arquivos($dbcon, $tipo, $reload = 1, $reloadUra = 1) {
} }
//GERA OS TRONCOS SIP DENTRO DO ARQUIVO DE RAMAIS callerid, //GERA OS TRONCOS SIP DENTRO DO ARQUIVO DE RAMAIS callerid,
$query = "SELECT nome, username, secret, type, context, host, $query = "SELECT nome_asterisk, username, secret, type, context_asterisk, host,
username as fromuser,fromdomain, fromuser as grava_fromuser, username as fromuser,fromdomain, fromuser as grava_fromuser,
port,case when permit = '' then '' else deny end as deny, port,case when permit = '' then '' else deny end as deny,
permit, qualify,case when nat = 'yes' then 'force_rport,comedia' else nat end as nat, canreinvite, disallow, allow, dtmfmode, 'port,invite' as insecure permit, qualify,case when nat = 'yes' then 'force_rport,comedia' else nat end as nat, canreinvite, disallow, allow, dtmfmode, 'port,invite' as insecure
@ -978,12 +978,14 @@ function gera_arquivos($dbcon, $tipo, $reload = 1, $reloadUra = 1) {
while ($dados = pg_fetch_array($result)) { while ($dados = pg_fetch_array($result)) {
for ($i = 0; pg_num_fields($result) > $i; $i++) { for ($i = 0; pg_num_fields($result) > $i; $i++) {
$fieldName = trim(pg_field_name($result, $i)); $fieldName = trim(pg_field_name($result, $i));
if ($fieldName == "nome") { if ($fieldName == "nome_asterisk") {
fwrite($escreve, "[" . $dados[$fieldName] . "]" . "\n"); fwrite($escreve, "[" . $dados[$fieldName] . "]" . "\n");
} else if ($fieldName == "fromuser") { } else if ($fieldName == "fromuser") {
if ($dados['grava_fromuser']) { if ($dados['grava_fromuser']) {
fwrite($escreve, $fieldName . '=' . $dados[$fieldName] . "\n"); fwrite($escreve, $fieldName . '=' . $dados[$fieldName] . "\n");
} }
} else if ($fieldName == "context_asterisk") {
fwrite($escreve, "context" . '=' . $dados[$fieldName] . "\n");
} else if ($fieldName != "grava_fromuser") { } else if ($fieldName != "grava_fromuser") {
if (trim($dados[$fieldName]) != '') { if (trim($dados[$fieldName]) != '') {
if (trim($fieldName) == 'permit') { if (trim($fieldName) == 'permit') {

Loading…
Cancel
Save