[ Index ]

PHP Cross Reference of E107 v0.7.22 code documentation

title

Body

[close]

/ -> email.php (source)

   1  <?php
   2  /*
   3  + ----------------------------------------------------------------------------+
   4  |     e107 website system
   5  |
   6  |     ©Steve Dunstan 2001-2002
   7  |     http://e107.org
   8  |     jalist@e107.org
   9  |
  10  |     Released under the terms and conditions of the
  11  |     GNU General Public License (http://gnu.org).
  12  |
  13  |     $Source: /cvs_backup/e107_0.7/email.php,v $
  14  |     $Revision: 11346 $
  15  |     $Date: 2010-02-17 13:56:14 -0500 (Wed, 17 Feb 2010) $
  16  |     $Author: secretr $
  17  +----------------------------------------------------------------------------+
  18  */
  19  require_once ('class2.php');
  20  if (!check_class(varset($pref['email_item_class'],e_UC_MEMBER)))
  21  {
  22      header('Location: '.e_BASE.'index.php');
  23      exit();
  24  }
  25  require_once(HEADERF);
  26  
  27  $use_imagecode = FALSE;
  28  $imgtypes = array('jpeg', 'png', 'gif');
  29  foreach($imgtypes as $t)
  30  {
  31      if(function_exists('imagecreatefrom'.$t))
  32      {
  33          $use_imagecode = TRUE;
  34      }
  35  }
  36  
  37  if ($use_imagecode)
  38  {
  39      require_once(e_HANDLER.'secure_img_handler.php');
  40      $sec_img = new secure_image;
  41  }
  42  
  43  if (e_QUERY)
  44  {
  45      $qs = explode('.', e_QUERY, 2);
  46  }
  47  else
  48  {
  49      header('location:'.e_BASE.'index.php');
  50      exit;
  51  }
  52  $source = $qs[0];
  53  $parms = varset($qs[1], '');
  54  unset($qs);
  55  $error = '';
  56  $message = '';
  57  
  58  $referrer = strip_tags(urldecode(html_entity_decode(varset($_SERVER['HTTP_REFERER'],''), ENT_QUOTES)));
  59  $emailurl = ($source == 'referer') ? $referrer : SITEURL;
  60  
  61  $comments = $tp->post_toHTML(varset($_POST['comment'],''), TRUE, 'retain_nl, emotes_off, no_make_clickable');
  62  $author = $tp->post_toHTML(varset($_POST['author_name'],''),FALSE,'emotes_off, no_make_clickable');
  63  $email_send = check_email(varset($_POST['email_send'],''));
  64  
  65  
  66  if (isset($_POST['emailsubmit']))
  67  {
  68      if (!$email_send)
  69      {
  70          $error .= LAN_EMAIL_106;
  71      }
  72  
  73      if($use_imagecode)
  74      {
  75          if(!isset($_POST['code_verify']) || !isset($_POST['rand_num']))
  76          {
  77              header('location:'.e_BASE.'index.php');
  78              exit;
  79          }
  80          if (!$sec_img->verify_code($_POST['rand_num'], $_POST['code_verify']))
  81          {
  82              header('location:'.e_BASE.'index.php');
  83              exit;
  84          }
  85      }
  86  
  87      if ($comments == '')
  88      {
  89          $message = LAN_EMAIL_188.' '.SITENAME.' ('.SITEURL.')';
  90          if (USER == TRUE)
  91          {
  92              $message .= "\n\n".LAN_EMAIL_1." ".USERNAME;
  93          }
  94          else
  95          {
  96              $message .= "\n\n".LAN_EMAIL_1." ".$author;
  97          }
  98      }
  99      else
 100      {
 101          $message .= $comments."\n";
 102      }
 103      $ip = $e107->getip();
 104      $message .= "\n\n".LAN_EMAIL_2." ".$ip."\n\n";
 105  
 106      if (substr($source,0,7) == 'plugin:')
 107      {
 108          $plugin = substr($source,7);
 109          $text = '';
 110          if(file_exists(e_PLUGIN.$plugin.'/e_emailprint.php'))
 111          {
 112              include_once(e_PLUGIN.$plugin.'/e_emailprint.php');
 113              $text = email_item($parms);
 114              $emailurl = SITEURL;
 115          }
 116          if($text == '')
 117          {
 118              header('location:'.e_BASE.'index.php');
 119              exit;
 120          }
 121          $message .= $text;
 122      }
 123      elseif($source == 'referer')
 124      {
 125          if(!isset($_POST['referer']) || $_POST['referer'] == '')
 126          {
 127              header('location:'.e_BASE.'index.php');
 128              exit;
 129          }
 130          $message .= strip_tags($_POST['referer']);
 131          $emailurl = strip_tags($_POST['referer']);
 132      }
 133      else
 134      {
 135          $emailurl = strip_tags($_POST['referer']);
 136          $message = '';
 137          $parms = intval($parms);
 138          if($sql->db_Select('news', '*', 'news_id='.$parms))
 139          {
 140              list($news_id, $news_title, $news_body, $news_extended, $news_datestamp, $news_author, $news_source, $news_url, $news_category, $news_allow_comments) = $sql->db_Fetch();
 141              $message = "<h3 class='email_heading'>".$news_title."</h3><br />".$news_body."<br />".$news_extended."<br /><br /><a href='{e_BASE}news.php?extend.".$parms."'>{e_BASE}news.php?extend.".$parms."</a><br />";
 142              $message = $tp->toEmail($message);
 143  
 144          }
 145  
 146          if($message == '')
 147          {
 148              header('location:'.e_BASE.'index.php');
 149              exit;
 150          }
 151      }
 152  
 153      if ($error == '')
 154      {
 155          // Load Mail Handler and Email Template.
 156          require_once(e_HANDLER.'mail.php');
 157          $email_body = $EMAIL_HEADER;
 158          $email_body .= (trim($comments) != '') ? $tp->toEmail($comments).'<hr />' : '';
 159          $email_body .= $tp->toEmail($message).$EMAIL_FOOTER;
 160  
 161          if (sendemail($email_send, LAN_EMAIL_3.SITENAME,$email_body))
 162          {
 163              $text = "<div style='text-align:center'>".LAN_EMAIL_10." ".$email_send."</div>";
 164          }
 165          else
 166          {
 167              $text = "<div style='text-align:center'>".LAN_EMAIL_9."</div>";
 168          }
 169          $ns->tablerender(LAN_EMAIL_11, $text);
 170      }
 171      else
 172      {
 173          $ns->tablerender(LAN_EMAIL_12, "<div style='text-align:center'>".$error."</div>");
 174      }
 175  }
 176  
 177  
 178  // --------------------- Form -------------------------------------------------
 179  
 180  
 181  
 182  $text = "<form method='post' action='".e_SELF."?".e_QUERY."'>\n
 183      <table>";
 184  
 185  if (USER != TRUE)
 186  {
 187      $text .= "<tr>
 188          <td style='width:25%'>".LAN_EMAIL_15."</td>
 189          <td style='width:75%'>
 190          <input class='tbox' type='text' name='author_name' size='60' style='width:95%' value='$author' maxlength='100' />
 191          </td>
 192          </tr>";
 193  }
 194  
 195  $text .= "
 196  <tr>
 197      <td style='width:25%'>".LAN_EMAIL_8."</td>
 198      <td style='width:75%'>
 199      <textarea class='tbox' name='comment' cols='70' rows='4' style='width:95%'>".LAN_EMAIL_6." ".SITENAME." (".$emailurl.")
 200  ";
 201  
 202  if (USER == TRUE)
 203  {
 204      $text .= "\n\n".LAN_EMAIL_1." ".USERNAME;
 205  }
 206  
 207  $text .= "</textarea>
 208      </td>
 209      </tr>
 210  
 211      <tr>
 212      <td style='width:25%'>".LAN_EMAIL_187."</td>
 213      <td style='width:75%'>
 214      <input class='tbox' type='text' name='email_send' size='60' value='$email_send' style='width:95%' maxlength='100' />
 215      </td>
 216      </tr>
 217      ";
 218  
 219  if($use_imagecode)
 220  {
 221      $text .= "<tr><td>".LAN_EMAIL_190."</td><td>";
 222      $text .= $sec_img->r_image();
 223      $text .= " <input class='tbox' type='text' name='code_verify' size='15' maxlength='20' />
 224          <input type='hidden' name='rand_num' value='".$sec_img->random_number."' /></td></tr>";
 225  }
 226  
 227  $text .= "
 228      <tr style='vertical-align:top'>
 229      <td style='width:25%'></td>
 230      <td style='width:75%'>
 231      <input class='button' type='submit' name='emailsubmit' value='".LAN_EMAIL_4."' />
 232      <input type='hidden' name='referer' value='".$referrer."' />
 233  </td>
 234      </tr>
 235      </table>
 236      </form>";
 237  
 238  $ns->tablerender(LAN_EMAIL_5, $text);
 239  
 240  require_once(FOOTERF);
 241  ?>


Generated: Tue Aug 3 00:19:13 2010
Open Source related documentation for developers.