home *** CD-ROM | disk | FTP | other *** search
/ PC World 2005 April / PCWorld_2005-04_cd.bin / akce / web / phpnuke / PHP-Nuke-7.5.exe / html / includes / usercp_email.php < prev    next >
PHP Script  |  2004-03-26  |  12KB  |  249 lines

  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.  *
  54.  *   This program is free software; you can redistribute it and/or modify
  55.  *   it under the terms of the GNU General Public License as published by
  56.  *   the Free Software Foundation; either version 2 of the License, or
  57.  *   (at your option) any later version.
  58.  *
  59.  *
  60.  ***************************************************************************/
  61.  
  62. if ( !defined('IN_PHPBB') )
  63. {
  64.         die("Hacking attempt");
  65.         exit;
  66. }
  67.  
  68. // Is send through board enabled? No, return to index
  69. if (!$board_config['board_email_form'])
  70. {
  71.         redirect(append_sid("index.$phpEx", true));
  72. }
  73.  
  74. if ( !empty($HTTP_GET_VARS[POST_USERS_URL]) || !empty($HTTP_POST_VARS[POST_USERS_URL]) )
  75. {
  76.         $user_id = ( !empty($HTTP_GET_VARS[POST_USERS_URL]) ) ? intval($HTTP_GET_VARS[POST_USERS_URL]) : intval($HTTP_POST_VARS[POST_USERS_URL]);
  77. }
  78. else
  79. {
  80.         message_die(GENERAL_MESSAGE, $lang['No_user_specified']);
  81. }
  82.  
  83. if ( !$userdata['session_logged_in'] )
  84. {
  85.         header('Location: ' . append_sid("login.$phpEx?redirect=profile.$phpEx&mode=user_email&" . POST_USERS_URL . "=$user_id", true));
  86.         exit;
  87. }
  88.  
  89. $sql = "SELECT username, user_email, user_viewemail, user_lang
  90.         FROM " . USERS_TABLE . "
  91.         WHERE user_id = '$user_id'";
  92. if ( $result = $db->sql_query($sql) )
  93. {
  94.         $row = $db->sql_fetchrow($result);
  95.  
  96.         $username = $row['username'];
  97.         $user_email = $row['user_email'];
  98.         $user_lang = $row['user_lang'];
  99.  
  100.         if ( $row['user_viewemail'] || $userdata['user_level'] == ADMIN )
  101.         {
  102.                 if ( time() - $userdata['user_emailtime'] < $board_config['flood_interval'] )
  103.                 {
  104.                         message_die(GENERAL_MESSAGE, $lang['Flood_email_limit']);
  105.                 }
  106.  
  107.                 if ( isset($HTTP_POST_VARS['submit']) )
  108.                 {
  109.                         $error = FALSE;
  110.  
  111.                         if ( !empty($HTTP_POST_VARS['subject']) )
  112.                         {
  113.                                 $subject = trim(stripslashes($HTTP_POST_VARS['subject']));
  114.                         }
  115.                         else
  116.                         {
  117.                                 $error = TRUE;
  118.                                 $error_msg = ( !empty($error_msg) ) ? $error_msg . '<br />' . $lang['Empty_subject_email'] : $lang['Empty_subject_email'];
  119.                         }
  120.  
  121.                         if ( !empty($HTTP_POST_VARS['message']) )
  122.                         {
  123.                                 $message = trim(stripslashes($HTTP_POST_VARS['message']));
  124.                         }
  125.                         else
  126.                         {
  127.                                 $error = TRUE;
  128.                                 $error_msg = ( !empty($error_msg) ) ? $error_msg . '<br />' . $lang['Empty_message_email'] : $lang['Empty_message_email'];
  129.                         }
  130.  
  131.                         if ( !$error )
  132.                         {
  133.                                 $sql = "UPDATE " . USERS_TABLE . "
  134.                                         SET user_emailtime = " . time() . "
  135.                                         WHERE user_id = " . $userdata['user_id'];
  136.                                 if ( $result = $db->sql_query($sql) )
  137.                                 {
  138.                                         include("includes/emailer.php");
  139.                                         $emailer = new emailer($board_config['smtp_delivery']);
  140.  
  141.                                         $emailer->from($userdata['user_email']);
  142.                                         $emailer->replyto($userdata['user_email']);
  143.  
  144.                                         $email_headers = 'X-AntiAbuse: Board servername - ' . $server_name . "\n";
  145.                                         $email_headers .= 'X-AntiAbuse: User_id - ' . $userdata['user_id'] . "\n";
  146.                                         $email_headers .= 'X-AntiAbuse: Username - ' . $userdata['username'] . "\n";
  147.                                         $email_headers .= 'X-AntiAbuse: User IP - ' . decode_ip($user_ip) . "\n";
  148.  
  149.                                         $emailer->use_template('profile_send_email', $user_lang);
  150.                                         $emailer->email_address($user_email);
  151.                                         $emailer->set_subject($subject);
  152.                                         $emailer->extra_headers($email_headers);
  153.  
  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.                                         if ( !empty($HTTP_POST_VARS['cc_email']) )
  165.                                         {
  166.                                                 $emailer->from($userdata['user_email']);
  167.                                                 $emailer->replyto($userdata['user_email']);
  168.                                                 $emailer->use_template('profile_send_email');
  169.                                                 $emailer->email_address($userdata['user_email']);
  170.                                                 $emailer->set_subject($subject);
  171.  
  172.                                                 $emailer->assign_vars(array(
  173.                                                         'SITENAME' => $board_config['sitename'],
  174.                                                         'BOARD_EMAIL' => $board_config['board_email'],
  175.                                                         'FROM_USERNAME' => $userdata['username'],
  176.                                                         'TO_USERNAME' => $username,
  177.                                                         'MESSAGE' => $message)
  178.                                                 );
  179.                                                 $emailer->send();
  180.                                                 $emailer->reset();
  181.                                         }
  182.  
  183.                                         $template->assign_vars(array(
  184.                                                 'META' => '<meta http-equiv="refresh" content="5;url=' . append_sid("index.$phpEx") . '">')
  185.                                         );
  186.  
  187.                                         $message = $lang['Email_sent'] . '<br /><br />' . sprintf($lang['Click_return_index'],  '<a href="' . append_sid("index.$phpEx") . '">', '</a>');
  188.  
  189.                                         message_die(GENERAL_MESSAGE, $message);
  190.                                 }
  191.                                 else
  192.                                 {
  193.                                         message_die(GENERAL_ERROR, 'Could not update last email time', '', __LINE__, __FILE__, $sql);
  194.                                 }
  195.                         }
  196.                 }
  197.  
  198.                 include("includes/page_header.php");
  199.  
  200.                 $template->set_filenames(array(
  201.                         'body' => 'profile_send_email.tpl')
  202.                 );
  203.                 make_jumpbox('viewforum.'.$phpEx);
  204.  
  205.                 if ( $error )
  206.                 {
  207.                         $template->set_filenames(array(
  208.                                 'reg_header' => 'error_body.tpl')
  209.                         );
  210.                         $template->assign_vars(array(
  211.                                 'ERROR_MESSAGE' => $error_msg)
  212.                         );
  213.                         $template->assign_var_from_handle('ERROR_BOX', 'reg_header');
  214.                 }
  215.  
  216.                 $template->assign_vars(array(
  217.                         'USERNAME' => $username,
  218.  
  219.                         'S_HIDDEN_FIELDS' => '',
  220.                         'S_POST_ACTION' => append_sid("profile.$phpEx?mode=email&" . POST_USERS_URL . "=$user_id"),
  221.  
  222.                         'L_SEND_EMAIL_MSG' => $lang['Send_email_msg'],
  223.                         'L_RECIPIENT' => $lang['Recipient'],
  224.                         'L_SUBJECT' => $lang['Subject'],
  225.                         'L_MESSAGE_BODY' => $lang['Message_body'],
  226.                         'L_MESSAGE_BODY_DESC' => $lang['Email_message_desc'],
  227.                         'L_EMPTY_SUBJECT_EMAIL' => $lang['Empty_subject_email'],
  228.                         'L_EMPTY_MESSAGE_EMAIL' => $lang['Empty_message_email'],
  229.                         'L_OPTIONS' => $lang['Options'],
  230.                         'L_CC_EMAIL' => $lang['CC_email'],
  231.                         'L_SPELLCHECK' => $lang['Spellcheck'],
  232.                         'L_SEND_EMAIL' => $lang['Send_email'])
  233.                 );
  234.  
  235.                 $template->pparse('body');
  236.  
  237.                 include("includes/page_tail.php");
  238.         }
  239.         else
  240.         {
  241.                 message_die(GENERAL_MESSAGE, $lang['User_prevent_email']);
  242.         }
  243. }
  244. else
  245. {
  246.         message_die(GENERAL_MESSAGE, $lang['User_not_exist']);
  247. }
  248.  
  249. ?>