[ Index ]
 

Code source de GeekLog 1.4.1

Accédez au Source d'autres logiciels libres

title

Body

[fermer]

/public_html/ -> stats.php (source)

   1  <?php
   2  
   3  /* Reminder: always indent with 4 spaces (no tabs). */
   4  // +---------------------------------------------------------------------------+
   5  // | Geeklog 1.4                                                               |
   6  // +---------------------------------------------------------------------------+
   7  // | stats.php                                                                 |
   8  // |                                                                           |
   9  // | Geeklog system statistics page.                                           |
  10  // +---------------------------------------------------------------------------+
  11  // | Copyright (C) 2000-2005 by the following authors:                         |
  12  // |                                                                           |
  13  // | Authors: Tony Bibbs        - tony AT tonybibbs DOT com                    |
  14  // |          Mark Limburg      - mlimburg AT users DOT sourceforge DOT net    |
  15  // |          Jason Whittenburg - jwhitten AT securitygeeks DOT com            |
  16  // |          Dirk Haun         - dirk AT haun-online DOT 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: stats.php,v 1.49 2006/10/11 20:08:41 dhaun Exp $
  36  
  37  require_once ('lib-common.php');
  38  require_once( $_CONF['path_system'] . 'lib-admin.php' );
  39  
  40  $display = '';
  41  
  42  if (empty ($_USER['username']) &&
  43      (($_CONF['loginrequired'] == 1) || ($_CONF['statsloginrequired'] == 1))) {
  44      $display = COM_siteHeader ('menu', $LANG_LOGIN[1]);
  45      $display .= COM_startBlock ($LANG_LOGIN[1], '',
  46                                  COM_getBlockTemplate ('_msg_block', 'header'));
  47      $login = new Template($_CONF['path_layout'] . 'submit');
  48      $login->set_file (array ('login'=>'submitloginrequired.thtml'));
  49      $login->set_var ('login_message', $LANG_LOGIN[2]);
  50      $login->set_var ('site_url', $_CONF['site_url']);
  51      $login->set_var ('lang_login', $LANG_LOGIN[3]);
  52      $login->set_var ('lang_newuser', $LANG_LOGIN[4]);
  53      $login->parse ('output', 'login');
  54      $display .= $login->finish ($login->get_var('output'));
  55      $display .= COM_endBlock (COM_getBlockTemplate ('_msg_block', 'footer'));
  56      $display .= COM_siteFooter();
  57      echo $display; 
  58      exit;
  59  }
  60  
  61  // MAIN
  62  
  63  $display .= COM_siteHeader ('menu', $LANG10[1]);
  64  
  65  // Overall Site Statistics
  66  
  67  $header_arr = array(
  68      array('text' => $LANG10[1], 'field' => 'title', 'width' => '90%', 'header_class' => 'stats-header-title'),
  69      array('text' => "", 'field' => 'stats', 'width' => '10%', 'header_class' => 'stats-header-count', 'field_class' => 'stats-list-count'),
  70  );
  71  $data_arr = array();
  72  $text_arr = array('has_menu'     =>  false,
  73                    'title'        => $LANG10[1],
  74  );
  75  
  76  $totalhits = DB_getItem ($_TABLES['vars'], 'value', "name = 'totalhits'");
  77  $data_arr[] = array('title' => $LANG10[2], 'stats' => COM_NumberFormat ($totalhits));
  78  
  79  if ($_CONF['lastlogin']) {
  80      // if we keep track of the last login date, count the number of users
  81      // that have logged in during the last 4 weeks
  82      $result = DB_query ("SELECT COUNT(*) AS count FROM {$_TABLES['users']} AS u,{$_TABLES['userinfo']} AS i WHERE (u.uid > 1) AND (u.uid = i.uid) AND (lastlogin <> '') AND (lastlogin >= UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 28 DAY)))");
  83      list($active_users) = DB_fetchArray ($result);
  84  } else {
  85      // otherwise, just count all users with status 'active'
  86      // (i.e. those that logged in at least once and have not been banned since)
  87      $active_users = DB_count ($_TABLES['users'], 'status', 3);
  88      $active_users--; // don't count the anonymous user account
  89  }
  90  $data_arr[] = array('title' => $LANG10[27], 'stats' => COM_NumberFormat ($active_users));
  91  
  92  $topicsql = COM_getTopicSql ('AND');
  93  
  94  $id = array ('draft_flag', 'date');
  95  $values = array ('0', 'NOW()');    
  96  $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);
  97  $A = DB_fetchArray ($result);
  98  if (empty ($A['ccount'])) {
  99      $A['ccount'] = 0;
 100  }
 101  $data_arr[] = array('title' => $LANG10[3],
 102                      'stats' => COM_NumberFormat ($A['count'])
 103                             . " (". COM_NumberFormat ($A['ccount']) . ")");
 104  
 105  // new stats plugin API call
 106  $plg_stats = PLG_getPluginStats (3);
 107  if (count ($plg_stats) > 0) {
 108      foreach ($plg_stats as $pstats) {
 109          if (is_array ($pstats[0])) {
 110              foreach ($pstats as $pmstats) {
 111                  $data_arr[] = array('title' => $pmstats[0], 'stats' => $pmstats[1]);
 112              }
 113          } else {
 114              $data_arr[] = array('title' => $pstats[0], 'stats' => $pstats[1]);
 115          }
 116      }
 117  }
 118  
 119  $display .= ADMIN_simpleList("", $header_arr, $text_arr, $data_arr);
 120  
 121  // old stats plugin API call, for backward compatibilty
 122  $display .= PLG_getPluginStats (1);
 123  
 124  // Detailed story statistics
 125  
 126  $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");
 127  $nrows  = DB_numRows($result);
 128  
 129  if ($nrows > 0) {
 130      $header_arr = array(
 131          array('text' => $LANG10[8], 'field' => 'sid', 'header_class' => 'stats-header-title'),
 132          array('text' => $LANG10[9], 'field' => 'hits', 'header_class' => 'stats-header-count', 'field_class' => 'stats-list-count'),
 133      );
 134      $data_arr = array();
 135      $text_arr = array('has_menu'     =>  false,
 136                        'title'        => $LANG10[7],
 137      );
 138  
 139      for ($i = 0; $i < $nrows; $i++) {
 140          $A = DB_fetchArray($result);
 141          $A['title'] = stripslashes(str_replace('$','&#36;',$A['title']));
 142          $A['sid'] = "<a href=\"" . COM_buildUrl ($_CONF['site_url']
 143                    . "/article.php?story={$A['sid']}"). "\">{$A['title']}</a>";
 144          $A['hits'] = COM_NumberFormat ($A['hits']);
 145          $data_arr[$i] = $A;
 146  
 147      }
 148      $display .= ADMIN_simpleList("", $header_arr, $text_arr, $data_arr);
 149  } else {
 150      $display .= COM_startBlock($LANG10[7]);
 151      $display .= $LANG10[10];
 152      $display .= COM_endBlock();
 153  }
 154  
 155  // Top Ten Commented Stories
 156  
 157  $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");
 158  $nrows  = DB_numRows($result);
 159  if ($nrows > 0) {
 160      $header_arr = array(
 161          array('text' => $LANG10[8], 'field' => 'sid', 'header_class' => 'stats-header-title'),
 162          array('text' => $LANG10[12], 'field' => 'comments', 'header_class' => 'stats-header-count', 'field_class' => 'stats-list-count'),
 163      );
 164      $data_arr = array();
 165      $text_arr = array('has_menu'     =>  false,
 166                        'title'        => $LANG10[11],
 167      );
 168      for ($i = 0; $i < $nrows; $i++) {
 169          $A = DB_fetchArray($result);    
 170          $A['title'] = stripslashes(str_replace('$','&#36;',$A['title']));
 171          $A['sid'] = "<a href=\"" . COM_buildUrl ($_CONF['site_url']
 172                    . "/article.php?story={$A['sid']}"). "\">{$A['title']}</a>";
 173          $A['comments'] = COM_NumberFormat ($A['comments']);
 174          $data_arr[$i] = $A;
 175      }
 176      $display .= ADMIN_simpleList("", $header_arr, $text_arr, $data_arr);
 177  
 178  } else {
 179      $display .= COM_startBlock($LANG10[11]);
 180      $display .= $LANG10[13];
 181      $display .= COM_endBlock();
 182  }
 183  
 184  // Top Ten Trackback Comments
 185  
 186  if ($_CONF['trackback_enabled'] || $_CONF['pingback_enabled']) {
 187      $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,{$_TABLES['stories']}.sid,{$_TABLES['stories']}.title ORDER BY count DESC LIMIT 10");
 188      $nrows = DB_numRows ($result);
 189      if ($nrows > 0) {
 190          $header_arr = array(
 191              array('text' => $LANG10[8], 'field' => 'sid', 'header_class' => 'stats-header-title'),
 192              array('text' => $LANG10[12], 'field' => 'count', 'header_class' => 'stats-header-count', 'field_class' => 'stats-list-count'),
 193          );
 194          $data_arr = array();
 195          $text_arr = array('has_menu'     =>  false,
 196                            'title'        => $LANG10[25],
 197          );
 198          for ($i = 0; $i < $nrows; $i++) {
 199              $A = DB_fetchArray ($result);
 200              $A['title'] = stripslashes(str_replace('$','&#36;',$A['title']));
 201              $A['sid'] = "<a href=\"" . COM_buildUrl ($_CONF['site_url']
 202                        . "/article.php?story={$A['sid']}"). "\">{$A['title']}</a>";
 203              $A['count'] = COM_NumberFormat ($A['count']);
 204              $data_arr[$i] = $A;
 205          }
 206          $display .= ADMIN_simpleList("", $header_arr, $text_arr, $data_arr);
 207  
 208      } else {
 209          $display .= COM_startBlock ($LANG10[25]);
 210          $display .= $LANG10[26];
 211          $display .= COM_endBlock ();
 212      }
 213  }
 214  
 215  // Top Ten Emailed Stories
 216  
 217  $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");
 218  $nrows = DB_numRows($result);
 219  
 220  if ($nrows > 0) {
 221      $header_arr = array(
 222          array('text' => $LANG10[8], 'field' => 'sid', 'header_class' => 'stats-header-title'),
 223          array('text' => $LANG10[23], 'field' => 'numemails', 'header_class' => 'stats-header-count', 'field_class' => 'stats-list-count'),
 224      );
 225      $data_arr = array();
 226      $text_arr = array('has_menu'     =>  false,
 227                        'title'        => $LANG10[22],
 228      );
 229      for ($i = 0; $i < $nrows; $i++) {
 230          $A = DB_fetchArray($result);
 231          $A['title'] = stripslashes(str_replace('$','&#36;',$A['title']));
 232          $A['sid'] = "<a href=\"" . COM_buildUrl ($_CONF['site_url']
 233                    . "/article.php?story={$A['sid']}"). "\">{$A['title']}</a>";
 234          $A['numemails'] = COM_NumberFormat ($A['numemails']);
 235          $data_arr[$i] = $A;
 236  
 237      }
 238      $display .= ADMIN_simpleList("", $header_arr, $text_arr, $data_arr);
 239  } else {
 240      $display .= COM_startBlock($LANG10[22]);
 241      $display .= $LANG10[24];
 242      $display .= COM_endBlock();
 243  }
 244  
 245  // Now show stats for any plugins that want to be included
 246  $display .= PLG_getPluginStats(2);
 247  $display .= COM_siteFooter();
 248  
 249  echo $display;
 250  
 251  ?>


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