Viewing file: esqueci_senha.php (10.12 KB) -rwxr-xr-x Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php ############################################################################# # Nome: esqueci_senha.php # # System: Irpen # # Criado por: Breno Henrique Vivarelli # # Empresa: Netnigro # # E-mail: breno@netnigro.com.br # # Descrição: Envia nova senha para o usuário # # Histórico: # # . 24/06/2008 - Breno Henrique Vivarelli # # Criação da Página # ############################################################################# // Includes include("config/config.php"); include(INCLUDES . "conexaoBD.php"); include(INCLUDES . "funcoes_uteis.php"); $urlPhpMailer = "./site/ipanel/app/system/email/PHPMailer.php"; require_once($urlPhpMailer); if(isset($_POST["btnOk"])) { $email = $_POST["txtEmail"]; $email_confirmado = $_POST["txtEmailConfirmado"]; if(strcmp($email,$email_confirmado) == 0) { $senha = GeraSenhaAleatoria(); $sql = "SELECT * FROM usuarios " . "WHERE USU_Email = '$email' "; $rs_usuario = $conexao->query($sql); $usuario = $rs_usuario->fetch_assoc();
$senha_md5 = md5($senha); $nome_usuario = $usuario["USU_Descricao"]; $sql = "UPDATE usuarios " . "SET USU_Senha = '$senha_md5' " . "WHERE USU_Email = '$email' "; $conexao->query($sql); if($conexao->affected_rows > 0) {
$assunto = " SOLICITAÇÃO PARA CRIAÇÃO DE NOVA SENHA DE ACESSO AO SISTEMA"; $body.= " ============================================================ "; $body.= "\n<br>"; $body.= " SOLICITAÇÃO PARA CRIAÇÃO DE NOVA SENHA DE ACESSO AO SISTEMA "; $body.= "\n<br>"; $body.= " ============================================================ "; $body.= "\n<br>"; $body.= "\n<br>"; $body.= "<font face='arial' size='2'> Caro(a) <b> $nome_usuario</b>,"; $body.= "\n<br>"; $body.= "\n<br>"; $body.= " Conforme solicitado, estamos enviando sua nova senha para acesso "; $body.= " Sistema IRPEN: "; $body.= "\n<br>"; $body.= "\n<br>"; $body.= " <b> Login: </b>" . $email; $body.= "\n<br>"; $body.= " <b> Senha: </b>" . $senha; $body.= "\n<br>"; $body.= "\n<br>"; $body.= "\n<br>"; $body.= "\n<br>"; $body.= " Atenciosamente," ; $body.= "\n<br>"; $body.= "\n<br>"; $corpo_email = "<html> <head> <title>$assunto</title> <style type=\"text/css\"> body { font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 12px; text-align: justify; width: 640px; max-width: 640px; margin: auto; } </style> </head> <body>" . stripslashes($body) . " </body> </html>"; $mail = new PHPMailer; $mail->From = 'contato@arpenpr.org.br'; $mail->FromName = 'Contato - IRPEN'; $mail->IsSMTP(); // Set mailer to use SMTP $mail->Host = 'smtp.arpenpr.org.br'; $mail->SMTPAuth = true; $mail->Username = "smtp@arpenpr.org.br"; $mail->Password = "ArpenPRIrpen\$br23"; $mail->IsHTML(true); $mail->Subject = $assunto; $mail->AddAddress($email); $mail->AddBcc('oscar@roko.com.br'); $mail->AddBcc('giuliano.silveira@roko.com.br'); $mail->Body = $corpo_email; $rs = $mail->Send(); if($rs==1) { $conexao->commit(); $tipo_msg = "msg_ok"; $msg = "Uma nova senha foi gerada e enviada ao e-mail informado."; } else { $conexao->rollback(); $tipo_msg = "msg_erro"; $msg = "O e-mail informado não é válido."; } } else { $tipo_msg = "msg_erro"; $msg = "O e-mail informado não está cadastrado no sistema."; } } else { $tipo_msg = "msg_erro"; $msg = "Confirme o e-mail corretamente."; } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml2/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <link rel="stylesheet" href="css/irpen.css" type="text/css" /> <link rel="stylesheet" media="all" type="text/css" href="css/menu_dropline.css" /> <!--[if IE]> <link rel="stylesheet" media="all" type="text/css" href="css/menu_dropline_ie.css" /> <![endif]--> <!--[if lt IE 7]> <link rel="stylesheet" media="all" type="text/css" href="css/menu_dropline_ie6.css" /> <![endif]--> <title>IRPEN | Instituto de Registro Civil de Pessoas Naturais do Paraná - 2010</title> <!-- <script src="scripts/delay.js" language="JavaScript"></script> --> <script type="text/javascript" src="<?= HOST;?>lib/jquery-1.2.6.js"></script> <script type="text/javascript" src="<?= HOST;?>lib/jquery.form.js"></script> <script type="text/javascript" src="<?= HOST;?>lib/email.js"></script> <script type="text/javascript" src="<?= HOST;?>scripts/esqueci_senha.js"></script> </head> <body> <div id="wrap_info_oficio"> <div id="top-bg" style="background: #fff!important;"> </div> <div id="header"> <div id="logo"> <img src="site/images/logo-novo.png" style="width: 170px; height: 50px; margin-top: 10px;"></img> </div> </div> <!-- content-wrap starts --> <div id="content-wrap"> <table width="100%" border="0"> <tr> <td width="79%" align="left" valign="top"> <h2>ESQUECI MINHA SENHA</h2> <div id="linha_h2" > </div> <div id="conteudo_meio" style="margin-right: 10px;" > <br /> <form name="frmEsqueciSenha" id="frmEsqueciSenha" action="esqueci_senha.php" enctype="multipart/form-data" method="post"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td align="right" width="27%"> <strong>E-mail: </strong> </td> <td align="left" width="73%"> <input type="text" name="txtEmail" id="txtEmail" size="50"> </td> </tr> <tr> <td align="right"> <strong>Confirme o e-mail: </strong> </td> <td align="left"> <input type="text" name="txtEmailConfirmado" id="txtEmailConfirmado" size="50"> </td> </tr> <tr> <td align="center" colspan="2"> <br /> <input type="submit" name="btnOk" id="btnOk" value="Ok" class="button"/> <br /> </td> </tr> </table> <br /> <?php if((isset($msg)) && (!empty($msg))) { ?> <div class="msg_erro" align="center"> <?= $msg;?> </div> <?php } ?> <br /> </form> </div> </td> </tr> </table> </div> <!-- footer starts --> <div id="footer-wrap"> </div> </div> </body> </html>
|