forked from SimplesIP/pabx-app
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.
78 lines
2.4 KiB
78 lines
2.4 KiB
<?php |
|
|
|
/* |
|
* variavel que vai conter o template |
|
*/ |
|
|
|
$janW = 500; |
|
$janH = 250; |
|
|
|
$fields = array('host', 'usuario', 'senha', 'basedados', 'porta', 'descricao'); |
|
$fieldsName = array('Host', 'Usuário', 'Senha', 'Base de Dados', 'Porta', 'Nome'); |
|
$erro = ""; |
|
if ((GetFormAcao() == FORM_SELECT) || (GetFormAcao() == FORM_DELETE)) { |
|
include("sites/siteSelect.php"); |
|
} else { |
|
$tpl = 'site.tpl'; |
|
$tpLayout = 1; |
|
if (IsPostBack()) { |
|
|
|
$id = $_POST["idSite"]; |
|
$host = $_POST["host"]; |
|
$usuario = isset($_POST["usuario"]) ? $_POST["usuario"] : 'manager'; |
|
$senha = isset($_POST["senha"]) ? $_POST["senha"] : 'manager007'; |
|
$basedados = $_POST["basedados"]; |
|
$porta = $_POST["porta"]; |
|
$descricao = $_POST["descricao"]; |
|
$status = isset($_POST["status"]) ? 1 : 0; |
|
} else { |
|
|
|
if (GetFormAcao() == FORM_UPDATE) { |
|
$id = $_GET["id"] ?? "0"; |
|
$query = "select id, host, usuario, senha, |
|
basedados, porta, descricao, status |
|
from pbx_sites where id = $id"; |
|
$result = @pg_query($dbcon, $query); |
|
$row = pg_fetch_array($result); |
|
foreach ($row as $key => $value) { |
|
$GLOBALS[$key] = $value; |
|
} |
|
} else { |
|
$id = 0; |
|
$status = 1; |
|
$porta = '5432'; |
|
} |
|
} |
|
|
|
if ((GetFormAcao() == FORM_NEW) || (GetFormAcao() == FORM_INSERT)) { |
|
include("siteInsert.php"); |
|
} else if ((GetFormAcao() == FORM_UPDATE) || (GetFormAcao() == FORM_SAVE)) { |
|
|
|
include("siteUpdate.php"); |
|
} |
|
|
|
$smarty->assign('msgErro', $erro); |
|
$smarty->assign('host', $host); |
|
$smarty->assign('usuario', $usuario); |
|
$smarty->assign('senha', $senha); |
|
$smarty->assign('basedados', $basedados); |
|
$smarty->assign('porta', $porta); |
|
$smarty->assign('descricao', $descricao); |
|
$smarty->assign('status', $status ? "checked" : ""); |
|
$smarty->assign('idSite', $id); |
|
$smarty->assign("formAction", $acaoForm); |
|
$smarty->assign("formAcaoDesc", GetFormAcaoDesc($acaoForm)); |
|
|
|
|
|
GetTemplate($smarty, $tpl); |
|
} |
|
|
|
function ValidaSite($fields, $fieldsName) { |
|
foreach ($fields as $key => $value) { |
|
if (empty($_POST[$value])) |
|
return $fieldsName[$key] . " é um campo de preenchimento obrigatório!"; |
|
} |
|
return ""; |
|
} |
|
|
|
?>
|
|
|