(file) Return to usercp_sendpasswd.php CVS log (file) (dir) Up to [RizwankCVS] / geekymedia_web / phpBB2 / includes

  1 rizwank 1.1 <?php
  2             /***************************************************************************
  3              *                           usercp_sendpasswd.php
  4              *                            -------------------
  5              *   begin                : Saturday, Feb 13, 2001
  6              *   copyright            : (C) 2001 The phpBB Group
  7              *   email                : support@phpbb.com
  8              *
  9              *   $Id: usercp_sendpasswd.php,v 1.6.2.9 2003/01/10 13:22:00 psotfx Exp $
 10              *
 11              *
 12              ***************************************************************************/
 13             
 14             /***************************************************************************
 15              *
 16              *   This program is free software; you can redistribute it and/or modify
 17              *   it under the terms of the GNU General Public License as published by
 18              *   the Free Software Foundation; either version 2 of the License, or
 19              *   (at your option) any later version.
 20              *
 21              *
 22 rizwank 1.1  ***************************************************************************/
 23             
 24             if ( !defined('IN_PHPBB') )
 25             {
 26             	die('Hacking attempt');
 27             	exit;
 28             }
 29             
 30             if ( isset($HTTP_POST_VARS['submit']) )
 31             {
 32             	// session id check
 33             	if ($sid == '' || $sid != $userdata['session_id'])
 34             	{
 35             		message_die(GENERAL_ERROR, 'Invalid_session');
 36             	}
 37             
 38             	$username = ( !empty($HTTP_POST_VARS['username']) ) ? trim(strip_tags($HTTP_POST_VARS['username'])) : '';
 39             	$email = ( !empty($HTTP_POST_VARS['email']) ) ? trim(strip_tags(htmlspecialchars($HTTP_POST_VARS['email']))) : '';
 40             
 41             	$sql = "SELECT user_id, username, user_email, user_active, user_lang 
 42             		FROM " . USERS_TABLE . " 
 43 rizwank 1.1 		WHERE user_email = '" . str_replace("\'", "''", $email) . "' 
 44             			AND username = '" . str_replace("\'", "''", $username) . "'";
 45             	if ( $result = $db->sql_query($sql) )
 46             	{
 47             		if ( $row = $db->sql_fetchrow($result) )
 48             		{
 49             			if ( !$row['user_active'] )
 50             			{
 51             				message_die(GENERAL_MESSAGE, $lang['No_send_account_inactive']);
 52             			}
 53             
 54             			$username = $row['username'];
 55             			$user_id = $row['user_id'];
 56             
 57             			$user_actkey = gen_rand_string(true);
 58             			$key_len = 54 - strlen($server_url);
 59             			$key_len = ( $str_len > 6 ) ? $key_len : 6;
 60             			$user_actkey = substr($user_actkey, 0, $key_len);
 61             			$user_password = gen_rand_string(false);
 62             			
 63             			$sql = "UPDATE " . USERS_TABLE . " 
 64 rizwank 1.1 				SET user_newpasswd = '" . md5($user_password) . "', user_actkey = '$user_actkey'  
 65             				WHERE user_id = " . $row['user_id'];
 66             			if ( !$db->sql_query($sql) )
 67             			{
 68             				message_die(GENERAL_ERROR, 'Could not update new password information', '', __LINE__, __FILE__, $sql);
 69             			}
 70             
 71             			include($phpbb_root_path . 'includes/emailer.'.$phpEx);
 72             			$emailer = new emailer($board_config['smtp_delivery']);
 73             
 74             			$email_headers = 'From: ' . $board_config['board_email'] . "\nReturn-Path: " . $board_config['board_email'] . "\n";
 75             
 76             			$emailer->use_template('user_activate_passwd', $row['user_lang']);
 77             			$emailer->email_address($row['user_email']);
 78             			$emailer->set_subject($lang['New_password_activation']);
 79             			$emailer->extra_headers($email_headers);
 80             
 81             			$emailer->assign_vars(array(
 82             				'SITENAME' => $board_config['sitename'], 
 83             				'USERNAME' => $username,
 84             				'PASSWORD' => $user_password,
 85 rizwank 1.1 				'EMAIL_SIG' => (!empty($board_config['board_email_sig'])) ? str_replace('<br />', "\n", "-- \n" . $board_config['board_email_sig']) : '', 
 86             
 87             				'U_ACTIVATE' => $server_url . '?mode=activate&' . POST_USERS_URL . '=' . $user_id . '&act_key=' . $user_actkey)
 88             			);
 89             			$emailer->send();
 90             			$emailer->reset();
 91             
 92             			$template->assign_vars(array(
 93             				'META' => '<meta http-equiv="refresh" content="15;url=' . append_sid("index.$phpEx") . '">')
 94             			);
 95             
 96             			$message = $lang['Password_updated'] . '<br /><br />' . sprintf($lang['Click_return_index'],  '<a href="' . append_sid("index.$phpEx") . '">', '</a>');
 97             
 98             			message_die(GENERAL_MESSAGE, $message);
 99             		}
100             		else
101             		{
102             			message_die(GENERAL_MESSAGE, $lang['No_email_match']);
103             		}
104             	}
105             	else
106 rizwank 1.1 	{
107             		message_die(GENERAL_ERROR, 'Could not obtain user information for sendpassword', '', __LINE__, __FILE__, $sql);
108             	}
109             }
110             else
111             {
112             	$username = '';
113             	$email = '';
114             }
115             
116             //
117             // Output basic page
118             //
119             include($phpbb_root_path . 'includes/page_header.'.$phpEx);
120             
121             $template->set_filenames(array(
122             	'body' => 'profile_send_pass.tpl')
123             );
124             make_jumpbox('viewforum.'.$phpEx);
125             
126             $template->assign_vars(array(
127 rizwank 1.1 	'USERNAME' => $username,
128             	'EMAIL' => $email,
129             
130             	'L_SEND_PASSWORD' => $lang['Send_password'], 
131             	'L_ITEMS_REQUIRED' => $lang['Items_required'],
132             	'L_EMAIL_ADDRESS' => $lang['Email_address'],
133             	'L_SUBMIT' => $lang['Submit'],
134             	'L_RESET' => $lang['Reset'],
135             	
136             	'S_HIDDEN_FIELDS' => '<input type="hidden" name="sid" value="' . $userdata['session_id'] . '" />', 
137             	'S_PROFILE_ACTION' => append_sid("profile.$phpEx?mode=sendpassword"))
138             );
139             
140             $template->pparse('body');
141             
142             include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
143             
144             ?>

Rizwan Kassim
Powered by
ViewCVS 0.9.2