[ Index ]
 

Code source de GeekLog 1.4.1

Accédez au Source d'autres logiciels libres

title

Body

[fermer]

/public_html/ -> index.php (source)

   1  <?php
   2  
   3  /* Reminder: always indent with 4 spaces (no tabs). */
   4  // +---------------------------------------------------------------------------+
   5  // | Geeklog 1.4                                                               |
   6  // +---------------------------------------------------------------------------+
   7  // | index.php                                                                 |
   8  // |                                                                           |
   9  // | Geeklog homepage.                                                         |
  10  // +---------------------------------------------------------------------------+
  11  // | Copyright (C) 2000-2006 by the following authors:                         |
  12  // |                                                                           |
  13  // | Authors: Tony Bibbs        - tony@tonybibbs.com                           |
  14  // |          Mark Limburg      - mlimburg@users.sourceforge.net               |
  15  // |          Jason Whittenburg - jwhitten@securitygeeks.com                   |
  16  // |          Dirk Haun         - dirk@haun-online.de                          |
  17  // +---------------------------------------------------------------------------+
  18  // |                                                                           |
  19  // | This program is free software; you can redistribute it and/or             |
  20  // | modify it under the terms of the GNU General Public License               |
  21  // | as published by the Free Software Foundation; either version 2            |
  22  // | of the License, or (at your option) any later version.                    |
  23  // |                                                                           |
  24  // | This program is distributed in the hope that it will be useful,           |
  25  // | but WITHOUT ANY WARRANTY; without even the implied warranty of            |
  26  // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             |
  27  // | GNU General Public License for more details.                              |
  28  // |                                                                           |
  29  // | You should have received a copy of the GNU General Public License         |
  30  // | along with this program; if not, write to the Free Software Foundation,   |
  31  // | Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.           |
  32  // |                                                                           |
  33  // +---------------------------------------------------------------------------+
  34  //
  35  // $Id: index.php,v 1.89 2006/12/10 12:08:39 dhaun Exp $
  36  
  37  require_once  ('lib-common.php');
  38  require_once ($_CONF['path_system'] . 'lib-story.php');
  39  
  40  $newstories = false;
  41  $displayall = false;
  42  if (isset ($_GET['display']) && empty ($topic)) {
  43      if ($_GET['display'] == 'new') {
  44          $newstories = true;
  45      } else if ($_GET['display'] == 'all') {
  46          $displayall = true;
  47      }
  48  }
  49  
  50  $page = 1;
  51  if (isset ($_GET['page'])) {
  52      $page = COM_applyFilter ($_GET['page'], true);
  53      if ($page == 0) {
  54          $page = 1;
  55      }
  56  }
  57  
  58  $display = '';
  59  
  60  if (!$newstories && !$displayall) {
  61      // give plugins a chance to replace this page entirely
  62      $newcontent = PLG_showCenterblock (0, $page, $topic);
  63      if (!empty ($newcontent)) {
  64          echo $newcontent;
  65          exit;
  66      }
  67  }
  68  
  69  $display .= COM_siteHeader();
  70  if (isset ($_GET['msg'])) {
  71      $plugin = '';
  72      if (isset ($_GET['plugin'])) {
  73          $plugin = COM_applyFilter ($_GET['plugin']);
  74      }
  75      $display .= COM_showMessage (COM_applyFilter ($_GET['msg'], true), $plugin);
  76  }
  77  
  78  
  79  // Show any Plugin formatted blocks
  80  // Requires a plugin to have a function called plugin_centerblock_<plugin_name>
  81  $displayBlock = PLG_showCenterblock (1, $page, $topic); // top blocks
  82  if (!empty ($displayBlock)) {
  83      $display .= $displayBlock;
  84      // Check if theme has added the template which allows the centerblock
  85      // to span the top over the rightblocks
  86      if (file_exists($_CONF['path_layout'] . 'topcenterblock-span.thtml')) {
  87              $topspan = new Template($_CONF['path_layout']);
  88              $topspan->set_file (array ('topspan'=>'topcenterblock-span.thtml'));
  89              $topspan->parse ('output', 'topspan');
  90              $display .= $topspan->finish ($topspan->get_var('output'));
  91              $GLOBALS['centerspan'] = true;
  92      }
  93  }
  94  
  95  if (isset ($_USER['uid']) && ($_USER['uid'] > 1)) {
  96      $result = DB_query("SELECT maxstories,tids,aids FROM {$_TABLES['userindex']} WHERE uid = '{$_USER['uid']}'");
  97      $U = DB_fetchArray($result);
  98  } else {
  99      $U['maxstories'] = 0;
 100  }
 101  
 102  $maxstories = 0;
 103  if ($U['maxstories'] >= $_CONF['minnews']) {
 104      $maxstories = $U['maxstories'];
 105  }
 106  if ((!empty ($topic)) && ($maxstories == 0)) {
 107      $topiclimit = DB_getItem ($_TABLES['topics'], 'limitnews',
 108                                "tid = '{$topic}'");
 109      if ($topiclimit >= $_CONF['minnews']) {
 110          $maxstories = $topiclimit;
 111      }
 112  }
 113  if ($maxstories == 0) {
 114      $maxstories = $_CONF['limitnews'];
 115  }
 116  
 117  $limit = $maxstories;
 118  
 119  // Geeklog now allows for articles to be published in the future.  Because of
 120  // this, we need to check to see if we need to rebuild the RDF file in the case
 121  // that any such articles have now been published
 122  COM_rdfUpToDateCheck();
 123  
 124  // For similar reasons, we need to see if there are currently two featured
 125  // articles.  Can only have one but you can have one current featured article
 126  // and one for the future...this check will set the latest one as featured
 127  // solely
 128  COM_featuredCheck();
 129  
 130  // Retrieve the archive topic - currently only one supported
 131  $archivetid = DB_getItem ($_TABLES['topics'], 'tid', "archive_flag=1");
 132  
 133  // Scan for any stories that have expired and should be archived or deleted
 134  $asql = "SELECT sid,tid,title,expire,statuscode FROM {$_TABLES['stories']} ";
 135  $asql .= 'WHERE (expire <= NOW()) AND (statuscode = ' . STORY_DELETE_ON_EXPIRE;
 136  if (empty ($archivetid)) {
 137      $asql .= ')';
 138  } else {
 139      $asql .= ' OR statuscode = ' . STORY_ARCHIVE_ON_EXPIRE . ") AND tid != '$archivetid'";
 140  }
 141  $expiresql = DB_query ($asql);
 142  while (list ($sid, $expiretopic, $title, $expire, $statuscode) = DB_fetchArray ($expiresql)) {
 143      if ($statuscode == STORY_ARCHIVE_ON_EXPIRE) {
 144          if (!empty ($archivetid) ) {
 145              COM_errorLOG("Archive Story: $sid, Topic: $archivetid, Title: $title, Expired: $expire");
 146              DB_query ("UPDATE {$_TABLES['stories']} SET tid = '$archivetid', frontpage = '0', featured = '0' WHERE sid='{$sid}'");
 147          }
 148      } else if ($statuscode == STORY_DELETE_ON_EXPIRE) {
 149          COM_errorLOG("Delete Story and comments: $sid, Topic: $expiretopic, Title: $title, Expired: $expire");
 150          STORY_deleteImages ($sid);
 151          DB_query("DELETE FROM {$_TABLES['comments']} WHERE sid='{$sid}' AND type = 'article'");
 152          DB_query("DELETE FROM {$_TABLES['stories']} WHERE sid='{$sid}'");
 153      }
 154  }
 155  
 156  $sql = " (date <= NOW()) AND (draft_flag = 0)";
 157  
 158  if (empty ($topic)) {
 159      $sql .= COM_getLangSQL ('tid', 'AND', 's');
 160  }
 161  
 162  // if a topic was provided only select those stories.
 163  if (!empty($topic)) {
 164      $sql .= " AND s.tid = '$topic' ";
 165  } elseif (!$newstories) {
 166      $sql .= " AND frontpage = 1 ";
 167  }
 168  
 169  if ($topic != $archivetid) {
 170      $sql .= " AND s.tid != '{$archivetid}' ";
 171  }
 172  
 173  $sql .= COM_getPermSQL ('AND', 0, 2, 's');
 174  
 175  if (!empty($U['aids'])) {
 176      $sql .= " AND s.uid NOT IN (" . str_replace( ' ', ",", $U['aids'] ) . ") ";
 177  }
 178  
 179  if (!empty($U['tids'])) {
 180      $sql .= " AND s.tid NOT IN ('" . str_replace( ' ', "','", $U['tids'] ) . "') ";
 181  }
 182  
 183  $sql .= COM_getTopicSQL ('AND', 0, 's') . ' ';
 184  
 185  if ($newstories) {
 186      $sql .= "AND (date >= (date_sub(NOW(), INTERVAL {$_CONF['newstoriesinterval']} SECOND))) ";
 187  }
 188  
 189  $offset = ($page - 1) * $limit;
 190  $userfields = 'u.username, u.fullname';
 191  if ($_CONF['allow_user_photo'] == 1) {
 192      $userfields .= ', u.photo';
 193      if ($_CONF['use_gravatar']) {
 194          $userfields .= ', u.email';
 195      }
 196  }
 197  
 198  $msql = array();
 199  $msql['mysql']="SELECT STRAIGHT_JOIN s.*, UNIX_TIMESTAMP(s.date) AS day, "
 200           . $userfields . ", t.topic, t.imageurl "
 201           . "FROM {$_TABLES['stories']} AS s, {$_TABLES['users']} AS u, "
 202           . "{$_TABLES['topics']} AS t WHERE (s.uid = u.uid) AND (s.tid = t.tid) AND"
 203           . $sql . "ORDER BY featured DESC, date DESC LIMIT $offset, $limit";
 204  
 205  $msql['mssql']="SELECT STRAIGHT_JOIN s.sid, s.uid, s.draft_flag, s.tid, s.date, s.title, cast(s.introtext as text) as introtext, cast(s.bodytext as text) as bodytext, s.hits, s.numemails, s.comments, s.trackbacks, s.related, s.featured, s.show_topic_icon, s.commentcode, s.trackbackcode, s.statuscode, s.expire, s.postmode, s.frontpage, s.in_transit, s.owner_id, s.group_id, s.perm_owner, s.perm_group, s.perm_members, s.perm_anon, s.advanced_editor_mode, "
 206           . " UNIX_TIMESTAMP(s.date) AS day, "
 207           . $userfields . ", t.topic, t.imageurl "
 208           . "FROM {$_TABLES['stories']} AS s, {$_TABLES['users']} AS u, "
 209           . "{$_TABLES['topics']} AS t WHERE (s.uid = u.uid) AND (s.tid = t.tid) AND"
 210           . $sql . "ORDER BY featured DESC, date DESC LIMIT $offset, $limit";
 211           
 212  $result = DB_query ($msql);
 213  
 214  $nrows = DB_numRows ($result);
 215  
 216  $data = DB_query ("SELECT COUNT(*) AS count FROM {$_TABLES['stories']} AS s WHERE" . $sql);
 217  $D = DB_fetchArray ($data);
 218  $num_pages = ceil ($D['count'] / $limit);
 219  
 220  if ( $A = DB_fetchArray( $result ) ) {
 221  
 222      if ( $_CONF['showfirstasfeatured'] == 1 ) {
 223          $A['featured'] = 1;
 224      }
 225  
 226      // display first article
 227      $display .= STORY_renderArticle ($A, 'y');
 228  
 229      // get plugin center blocks after featured article
 230      if ($A['featured'] == 1) {
 231          $display .= PLG_showCenterblock (2, $page, $topic);
 232      }
 233  
 234      // get remaining stories
 235      while ($A = DB_fetchArray ($result)) {
 236          $display .= STORY_renderArticle ($A, 'y');
 237      }
 238  
 239      // get plugin center blocks that follow articles
 240      $display .= PLG_showCenterblock (3, $page, $topic); // bottom blocks
 241  
 242      // Print Google-like paging navigation
 243      if (!isset ($_CONF['hide_main_page_navigation']) ||
 244              ($_CONF['hide_main_page_navigation'] == 0)) {
 245          if (empty ($topic)) {
 246              $base_url = $_CONF['site_url'] . '/index.php';
 247              if ($newstories) {
 248                  $base_url .= '?display=new';
 249              }
 250          } else {
 251              $base_url = $_CONF['site_url'] . '/index.php?topic=' . $topic;
 252          }
 253          $display .= COM_printPageNavigation ($base_url, $page, $num_pages);
 254      }
 255  } else { // no stories to display
 256      if (!isset ($_CONF['hide_no_news_msg']) ||
 257              ($_CONF['hide_no_news_msg'] == 0)) {
 258          $display .= COM_startBlock ($LANG05[1], '',
 259                      COM_getBlockTemplate ('_msg_block', 'header')) . $LANG05[2];
 260          if (!empty ($topic)) {
 261              $topicname = DB_getItem ($_TABLES['topics'], 'topic',
 262                                       "tid = '$topic'");
 263              $display .= sprintf ($LANG05[3], $topicname);
 264          }
 265          $display .= COM_endBlock (COM_getBlockTemplate ('_msg_block', 'footer'));
 266      }
 267  
 268      $display .= PLG_showCenterblock (3, $page, $topic); // bottom blocks
 269  }
 270  
 271  $display .= COM_siteFooter (true); // The true value enables right hand blocks.
 272  
 273  // Output page 
 274  echo $display;
 275  
 276  ?>


Généré le : Wed Nov 21 12:27:40 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics