summaryrefslogtreecommitdiffstats
path: root/modules-available/statistics_reporting
diff options
context:
space:
mode:
authorUdo Walter2017-01-13 16:19:33 +0100
committerUdo Walter2017-01-13 16:19:33 +0100
commit3df046508f58bbfff51c5cad33f42af4e378bea7 (patch)
tree438aa31c0a8f35e8fc1f14a246ed55fcdd18b95d /modules-available/statistics_reporting
parent[statistics_reporting] improved cutoff in query functions + bugfix (diff)
downloadslx-admin-3df046508f58bbfff51c5cad33f42af4e378bea7.tar.gz
slx-admin-3df046508f58bbfff51c5cad33f42af4e378bea7.tar.xz
slx-admin-3df046508f58bbfff51c5cad33f42af4e378bea7.zip
[statistics_reporting] improved anonymization
Diffstat (limited to 'modules-available/statistics_reporting')
-rw-r--r--modules-available/statistics_reporting/inc/getdata.inc.php50
-rw-r--r--modules-available/statistics_reporting/page.inc.php5
2 files changed, 36 insertions, 19 deletions
diff --git a/modules-available/statistics_reporting/inc/getdata.inc.php b/modules-available/statistics_reporting/inc/getdata.inc.php
index 8628d9db..880256d6 100644
--- a/modules-available/statistics_reporting/inc/getdata.inc.php
+++ b/modules-available/statistics_reporting/inc/getdata.inc.php
@@ -13,12 +13,18 @@ class GetData
// total time online, average time online, total number of logins
$res = Queries::getOverallStatistics(self::$from, self::$to, self::$lowerTimeBound, self::$upperTimeBound);
$row = $res->fetch(PDO::FETCH_ASSOC);
- $data = array('time' => self::formatSeconds($row['sum']), 'medianTime' => self::formatSeconds(self::calcMedian($row['median'])), 'sessions' => $row['longSessions'], 'shortSessions' => $row['shortSessions']);
+ $data = array('time' => $row['sum'], 'medianTime' => self::calcMedian($row['median']), 'sessions' => $row['longSessions'], 'shortSessions' => $row['shortSessions']);
//total time offline
$res = Queries::getTotalOfflineStatistics(self::$from, self::$to, self::$lowerTimeBound, self::$upperTimeBound);
$row = $res->fetch(PDO::FETCH_ASSOC);
- $data = array_merge($data, array('totalOfftime' => self::formatSeconds($row['timeOff'])));
+ $data = array_merge($data, array('totalOfftime' => $row['timeOff']));
+
+ if (!$anonymize) {
+ $data["time"] = self::formatSeconds($data["time"]);
+ $data["medianTime"] = self::formatSeconds($data["time"]);
+ $data["totalOfftime"] = self::formatSeconds($data["time"]);
+ }
return $data;
}
@@ -27,11 +33,19 @@ class GetData
public static function perLocation($anonymize = false) {
$res = Queries::getLocationStatistics(self::$from, self::$to, self::$lowerTimeBound, self::$upperTimeBound);
$data = array();
- $loc = $anonymize ? 'locHash' : 'locName';
- while ($row = $res->fetch(PDO::FETCH_ASSOC)) {
- $median = self::calcMedian(self::calcMedian($row['medianTime']));
- $data[] = array('location' => $row[$loc], 'time' => self::formatSeconds($row['timeSum']), 'timeInSeconds' => $row['timeSum'],
- 'medianTime' => self::formatSeconds($median), 'medianTimeInSeconds' => $median, 'offTime' => self::formatSeconds($row['offlineSum']), 'offlineTimeInSeconds' => $row['offlineSum'], 'sessions' => $row['longSessions'], 'shortSessions' => $row['shortSessions']);
+ if (!$anonymize) {
+ while ($row = $res->fetch(PDO::FETCH_ASSOC)) {
+ $median = self::calcMedian(self::calcMedian($row['medianTime']));
+ $data[] = array('location' => $row['locName'], 'time' => self::formatSeconds($row['timeSum']), 'timeInSeconds' => $row['timeSum'],
+ 'medianTime' => self::formatSeconds($median), 'medianTimeInSeconds' => $median, 'offTime' => self::formatSeconds($row['offlineSum']),
+ 'offlineTimeInSeconds' => $row['offlineSum'], 'sessions' => $row['longSessions'], 'shortSessions' => $row['shortSessions']);
+ }
+ } else {
+ while ($row = $res->fetch(PDO::FETCH_ASSOC)) {
+ $median = self::calcMedian(self::calcMedian($row['medianTime']));
+ $data[] = array('location' => $row['locHash'], 'time' => $row['timeSum'], 'medianTime' => $median, 'offTime' => $row['offlineSum'],
+ 'sessions' => $row['longSessions'], 'shortSessions' => $row['shortSessions']);
+ }
}
return $data;
}
@@ -40,13 +54,19 @@ class GetData
public static function perClient($anonymize = false) {
$res = Queries::getClientStatistics(self::$from, self::$to, self::$lowerTimeBound, self::$upperTimeBound);
$data = array();
- $name = $anonymize ? 'clientHash' : 'clientName';
- $loc = $anonymize ? 'locHash' : 'locName';
- while ($row = $res->fetch(PDO::FETCH_ASSOC)) {
- $median = self::calcMedian(self::calcMedian($row['medianTime']));
- $data[] = array('hostname' => $row[$name], 'time' => self::formatSeconds($row['timeSum']), 'timeInSeconds' => $row['timeSum'],
- 'medianTime' => self::formatSeconds($median), 'medianTimeInSeconds' => $median, 'offTime' => self::formatSeconds($row['offlineSum']), 'offlineTimeInSeconds' => $row['offlineSum'], 'lastStart' => date(DATE_RSS,$row['lastStart']), 'lastStartUnixtime' => $row['lastStart'],
- 'lastLogout' => date(DATE_RSS,$row['lastLogout']), 'lastLogoutUnixtime' => $row['lastLogout'], 'sessions' => $row['longSessions'], 'shortSessions' => $row['shortSessions'], 'locationName' => $row[$loc]);
+ if (!$anonymize) {
+ while ($row = $res->fetch(PDO::FETCH_ASSOC)) {
+ $median = self::calcMedian(self::calcMedian($row['medianTime']));
+ $data[] = array('hostname' => $row['clientName'], 'time' => self::formatSeconds($row['timeSum']), 'timeInSeconds' => $row['timeSum'],
+ 'medianTime' => self::formatSeconds($median), 'medianTimeInSeconds' => $median, 'offTime' => self::formatSeconds($row['offlineSum']), 'offlineTimeInSeconds' => $row['offlineSum'], 'lastStart' => date(DATE_RSS, $row['lastStart']), 'lastStartUnixtime' => $row['lastStart'],
+ 'lastLogout' => date(DATE_RSS, $row['lastLogout']), 'lastLogoutUnixtime' => $row['lastLogout'], 'sessions' => $row['longSessions'], 'shortSessions' => $row['shortSessions'], 'locationName' => $row['locName']);
+ }
+ } else {
+ while ($row = $res->fetch(PDO::FETCH_ASSOC)) {
+ $median = self::calcMedian(self::calcMedian($row['medianTime']));
+ $data[] = array('hostname' => $row['clientHash'], 'time' => $row['timeSum'], 'medianTime' => $median, 'offTime' => $row['offlineSum'], 'lastStart' => $row['lastStart'],
+ 'lastLogout' => $row['lastLogout'], 'sessions' => $row['longSessions'], 'shortSessions' => $row['shortSessions'], 'locationName' => $row['locHash']);
+ }
}
return $data;
}
@@ -57,7 +77,7 @@ class GetData
$data = array();
$user = $anonymize ? 'userHash' : 'name';
while ($row = $res->fetch(PDO::FETCH_ASSOC)) {
- $data[] = array('user' => $row['name'], 'sessions' => $row['count']);
+ $data[] = array('user' => $row[$user], 'sessions' => $row['count']);
}
return $data;
}
diff --git a/modules-available/statistics_reporting/page.inc.php b/modules-available/statistics_reporting/page.inc.php
index aa373f54..941bf12f 100644
--- a/modules-available/statistics_reporting/page.inc.php
+++ b/modules-available/statistics_reporting/page.inc.php
@@ -24,9 +24,7 @@ class Page_Statistics_Reporting extends Page
{
// timespan you want to see = Days selected * seconds per Day (86400)
// default = 14 days
- $date = new DateTime(date('Y-m-d 00:00:00'));
- $date->sub(new DateInterval('P'.(Request::get('cutoff', 14, 'int') - 1).'D'));
- GetData::$from = $date->getTimestamp();
+ GetData::$from = strtotime("- ".(Request::get('cutoff', 14, 'int') - 1)." days 00:00:00");
GetData::$to = time();
GetData::$lowerTimeBound = Request::get('lower', 0, 'int');
GetData::$upperTimeBound = Request::get('upper', 24, 'int');
@@ -37,7 +35,6 @@ class Page_Statistics_Reporting extends Page
$data['perUser'] = GetData::perUser();
$data['perVM'] = GetData::perVM();
-
Render::addTemplate('columnChooser');
Render::addTemplate('_page', $data);
}