|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* variavel que vai conter o template
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
$janW = 500;
|
|
|
|
|
$janH = 250;
|
|
|
|
|
|
|
|
|
|
$fields = array('host', 'usuario', 'senha', 'basedados', 'porta', 'descricao');
|
|
|
|
|
$fieldsName = array('Host', 'Usu<EFBFBD>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"];
|
|
|
|
|
$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] . " <EFBFBD> um campo de preenchimento obrigat<EFBFBD>rio!";
|
|
|
|
|
}
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
?>
|