From b9f186befbb766d608e9fce084f46266e8aa89c7 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Tue, 18 Oct 2016 15:52:58 +0100 Subject: [PATCH] Revert "set default time zone for date" --- data.php | 10 ++++++---- php/auth.php | 3 +-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/data.php b/data.php index 9a36dae3..2e4d9ffc 100644 --- a/data.php +++ b/data.php @@ -125,7 +125,7 @@ $hostname = trim(file_get_contents("/etc/hostname"), "\x00..\x1F"); foreach ($dns_queries as $query) { - $time = exec("date --date='" . trim(substr($query, 0, 16)) . "' +'%Y-%m-%dT%H:%M:%S'"); + $time = date_create(substr($query, 0, 16)); $exploded = explode(" ", trim($query)); $tmp = $exploded[count($exploded)-4]; $status = ""; @@ -145,7 +145,7 @@ if ( $status != ""){ array_push($allQueries['data'], array( - $time, + $time->format('Y-m-d\TH:i:s'), $type, $domain, hasHostName($client), @@ -239,7 +239,8 @@ function overTime($entries) { $byTime = array(); foreach ($entries as $entry) { - $hour = trim(exec("date --date='" . trim(substr($entry, 0, 16)) . "' +'%k'")); + $time = date_create(substr($entry, 0, 16)); + $hour = $time->format('G'); if (isset($byTime[$hour])) { $byTime[$hour]++; @@ -273,7 +274,8 @@ foreach (array_slice($queries, -$qty) as $query) { $queryArray = array(); $exploded = explode(" ", $query); - $queryArray['time'] = strtolower(exec("date --date='" . trim(substr($query, 0, 16)) . "' +'%I:%M:%S %p'")); + $time = date_create(substr($query, 0, 16)); + $queryArray['time'] = $time->format('h:i:s a'); $queryArray['domain'] = trim($exploded[count($exploded) - 3]); $queryArray['ip'] = trim($exploded[count($exploded)-1]); array_push($recent, $queryArray); diff --git a/php/auth.php b/php/auth.php index 7eea8158..55e5e58d 100644 --- a/php/auth.php +++ b/php/auth.php @@ -6,8 +6,7 @@ if (empty($ERRORLOG)) { } function pi_log($message) { - $date = exec("date +'%Y-%m-%d %H:%M:%S'"); - error_log($date . ': ' . $message . "\n", 3, $GLOBALS['ERRORLOG']); + error_log(date('Y-m-d H:i:s') . ': ' . $message . "\n", 3, $GLOBALS['ERRORLOG']); } function log_and_die($message) {