[ Index ]

PHP Cross Reference of e107 v1


title

Body

[close]

/ -> contact.php (source)

   1  <?php
   2  /*
   3  + ----------------------------------------------------------------------------+
   4  |     e107 website system
   5  |
   6  |     Steve Dunstan 2001-2002
   7  |     Copyright (C) 2008-2010 e107 Inc (e107.org)
   8  |
   9  |
  10  |     Released under the terms and conditions of the
  11  |     GNU General Public License (http://gnu.org).
  12  |
  13  |     $URL: https://e107.svn.sourceforge.net/svnroot/e107/trunk/e107_0.7/contact.php $
  14  |     $Revision: 12098 $
  15  |     $Id: contact.php 12098 2011-03-12 12:38:17Z e107steved $
  16  |     $Author: e107steved $
  17  +----------------------------------------------------------------------------+
  18  */
  19  
  20  // Experimental e-token
  21  if(isset($_POST['send-contactus']) && !isset($_POST['e-token']))
  22  {
  23      // set e-token so it can be processed by class2
  24      $_POST['e-token'] = '';
  25  }
  26  
  27  require_once ("class2.php");
  28  
  29      // security image may be disabled by removing the appropriate shortcodes from the template.
  30      require_once(e_HANDLER."secure_img_handler.php");
  31      $sec_img = new secure_image;
  32  
  33  if (!isset($CONTACT_FORM) || !$CONTACT_FORM)
  34  {
  35      if (file_exists(THEME."contact_template.php"))
  36      {
  37          require_once(THEME."contact_template.php");
  38      }
  39      else
  40      {        
  41          // Redirect Page if no contact-form or contact-info is available. 
  42          if(($pref['sitecontacts']== e_UC_NOBODY) && trim(SITECONTACTINFO) == "")
  43          {
  44                  header("location:".e_BASE."index.php");
  45                  exit;
  46          }
  47          
  48          require_once(e_THEME."templates/contact_template.php");
  49      }
  50  }
  51  
  52  require_once(HEADERF);
  53  
  54  if(isset($_POST['send-contactus'])/* && isset($_POST['e-token'])*/)
  55  {
  56  
  57      $error = "";
  58  
  59      $sender_name = $tp->toEmail($_POST['author_name'],TRUE,"rawtext");
  60      $sender = check_email($_POST['email_send']);
  61      $subject = $tp->toEmail($_POST['subject'],TRUE,"rawtext");
  62      $body = $tp->toEmail($_POST['body'],TRUE,"rawtext");
  63  
  64  
  65  // Check Image-Code
  66      if (isset($_POST['rand_num']) && !$sec_img->verify_code($_POST['rand_num'], $_POST['code_verify']))
  67      {
  68          $error .= LANCONTACT_15."\\n";
  69      }
  70  
  71  // Check message body.
  72      if(strlen(trim($_POST['body'])) < 15)
  73      {
  74          $error .= LANCONTACT_12."\\n";
  75      }
  76  
  77  // Check subject line.
  78      if(strlen(trim($_POST['subject'])) < 2)
  79      {
  80          $error .= LANCONTACT_13."\\n";
  81      }
  82  
  83      if(!strpos(trim($_POST['email_send']),"@"))
  84      {
  85          $error .= LANCONTACT_11."\\n";
  86      }
  87  
  88  
  89  
  90  // Check email address on remote server (if enabled).
  91      if ($pref['signup_remote_emailcheck'] && $error == "")
  92      {
  93          require_once(e_HANDLER."mail_validation_class.php");
  94          list($adminuser,$adminhost) = split ("@", SITEADMINEMAIL);
  95          $validator = new email_validation_class;
  96          $validator->localuser= $adminuser;
  97          $validator->localhost= $adminhost;
  98          $validator->timeout=3;
  99          //    $validator->debug=1;
 100          //    $validator->html_debug=1;
 101          if($validator->ValidateEmailBox($sender) != 1)
 102          {
 103              $error .= LANCONTACT_11."\\n";
 104          }
 105  
 106      }
 107  
 108  
 109  
 110  // No errors - so proceed to email the admin and the user (if selected).
 111      if(!$error)
 112      {
 113          $body .= "\n\nIP:\t".USERIP."\n";
 114          if(USER)
 115          {
 116              $body .= "User:\t#".USERID." ".USERNAME."\n";
 117          }
 118  
 119          if(!$_POST['contact_person'] && isset($pref['sitecontacts'])) // only 1 person, so contact_person not posted.
 120          {
 121              if($pref['sitecontacts'] == e_UC_MAINADMIN)
 122              {
 123                  $query = "user_perms = '0' OR user_perms = '0.' ";
 124              }
 125              elseif($pref['sitecontacts'] == e_UC_ADMIN)
 126              {
 127                  $query = "user_admin = 1 ";
 128              }
 129              else
 130              {
 131                  $query = "FIND_IN_SET(".$pref['sitecontacts'].",user_class) ";
 132              }
 133          }
 134          else
 135          {
 136                $query = "user_id = ".intval($_POST['contact_person']);
 137          }
 138  
 139          if($sql -> db_Select("user", "user_name,user_email",$query." LIMIT 1"))
 140          {
 141              $row = $sql -> db_Fetch();
 142              $send_to = $row['user_email'];
 143              $send_to_name = $row['user_name'];
 144          }
 145          else
 146          {
 147              $send_to = SITEADMINEMAIL;
 148              $send_to_name = ADMIN;
 149          }
 150  
 151          require_once(e_HANDLER."mail.php");
 152           $message =  (sendemail($send_to,"[".SITENAME."] ".$subject, $body,$send_to_name,$sender,$sender_name)) ? LANCONTACT_09 : LANCONTACT_10;
 153          if(isset($pref['contact_emailcopy']) && $pref['contact_emailcopy'] && $_POST['email_copy'] == 1){
 154              sendemail($sender,"[".SITENAME."] ".$subject, $body,ADMIN,$sender,$sender_name);
 155          }
 156          $ns -> tablerender('', $message);
 157          require_once(FOOTERF);
 158          exit;
 159      }
 160      else
 161      {
 162          require_once(e_HANDLER."message_handler.php");
 163          message_handler("P_ALERT", $error);
 164      }
 165  
 166  }
 167  
 168  if(SITECONTACTINFO && $CONTACT_INFO)
 169  {
 170      require_once(e_FILE."shortcode/batch/contact_shortcodes.php");
 171      $text = $tp->parseTemplate($CONTACT_INFO, TRUE, $contact_shortcodes);
 172      $ns -> tablerender(LANCONTACT_01, $text,"contact");
 173  }
 174  
 175  if(isset($pref['sitecontacts']) && $pref['sitecontacts'] != 255)
 176  {
 177      require_once(e_FILE."shortcode/batch/contact_shortcodes.php");
 178      $text = $tp->parseTemplate($CONTACT_FORM, TRUE, $contact_shortcodes);
 179  
 180      if(trim($text) != "")
 181      {
 182          $ns -> tablerender(LANCONTACT_02, $text, "contact");
 183      }
 184  }
 185  require_once(FOOTERF);
 186  exit;
 187  ?>


Generated: Mon Mar 12 16:28:38 2012 Cross Reference PHPXref