| Server IP : 20.75.53.88 / Your IP : 216.73.217.72 [ Web Server : Apache System : Linux VMRALP-3 4.4.0-256-generic #290~14.04.1-Ubuntu SMP Thu Jun 20 09:24:50 UTC 2024 x86_64 User : www-data ( 33) PHP Version : 5.5.9-1ubuntu4.29+esm15 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, Domains : 3 Domains MySQL : ON | cURL : OFF | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/html/ouvidoria/obidos/inc/ |
Upload File : |
<?php
require_once("database.php");
require_once("funcoes.php");
function sendMail($to, $subject, $body, $from = "", $fromname = "")
{
$html
= "<html>
<body>
$body
</body>
</html>";
$email_remetente = "gtcontrollerbrasil@gmail.com";
$email_usuario = $to;
$headers = "MIME-Version: 1.1\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\n";
$headers .= "From: $email_remetente\n"; // remetente
$headers .= "Organization: G&T Controller\n";
$headers .= "Return-Path: $email_remetente\n"; // return-path
$headers .= "Reply-To: $email_usuario\n"; // Endereço (devidamente validado) que o seu usuário informou no contato
//$envio = mail($email_usuario, $subject, $html, $headers, "-f$email_remetente");
if (mail($email_usuario, $subject, $html, $headers, "-f$email_remetente"))
return true;
else
return false;
}
function sendMailAnexo($to, $subject, $body, $arquivos = array(), $from = "", $fromname = "", $cc = "")
{
//se nao for informado o remetente, recupera das configurações do sistema
if (empty($from)) {
$sql = "select nomeremetenteemail, emailremetente from lda_configuracao";
$rs = execQuery($sql);
$row = mysql_fetch_array($rs);
$from = $row['emailremetente'];
$fromname = $row['nomeremetenteemail'];
}
$html
= "<html>
<body>
$body
</body>
</html>";
$boundary = strtotime('NOW');
$headers = "Content-Type: multipart/mixed; boundary=\"" . $boundary . "\"" . PHP_EOL;
$headers .= "Reply-To: $fromname <$from>" . PHP_EOL;
$headers .= "Return-Path: $fromname <$from>" . PHP_EOL;
$headers .= "From: $fromname <$from>" . PHP_EOL;
$headers .= "Cc: $cc" . PHP_EOL;
$headers .= "MIME-Version: 1.0" . PHP_EOL;
$headers .= "Organization: Prefeitura do Natal" . PHP_EOL;
$msg = "--" . $boundary . PHP_EOL;
$msg .= "Content-Type: text/html; charset=\"ISO-8859-1\"" . PHP_EOL;
$msg .= "Content-Transfer-Encoding: 8bit" . PHP_EOL . PHP_EOL;
$msg .= stripslashes($html) . PHP_EOL;
for ($i = 1; $i <= count($arquivos); $i++) {
$finfo = finfo_open(FILEINFO_MIME_TYPE);
$tipoarquivo = finfo_file($finfo, $arquivos['arquivo'][$i]);
$msg .= "--" . $boundary . PHP_EOL;
$msg .= "Content-Transfer-Encoding: base64" . PHP_EOL;
$msg .= "Content-Type: \"" . $tipoarquivo . "\"; name=\"" . $arquivos['nome'][$i] . "\"" . PHP_EOL;
$msg .= "Content-Disposition: attachment; filename=\"" . $arquivos['nome'][$i] . "\"" . PHP_EOL . PHP_EOL;
ob_start();
readfile($arquivos['arquivo'][$i]);
$enc = ob_get_contents();
ob_end_clean();
$msg_temp = base64_encode($enc) . PHP_EOL;
$tmp[1] = strlen($msg_temp);
$tmp[2] = ceil($tmp[1] / 76);
for ($b = 0; $b <= $tmp[2]; $b++) {
$tmp[3] = $b * 76;
$msg .= substr($msg_temp, $tmp[3], 76) . PHP_EOL;
}
unset($msg_temp, $tmp, $enc);
}
return mail($to, $subject, $msg, $headers);
}
//registra na tabela de erros de login, a tentativa sem sucesso de acesso ao sistema
function setTentativaLogin($usuario)
{
$ipaddr = $_SERVER["REMOTE_ADDR"];
$sistema = SISTEMA_CODIGO;
$query = "insert into sis_errologin (sistema, usuario,ip) values('$sistema','$usuario','$ipaddr')";
execQuery($query) or die("Ocorreu um erro inesperado ao logar erro de entrada");
}
//exclui da tabela de erros de login, as tentativa sem sucesso de acesso ao sistema
function delTentativaLogin($usuario)
{
$sistema = SISTEMA_CODIGO;
$query = "delete from sis_errologin where usuario='$usuario' and sistema = '$sistema'";
execQuery($query) or die("Ocorreu um erro inesperado ao excluir tentativas de acesso");
}
/*---------------------------------------------------------------------------
* verifica da existencia de uma tentativa de acesso, sem sucesso, ao sistema
* e retorna se deve ser usado o recaptcha para proxima tentativa de acesso
*---------------------------------------------------------------------------*/
function usaRecaptcha($usuario)
{
if (empty($usuario)) return false;
$sistema = SISTEMA_CODIGO;
$query
= "select * from sis_errologin
where usuario='$usuario' and sistema = '$sistema'";
$rs = execQuery($query);
//se houver tentativas registradas retorna true para exibir o controle recaptcha
return (mysql_num_rows($rs) > 0);
}
function autentica($login, $pwd, $tipo)
{
if (empty($login) or empty($pwd)) {
if (!empty($login))
setTentativaLogin($login);
return false;
}
$query
= "select idsolicitante as id, nome, confirmado, email
from lda_solicitante
where cpfcnpj='$login' and chave = '" . md5($pwd) . "' ";
$rs = execQuery($query);
if (mysql_num_rows($rs)!=0) {
$row = mysql_fetch_array($rs);
} else {
//inclui tentativa de acesso ao sistema, para usar o recaptcha no proximo login
setTentativaLogin($login);
return false;
}
//exclui tentativas de acesso ao sistema do usuario (para evitar o recaptcha no proximo login)
delTentativaLogin($login);
$apelido = explode(" ", $row['nome']);
$var = array();
$var["uid"] = $row['id'];
$var["nomeusuario"] = $row['nome'];
$var["emailusuario"] = $row['email'];
$var["apelidousuario"] = $apelido[0];
$var["confirmado"] = ($row['confirmado']) ? "S" : "N";
$_SESSION[SISTEMA_CODIGO] = $var;
return true;
}
/*pega o diretorio padrao para grava��o de arquivos
$sis = sistema para busca do diretorio na tabela de parametros
*/
function getDiretorio($sis = "lda")
{
$query = "select diretorioarquivos from lda_configuracao";
$rs = execQuery($query);
if (mysql_num_rows($rs)!=0) {
$row = mysql_fetch_array($rs);
$retorno = $row['diretorioarquivos'];
}
return $retorno;
}
/*paga o URL padrao para exibi��o de arquivos
$sis = sistema para busca do diretorio na tabela de parametros
*/
function getURL($sis = "alb")
{
$query = "select urlarquivos from lda_configuracao";
$rs = execQuery($query);
if (mysql_num_rows($rs)!=0) {
$row = mysql_fetch_array($rs);
$retorno = $row['urlarquivos'];
}
return $retorno;
}
function prepData($var)
{
$conn = db_open();
if (get_magic_quotes_gpc()) {
$var = stripslashes($var);
}
$retorno = mysql_real_escape_string($var);
db_close($conn);
return $retorno;
}
function logger($msg)
{
$usuario = getSession("uid");
$usuario = empty($usuario) ? "SYSTEM" : $usuario;
// Ugly fix pra nao permitir salvar senha em banco.
unset($_POST["senha"]);
$mensagem = $msg;
$datahora = "now()";
$dados_post = prepData(serialize($_POST));
$dados_get = prepData(serialize($_GET));
$dados_session = prepData(serialize($_SESSION));
$ipaddr = $_SERVER["REMOTE_ADDR"];
$query = "insert into sis_log (usuario,mensagem,datahora,dados_get,dados_post,ipaddr) values('$usuario','$mensagem',$datahora,'$dados_get','$dados_post','$ipaddr')";
execQuery($query) or die("Erro logando");
}
function getErro($msg)
{
//Exibe mensagem de erro passado pelas telas de manuten��o
if (trim($msg)!="")
echo "<script>alert('$msg'); </script>";
}
function getConfirmacao($msg, $funcaoConfirmacao)
{
//Exibe mensagem de Confirmação passado pelas telas de manuten��o
//funcaoConfirmacao -> fun��o javascript com o alert de Confirmação e procedimentos a serem seguidos.
if (trim($msg)!="")
echo "<script> $funcaoConfirmacao('$msg'); </script>";
}
function Redirect($url)
{
Header("Location:$url");
}
function isauth($tipo = "consumidor")
{
session_start();
if (!isset($_SESSION[SISTEMA_CODIGO])) {
Redirect(SITELNK . "index/?t=" . $tipo);
exit;
}
}
session_start();