[geeklog-cvs] geeklog-1.3/public_html trackback.php,NONE,1.1 article.php,1.57,1.58 lib-common.php,1.408,1.409 stats.php,1.32,1.33

dhaun at iowaoutdoors.org dhaun at iowaoutdoors.org
Sun Jan 16 14:14:30 EST 2005


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

Modified Files:
	article.php lib-common.php stats.php 
Added Files:
	trackback.php 
Log Message:
Added support for sending and receiving trackback comments (Feature Request #34)


Index: article.php
===================================================================
RCS file: /var/cvs/geeklog-1.3/public_html/article.php,v
retrieving revision 1.57
retrieving revision 1.58
diff -C2 -d -r1.57 -r1.58
*** article.php	1 Jan 2005 15:41:10 -0000	1.57
--- article.php	16 Jan 2005 19:14:28 -0000	1.58
***************
*** 9,17 ****
  // | Shows articles in various formats.                                        |
  // +---------------------------------------------------------------------------+
! // | Copyright (C) 2000-2004 by the following authors:                         |
  // |                                                                           |
! // | Authors: Tony Bibbs        - tony at tonybibbs.com                           |
! // |          Jason Whittenburg - jwhitten at securitygeeks.com                   |
! // |          Dirk Haun         - dirk at haun-online.de                          |
  // +---------------------------------------------------------------------------+
  // |                                                                           |
--- 9,17 ----
  // | Shows articles in various formats.                                        |
  // +---------------------------------------------------------------------------+
! // | Copyright (C) 2000-2005 by the following authors:                         |
  // |                                                                           |
! // | Authors: Tony Bibbs        - tony AT tonybibbs DOT com                    |
! // |          Jason Whittenburg - jwhitten AT securitygeeks DOT com            |
! // |          Dirk Haun         - dirk AT haun-online DOT de                   |
  // +---------------------------------------------------------------------------+
  // |                                                                           |
***************
*** 47,50 ****
--- 47,53 ----
  require_once ('lib-common.php');
  require_once ($_CONF['path_system'] . 'lib-story.php');
+ if ($_CONF['trackback_enabled']) {
+     require_once ($_CONF['path_system'] . 'lib-trackback.php');
+ }
  
  // Uncomment the line below if you need to debug the HTTP variables being passed
***************
*** 52,72 ****
  // the data being passed in a POST operation
  
! // echo COM_debug($HTTP_POST_VARS);
  
  // MAIN
  
! if (isset ($HTTP_POST_VARS['mode'])) {
!     $story = COM_applyFilter ($HTTP_POST_VARS['story']);
!     $mode = COM_applyFilter ($HTTP_POST_VARS['mode']);
!     $order = COM_applyFilter ($HTTP_POST_VARS['order']);
!     $query = COM_applyFilter ($HTTP_POST_VARS['query']);
!     $reply = COM_applyFilter ($HTTP_POST_VARS['reply']);
  } else {
      COM_setArgNames (array ('story', 'mode'));
      $story = COM_applyFilter (COM_getArgument ('story'));
      $mode = COM_applyFilter (COM_getArgument ('mode'));
!     $order = COM_applyFilter ($HTTP_GET_VARS['order']);
!     $query = COM_applyFilter ($HTTP_GET_VARS['query']);
!     $reply = COM_applyFilter ($HTTP_GET_VARS['reply']);
  }
  if (empty ($story)) {
--- 55,75 ----
  // the data being passed in a POST operation
  
! // echo COM_debug($_POST);
  
  // MAIN
  
! if (isset ($_POST['mode'])) {
!     $story = COM_applyFilter ($_POST['story']);
!     $mode = COM_applyFilter ($_POST['mode']);
!     $order = COM_applyFilter ($_POST['order']);
!     $query = COM_applyFilter ($_POST['query']);
!     $reply = COM_applyFilter ($_POST['reply']);
  } else {
      COM_setArgNames (array ('story', 'mode'));
      $story = COM_applyFilter (COM_getArgument ('story'));
      $mode = COM_applyFilter (COM_getArgument ('mode'));
!     $order = COM_applyFilter ($_GET['order']);
!     $query = COM_applyFilter ($_GET['query']);
!     $reply = COM_applyFilter ($_GET['reply']);
  }
  if (empty ($story)) {
***************
*** 79,87 ****
  
  // First see if we have a plugin that may be trying to use the Geeklog comment engine
! if (isset ($HTTP_POST_VARS['type'])) {
!     $type = COM_applyFilter ($HTTP_POST_VARS['type']);
! } else {
!     $type = COM_applyFilter ($HTTP_GET_VARS['type']);
! }
  if (!empty ($type) && PLG_supportsComments ($type)) {
      // Yes, this is a plugin wanting to be commented on...do it
--- 82,86 ----
  
  // First see if we have a plugin that may be trying to use the Geeklog comment engine
! $type = COM_applyFilter ($_REQUEST['type']);
  if (!empty ($type) && PLG_supportsComments ($type)) {
      // Yes, this is a plugin wanting to be commented on...do it
***************
*** 103,107 ****
                  . "/comment.php?sid=$story&pid=$pid&type=$type");
      } else {
! 	$result = DB_query ("SELECT STRAIGHT_JOIN s.*, UNIX_TIMESTAMP(s.date) as day, "
           . "u.username, u.fullname, u.photo, t.topic, t.imageurl "
           . "FROM {$_TABLES['stories']} as s, {$_TABLES['users']} as u, {$_TABLES['topics']} as t "
--- 102,106 ----
                  . "/comment.php?sid=$story&pid=$pid&type=$type");
      } else {
!         $result = DB_query ("SELECT STRAIGHT_JOIN s.*, UNIX_TIMESTAMP(s.date) as day, "
           . "u.username, u.fullname, u.photo, t.topic, t.imageurl "
           . "FROM {$_TABLES['stories']} as s, {$_TABLES['users']} as u, {$_TABLES['topics']} as t "
***************
*** 156,162 ****
          } else {
              // Set page title
!             $_CONF['pagetitle'] = stripslashes (str_replace ('$', '$',
!                                                 $A['title']));
!             $display .= COM_siteHeader ('menu');
  
              DB_query ("UPDATE {$_TABLES['stories']} SET hits = hits + 1 WHERE (sid = '$story') AND (date <= NOW()) AND (draft_flag = 0)");
--- 155,171 ----
          } else {
              // Set page title
!             $pagetitle = stripslashes (str_replace ('$', '$', $A['title']));
! 
!             if ($_CONF['trackback_enabled']) {
!                 $permalink = COM_buildUrl ($_CONF['site_url']
!                                            . '/article.php?story=' . $story);
!                 $trackbackurl = TRB_makeTrackbackUrl ($story);
!                 $rdf = '<!--' . LB
!                      . TRB_trackbackRdf ($permalink, $A['title'], $trackbackurl)
!                      . LB . '-->' . LB;
!             } else {
!                 $rdf = '';
!             }
!             $display .= COM_siteHeader ('menu', $pagetitle, $rdf);
  
              DB_query ("UPDATE {$_TABLES['stories']} SET hits = hits + 1 WHERE (sid = '$story') AND (date <= NOW()) AND (draft_flag = 0)");
***************
*** 238,241 ****
--- 247,269 ----
                                            $order, $mode, 0, $page, false, $delete_option));
              }
+             if ($_CONF['trackback_enabled']) {
+                 if (SEC_inGroup ('Root')) {
+                     $url = $_CONF['site_admin_url']
+                          . '/trackback.php?mode=new&id=' . $A['sid'];
+                     $story_template->set_var ('send_trackback_link', '<a href="'
+                          . $url . '">' . $LANG_TRB['send_trackback'] . '</a>');
+                     $story_template->set_var ('send_trackback_url', $url);
+                     $story_template->set_var ('lang_send_trackback_text',
+                                               $LANG_TRB['send_trackback']);
+                 }
+ 
+                 $permalink = COM_buildUrl ($_CONF['site_url']
+                                            . '/article.php?story=' . $story);
+                 $story_template->set_var ('trackback',
+                         TRB_renderTrackbackComments ($story, 'article',
+                                                      $A['title'], $permalink));
+             } else {
+                 $story_template->set_var ('trackback', '');
+             }
              $display .= $story_template->finish ($story_template->parse ('output', 'article'));
              $display .= COM_siteFooter ();

Index: lib-common.php
===================================================================
RCS file: /var/cvs/geeklog-1.3/public_html/lib-common.php,v
retrieving revision 1.408
retrieving revision 1.409
diff -C2 -d -r1.408 -r1.409
*** lib-common.php	29 Dec 2004 08:43:37 -0000	1.408
--- lib-common.php	16 Jan 2005 19:14:28 -0000	1.409
***************
*** 9,19 ****
  // | Geeklog common library.                                                   |
  // +---------------------------------------------------------------------------+
! // | Copyright (C) 2000-2004 by the following authors:                         |
  // |                                                                           |
! // | Authors: Tony Bibbs        - tony at tonybibbs.com                           |
! // |          Mark Limburg      - mlimburg at users.sourceforge.net               |
! // |          Jason Whittenburg - jwhitten at securitygeeks.com                   |
! // |          Dirk Haun         - dirk at haun-online.de                          |
! // |          Vincent Furia     - vinny01 at users.sourceforge.net                |
  // +---------------------------------------------------------------------------+
  // |                                                                           |
--- 9,19 ----
  // | Geeklog common library.                                                   |
  // +---------------------------------------------------------------------------+
! // | Copyright (C) 2000-2005 by the following authors:                         |
  // |                                                                           |
! // | Authors: Tony Bibbs        - tony AT tonybibbs DOT com                    |
! // |          Mark Limburg      - mlimburg AT users DOT sourceforge DOT net    |
! // |          Jason Whittenburg - jwhitten AT securitygeeks DOT com            |
! // |          Dirk Haun         - dirk AT haun-online DOT de                   |
! // |          Vincent Furia     - vinny01 AT users DOT sourceforge DOT net     |
  // +---------------------------------------------------------------------------+
  // |                                                                           |
***************
*** 95,99 ****
  
  // this file can't be used on its own - redirect to index.php
! if( eregi( 'lib-common.php', $HTTP_SERVER_VARS['PHP_SELF'] ))
  {
      echo COM_refresh( $_CONF['site_url'] . '/index.php' );
--- 95,99 ----
  
  // this file can't be used on its own - redirect to index.php
! if( eregi( 'lib-common.php', $_SERVER['PHP_SELF'] ))
  {
      echo COM_refresh( $_CONF['site_url'] . '/index.php' );
***************
*** 243,250 ****
  // which theme to show them.
  
! if( !empty( $HTTP_POST_VARS['usetheme'] ) && is_dir( $_CONF['path_themes']
!         . $HTTP_POST_VARS['usetheme'] ))
  {
!     $_CONF['theme'] = $HTTP_POST_VARS['usetheme'];
      $_CONF['path_layout'] = $_CONF['path_themes'] . $_CONF['theme'] . '/';      
      $_CONF['layout_url'] = $_CONF['site_url'] . '/layout/' . $_CONF['theme'];   
--- 243,250 ----
  // which theme to show them.
  
! if( !empty( $_POST['usetheme'] ) && is_dir( $_CONF['path_themes']
!         . $_POST['usetheme'] ))
  {
!     $_CONF['theme'] = $_POST['usetheme'];
      $_CONF['path_layout'] = $_CONF['path_themes'] . $_CONF['theme'] . '/';      
      $_CONF['layout_url'] = $_CONF['site_url'] . '/layout/' . $_CONF['theme'];   
***************
*** 252,260 ****
  else if( $_CONF['allow_user_themes'] == 1 )
  {
!     if( isset( $HTTP_COOKIE_VARS[$_CONF['cookie_theme']]) && empty($_USER['theme'] ))
      {
!         if( is_dir( $_CONF['path_themes'] . $HTTP_COOKIE_VARS[$_CONF['cookie_theme']] ))
          {
!             $_USER['theme'] = $HTTP_COOKIE_VARS[$_CONF['cookie_theme']];
          }
      }
--- 252,260 ----
  else if( $_CONF['allow_user_themes'] == 1 )
  {
!     if( isset( $_COOKIE[$_CONF['cookie_theme']]) && empty($_USER['theme'] ))
      {
!         if( is_dir( $_CONF['path_themes'] . $_COOKIE[$_CONF['cookie_theme']] ))
          {
!             $_USER['theme'] = $_COOKIE[$_CONF['cookie_theme']];
          }
      }
***************
*** 288,297 ****
  // Similarly set language
  
! if( isset( $HTTP_COOKIE_VARS[$_CONF['cookie_language']]) && empty( $_USER['language'] ))
  {
!     if( is_file( $_CONF['path_language'] . $HTTP_COOKIE_VARS[$_CONF['cookie_language']] . '.php' ))
      {
!         $_USER['language'] = $HTTP_COOKIE_VARS[$_CONF['cookie_language']];
!         $_CONF['language'] = $HTTP_COOKIE_VARS[$_CONF['cookie_language']];
      }
  }
--- 288,297 ----
  // Similarly set language
  
! if( isset( $_COOKIE[$_CONF['cookie_language']]) && empty( $_USER['language'] ))
  {
!     if( is_file( $_CONF['path_language'] . $_COOKIE[$_CONF['cookie_language']] . '.php' ))
      {
!         $_USER['language'] = $_COOKIE[$_CONF['cookie_language']];
!         $_CONF['language'] = $_COOKIE[$_CONF['cookie_language']];
      }
  }
***************
*** 308,312 ****
  {
      // The following code handles anonymous users so they show up properly
!     DB_query( "DELETE FROM {$_TABLES['sessions']} WHERE remote_ip = '{$HTTP_SERVER_VARS['REMOTE_ADDR']}' AND uid = 1" );
  
      $tries = 0;
--- 308,312 ----
  {
      // The following code handles anonymous users so they show up properly
!     DB_query( "DELETE FROM {$_TABLES['sessions']} WHERE remote_ip = '{$_SERVER['REMOTE_ADDR']}' AND uid = 1" );
  
      $tries = 0;
***************
*** 319,323 ****
  
          // Insert anonymous user session
!         $result = DB_query( "INSERT INTO {$_TABLES['sessions']} (sess_id, start_time, remote_ip, uid) VALUES ($sess_id, $curtime, '{$HTTP_SERVER_VARS['REMOTE_ADDR']}', 1)", 1 );
          $tries++;
      }
--- 319,323 ----
  
          // Insert anonymous user session
!         $result = DB_query( "INSERT INTO {$_TABLES['sessions']} (sess_id, start_time, remote_ip, uid) VALUES ($sess_id, $curtime, '{$_SERVER['REMOTE_ADDR']}', 1)", 1 );
          $tries++;
      }
***************
*** 359,369 ****
  $_RIGHTS = explode( ',', SEC_getUserPermissions() );
  
! if( isset( $HTTP_GET_VARS['topic'] ))
  {
!     $topic = COM_applyFilter( $HTTP_GET_VARS['topic'] );
  }
! else if( isset( $HTTP_POST_VARS['topic'] ))
  {
!     $topic = COM_applyFilter( $HTTP_POST_VARS['topic'] );
  }
  else
--- 359,369 ----
  $_RIGHTS = explode( ',', SEC_getUserPermissions() );
  
! if( isset( $_GET['topic'] ))
  {
!     $topic = COM_applyFilter( $_GET['topic'] );
  }
! else if( isset( $_POST['topic'] ))
  {
!     $topic = COM_applyFilter( $_POST['topic'] );
  }
  else
***************
*** 451,460 ****
  * Gets all installed themes
  *
! * Gets all directory names in /path/to/geeklog/themes/ and returns all the
! * directories
  *
- * @return   array   All installed themes
  */
- 
  function COM_getThemes( $all = false )
  {
--- 451,461 ----
  * Gets all installed themes
  *
! * Returns a list of all the directory names in $_CONF['path_themes'], i.e.
! * a list of all the theme names.
! *
! * @param    bool    $all    if true, return all themes even if users aren't allowed to change their default themes
! * @return   array           All installed themes
  *
  */
  function COM_getThemes( $all = false )
  {
***************
*** 755,762 ****
  */
  
! function COM_siteHeader( $what = 'menu', $pagetitle = '' )
  {
      global $_CONF, $_TABLES, $_USER, $LANG01, $LANG_BUTTONS, $LANG_CHARSET,
!            $topic, $_COM_VERBOSE, $HTTP_POST_VARS, $HTTP_GET_VARS;
  
      // If the theme implemented this for us then call their version instead.
--- 756,763 ----
  */
  
! function COM_siteHeader( $what = 'menu', $pagetitle = '', $headercode = '' )
  {
      global $_CONF, $_TABLES, $_USER, $LANG01, $LANG_BUTTONS, $LANG_CHARSET,
!            $topic, $_COM_VERBOSE;
  
      // If the theme implemented this for us then call their version instead.
***************
*** 782,798 ****
  
      // get topic if not on home page
!     if( !isset( $HTTP_GET_VARS['topic'] ))
      {
!         if( isset( $HTTP_GET_VARS['story'] ))
          {
!             $sid = COM_applyFilter( $HTTP_GET_VARS['story'] );
          }
!         elseif( isset( $HTTP_GET_VARS['sid'] ))
          {
!             $sid = COM_applyFilter( $HTTP_GET_VARS['sid'] );
          }
!         elseif( isset( $HTTP_POST_VARS['story'] ))
          {
!             $sid = COM_applyFilter( $HTTP_POST_VARS['story'] );
          }
          if( !empty( $sid ))
--- 783,799 ----
  
      // get topic if not on home page
!     if( !isset( $_GET['topic'] ))
      {
!         if( isset( $_GET['story'] ))
          {
!             $sid = COM_applyFilter( $_GET['story'] );
          }
!         elseif( isset( $_GET['sid'] ))
          {
!             $sid = COM_applyFilter( $_GET['sid'] );
          }
!         elseif( isset( $_POST['story'] ))
          {
!             $sid = COM_applyFilter( $_POST['story'] );
          }
          if( !empty( $sid ))
***************
*** 803,807 ****
      else
      {
!         $topic = COM_applyFilter( $HTTP_GET_VARS['topic'] );
      }
  
--- 804,808 ----
      else
      {
!         $topic = COM_applyFilter( $_GET['topic'] );
      }
  
***************
*** 958,962 ****
      // Call any plugin that may want to include extra Meta tags
      // or Javascript functions
!     $header->set_var( 'plg_headercode', PLG_getHeaderCode() );
  
      // Call to plugins to set template variables in the header
--- 959,963 ----
      // Call any plugin that may want to include extra Meta tags
      // or Javascript functions
!     $header->set_var( 'plg_headercode', $headercode . PLG_getHeaderCode() );
  
      // Call to plugins to set template variables in the header
***************
*** 1564,1568 ****
  function COM_accessLog( $logentry )
  {
!     global $_CONF, $_USER, $LANG01, $HTTP_SERVER_VARS;
  
      $retval = '';
--- 1565,1569 ----
  function COM_accessLog( $logentry )
  {
!     global $_CONF, $_USER, $LANG01;
  
      $retval = '';
***************
*** 1578,1586 ****
      if( isset( $_USER['uid'] ))
      {
!         $byuser = $_USER['uid'] . '@' . $HTTP_SERVER_VARS['REMOTE_ADDR'];
      }
      else
      {
!         $byuser = 'anon@' . $HTTP_SERVER_VARS['REMOTE_ADDR'];
      }
  
--- 1579,1587 ----
      if( isset( $_USER['uid'] ))
      {
!         $byuser = $_USER['uid'] . '@' . $_SERVER['REMOTE_ADDR'];
      }
      else
      {
!         $byuser = 'anon@' . $_SERVER['REMOTE_ADDR'];
      }
  
***************
*** 1604,1608 ****
  function COM_pollVote( $qid )
  {
!     global $_CONF, $_TABLES, $LANG01, $HTTP_COOKIE_VARS, $HTTP_SERVER_VARS;
  
      $retval = '';
--- 1605,1609 ----
  function COM_pollVote( $qid )
  {
!     global $_CONF, $_TABLES, $LANG01, $_COOKIE;
  
      $retval = '';
***************
*** 1618,1625 ****
      $nquestion = DB_numRows( $question );
      $fields = array( 'ipaddress', 'qid' );
!     $values = array( $HTTP_SERVER_VARS['REMOTE_ADDR'], $qid );
      $id = DB_count( $_TABLES['pollvoters'], $fields, $values );
  
!     if( empty( $HTTP_COOKIE_VARS[$qid] ) && $id == 0 )
      {
          if( $nquestion == 1 )
--- 1619,1626 ----
      $nquestion = DB_numRows( $question );
      $fields = array( 'ipaddress', 'qid' );
!     $values = array( $_SERVER['REMOTE_ADDR'], $qid );
      $id = DB_count( $_TABLES['pollvoters'], $fields, $values );
  
!     if( empty( $_COOKIE[$qid] ) && $id == 0 )
      {
          if( $nquestion == 1 )
***************
*** 1705,1709 ****
  function COM_showPoll( $size, $qid='' )
  {
!     global $_CONF, $_TABLES, $HTTP_COOKIE_VARS, $HTTP_SERVER_VARS;
  
      $retval = '';
--- 1706,1710 ----
  function COM_showPoll( $size, $qid='' )
  {
!     global $_CONF, $_TABLES, $_COOKIE;
  
      $retval = '';
***************
*** 1714,1720 ****
      {
          $pcount = DB_count( $_TABLES['pollvoters'], array( 'ipaddress', 'qid' ),
!                             array( $HTTP_SERVER_VARS['REMOTE_ADDR'], $qid ));
  
!         if( empty( $HTTP_COOKIE_VARS[$qid]) && $pcount == 0 )
          {
              $retval .= COM_pollVote( $qid );
--- 1715,1721 ----
      {
          $pcount = DB_count( $_TABLES['pollvoters'], array( 'ipaddress', 'qid' ),
!                             array( $_SERVER['REMOTE_ADDR'], $qid ));
  
!         if( empty( $_COOKIE[$qid]) && $pcount == 0 )
          {
              $retval .= COM_pollVote( $qid );
***************
*** 1737,1744 ****
                  $qid = $Q['qid'];
                  $id = array( 'ipaddress', 'qid' );
!                 $value = array( $HTTP_SERVER_VARS['REMOTE_ADDR'], $qid );
                  $pcount = DB_count( $_TABLES['pollvoters'], $id, $value );
  
!                 if( !isset( $HTTP_COOKIE_VARS[$qid]) && $pcount == 0 )
                  {
                      $retval .= COM_pollVote( $qid );
--- 1738,1745 ----
                  $qid = $Q['qid'];
                  $id = array( 'ipaddress', 'qid' );
!                 $value = array( $_SERVER['REMOTE_ADDR'], $qid );
                  $pcount = DB_count( $_TABLES['pollvoters'], $id, $value );
  
!                 if( !isset( $_COOKIE[$qid]) && $pcount == 0 )
                  {
                      $retval .= COM_pollVote( $qid );
***************
*** 1897,1901 ****
                      $Q['perm_anon'] ) == 3 ? true : false );
                  $retval .= COM_userComments( $qid, $Q['question'], 'poll',
!                                              $order, $mode, 0, 1, false, $delete_option ); 
              }
          }
--- 1898,1902 ----
                      $Q['perm_anon'] ) == 3 ? true : false );
                  $retval .= COM_userComments( $qid, $Q['question'], 'poll',
!                                 $order, $mode, 0, 1, false, $delete_option ); 
              }
          }
***************
*** 1918,1922 ****
  function COM_showTopics( $topic='' )
  {
!     global $_CONF, $_TABLES, $_USER, $LANG01, $HTTP_SERVER_VARS,
             $_THEME_URL, $_BLOCK_TEMPLATE, $page, $newstories;
  
--- 1919,1923 ----
  function COM_showTopics( $topic='' )
  {
!     global $_CONF, $_TABLES, $_USER, $LANG01,
             $_THEME_URL, $_BLOCK_TEMPLATE, $page, $newstories;
  
***************
*** 2098,2102 ****
  function COM_userMenu( $help='', $title='' )
  {
!     global $_TABLES, $_USER, $_CONF, $LANG01, $_BLOCK_TEMPLATE, $HTTP_SERVER_VARS;
  
      $retval = '';
--- 2099,2103 ----
  function COM_userMenu( $help='', $title='' )
  {
!     global $_TABLES, $_USER, $_CONF, $LANG01, $_BLOCK_TEMPLATE;
  
      $retval = '';
***************
*** 2248,2252 ****
  function COM_adminMenu( $help = '', $title = '' )
  {
!     global $_TABLES, $_USER, $_CONF, $LANG01, $_BLOCK_TEMPLATE, $LANG_PDF, $HTTP_SERVER_VARS;
  
      $retval = '';
--- 2249,2253 ----
  function COM_adminMenu( $help = '', $title = '' )
  {
!     global $_TABLES, $_USER, $_CONF, $LANG01, $_BLOCK_TEMPLATE, $LANG_PDF;
  
      $retval = '';
***************
*** 2498,2501 ****
--- 2499,2513 ----
          }
  
+         if( $_CONF['trackback_enabled'] && SEC_inGroup( 'Root' ))
+         {
+             $url = $_CONF['site_admin_url'] . '/trackback.php';
+             $adminmenu->set_var( 'option_url', $url );
+             $adminmenu->set_var( 'option_label', $LANG01[116] );
+             $adminmenu->set_var( 'option_count', 'N/A' );
+ 
+             $retval .= $adminmenu->parse( 'item',
+                     ( $thisUrl == $url ) ? 'current' : 'option' );
+         }
+ 
          if( SEC_hasrights( 'plugin.edit' ))
          {
***************
*** 2613,2619 ****
  function COM_commentBar( $sid, $title, $type, $order, $mode )
  {
!     global $_CONF, $_TABLES, $_USER, $LANG01, $_REQUEST, $HTTP_SERVER_VARS;
  
!     $page = array_pop( explode( '/', $HTTP_SERVER_VARS['PHP_SELF'] ));
      $nrows = DB_count( $_TABLES['comments'], 'sid', $sid );
  
--- 2625,2631 ----
  function COM_commentBar( $sid, $title, $type, $order, $mode )
  {
!     global $_CONF, $_TABLES, $_USER, $LANG01;
  
!     $page = array_pop( explode( '/', $_SERVER['PHP_SELF'] ));
      $nrows = DB_count( $_TABLES['comments'], 'sid', $sid );
  
***************
*** 3685,3689 ****
  function COM_showBlocks( $side, $topic='', $name='all' )
  {
!     global $_TABLES, $_CONF, $_USER, $LANG21, $HTTP_SERVER_VARS, $topic, $page, $newstories;
  
      $retval = '';
--- 3697,3701 ----
  function COM_showBlocks( $side, $topic='', $name='all' )
  {
!     global $_CONF, $_TABLES, $_USER, $LANG21, $topic, $page, $newstories;
  
      $retval = '';
***************
*** 3768,3773 ****
  function COM_formatBlock( $A, $noboxes = false )
  {
!     global $_CONF, $_TABLES, $_USER, $LANG21, $HTTP_SERVER_VARS,
!            $topic, $page, $newstories;
  
      $retval = '';
--- 3780,3784 ----
  function COM_formatBlock( $A, $noboxes = false )
  {
!     global $_CONF, $_TABLES, $_USER, $LANG21, $topic, $page, $newstories;
  
      $retval = '';
***************
*** 4141,4145 ****
      if ($uid == '')
      {
!         $uid = $_USER['uid'];
      }
  
--- 4152,4163 ----
      if ($uid == '')
      {
!         if( empty( $_USER['uid'] ) || ( $_USER['uid'] <= 1 ))
!         {
!             $uid = 1;
!         }
!         else
!         {
!             $uid = $_USER['uid'];
!         }
      }
  
***************
*** 4540,4554 ****
  
  /**
! * Shows any new information in block
  *
  * Return the HTML that shows any new stories, comments, etc
  *
! * @param        string      $help       Help file for block
! * @param        string      $title      Title used in block header
! * @return     string  Return the HTML that shows any new stories, comments, etc
  *
  */
  
! function COM_whatsNewBlock( $help='', $title='' )
  {
      global $_CONF, $_TABLES, $_USER, $LANG01, $page, $newstories;
--- 4558,4572 ----
  
  /**
! * Shows any new information in a block
  *
  * Return the HTML that shows any new stories, comments, etc
  *
! * @param    string  $help   Help file for block
! * @param    string  $title  Title used in block header
! * @return   string  Return the HTML that shows any new stories, comments, etc
  *
  */
  
! function COM_whatsNewBlock( $help = '', $title = '' )
  {
      global $_CONF, $_TABLES, $_USER, $LANG01, $page, $newstories;
***************
*** 4558,4579 ****
  
      $topicsql = '';
!     if(( $_CONF['hidenewstories'] == 0 ) || ( $_CONF['hidenewcomments'] == 0 ))
      {
!         $tresult = DB_query( "SELECT tid FROM {$_TABLES['topics']}"
!                              . COM_getPermSQL() );
!         $trows = DB_numRows( $tresult );
!         if( $trows > 0 )
!         {
!             $tids = array();
!             for( $i = 0; $i < $trows; $i++ )
!             {
!                 $T = DB_fetchArray( $tresult );
!                 $tids[] = $T['tid'];
!             }
!             if( sizeof( $tids ) > 0 )
!             {
!                 $topicsql = " AND (tid IN ('" . implode( "','", $tids ) . "'))";
!             }
!         }
      }
  
--- 4576,4584 ----
  
      $topicsql = '';
!     if(( $_CONF['hidenewstories'] == 0 ) || ( $_CONF['hidenewcomments'] == 0 )
!             || ( $_CONF['trackback_enabled']
!             && ( $_CONF['hidenewtrackbacks'] == 0 )))
      {
!         $topicsql = COM_getTopicSql ('AND', 0, $_TABLES['stories']);
      }
  
***************
*** 4630,4634 ****
          }
  
!         if(( $_CONF['hidenewcomments'] == 0 ) || ( $_CONF['hidenewlinks'] == 0 )
                  || ( $_CONF['hidenewplugins'] == 0 ))
          {
--- 4635,4641 ----
          }
  
!         if(( $_CONF['hidenewcomments'] == 0 ) || ( $_CONF['trackback_enabled']
!                 && ( $_CONF['hidenewtrackbacks'] == 0 )) 
!                 || ( $_CONF['hidenewlinks'] == 0 )
                  || ( $_CONF['hidenewplugins'] == 0 ))
          {
***************
*** 4678,4682 ****
              $newcomments = array();
  
!             for( $x = 1; $x <= $nrows; $x++ )
              {
                  $A = DB_fetchArray( $result );
--- 4685,4689 ----
              $newcomments = array();
  
!             for( $x = 0; $x < $nrows; $x++ )
              {
                  $A = DB_fetchArray( $result );
***************
*** 4684,4689 ****
                  if(( $A['type'] == 'article' ) || empty( $A['type'] ))
                  {
-                     $itemlen = strlen( $A['title'] );
                      $titletouse = stripslashes( $A['title'] );
                      $urlstart = '<a href="' . COM_buildUrl( $_CONF['site_url']
                          . '/article.php?story=' . $A['sid'] ) . '#comments' . '"';
--- 4691,4696 ----
                  if(( $A['type'] == 'article' ) || empty( $A['type'] ))
                  {
                      $titletouse = stripslashes( $A['title'] );
+                     $itemlen = strlen( $titletouse );
                      $urlstart = '<a href="' . COM_buildUrl( $_CONF['site_url']
                          . '/article.php?story=' . $A['sid'] ) . '#comments' . '"';
***************
*** 4691,4702 ****
                  else if( $A['type'] == 'poll' )
                  {
-                     $itemlen = strlen( $A['question'] );
                      $titletouse = $A['question'];
                      $urlstart = '<a href="' . $_CONF['site_url'] . '/pollbooth.php?qid=' . $A['qid'] . '&aid=-1#comments"';
                  }
  
                  if( $itemlen > 20 )
                  {
                      $urlstart .= ' title="' . htmlspecialchars( $titletouse ) . '">';
                  }
                  else
--- 4698,4711 ----
                  else if( $A['type'] == 'poll' )
                  {
                      $titletouse = $A['question'];
+                     $itemlen = strlen( $titletouse );
                      $urlstart = '<a href="' . $_CONF['site_url'] . '/pollbooth.php?qid=' . $A['qid'] . '&aid=-1#comments"';
                  }
  
+                 // Trim the length if over 20 characters
                  if( $itemlen > 20 )
                  {
                      $urlstart .= ' title="' . htmlspecialchars( $titletouse ) . '">';
+                     $titletouse = substr( $titletouse, 0, 17 ) . '...';
                  }
                  else
***************
*** 4705,4729 ****
                  }
  
                  // Trim the length if over 20 characters
                  if( $itemlen > 20 )
                  {
!                     $titletouse = substr( $titletouse, 0, 17 );
!                     $acomment = str_replace( '$', '$', $titletouse ) . '...';
!                     $acomment = str_replace( ' ', ' ', $acomment );
! 
!                     if( $A['dups'] > 1 )
!                     {
!                         $acomment .= ' [+' . $A['dups'] . ']';
!                     }
                  }
                  else
                  {
!                     $acomment = str_replace( '$', '$', $titletouse );
!                     $acomment = str_replace( ' ', ' ', $acomment );
  
!                     if( $A['dups'] > 1 )
!                     {
!                         $acomment .= ' [+' . $A['dups'] . ']';
!                     }
                  }
  
--- 4714,4781 ----
                  }
  
+                 $acomment = str_replace( '$', '$', $titletouse );
+                 $acomment = str_replace( ' ', ' ', $acomment );
+ 
+                 if( $A['dups'] > 1 )
+                 {
+                     $acomment .= ' [+' . $A['dups'] . ']';
+                 }
+ 
+                 $newcomments[] = $urlstart . $acomment . '</a>';
+             }
+ 
+             $retval .= COM_makeList( $newcomments, 'list-new-comments' );
+         }
+         else
+         {
+             $retval .= $LANG01[86] . '<br>' . LB;
+         }
+ 
+         if(( $_CONF['hidenewlinks'] == 0 ) || ( $_CONF['hidenewplugins'] == 0 )
+                 || ( $_CONF['trackback_enabled']
+                 && ( $_CONF['hidenewtrackbacks'] == 0 )))
+         {
+             $retval .= '<br>';
+         }
+     }
+ 
+     if( $_CONF['trackback_enabled'] && ( $_CONF['hidenewtrackbacks'] == 0 ))
+     {
+         $retval .= '<b>' . $LANG01[114] . '</b> <small>' . $LANG01[85] . '</small><br>';
+ 
+         $sql = "SELECT DISTINCT COUNT(*) AS count,{$_TABLES['stories']}.title,t.sid FROM {$_TABLES['trackback']} AS t,{$_TABLES['stories']} WHERE (t.type = 'article') AND (t.sid = {$_TABLES['stories']}.sid) AND (t.date >= (DATE_SUB(NOW(), INTERVAL {$_CONF['newtrackbackinterval']} SECOND)))" . COM_getPermSQL( 'AND', 0, 2, $_TABLES['stories'] ) . " AND ({$_TABLES['stories']}.draft_flag = 0)" . $topicsql . " GROUP BY t.sid ORDER BY t.date DESC LIMIT 15";
+         $result = DB_query( $sql );
+ 
+         $nrows = DB_numRows( $result );
+         if( $nrows > 0 )
+         {
+             $newcomments = array();
+ 
+             for( $i = 0; $i < $nrows; $i++ )
+             {
+                 $A = DB_fetchArray( $result );
+ 
+                 $titletouse = stripslashes( $A['title'] );
+                 $itemlen = strlen( $titletouse );
+                 $urlstart = '<a href="' . COM_buildUrl( $_CONF['site_url']
+                     . '/article.php?story=' . $A['sid'] ) . '#trackback' . '"';
+ 
                  // Trim the length if over 20 characters
                  if( $itemlen > 20 )
                  {
!                     $urlstart .= ' title="' . htmlspecialchars( $titletouse ) . '">';
!                     $titletouse = substr( $titletouse, 0, 17 ) . '...';
                  }
                  else
                  {
!                     $urlstart .= '>';
!                 }
  
!                 $acomment = str_replace( '$', '$', $titletouse );
!                 $acomment = str_replace( ' ', ' ', $acomment );
! 
!                 if( $A['count'] > 1 )
!                 {
!                     $acomment .= ' [+' . $A['count'] . ']';
                  }
  
***************
*** 4731,4739 ****
              }
  
!             $retval .= COM_makeList( $newcomments, 'list-new-comments' );
          }
          else
          {
!             $retval .= $LANG01[86] . '<br>' . LB;
          }
  
--- 4783,4791 ----
              }
  
!             $retval .= COM_makeList( $newcomments, 'list-new-trackbacks' );
          }
          else
          {
!             $retval .= $LANG01[115] . '<br>' . LB;
          }
  
***************
*** 5397,5406 ****
  function COM_checkSpeedlimit( $type = 'submit' )
  {
!     global $_TABLES, $HTTP_SERVER_VARS;
  
      $last = 0;
  
      $date = DB_getItem( $_TABLES['speedlimit'], 'date',
!             "(type = '$type') AND (ipaddress = '{$HTTP_SERVER_VARS['REMOTE_ADDR']}')" );
      if( !empty( $date ))
      {
--- 5449,5458 ----
  function COM_checkSpeedlimit( $type = 'submit' )
  {
!     global $_TABLES;
  
      $last = 0;
  
      $date = DB_getItem( $_TABLES['speedlimit'], 'date',
!             "(type = '$type') AND (ipaddress = '{$_SERVER['REMOTE_ADDR']}')" );
      if( !empty( $date ))
      {
***************
*** 5424,5431 ****
  function COM_updateSpeedlimit( $type = 'submit' )
  {
!     global $_TABLES, $HTTP_SERVER_VARS;
  
      DB_save( $_TABLES['speedlimit'], 'ipaddress,date,type',
!              "'{$HTTP_SERVER_VARS['REMOTE_ADDR']}',unix_timestamp(),'$type'" );
  }
  
--- 5476,5483 ----
  function COM_updateSpeedlimit( $type = 'submit' )
  {
!     global $_TABLES;
  
      DB_save( $_TABLES['speedlimit'], 'ipaddress,date,type',
!              "'{$_SERVER['REMOTE_ADDR']}',unix_timestamp(),'$type'" );
  }
  
***************
*** 5736,5741 ****
  function COM_applyFilter( $parameter, $isnumeric = false )
  {
-     global $HTTP_SERVER_VARS;
- 
      $log_manipulation = false; // set to true to log when the filter applied
  
--- 5788,5791 ----
***************
*** 5767,5771 ****
          if( strcmp( $p, $parameter ) != 0 )
          {
!             COM_errorLog( "Filter applied: >> $parameter << filtered to $p [IP {$HTTP_SERVER_VARS['REMOTE_ADDR']}]", 1);
          }
      }
--- 5817,5821 ----
          if( strcmp( $p, $parameter ) != 0 )
          {
!             COM_errorLog( "Filter applied: >> $parameter << filtered to $p [IP {$_SERVER['REMOTE_ADDR']}]", 1);
          }
      }
***************
*** 5948,5987 ****
  function COM_getCurrentURL()
  {
!     global $_CONF, $HTTP_SERVER_VARS;
  
      $thisUrl = '';
  
!     if( empty( $HTTP_SERVER_VARS['SCRIPT_URI'] ))
      {
!         if( !empty( $HTTP_SERVER_VARS['DOCUMENT_URI'] ))
          {
!             $thisUrl = $HTTP_SERVER_VARS['DOCUMENT_URI'];
          }
      }
      else
      {
!         $thisUrl = $HTTP_SERVER_VARS['SCRIPT_URI'];
      }
!     if( !empty( $thisUrl ) && !empty( $HTTP_SERVER_VARS['QUERY_STRING'] ))
      {
!         $thisUrl .= '?' . $HTTP_SERVER_VARS['QUERY_STRING'];
      }
      if( empty( $thisUrl ))
      {
!         $requestUri = $HTTP_SERVER_VARS['REQUEST_URI'];
!         if( empty( $HTTP_SERVER_VARS['REQUEST_URI'] ))
          {
              // on a Zeus webserver, prefer PATH_INFO over SCRIPT_NAME
!             if( empty( $HTTP_SERVER_VARS['PATH_INFO'] ))
              {
!                 $requestUri = $HTTP_SERVER_VARS['SCRIPT_NAME'];
              }
              else
              {
!                 $requestUri = $HTTP_SERVER_VARS['PATH_INFO'];
              }
!             if( !empty( $HTTP_SERVER_VARS['QUERY_STRING'] ))
              {
!                 $requestUri .= '?' . $HTTP_SERVER_VARS['QUERY_STRING'];     
              }
          }
--- 5998,6037 ----
  function COM_getCurrentURL()
  {
!     global $_CONF;
  
      $thisUrl = '';
  
!     if( empty( $_SERVER['SCRIPT_URI'] ))
      {
!         if( !empty( $_SERVER['DOCUMENT_URI'] ))
          {
!             $thisUrl = $_SERVER['DOCUMENT_URI'];
          }
      }
      else
      {
!         $thisUrl = $_SERVER['SCRIPT_URI'];
      }
!     if( !empty( $thisUrl ) && !empty( $_SERVER['QUERY_STRING'] ))
      {
!         $thisUrl .= '?' . $_SERVER['QUERY_STRING'];
      }
      if( empty( $thisUrl ))
      {
!         $requestUri = $_SERVER['REQUEST_URI'];
!         if( empty( $_SERVER['REQUEST_URI'] ))
          {
              // on a Zeus webserver, prefer PATH_INFO over SCRIPT_NAME
!             if( empty( $_SERVER['PATH_INFO'] ))
              {
!                 $requestUri = $_SERVER['SCRIPT_NAME'];
              }
              else
              {
!                 $requestUri = $_SERVER['PATH_INFO'];
              }
!             if( !empty( $_SERVER['QUERY_STRING'] ))
              {
!                 $requestUri .= '?' . $_SERVER['QUERY_STRING'];     
              }
          }
***************
*** 6019,6023 ****
  function COM_isFrontpage()
  {
!     global $_CONF, $HTTP_SERVER_VARS, $topic, $page, $newstories;
  
      // Note: We can't use $PHP_SELF here since the site may not be in the
--- 6069,6073 ----
  function COM_isFrontpage()
  {
!     global $_CONF, $topic, $page, $newstories;
  
      // Note: We can't use $PHP_SELF here since the site may not be in the
***************
*** 6026,6036 ****
  
      // on a Zeus webserver, prefer PATH_INFO over SCRIPT_NAME
!     if( empty( $HTTP_SERVER_VARS['PATH_INFO'] ))
      {
!         $scriptName = $HTTP_SERVER_VARS['SCRIPT_NAME'];
      }
      else
      {
!         $scriptName = $HTTP_SERVER_VARS['PATH_INFO'];
      }
  
--- 6076,6086 ----
  
      // on a Zeus webserver, prefer PATH_INFO over SCRIPT_NAME
!     if( empty( $_SERVER['PATH_INFO'] ))
      {
!         $scriptName = $_SERVER['SCRIPT_NAME'];
      }
      else
      {
!         $scriptName = $_SERVER['PATH_INFO'];
      }
  

Index: stats.php
===================================================================
RCS file: /var/cvs/geeklog-1.3/public_html/stats.php,v
retrieving revision 1.32
retrieving revision 1.33
diff -C2 -d -r1.32 -r1.33
*** stats.php	5 Sep 2004 19:19:50 -0000	1.32
--- stats.php	16 Jan 2005 19:14:28 -0000	1.33
***************
*** 9,18 ****
  // | Geeklog system statistics page.                                           |
  // +---------------------------------------------------------------------------+
! // | Copyright (C) 2000-2004 by the following authors:                         |
  // |                                                                           |
! // | Authors: Tony Bibbs        - tony at tonybibbs.com                           |
! // |          Mark Limburg      - mlimburg at users.sourceforge.net               |
! // |          Jason Whittenburg - jwhitten at securitygeeks.com                   |
! // |          Dirk Haun         - dirk at haun-online.de                          |
  // +---------------------------------------------------------------------------+
  // |                                                                           |
--- 9,18 ----
  // | Geeklog system statistics page.                                           |
  // +---------------------------------------------------------------------------+
! // | Copyright (C) 2000-2005 by the following authors:                         |
  // |                                                                           |
! // | Authors: Tony Bibbs        - tony AT tonybibbs DOT com                    |
! // |          Mark Limburg      - mlimburg AT users DOT sourceforge DOT net    |
! // |          Jason Whittenburg - jwhitten AT securitygeeks DOT com            |
! // |          Dirk Haun         - dirk AT haun-online DOT de                   |
  // +---------------------------------------------------------------------------+
  // |                                                                           |
***************
*** 63,70 ****
  
  $stat_templates = new Template($_CONF['path_layout'] . 'stats');
! $stat_templates->set_file(array('stats'=>'stats.thtml',
!                             'sitestats'=>'sitestatistics.thtml',
!                             'itemstats'=>'itemstatistics.thtml',
!                             'statrow'=>'singlestat.thtml'));
  
  // Overall Site Statistics
--- 63,70 ----
  
  $stat_templates = new Template($_CONF['path_layout'] . 'stats');
! $stat_templates->set_file (array ('stats'     => 'stats.thtml',
!                                   'sitestats' => 'sitestatistics.thtml',
!                                   'itemstats' => 'itemstatistics.thtml',
!                                   'statrow'   => 'singlestat.thtml'));
  
  // Overall Site Statistics
***************
*** 74,80 ****
  $stat_templates->set_var('total_hits', $totalhits);
  
  $id = array('draft_flag','date');
  $values = array('0','NOW()');	
! $result = DB_query("SELECT count(*) AS count,SUM(comments) as ccount FROM {$_TABLES['stories']} WHERE (draft_flag = 0) AND (date <= NOW())" . COM_getPermSQL ('AND'));
  $A = DB_fetchArray($result);
  $total_stories = $A['count'];
--- 74,82 ----
  $stat_templates->set_var('total_hits', $totalhits);
  
+ $topicsql = COM_getTopicSql ('AND');
+ 
  $id = array('draft_flag','date');
  $values = array('0','NOW()');	
! $result = DB_query("SELECT count(*) AS count,SUM(comments) as ccount FROM {$_TABLES['stories']} WHERE (draft_flag = 0) AND (date <= NOW())" . COM_getPermSQL ('AND') . $topicsql);
  $A = DB_fetchArray($result);
  $total_stories = $A['count'];
***************
*** 111,115 ****
  $stat_templates->set_var('total_answers', $total_answers);
  
! $result = DB_query ("SELECT count(*) AS count,SUM(hits) AS clicks FROM {$_TABLES['links']}" . COM_getPermSQL ());
  $A = DB_fetchArray($result);
  $total_links = $A['count'];
--- 113,117 ----
  $stat_templates->set_var('total_answers', $total_answers);
  
! $result = DB_query ("SELECT COUNT(*) AS count,SUM(hits) AS clicks FROM {$_TABLES['links']}" . COM_getPermSQL ());
  $A = DB_fetchArray($result);
  $total_links = $A['count'];
***************
*** 122,126 ****
  $stat_templates->set_var('total_clicks',$total_clicks);
  
! $result = DB_query ("SELECT count(*) AS count FROM {$_TABLES['events']}" . COM_getPermSQL ());
  $A = DB_fetchArray($result);
  $total_events = $A['count'];
--- 124,128 ----
  $stat_templates->set_var('total_clicks',$total_clicks);
  
! $result = DB_query ("SELECT COUNT(*) AS count FROM {$_TABLES['events']}" . COM_getPermSQL ());
  $A = DB_fetchArray($result);
  $total_events = $A['count'];
***************
*** 139,143 ****
  // Detailed story statistics
  
! $result = DB_query("SELECT sid,title,hits FROM {$_TABLES["stories"]} WHERE (draft_flag = 0) AND (date <= NOW()) AND (Hits > 0)" . COM_getPermSQL ('AND') . " ORDER BY Hits desc LIMIT 10");
  $nrows  = DB_numRows($result);
  
--- 141,145 ----
  // Detailed story statistics
  
! $result = DB_query("SELECT sid,title,hits FROM {$_TABLES['stories']} WHERE (draft_flag = 0) AND (date <= NOW()) AND (Hits > 0)" . COM_getPermSQL ('AND') . $topicsql . " ORDER BY hits DESC LIMIT 10");
  $nrows  = DB_numRows($result);
  
***************
*** 159,163 ****
      $display .= $LANG10[10];
  }
! 	
  $display .= COM_endBlock();
  $stat_templates->set_var('stat_row','');
--- 161,165 ----
      $display .= $LANG10[10];
  }
! 
  $display .= COM_endBlock();
  $stat_templates->set_var('stat_row','');
***************
*** 165,169 ****
  // Top Ten Commented Stories
  
! $result = DB_query("SELECT sid,title,comments from {$_TABLES['stories']} WHERE (draft_flag = 0) AND (date <= NOW()) AND (comments > 0)" . COM_getPermSQL ('AND') . " ORDER BY comments desc LIMIT 10");
  $nrows  = DB_numRows($result);
  $display .= COM_startBlock($LANG10[11]);
--- 167,171 ----
  // Top Ten Commented Stories
  
! $result = DB_query("SELECT sid,title,comments FROM {$_TABLES['stories']} WHERE (draft_flag = 0) AND (date <= NOW()) AND (comments > 0)" . COM_getPermSQL ('AND') . $topicsql . " ORDER BY comments DESC LIMIT 10");
  $nrows  = DB_numRows($result);
  $display .= COM_startBlock($LANG10[11]);
***************
*** 187,193 ****
  $stat_templates->set_var('stat_row','');
  
  // Top Ten Emailed Stories
  
! $result = DB_query("SELECT sid,title,numemails FROM {$_TABLES["stories"]} WHERE (numemails > 0) AND (draft_flag = 0) AND (date <= NOW())" . COM_getPermSQL ('AND') . " ORDER BY numemails desc LIMIT 10");
  $nrows = DB_numRows($result);
  $display .= COM_startBlock($LANG10[22]);
--- 189,220 ----
  $stat_templates->set_var('stat_row','');
  
+ // Top Ten Trackback Comments
+ 
+ $result = DB_query ("SELECT {$_TABLES['stories']}.sid,{$_TABLES['stories']}.title,COUNT(*) AS count FROM {$_TABLES['stories']},{$_TABLES['trackback']} AS t WHERE (draft_flag = 0) AND ({$_TABLES['stories']}.date <= NOW()) AND ({$_TABLES['stories']}.sid = t.sid) AND (t.type = 'article')" . COM_getPermSql ('AND') . $topicsql . " GROUP BY t.sid ORDER BY count DESC LIMIT 10");
+ $nrows = DB_numRows ($result);
+ $display .= COM_startBlock ($LANG10[25]);
+ if ($nrows > 0) {
+     $stat_templates->set_var ('item_label', $LANG10[8]);
+     $stat_templates->set_var ('stat_name', $LANG10[12]);
+     for ($i = 0; $i < $nrows; $i++) {
+         $A = DB_fetchArray ($result);
+         $stat_templates->set_var ('item_url', COM_buildUrl ($_CONF['site_url']
+                                         . '/article.php?story=' . $A['sid']));
+         $stat_templates->set_var ('item_text',
+                 stripslashes (str_replace ('$', '$', $A['title'])));
+         $stat_templates->set_var ('item_stat', $A['count']);
+         $stat_templates->parse ('stat_row', 'statrow', true);
+     }
+     $stat_templates->parse ('output', 'itemstats');
+     $display .= $stat_templates->finish ($stat_templates->get_var ('output'));
+ } else {
+     $display .= $LANG10[26];
+ }
+ $display .= COM_endBlock ();
+ $stat_templates->set_var ('stat_row', '');
+ 
  // Top Ten Emailed Stories
  
! $result = DB_query("SELECT sid,title,numemails FROM {$_TABLES['stories']} WHERE (numemails > 0) AND (draft_flag = 0) AND (date <= NOW())" . COM_getPermSQL ('AND') . $topicsql . " ORDER BY numemails DESC LIMIT 10");
  $nrows = DB_numRows($result);
  $display .= COM_startBlock($LANG10[22]);
***************
*** 214,218 ****
  // Top Ten Polls
  
! $result = DB_query("SELECT qid,question,voters from {$_TABLES['pollquestions']} WHERE (voters > 0)" . COM_getPermSQL ('AND') . " ORDER BY voters desc LIMIT 10");
  $nrows  = DB_numRows($result);
  $display .= COM_startBlock($LANG10[14]);
--- 241,245 ----
  // Top Ten Polls
  
! $result = DB_query("SELECT qid,question,voters FROM {$_TABLES['pollquestions']} WHERE (voters > 0)" . COM_getPermSQL ('AND') . " ORDER BY voters DESC LIMIT 10");
  $nrows  = DB_numRows($result);
  $display .= COM_startBlock($LANG10[14]);
***************
*** 239,243 ****
  // Top Ten Links
  
! $result = DB_query("SELECT lid,url,title,hits from {$_TABLES['links']} WHERE (hits > 0)" . COM_getPermSQL ('AND') . " ORDER BY hits desc LIMIT 10");
  $nrows  = DB_numRows($result);
  $display .= COM_startBlock($LANG10[18]);
--- 266,270 ----
  // Top Ten Links
  
! $result = DB_query("SELECT lid,url,title,hits FROM {$_TABLES['links']} WHERE (hits > 0)" . COM_getPermSQL ('AND') . " ORDER BY hits DESC LIMIT 10");
  $nrows  = DB_numRows($result);
  $display .= COM_startBlock($LANG10[18]);

--- NEW FILE: trackback.php ---
<?php

/* Reminder: always indent with 4 spaces (no tabs). */
// +---------------------------------------------------------------------------+
// | Geeklog 1.3                                                               |
// +---------------------------------------------------------------------------+
// | trackback.php                                                             |
// |                                                                           |
// | Handle trackback pings for stories and plugins.                           |
// +---------------------------------------------------------------------------+
// | Copyright (C) 2005 by the following authors:                              |
// |                                                                           |
// | Author: Dirk Haun - dirk AT haun-online DOT de                            |
// +---------------------------------------------------------------------------+
// |                                                                           |
// | This program is free software; you can redistribute it and/or             |
// | modify it under the terms of the GNU General Public License               |
// | as published by the Free Software Foundation; either version 2            |
// | of the License, or (at your option) any later version.                    |
// |                                                                           |
// | This program is distributed in the hope that it will be useful,           |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of            |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             |
// | GNU General Public License for more details.                              |
// |                                                                           |
// | You should have received a copy of the GNU General Public License         |
// | along with this program; if not, write to the Free Software Foundation,   |
// | Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.           |
// |                                                                           |
// +---------------------------------------------------------------------------+
// 
// $Id: trackback.php,v 1.1 2005/01/16 19:14:28 dhaun Exp $

require_once ('lib-common.php');
require_once ($_CONF['path_system'] . 'lib-trackback.php');

// Note: Error messages are hard-coded in English since there is no way of
// knowing which language the sender of the trackback ping may prefer.
$TRB_ERROR = array (
    'not_enabled'       => 'Trackback not enabled.',
    'illegal_request'   => 'Illegal request.',
    'no_access'         => 'You do not have access to this entry.'
);

if (!$_CONF['trackback_enabled']) {
    TRB_sendTrackbackResponse (1, $TRB_ERROR['not_enabled']);
    exit;
}

COM_setArgNames (array ('id', 'type'));
$id = COM_applyFilter (COM_getArgument ('id'));
$type = COM_applyFilter (COM_getArgument ('type'));

// Trackback pings using GET requests are deprecated but we still support them
if (empty ($id)) {
    $id = COM_applyFilter ($_REQUEST['id']);
    $type = COM_applyFilter ($_REQUEST['type']);
}

if (empty ($id)) {
    TRB_sendTrackbackResponse (1, $TRB_ERROR['illegal_request']);
    exit;
}

if (empty ($type)) {
    $type = 'article';
}

if ($type == 'article') {
    // check if they have access to this story
    $sid = addslashes ($id);
    $result = DB_query("SELECT COUNT(*) AS count FROM {$_TABLES['stories']} WHERE (sid = '$sid') AND (date <= NOW()) AND (draft_flag = 0)" . COM_getPermSql ('AND') . COM_getTopicSql ('AND'));
    $A = DB_fetchArray ($result);
    if ($A['count'] == 1) {
        TRB_handleTrackbackPing ($id, $type);
        exit;
    } else {
        TRB_sendTrackbackResponse (1, $TRB_ERROR['no_access']);
        exit;
    }
} else if (PLG_acceptTrackbackPing ($type, $id) === true) {
    TRB_handleTrackbackPing ($id, $type);
    exit;
} else {
    TRB_sendTrackbackResponse (1, $TRB_ERROR['no_access']);
    exit;
}

?>




More information about the geeklog-cvs mailing list