From b1df4deaf19efb21d5bb8efe936c1d4190087745 Mon Sep 17 00:00:00 2001 From: Jean Paul Galea Date: Fri, 17 Jul 2015 00:42:42 +0200 Subject: [PATCH] Refactor. - unwrap getUTCTimeStamp() - use gmdate() instead of date_default_timezone_set('UTC') + date() --- ykval-common.php | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/ykval-common.php b/ykval-common.php index a4802ad..a6e1b21 100644 --- a/ykval-common.php +++ b/ykval-common.php @@ -80,14 +80,6 @@ function log_format() { return $str; } -// Return eg. 2008-11-21T06:11:55Z0711 -// -function getUTCTimeStamp() { - date_default_timezone_set('UTC'); - $tiny = substr(microtime(false), 2, 3); - return date('Y-m-d\TH:i:s\Z0', time()) . $tiny; -} - // Sign a http query string in the array of key-value pairs // return b64 encoded hmac hash function sign($a, $apiKey, $logger) { @@ -247,7 +239,12 @@ function KSMdecryptOTP($urls, $logger, $curlopts) { function sendResp($status, $logger, $apiKey = '', $extra = null) { $a['status'] = $status; - $a['t'] = getUTCTimeStamp(); + + // 2008-11-21T06:11:55Z0711 + $t = substr(microtime(false), 2, 3); + $t = gmdate('Y-m-d\TH:i:s\Z0', time()) . $t; + + $a['t'] = $t; if ($extra) foreach ($extra as $param => $value) @@ -266,7 +263,7 @@ function sendResp($status, $logger, $apiKey = '', $extra = null) { $str .= "status=" . $a['status'] . "\r\n"; $str .= "\r\n"; - $logger->log(LOG_INFO, "Response: " . $str . " (at " . date("c") . " " . microtime() . ")"); + $logger->log(LOG_INFO, "Response: " . $str . " (at " . gmdate("c") . " " . microtime() . ")"); echo $str; exit;