[ Index ] |
|
Code source de LifeType 1.2.4 |
1 <?php 2 3 lt_include( PLOG_CLASS_PATH."class/summary/action/summaryaction.class.php" ); 4 lt_include( PLOG_CLASS_PATH."class/summary/view/summarymessageview.class.php" ); 5 lt_include( PLOG_CLASS_PATH."class/data/validator/stringvalidator.class.php" ); 6 lt_include( PLOG_CLASS_PATH."class/data/validator/emailvalidator.class.php" ); 7 lt_include( PLOG_CLASS_PATH."class/data/filter/htmlfilter.class.php" ); 8 lt_include( PLOG_CLASS_PATH."class/data/filter/htmlspecialcharsfilter.class.php" ); 9 lt_include( PLOG_CLASS_PATH."class/dao/users.class.php" ); 10 lt_include( PLOG_CLASS_PATH."class/summary/data/summarytools.class.php" ); 11 lt_include( PLOG_CLASS_PATH."class/config/config.class.php" ); 12 13 /** 14 * sends an email to reset a password, first checking whether the username 15 * and the given mailbox really exist 16 */ 17 class SummarySendResetEmail extends SummaryAction 18 { 19 20 var $_userName; 21 var $_userEmail; 22 23 function SummarySendResetEmail( $actionInfo, $request ) 24 { 25 $this->SummaryAction( $actionInfo, $request ); 26 27 // data filtering 28 $f = new HtmlFilter(); 29 $f->addFilter( new HtmlSpecialCharsFilter()); 30 $this->_request->registerFilter( "userName", $f ); 31 $this->_request->registerFilter( "userEmail", $f ); 32 33 // data validation 34 $this->registerFieldValidator( "userName", new StringValidator()); 35 $this->registerFieldValidator( "userEmail", new EmailValidator()); 36 $this->setValidationErrorView( new SummaryView( "resetpassword" )); 37 } 38 39 function perform() 40 { 41 // fetch the data 42 $this->_userName = $this->_request->getValue( "userName" ); 43 $this->_userEmail = $this->_request->getValue( "userEmail" ); 44 45 // try to see if there is a user who has this username and uses the 46 // given mailbox as the email address 47 $users = new Users(); 48 $userInfo = $users->getUserInfoFromUsername( $this->_userName ); 49 50 // if the user doesn't exist, quit 51 if( !$userInfo ) { 52 $this->_view = new SummaryView( "resetpassword" ); 53 $this->_form->setFieldValidationStatus( "userName", false ); 54 $this->setCommonData( true ); 55 return false; 56 } 57 58 // if the user exists but this is not his/her mailbox, then quit too 59 if( $userInfo->getEmail() != $this->_userEmail ) { 60 $this->_view = new SummaryView( "resetpassword" ); 61 $this->_form->setFieldValidationStatus( "userEmail", false ); 62 $this->setCommonData( true ); 63 return false; 64 } 65 66 // if everything's fine, then send out the email message with a request to 67 // reset the password 68 $requestHash = SummaryTools::calculatePasswordResetHash( $userInfo ); 69 $config =& Config::getConfig(); 70 $baseUrl = $config->getValue( "base_url" ); 71 $resetUrl = $baseUrl."/summary.php?op=setNewPassword&a=$requestHash&b=".md5($userInfo->getUsername()); 72 73 SummaryTools::sendResetEmail( $userInfo, $resetUrl ); 74 75 $this->_view = new SummaryMessageView( $this->_locale->tr( "password_reset_message_sent_ok" )); 76 77 $this->setCommonData(); 78 79 return true; 80 } 81 } 82 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Mon Nov 26 21:04:15 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |