summaryrefslogtreecommitdiff
path: root/include/functions.php
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2013-03-30 15:10:53 +0400
committerAndrew Dolgov <[email protected]>2013-03-30 15:12:20 +0400
commit7a01dc776ed6e124eac9db1a288d4aa5ab63b53d (patch)
treef43605d9941de5b513c573d5aacd6ff0e4a37ffb /include/functions.php
parent60b88b254c16a25c56e7016c1ef889b1d3e15c8b (diff)
support If-Modified-Since
Diffstat (limited to 'include/functions.php')
-rw-r--r--include/functions.php11
1 files changed, 10 insertions, 1 deletions
diff --git a/include/functions.php b/include/functions.php
index 36d349b54..307f66200 100644
--- a/include/functions.php
+++ b/include/functions.php
@@ -6,6 +6,7 @@
define('PLUGIN_FEED_BASE_INDEX', -128);
$fetch_last_error = false;
+ $fetch_last_error_code = false;
$pluginhost = false;
function __autoload($class) {
@@ -287,9 +288,10 @@
}
}
- function fetch_file_contents($url, $type = false, $login = false, $pass = false, $post_query = false, $timeout = false) {
+ function fetch_file_contents($url, $type = false, $login = false, $pass = false, $post_query = false, $timeout = false, $timestamp = 0) {
global $fetch_last_error;
+ global $fetch_last_error_code;
if (function_exists('curl_init') && !ini_get("open_basedir")) {
@@ -299,6 +301,11 @@
$ch = curl_init($url);
}
+ if ($timestamp) {
+ curl_setopt($ch, CURLOPT_HTTPHEADER,
+ array("If-Modified-Since: ".gmdate('D, d M Y H:i:s \G\M\T', $timestamp)));
+ }
+
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout ? $timeout : 15);
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout ? $timeout : 45);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, !ini_get("safe_mode"));
@@ -335,6 +342,8 @@
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$content_type = curl_getinfo($ch, CURLINFO_CONTENT_TYPE);
+ $fetch_last_error_code = $http_code;
+
if ($http_code != 200 || $type && strpos($content_type, "$type") === false) {
if (curl_errno($ch) != 0) {
$fetch_last_error = curl_errno($ch) . " " . curl_error($ch);