Beehive PHP Cross Reference Discussion Forums

Source: /email.php - 196 lines - 7566 bytes - Summary - Text - Print

   1  <?php
   2  
   3  /*======================================================================
   4  Copyright Project Beehive Forum 2002
   5  
   6  This file is part of Beehive Forum.
   7  
   8  Beehive Forum is free software; you can redistribute it and/or modify
   9  it under the terms of the GNU General Public License as published by
  10  the Free Software Foundation; either version 3 of the License, or
  11  (at your option) any later version.
  12  
  13  Beehive Forum is distributed in the hope that it will be useful,
  14  but WITHOUT ANY WARRANTY; without even the implied warranty of
  15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16  GNU General Public License for more details.
  17  
  18  You should have received a copy of the GNU General Public License
  19  along with Beehive; if not, write to the Free Software
  20  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
  21  USA
  22  ======================================================================*/
  23  
  24  // Bootstrap
  25  require_once  'boot.php';
  26  
  27  // Required includes
  28  require_once  BH_INCLUDE_PATH . 'constants.inc.php';
  29  require_once  BH_INCLUDE_PATH . 'email.inc.php';
  30  require_once  BH_INCLUDE_PATH . 'form.inc.php';
  31  require_once  BH_INCLUDE_PATH . 'format.inc.php';
  32  require_once  BH_INCLUDE_PATH . 'forum.inc.php';
  33  require_once  BH_INCLUDE_PATH . 'html.inc.php';
  34  require_once  BH_INCLUDE_PATH . 'session.inc.php';
  35  require_once  BH_INCLUDE_PATH . 'user.inc.php';
  36  require_once  BH_INCLUDE_PATH . 'word_filter.inc.php';
  37  // End Required includes
  38  
  39  // Check we're logged in correctly
  40  if (!session::logged_in()) {
  41      html_guest_error();
  42  }
  43  
  44  // Forum name
  45  $forum_name = forum_get_setting('forum_name', 'strlen', 'A Beehive Forum');
  46  
  47  // Array to hold error messages
  48  $error_msg_array = array();
  49  
  50  $to_uid = null;
  51  
  52  // User UID to send email to.
  53  if (isset($_GET['uid']) && is_numeric($_GET['uid'])) {
  54  
  55      $to_uid = $_GET['uid'];
  56  
  57  } else if (isset($_POST['to_uid']) && is_numeric($_POST['to_uid'])) {
  58  
  59      $to_uid = $_POST['to_uid'];
  60  
  61  } else {
  62  
  63      html_draw_error(gettext("No user specified for emailing."));
  64  }
  65  
  66  $to_user = user_get($to_uid);
  67  
  68  $from_user = user_get($_SESSION['UID']);
  69  
  70  $subject = null;
  71  $message = null;
  72  
  73  if (isset($_POST['send'])) {
  74  
  75      $valid = true;
  76  
  77      if (isset($_POST['t_subject']) && strlen(trim($_POST['t_subject'])) > 0) {
  78  
  79          $subject = trim($_POST['t_subject']);
  80  
  81      } else {
  82  
  83          $error_msg_array[] = gettext("Enter a subject for the message");
  84          $valid = false;
  85      }
  86  
  87      if (isset($_POST['t_message']) && strlen(trim($_POST['t_message'])) > 0) {
  88  
  89          $message = trim($_POST['t_message']);
  90  
  91      } else {
  92  
  93          $error_msg_array[] = gettext("Enter some content for the message");
  94          $valid = false;
  95      }
  96  
  97      if (isset($_POST['t_use_email_addr']) && $_POST['t_use_email_addr'] == 'Y') {
  98          $use_email_addr = true;
  99      } else {
 100          $use_email_addr = false;
 101      }
 102  
 103      if (!user_allow_email($to_user['UID'])) {
 104  
 105          $error_msg_array[] = sprintf(gettext("%s has opted out of email contact"), word_filter_add_ob_tags(format_user_name($to_user['LOGON'], $to_user['NICKNAME']), true));
 106          $valid = false;
 107      }
 108  
 109      if (!email_address_valid($to_user['EMAIL'])) {
 110  
 111          $error_msg_array[] = sprintf(gettext("%s has an invalid email address"), word_filter_add_ob_tags(format_user_name($to_user['LOGON'], $to_user['NICKNAME']), true));
 112          $valid = false;
 113      }
 114  
 115      if ($valid) {
 116  
 117          if (email_send_message_to_user($to_uid, $_SESSION['UID'], $subject, $message, $use_email_addr)) {
 118  
 119              html_draw_top(sprintf('title=%s', gettext("Email result")), 'pm_popup_disabled', 'class=window_title');
 120              html_display_msg(gettext("Message sent"), gettext("Message sent successfully."), 'email.php', 'post', array('close' => gettext("Close")), array('to_uid' => $to_uid), '_self', 'center');
 121              html_draw_bottom();
 122              exit;
 123  
 124          } else {
 125  
 126              html_draw_error(gettext("Mail system failure. Message not sent."));
 127              exit;
 128          }
 129      }
 130  }
 131  
 132  html_draw_top(sprintf('title=%s', sprintf(gettext("Send Email to %s"), htmlentities_array(format_user_name($to_user['LOGON'], $to_user['NICKNAME'])))), 'pm_popup_disabled', 'class=window_title');
 133  
 134  echo "<h1>", sprintf(gettext("Send Email to %s"), htmlentities_array(format_user_name($to_user['LOGON'], $to_user['NICKNAME']))), "</h1>\n";
 135  echo "<br />";
 136  echo "<div align=\"center\">\n";
 137  echo "<form accept-charset=\"utf-8\" name=\"f_email\" action=\"email.php\" method=\"post\">\n";
 138  echo "  ", form_input_hidden('webtag', htmlentities_array($webtag)), "\n";
 139  echo "  ", form_input_hidden("to_uid", htmlentities_array($to_uid)), "\n";
 140  
 141  if (isset($error_msg_array) && sizeof($error_msg_array) > 0) {
 142      html_display_error_array($error_msg_array, '480', 'center');
 143  }
 144  
 145  echo "  <table cellpadding=\"0\" cellspacing=\"0\" width=\"480\">\n";
 146  echo "    <tr>\n";
 147  echo "      <td align=\"left\">\n";
 148  echo "        <table class=\"box\">\n";
 149  echo "          <tr>\n";
 150  echo "            <td align=\"left\" class=\"posthead\">\n";
 151  echo "              <table class=\"posthead\" width=\"480\">\n";
 152  echo "                <tr>\n";
 153  echo "                  <td align=\"left\" class=\"subhead\" colspan=\"2\">", sprintf(gettext("Send Email to %s"), htmlentities_array(format_user_name($to_user['LOGON'], $to_user['NICKNAME']))), "</td>\n";
 154  echo "                </tr>\n";
 155  echo "                <tr>\n";
 156  echo "                  <td align=\"center\">\n";
 157  echo "                    <table class=\"posthead\" width=\"95%\">\n";
 158  echo "                      <tr>\n";
 159  echo "                        <td align=\"left\" width=\"25%\">", gettext("From"), ":</td>\n";
 160  echo "                        <td align=\"left\">", word_filter_add_ob_tags($from_user['NICKNAME'], true), "</td>\n";
 161  echo "                      </tr>\n";
 162  echo "                      <tr>\n";
 163  echo "                        <td align=\"left\">", gettext("Subject"), ":</td>\n";
 164  echo "                        <td align=\"left\">", form_input_text("t_subject", (isset($subject) ? htmlentities_array($subject) : ''), 54, 128), "</td>\n";
 165  echo "                      </tr>\n";
 166  echo "                      <tr>\n";
 167  echo "                        <td align=\"left\" valign=\"top\">", gettext("Message"), ":</td>\n";
 168  echo "                        <td align=\"left\">", form_textarea("t_message", (isset($message) ? htmlentities_array($message) : ''), 12, 51), "</td>\n";
 169  echo "                      </tr>\n";
 170  echo "                      <tr>\n";
 171  echo "                        <td align=\"left\" valign=\"top\">&nbsp;</td>\n";
 172  echo "                        <td align=\"left\">", form_checkbox('t_use_email_addr', 'Y', gettext("Use my real email address to send this message"), (isset($use_email_addr) ? $use_email_addr : (isset($_SESSION['USE_EMAIL_ADDR']) && $_SESSION['USE_EMAIL_ADDR'] == 'Y'))), "</td>\n";
 173  echo "                      </tr>\n";
 174  echo "                      <tr>\n";
 175  echo "                        <td align=\"left\" colspan=\"2\">&nbsp;</td>\n";
 176  echo "                      </tr>\n";
 177  echo "                    </table>\n";
 178  echo "                  </td>\n";
 179  echo "                </tr>\n";
 180  echo "              </table>\n";
 181  echo "            </td>\n";
 182  echo "          </tr>\n";
 183  echo "        </table>\n";
 184  echo "      </td>\n";
 185  echo "    </tr>\n";
 186  echo "    <tr>\n";
 187  echo "      <td align=\"left\">&nbsp;</td>\n";
 188  echo "    </tr>\n";
 189  echo "    <tr>\n";
 190  echo "      <td align=\"center\">", form_submit("send", gettext("Send")), "&nbsp;", form_button("close_popup", gettext("Cancel")), "</td>\n";
 191  echo "    </tr>\n";
 192  echo "  </table>\n";
 193  echo "</form>\n";
 194  echo "</div>\n";
 195  
 196  html_draw_bottom();

title

Description

title

Description

title

Description

title

title

Body