Common subdirectories: /data/tmp/phpwebgallery-1.6.0/admin/images and ./images Common subdirectories: /data/tmp/phpwebgallery-1.6.0/admin/include and ./include diff -u /data/tmp/phpwebgallery-1.6.0/admin/stats.php ./stats.php --- /data/tmp/phpwebgallery-1.6.0/admin/stats.php 2006-06-16 20:45:06.000000000 +0200 +++ ./stats.php 2006-07-09 21:27:17.000000000 +0200 @@ -47,14 +47,16 @@ $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 { @@ -115,11 +117,13 @@ )); //---------------------------------------------------------------- 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.';'; @@ -132,20 +136,11 @@ $value = ''; if (isset($_GET['month']) && isset($_GET['year']) ) { - $where_clause = 'DAYOFMONTH(date) = '.$row['d'].' - AND MONTH(date) = '.$row['m'].' - AND YEAR(date) = '.$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'] - ; + $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']))]; + $url = PHPWG_ROOT_PATH.'admin.php'.'?page=stats' + .'&year='.$row['y'].'&month='.$row['m'].'&day='.$row['d']; $value = ''; $value.= $row['d'].' ('.$week_day.')'; @@ -157,28 +152,19 @@ 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 )); + $pictures['p'] = $row['pict']; // Number of different visitors $query = ' @@ -238,8 +224,9 @@ } // Set WHERE clause -$where = ' WHERE DATE_FORMAT(date,\'%Y-%m-%d\') = \''.$current_year."-".$current_month."-".$current_day.'\''; - +$dd=sprintf("%d-%02d-%02d", $current_year,$current_month, $current_day); +$where = " where date between '$dd' and date_add('$dd', interval 1 day) "; + // Set LIMIT clause $limit = ' LIMIT '; $page['start'] = 0;