Common subdirectories: ./images and /home/groups/home/FotoBoek/admin/images
Common subdirectories: ./include and /home/groups/home/FotoBoek/admin/include
diff -u ./stats.php /home/groups/home/FotoBoek/admin/stats.php
--- ./stats.php 2005-10-30 21:35:39.000000000 +0100
+++ /home/groups/home/FotoBoek/admin/stats.php 2006-05-14 21:09:57.000000000 +0200
@@ -41,20 +41,25 @@
$url_img .= 'daily_stats.img.php?year='.$_GET['year'].'&month='.$_GET['month'].'&day='.$_GET['day'];
$nls_value_title = $lang['w_day'];
$group_clause = "DATE_FORMAT(date,'%Y-%m-%d') ASC";
- $where_clause = "(YEAR(date) = ".$_GET['year']." AND MONTH(date) = ".$_GET['month']." )";
+ $dd=sprintf("%d-%02d-01", $_GET['year'],$_GET['month']);
+ $where_clause = "date BETWEEN '$dd' and date_add('$dd', interval 1 month)";
}
elseif (isset($_GET['month']) && isset($_GET['year']) )
{
$url_img .= 'monthly_stats.img.php?year='.$_GET['year'].'&month='.$_GET['month'];
$nls_value_title = $lang['w_day'];
$group_clause = "DATE_FORMAT(date,'%Y-%m-%d') ASC";
- $where_clause = "(YEAR(date) = ".$_GET['year']." AND MONTH(date) = ".$_GET['month']." )";
+ $dd=sprintf("%d-%02d-01", $_GET['year'],$_GET['month']);
+ $where_clause = "date BETWEEN '$dd' and date_add('$dd', interval 1 month)";
}
else
{
$url_img .= 'global_stats.img.php';
}
-
+// 65.54.188. msnbot
+// 66.249.66. googlebot
+$bot_clause = " AND IP not like '65.54.188.%' AND IP not like '66.249.66.%' AND IP not like '66.249.72.%' AND IP not like '66.154.103.%'";
+$where_clause .= $bot_clause;
//----------------------------------------------------- template initialization
if (isset($_GET['day']) && isset($_GET['month']) && isset($_GET['year']) )
@@ -109,37 +114,33 @@
));
//---------------------------------------------------------------- log history
+// GJ, added num pictures in main query
$query = '
SELECT DISTINCT COUNT(*) as p,
DAYOFMONTH(date) as d,
MONTH(date) as m,
- YEAR(date) as y
+ YEAR(date) as y,
+ count(if(file=\'picture\',\'picture\',NULL)) as pict
FROM '.HISTORY_TABLE.'
WHERE '.$where_clause.'
GROUP BY '.$group_clause.';';
$result = pwg_query( $query );
$i=0;
+
while ( $row = mysql_fetch_array( $result ) )
{
$where_clause="";
$value = '';
if (isset($_GET['month']) && isset($_GET['year']) )
- {
- $where_clause = 'DAYOFMONTH(date) = '.$row['d'].'
- AND MONTH(date) = '.$row['m'].'
- AND YEAR(date) = '.$row['y'];
+ {
+ $dd = sprintf("%d-%02d-%02d", $row['y'], $row['m'], $row['d']);
+ $where_clause = "date between '$dd' and date_add('$dd',interval 1 day)";
- $week_day =
- $lang['day'][date('w', mktime(12,0,0,$row['m'],$row['d'],$row['y']))];
+ $week_day = $lang['day'][date('w', mktime(12,0,0,$row['m'],$row['d'],$row['y']))];
- $url =
- PHPWG_ROOT_PATH.'admin.php'
- .'?page=stats'
- .'&year='.$row['y']
- .'&month='.$row['m']
- .'&day='.$row['d']
- ;
+ $url = PHPWG_ROOT_PATH.'admin.php'.'?page=stats'
+ .'&year='.$row['y'].'&month='.$row['m'].'&day='.$row['d'];
$value = '';
$value.= $row['d'].' ('.$week_day.')';
@@ -151,36 +152,21 @@
if ($row['m'] <10) {$current_month.='0';}
$current_month .= $row['m'];
- $where_clause = "DATE_FORMAT(date,'%Y-%m') = '".$current_month."'";
-
- $url =
- PHPWG_ROOT_PATH.'admin.php'
- .'?page=stats'
- .'&year='.$row['y']
- .'&month='.$row['m']
- ;
+ $dd = sprintf("%d-%02d-01",$row['y'],$row['m']);
+ $where_clause = "date between '$dd' and date_add('$dd', interval 1 month)";
+
+ $url = PHPWG_ROOT_PATH.'admin.php'
+ .'?page=stats'.'&year='.$row['y'].'&month='.$row['m'];
$value = '';
$value.= $lang['month'][$row['m']].' '.$row['y'];
$value.= "";
}
-
- // Number of pictures seen
- $query = '
-SELECT COUNT(*) as p
- FROM '.HISTORY_TABLE.'
- WHERE '.$where_clause.'
- AND FILE = \'picture\'
-;';
- $pictures = mysql_fetch_array(pwg_query( $query ));
+ $where_clause .= $bot_clause;
+ $pictures['p'] = $row['pict'];
// Number of different visitors
- $query = '
-SELECT COUNT(*) as p, login
- FROM '.HISTORY_TABLE.'
- WHERE '.$where_clause.'
- GROUP BY login, IP
-;';
+ $query = 'SELECT COUNT(*) as p, login FROM '.HISTORY_TABLE.' WHERE '.$where_clause.' GROUP BY login, IP ;';
$user_results = pwg_query( $query );
$nb_visitors = 0;
$auth_users = array();
@@ -195,7 +181,7 @@
$class = ($i % 2)? 'row1':'row2'; $i++;
$template->assign_block_vars('statrow',array(
- 'VALUE'=>$value,
+ 'VALUE'=>$value,
'PAGES'=>$row['p'],
'VISITORS'=>$nb_visitors,
'IMAGES'=>$pictures['p'],
@@ -232,8 +218,10 @@
}
// Set WHERE clause
+$dd=sprintf("%d-%02d-%02d", $current_year,$current_month, $current_day);
$where = ' WHERE DATE_FORMAT(date,\'%Y-%m-%d\') = \''.$current_year."-".$current_month."-".$current_day.'\'';
-
+$where = " where date between '$dd' and date_add('$dd', interval 1 day) ";
+$where .= $bot_clause;
// Set LIMIT clause
$limit = ' LIMIT ';
$page['start'] = 0;
Only in /home/groups/home/FotoBoek/admin/: stats.php~