root / tags / release_2_0_2 / phpBB / includes / usercp_email.php
History | View | Annotate | Download (6.2 kB)
| 1 | 2302 | psotfx | <?php
|
|---|---|---|---|
| 2 | 2302 | psotfx | /***************************************************************************
|
| 3 | 2361 | the_systech | * usercp_email.php |
| 4 | 2302 | psotfx | * ------------------- |
| 5 | 2302 | psotfx | * begin : Saturday, Feb 13, 2001 |
| 6 | 2302 | psotfx | * copyright : (C) 2001 The phpBB Group |
| 7 | 2302 | psotfx | * email : support@phpbb.com |
| 8 | 2302 | psotfx | * |
| 9 | 2302 | psotfx | * $Id$ |
| 10 | 2302 | psotfx | * |
| 11 | 2302 | psotfx | * |
| 12 | 2302 | psotfx | ***************************************************************************/ |
| 13 | 2302 | psotfx | |
| 14 | 2302 | psotfx | /***************************************************************************
|
| 15 | 2302 | psotfx | * |
| 16 | 2302 | psotfx | * This program is free software; you can redistribute it and/or modify |
| 17 | 2302 | psotfx | * it under the terms of the GNU General Public License as published by |
| 18 | 2302 | psotfx | * the Free Software Foundation; either version 2 of the License, or |
| 19 | 2302 | psotfx | * (at your option) any later version. |
| 20 | 2302 | psotfx | * |
| 21 | 2302 | psotfx | * |
| 22 | 2302 | psotfx | ***************************************************************************/ |
| 23 | 2302 | psotfx | |
| 24 | 2328 | psotfx | if ( !defined('IN_PHPBB') ) |
| 25 | 2302 | psotfx | {
|
| 26 | 2304 | psotfx | die("Hacking attempt"); |
| 27 | 2302 | psotfx | exit;
|
| 28 | 2302 | psotfx | } |
| 29 | 2302 | psotfx | |
| 30 | 2302 | psotfx | if ( !empty($HTTP_GET_VARS[POST_USERS_URL]) || !empty($HTTP_POST_VARS[POST_USERS_URL]) ) |
| 31 | 2302 | psotfx | {
|
| 32 | 2815 | psotfx | $user_id = ( !empty($HTTP_GET_VARS[POST_USERS_URL]) ) ? intval($HTTP_GET_VARS[POST_USERS_URL]) : intval($HTTP_POST_VARS[POST_USERS_URL]); |
| 33 | 2302 | psotfx | } |
| 34 | 2302 | psotfx | else
|
| 35 | 2302 | psotfx | {
|
| 36 | 2302 | psotfx | message_die(GENERAL_MESSAGE, $lang['No_user_specified']); |
| 37 | 2302 | psotfx | } |
| 38 | 2302 | psotfx | |
| 39 | 2493 | psotfx | if ( !$userdata['session_logged_in'] ) |
| 40 | 2493 | psotfx | {
|
| 41 | 2493 | psotfx | header('Location: ' . append_sid("login.$phpEx?redirect=profile.$phpEx&mode=email&" . POST_USERS_URL . "=$user_id", true)); |
| 42 | 2493 | psotfx | exit;
|
| 43 | 2493 | psotfx | } |
| 44 | 2493 | psotfx | |
| 45 | 2302 | psotfx | $sql = "SELECT username, user_email, user_viewemail, user_lang |
| 46 | 2302 | psotfx | FROM " . USERS_TABLE . " |
| 47 | 2302 | psotfx | WHERE user_id = $user_id"; |
| 48 | 2302 | psotfx | if ( $result = $db->sql_query($sql) ) |
| 49 | 2302 | psotfx | {
|
| 50 | 2302 | psotfx | $row = $db->sql_fetchrow($result); |
| 51 | 2302 | psotfx | |
| 52 | 2302 | psotfx | $username = $row['username']; |
| 53 | 2302 | psotfx | $user_email = $row['user_email']; |
| 54 | 2302 | psotfx | $user_lang = $row['user_lang']; |
| 55 | 2302 | psotfx | |
| 56 | 2302 | psotfx | if ( $row['user_viewemail'] || $userdata['user_level'] == ADMIN ) |
| 57 | 2302 | psotfx | {
|
| 58 | 2302 | psotfx | if ( time() - $userdata['user_emailtime'] < $board_config['flood_interval'] ) |
| 59 | 2302 | psotfx | {
|
| 60 | 2302 | psotfx | message_die(GENERAL_MESSAGE, $lang['Flood_email_limit']); |
| 61 | 2302 | psotfx | } |
| 62 | 2302 | psotfx | |
| 63 | 2302 | psotfx | if ( isset($HTTP_POST_VARS['submit']) ) |
| 64 | 2302 | psotfx | {
|
| 65 | 2302 | psotfx | $error = FALSE; |
| 66 | 2302 | psotfx | |
| 67 | 2302 | psotfx | if ( !empty($HTTP_POST_VARS['subject']) ) |
| 68 | 2302 | psotfx | {
|
| 69 | 2406 | psotfx | $subject = trim(stripslashes($HTTP_POST_VARS['subject'])); |
| 70 | 2302 | psotfx | } |
| 71 | 2302 | psotfx | else
|
| 72 | 2302 | psotfx | {
|
| 73 | 2302 | psotfx | $error = TRUE; |
| 74 | 2302 | psotfx | $error_msg = ( !empty($error_msg) ) ? $error_msg . '<br />' . $lang['Empty_subject_email'] : $lang['Empty_subject_email']; |
| 75 | 2302 | psotfx | } |
| 76 | 2302 | psotfx | |
| 77 | 2302 | psotfx | if ( !empty($HTTP_POST_VARS['message']) ) |
| 78 | 2302 | psotfx | {
|
| 79 | 2406 | psotfx | $message = trim(stripslashes($HTTP_POST_VARS['message'])); |
| 80 | 2302 | psotfx | } |
| 81 | 2302 | psotfx | else
|
| 82 | 2302 | psotfx | {
|
| 83 | 2302 | psotfx | $error = TRUE; |
| 84 | 2302 | psotfx | $error_msg = ( !empty($error_msg) ) ? $error_msg . '<br />' . $lang['Empty_message_email'] : $lang['Empty_message_email']; |
| 85 | 2302 | psotfx | } |
| 86 | 2302 | psotfx | |
| 87 | 2302 | psotfx | if ( !$error ) |
| 88 | 2302 | psotfx | {
|
| 89 | 2302 | psotfx | $sql = "UPDATE " . USERS_TABLE . " |
| 90 | 2302 | psotfx | SET user_emailtime = " . time() . " |
| 91 | 2302 | psotfx | WHERE user_id = " . $userdata['user_id']; |
| 92 | 2302 | psotfx | if ( $result = $db->sql_query($sql) ) |
| 93 | 2302 | psotfx | {
|
| 94 | 2302 | psotfx | include($phpbb_root_path . 'includes/emailer.'.$phpEx); |
| 95 | 2302 | psotfx | $emailer = new emailer($board_config['smtp_delivery']); |
| 96 | 2302 | psotfx | |
| 97 | 2605 | psotfx | $email_headers = 'Return-Path: ' . $userdata['user_email'] . "\nFrom: " . $userdata['user_email'] . "\n"; |
| 98 | 2605 | psotfx | $email_headers .= 'X-AntiAbuse: Board servername - ' . $server_name . "\n"; |
| 99 | 2605 | psotfx | $email_headers .= 'X-AntiAbuse: User_id - ' . $userdata['user_id'] . "\n"; |
| 100 | 2605 | psotfx | $email_headers .= 'X-AntiAbuse: Username - ' . $userdata['username'] . "\n"; |
| 101 | 2605 | psotfx | $email_headers .= 'X-AntiAbuse: User IP - ' . decode_ip($user_ip) . "\n"; |
| 102 | 2302 | psotfx | |
| 103 | 2302 | psotfx | $emailer->use_template('profile_send_email', $user_lang); |
| 104 | 2302 | psotfx | $emailer->email_address($user_email); |
| 105 | 2302 | psotfx | $emailer->set_subject($subject); |
| 106 | 2302 | psotfx | $emailer->extra_headers($email_headers); |
| 107 | 2302 | psotfx | |
| 108 | 2302 | psotfx | $emailer->assign_vars(array( |
| 109 | 2302 | psotfx | 'SITENAME' => $board_config['sitename'], |
| 110 | 2302 | psotfx | 'BOARD_EMAIL' => $board_config['board_email'], |
| 111 | 2302 | psotfx | 'FROM_USERNAME' => $userdata['username'], |
| 112 | 2302 | psotfx | 'TO_USERNAME' => $username, |
| 113 | 2302 | psotfx | 'MESSAGE' => $message) |
| 114 | 2302 | psotfx | ); |
| 115 | 2302 | psotfx | $emailer->send();
|
| 116 | 2302 | psotfx | $emailer->reset(); |
| 117 | 2302 | psotfx | |
| 118 | 2587 | psotfx | if ( !empty($HTTP_POST_VARS['cc_email']) ) |
| 119 | 2587 | psotfx | {
|
| 120 | 2605 | psotfx | $email_headers = 'Return-Path: ' . $userdata['user_email'] . "\nFrom: " . $userdata['user_email'] . "\n"; |
| 121 | 2587 | psotfx | $emailer->use_template('profile_send_email'); |
| 122 | 2587 | psotfx | $emailer->email_address($userdata['user_email']); |
| 123 | 2587 | psotfx | $emailer->set_subject($subject); |
| 124 | 2587 | psotfx | $emailer->extra_headers($email_headers); |
| 125 | 2587 | psotfx | |
| 126 | 2587 | psotfx | $emailer->assign_vars(array( |
| 127 | 2587 | psotfx | 'SITENAME' => $board_config['sitename'], |
| 128 | 2587 | psotfx | 'BOARD_EMAIL' => $board_config['board_email'], |
| 129 | 2587 | psotfx | 'FROM_USERNAME' => $userdata['username'], |
| 130 | 2587 | psotfx | 'TO_USERNAME' => $username, |
| 131 | 2587 | psotfx | 'MESSAGE' => $message) |
| 132 | 2587 | psotfx | ); |
| 133 | 2587 | psotfx | $emailer->send();
|
| 134 | 2587 | psotfx | $emailer->reset(); |
| 135 | 2587 | psotfx | } |
| 136 | 2587 | psotfx | |
| 137 | 2302 | psotfx | $template->assign_vars(array( |
| 138 | 2302 | psotfx | 'META' => '<meta http-equiv="refresh" content="5;url=' . append_sid("index.$phpEx") . '">') |
| 139 | 2302 | psotfx | ); |
| 140 | 2302 | psotfx | |
| 141 | 2302 | psotfx | $message = $lang['Email_sent'] . '<br /><br />' . sprintf($lang['Click_return_index'], '<a href="' . append_sid("index.$phpEx") . '">', '</a>'); |
| 142 | 2302 | psotfx | |
| 143 | 2302 | psotfx | message_die(GENERAL_MESSAGE, $message); |
| 144 | 2302 | psotfx | } |
| 145 | 2302 | psotfx | else
|
| 146 | 2302 | psotfx | {
|
| 147 | 2302 | psotfx | message_die(GENERAL_ERROR, 'Could not update last email time', '', __LINE__, __FILE__, $sql); |
| 148 | 2302 | psotfx | } |
| 149 | 2302 | psotfx | } |
| 150 | 2302 | psotfx | } |
| 151 | 2302 | psotfx | |
| 152 | 2302 | psotfx | include($phpbb_root_path . 'includes/page_header.'.$phpEx); |
| 153 | 2302 | psotfx | |
| 154 | 2302 | psotfx | $template->set_filenames(array( |
| 155 | 2448 | psotfx | 'body' => 'profile_send_email.tpl') |
| 156 | 2302 | psotfx | ); |
| 157 | 2448 | psotfx | make_jumpbox('viewforum.'.$phpEx); |
| 158 | 2302 | psotfx | |
| 159 | 2302 | psotfx | if ( $error ) |
| 160 | 2302 | psotfx | {
|
| 161 | 2302 | psotfx | $template->set_filenames(array( |
| 162 | 2302 | psotfx | 'reg_header' => 'error_body.tpl') |
| 163 | 2302 | psotfx | ); |
| 164 | 2302 | psotfx | $template->assign_vars(array( |
| 165 | 2302 | psotfx | 'ERROR_MESSAGE' => $error_msg) |
| 166 | 2302 | psotfx | ); |
| 167 | 2302 | psotfx | $template->assign_var_from_handle('ERROR_BOX', 'reg_header'); |
| 168 | 2302 | psotfx | } |
| 169 | 2302 | psotfx | |
| 170 | 2302 | psotfx | $template->assign_vars(array( |
| 171 | 2302 | psotfx | 'USERNAME' => $username, |
| 172 | 2302 | psotfx | |
| 173 | 2302 | psotfx | 'S_POST_ACTION' => append_sid("profile.$phpEx?&mode=email&" . POST_USERS_URL . "=$user_id"), |
| 174 | 2302 | psotfx | |
| 175 | 2302 | psotfx | 'L_SEND_EMAIL_MSG' => $lang['Send_email_msg'], |
| 176 | 2302 | psotfx | 'L_RECIPIENT' => $lang['Recipient'], |
| 177 | 2302 | psotfx | 'L_SUBJECT' => $lang['Subject'], |
| 178 | 2302 | psotfx | 'L_MESSAGE_BODY' => $lang['Message_body'], |
| 179 | 2302 | psotfx | 'L_MESSAGE_BODY_DESC' => $lang['Email_message_desc'], |
| 180 | 2320 | thefinn | 'L_EMPTY_SUBJECT_EMAIL' => $lang['Empty_subject_email'], |
| 181 | 2320 | thefinn | 'L_EMPTY_MESSAGE_EMAIL' => $lang['Empty_message_email'], |
| 182 | 2302 | psotfx | 'L_OPTIONS' => $lang['Options'], |
| 183 | 2302 | psotfx | 'L_CC_EMAIL' => $lang['CC_email'], |
| 184 | 2302 | psotfx | 'L_SPELLCHECK' => $lang['Spellcheck'], |
| 185 | 2302 | psotfx | 'L_SEND_EMAIL' => $lang['Send_email']) |
| 186 | 2302 | psotfx | ); |
| 187 | 2302 | psotfx | |
| 188 | 2302 | psotfx | $template->pparse('body'); |
| 189 | 2302 | psotfx | |
| 190 | 2302 | psotfx | include($phpbb_root_path . 'includes/page_tail.'.$phpEx); |
| 191 | 2302 | psotfx | } |
| 192 | 2302 | psotfx | else
|
| 193 | 2302 | psotfx | {
|
| 194 | 2302 | psotfx | message_die(GENERAL_MESSAGE, $lang['User_prevent_email']); |
| 195 | 2302 | psotfx | } |
| 196 | 2302 | psotfx | } |
| 197 | 2302 | psotfx | else
|
| 198 | 2302 | psotfx | {
|
| 199 | 2302 | psotfx | message_die(GENERAL_MESSAGE, $lang['User_not_exist']); |
| 200 | 2302 | psotfx | } |
| 201 | 2302 | psotfx | |
| 202 | 2448 | psotfx | ?> |

