summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobThree <rob@devcorner.nl>2017-02-17 15:21:31 +0100
committerRobThree <rob@devcorner.nl>2017-02-17 15:21:31 +0100
commitf90bc373198a9184e86a797fceb78687745cb540 (patch)
tree27a3bc22ea398848a02dfb90f8439d918ab2f7c5
parent0ebe1d69a6727cea0635402b8f09a6a0bd921ed2 (diff)
downloadTwoFactorAuth-f90bc373198a9184e86a797fceb78687745cb540.zip
TwoFactorAuth-f90bc373198a9184e86a797fceb78687745cb540.tar.gz
TwoFactorAuth-f90bc373198a9184e86a797fceb78687745cb540.tar.bz2
* You can now specify the expected time format returned by a 3rd party to the HttpTimeProvider.
-rw-r--r--lib/Providers/Time/HttpTimeProvider.php7
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/Providers/Time/HttpTimeProvider.php b/lib/Providers/Time/HttpTimeProvider.php
index 27982f1..c761bd9 100644
--- a/lib/Providers/Time/HttpTimeProvider.php
+++ b/lib/Providers/Time/HttpTimeProvider.php
@@ -9,11 +9,12 @@ class HttpTimeProvider implements ITimeProvider
{
public $url;
public $options;
+ public $expectedtimeformat;
- function __construct($url = 'https://google.com', array $options = null)
+ function __construct($url = 'https://google.com', $expectedtimeformat = 'D, d M Y H:i:s O+', array $options = null)
{
$this->url = $url;
-
+ $this->expectedtimeformat = $expectedtimeformat;
$this->options = $options;
if ($this->options === null) {
$this->options = array(
@@ -41,7 +42,7 @@ class HttpTimeProvider implements ITimeProvider
foreach ($headers['wrapper_data'] as $h) {
if (strcasecmp(substr($h, 0, 5), 'Date:') === 0)
- return \DateTime::createFromFormat('D, d M Y H:i:s O+', trim(substr($h,5)))->getTimestamp();
+ return \DateTime::createFromFormat($this->expectedtimeformat, trim(substr($h,5)))->getTimestamp();
}
throw new \TimeException(sprintf('Unable to retrieve time from %s (Invalid or no "Date:" header found)', $this->url));
}