PageRenderTime 58ms CodeModel.GetById 29ms RepoModel.GetById 0ms app.codeStats 0ms

/prolabBeta/includes/usercp_email.php

https://github.com/lucasgoicoechea/prolab
PHP | 249 lines | 160 code | 30 blank | 59 comment | 17 complexity | 0a09bee31ce8255d5c71e8dd59b86d09 MD5 | raw file
  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.13 2003/06/06 18:02:15 acydburn Exp $
  10. *
  11. *
  12. ***************************************************************************/
  13. /***************************************************************************
  14. * phpbb2 forums port version 2.0.5 (c) 2003 - Nuke Cops (http://nukecops.com)
  15. *
  16. * Ported by Nuke Cops to phpbb2 standalone 2.0.5 Test
  17. * and debugging completed by the Elite Nukers and site members.
  18. *
  19. * You run this package at your sole risk. Nuke Cops and affiliates cannot
  20. * be held liable if anything goes wrong. You are advised to test this
  21. * package on a development system. Backup everything before implementing
  22. * in a production environment. If something goes wrong, you can always
  23. * backout and restore your backups.
  24. *
  25. * Installing and running this also means you agree to the terms of the AUP
  26. * found at Nuke Cops.
  27. *
  28. * This is version 2.0.5 of the phpbb2 forum port for PHP-Nuke. Work is based
  29. * on Tom Nitzschner's forum port version 2.0.6. Tom's 2.0.6 port was based
  30. * on the phpbb2 standalone version 2.0.3. Our version 2.0.5 from Nuke Cops is
  31. * now reflecting phpbb2 standalone 2.0.5 that fixes some bugs and the
  32. * invalid_session error message.
  33. ***************************************************************************/
  34. /***************************************************************************
  35. * This file is part of the phpBB2 port to Nuke 6.0 (c) copyright 2002
  36. * by Tom Nitzschner (tom@toms-home.com)
  37. * http://bbtonuke.sourceforge.net (or http://www.toms-home.com)
  38. *
  39. * As always, make a backup before messing with anything. All code
  40. * release by me is considered sample code only. It may be fully
  41. * functual, but you use it at your own risk, if you break it,
  42. * you get to fix it too. No waranty is given or implied.
  43. *
  44. * Please post all questions/request about this port on http://bbtonuke.sourceforge.net first,
  45. * then on my site. All original header code and copyright messages will be maintained
  46. * to give credit where credit is due. If you modify this, the only requirement is
  47. * that you also maintain all original copyright messages. All my work is released
  48. * under the GNU GENERAL PUBLIC LICENSE. Please see the README for more information.
  49. *
  50. ***************************************************************************/
  51. /***************************************************************************
  52. *
  53. * This program is free software; you can redistribute it and/or modify
  54. * it under the terms of the GNU General Public License as published by
  55. * the Free Software Foundation; either version 2 of the License, or
  56. * (at your option) any later version.
  57. *
  58. *
  59. ***************************************************************************/
  60. if ( !defined('IN_PHPBB') )
  61. {
  62. die("Hacking attempt");
  63. exit;
  64. }
  65. // Is send through board enabled? No, return to index
  66. if (!$board_config['board_email_form'])
  67. {
  68. redirect(append_sid("index.$phpEx", true));
  69. }
  70. if ( !empty($HTTP_GET_VARS[POST_USERS_URL]) || !empty($HTTP_POST_VARS[POST_USERS_URL]) )
  71. {
  72. $user_id = ( !empty($HTTP_GET_VARS[POST_USERS_URL]) ) ? intval($HTTP_GET_VARS[POST_USERS_URL]) : intval($HTTP_POST_VARS[POST_USERS_URL]);
  73. }
  74. else
  75. {
  76. message_die(GENERAL_MESSAGE, $lang['No_user_specified']);
  77. }
  78. if ( !$userdata['session_logged_in'] )
  79. {
  80. header('Location: ' . append_sid("login.$phpEx?redirect=profile.$phpEx&mode=email&" . POST_USERS_URL . "=$user_id", true));
  81. exit;
  82. }
  83. $sql = "SELECT username, user_email, user_viewemail, user_lang
  84. FROM " . USERS_TABLE . "
  85. WHERE user_id = '$user_id'";
  86. if ( $result = $db->sql_query($sql) )
  87. {
  88. $row = $db->sql_fetchrow($result);
  89. $username = $row['username'];
  90. $user_email = $row['user_email'];
  91. $user_lang = $row['user_lang'];
  92. if ( $row['user_viewemail'] || $userdata['user_level'] == ADMIN )
  93. {
  94. if ( time() - $userdata['user_emailtime'] < $board_config['flood_interval'] )
  95. {
  96. message_die(GENERAL_MESSAGE, $lang['Flood_email_limit']);
  97. }
  98. if ( isset($HTTP_POST_VARS['submit']) )
  99. {
  100. $error = FALSE;
  101. if ( !empty($HTTP_POST_VARS['subject']) )
  102. {
  103. $subject = trim(stripslashes($HTTP_POST_VARS['subject']));
  104. }
  105. else
  106. {
  107. $error = TRUE;
  108. $error_msg = ( !empty($error_msg) ) ? $error_msg . '<br />' . $lang['Empty_subject_email'] : $lang['Empty_subject_email'];
  109. }
  110. if ( !empty($HTTP_POST_VARS['message']) )
  111. {
  112. $message = trim(stripslashes($HTTP_POST_VARS['message']));
  113. }
  114. else
  115. {
  116. $error = TRUE;
  117. $error_msg = ( !empty($error_msg) ) ? $error_msg . '<br />' . $lang['Empty_message_email'] : $lang['Empty_message_email'];
  118. }
  119. if ( !$error )
  120. {
  121. $sql = "UPDATE " . USERS_TABLE . "
  122. SET user_emailtime = " . time() . "
  123. WHERE user_id = " . $userdata['user_id'];
  124. if ( $result = $db->sql_query($sql) )
  125. {
  126. include("includes/emailer.php");
  127. $emailer = new emailer($board_config['smtp_delivery']);
  128. $emailer->from($userdata['user_email']);
  129. $emailer->replyto($userdata['user_email']);
  130. $email_headers = 'X-AntiAbuse: Board servername - ' . $server_name . "\n";
  131. $email_headers .= 'X-AntiAbuse: User_id - ' . $userdata['user_id'] . "\n";
  132. $email_headers .= 'X-AntiAbuse: Username - ' . $userdata['username'] . "\n";
  133. $email_headers .= 'X-AntiAbuse: User IP - ' . decode_ip($user_ip) . "\n";
  134. $emailer->use_template('profile_send_email', $user_lang);
  135. $emailer->email_address($user_email);
  136. $emailer->set_subject($subject);
  137. $emailer->extra_headers($email_headers);
  138. $emailer->assign_vars(array(
  139. 'SITENAME' => $board_config['sitename'],
  140. 'BOARD_EMAIL' => $board_config['board_email'],
  141. 'FROM_USERNAME' => $userdata['username'],
  142. 'TO_USERNAME' => $username,
  143. 'MESSAGE' => $message)
  144. );
  145. $emailer->send();
  146. $emailer->reset();
  147. if ( !empty($HTTP_POST_VARS['cc_email']) )
  148. {
  149. $emailer->from($userdata['user_email']);
  150. $emailer->replyto($userdata['user_email']);
  151. $emailer->use_template('profile_send_email');
  152. $emailer->email_address($userdata['user_email']);
  153. $emailer->set_subject($subject);
  154. $emailer->assign_vars(array(
  155. 'SITENAME' => $board_config['sitename'],
  156. 'BOARD_EMAIL' => $board_config['board_email'],
  157. 'FROM_USERNAME' => $userdata['username'],
  158. 'TO_USERNAME' => $username,
  159. 'MESSAGE' => $message)
  160. );
  161. $emailer->send();
  162. $emailer->reset();
  163. }
  164. $template->assign_vars(array(
  165. 'META' => '<meta http-equiv="refresh" content="5;url=' . append_sid("index.$phpEx") . '">')
  166. );
  167. $message = $lang['Email_sent'] . '<br /><br />' . sprintf($lang['Click_return_index'], '<a href="' . append_sid("index.$phpEx") . '">', '</a>');
  168. message_die(GENERAL_MESSAGE, $message);
  169. }
  170. else
  171. {
  172. message_die(GENERAL_ERROR, 'Could not update last email time', '', __LINE__, __FILE__, $sql);
  173. }
  174. }
  175. }
  176. include("includes/page_header.php");
  177. $template->set_filenames(array(
  178. 'body' => 'profile_send_email.tpl')
  179. );
  180. make_jumpbox('viewforum.'.$phpEx);
  181. if ( $error )
  182. {
  183. $template->set_filenames(array(
  184. 'reg_header' => 'error_body.tpl')
  185. );
  186. $template->assign_vars(array(
  187. 'ERROR_MESSAGE' => $error_msg)
  188. );
  189. $template->assign_var_from_handle('ERROR_BOX', 'reg_header');
  190. }
  191. $template->assign_vars(array(
  192. 'USERNAME' => $username,
  193. 'S_HIDDEN_FIELDS' => '',
  194. 'S_POST_ACTION' => append_sid("profile.$phpEx?mode=email&amp;" . POST_USERS_URL . "=$user_id"),
  195. 'L_SEND_EMAIL_MSG' => $lang['Send_email_msg'],
  196. 'L_RECIPIENT' => $lang['Recipient'],
  197. 'L_SUBJECT' => $lang['Subject'],
  198. 'L_MESSAGE_BODY' => $lang['Message_body'],
  199. 'L_MESSAGE_BODY_DESC' => $lang['Email_message_desc'],
  200. 'L_EMPTY_SUBJECT_EMAIL' => $lang['Empty_subject_email'],
  201. 'L_EMPTY_MESSAGE_EMAIL' => $lang['Empty_message_email'],
  202. 'L_OPTIONS' => $lang['Options'],
  203. 'L_CC_EMAIL' => $lang['CC_email'],
  204. 'L_SPELLCHECK' => $lang['Spellcheck'],
  205. 'L_SEND_EMAIL' => $lang['Send_email'])
  206. );
  207. $template->pparse('body');
  208. include("includes/page_tail.php");
  209. }
  210. else
  211. {
  212. message_die(GENERAL_MESSAGE, $lang['User_prevent_email']);
  213. }
  214. }
  215. else
  216. {
  217. message_die(GENERAL_MESSAGE, $lang['User_not_exist']);
  218. }
  219. ?>