From c798704b2901048e886966c6db4caed8d1b6130d Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sun, 20 Aug 2006 11:27:25 +0100 Subject: new option: USE_CURL_FOR_ICONS (closes #101), add some CRs to error messages --- functions.php | 61 +++++++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 40 insertions(+), 21 deletions(-) (limited to 'functions.php') diff --git a/functions.php b/functions.php index 99cea3e6f..6ed06898b 100644 --- a/functions.php +++ b/functions.php @@ -213,32 +213,51 @@ $icon_file = ICONS_DIR . "/$feed.ico"; if (!file_exists($icon_file)) { - - error_reporting(0); - $r = fopen($icon_url, "r"); - error_reporting (DEFAULT_ERROR_LEVEL); - if ($r) { - $tmpfname = tempnam(TMP_DIRECTORY, "ttrssicon"); - - $t = fopen($tmpfname, "w"); - - while (!feof($r)) { - $buf = fread($r, 16384); - fwrite($t, $buf); - } - - fclose($r); - fclose($t); + if (USE_CURL_FOR_ICONS) { + //error_reporting(0); + $ch = curl_init($icon_url); + $fp = fopen($icon_file, "w"); - error_reporting(0); - if (!rename($tmpfname, $icon_file)) { - unlink($tmpfname); + if ($fp) { + curl_setopt($ch, CURLOPT_FILE, $fp); + curl_setopt($ch, CURLOPT_FILE, $fp); + + curl_exec($ch); + curl_close($ch); + fclose($fp); } - chmod($icon_file, 0644); - + //error_reporting (DEFAULT_ERROR_LEVEL); + + } else { + + error_reporting(0); + $r = fopen($icon_url, "r"); error_reporting (DEFAULT_ERROR_LEVEL); + + if ($r) { + $tmpfname = tempnam(TMP_DIRECTORY, "ttrssicon"); + + $t = fopen($tmpfname, "w"); + + while (!feof($r)) { + $buf = fread($r, 16384); + fwrite($t, $buf); + } + + fclose($r); + fclose($t); + + error_reporting(0); + if (!rename($tmpfname, $icon_file)) { + unlink($tmpfname); + } + + chmod($icon_file, 0644); + + error_reporting (DEFAULT_ERROR_LEVEL); + } } } -- cgit v1.2.3