diff options
author | RobThree <rob@devcorner.nl> | 2017-02-17 15:12:34 +0100 |
---|---|---|
committer | RobThree <rob@devcorner.nl> | 2017-02-17 15:12:34 +0100 |
commit | 78a2d6e5144c19d7b9afabc2eae5f474d162328e (patch) | |
tree | 03a6887c9248500adbf187b08255328724f9b43f | |
parent | 582a26749a2b100d77e9ef98d15f0799ea3930a4 (diff) | |
download | TwoFactorAuth-78a2d6e5144c19d7b9afabc2eae5f474d162328e.zip TwoFactorAuth-78a2d6e5144c19d7b9afabc2eae5f474d162328e.tar.gz TwoFactorAuth-78a2d6e5144c19d7b9afabc2eae5f474d162328e.tar.bz2 |
* Default stream options can now be overridden by specifying them in the constructor
* Removed some deprecated/stale code
-rw-r--r-- | lib/Providers/Time/HttpTimeProvider.php | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/lib/Providers/Time/HttpTimeProvider.php b/lib/Providers/Time/HttpTimeProvider.php index 2eaad80..243bba0 100644 --- a/lib/Providers/Time/HttpTimeProvider.php +++ b/lib/Providers/Time/HttpTimeProvider.php @@ -8,16 +8,15 @@ namespace RobThree\Auth\Providers\Time; class HttpTimeProvider implements ITimeProvider { public $url; + public $options; - function __construct($url = 'https://google.com') + function __construct($url = 'https://google.com', array $options = null) { $this->url = $url; - } - public function getTime() { - try { - $host = parse_url($this->url, PHP_URL_HOST); - $context = stream_context_create(array( + $this->options = $options; + if ($this->options === null) { + $this->options = array( 'http' => array( 'method' => 'HEAD', 'follow_location' => false, @@ -30,10 +29,15 @@ class HttpTimeProvider implements ITimeProvider ) ), 'ssl' => array( - 'SNI_enabled' => true, - 'peer_name' => $host + 'verify_peer' => true ) - )); + ); + } + } + + public function getTime() { + try { + $context = stream_context_create($this->options); $fd = fopen($this->url, 'rb', false, $context); $headers = stream_get_meta_data($fd); fclose($fd); |