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

Source for file change_password.php

Documentation is available at change_password.php

  1. <?php
  2. /**
  3.  * change password
  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. if( !isset( $_REQUEST['login'] )) {
  16.     $_REQUEST['login'] = '';
  17. }
  18. if( !isset( $_REQUEST['user_id'] )) {
  19.     $_REQUEST['user_id'] = '';
  20. }
  21. if( !isset( $_REQUEST["oldpass"] )) {
  22.     $_REQUEST["oldpass"] = '';
  23. }
  24. if( !isset( $_REQUEST["provpass"] )) {
  25.     $_REQUEST["provpass"] = '';
  26. }
  27.  
  28. $gBitSmarty->assign( 'login', $_REQUEST['login'] );
  29. $gBitSmarty->assign( 'oldpass', $_REQUEST["oldpass"] );
  30. $gBitSmarty->assign( 'provpass', $_REQUEST["provpass"] );
  31.  
  32. $userInfo = $gBitUser->getUserInfo( array( 'user_id' => $_REQUEST['user_id'] ));
  33. $gBitSmarty->assign_by_ref( 'userInfo', $userInfo );
  34.  
  35. if( isset( $_REQUEST["change"] )) {
  36.  
  37.     if( $_REQUEST["pass"] == $_REQUEST["oldpass"] ) {
  38.         $gBitSystem->fatalError( tra( "You can not use the same password again" ));
  39.     }
  40.  
  41.     if( $passswordError = $gBitUser->verifyPasswordFormat( $_REQUEST["pass"], $_REQUEST["pass2"] )) {
  42.         $gBitSystem->fatalError( tra( $passswordError ));
  43.     }
  44.  
  45.     $validated = FALSE;
  46.     if( !empty( $_REQUEST["provpass"] ) ) {
  47.         if( $validated = $gBitUser->confirmRegistration( $userInfo['user_id'], $_REQUEST["provpass"] ) ) {
  48.             if( $gBitSystem->isFeatureActive( 'send_welcome_email' ) ) {
  49.                 $siteName = $gBitSystem->getConfig( 'site_title', $_SERVER['HTTP_HOST'] );
  50.                 // Send the welcome mail
  51.                 $gBitSmarty->assign( 'siteName', $_SERVER["SERVER_NAME"] );
  52.                 $gBitSmarty->assign( 'mail_site', $_SERVER["SERVER_NAME"] );
  53.                 $gBitSmarty->assign( 'mail_user', $userInfo['login'] );
  54.                 $gBitSmarty->assign( 'mailPassword',$_REQUEST['pass'] );
  55.                 $gBitSmarty->assign( 'mailEmail',$validated['email'] );
  56.                 $mail_data = $gBitSmarty->fetch('bitpackage:users/welcome_mail.tpl');
  57.                 mail($validated["email"], tra( 'Welcome to' ).' '.$siteName,$mail_data,"From: ".$gBitSystem->getConfig('site_sender_email')."\r\nContent-type: text/plain;charset=utf-8\r\n");
  58.             }
  59.         } else    {
  60.                 $gBitSystem->fatalError( tra("Password reset request is invalid or has expired") );
  61.         }
  62.     } elseif( !( $validated = $gBitUser->validate( $userInfo['email'], $_REQUEST["oldpass"], '', '' )) ) {
  63.         $gBitSystem->fatalError( tra("Invalid old password") );
  64.     }
  65.  
  66.     if( $validated ) {
  67.         $gBitUser->storePassword( $_REQUEST["pass"], (!empty( $userInfo['login'] )?$userInfo['login']:$userInfo['email']) );
  68.         $url = $gBitUser->login( (!empty( $userInfo['login'] )?$userInfo['login']:$userInfo['email']), $_REQUEST["pass"] );
  69.     }
  70.  
  71.     bit_redirect( $url );
  72. }
  73.  
  74. // Display the template
  75. $gBitSystem->display( 'bitpackage:users/change_password.tpl', 'Change Password' , array( 'display_mode' => 'display' ));
  76.  
  77. ?>

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