diff --git a/bridges/Gawker.php b/bridges/Gawker.php
index efb75d8..624e66d 100644
--- a/bridges/Gawker.php
+++ b/bridges/Gawker.php
@@ -31,10 +31,10 @@ class Gawker extends RssExpander{
trigger_error("If no site is provided, nothing is gonna happen", E_USER_ERROR);
} else {
$this->name = $param['site'];
- $param['url'] = $this->toURI(strtolower($param['site']));
+ $url = $this->toURI(strtolower($param['site']));
}
// $this->message("loading feed from ".$this->getURI());
- parent::collectExpandableDatas($param, $name);
+ parent::collectExpandableDatas($param, $url);
}
protected function parseRSSItem($newsItem) {
@@ -49,7 +49,7 @@ class Gawker extends RssExpander{
$articlePage = str_get_html($this->get_cached($item->uri));
if(is_object($articlePage)) {
$content = $articlePage->find('.post-content', 0);
- $this->defaultImageSrcTo($content, $this->getURI());
+ HTMLSanitizer::defaultImageSrcTo($content, $this->getURI());
$vcard = $articlePage->find('.vcard', 0);
if(is_object($vcard)) {
$authorLink = $vcard->find('a', 0);
diff --git a/bridges/WorldOfTanks.php b/bridges/WorldOfTanks.php
index c6dc7ef..adaf22c 100644
--- a/bridges/WorldOfTanks.php
+++ b/bridges/WorldOfTanks.php
@@ -86,7 +86,7 @@ class WorldOfTanks extends HttpCachingBridgeAbstract{
// $this->message("loading page ".$item->uri);
$articlePage = str_get_html($this->get_cached($item->uri));
$content = $articlePage->find('.l-content', 0);
- $this->defaultImageSrcTo($content, WORLD_OF_TANKS);
+ HTMLSanitizer::defaultImageSrcTo($content, WORLD_OF_TANKS);
$item->title = $content->find('h1', 0)->innertext;
$item->content = $content->find('.b-content', 0)->innertext;
// $item->name = $auteur->innertext;
diff --git a/index.php b/index.php
index 31e1e0b..a2546d6 100644
--- a/index.php
+++ b/index.php
@@ -11,6 +11,8 @@ TODO :
- implement header('X-Cached-Version: '.date(DATE_ATOM, filemtime($cachefile)));
*/
+//define('PROXY_URL', 'tcp://192.168.0.0:28');
+
date_default_timezone_set('UTC');
error_reporting(0);
//ini_set('display_errors','1'); error_reporting(E_ALL); // For debugging only.
@@ -21,6 +23,7 @@ if (!extension_loaded('openssl'))
// FIXME : beta test UA spoofing, please report any blacklisting by PHP-fopen-unfriendly websites
ini_set('user_agent', 'Mozilla/5.0 (X11; Linux x86_64; rv:30.0) Gecko/20121202 Firefox/30.0 (rss-bridge/0.1; +https://github.com/sebsauvage/rss-bridge)');
+
// -------
// cache file purge - delete cache files older than 24 hours
diff --git a/lib/Bridge.php b/lib/Bridge.php
index 6fb67b7..3a104a1 100644
--- a/lib/Bridge.php
+++ b/lib/Bridge.php
@@ -39,7 +39,7 @@ abstract class BridgeAbstract implements BridgeInterface{
}
/**
- * Return datas store in the bridge
+ * Return datas stored in the bridge
* @return mixed
*/
public function getDatas(){
@@ -50,7 +50,7 @@ abstract class BridgeAbstract implements BridgeInterface{
/**
* Defined datas with parameters depending choose bridge
- * Note : you can defined a cache before with "setCache"
+ * Note : you can define a cache before with "setCache"
* @param array $param $_REQUEST, $_GET, $_POST, or array with bridge expected paramters
*/
public function setDatas(array $param){
@@ -90,16 +90,6 @@ abstract class BridgeAbstract implements BridgeInterface{
return $this;
}
- /**
- * Set default image SRC attribute to point on given server when none is provided (that's to say when image src starts with '/'
- */
- public function defaultImageSrcTo($content, $server) {
- foreach($content->find('img') as $image) {
- if(strpos($image->src, '/')==0) {
- $image->src = $server.$image->src;
- }
- }
- }
}
/**
@@ -311,7 +301,7 @@ abstract class RssExpander extends HttpCachingBridgeAbstract{
public function collectExpandableDatas(array $param, $name){
if (empty($name)) {
- $this->returnError('There is no $param[\'url\'] for this RSS expander', 404);
+ $this->returnError('There is no $name for this RSS expander', 404);
}
// $this->message("Loading from ".$param['url']);
// Notice WE DO NOT use cache here on purpose : we want a fresh view of the RSS stream each time
@@ -363,3 +353,20 @@ abstract class RssExpander extends HttpCachingBridgeAbstract{
return $this->description;
}
}
+
+function advanced_file_get_contents($url) {
+
+ if(defined('PROXY_URL')) {
+ $context = array(
+ 'http' => array(
+ 'proxy' => PROXY_URL,
+ 'request_fulluri' => true,
+ ),
+ );
+ $context = stream_context_create($context);
+ return file_get_contents($url, false, $context);
+ } else {
+ return file_get_contents($url);
+ }
+
+}
diff --git a/lib/HTMLUtils.php b/lib/HTMLUtils.php
index ff25130..9f09723 100644
--- a/lib/HTMLUtils.php
+++ b/lib/HTMLUtils.php
@@ -91,7 +91,7 @@ CARD;
} else if($inputEntry['type'] == 'number') {
$card .= '
' . PHP_EOL;
} else if($inputEntry['type'] == 'list') {
- $card .= '