users
[ class tree: users ] [ index: users ] [ all elements ]

Source for file remind_password.php

Documentation is available at remind_password.php

  1. <?php
  2. /**
  3.  * password reminder
  4.  *
  5.  * @copyright (c) 2004-15 bitweaver.org
  6.  *
  7.  * @package users
  8.  * @subpackage functions
  9.  */
  10.  
  11. /**
  12.  * required setup
  13.  */
  14. require_once( '../kernel/setup_inc.php' );
  15.  
  16. $gBitSystem->verifyFeature( 'users_forgot_pass' );
  17.  
  18. $pageTitle = tra( 'Request Password Reminder' );
  19.  
  20. if( $gBitUser->isRegistered() ) {
  21.     header( 'Location: '.BIT_ROOT_URL );
  22.     die;
  23. } elseif (isset($_REQUEST["remind"])) {
  24.     $userInfo = '';
  25.     $_REQUEST["username"] = strip_tags( urldecode( $_REQUEST["username"]) );
  26.     $pLogin = trim( $_REQUEST["username"] );
  27.     if ( strlen ( $pLogin ) ) {
  28.         $loginCol = strpos( $pLogin, '@' ) ? 'email' : 'login';
  29.         $userInfo = $gBitUser->getUserInfo( array( $loginCol => $pLogin ) );
  30.     }
  31.     if( $userInfo ) {
  32.         if ( $gBitSystem->isFeatureActive( 'users_clear_passwords' ) && !empty($userInfo['user_password']) ) {
  33.             $gBitSmarty->assign( 'userPass', $userInfo['user_password'] );
  34.             $tmp['success'] = tra("A password reminder email has been sent ");
  35.             $pass = $userInfo['user_password'];
  36.         } else {
  37.             $pass = $gBitUser->genPass();
  38.             list($pass,$provpass) = $gBitUser->createTempPassword( $_REQUEST["username"], $pass );
  39.             $gBitSmarty->assign( 'mailProvPass', $provpass );
  40.             $gBitSmarty->assign( 'mailUserId', $userInfo['user_id'] );
  41.             $pageTitle = tra( 'Change Your Password' );
  42.             $tmp['success'] = tra("Information to change your password has been sent ");
  43.         }
  44.         $tmp['success'] .= tra("to the registered email address for")." " . $_REQUEST["username"] . ".";
  45.  
  46.         $gBitSmarty->assign('mail_user', $userInfo[$loginCol]);
  47.         $gBitSmarty->assign('mail_same', $gBitSystem->isFeatureActive( 'users_clear_passwords' ));
  48.         $gBitSmarty->assign('mail_pass', $pass);
  49.         $gBitSmarty->assign('linkUri', $gBitSystem->isFeatureActive("site_https_login_required") ? 'https://'.$_SERVER['HTTP_HOST'].USERS_PKG_URL : USERS_PKG_URI );
  50.         $mail_data = $gBitSmarty->fetch('bitpackage:users/password_reminder.tpl');
  51.         $subject = tra( "Your password for" ).": ".$gBitSystem->getConfig( 'site_title', $_SERVER['HTTP_HOST'] );
  52.         mail( $userInfo['email'], $subject, $mail_data, "From: ".$gBitSystem->getConfig( 'site_sender_email' )."\nContent-type: text/plain;charset=utf-8\n");
  53.         // Just show "success" message and no form
  54.     } else {
  55.         // Show error message (and leave form visible so user can fix problem)
  56.         $gBitSmarty->assign('showmsg', 'e');
  57.         $tmp['error'] = tra("Invalid or unknown username").": ".$_REQUEST["username"];
  58.     }
  59.     $gBitSmarty->assign('msg', $tmp);
  60. }
  61. // Display the template
  62. $gBitSystem->display( 'bitpackage:users/remind_password.tpl', $pageTitle, array( 'display_mode' => 'display' ));

Documentation generated on Wed, 29 Jul 2015 13:57:19 +0000 by phpDocumentor 1.5.0-lsces