![]() |
|---|
| [ Index ] |
Source Code Reference for V1.00 |
[Summary view] [Print] [Text view]
1 <?php /* $Id: sendpass.php 135 2008-04-04 13:49:13Z pedroix $ $URL: https://web2project.svn.sourceforge.net/svnroot/web2project/trunk/includes/sendpass.php $ */ 2 /** 3 * @package web2project 4 * @subpackage core 5 * @license http://opensource.org/licenses/bsd-license.php BSD License 6 */ 7 8 if (!defined('W2P_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; 19 20 $_live_site = w2PgetConfig('base_url'); 21 $_sitename = w2PgetConfig('company_name'); 22 23 // ensure no malicous sql gets past 24 $checkusername = trim(w2PgetParam($_POST, 'checkusername', '')); 25 $checkusername = db_escape($checkusername); 26 $confirmEmail = trim(w2PgetParam($_POST, 'checkemail', '')); 27 $confirmEmail = strtolower(db_escape($confirmEmail)); 28 29 $q = new DBQuery; 30 $q->addTable('users'); 31 $q->addJoin('contacts', '', 'user_contact = contact_id', 'inner'); 32 $q->addQuery('user_id'); 33 $q->addWhere('user_username = \'' . $checkusername . '\''); 34 $q->addWhere('LOWER(contact_email) = \'' . $confirmEmail . '\''); 35 if (!($user_id = $q->loadResult()) || !$checkusername || !$confirmEmail) { 36 $AppUI->setMsg('Invalid username or email.', UI_MSG_ERROR); 37 $AppUI->redirect(); 38 } 39 40 $newpass = makePass(); 41 $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); 42 $subject = $_sitename . ' :: ' . $AppUI->_('sendpass4', UI_OUTPUT_RAW) . ' - ' . $checkusername; 43 44 $m = new Mail; // create the mail 45 $m->From('web2Project@' . w2PgetConfig('site_domain')); 46 $m->To($confirmEmail); 47 $m->Subject($subject); 48 $m->Body($message, isset($GLOBALS['locale_char_set']) ? $GLOBALS['locale_char_set'] : ''); // set the body 49 $m->Send(); // send the mail 50 51 $newpass = md5($newpass); 52 $q->addTable('users'); 53 $q->addUpdate('user_password', $newpass); 54 $q->addWhere('user_id=' . $user_id); 55 $cur = $q->exec(); 56 if (!$cur) { 57 die('SQL error' . $database->stderr(true)); 58 } else { 59 $AppUI->setMsg('New User Password created and emailed to you'); 60 $AppUI->redirect(); 61 } 62 } 63 64 function makePass() { 65 $makepass = ''; 66 $salt = 'abchefghjkmnpqrstuvwxyz0123456789'; 67 srand((double)microtime() * 1000000); 68 $i = 0; 69 while ($i <= 7) { 70 $num = rand() % 33; 71 $tmp = substr($salt, $num, 1); 72 $makepass = $makepass . $tmp; 73 $i++; 74 } 75 return ($makepass); 76 } 77 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Thu Nov 20 03:00:14 2008 | Cross-referenced by PHPXref 0.7 |