source: trunk/admin/stats.php @ 539

Last change on this file since 539 was 539, checked in by gweltas, 20 years ago
  • Change of the picture page behavior to be able to open the full size image in a new window
  • Minor modification for template migration
  • Rename of script.js in scripts.js
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.5 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// |                               stats.php                               |
4// +-----------------------------------------------------------------------+
5// | application   : PhpWebGallery <http://phpwebgallery.net>              |
6// | branch        : BSF (Best So Far)                                     |
7// +-----------------------------------------------------------------------+
8// | file          : $RCSfile$
9// | last update   : $Date: 2004-10-01 22:50:50 +0000 (Fri, 01 Oct 2004) $
10// | last modifier : $Author: gweltas $
11// | revision      : $Revision: 539 $
12// +-----------------------------------------------------------------------+
13// | This program is free software; you can redistribute it and/or modify  |
14// | it under the terms of the GNU General Public License as published by  |
15// | the Free Software Foundation                                          |
16// |                                                                       |
17// | This program is distributed in the hope that it will be useful, but   |
18// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
19// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
20// | General Public License for more details.                              |
21// |                                                                       |
22// | You should have received a copy of the GNU General Public License     |
23// | along with this program; if not, write to the Free Software           |
24// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
25// | USA.                                                                  |
26// +-----------------------------------------------------------------------+
27if( !defined("PHPWG_ROOT_PATH") )
28{
29        die ("Hacking attempt!");
30}
31include_once( PHPWG_ROOT_PATH.'admin/include/isadmin.inc.php' );
32
33$url_img_global_report = PHPWG_ROOT_PATH.'admin/images/global_stats.img.php';
34//----------------------------------------------------- template initialization
35$template->set_filenames( array('stats'=>'admin/stats.tpl') );
36
37$template->assign_vars(array(
38  'L_STAT_TITLE'=>$lang['stats_last_days'],
39  'L_STAT_MONTHLY_ALT'=>$lang['stats_pages_seen_graph_title'],
40  'IMG_MONTHLY_REPORT'=>add_session_id($url_img_global_report)
41  ));
42
43//---------------------------------------------------------------- log  history
44$days = array();
45$max_nb_visitors = 0;
46$max_pages_seen = 0;
47
48$starttime = mktime(  0, 0, 0,date('n'),date('j'),date('Y') );
49$endtime   = mktime( 23,59,59,date('n'),date('j'),date('Y') );
50//for ( $i = 0; $i <= MAX_DAYS; $i++ )
51{
52  /*$day = array();
53  $template->assign_block_vars('day',array(
54    ));
55 
56  // link to open the day to see details
57  $local_expand = $page['expand_days'];
58  if ( in_array( $i, $page['expand_days'] ) )
59  {
60    $vtp->addSession( $sub, 'expanded' );
61    $vtp->closeSession( $sub, 'expanded' );
62    $vtp->setVar( $sub, 'day.open_or_close', $lang['close'] );
63    $local_expand = array_remove( $local_expand, $i );
64  }
65  else
66  {
67    $vtp->addSession( $sub, 'collapsed' );
68    $vtp->closeSession( $sub, 'collapsed' );
69    $vtp->setVar( $sub, 'day.open_or_close', $lang['open'] );
70    array_push( $local_expand, $i );
71  }
72  $url = './admin.php?page=stats';
73  if (isset($_GET['last_days']))
74        $url.= '&amp;last_days='.$_GET['last_days'];
75  $url.= '&amp;expand='.implode( ',', $local_expand );
76  $vtp->setVar( $sub, 'day.url', add_session_id( $url ) );
77  // date displayed like this (in English ) :
78  //                     Sunday 15 June 2003
79  $date = $lang['day'][date( 'w', $starttime )];   // Sunday
80  $date.= date( ' j ', $starttime );               // 15
81  $date.= $lang['month'][date( 'n', $starttime )]; // June
82  $date.= date( ' Y', $starttime );                // 2003
83  $day['date'] = $date;
84  $vtp->setVar( $sub, 'day.name', $date );
85  // number of visitors for this day
86  $query = 'SELECT DISTINCT(IP) as nb_visitors';
87  $query.= ' FROM '.PREFIX_TABLE.'history';
88  $query.= ' WHERE date > '.$starttime;
89  $query.= ' AND date < '.$endtime;
90  $query.= ';';
91  $result = mysql_query( $query );
92  $nb_visitors = mysql_num_rows( $result );
93  $day['nb_visitors'] = $nb_visitors;
94  if ( $nb_visitors > $max_nb_visitors ) $max_nb_visitors = $nb_visitors;
95  $vtp->setVar( $sub, 'day.nb_visitors', $nb_visitors );
96  // log lines for this day
97  $query = 'SELECT date,login,IP,category,file,picture';
98  $query.= ' FROM '.PREFIX_TABLE.'history';
99  $query.= ' WHERE date > '.$starttime;
100  $query.= ' AND date < '.$endtime;
101  $query.= ' ORDER BY date DESC';
102  $query.= ';';
103  $result = mysql_query( $query );
104  $nb_pages_seen = mysql_num_rows( $result );
105  $day['nb_pages_seen'] = $nb_pages_seen;
106  if ( $nb_pages_seen > $max_pages_seen ) $max_pages_seen = $nb_pages_seen;
107  $vtp->setVar( $sub, 'day.nb_pages', $nb_pages_seen );
108  if ( in_array( $i, $page['expand_days'] ) )
109  {
110    while ( $row = mysql_fetch_array( $result ) )
111    {
112      $vtp->addSession( $sub, 'line' );
113      $vtp->setVar( $sub, 'line.date', date( 'G:i:s', $row['date'] ) );
114      $vtp->setVar( $sub, 'line.login', $row['login'] );
115      $vtp->setVar( $sub, 'line.IP', $row['IP'] );
116      $vtp->setVar( $sub, 'line.category', $row['category'] );
117      $vtp->setVar( $sub, 'line.file', $row['file'] );
118      $vtp->setVar( $sub, 'line.picture', $row['picture'] );
119      $vtp->closeSession( $sub, 'line' );
120    }
121  }
122  $starttime-= 24*60*60;
123  $endtime  -= 24*60*60;
124  $vtp->closeSession( $sub, 'day' );
125  array_push( $days, $day );*/
126}
127//------------------------------------------------------------ pages seen graph
128foreach ( $days as $day ) {
129  /*$vtp->addSession( $sub, 'pages_day' );
130  if ( $max_pages_seen > 0 )
131    $width = floor( ( $day['nb_pages_seen']*$max_pixels ) / $max_pages_seen );
132  else $width = 0;
133  $vtp->setVar( $sub, 'pages_day.date', $day['date'] );
134  $vtp->setVar( $sub, 'pages_day.width', $width );
135  $vtp->setVar( $sub, 'pages_day.nb_pages', $day['nb_pages_seen'] );
136  $vtp->closeSession( $sub, 'pages_day' );*/
137}
138//-------------------------------------------------------------- visitors grpah
139foreach ( $days as $day ) {
140  /*$vtp->addSession( $sub, 'visitors_day' );
141  if ( $max_nb_visitors > 0 )
142    $width = floor( ( $day['nb_visitors'] * $max_pixels ) / $max_nb_visitors );
143  else $width = 0;
144  $vtp->setVar( $sub, 'visitors_day.date', $day['date'] );
145  $vtp->setVar( $sub, 'visitors_day.width', $width );
146  $vtp->setVar( $sub, 'visitors_day.nb_visitors', $day['nb_visitors'] );
147  $vtp->closeSession( $sub, 'visitors_day' );*/
148}
149//----------------------------------------------------------- sending html code
150$template->assign_var_from_handle('ADMIN_CONTENT', 'stats');
151?>
Note: See TracBrowser for help on using the repository browser.