[geeklog-cvs] geeklog-1.3/public_html lib-common.php,1.248,1.249 profiles.php,1.24,1.25 submit.php,1.55,1.56 users.php,1.68,1.69

geeklog-cvs-admin at lists.geeklog.net geeklog-cvs-admin at lists.geeklog.net
Mon Sep 1 08:53:08 EDT 2003


Update of /usr/cvs/geeklog/geeklog-1.3/public_html
In directory geeklog_prod:/tmp/cvs-serv23520/public_html

Modified Files:
	lib-common.php profiles.php submit.php users.php 
Log Message:
Introduced COM_mail() function and rewrote all functions that send emails to use COM_mail() instead of PHP's mail() function directly.


Index: lib-common.php
===================================================================
RCS file: /usr/cvs/geeklog/geeklog-1.3/public_html/lib-common.php,v
retrieving revision 1.248
retrieving revision 1.249
diff -C2 -d -r1.248 -r1.249
*** lib-common.php	21 Aug 2003 21:19:46 -0000	1.248
--- lib-common.php	1 Sep 2003 12:53:06 -0000	1.249
***************
*** 2939,2942 ****
--- 2939,2989 ----
  }
  
+ function COM_mail( $to, $subject, $message, $from = '', $html = false, $priority = 0 )
+ {
+     global $_CONF, $LANG_CHARSET;
+ 
+     if( empty( $LANG_CHARSET ))
+     {
+         $charset = $_CONF['default_charset'];
+         if( empty( $charset ))
+         {
+             $charset = 'iso-8859-1';
+         }
+     }
+     else
+     {
+         $charset = $LANG_CHARSET;
+     }
+ 
+     $headers = '';
+ 
+     if( empty( $from ))
+     {
+         $headers .= "From: {$_CONF['site_name']} <{$_CONF['site_mail']}>\r\n"
+                  . "Return-Path: <{$_CONF['site_mail']}>\r\n";
+     }
+     else
+     {
+         $headers .= "From: $from\r\n";
+     }
+     if( $html )
+     {
+         $headers .= "Content-Type: text/html; charset=$charset\r\n"
+                  . "Content-Transfer-Encoding: 8bit\r\n";
+     }
+     else
+     {
+         $headers .= "Content-Type: text/plain; charset=$charset\r\n";
+     }
+     if( $priority > 0 )
+     {
+         $headers .= 'X-Priority: ' . $priority . "\r\n";
+     }
+     $headers .= 'X-Mailer: GeekLog ' . VERSION;
+ 
+     return mail( $to, $subject, $message, $headers );
+ }
+ 
+ 
  /**
  * Creates older stuff block
***************
*** 3660,3679 ****
      global $_TABLES, $LANG08, $LANG24, $_CONF, $LANG_CHARSET;
  
-     // prepare email header - it's always the same for all users
-     $charset = $LANG_CHARSET;
-     if( empty( $charset ))
-     {
-         $charset = $_CONF['default_charset'];
-         if( empty( $charset ))
-         {
-             $charset = "iso-8859-1";
-         }
-     }
- 
-     $mailfrom = "From: {$_CONF['site_name']} <{$_CONF['site_mail']}>\r\n"
-               . "Return-Path: <{$_CONF['site_mail']}>\r\n"
-               . "X-Mailer: GeekLog " . VERSION . "\r\n"
-               . "Content-Type: text/plain; charset={$charset}";
- 
      $subject = strip_tags( $_CONF['site_name'] . $LANG08[30] . strftime( '%Y-%m-%d', time() ));
  
--- 3707,3710 ----
***************
*** 3782,3789 ****
          $mailtext .= "\n------------------------------\n";
  
!         $toemail = $U['email'];
!         $mailto = "{$U['username']} <{$toemail}>";
  
!         @mail( $toemail, $subject, $mailtext, $mailfrom );
      }
  
--- 3813,3819 ----
          $mailtext .= "\n------------------------------\n";
  
!         $mailto = $U['username'] . ' <' . $toemail . '>';
  
!         COM_mail( $mailto, $subject, $mailtext );
      }
  

Index: profiles.php
===================================================================
RCS file: /usr/cvs/geeklog/geeklog-1.3/public_html/profiles.php,v
retrieving revision 1.24
retrieving revision 1.25
diff -C2 -d -r1.24 -r1.25
*** profiles.php	25 Jun 2003 08:39:02 -0000	1.24
--- profiles.php	1 Sep 2003 12:53:06 -0000	1.25
***************
*** 50,54 ****
  function contactemail($uid,$author,$authoremail,$subject,$message) 
  {
!     global $_TABLES, $_CONF, $_USER, $LANG08, $LANG_CHARSET;
  
      if (!empty($author) && !empty($subject) && !empty($message)) {
--- 50,54 ----
  function contactemail($uid,$author,$authoremail,$subject,$message) 
  {
!     global $_CONF, $_TABLES, $_USER, $LANG08;
  
      if (!empty($author) && !empty($subject) && !empty($message)) {
***************
*** 56,67 ****
              $result = DB_query("SELECT username,email FROM {$_TABLES['users']} WHERE uid = $uid");
              $A = DB_fetchArray($result);
-             if (empty ($LANG_CHARSET)) {
-                 $charset = $_CONF['default_charset'];
-                 if (empty ($charset)) {
-                     $charset = "iso-8859-1";
-                 }
-             } else {
-                 $charset = $LANG_CHARSET;
-             }
  
              // Append the user's signature to the message
--- 56,59 ----
***************
*** 75,86 ****
              }
  
!             $subject = strip_tags (stripslashes ($subject));
              $subject = substr ($subject, 0, strcspn ($subject, "\r\n"));
!             $RET = @mail($A['email'], $subject,
!                 strip_tags(stripslashes($message)) . $sig,
!                 "From: $author <$authoremail>\r\n" .
!                 "Return-Path: <$authoremail>\r\n" .
!                 "X-Mailer: GeekLog " . VERSION . "\r\n" .
!                 "Content-Type: text/plain; charset=$charset");
              $retval .= COM_refresh($_CONF['site_url'] . '/index.php?msg=27');
  		} else {
--- 67,76 ----
              }
  
!             $subject = strip_tags (COM_stripslashes ($subject));
              $subject = substr ($subject, 0, strcspn ($subject, "\r\n"));
!             $message = strip_tags (COM_stripslashes ($message)) . $sig;
!             $from = $author . ' <' . $authoremail . '>';
!             COM_mail ($A['email'], $subject, $message, $from);
! 
              $retval .= COM_refresh($_CONF['site_url'] . '/index.php?msg=27');
  		} else {
***************
*** 96,99 ****
--- 86,90 ----
  			.COM_siteFooter();
  	}
+ 
  	return $retval;
  }
***************
*** 185,209 ****
  #
  
! function mailstory($sid,$to,$toemail,$from,$fromemail,$sid, $shortmsg) 
  {
!  	global $_TABLES, $_CONF, $LANG01, $LANG08, $A;
! 	
!  	$sql = "SELECT uid,title,introtext,bodytext,UNIX_TIMESTAMP(date) AS day FROM {$_TABLES['stories']} WHERE sid = '$sid' ";
!  	$result = DB_query($sql);
!  	$A = DB_fetchArray($result);
!     $shortmsg = stripslashes($shortmsg);
!  	$mailtext = $LANG08[23].LB;
! 	if (strlen($shortmsg) > 0) {
! 		$mailtext .= $LANG08[28].LB;
  	}
!     if ($_CONF['contributedbyline'] == 1) {
!         $author = DB_getItem ($_TABLES['users'], 'username', "uid={$A['uid']}");
!     }
  
- 	$mailtext .= '------------------------------------------------------------'.LB.LB
- 		. COM_undoSpecialChars (stripslashes ($A['title'])) . LB
- 		.strftime($_CONF['date'],$A['day']).LB;
      if ($_CONF['contributedbyline'] == 1) {
! 		$mailtext .= $LANG01[1] . ' ' . $author . LB;
      }
      $mailtext .= LB
--- 176,199 ----
  #
  
! function mailstory ($sid, $to, $toemail, $from, $fromemail, $sid, $shortmsg) 
  {
!  	global $_CONF, $_TABLES, $LANG01, $LANG08;
! 
!  	$sql = "SELECT uid,title,introtext,bodytext,UNIX_TIMESTAMP(date) AS day FROM {$_TABLES['stories']} WHERE sid = '$sid'";
!  	$result = DB_query ($sql);
!  	$A = DB_fetchArray ($result);
!     $shortmsg = COM_stripslashes ($shortmsg);
!  	$mailtext = $LANG08[23] . LB;
! 	if (strlen ($shortmsg) > 0) {
! 		$mailtext .= LB . $LANG08[28] . LB;
  	}
!     $mailtext .= '------------------------------------------------------------'
!               . LB . LB
!               . COM_undoSpecialChars (stripslashes ($A['title'])) . LB
!               . strftime ($_CONF['date'], $A['day']) . LB;
  
      if ($_CONF['contributedbyline'] == 1) {
!         $author = DB_getItem ($_TABLES['users'], 'username', "uid={$A['uid']}");
!         $mailtext .= $LANG01[1] . ' ' . $author . LB;
      }
      $mailtext .= LB
***************
*** 212,222 ****
  		.'------------------------------------------------------------'.LB
  		.$LANG08[24].LB.$_CONF['site_url'].'/article.php?story='.$sid.'#comments';
! 	
!  	$mailto = $to.' <'.$toemail.'>';
!  	$mailfrom = 'From: '.$from.' <'.$fromemail.'>';
   	$subject = COM_undoSpecialChars(strip_tags(stripslashes('Re: '.$A['title'])));
! 	
!  	@mail($toemail,$subject,$mailtext,$mailfrom);
!  	$retval .= COM_refresh("{$_CONF['site_url']}/article.php?story=$sid");
  	// Increment numemails counter for story
  	$result = DB_query("SELECT numemails FROM {$_TABLES['stories']} WHERE sid = '$sid'");
--- 202,214 ----
  		.'------------------------------------------------------------'.LB
  		.$LANG08[24].LB.$_CONF['site_url'].'/article.php?story='.$sid.'#comments';
! 
!  	$mailto = $to . ' <' . $toemail . '>';
!  	$mailfrom = $from . ' <' . $fromemail . '>';
   	$subject = COM_undoSpecialChars(strip_tags(stripslashes('Re: '.$A['title'])));
! 
!     COM_mail ($toemail, $subject, $mailtext, $mailfrom);
! 
!  	$retval .= COM_refresh ($_CONF['site_url'] . '/article.php?story=' . $sid);
! 
  	// Increment numemails counter for story
  	$result = DB_query("SELECT numemails FROM {$_TABLES['stories']} WHERE sid = '$sid'");
***************
*** 224,228 ****
  	$numemails = $A['numemails'] + 1;
  	DB_change($_TABLES['stories'],'numemails',$numemails,'sid',$sid);
! 	
  	return $retval;
  }
--- 216,220 ----
  	$numemails = $A['numemails'] + 1;
  	DB_change($_TABLES['stories'],'numemails',$numemails,'sid',$sid);
! 
  	return $retval;
  }

Index: submit.php
===================================================================
RCS file: /usr/cvs/geeklog/geeklog-1.3/public_html/submit.php,v
retrieving revision 1.55
retrieving revision 1.56
diff -C2 -d -r1.55 -r1.56
*** submit.php	12 Aug 2003 21:10:04 -0000	1.55
--- submit.php	1 Sep 2003 12:53:06 -0000	1.56
***************
*** 410,415 ****
  function sendNotification ($table, $A)
  {
!     global $_CONF, $_TABLES, $LANG_CHARSET, $LANG01, $LANG02, $LANG06, $LANG08,
!            $LANG09, $LANG12, $LANG24, $LANG29, $LANG30;
  
      switch ($table) {
--- 410,415 ----
  function sendNotification ($table, $A)
  {
!     global $_CONF, $_TABLES, $LANG01, $LANG02, $LANG06, $LANG08, $LANG09,
!            $LANG12, $LANG24, $LANG29, $LANG30;
  
      switch ($table) {
***************
*** 426,433 ****
                                                 "tid = '{$A['tid']}'"));
  
!             $mailbody = "$LANG08[31]: {$title}\r\n"
!                       . "$LANG24[7]: {$storyauthor}\r\n"
!                       . "$LANG08[32]: " . strftime ($_CONF['date']) . "\r\n"
!                       . "$LANG24[14]: {$topic}\r\n\r\n";
  
              if ($_CONF['emailstorieslength'] > 0) {
--- 426,433 ----
                                                 "tid = '{$A['tid']}'"));
  
!             $mailbody = "$LANG08[31]: {$title}\n"
!                       . "$LANG24[7]: {$storyauthor}\n"
!                       . "$LANG08[32]: " . strftime ($_CONF['date']) . "\n"
!                       . "$LANG24[14]: {$topic}\n\n";
  
              if ($_CONF['emailstorieslength'] > 0) {
***************
*** 436,445 ****
                              $_CONF['emailstorieslength']) . '...';
                  }
!                 $mailbody .= $introtext . "\r\n\r\n";
              }
              if ($table == $_TABLES['storysubmission']) {
!                 $mailbody .= "$LANG01[10] <{$_CONF['site_admin_url']}/moderation.php>\r\n\r\n";
              } else {
!                 $mailbody .= "$LANG08[33] <{$_CONF['site_url']}/article.php?story={$A['sid']}>\r\n\r\n";
              }
              $mailsubject = $_CONF['site_name'] . ' ' . $LANG29[35];
--- 436,445 ----
                              $_CONF['emailstorieslength']) . '...';
                  }
!                 $mailbody .= $introtext . "\n\n";
              }
              if ($table == $_TABLES['storysubmission']) {
!                 $mailbody .= "$LANG01[10] <{$_CONF['site_admin_url']}/moderation.php>\n\n";
              } else {
!                 $mailbody .= "$LANG08[33] <{$_CONF['site_url']}/article.php?story={$A['sid']}>\n\n";
              }
              $mailsubject = $_CONF['site_name'] . ' ' . $LANG29[35];
***************
*** 451,455 ****
              $description = stripslashes ($A['description']);
  
!             $mailbody = "$LANG09[16]: $title\r\n"
                        . "$LANG09[17]: " . strftime ($_CONF['date'],
                          strtotime ($A['datestart'] . ' ' . $A['timestart']));
--- 451,455 ----
              $description = stripslashes ($A['description']);
  
!             $mailbody = "$LANG09[16]: $title\n"
                        . "$LANG09[17]: " . strftime ($_CONF['date'],
                          strtotime ($A['datestart'] . ' ' . $A['timestart']));
***************
*** 457,469 ****
                  $mailbody .= ' (' . $LANG30[26] . ')';
              }
!             $mailbody .= "\r\n";
              if (!empty ($A['url']) && ($A['url'] != 'http://')) {
!                 $mailbody .= "$LANG09[33]: <" . $A['url'] . ">\r\n";
              }
!             $mailbody .= "\r\n" . $description . "\r\n\r\n";
              if ($table == $_TABLES['eventsubmission']) {
!                 $mailbody .= "$LANG01[10] <{$_CONF['site_admin_url']}/moderation.php>\r\n\r\n";
              } else {
!                 $mailbody .= "$LANG02[12] <{$_CONF['site_url']}/calendar_event.php?eid={$A['eid']}>\r\n\r\n";
              }
              $mailsubject = $_CONF['site_name'] . ' ' . $LANG29[37];
--- 457,469 ----
                  $mailbody .= ' (' . $LANG30[26] . ')';
              }
!             $mailbody .= "\n";
              if (!empty ($A['url']) && ($A['url'] != 'http://')) {
!                 $mailbody .= "$LANG09[33]: <" . $A['url'] . ">\n";
              }
!             $mailbody .= "\n" . $description . "\n\n";
              if ($table == $_TABLES['eventsubmission']) {
!                 $mailbody .= "$LANG01[10] <{$_CONF['site_admin_url']}/moderation.php>\n\n";
              } else {
!                 $mailbody .= "$LANG02[12] <{$_CONF['site_url']}/calendar_event.php?eid={$A['eid']}>\n\n";
              }
              $mailsubject = $_CONF['site_name'] . ' ' . $LANG29[37];
***************
*** 475,486 ****
              $description = stripslashes ($A['description']);
  
!             $mailbody = "$LANG12[10]: $title\r\n"
!                       . "$LANG12[11]: <{$A['url']}>\r\n"
!                       . "$LANG12[17]: {$A['category']}\r\n\r\n"
!                       . $description . "\r\n\r\n";
              if ($table == $_TABLES['linksubmission']) {
!                 $mailbody .= "$LANG01[10] <{$_CONF['site_admin_url']}/moderation.php>\r\n\r\n";
              } else {
!                 $mailbody .= "$LANG06[1] <{$_CONF['site_url']}/links.php?category=" . urlencode ($A['category']) . ">\r\n\r\n";
              }
              $mailsubject = $_CONF['site_name'] . ' ' . $LANG29[36];
--- 475,486 ----
              $description = stripslashes ($A['description']);
  
!             $mailbody = "$LANG12[10]: $title\n"
!                       . "$LANG12[11]: <{$A['url']}>\n"
!                       . "$LANG12[17]: {$A['category']}\n\n"
!                       . $description . "\n\n";
              if ($table == $_TABLES['linksubmission']) {
!                 $mailbody .= "$LANG01[10] <{$_CONF['site_admin_url']}/moderation.php>\n\n";
              } else {
!                 $mailbody .= "$LANG06[1] <{$_CONF['site_url']}/links.php?category=" . urlencode ($A['category']) . ">\n\n";
              }
              $mailsubject = $_CONF['site_name'] . ' ' . $LANG29[36];
***************
*** 488,509 ****
      }
  
!     $mailbody .= "\r\n------------------------------\r\n";
!     $mailbody .= "\r\n$LANG08[34]\r\n";
!     $mailbody .= "\r\n------------------------------\r\n";
! 
!     if (empty ($LANG_CHARSET)) {
!         $charset = $_CONF['default_charset'];
!         if (empty ($charset)) {
!             $charset = "iso-8859-1";
!         }
!     } else {
!         $charset = $LANG_CHARSET;
!     }
!     $mailheaders = "From: {$_CONF['site_name']} <{$_CONF['site_mail']}>\r\n"
!                  . "Return-Path: {$_CONF['site_mail']}\r\n"
!                  . "Content-Type: text/plain; charset=$charset\r\n"
!                  . "X-Mailer: GeekLog " . VERSION;
  
!     @mail ($_CONF['site_mail'], $mailsubject, $mailbody, $mailheaders);
  }
  
--- 488,496 ----
      }
  
!     $mailbody .= "\n------------------------------\n";
!     $mailbody .= "\n$LANG08[34]\n";
!     $mailbody .= "\n------------------------------\n";
  
!     COM_mail ($_CONF['site_mail'], $mailsubject, $mailbody);
  }
  

Index: users.php
===================================================================
RCS file: /usr/cvs/geeklog/geeklog-1.3/public_html/users.php,v
retrieving revision 1.68
retrieving revision 1.69
diff -C2 -d -r1.68 -r1.69
*** users.php	22 Aug 2003 20:48:26 -0000	1.68
--- users.php	1 Sep 2003 12:53:06 -0000	1.69
***************
*** 260,264 ****
  function emailpassword($username,$msg=0) 
  {
!     global $_TABLES, $_CONF, $LANG04, $LANG_CHARSET;
  
      $result = DB_query("SELECT email,passwd FROM {$_TABLES['users']} WHERE username = '$username'");
--- 260,264 ----
  function emailpassword($username,$msg=0) 
  {
!     global $_CONF, $_TABLES, $LANG04;
  
      $result = DB_query("SELECT email,passwd FROM {$_TABLES['users']} WHERE username = '$username'");
***************
*** 282,299 ****
          $mailtext .= "{$_CONF["site_name"]}\n";
          $mailtext .= "{$_CONF['site_url']}\n";
!         if (empty ($LANG_CHARSET)) {
!             $charset = $_CONF['default_charset'];
!             if (empty ($charset)) {
!                 $charset = "iso-8859-1";
!             }
!         }
!         else {
!             $charset = $LANG_CHARSET;
!         }
!         mail($A["email"]
!             ,"{$_CONF["site_name"]}: {$LANG04[16]}"
!             ,$mailtext
!             ,"From: {$_CONF["site_name"]} <{$_CONF["site_mail"]}>\r\nReturn-Path: <{$_CONF["site_mail"]}>\r\nX-Mailer: GeekLog " . VERSION . "\r\nContent-Type: text/plain; charset={$charset}"
!             );
  
          if ($msg) {
--- 282,288 ----
          $mailtext .= "{$_CONF["site_name"]}\n";
          $mailtext .= "{$_CONF['site_url']}\n";
! 
!         $subject = $_CONF['site_name'] . ': ' . $LANG04[16];
!         COM_mail ($A['email'], $subject, $mailtext);
  
          if ($msg) {
***************
*** 319,323 ****
  function requestpassword ($username, $msg = 0)
  {
!     global $_TABLES, $_CONF, $LANG04, $LANG_CHARSET;
  
      $result = DB_query ("SELECT uid,email,passwd FROM {$_TABLES['users']} WHERE username = '$username'");
--- 308,312 ----
  function requestpassword ($username, $msg = 0)
  {
!     global $_CONF, $_TABLES, $LANG04;
  
      $result = DB_query ("SELECT uid,email,passwd FROM {$_TABLES['users']} WHERE username = '$username'");
***************
*** 338,354 ****
          $mailtext .= "{$_CONF['site_url']}\n";
  
!         if (empty ($LANG_CHARSET)) {
!             $charset = $_CONF['default_charset'];
!             if (empty ($charset)) {
!                 $charset = "iso-8859-1";
!             }
!         } else {
!             $charset = $LANG_CHARSET;
!         }
!         mail ($A['email'],
!               "{$_CONF['site_name']}: {$LANG04[16]}",
!               $mailtext,
!               "From: {$_CONF['site_name']} <{$_CONF['site_mail']}>\r\nReturn-Path: <{$_CONF['site_mail']}>\r\nX-Mailer: GeekLog " . VERSION . "\r\nContent-Type: text/plain; charset={$charset}"
!              );
  
          if ($msg) {
--- 327,332 ----
          $mailtext .= "{$_CONF['site_url']}\n";
  
!         $subject = $_CONF['site_name'] . ': ' . $LANG04[16];
!         COM_mail ($A['email'], $subject, $mailtext);
  
          if ($msg) {
***************
*** 411,416 ****
  function sendNotification ($username, $email, $uid, $queued = false)
  {
!     global $_CONF, $_TABLES, $LANG_CHARSET, $LANG01, $LANG04, $LANG08, $LANG28,
!            $LANG29;
  
      $mailbody = "$LANG04[2]: $username\n"
--- 389,393 ----
  function sendNotification ($username, $email, $uid, $queued = false)
  {
!     global $_CONF, $_TABLES, $LANG01, $LANG04, $LANG08, $LANG28, $LANG29;
  
      $mailbody = "$LANG04[2]: $username\n"
***************
*** 427,445 ****
  
      $mailsubject = $_CONF['site_name'] . ' ' . $LANG29[40];
! 
!     if (empty ($LANG_CHARSET)) {
!         $charset = $_CONF['default_charset'];
!         if (empty ($charset)) {
!             $charset = "iso-8859-1";
!         }
!     } else {
!         $charset = $LANG_CHARSET;
!     }
!     $mailheaders = "From: {$_CONF['site_name']} <{$_CONF['site_mail']}>\r\n"
!                  . "Return-Path: {$_CONF['site_mail']}\r\n"
!                  . "X-Mailer: GeekLog " . VERSION . "\r\n"
!                  . "Content-Type: text/plain; charset=$charset";
! 
!     @mail ($_CONF['site_mail'], $mailsubject, $mailbody, $mailheaders);
  }
  
--- 404,408 ----
  
      $mailsubject = $_CONF['site_name'] . ' ' . $LANG29[40];
!     COM_mail ($_CONF['site_mail'], $mailsubject, $mailbody);
  }
  





More information about the geeklog-cvs mailing list