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

  1 rizwank 1.1 <?php
  2             /***************************************************************************
  3              *                             usercp_email.php 
  4              *                            -------------------
  5              *   begin                : Saturday, Feb 13, 2001
  6              *   copyright            : (C) 2001 The phpBB Group
  7              *   email                : support@phpbb.com
  8              *
  9              *   $Id: usercp_email.php,v 1.7.2.9 2003/01/05 01:06:40 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 ( !empty($HTTP_GET_VARS[POST_USERS_URL]) || !empty($HTTP_POST_VARS[POST_USERS_URL]) )
 31             {
 32             	$user_id = ( !empty($HTTP_GET_VARS[POST_USERS_URL]) ) ? intval($HTTP_GET_VARS[POST_USERS_URL]) : intval($HTTP_POST_VARS[POST_USERS_URL]);
 33             }
 34             else
 35             {
 36             	message_die(GENERAL_MESSAGE, $lang['No_user_specified']);
 37             }
 38             
 39             if ( !$userdata['session_logged_in'] )
 40             {
 41             	redirect(append_sid("login.$phpEx?redirect=profile.$phpEx&mode=email&" . POST_USERS_URL . "=$user_id", true));
 42             }
 43 rizwank 1.1 
 44             $sql = "SELECT username, user_email, user_viewemail, user_lang  
 45             	FROM " . USERS_TABLE . " 
 46             	WHERE user_id = $user_id";
 47             if ( $result = $db->sql_query($sql) )
 48             {
 49             	$row = $db->sql_fetchrow($result);
 50             
 51             	$username = $row['username'];
 52             	$user_email = $row['user_email']; 
 53             	$user_lang = $row['user_lang'];
 54             
 55             	if ( $row['user_viewemail'] || $userdata['user_level'] == ADMIN )
 56             	{
 57             		if ( time() - $userdata['user_emailtime'] < $board_config['flood_interval'] )
 58             		{
 59             			message_die(GENERAL_MESSAGE, $lang['Flood_email_limit']);
 60             		}
 61             
 62             		if ( isset($HTTP_POST_VARS['submit']) )
 63             		{
 64 rizwank 1.1 			// session id check
 65             			if ($sid == '' || $sid != $userdata['session_id'])
 66             			{
 67             				message_die(GENERAL_ERROR, 'Invalid_session');
 68             			}
 69             
 70             			$error = FALSE;
 71             
 72             			if ( !empty($HTTP_POST_VARS['subject']) )
 73             			{
 74             				$subject = trim(stripslashes($HTTP_POST_VARS['subject']));
 75             			}
 76             			else
 77             			{
 78             				$error = TRUE;
 79             				$error_msg = ( !empty($error_msg) ) ? $error_msg . '<br />' . $lang['Empty_subject_email'] : $lang['Empty_subject_email'];
 80             			}
 81             
 82             			if ( !empty($HTTP_POST_VARS['message']) )
 83             			{
 84             				$message = trim(stripslashes($HTTP_POST_VARS['message']));
 85 rizwank 1.1 			}
 86             			else
 87             			{
 88             				$error = TRUE;
 89             				$error_msg = ( !empty($error_msg) ) ? $error_msg . '<br />' . $lang['Empty_message_email'] : $lang['Empty_message_email'];
 90             			}
 91             
 92             			if ( !$error )
 93             			{
 94             				$sql = "UPDATE " . USERS_TABLE . " 
 95             					SET user_emailtime = " . time() . " 
 96             					WHERE user_id = " . $userdata['user_id'];
 97             				if ( $result = $db->sql_query($sql) )
 98             				{
 99             					include($phpbb_root_path . 'includes/emailer.'.$phpEx);
100             					$emailer = new emailer($board_config['smtp_delivery']);
101             
102             					$email_headers = 'Return-Path: ' . $userdata['user_email'] . "\nFrom: " . $userdata['user_email'] . "\n";
103             					$email_headers .= 'X-AntiAbuse: Board servername - ' . $server_name . "\n";
104             					$email_headers .= 'X-AntiAbuse: User_id - ' . $userdata['user_id'] . "\n";
105             					$email_headers .= 'X-AntiAbuse: Username - ' . $userdata['username'] . "\n";
106 rizwank 1.1 					$email_headers .= 'X-AntiAbuse: User IP - ' . decode_ip($user_ip) . "\n";
107             
108             					$emailer->use_template('profile_send_email', $user_lang);
109             					$emailer->email_address($user_email);
110             					$emailer->set_subject($subject);
111             					$emailer->extra_headers($email_headers);
112             
113             					$emailer->assign_vars(array(
114             						'SITENAME' => $board_config['sitename'], 
115             						'BOARD_EMAIL' => $board_config['board_email'], 
116             						'FROM_USERNAME' => $userdata['username'], 
117             						'TO_USERNAME' => $username, 
118             						'MESSAGE' => $message)
119             					);
120             					$emailer->send();
121             					$emailer->reset();
122             
123             					if ( !empty($HTTP_POST_VARS['cc_email']) )
124             					{
125             						$email_headers = 'Return-Path: ' . $userdata['user_email'] . "\nFrom: " . $userdata['user_email'] . "\n";
126             						$emailer->use_template('profile_send_email');
127 rizwank 1.1 						$emailer->email_address($userdata['user_email']);
128             						$emailer->set_subject($subject);
129             						$emailer->extra_headers($email_headers);
130             
131             						$emailer->assign_vars(array(
132             							'SITENAME' => $board_config['sitename'], 
133             							'BOARD_EMAIL' => $board_config['board_email'], 
134             							'FROM_USERNAME' => $userdata['username'], 
135             							'TO_USERNAME' => $username, 
136             							'MESSAGE' => $message)
137             						);
138             						$emailer->send();
139             						$emailer->reset();
140             					}
141             
142             					$template->assign_vars(array(
143             						'META' => '<meta http-equiv="refresh" content="5;url=' . append_sid("index.$phpEx") . '">')
144             					);
145             
146             					$message = $lang['Email_sent'] . '<br /><br />' . sprintf($lang['Click_return_index'],  '<a href="' . append_sid("index.$phpEx") . '">', '</a>');
147             
148 rizwank 1.1 					message_die(GENERAL_MESSAGE, $message);
149             				}
150             				else
151             				{
152             					message_die(GENERAL_ERROR, 'Could not update last email time', '', __LINE__, __FILE__, $sql);
153             				}
154             			}
155             		}
156             
157             		include($phpbb_root_path . 'includes/page_header.'.$phpEx);
158             
159             		$template->set_filenames(array(
160             			'body' => 'profile_send_email.tpl')
161             		);
162             		make_jumpbox('viewforum.'.$phpEx);
163             
164             		if ( $error )
165             		{
166             			$template->set_filenames(array(
167             				'reg_header' => 'error_body.tpl')
168             			);
169 rizwank 1.1 			$template->assign_vars(array(
170             				'ERROR_MESSAGE' => $error_msg)
171             			);
172             			$template->assign_var_from_handle('ERROR_BOX', 'reg_header');
173             		}
174             
175             		$template->assign_vars(array(
176             			'USERNAME' => $username,
177             
178             			'S_HIDDEN_FIELDS' => '<input type="hidden" name="sid" value="' . $userdata['session_id'] . '" />', 
179             			'S_POST_ACTION' => append_sid("profile.$phpEx?&amp;mode=email&amp;" . POST_USERS_URL . "=$user_id"), 
180             
181             			'L_SEND_EMAIL_MSG' => $lang['Send_email_msg'], 
182             			'L_RECIPIENT' => $lang['Recipient'], 
183             			'L_SUBJECT' => $lang['Subject'],
184             			'L_MESSAGE_BODY' => $lang['Message_body'], 
185             			'L_MESSAGE_BODY_DESC' => $lang['Email_message_desc'], 
186             			'L_EMPTY_SUBJECT_EMAIL' => $lang['Empty_subject_email'],
187             			'L_EMPTY_MESSAGE_EMAIL' => $lang['Empty_message_email'],
188             			'L_OPTIONS' => $lang['Options'],
189             			'L_CC_EMAIL' => $lang['CC_email'], 
190 rizwank 1.1 			'L_SPELLCHECK' => $lang['Spellcheck'],
191             			'L_SEND_EMAIL' => $lang['Send_email'])
192             		);
193             
194             		$template->pparse('body');
195             
196             		include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
197             	}
198             	else
199             	{
200             		message_die(GENERAL_MESSAGE, $lang['User_prevent_email']);
201             	}
202             }
203             else
204             {
205             	message_die(GENERAL_MESSAGE, $lang['User_not_exist']);
206             }
207             
208             ?>

Rizwan Kassim
Powered by
ViewCVS 0.9.2