| [ Index ] |
|
Code source de XOOPS 2.0.17.1 |
1 <?php 2 // $Id: lostpass.php 2 2005-11-02 18:23:29Z skalpa $ 3 // ------------------------------------------------------------------------ // 4 // XOOPS - PHP Content Management System // 5 // Copyright (c) 2000 XOOPS.org // 6 // <http://www.xoops.org/> // 7 // ------------------------------------------------------------------------ // 8 // This program is free software; you can redistribute it and/or modify // 9 // it under the terms of the GNU General Public License as published by // 10 // the Free Software Foundation; either version 2 of the License, or // 11 // (at your option) any later version. // 12 // // 13 // You may not change or alter any portion of this comment or credits // 14 // of supporting developers from this source code or any supporting // 15 // source code which is considered copyrighted (c) material of the // 16 // original comment or credit authors. // 17 // // 18 // This program is distributed in the hope that it will be useful, // 19 // but WITHOUT ANY WARRANTY; without even the implied warranty of // 20 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // 21 // GNU General Public License for more details. // 22 // // 23 // You should have received a copy of the GNU General Public License // 24 // along with this program; if not, write to the Free Software // 25 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // 26 // ------------------------------------------------------------------------ // 27 28 $xoopsOption['pagetype'] = "user"; 29 include "mainfile.php"; 30 $email = isset($_GET['email']) ? trim($_GET['email']) : ''; 31 $email = isset($_POST['email']) ? trim($_POST['email']) : $email; 32 if ($email == '') { 33 redirect_header("user.php",2,_US_SORRYNOTFOUND); 34 exit(); 35 } 36 37 $myts =& MyTextSanitizer::getInstance(); 38 $member_handler =& xoops_gethandler('member'); 39 $getuser =& $member_handler->getUsers(new Criteria('email', $myts->addSlashes($email))); 40 41 if (empty($getuser)) { 42 $msg = _US_SORRYNOTFOUND; 43 redirect_header("user.php",2,$msg); 44 exit(); 45 } else { 46 $code = isset($_GET['code']) ? trim($_GET['code']) : ''; 47 $areyou = substr($getuser[0]->getVar("pass"), 0, 5); 48 if ($code != '' && $areyou == $code) { 49 $newpass = xoops_makepass(); 50 $xoopsMailer =& getMailer(); 51 $xoopsMailer->useMail(); 52 $xoopsMailer->setTemplate("lostpass2.tpl"); 53 $xoopsMailer->assign("SITENAME", $xoopsConfig['sitename']); 54 $xoopsMailer->assign("ADMINMAIL", $xoopsConfig['adminmail']); 55 $xoopsMailer->assign("SITEURL", XOOPS_URL."/"); 56 $xoopsMailer->assign("IP", $_SERVER['REMOTE_ADDR']); 57 $xoopsMailer->assign("NEWPWD", $newpass); 58 $xoopsMailer->setToUsers($getuser[0]); 59 $xoopsMailer->setFromEmail($xoopsConfig['adminmail']); 60 $xoopsMailer->setFromName($xoopsConfig['sitename']); 61 $xoopsMailer->setSubject(sprintf(_US_NEWPWDREQ,XOOPS_URL)); 62 if ( !$xoopsMailer->send() ) { 63 echo $xoopsMailer->getErrors(); 64 } 65 66 // Next step: add the new password to the database 67 $sql = sprintf("UPDATE %s SET pass = '%s' WHERE uid = %u", $xoopsDB->prefix("users"), md5($newpass), $getuser[0]->getVar('uid')); 68 if ( !$xoopsDB->queryF($sql) ) { 69 include "header.php"; 70 echo _US_MAILPWDNG; 71 include "footer.php"; 72 exit(); 73 } 74 redirect_header("user.php", 3, sprintf(_US_PWDMAILED,$getuser[0]->getVar("uname")), false); 75 exit(); 76 // If no Code, send it 77 } else { 78 $xoopsMailer =& getMailer(); 79 $xoopsMailer->useMail(); 80 $xoopsMailer->setTemplate("lostpass1.tpl"); 81 $xoopsMailer->assign("SITENAME", $xoopsConfig['sitename']); 82 $xoopsMailer->assign("ADMINMAIL", $xoopsConfig['adminmail']); 83 $xoopsMailer->assign("SITEURL", XOOPS_URL."/"); 84 $xoopsMailer->assign("IP", $_SERVER['REMOTE_ADDR']); 85 $xoopsMailer->assign("NEWPWD_LINK", XOOPS_URL."/lostpass.php?email=".$email."&code=".$areyou); 86 $xoopsMailer->setToUsers($getuser[0]); 87 $xoopsMailer->setFromEmail($xoopsConfig['adminmail']); 88 $xoopsMailer->setFromName($xoopsConfig['sitename']); 89 $xoopsMailer->setSubject(sprintf(_US_NEWPWDREQ,$xoopsConfig['sitename'])); 90 include "header.php"; 91 if ( !$xoopsMailer->send() ) { 92 echo $xoopsMailer->getErrors(); 93 } 94 echo "<h4>"; 95 printf(_US_CONFMAIL,$getuser[0]->getVar("uname")); 96 echo "</h4>"; 97 include "footer.php"; 98 } 99 } 100 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
| Généré le : Sun Nov 25 11:44:32 2007 | par Balluche grâce à PHPXref 0.7 |
|