From b0f3d4febbc2fa0952ebbe3ec1cd2674152481a7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andreas=20=C3=85kre=20Solberg?= <andreas.solberg@uninett.no>
Date: Wed, 25 Feb 2009 11:22:31 +0000
Subject: [PATCH] Better errorr handling in frontend when no statistics files
 was found...

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@1325 44740490-163a-0410-bde0-09ae8108e29a
---
 modules/statistics/www/showstats.php | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/modules/statistics/www/showstats.php b/modules/statistics/www/showstats.php
index bf8327caa..aa0c67b0f 100644
--- a/modules/statistics/www/showstats.php
+++ b/modules/statistics/www/showstats.php
@@ -25,6 +25,8 @@ foreach ($filelist AS $file) {
 		}
 	}
 }
+if (empty($available)) 
+	throw new Exception('No aggregated statistics files found in [' . $statdir . ']');
 
 /*
  * Create array with information about available rules..
@@ -62,7 +64,12 @@ if (array_key_exists('time', $_GET)) {
 }
 
 // Get file and extract results.
-$resultfile = file_get_contents($statdir . $rule . '-' . $fileslot . '.stat');
+$resultFileName = $statdir . $rule . '-' . $fileslot . '.stat';
+if (!file_exists($resultFileName))
+	throw new Exception('Aggregated statitics file [' . $resultFileName . '] not found.');
+if (!is_readable($resultFileName))
+	throw new Exception('Could not read statitics file [' . $resultFileName . ']. Bad file permissions?');
+$resultfile = file_get_contents($resultFileName);
 $results = unserialize($resultfile);
 
 
-- 
GitLab