diff options
-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); |