From 3f04afc12a369ca3284624de7b6695ab42cd0e4a Mon Sep 17 00:00:00 2001 From: plegall Date: Thu, 18 Jan 2007 09:05:39 +0000 Subject: Bug fixed: infinite loop in history statistics summary when no data to display. git-svn-id: http://piwigo.org/svn/trunk@1733 68402e56-0260-453c-a942-63ccdbb3a9ee --- admin/stats.php | 123 +++++++++++++++++++++++++++++--------------------------- 1 file changed, 63 insertions(+), 60 deletions(-) (limited to 'admin/stats.php') diff --git a/admin/stats.php b/admin/stats.php index 1030c5f45..26ba459d6 100644 --- a/admin/stats.php +++ b/admin/stats.php @@ -437,75 +437,78 @@ foreach ($summary_lines as $line) $datas[ $line[$key] ] = $line['nb_pages']; } -if (!isset($min_x) and !isset($max_x)) +if (!isset($min_x) and !isset($max_x) and count($datas) > 0) { $min_x = min(array_keys($datas)); $max_x = max(array_keys($datas)); } -for ($i = $min_x; $i <= $max_x; $i++) +if (count($datas) > 0) { - if (!isset($datas[$i])) + for ($i = $min_x; $i <= $max_x; $i++) { - $datas[$i] = 0; - } - - $url = null; - - if (isset($page['day'])) - { - $value = $i.' '.l10n('hour'); - } - else if (isset($page['month'])) - { - $url = - PHPWG_ROOT_PATH.'admin.php' - .'?page=stats' - .'&year='.$page['year'] - .'&month='.$page['month'] - .'&day='.$i - ; - - $time = mktime(12, 0, 0, $page['month'], $i, $page['year']); - - $value = $i.' ('.$lang['day'][date('w', $time)].')'; - } - else if (isset($page['year'])) - { - $url = - PHPWG_ROOT_PATH.'admin.php' - .'?page=stats' - .'&year='.$page['year'] - .'&month='.$i - ; - - $value = $lang['month'][$i]; - } - else - { - // at least the year is defined - $url = - PHPWG_ROOT_PATH.'admin.php' - .'?page=stats' - .'&year='.$i - ; + if (!isset($datas[$i])) + { + $datas[$i] = 0; + } + + $url = null; + + if (isset($page['day'])) + { + $value = $i.' '.l10n('hour'); + } + else if (isset($page['month'])) + { + $url = + PHPWG_ROOT_PATH.'admin.php' + .'?page=stats' + .'&year='.$page['year'] + .'&month='.$page['month'] + .'&day='.$i + ; + + $time = mktime(12, 0, 0, $page['month'], $i, $page['year']); + + $value = $i.' ('.$lang['day'][date('w', $time)].')'; + } + else if (isset($page['year'])) + { + $url = + PHPWG_ROOT_PATH.'admin.php' + .'?page=stats' + .'&year='.$page['year'] + .'&month='.$i + ; + + $value = $lang['month'][$i]; + } + else + { + // at least the year is defined + $url = + PHPWG_ROOT_PATH.'admin.php' + .'?page=stats' + .'&year='.$i + ; + + $value = $i; + } + + if ($datas[$i] != 0 and isset($url)) + { + $value = ''.$value.''; + } - $value = $i; - } - - if ($datas[$i] != 0 and isset($url)) - { - $value = ''.$value.''; + $template->assign_block_vars( + 'statrow', + array( + 'VALUE' => $value, + 'PAGES' => $datas[$i], + 'WIDTH' => ceil(($datas[$i] * $max_width) / $max_pages ), + ) + ); } - - $template->assign_block_vars( - 'statrow', - array( - 'VALUE' => $value, - 'PAGES' => $datas[$i], - 'WIDTH' => ceil(($datas[$i] * $max_width) / $max_pages ), - ) - ); } // +-----------------------------------------------------------------------+ -- cgit v1.2.3