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-04-26 20:47:16 +0000 (Tue, 26 Apr 2005) $ |
---|
10 | // | last modifier : $Author: plg $ |
---|
11 | // | revision : $Revision: 775 $ |
---|
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 = PHPWG_ROOT_PATH.'admin/images/'; |
---|
34 | $nls_value_title = $lang['w_month']; |
---|
35 | $group_clause = "DATE_FORMAT(date,'%Y-%m') DESC"; |
---|
36 | $where_clause = "1"; |
---|
37 | |
---|
38 | if (isset($_GET['month']) && isset($_GET['year']) ) |
---|
39 | { |
---|
40 | $url_img .= 'monthly_stats.img.php?year='.$_GET['year'].'&month='.$_GET['month']; |
---|
41 | $nls_value_title = $lang['w_day']; |
---|
42 | $group_clause = "DATE_FORMAT(date,'%Y-%m-%d') ASC"; |
---|
43 | $where_clause = "(YEAR(date) = ".$_GET['year']." AND MONTH(date) = ".$_GET['month']." )"; |
---|
44 | } |
---|
45 | else |
---|
46 | { |
---|
47 | $url_img .= 'global_stats.img.php'; |
---|
48 | } |
---|
49 | |
---|
50 | //----------------------------------------------------- template initialization |
---|
51 | $template->set_filenames( array('stats'=>'admin/stats.tpl') ); |
---|
52 | |
---|
53 | $template->assign_vars(array( |
---|
54 | 'L_VALUE'=>$nls_value_title, |
---|
55 | 'L_PAGES_SEEN'=>$lang['stats_pages_seen'], |
---|
56 | 'L_VISITORS'=>$lang['visitors'], |
---|
57 | 'L_PICTURES'=>$lang['pictures'], |
---|
58 | 'L_STAT_TITLE'=>$lang['stats_title'], |
---|
59 | 'L_STAT_MONTH_TITLE'=>$lang['stats_month_title'], |
---|
60 | 'L_STAT_MONTHLY_ALT'=>$lang['stats_global_graph_title'], |
---|
61 | |
---|
62 | 'IMG_REPORT'=>add_session_id($url_img) |
---|
63 | )); |
---|
64 | |
---|
65 | //---------------------------------------------------------------- log history |
---|
66 | $query = ' |
---|
67 | SELECT DISTINCT COUNT(*) as p, |
---|
68 | DAYOFMONTH(date) as d, |
---|
69 | MONTH(date) as m, |
---|
70 | YEAR(date) as y |
---|
71 | FROM '.HISTORY_TABLE.' |
---|
72 | WHERE '.$where_clause.' |
---|
73 | GROUP BY '.$group_clause.';'; |
---|
74 | |
---|
75 | $result = pwg_query( $query ); |
---|
76 | $i=0; |
---|
77 | while ( $row = mysql_fetch_array( $result ) ) |
---|
78 | { |
---|
79 | $where_clause=""; |
---|
80 | $value = ''; |
---|
81 | if (isset($_GET['month']) && isset($_GET['year']) ) |
---|
82 | { |
---|
83 | $where_clause = "DATE_FORMAT(date,'%Y-%m-%d') = '".$row['d']."'"; |
---|
84 | $value = substr($row['d'],8,2); |
---|
85 | } |
---|
86 | else |
---|
87 | { |
---|
88 | $current_month = $row['y']."-"; |
---|
89 | if ($row['m'] <10) {$current_month.='0';} |
---|
90 | $current_month .= $row['m']; |
---|
91 | $where_clause = "DATE_FORMAT(date,'%Y-%m') = '".$current_month."'"; |
---|
92 | $value = "<a href='".PHPWG_ROOT_PATH."admin.php?page=stats"; |
---|
93 | $value.= "&year=".$row['y']."&month=".$row['m']."'>"; |
---|
94 | $value.= $lang['month'][$row['m']].' '.$row['y']; |
---|
95 | $value.= "</a>"; |
---|
96 | } |
---|
97 | |
---|
98 | // Number of pictures seen |
---|
99 | $query = ' |
---|
100 | SELECT COUNT(*) as p, |
---|
101 | FILE as f |
---|
102 | FROM '.HISTORY_TABLE.' |
---|
103 | WHERE '.$where_clause.' |
---|
104 | AND FILE = \'picture\' |
---|
105 | GROUP BY FILE |
---|
106 | ;'; |
---|
107 | $pictures = mysql_fetch_array(pwg_query( $query )); |
---|
108 | |
---|
109 | // Number of different visitors |
---|
110 | $query = ' |
---|
111 | SELECT COUNT(*) as p, login |
---|
112 | FROM '.HISTORY_TABLE.' |
---|
113 | WHERE '.$where_clause.' |
---|
114 | GROUP BY login, IP |
---|
115 | ;'; |
---|
116 | $user_results = pwg_query( $query ); |
---|
117 | $nb_visitors = 0; |
---|
118 | $auth_users = array(); |
---|
119 | while ( $user_array = mysql_fetch_array( $user_results ) ) |
---|
120 | { |
---|
121 | if ($user_array['login'] == 'guest') |
---|
122 | $nb_visitors += 1; |
---|
123 | else |
---|
124 | array_push($auth_users, $user_array['login']); |
---|
125 | } |
---|
126 | $nb_visitors +=count(array_unique($auth_users)); |
---|
127 | $class = ($i % 2)? 'row1':'row2'; $i++; |
---|
128 | |
---|
129 | $template->assign_block_vars('statrow',array( |
---|
130 | 'VALUE'=>$value, |
---|
131 | 'PAGES'=>$row['p'], |
---|
132 | 'VISITORS'=>$nb_visitors, |
---|
133 | 'IMAGES'=>$pictures['p'], |
---|
134 | |
---|
135 | 'T_CLASS'=>$class |
---|
136 | )); |
---|
137 | } |
---|
138 | $nb_visitors = mysql_num_rows( $result ); |
---|
139 | $days = array(); |
---|
140 | $max_nb_visitors = 0; |
---|
141 | $max_pages_seen = 0; |
---|
142 | //----------------------------------------------------------- sending html code |
---|
143 | $template->assign_var_from_handle('ADMIN_CONTENT', 'stats'); |
---|
144 | ?> |
---|