[ Index ] |
|
Code source de dotProject 2.1 RC1 |
1 <?php 2 /** 3 * @package dotproject 4 * @subpackage core 5 * @license http://opensource.org/licenses/bsd-license.php BSD License 6 */ 7 8 if (!defined('DP_BASE_DIR')) { 9 die('You should not access this file directly'); 10 } 11 require_once( $AppUI->getSystemClass( 'libmail' ) ); 12 13 // 14 // New password code based oncode from Mambo Open Source Core 15 // www.mamboserver.com | mosforge.net 16 // 17 function sendNewPass() { 18 global $AppUI, $dPconfig; 19 20 $_live_site = $dPconfig['base_url']; 21 $_sitename = $dPconfig['company_name']; 22 23 // ensure no malicous sql gets past 24 $checkusername = trim( dPgetParam( $_POST, 'checkusername', '') ); 25 $checkusername = db_escape( $checkusername ); 26 $confirmEmail = trim( dPgetParam( $_POST, 'checkemail', '') ); 27 $confirmEmail = strtolower( db_escape( $confirmEmail ) ); 28 29 $query = "SELECT user_id FROM users" 30 ." LEFT JOIN contacts ON user_contact = contact_id" 31 . "\nWHERE user_username='$checkusername' AND LOWER(contact_email)='$confirmEmail'" 32 ; 33 if (!($user_id = db_loadResult($query)) || !$checkusername || !$confirmEmail) { 34 $AppUI->setMsg( 'Invalid username or email.', UI_MSG_ERROR ); 35 $AppUI->redirect(); 36 } 37 38 $newpass = makePass(); 39 $message = $AppUI->_('sendpass0', UI_OUTPUT_RAW)." $checkusername ". $AppUI->_('sendpass1', UI_OUTPUT_RAW) . " $_live_site ". $AppUI->_('sendpass2', UI_OUTPUT_RAW) ." $newpass ". $AppUI->_('sendpass3', UI_OUTPUT_RAW); 40 $subject = "$_sitename :: ".$AppUI->_('sendpass4', UI_OUTPUT_RAW)." - $checkusername"; 41 42 $m= new Mail; // create the mail 43 $m->From( "dotProject" ); 44 $m->To( $confirmEmail ); 45 $m->Subject( $subject ); 46 $m->Body( $message, isset( $GLOBALS['locale_char_set']) ? $GLOBALS['locale_char_set'] : "" ); // set the body 47 $m->Send(); // send the mail 48 49 $newpass = md5( $newpass ); 50 $sql = "UPDATE users SET user_password='$newpass' WHERE user_id='$user_id'"; 51 $cur = db_exec( $sql ); 52 if (!$cur) { 53 die("SQL error" . $database->stderr(true)); 54 } else { 55 $AppUI->setMsg( 'New User Password created and emailed to you' ); 56 $AppUI->redirect(); 57 } 58 } 59 60 function makePass(){ 61 $makepass=""; 62 $salt = "abchefghjkmnpqrstuvwxyz0123456789"; 63 srand((double)microtime()*1000000); 64 $i = 0; 65 while ($i <= 7) { 66 $num = rand() % 33; 67 $tmp = substr($salt, $num, 1); 68 $makepass = $makepass . $tmp; 69 $i++; 70 } 71 return ($makepass); 72 } 73 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 18 19:46:52 2007 | par Balluche grâce à PHPXref 0.7 |