diff options
| author | 2017-03-04 11:55:47 +0100 | |
|---|---|---|
| committer | 2017-03-04 11:55:47 +0100 | |
| commit | 6bbe89e9bc5ae5adf3d163923faa03c9207bd9e2 (patch) | |
| tree | f14e842fbc320d3f3c1331dae62eb7e24aaf2517 /lib/Favicon/DataAccess.php | |
| parent | 29b4fbcf0abff1cff13b53d6b01e79e14de4c7f9 (diff) | |
| parent | 2818c72f5ae00276a083d0c24454394e9d064c7c (diff) | |
Merge pull request #1447 from Alkarex/CLI-bugs
Fix CLI bugs
Diffstat (limited to 'lib/Favicon/DataAccess.php')
| -rw-r--r-- | lib/Favicon/DataAccess.php | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/lib/Favicon/DataAccess.php b/lib/Favicon/DataAccess.php index ae7509881..4c1a29541 100644 --- a/lib/Favicon/DataAccess.php +++ b/lib/Favicon/DataAccess.php @@ -9,33 +9,33 @@ namespace Favicon; **/ class DataAccess { public function retrieveUrl($url) { - $this->set_context(); - return @file_get_contents($url); + $this->set_context(); + return @file_get_contents($url); } - + public function retrieveHeader($url) { - $this->set_context(); + $this->set_context(); $headers = @get_headers($url, 1); - return $headers ? array_change_key_case($headers) : array(); + return is_array($headers) ? array_change_key_case($headers) : array(); + } + + public function saveCache($file, $data) { + file_put_contents($file, $data); + } + + public function readCache($file) { + return file_get_contents($file); + } + + private function set_context() { + stream_context_set_default( + array( + 'http' => array( + 'method' => 'GET', + 'timeout' => 10, + 'header' => "User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:20.0; Favicon; +https://github.com/ArthurHoaro/favicon) Gecko/20100101 Firefox/32.0\r\n", + ) + ) + ); } - - public function saveCache($file, $data) { - file_put_contents($file, $data); - } - - public function readCache($file) { - return file_get_contents($file); - } - - private function set_context() { - stream_context_set_default( - array( - 'http' => array( - 'method' => 'GET', - 'timeout' => 10, - 'header' => "User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:20.0; Favicon; +https://github.com/ArthurHoaro/favicon) Gecko/20100101 Firefox/32.0\r\n", - ) - ) - ); - } -}
\ No newline at end of file +} |
