summaryrefslogtreecommitdiffstats
path: root/articleenhancer
diff options
context:
space:
mode:
authorBernhard Posselt <dev@bernhard-posselt.com>2014-04-10 19:15:31 +0200
committerBernhard Posselt <dev@bernhard-posselt.com>2014-04-10 19:15:31 +0200
commit5befce51ef9f38609b713cfbc6095a3b60b1d574 (patch)
tree0bbe540c109afa83086ed7ad43adb8a215e54633 /articleenhancer
parentdb545b430a513e7fda3fba5859972b6c550958b5 (diff)
add proxy support based on simplepie pr, fix #491
Diffstat (limited to 'articleenhancer')
-rw-r--r--articleenhancer/xpatharticleenhancer.php39
1 files changed, 32 insertions, 7 deletions
diff --git a/articleenhancer/xpatharticleenhancer.php b/articleenhancer/xpatharticleenhancer.php
index 50dc402cc..0d7589fec 100644
--- a/articleenhancer/xpatharticleenhancer.php
+++ b/articleenhancer/xpatharticleenhancer.php
@@ -36,6 +36,7 @@ class XPathArticleEnhancer implements ArticleEnhancer {
private $feedRegex;
private $fileFactory;
private $maximumTimeout;
+ private $config;
/**
@@ -50,6 +51,7 @@ class XPathArticleEnhancer implements ArticleEnhancer {
$this->regexXPathPair = $regexXPathPair;
$this->fileFactory = $fileFactory;
$this->maximumTimeout = $config->getFeedFetcherTimeout();
+ $this->config = $config;
}
@@ -58,13 +60,7 @@ class XPathArticleEnhancer implements ArticleEnhancer {
foreach($this->regexXPathPair as $regex => $search) {
if(preg_match($regex, $item->getUrl())) {
- $file = $this->fileFactory->getFile(
- $item->getUrl(),
- $this->maximumTimeout,
- 5,
- null,
- "Mozilla/5.0 AppleWebKit"
- );
+ $file = $this->getFile($item->getUrl());
// convert encoding by detecting charset from header
$contentType = $file->headers['content-type'];
@@ -98,6 +94,35 @@ class XPathArticleEnhancer implements ArticleEnhancer {
}
+ private function getFile($url) {
+ if(trim($this->config->getProxyHost()) === '') {
+ return $this->fileFactory->getFile(
+ $url,
+ $this->maximumTimeout,
+ 5,
+ null,
+ "Mozilla/5.0 AppleWebKit",
+ false,
+ null,
+ null,
+ null
+ );
+ } else {
+ return $this->fileFactory->getFile(
+ $url,
+ $this->maximumTimeout,
+ 5,
+ null,
+ "Mozilla/5.0 AppleWebKit",
+ false,
+ $this->config->getProxyHost(),
+ $this->config->getProxyPort(),
+ $this->config->getProxyAuth()
+ );
+ }
+ }
+
+
/**
* Method which converts all relative "href" and "src" URLs of
* a HTML snippet with their absolute equivalent