[ Index ]

PHP Cross Reference of Xoops v2.3.1

[Global whois Lookup]    [Ranchi, Jharkhand, India website]     [Hindi Magazine]     [Desi Community website in tristate area]    [B 4 Bollywood]    [Internet nation of India]

title

Body

[close]

/ -> lostpass.php (source)

   1  <?php
   2  // $Id: lostpass.php 1969 2008-08-24 02:13:23Z phppp $

   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  
  33  $module_handler = xoops_gethandler('module');
  34  $profile_module = $module_handler->getByDirname('profile');
  35  if ($profile_module && $profile_module->getVar('isactive')) {
  36      header("location: ./modules/profile/lostpass.php?email={$email}" . (empty($_GET['code']) ? "" : "&" . $_GET['code']) );
  37      exit();
  38  }
  39  
  40  xoops_loadLanguage('user');
  41  
  42  if ($email == '') {
  43      redirect_header("user.php",2,_US_SORRYNOTFOUND);
  44      exit();
  45  }
  46  
  47  $myts =& MyTextSanitizer::getInstance();
  48  $member_handler =& xoops_gethandler('member');
  49  $getuser =& $member_handler->getUsers(new Criteria('email', $myts->addSlashes($email)));
  50  
  51  if (empty($getuser)) {
  52      $msg = _US_SORRYNOTFOUND;
  53      redirect_header("user.php",2,$msg);
  54      exit();
  55  } else {
  56      $code = isset($_GET['code']) ? trim($_GET['code']) : '';
  57      $areyou = substr($getuser[0]->getVar("pass"), 0, 5);
  58      if ($code != '' && $areyou == $code) {
  59          $newpass = xoops_makepass();
  60          $xoopsMailer =& xoops_getMailer();
  61          $xoopsMailer->useMail();
  62          $xoopsMailer->setTemplate("lostpass2.tpl");
  63          $xoopsMailer->assign("SITENAME", $xoopsConfig['sitename']);
  64          $xoopsMailer->assign("ADMINMAIL", $xoopsConfig['adminmail']);
  65          $xoopsMailer->assign("SITEURL", XOOPS_URL."/");
  66          $xoopsMailer->assign("IP", $_SERVER['REMOTE_ADDR']);
  67          $xoopsMailer->assign("NEWPWD", $newpass);
  68          $xoopsMailer->setToUsers($getuser[0]);
  69          $xoopsMailer->setFromEmail($xoopsConfig['adminmail']);
  70          $xoopsMailer->setFromName($xoopsConfig['sitename']);
  71          $xoopsMailer->setSubject(sprintf(_US_NEWPWDREQ,XOOPS_URL));
  72          if ( !$xoopsMailer->send() ) {
  73              echo $xoopsMailer->getErrors();
  74          }
  75  
  76          // Next step: add the new password to the database

  77          $sql = sprintf("UPDATE %s SET pass = '%s' WHERE uid = %u", $xoopsDB->prefix("users"), md5($newpass), $getuser[0]->getVar('uid'));
  78          if ( !$xoopsDB->queryF($sql) ) {
  79              include  "header.php";
  80              echo _US_MAILPWDNG;
  81              include  "footer.php";
  82              exit();
  83          }
  84          redirect_header("user.php", 3, sprintf(_US_PWDMAILED,$getuser[0]->getVar("uname")), false);
  85          exit();
  86      // If no Code, send it

  87      } else {
  88          $xoopsMailer =& xoops_getMailer();
  89          $xoopsMailer->useMail();
  90          $xoopsMailer->setTemplate("lostpass1.tpl");
  91          $xoopsMailer->assign("SITENAME", $xoopsConfig['sitename']);
  92          $xoopsMailer->assign("ADMINMAIL", $xoopsConfig['adminmail']);
  93          $xoopsMailer->assign("SITEURL", XOOPS_URL."/");
  94          $xoopsMailer->assign("IP", $_SERVER['REMOTE_ADDR']);
  95          $xoopsMailer->assign("NEWPWD_LINK", XOOPS_URL."/lostpass.php?email=".$email."&code=".$areyou);
  96          $xoopsMailer->setToUsers($getuser[0]);
  97          $xoopsMailer->setFromEmail($xoopsConfig['adminmail']);
  98          $xoopsMailer->setFromName($xoopsConfig['sitename']);
  99          $xoopsMailer->setSubject(sprintf(_US_NEWPWDREQ,$xoopsConfig['sitename']));
 100          include  "header.php";
 101          if ( !$xoopsMailer->send() ) {
 102              echo $xoopsMailer->getErrors();
 103          }
 104          echo "<h4>";
 105          printf(_US_CONFMAIL,$getuser[0]->getVar("uname"));
 106          echo "</h4>";
 107          include  "footer.php";
 108      }
 109  }
 110  ?>


[ Xoops]     [PhpNuke]     [PostNuke]     [Joomla]    [Drupal]    [E107]    [NucleusCms]
[Php-Fusion]     [PhpBB]     [WordPress]     [Typo3]
Generated: Mon Oct 27 11:51:45 2008
Open Source related documentation for developers.