[geeklog-cvs] geeklog-1.3/public_html trackback.php,1.1,1.2

dhaun at iowaoutdoors.org dhaun at iowaoutdoors.org
Tue Jan 18 08:15:55 EST 2005


Update of /var/cvs/geeklog-1.3/public_html
In directory www:/tmp/cvs-serv25422/public_html

Modified Files:
	trackback.php 
Log Message:
Added an (optional) email notification when a new trackback comment has been posted.


Index: trackback.php
===================================================================
RCS file: /var/cvs/geeklog-1.3/public_html/trackback.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** trackback.php	16 Jan 2005 19:14:28 -0000	1.1
--- trackback.php	18 Jan 2005 13:15:52 -0000	1.2
***************
*** 48,51 ****
--- 48,110 ----
  }
  
+ /**
+ * Send a notification email when a new trackback comment has been posted
+ *
+ * FIXME: Currently always picks the latest comment for ($id, $type).
+ *        This may not always be the comment that was just posted ...
+ *
+ * @param    string  $id         ID of the entry the comment was posted to
+ * @param    string  $type       type of that entry ('article' = story, etc.)
+ * @return   void
+ *
+ */
+ function sendNotification ($id, $type)
+ {
+     global $_CONF, $_TABLES, $LANG03, $LANG08, $LANG09, $LANG29, $LANG_TRB;
+ 
+     $trbtype = addslashes ($type);
+     $result = DB_query ("SELECT title,excerpt,url,blog,ipaddress FROM {$_TABLES['trackback']} WHERE (type = '$trbtype') ORDER BY date DESC LIMIT 1");
+     $A = DB_fetchArray ($result);
+ 
+     $mailbody = '';
+     if (!empty ($A['title'])) {
+         $mailbody .= $LANG03[16] . ': ' . $A['title'] . "\n";
+     }
+     $mailbody .= $LANG_TRB['blog_name'] . ': ';
+     if (!empty ($A['blog'])) {
+         $mailbody .= $A['blog'] . ' ';
+     }
+     $mailbody .= '(' . $A['ipaddress'] . ")\n";
+     $mailbody .= $LANG29[12] . ': ' . $A['url'] . "\n";
+ 
+     if ($type != 'article') {
+         $mailbody .= $LANG09[5] . ': ' . $type . "\n";
+     }
+ 
+     if (!empty ($A['excerpt'])) {
+         // the excerpt is max. 255 characters long anyway, so we add it
+         // in its entirety
+         $mailbody .= $A['excerpt'] . "\n\n";
+     }
+ 
+     if ($type == 'article') {
+         $commenturl = COM_buildUrl ($_CONF['site_url'] . '/article.php?story='
+                                     . $id) . '#trackback';
+     } else {
+         list ($commenturl, $dummy1, $dummy2)
+                 = PLG_handleTrackbackComment ($type, $id, 'info');
+     }
+ 
+     $mailbody .= $LANG08[33] . ' <' . $commenturl . ">\n\n";
+ 
+     $mailbody .= "\n------------------------------\n";
+     $mailbody .= "\n$LANG08[34]\n";
+     $mailbody .= "\n------------------------------\n";
+ 
+     $mailsubject = $_CONF['site_name'] . ' ' . $LANG_TRB['trackback'];
+ 
+     COM_mail ($_CONF['site_mail'], $mailsubject, $mailbody);
+ }
+ 
  COM_setArgNames (array ('id', 'type'));
  $id = COM_applyFilter (COM_getArgument ('id'));
***************
*** 73,77 ****
      $A = DB_fetchArray ($result);
      if ($A['count'] == 1) {
!         TRB_handleTrackbackPing ($id, $type);
          exit;
      } else {
--- 132,141 ----
      $A = DB_fetchArray ($result);
      if ($A['count'] == 1) {
!         if (TRB_handleTrackbackPing ($id, $type)) {
!             if (isset ($_CONF['notification']) &&
!                     in_array ('trackback', $_CONF['notification'])) {
!                 sendNotification ($id, $type);
!             }
!         }
          exit;
      } else {
***************
*** 80,84 ****
      }
  } else if (PLG_acceptTrackbackPing ($type, $id) === true) {
!     TRB_handleTrackbackPing ($id, $type);
      exit;
  } else {
--- 144,153 ----
      }
  } else if (PLG_acceptTrackbackPing ($type, $id) === true) {
!     if (TRB_handleTrackbackPing ($id, $type)) {
!         if (isset ($_CONF['notification']) &&
!                 in_array ('trackback', $_CONF['notification'])) {
!             sendNotification ($id, $type);
!         }
!     }
      exit;
  } else {




More information about the geeklog-cvs mailing list