[24] | 1 | <?php |
---|
[362] | 2 | // +-----------------------------------------------------------------------+ |
---|
[593] | 3 | // | PhpWebGallery - a PHP based picture gallery | |
---|
| 4 | // | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net | |
---|
| 5 | // | Copyright (C) 2003-2004 PhpWebGallery Team - http://phpwebgallery.net | |
---|
[362] | 6 | // +-----------------------------------------------------------------------+ |
---|
[593] | 7 | // | branch : BSF (Best So Far) |
---|
[362] | 8 | // | file : $RCSfile$ |
---|
| 9 | // | last update : $Date: 2004-11-06 21:12:59 +0000 (Sat, 06 Nov 2004) $ |
---|
| 10 | // | last modifier : $Author: z0rglub $ |
---|
| 11 | // | revision : $Revision: 593 $ |
---|
| 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 | // +-----------------------------------------------------------------------+ |
---|
[527] | 27 | if( !defined("PHPWG_ROOT_PATH") ) |
---|
| 28 | { |
---|
| 29 | die ("Hacking attempt!"); |
---|
| 30 | } |
---|
| 31 | include_once( PHPWG_ROOT_PATH.'admin/include/isadmin.inc.php' ); |
---|
| 32 | |
---|
[539] | 33 | $url_img_global_report = PHPWG_ROOT_PATH.'admin/images/global_stats.img.php'; |
---|
[24] | 34 | //----------------------------------------------------- template initialization |
---|
[527] | 35 | $template->set_filenames( array('stats'=>'admin/stats.tpl') ); |
---|
| 36 | |
---|
| 37 | $template->assign_vars(array( |
---|
[566] | 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 | |
---|
[539] | 46 | 'IMG_MONTHLY_REPORT'=>add_session_id($url_img_global_report) |
---|
[527] | 47 | )); |
---|
| 48 | |
---|
[24] | 49 | //---------------------------------------------------------------- log history |
---|
[591] | 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 | ;'; |
---|
[587] | 57 | $result = pwg_query( $query ); |
---|
[566] | 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 |
---|
[591] | 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 | ;'; |
---|
[587] | 73 | $pictures = mysql_fetch_array(pwg_query( $query )); |
---|
[566] | 74 | |
---|
| 75 | // Number of different visitors |
---|
[591] | 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 | ;'; |
---|
[587] | 82 | $user_results = pwg_query( $query ); |
---|
[566] | 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 ); |
---|
[24] | 105 | $days = array(); |
---|
| 106 | $max_nb_visitors = 0; |
---|
| 107 | $max_pages_seen = 0; |
---|
| 108 | |
---|
| 109 | $starttime = mktime( 0, 0, 0,date('n'),date('j'),date('Y') ); |
---|
| 110 | $endtime = mktime( 23,59,59,date('n'),date('j'),date('Y') ); |
---|
[537] | 111 | //for ( $i = 0; $i <= MAX_DAYS; $i++ ) |
---|
[24] | 112 | { |
---|
[566] | 113 | /* |
---|
[24] | 114 | // log lines for this day |
---|
| 115 | $query = 'SELECT date,login,IP,category,file,picture'; |
---|
| 116 | $query.= ' FROM '.PREFIX_TABLE.'history'; |
---|
| 117 | $query.= ' WHERE date > '.$starttime; |
---|
| 118 | $query.= ' AND date < '.$endtime; |
---|
[152] | 119 | $query.= ' ORDER BY date DESC'; |
---|
[24] | 120 | $query.= ';'; |
---|
[587] | 121 | $result = pwg_query( $query ); |
---|
[24] | 122 | $nb_pages_seen = mysql_num_rows( $result ); |
---|
| 123 | $day['nb_pages_seen'] = $nb_pages_seen; |
---|
| 124 | if ( $nb_pages_seen > $max_pages_seen ) $max_pages_seen = $nb_pages_seen; |
---|
| 125 | $vtp->setVar( $sub, 'day.nb_pages', $nb_pages_seen ); |
---|
| 126 | if ( in_array( $i, $page['expand_days'] ) ) |
---|
| 127 | { |
---|
| 128 | while ( $row = mysql_fetch_array( $result ) ) |
---|
| 129 | { |
---|
| 130 | $vtp->addSession( $sub, 'line' ); |
---|
[157] | 131 | $vtp->setVar( $sub, 'line.date', date( 'G:i:s', $row['date'] ) ); |
---|
[24] | 132 | $vtp->setVar( $sub, 'line.login', $row['login'] ); |
---|
| 133 | $vtp->setVar( $sub, 'line.IP', $row['IP'] ); |
---|
| 134 | $vtp->setVar( $sub, 'line.category', $row['category'] ); |
---|
| 135 | $vtp->setVar( $sub, 'line.file', $row['file'] ); |
---|
| 136 | $vtp->setVar( $sub, 'line.picture', $row['picture'] ); |
---|
| 137 | $vtp->closeSession( $sub, 'line' ); |
---|
| 138 | } |
---|
| 139 | } |
---|
| 140 | $starttime-= 24*60*60; |
---|
| 141 | $endtime -= 24*60*60; |
---|
| 142 | $vtp->closeSession( $sub, 'day' ); |
---|
[527] | 143 | array_push( $days, $day );*/ |
---|
[24] | 144 | } |
---|
| 145 | //------------------------------------------------------------ pages seen graph |
---|
| 146 | foreach ( $days as $day ) { |
---|
[527] | 147 | /*$vtp->addSession( $sub, 'pages_day' ); |
---|
[52] | 148 | if ( $max_pages_seen > 0 ) |
---|
| 149 | $width = floor( ( $day['nb_pages_seen']*$max_pixels ) / $max_pages_seen ); |
---|
| 150 | else $width = 0; |
---|
[24] | 151 | $vtp->setVar( $sub, 'pages_day.date', $day['date'] ); |
---|
| 152 | $vtp->setVar( $sub, 'pages_day.width', $width ); |
---|
| 153 | $vtp->setVar( $sub, 'pages_day.nb_pages', $day['nb_pages_seen'] ); |
---|
[527] | 154 | $vtp->closeSession( $sub, 'pages_day' );*/ |
---|
[24] | 155 | } |
---|
| 156 | //-------------------------------------------------------------- visitors grpah |
---|
| 157 | foreach ( $days as $day ) { |
---|
[527] | 158 | /*$vtp->addSession( $sub, 'visitors_day' ); |
---|
[52] | 159 | if ( $max_nb_visitors > 0 ) |
---|
| 160 | $width = floor( ( $day['nb_visitors'] * $max_pixels ) / $max_nb_visitors ); |
---|
| 161 | else $width = 0; |
---|
[24] | 162 | $vtp->setVar( $sub, 'visitors_day.date', $day['date'] ); |
---|
| 163 | $vtp->setVar( $sub, 'visitors_day.width', $width ); |
---|
| 164 | $vtp->setVar( $sub, 'visitors_day.nb_visitors', $day['nb_visitors'] ); |
---|
[527] | 165 | $vtp->closeSession( $sub, 'visitors_day' );*/ |
---|
[24] | 166 | } |
---|
| 167 | //----------------------------------------------------------- sending html code |
---|
[527] | 168 | $template->assign_var_from_handle('ADMIN_CONTENT', 'stats'); |
---|
[362] | 169 | ?> |
---|