[geeklog-cvs] geeklog-1.3/public_html comment.php,1.84,1.85 lib-common.php,1.402,1.403

dhaun at iowaoutdoors.org dhaun at iowaoutdoors.org
Thu Dec 16 06:09:54 EST 2004


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

Modified Files:
	comment.php lib-common.php 
Log Message:
Update comment count in Older Stories block when a new comment is posted (bug #317) and optimized code to update the Older Stories block.


Index: comment.php
===================================================================
RCS file: /var/cvs/geeklog-1.3/public_html/comment.php,v
retrieving revision 1.84
retrieving revision 1.85
diff -C2 -d -r1.84 -r1.85
*** comment.php	13 Nov 2004 21:41:59 -0000	1.84
--- comment.php	16 Dec 2004 11:09:51 -0000	1.85
***************
*** 53,57 ****
  // to the script.  This will sometimes cause errors but it will allow you to see
  // the data being passed in a POST operation
! // echo COM_debug($HTTP_POST_VARS);
  
  /**
--- 53,57 ----
  // to the script.  This will sometimes cause errors but it will allow you to see
  // the data being passed in a POST operation
! // echo COM_debug($_POST);
  
  /**
***************
*** 71,75 ****
  function commentform($uid,$title,$comment,$sid,$pid='0',$type,$mode,$postmode) 
  {
!     global $_CONF, $_TABLES, $_USER, $HTTP_POST_VARS, $LANG03, $LANG12, $LANG_LOGIN;
  
      $retval = '';
--- 71,75 ----
  function commentform($uid,$title,$comment,$sid,$pid='0',$type,$mode,$postmode) 
  {
!     global $_CONF, $_TABLES, $_USER, $LANG03, $LANG12, $LANG_LOGIN;
  
      $retval = '';
***************
*** 148,152 ****
              $title = str_replace('}','}',$title);
  
!             $HTTP_POST_VARS['title'] = addslashes ($title);
              $newcomment = $comment;
              if (!empty ($sig)) {
--- 148,152 ----
              $title = str_replace('}','}',$title);
  
!             $_POST['title'] = addslashes ($title);
              $newcomment = $comment;
              if (!empty ($sig)) {
***************
*** 157,161 ****
                  }
              }
!             $HTTP_POST_VARS['comment'] = addslashes ($newcomment);
  
              if ($mode == $LANG03[14] && !empty($title) && !empty($comment) ) {
--- 157,161 ----
                  }
              }
!             $_POST['comment'] = addslashes ($newcomment);
  
              if ($mode == $LANG03[14] && !empty($title) && !empty($comment) ) {
***************
*** 165,173 ****
                  $start->set_var( 'layout_url', $_CONF['layout_url'] );
  
!                 if (empty ($HTTP_POST_VARS['username'])) {
!                     $HTTP_POST_VARS['username'] = DB_getItem ($_TABLES['users'],
                              'username', "uid = $uid");
                  }
!                 $thecomments = COM_getComment ($HTTP_POST_VARS, 'flat', $type,
                                                 'ASC', false, true );
  
--- 165,173 ----
                  $start->set_var( 'layout_url', $_CONF['layout_url'] );
  
!                 if (empty ($_POST['username'])) {
!                     $_POST['username'] = DB_getItem ($_TABLES['users'],
                              'username', "uid = $uid");
                  }
!                 $thecomments = COM_getComment ($_POST, 'flat', $type,
                                                 'ASC', false, true );
  
***************
*** 254,258 ****
  function savecomment ($uid, $title, $comment, $sid, $pid, $type, $postmode) 
  {
!     global $_CONF, $_TABLES, $_USER, $LANG03, $HTTP_SERVER_VARS;
      
      $retval = '';
--- 254,258 ----
  function savecomment ($uid, $title, $comment, $sid, $pid, $type, $postmode) 
  {
!     global $_CONF, $_TABLES, $_USER, $LANG03;
      
      $retval = '';
***************
*** 359,367 ****
                     . "WHERE sid = '$sid' AND rht >= $rht");
              DB_save ($_TABLES['comments'], 'sid,uid,comment,date,title,pid,lft,rht,indent,type,ipaddress',
!                     "'$sid',$uid,'$comment',now(),'$title',$pid,$rht,$rht+1,$indent+1,'$type','{$HTTP_SERVER_VARS['REMOTE_ADDR']}'");
          } else {
              $rht = DB_getItem($_TABLES['comments'], 'MAX(rht)');
              DB_save ($_TABLES['comments'], 'sid,uid,comment,date,title,pid,lft,rht,indent,type,ipaddress',
!                     "'$sid',$uid,'$comment',now(),'$title',$pid,$rht+1,$rht+2,0,'$type','{$HTTP_SERVER_VARS['REMOTE_ADDR']}'");
          }
          $cid = DB_insertId();
--- 359,367 ----
                     . "WHERE sid = '$sid' AND rht >= $rht");
              DB_save ($_TABLES['comments'], 'sid,uid,comment,date,title,pid,lft,rht,indent,type,ipaddress',
!                     "'$sid',$uid,'$comment',now(),'$title',$pid,$rht,$rht+1,$indent+1,'$type','{$_SERVER['REMOTE_ADDR']}'");
          } else {
              $rht = DB_getItem($_TABLES['comments'], 'MAX(rht)');
              DB_save ($_TABLES['comments'], 'sid,uid,comment,date,title,pid,lft,rht,indent,type,ipaddress',
!                     "'$sid',$uid,'$comment',now(),'$title',$pid,$rht+1,$rht+2,0,'$type','{$_SERVER['REMOTE_ADDR']}'");
          }
          $cid = DB_insertId();
***************
*** 370,375 ****
          if (isset ($_CONF['notification']) &&
                  in_array ('comment', $_CONF['notification'])) {
!             sendNotification ($title, $comment, $uid,
!                               $HTTP_SERVER_VARS['REMOTE_ADDR'], $type, $cid);
          }
  
--- 370,375 ----
          if (isset ($_CONF['notification']) &&
                  in_array ('comment', $_CONF['notification'])) {
!             sendNotification ($title, $comment, $uid, $_SERVER['REMOTE_ADDR'],
!                               $type, $cid);
          }
  
***************
*** 379,383 ****
          } elseif ($type == 'article') {
              $comments = DB_count ($_TABLES['comments'], 'sid', $sid);
!             DB_change($_TABLES['stories'],'comments',$comments,'sid',$sid);
              $retval = COM_refresh (COM_buildUrl ($_CONF['site_url']
                      . "/article.php?story=$sid"));
--- 379,384 ----
          } elseif ($type == 'article') {
              $comments = DB_count ($_TABLES['comments'], 'sid', $sid);
!             DB_change ($_TABLES['stories'], 'comments', $comments, 'sid', $sid);
!             COM_olderStuff (); // update comment count in Older Stories block
              $retval = COM_refresh (COM_buildUrl ($_CONF['site_url']
                      . "/article.php?story=$sid"));
***************
*** 467,471 ****
  function deletecomment ($cid, $sid, $type) 
  {
!     global $_CONF, $_TABLES, $_USER, $HTTP_SERVER_VARS;
  
      $retval = '';
--- 468,472 ----
  function deletecomment ($cid, $sid, $type) 
  {
!     global $_CONF, $_TABLES, $_USER;
  
      $retval = '';
***************
*** 517,521 ****
              } else {
                  COM_errorLog ('User ' . $_USER['username'] . ' (IP: '
!                         . $HTTP_SERVER_VARS['REMOTE_ADDR']
                          . ') tried to illegally delete comment '
                          . $cid . ' from ' . $type . ' ' . $sid);
--- 518,522 ----
              } else {
                  COM_errorLog ('User ' . $_USER['username'] . ' (IP: '
!                         . $_SERVER['REMOTE_ADDR']
                          . ') tried to illegally delete comment '
                          . $cid . ' from ' . $type . ' ' . $sid);
***************
*** 707,727 ****
  case $LANG03[14]: // Preview
      $display .= COM_siteHeader()
!         . commentform (COM_applyFilter ($HTTP_POST_VARS['uid'], true),
!             strip_tags ($HTTP_POST_VARS['title']), $HTTP_POST_VARS['comment'],
!             COM_applyFilter ($HTTP_POST_VARS['sid']),
!             COM_applyFilter ($HTTP_POST_VARS['pid'], true),
!             COM_applyFilter ($HTTP_POST_VARS['type']),
!             COM_applyFilter ($HTTP_POST_VARS['mode']),
!             COM_applyFilter ($HTTP_POST_VARS['postmode']))
          . COM_siteFooter(); 
      break;
  
  case $LANG03[11]: // Submit Comment
!     $display .= savecomment (COM_applyFilter ($HTTP_POST_VARS['uid'], true),
!             strip_tags ($HTTP_POST_VARS['title']), $HTTP_POST_VARS['comment'],
!             COM_applyFilter ($HTTP_POST_VARS['sid']),
!             COM_applyFilter ($HTTP_POST_VARS['pid'], true),
!             COM_applyFilter ($HTTP_POST_VARS['type']),
!             COM_applyFilter ($HTTP_POST_VARS['postmode']));
      break;
  
--- 708,727 ----
  case $LANG03[14]: // Preview
      $display .= COM_siteHeader()
!         . commentform (COM_applyFilter ($_POST['uid'], true),
!             strip_tags ($_POST['title']), $_POST['comment'],
!             COM_applyFilter ($_POST['sid']),
!             COM_applyFilter ($_POST['pid'], true),
!             COM_applyFilter ($_POST['type']), COM_applyFilter ($_POST['mode']),
!             COM_applyFilter ($_POST['postmode']))
          . COM_siteFooter(); 
      break;
  
  case $LANG03[11]: // Submit Comment
!     $display .= savecomment (COM_applyFilter ($_POST['uid'], true),
!             strip_tags ($_POST['title']), $_POST['comment'],
!             COM_applyFilter ($_POST['sid']),
!             COM_applyFilter ($_POST['pid'], true),
!             COM_applyFilter ($_POST['type']),
!             COM_applyFilter ($_POST['postmode']));
      break;
  
***************
*** 843,872 ****
  case 'report':
      $display = COM_siteHeader ('menu')
!              . report_abusive_comment (COM_applyFilter ($HTTP_GET_VARS['cid'],
!                     true), COM_applyFilter ($HTTP_GET_VARS['type']))
               . COM_siteFooter ();
      break;
  
  case 'sendreport':
!     $display = send_report (COM_applyFilter ($HTTP_POST_VARS['cid'], true),
!                             COM_applyFilter ($HTTP_POST_VARS['type']));
      break;
  
  default:
!     if (isset ($HTTP_POST_VARS['sid'])) {
!         $sid = COM_applyFilter ($HTTP_POST_VARS['sid']);
!         $type = COM_applyFilter ($HTTP_POST_VARS['type']);
!         $title = strip_tags ($HTTP_POST_VARS['title']);
!         $pid = COM_applyFilter ($HTTP_POST_VARS['pid'], true);
!         $mode = COM_applyFilter ($HTTP_POST_VARS['mode']);
!         $postmode = COM_applyFilter ($HTTP_POST_VARS['postmode']);
!     } else {
!         $sid = COM_applyFilter ($HTTP_GET_VARS['sid']);
!         $type = COM_applyFilter ($HTTP_GET_VARS['type']);
!         $title = strip_tags ($HTTP_GET_VARS['title']);
!         $pid = COM_applyFilter ($HTTP_GET_VARS['pid'], true);
!         $mode = COM_applyFilter ($HTTP_GET_VARS['mode']);
!         $postmode = COM_applyFilter ($HTTP_GET_VARS['postmode']);
!     }
      if (!empty ($sid)) {
          if (empty ($title)) {
--- 843,864 ----
  case 'report':
      $display = COM_siteHeader ('menu')
!              . report_abusive_comment (COM_applyFilter ($_GET['cid'], true),
!                                        COM_applyFilter ($_GET['type']))
               . COM_siteFooter ();
      break;
  
  case 'sendreport':
!     $display = send_report (COM_applyFilter ($_POST['cid'], true),
!                             COM_applyFilter ($_POST['type']));
      break;
  
  default:
!     $sid = COM_applyFilter ($_REQUEST['sid']);
!     $type = COM_applyFilter ($_REQUEST['type']);
!     $title = strip_tags ($_REQUEST['title']);
!     $pid = COM_applyFilter ($_REQUEST['pid'], true);
!     $mode = COM_applyFilter ($_REQUEST['mode']);
!     $postmode = COM_applyFilter ($_REQUEST['postmode']);
! 
      if (!empty ($sid)) {
          if (empty ($title)) {
***************
*** 890,906 ****
      } else {
          // This could still be a plugin wanting comments
!         if (isset ($HTTP_POST_VARS['cid'])) {
!             $cid = COM_applyFilter ($HTTP_POST_VARS['cid']);
!             $format = COM_applyFilter ($HTTP_POST_VARS['format']);
!             $order = COM_applyFilter ($HTTP_POST_VARS['order']);
!             $reply = COM_applyFilter ($HTTP_POST_VARS['reply']);
!             $type = COM_applyFilter ($HTTP_POST_VARS['type']);
!         } else {
!             $cid = COM_applyFilter ($HTTP_GET_VARS['cid']);
!             $format = COM_applyFilter ($HTTP_GET_VARS['format']);
!             $order = COM_applyFilter ($HTTP_GET_VARS['order']);
!             $reply = COM_applyFilter ($HTTP_GET_VARS['reply']);
!             $type = COM_applyFilter ($HTTP_GET_VARS['type']);
!         }
          if (!empty ($type) && !empty ($cid)) {
              $display .= PLG_callCommentForm ($type, $cid, $format, $order, $reply);
--- 882,891 ----
      } else {
          // This could still be a plugin wanting comments
!         $cid = COM_applyFilter ($_REQUEST['cid'], true);
!         $format = COM_applyFilter ($_REQUEST['format']);
!         $order = COM_applyFilter ($_REQUEST['order']);
!         $reply = COM_applyFilter ($_REQUEST['reply']);
!         $type = COM_applyFilter ($_REQUEST['type']);
! 
          if (!empty ($type) && !empty ($cid)) {
              $display .= PLG_callCommentForm ($type, $cid, $format, $order, $reply);

Index: lib-common.php
===================================================================
RCS file: /var/cvs/geeklog-1.3/public_html/lib-common.php,v
retrieving revision 1.402
retrieving revision 1.403
diff -C2 -d -r1.402 -r1.403
*** lib-common.php	11 Dec 2004 22:07:07 -0000	1.402
--- lib-common.php	16 Dec 2004 11:09:52 -0000	1.403
***************
*** 3520,3524 ****
      global $_TABLES, $_CONF;
  
!     $sql = "SELECT sid,tid,title,comments,unix_timestamp(date) AS day FROM {$_TABLES['stories']} WHERE (perm_anon = 2) AND (date <= NOW()) AND (draft_flag = 0) ORDER BY featured DESC, date DESC LIMIT {$_CONF['limitnews']}, {$_CONF['limitnews']}";
      $result = DB_query( $sql );
      $nrows = DB_numRows( $result );
--- 3520,3524 ----
      global $_TABLES, $_CONF;
  
!     $sql = "SELECT sid,tid,title,comments,UNIX_TIMESTAMP(date) AS day FROM {$_TABLES['stories']} WHERE (perm_anon = 2) AND (date <= NOW()) AND (draft_flag = 0)" . COM_getTopicSQL( 'AND', 1 ) . " ORDER BY featured DESC, date DESC LIMIT {$_CONF['limitnews']}, {$_CONF['limitnews']}";
      $result = DB_query( $sql );
      $nrows = DB_numRows( $result );
***************
*** 3538,3567 ****
          {
              $A = DB_fetchArray( $result );
-             $topic_anon = DB_getItem( $_TABLES['topics'], 'perm_anon', "tid='{$A['tid']}'" );
  
!             if( $topic_anon == 2 )
              {
!                 $daycheck = strftime( '%A', $A['day'] );
!                 if( $day != $daycheck )
                  {
!                     if( $day != 'noday' )
!                     {
!                         $daylist = COM_makeList( $oldnews, 'list-older-stories' );
!                         $daylist = preg_replace( "/(\015\012)|(\015)|(\012)/",
!                                                  '', $daylist );
!                         $string .= $daylist . '<br>';
!                     }
! 
!                     $day2 = strftime( $dateonly, $A['day'] );
!                     $string .= '<b>' . $daycheck . '</b> <small>' . $day2
!                             . '</small>' . LB;
!                     $oldnews = array();
!                     $day = $daycheck;
                  }
  
!                 $oldnews[] = '<a href="' . COM_buildUrl( $_CONF['site_url']
!                     . '/article.php?story=' . $A['sid'] ) . '">' . $A['title']
!                     . '</a> (' . $A['comments'] . ')';
              }
          }
  
--- 3538,3563 ----
          {
              $A = DB_fetchArray( $result );
  
!             $daycheck = strftime( '%A', $A['day'] );
!             if( $day != $daycheck )
              {
!                 if( $day != 'noday' )
                  {
!                     $daylist = COM_makeList( $oldnews, 'list-older-stories' );
!                     $daylist = preg_replace( "/(\015\012)|(\015)|(\012)/",
!                                              '', $daylist );
!                     $string .= $daylist . '<br>';
                  }
  
!                 $day2 = strftime( $dateonly, $A['day'] );
!                 $string .= '<b>' . $daycheck . '</b> <small>' . $day2
!                         . '</small>' . LB;
!                 $oldnews = array();
!                 $day = $daycheck;
              }
+ 
+             $oldnews[] = '<a href="' . COM_buildUrl( $_CONF['site_url']
+                 . '/article.php?story=' . $A['sid'] ) . '">' . $A['title']
+                 . '</a> (' . $A['comments'] . ')';
          }
  




More information about the geeklog-cvs mailing list