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.
 
 
 
 
 
 

299 lines
16 KiB

<?php session_start(); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="cs" lang="cs">
<head>
<link href="admin/css/forms.css" rel="stylesheet" type="text/css">
<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() {}
})
});
</script>
</head>
<body>
<?php
/*
* Parametros necessarios para manter a paginação.
*/
$param = sprintf('&numRamal=%s&pgn=%s&bloco=%s&pg=%s', $_REQUEST['numRamal'], $_REQUEST['pgn'], $_REQUEST['bloco'], $_REQUEST['pg']);
$acao = $_GET["acao"];
$id = $_GET['id'];
$acao2 = $_GET["acao2"];
$org_id = GetOrganizacao();
if ($acao2 == "salva") {
$id = $_POST["id"];
$nome = trim($_POST["nome"]);
$conta = trim($_POST["conta"]);
$porta = trim($_POST["porta"]);
$timeout = trim($_POST["timeout"]);
$protocolo = trim($_POST["protocolo"]);
$dominio = trim($_POST["dominio"]);
$tsl = trim($_POST["tsl"]);
$tsl_certificado = $_POST["tsl_certificado"];
$tsl_check = trim($_POST["tsl_check"]);
$logfile = trim($_POST["logfile"]);
$hosts = trim($_POST["hosts"]);
$de = trim($_POST["de"]);
$auth = trim($_POST["auth"]);
$usuario = trim($_POST["usuario"]);
if (md5($_SESSION['SSKeepPassword']) == trim($_POST["senha"])) {
$senha = $_SESSION['SSKeepPassword'];
unset($_SESSION['SSKeepPassword']);
} else {
$senha = trim($_POST["senha"]);
}
$padrao = trim($_POST["padrao"]);
if ($acao == "inseri") {
if ($padrao == 'S') {
$query = "update pbx_confmail set padrao = 'N'";
pg_query($dbcon, $query);
}
$query = "INSERT INTO pbx_confmail(conta, porta, timeout, protocolo, dominio, tsl, tsl_certificado, tsl_check, logfile, hosts, de, auth, usuario, senha,padrao, org_id)
VALUES ('$conta', '$porta', '$timeout', '$protocolo', '$dominio', '$tsl', '$tsl_certificado', '$tsl_check', '$logfile', '$hosts', '$de', '$auth', '$usuario', '$senha','$padrao', $org_id);";
pg_query($dbcon, $query);
}
if ($acao == "edita") {
//REALIZA BACKUP BO BANCO
backup($dbcon, 'pbx_confmail', 'U', $id, 'update', 'CONFMAIL');
if ($padrao == 'S') {
$query = "update pbx_confmail set padrao = 'N', org_id = $org_id ";
pg_query($dbcon, $query);
}
$query = "UPDATE pbx_confmail
SET conta='$conta', porta='$porta', timeout='$timeout', protocolo='$protocolo', dominio='$dominio',
tsl='$tsl', tsl_certificado='$tsl_certificado', tsl_check='$tsl_check', logfile='$logfile',
hosts='$hosts', de='$de', auth='$auth', usuario='$usuario', senha='$senha',padrao='$padrao'
WHERE id=$id";
pg_query($dbcon, $query);
} //gera arquivos e executa o reload dos dados no asterisk
gera_arquivos($dbcon, 'CONFMAIL');
echo "<script type=\"text/javascript\">
fecha_popup(0,'index.php?idProg=10040&pbxRequest=1$param&acao=$acao');
</script>";
}
if ($acao == "edita") {
$id = $_GET["id"] ?? "0";
$query = "SELECT * FROM pbx_confMail where id=$id";
$result = pg_query($dbcon, $query);
} else {
$query = "SELECT * FROM pbx_confMail where id is null";
}
$result = pg_query($dbcon, $query);
while ($dados = pg_fetch_array($result)) {
$id = $dados["id"];
$nome = $dados["nome"];
$conta = $dados["conta"];
$porta = $dados["porta"];
$timeout = $dados["timeout"];
$protocolo = $dados["protocolo"];
$dominio = $dados["dominio"];
$tsl = $dados["tsl"];
$tsl_certificado = $dados["tsl_certificado"];
$tsl_check = $dados["tsl_check"];
$logfile = $dados["logfile"];
$hosts = $dados["hosts"];
$de = $dados["de"];
$auth = $dados["auth"];
$usuario = $dados["usuario"];
$_SESSION['SSKeepPassword'] = $dados["senha"];
$senha = md5($dados["senha"]);
$padrao = $dados["padrao"];
}
?>
<script language="JavaScript" type="text/JavaScript">
function MM_openBrWindow(theURL,winName,features) {
window.open(theURL,winName,features);
}
</script>
<form name="form1" method="post" action="index.php?idProg=11040&pbxRequest=1&acao=<?php echo $acao; ?>&acao2=salva<?php echo $param ?>" id="form1">
<table width="410" height="231" border="1" align="center" cellpadding="0" cellspacing="0" class="tabela">
<tr bordercolor="#EAEAEA" bgcolor="#EAEAEA">
<td width="406" height="21">
<div align="center" class="cabecalho">CADASTRO DE CONTAS DE E-MAIL
<input name="id" type="hidden" id="id2" value="<?= ($acao == 'edita') ? $id : null; ?>" />
</div>
</td>
</tr>
<tr bordercolor="#EAEAEA" bgcolor="#EAEAEA">
<td height="31" class="labels">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="47%">
<fieldset>
<legend class="labels">Conta:</legend>
<input name="conta" type="text" class="validate[required,length[0,100]] caixas" id="nome" value="<?= ($acao == 'edita') ? $conta : null; ?>" size="70" maxlength="100" />
</fieldset>
</td>
</tr>
</table>
</td>
</tr>
<tr bordercolor="#EAEAEA" bgcolor="#EAEAEA">
<td height="31" class="labels">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="33%">
<fieldset>
<legend class="labels">Porta:</legend>
<input name="porta" type="text" class="validate[required,length[0,100]] caixas" id="nome3" value="<?= ($acao == 'edita') ? $porta : "25"; ?>" size="10" maxlength="100" />
</fieldset>
</td>
<td width="33%">
<fieldset>
<legend class="labels">Timeout:</legend>
<input name="timeout" type="text" class="validate[required,length[0,100]] caixas" id="protocolo" value="<?= ($acao == 'edita') ? $timeout : "off"; ?>" size="10" maxlength="100" />
</fieldset>
</td>
<td width="33%">
<fieldset>
<legend class="labels">Protocolo:</legend>
<input name="protocolo" type="text" class="validate[required,length[0,100]] caixas" id="conta2" value="<?= ($acao == 'edita') ? $protocolo : "smtp"; ?>" size="10" maxlength="100" />
</fieldset>
</td>
</tr>
</table>
</td>
</tr>
<tr class="labels" bordercolor="#EAEAEA" bgcolor="#EAEAEA">
<td height="31">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="41%">
<fieldset>
<legend class="labels">Domino:</legend>
<input name="dominio" type="text" class="validate[required,length[0,100]] caixas" id="dominio" value="<?= ($acao == 'edita') ? $dominio : null; ?>" size="30" maxlength="100" />
</fieldset>
</td>
<td width="27%">
<fieldset>
<legend class="labels">Usu&aacute;rio:</legend>
<input name="usuario" type="text" class="validate[required,length[0,100]] caixas" id="conta22" value="<?= ($acao == 'edita') ? $usuario : null; ?>" size="20" maxlength="100" />
</fieldset>
</td>
<td width="32%">
<fieldset>
<legend class="labels">Senha:</legend>
<input name="senha" type="password" class="validate[required,length[0,100]] caixas" id="senha" value="<?= ($acao == 'edita') ? $senha : null; ?>" size="20" maxlength="100" />
</fieldset>
</td>
</tr>
</table>
</td>
</tr>
<tr class="labels" bordercolor="#EAEAEA" bgcolor="#EAEAEA">
<td height="31">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="33%">
<fieldset class="labels">
<legend class="labels">Tsl:</legend>
<input name="tsl" type="radio" value="on" <?= ($acao == 'edita') && ($tsl == 'on') ? "checked" : null; ?> />
Ligado
<input name="tsl" type="radio" value="off" <?= ($acao == 'edita') && ($tsl == 'off') ? "checked" : null; ?> <?= ($acao != 'edita') ? "checked" : null; ?> />
Desligado
</fieldset>
</td>
<td width="33%">
<fieldset>
<legend class="labels">Tsl certificado:</legend>
<input name="tsl_certificado" type="text" class="validate[optional,length[0,100]] caixas" id="tsl_certificado" value="<?= ($acao == 'edita') ? $tsl_certificado : null; ?>" size="10" maxlength="100" />
</fieldset>
</td>
<td width="33%">
<fieldset class="labels">
<legend class="labels">Tsl Cert Check:</legend>
<input name="tsl_check" type="radio" value="on" <?= ($acao == 'edita') && ($tsl_check == 'on') ? "checked" : null; ?> />
Ligado
<input name="tsl_check" type="radio" value="off" <?= ($acao == 'edita') && ($tsl_check == 'off') ? "checked" : null; ?> <?= ($acao != 'edita') ? "checked" : null; ?> />
Desligado
</fieldset>
</td>
</tr>
</table>
</td>
</tr>
<tr class="labels" bordercolor="#EAEAEA" bgcolor="#EAEAEA">
<td height="31">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="33%">
<fieldset>
<legend class="labels">Arquivo de log :</legend>
<input name="logfile" type="text" class="validate[required,length[0,100]] caixas" id="logfile" value="<?= ($acao == 'edita') ? $logfile : "~/.msmtp.log"; ?>" size="20" maxlength="100" />
</fieldset>
</td>
<td width="33%">
<fieldset>
<legend class="labels">Servidor:</legend>
<input name="hosts" type="text" class="validate[required,length[0,100]] caixas" id="hosts" value="<?= ($acao == 'edita') ? $hosts : null; ?>" size="20" maxlength="100" />
</fieldset>
</td>
<td width="33%">
<fieldset>
<legend class="labels">Auth :</legend>
<input name="auth" type="text" class="validate[required,length[0,100]] caixas" id="auth" value="<?= ($acao == 'edita') ? $auth : "login"; ?>" size="10" maxlength="100" />
</fieldset>
</td>
</tr>
</table>
</td>
</tr>
<tr class="labels" bordercolor="#EAEAEA" bgcolor="#EAEAEA">
<td height="31">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="16%">
<fieldset>
<legend class="labels">De :</legend>
<input name="de" type="text" class="validate[required,length[0,100]] caixas" id="de" value="<?= ($acao == 'edita') ? $de : null; ?>" size="50" maxlength="100" />
</fieldset>
</td>
<td width="17%">
<fieldset>
<legend class="labels">Conta Padr&atilde;o :</legend>
<input name="padrao" type="checkbox" id="padrao" value="S" <?= ($padrao == 'S') ? "checked" : null; ?> />
</fieldset>
</td>
</tr>
</table>
</td>
</tr>
<tr bordercolor="#EAEAEA" bgcolor="#EAEAEA">
<td height="22">
<div align="center">
<input name="Submit2" type="button" class="labels" onclick="fecha_popup();" value="Fechar" />
<input name="Submit" type="submit" class="labels" value="Salvar" />
</div>
</td>
</tr>
</table>
</form>
</body>
</html>