aboutsummaryrefslogtreecommitdiff
path: root/lib/favicons.php
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2019-10-31 18:15:47 +0100
committerGravatar GitHub <noreply@github.com> 2019-10-31 18:15:47 +0100
commit3aa66f317b496ccd9a2df914bbc747c52081a7ad (patch)
tree6a3f3f74899801abdca00546e213dfdc141c53cf /lib/favicons.php
parent82611c9622ed23b0e9fcf5f9f651ddffa1fd7706 (diff)
parentfcae48f313d399050cb15f37a8a73ae52fc67796 (diff)
Merge pull request #2599 from FreshRSS/dev1.15.0
FreshRSS 1.15
Diffstat (limited to 'lib/favicons.php')
-rw-r--r--lib/favicons.php19
1 files changed, 7 insertions, 12 deletions
diff --git a/lib/favicons.php b/lib/favicons.php
index 7a2d1187e..bc82b57b9 100644
--- a/lib/favicons.php
+++ b/lib/favicons.php
@@ -1,6 +1,6 @@
<?php
-$favicons_dir = DATA_PATH . '/favicons/';
-$default_favicon = PUBLIC_PATH . '/themes/icons/default_favicon.ico';
+const FAVICONS_DIR = DATA_PATH . '/favicons/';
+const DEFAULT_FAVICON = PUBLIC_PATH . '/themes/icons/default_favicon.ico';
function isImgMime($content) {
//Based on https://github.com/ArthurHoaro/favicon/blob/3a4f93da9bb24915b21771eb7873a21bde26f5d1/src/Favicon/Favicon.php#L311-L319
@@ -31,18 +31,14 @@ function downloadHttp(&$url, $curlOptions = array()) {
return '';
}
$ch = curl_init($url);
- curl_setopt_array($ch, array(
+ curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 15,
CURLOPT_USERAGENT => FRESHRSS_USERAGENT,
CURLOPT_MAXREDIRS => 10,
- ));
- if (version_compare(PHP_VERSION, '5.6.0') >= 0 || ini_get('open_basedir') == '') {
- curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); //Keep option separated for open_basedir PHP bug 65646
- }
- if (defined('CURLOPT_ENCODING')) {
- curl_setopt($ch, CURLOPT_ENCODING, ''); //Enable all encodings
- }
+ CURLOPT_FOLLOWLOCATION => true,
+ CURLOPT_ENCODING => '', //Enable all encodings
+ ]);
curl_setopt_array($ch, $curlOptions);
$response = curl_exec($ch);
$info = curl_getinfo($ch);
@@ -89,7 +85,6 @@ function searchFavicon(&$url) {
}
function download_favicon($url, $dest) {
- global $default_favicon;
$url = trim($url);
$favicon = searchFavicon($url);
if ($favicon == '') {
@@ -109,5 +104,5 @@ function download_favicon($url, $dest) {
}
}
return ($favicon != '' && file_put_contents($dest, $favicon)) ||
- @copy($default_favicon, $dest);
+ @copy(DEFAULT_FAVICON, $dest);
}