summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--config.php-dist5
-rw-r--r--include/functions.php35
2 files changed, 22 insertions, 18 deletions
diff --git a/config.php-dist b/config.php-dist
index 7a076d976..f9cc181af 100644
--- a/config.php-dist
+++ b/config.php-dist
@@ -196,4 +196,9 @@
// Expected config version. Please update this option in config.php
// if necessary (after migrating all new options from this file).
+ define('PROXY', '');
+ // Connect to RSS feeds through a PROXY, this way tt-rss won't connect to
+ // webservers directly.
+ // Example format: '127.0.0.1:8123' (polipo proxy running on localhost)
+
// vim:ft=php
diff --git a/include/functions.php b/include/functions.php
index 649b77881..f58a2fc68 100644
--- a/include/functions.php
+++ b/include/functions.php
@@ -402,8 +402,8 @@
curl_setopt($ch, CURLOPT_COOKIEJAR, "/dev/null");
}
- if (defined('_CURL_HTTP_PROXY')) {
- curl_setopt($ch, CURLOPT_PROXY, _CURL_HTTP_PROXY);
+ if (defined('PROXY')) {
+ curl_setopt($ch, CURLOPT_PROXY, PROXY);
}
if ($post_query) {
@@ -483,25 +483,24 @@
// TODO: should this support POST requests or not? idk
+ $context_options = array(
+ 'http' => array(
+ 'method' => 'GET',
+ 'ignore_errors' => true,
+ 'timeout' => $timeout ? $timeout : FILE_FETCH_TIMEOUT,
+ 'protocol_version'=> 1.1)
+ );
+
if (!$post_query && $last_modified) {
- $context = stream_context_create(array(
- 'http' => array(
- 'method' => 'GET',
- 'ignore_errors' => true,
- 'timeout' => $timeout ? $timeout : FILE_FETCH_TIMEOUT,
- 'protocol_version'=> 1.1,
- 'header' => "If-Modified-Since: $last_modified\r\n")
- ));
- } else {
- $context = stream_context_create(array(
- 'http' => array(
- 'method' => 'GET',
- 'ignore_errors' => true,
- 'timeout' => $timeout ? $timeout : FILE_FETCH_TIMEOUT,
- 'protocol_version'=> 1.1
- )));
+ $context_options['http']['header'] = "If-Modified-Since: $last_modified\r\n";
}
+ if (defined('PROXY')) {
+ $context_options['http']['proxy'] = PROXY;
+ }
+
+ $context = stream_context_create($context_options);
+
$old_error = error_get_last();
$data = @file_get_contents($url, false, $context);