1 | <?php |
---|
2 | // +-----------------------------------------------------------------------+ |
---|
3 | // | PhpWebGallery - a PHP based picture gallery | |
---|
4 | // | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net | |
---|
5 | // | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net | |
---|
6 | // +-----------------------------------------------------------------------+ |
---|
7 | // | branch : BSF (Best So Far) |
---|
8 | // | file : $RCSfile$ |
---|
9 | // | last update : $Date: 2005-02-01 07:28:38 +0000 (Tue, 01 Feb 2005) $ |
---|
10 | // | last modifier : $Author: plg $ |
---|
11 | // | revision : $Revision: 724 $ |
---|
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 | // +-----------------------------------------------------------------------+ |
---|
27 | if( !defined("PHPWG_ROOT_PATH") ) |
---|
28 | { |
---|
29 | die ("Hacking attempt!"); |
---|
30 | } |
---|
31 | include_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_MONTH'=>$lang['w_month'], |
---|
39 | 'L_PAGES_SEEN'=>$lang['stats_pages_seen'], |
---|
40 | 'L_VISITORS'=>$lang['visitors'], |
---|
41 | 'L_PICTURES'=>$lang['pictures'], |
---|
42 | 'L_STAT_TITLE'=>$lang['stats_title'], |
---|
43 | 'L_STAT_MONTH_TITLE'=>$lang['stats_month_title'], |
---|
44 | 'L_STAT_MONTHLY_ALT'=>$lang['stats_global_graph_title'], |
---|
45 | |
---|
46 | 'IMG_MONTHLY_REPORT'=>add_session_id($url_img_global_report) |
---|
47 | )); |
---|
48 | |
---|
49 | //---------------------------------------------------------------- log history |
---|
50 | $query = ' |
---|
51 | SELECT DISTINCT COUNT(*) as p, |
---|
52 | MONTH(date) as m, |
---|
53 | YEAR(date) as y |
---|
54 | FROM '.HISTORY_TABLE.' |
---|
55 | GROUP BY DATE_FORMAT(date,\'%Y-%m\') DESC |
---|
56 | ;'; |
---|
57 | $result = pwg_query( $query ); |
---|
58 | $i=0; |
---|
59 | while ( $row = mysql_fetch_array( $result ) ) |
---|
60 | { |
---|
61 | $current_month = $row['y']."-"; |
---|
62 | if ($row['m'] <10) {$current_month.='0';} |
---|
63 | $current_month .= $row['m']; |
---|
64 | // Number of pictures seen |
---|
65 | $query = ' |
---|
66 | SELECT COUNT(*) as p, |
---|
67 | FILE as f |
---|
68 | FROM '.HISTORY_TABLE.' |
---|
69 | WHERE DATE_FORMAT(date,\'%Y-%m\') = \''.$current_month.'\' |
---|
70 | AND FILE = \'picture\' |
---|
71 | GROUP BY FILE |
---|
72 | ;'; |
---|
73 | $pictures = mysql_fetch_array(pwg_query( $query )); |
---|
74 | |
---|
75 | // Number of different visitors |
---|
76 | $query = ' |
---|
77 | SELECT COUNT(*) as p, login |
---|
78 | FROM '.HISTORY_TABLE.' |
---|
79 | WHERE DATE_FORMAT(date,\'%Y-%m\') = \''.$current_month.'\' |
---|
80 | GROUP BY login, IP |
---|
81 | ;'; |
---|
82 | $user_results = pwg_query( $query ); |
---|
83 | $nb_visitors = 0; |
---|
84 | $auth_users = array(); |
---|
85 | while ( $user_array = mysql_fetch_array( $user_results ) ) |
---|
86 | { |
---|
87 | if ($user_array['login'] == 'guest') |
---|
88 | $nb_visitors += 1; |
---|
89 | else |
---|
90 | array_push($auth_users, $user_array['login']); |
---|
91 | } |
---|
92 | $nb_visitors +=count(array_unique($auth_users)); |
---|
93 | $class = ($i % 2)? 'row1':'row2'; $i++; |
---|
94 | |
---|
95 | $template->assign_block_vars('month',array( |
---|
96 | 'MONTH'=>$lang['month'][$row['m']].' '.$row['y'], |
---|
97 | 'PAGES'=>$row['p'], |
---|
98 | 'VISITORS'=>$nb_visitors, |
---|
99 | 'IMAGES'=>$pictures['p'], |
---|
100 | |
---|
101 | 'T_CLASS'=>$class |
---|
102 | )); |
---|
103 | } |
---|
104 | $nb_visitors = mysql_num_rows( $result ); |
---|
105 | $days = array(); |
---|
106 | $max_nb_visitors = 0; |
---|
107 | $max_pages_seen = 0; |
---|
108 | //----------------------------------------------------------- sending html code |
---|
109 | $template->assign_var_from_handle('ADMIN_CONTENT', 'stats'); |
---|
110 | ?> |
---|