source: temp/test-xoops.ec-cube.net/html/lostpass.php @ 405

Revision 405, 4.9 KB checked in by root, 20 years ago (diff)
Line 
1<?php
2// $Id: lostpass.php,v 1.4 2006/05/01 02:37:26 onokazu Exp $
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";
29include "mainfile.php";
30$email = isset($_GET['email']) ? trim($_GET['email']) : '';
31$email = isset($_POST['email']) ? trim($_POST['email']) : $email;
32if ($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
41if (empty($getuser)) {
42    redirect_header("user.php",2,_US_SORRYNOTFOUND);
43    exit();
44} else {
45    $code = isset($_GET['code']) ? trim($_GET['code']) : '';
46    $areyou = substr($getuser[0]->getVar("pass"), 0, 5);
47    if ($code != '' && $areyou == $code) {
48        $newpass = xoops_makepass();
49        $xoopsMailer =& getMailer();
50        $xoopsMailer->useMail();
51        $xoopsMailer->setTemplate("lostpass2.tpl");
52        $xoopsMailer->assign("SITENAME", $xoopsConfig['sitename']);
53        $xoopsMailer->assign("ADMINMAIL", $xoopsConfig['adminmail']);
54        $xoopsMailer->assign("SITEURL", XOOPS_URL."/");
55        $xoopsMailer->assign("IP", $_SERVER['REMOTE_ADDR']);
56        $xoopsMailer->assign("NEWPWD", $newpass);
57        $xoopsMailer->setToUsers($getuser[0]);
58        $xoopsMailer->setFromEmail($xoopsConfig['adminmail']);
59        $xoopsMailer->setFromName($xoopsConfig['sitename']);
60        $xoopsMailer->setSubject(sprintf(_US_NEWPWDREQ,XOOPS_URL));
61        if ( !$xoopsMailer->send() ) {
62            echo $xoopsMailer->getErrors();
63        }
64
65        // Next step: add the new password to the database
66        $sql = sprintf("UPDATE %s SET pass = '%s' WHERE uid = %u", $xoopsDB->prefix("users"), md5($newpass), $getuser[0]->getVar('uid'));
67        if ( !$xoopsDB->queryF($sql) ) {
68            include "header.php";
69            echo _US_MAILPWDNG;
70            include "footer.php";
71            exit();
72        }
73        redirect_header("user.php", 3, sprintf(_US_PWDMAILED,$getuser[0]->getVar("uname")), false);
74        exit();
75    // If no Code, send it
76    } else {
77        $xoopsMailer =& getMailer();
78        $xoopsMailer->useMail();
79        $xoopsMailer->setTemplate("lostpass1.tpl");
80        $xoopsMailer->assign("SITENAME", $xoopsConfig['sitename']);
81        $xoopsMailer->assign("ADMINMAIL", $xoopsConfig['adminmail']);
82        $xoopsMailer->assign("SITEURL", XOOPS_URL."/");
83        $xoopsMailer->assign("IP", $_SERVER['REMOTE_ADDR']);
84        $xoopsMailer->assign("NEWPWD_LINK", XOOPS_URL."/lostpass.php?email=".$email."&code=".$areyou);
85        $xoopsMailer->setToUsers($getuser[0]);
86        $xoopsMailer->setFromEmail($xoopsConfig['adminmail']);
87        $xoopsMailer->setFromName($xoopsConfig['sitename']);
88        $xoopsMailer->setSubject(sprintf(_US_NEWPWDREQ,$xoopsConfig['sitename']));
89        include "header.php";
90        if ( !$xoopsMailer->send() ) {
91            echo $xoopsMailer->getErrors();
92        }
93        echo "<h4>";
94        printf(_US_CONFMAIL,$getuser[0]->getVar("uname"));
95        echo "</h4>";
96        include "footer.php";
97    }
98}
99?>
Note: See TracBrowser for help on using the repository browser.