[ Index ]

PHP Cross Reference of e107 v1


title

Body

[close]

/ -> email.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/email.php $
  14  |     $Revision: 11948 $
  15  |     $Id: email.php 11948 2010-11-02 22:36:41Z e107steved $
  16  |     $Author: e107steved $
  17  +----------------------------------------------------------------------------+
  18  */
  19  
  20  // Experimental e-token
  21  if (isset($_POST['emailsubmit']) && !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  if (!check_class(varset($pref['email_item_class'],e_UC_MEMBER)))
  29  {
  30      header('Location: '.e_BASE.'index.php');
  31      exit();
  32  }
  33  require_once(HEADERF);
  34  
  35  $use_imagecode = FALSE;
  36  $imgtypes = array('jpeg', 'png', 'gif');
  37  foreach($imgtypes as $t)
  38  {
  39      if(function_exists('imagecreatefrom'.$t))
  40      {
  41          $use_imagecode = TRUE;
  42      }
  43  }
  44  
  45  if ($use_imagecode)
  46  {
  47      require_once(e_HANDLER.'secure_img_handler.php');
  48      $sec_img = new secure_image;
  49  }
  50  
  51  if (e_QUERY)
  52  {
  53      $qs = explode('.', e_QUERY, 2);
  54  }
  55  else
  56  {
  57      header('location:'.e_BASE.'index.php');
  58      exit;
  59  }
  60  $source = $qs[0];
  61  $parms = varset($qs[1], '');
  62  unset($qs);
  63  $error = '';
  64  $message = '';
  65  
  66  $referrer = strip_tags(urldecode(html_entity_decode(varset($_SERVER['HTTP_REFERER'],''), ENT_QUOTES)));
  67  $emailurl = ($source == 'referer') ? $referrer : SITEURL;
  68  
  69  $comments = $tp->post_toHTML(varset($_POST['comment'],''), TRUE, 'retain_nl, emotes_off, no_make_clickable');
  70  $author = $tp->post_toHTML(varset($_POST['author_name'],''),FALSE,'emotes_off, no_make_clickable');
  71  $email_send = check_email(varset($_POST['email_send'],''));
  72  
  73  
  74  if (isset($_POST['emailsubmit']))
  75  {
  76      if (!$email_send)
  77      {
  78          $error .= LAN_EMAIL_106;
  79      }
  80  
  81      if($use_imagecode)
  82      {
  83          if(!isset($_POST['code_verify']) || !isset($_POST['rand_num']))
  84          {
  85              header('location:'.e_BASE.'index.php');
  86              exit;
  87          }
  88          if (!$sec_img->verify_code($_POST['rand_num'], $_POST['code_verify']))
  89          {
  90              header('location:'.e_BASE.'index.php');
  91              exit;
  92          }
  93      }
  94  
  95      if ($comments == '')
  96      {
  97          $message = LAN_EMAIL_6.' '.SITENAME.' ('.SITEURL.')';
  98          if (USER == TRUE)
  99          {
 100              $message .= "\n\n".LAN_EMAIL_1." ".USERNAME;
 101          }
 102          else
 103          {
 104              $message .= "\n\n".LAN_EMAIL_1." ".$author;
 105          }
 106      }
 107      else
 108      {
 109  //        $message .= $comments."\n";        // Added into message later
 110      }
 111      $ip = $e107->getip();
 112      $message .= "\n\n".LAN_EMAIL_2." ".$ip."\n\n";
 113  
 114      if (substr($source,0,7) == 'plugin:')
 115      {
 116          $plugin = substr($source,7);
 117          $text = '';
 118          if(file_exists(e_PLUGIN.$plugin.'/e_emailprint.php'))
 119          {
 120              include_once(e_PLUGIN.$plugin.'/e_emailprint.php');
 121              $text = email_item($parms);
 122              $emailurl = SITEURL;
 123          }
 124          if($text == '')
 125          {
 126              header('location:'.e_BASE.'index.php');
 127              exit;
 128          }
 129          $message .= $text;
 130      }
 131      elseif($source == 'referer')
 132      {
 133          if(!isset($_POST['referer']) || $_POST['referer'] == '')
 134          {
 135              header('location:'.e_BASE.'index.php');
 136              exit;
 137          }
 138          $message .= strip_tags($_POST['referer']);
 139          $emailurl = strip_tags($_POST['referer']);
 140      }
 141      else
 142      {
 143          $emailurl = strip_tags($_POST['referer']);
 144          $message = '';
 145          $parms = intval($parms);
 146          if($sql->db_Select('news', '*', 'news_id='.$parms))
 147          {
 148              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();
 149              $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 />";
 150              $message = $tp->toEmail($message);
 151  
 152          }
 153  
 154          if($message == '')
 155          {
 156              header('location:'.e_BASE.'index.php');
 157              exit;
 158          }
 159      }
 160  
 161      if ($error == '')
 162      {
 163          // Load Mail Handler and Email Template.
 164          require_once(e_HANDLER.'mail.php');
 165          if (file_exists(THEME.'email_template.php'))
 166          {
 167              require_once(THEME.'email_template.php');
 168          }
 169          else
 170          {
 171              require_once(e_THEME.'templates/email_template.php');
 172          }
 173  
 174          $email_body = '';
 175          if(isset($EMAIL_HEADER))
 176          {
 177              $email_body = $tp->parseTemplate($EMAIL_HEADER);
 178          }
 179  
 180          $email_body .= (trim($comments) != '') ? $tp->toEmail($comments).'<hr />' : '';
 181          $email_body .= $tp->toEmail($message);
 182          if (isset($EMAIL_FOOTER))
 183          {
 184              $email_body .= $tp->parseTemplate($EMAIL_FOOTER);
 185          }
 186  
 187          if (sendemail($email_send, LAN_EMAIL_3.SITENAME,$email_body))
 188          {
 189              $text = "<div style='text-align:center'>".LAN_EMAIL_10." ".$email_send."</div>";
 190          }
 191          else
 192          {
 193              $text = "<div style='text-align:center'>".LAN_EMAIL_9."</div>";
 194          }
 195          $ns->tablerender(LAN_EMAIL_11, $text);
 196      }
 197      else
 198      {
 199          $ns->tablerender(LAN_EMAIL_12, "<div style='text-align:center'>".$error."</div>");
 200      }
 201  }
 202  
 203  
 204  // --------------------- Form -------------------------------------------------
 205  
 206  
 207  
 208  $text = "<form method='post' action='".e_SELF."?".e_QUERY."'>\n
 209      <table>";
 210  
 211  if (USER != TRUE)
 212  {
 213      $text .= "<tr>
 214          <td style='width:25%'>".LAN_EMAIL_15."</td>
 215          <td style='width:75%'>
 216          <input class='tbox' type='text' name='author_name' size='60' style='width:95%' value='$author' maxlength='100' />
 217          </td>
 218          </tr>";
 219  }
 220  
 221  $text .= "
 222  <tr>
 223      <td style='width:25%'>".LAN_EMAIL_8."</td>
 224      <td style='width:75%'>
 225      <textarea class='tbox' name='comment' cols='70' rows='4' style='width:95%'>".LAN_EMAIL_6." ".SITENAME." (".$emailurl.")
 226  ";
 227  
 228  if (USER == TRUE)
 229  {
 230      $text .= "\n\n".LAN_EMAIL_1." ".USERNAME;
 231  }
 232  
 233  $text .= "</textarea>
 234      </td>
 235      </tr>
 236  
 237      <tr>
 238      <td style='width:25%'>".LAN_EMAIL_187."</td>
 239      <td style='width:75%'>
 240      <input class='tbox' type='text' name='email_send' size='60' value='$email_send' style='width:95%' maxlength='100' />
 241      </td>
 242      </tr>
 243      ";
 244  
 245  if($use_imagecode)
 246  {
 247      $text .= "<tr><td>".LAN_EMAIL_190."</td><td>";
 248      $text .= $sec_img->r_image();
 249      $text .= " <input class='tbox' type='text' name='code_verify' size='15' maxlength='20' />
 250          <input type='hidden' name='rand_num' value='".$sec_img->random_number."' /></td></tr>";
 251  }
 252  
 253  $text .= "
 254      <tr style='vertical-align:top'>
 255      <td style='width:25%'></td>
 256      <td style='width:75%'>
 257      <input class='button' type='submit' name='emailsubmit' value='".LAN_EMAIL_4."' />
 258      <input type='hidden' name='referer' value='".$referrer."' />
 259      <input type='hidden' name='e-token' value='".e_TOKEN."' />
 260  </td>
 261      </tr>
 262      </table>
 263      </form>";
 264  
 265  $ns->tablerender(LAN_EMAIL_5, $text);
 266  
 267  require_once(FOOTERF);
 268  ?>


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