[geeklog-cvs] geeklog-1.3/public_html index.php,1.40,1.40.2.1

geeklog-cvs-admin at lists.geeklog.net geeklog-cvs-admin at lists.geeklog.net
Thu May 15 11:41:10 EDT 2003


Update of /usr/cvs/geeklog/geeklog-1.3/public_html
In directory internal.geeklog.net:/tmp/cvs-serv4336

Modified Files:
      Tag: geeklog_1_3_7sr1_1
	index.php 
Log Message:
Fixes for 1) topic permissions, 2) google paging, 3) right blocks on empty topics


Index: index.php
===================================================================
RCS file: /usr/cvs/geeklog/geeklog-1.3/public_html/index.php,v
retrieving revision 1.40
retrieving revision 1.40.2.1
diff -C2 -d -r1.40 -r1.40.2.1
*** index.php	31 Dec 2002 10:58:55 -0000	1.40
--- index.php	15 May 2003 15:41:07 -0000	1.40.2.1
***************
*** 169,173 ****
  COM_featuredCheck();
  
! $sql = "SELECT *,unix_timestamp(date) AS day FROM {$_TABLES['stories']} WHERE (date <= NOW()) AND (draft_flag = 0)";
  
  // if a topic was provided only select those stories.
--- 169,173 ----
  COM_featuredCheck();
  
! $sql = "FROM {$_TABLES['stories']} WHERE (date <= NOW()) AND (draft_flag = 0)";
  
  // if a topic was provided only select those stories.
***************
*** 178,193 ****
  }
  
! $sql .= " AND (";
  if (!empty ($_USER['uid'])) {
!     $groupList = '';
!     foreach ($_GROUPS as $grp) {
!         $groupList .= $grp . ',';
!     }
!     $groupList = substr ($groupList, 0, -1);
!     $sql .= "(owner_id = {$_USER['uid']} AND perm_owner >= 2) OR ";
!     $sql .= "(group_id IN ($groupList) AND perm_group >= 2) OR ";
!     $sql .= "(perm_members >= 2) OR ";
  }
! $sql .= "(perm_anon >= 2))";
  
  if (!empty($U['aids'])) {
--- 178,191 ----
  }
  
! $groupsql = " (";
  if (!empty ($_USER['uid'])) {
!     $groupsql .= "(owner_id = {$_USER['uid']} AND perm_owner >= 2) OR ";
!     $groupsql .= "(group_id IN (" . implode (',', $_GROUPS) . ") AND perm_group >= 2) OR ";
!     $groupsql .= "(perm_members >= 2)) ";
! } else {
!     $groupsql .= "perm_anon >= 2) ";
  }
! 
! $sql .= " AND" . $groupsql;
  
  if (!empty($U['aids'])) {
***************
*** 205,239 ****
  }
  
! if ($newstories) {
!     $sql .= "AND (date >= (NOW() - INTERVAL {$_CONF['newstoriesinterval']} SECOND))";
  }
  
! $offset = ($page - 1) * $limit;
! $sql .= "ORDER BY featured DESC, date DESC LIMIT $offset, $limit";
! 
! $result = DB_query($sql);
! $nrows = DB_numRows($result);
  
! $countsql = "SELECT count(*) AS count FROM {$_TABLES['stories']} WHERE (date <= NOW()) AND (draft_flag = 0)";
! if (!empty($topic)) {
!     $countsql = $countsql . " AND tid='$topic'";
! } elseif (!$newstories) {
!     $countsql = $countsql . ' AND frontpage = 1';
  }
  
! $countsql .= " AND (";
! if (!empty ($_USER['uid'])) {
!     // Note: $groupList re-used from above
!     $countsql .= "(owner_id = {$_USER['uid']} AND perm_owner >= 2) OR ";
!     $countsql .= "(group_id IN ($groupList) AND perm_group >= 2) OR ";
!     $countsql .= "(perm_members >= 2) OR ";
! }
! $countsql .= "(perm_anon >= 2))";
  
! if ($newstories) {
!     $countsql .= " AND (date >= (NOW() - INTERVAL {$_CONF['newstoriesinterval']} SECOND))";
! }
  
! $data = DB_query($countsql);
  $D = DB_fetchArray($data);
  $num_pages = ceil($D['count'] / $limit);
--- 203,234 ----
  }
  
! $tresult = DB_query ("SELECT tid FROM {$_TABLES['topics']} WHERE" . $groupsql);
! $trows = DB_numRows ($tresult);
! $topicsql = '';
! 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) . "')) ";
!     }
  }
  
! $sql .= $topicsql;
  
! if ($newstories) {
!     $sql .= "AND (date >= (NOW() - INTERVAL {$_CONF['newstoriesinterval']} SECOND)) ";
  }
  
! $offset = ($page - 1) * $limit;
! $sql .= "ORDER BY featured DESC, date DESC";
  
! $result = DB_query ("SELECT *,unix_timestamp(date) AS day " . $sql
!         . " LIMIT $offset, $limit");
! $nrows = DB_numRows($result);
  
! $data = DB_query("SELECT count(*) AS count " . $sql);
  $D = DB_fetchArray($data);
  $num_pages = ceil($D['count'] / $limit);
***************
*** 242,256 ****
      for ($x = 1; $x <= $nrows; $x++) {
          $A = DB_fetchArray($result);
!         if (SEC_hasAccess($A['owner_id'],$A['group_id'],$A['perm_owner'],$A['perm_group'],$A['perm_members'],$A['perm_anon']) > 0) {
!             if ($A['featured'] == 1) {
!                 $feature = 'true';
!             } elseif (($x == 1) && ($_CONF['showfirstasfeatured'] == 1)) {
!                 $feature = 'true';
!                 $A['featured'] = 1;
!             }
!             $display .= COM_article($A,'y');
          }
      }
!     
      // Print Google-like paging navigation
      if (empty($topic)) {
--- 237,249 ----
      for ($x = 1; $x <= $nrows; $x++) {
          $A = DB_fetchArray($result);
!         if ($A['featured'] == 1) {
!             $feature = 'true';
!         } elseif (($x == 1) && ($_CONF['showfirstasfeatured'] == 1)) {
!             $feature = 'true';
!             $A['featured'] = 1;
          }
+         $display .= COM_article($A,'y');
      }
! 
      // Print Google-like paging navigation
      if (empty($topic)) {
***************
*** 266,275 ****
      $display .= COM_startBlock($LANG05[1]) . $LANG05[2];
      if (!empty($topic)) {
!         $result = DB_query ("SELECT topic FROM {$_TABLES['topics']} WHERE tid='$topic'");
!         $A = DB_fetchArray ($result);
!         if (!empty ($A['topic'])) {
!             $topic = $A['topic'];
!         }
!         $display .= $LANG05[3];
      }
      $display .= COM_endBlock();
--- 259,264 ----
      $display .= COM_startBlock($LANG05[1]) . $LANG05[2];
      if (!empty($topic)) {
!         $topicname = DB_getItem ($_TABLES['topics'], 'topic', "tid='{$topic}'");
!         $display .= sprintf ($LANG05[3], $topicname);
      }
      $display .= COM_endBlock();





More information about the geeklog-cvs mailing list