From fbf17beae897644d6900fc984d3e1a521db5a498 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Mazi=C3=A8re?= Date: Wed, 24 Aug 2016 23:40:47 +0200 Subject: [PATCH 01/22] [Arte7Bridge] extract nested function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Pierre Mazière --- bridges/Arte7Bridge.php | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/bridges/Arte7Bridge.php b/bridges/Arte7Bridge.php index 70c04e4a..4fe92bac 100644 --- a/bridges/Arte7Bridge.php +++ b/bridges/Arte7Bridge.php @@ -45,35 +45,30 @@ class Arte7Bridge extends BridgeAbstract{ ); } - - public function collectData(array $param){ - - function extractVideoset($category='toutes-les-videos', $lang='fr') - { - $url = 'http://www.arte.tv/guide/'.$lang.'/plus7/'.$category; - $input = $this->getContents($url) or die('Could not request ARTE.'); - if(strpos($input, 'categoryVideoSet') !== FALSE) - { + protected function extractVideoset($category='toutes-les-videos', $lang='fr'){ + $url = 'http://www.arte.tv/guide/'.$lang.'/plus7/'.$category; + $input = $this->getContents($url) or die('Could not request ARTE.'); + if(strpos($input, 'categoryVideoSet') !== FALSE){ $input = explode('categoryVideoSet: ', $input); $input = explode('}},', $input[1]); $input = $input[0].'}}'; - } - else - { + }else{ $input = explode('videoSet: ', $input); $input = explode('}]},', $input[1]); $input = $input[0].'}]}'; - } - $input = json_decode($input, TRUE); - return $input; - } + } + $input = json_decode($input, TRUE); + return $input; + } + + public function collectData(array $param){ $category='toutes-les-videos'; $lang='fr'; if (!empty($param['catfr'])) $category=$param['catfr']; if (!empty($param['catde'])) { $category=$param['catde']; $lang='de'; } - $input_json = extractVideoset($category, $lang); + $input_json = $this->extractVideoset($category, $lang); foreach($input_json['videos'] as $element) { $item = array(); From 5b32050a6ef5b4dfddcd1f6a50e8e3b3e8f3003a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Mazi=C3=A8re?= Date: Wed, 24 Aug 2016 23:41:33 +0200 Subject: [PATCH 02/22] [AskfmBridge] fix parameter 'u' requirement status MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Pierre Mazière --- bridges/AskfmBridge.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bridges/AskfmBridge.php b/bridges/AskfmBridge.php index 6ad74669..ac1d0493 100644 --- a/bridges/AskfmBridge.php +++ b/bridges/AskfmBridge.php @@ -10,7 +10,8 @@ class AskfmBridge extends BridgeAbstract{ $this->parameters["Ask.fm username"] = array( 'u'=>array( - 'name'=>'Username' + 'name'=>'Username', + 'required'=>true ) ); } From d530415481986741ca3a5ce30275aaf148684a5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Mazi=C3=A8re?= Date: Thu, 25 Aug 2016 00:11:24 +0200 Subject: [PATCH 03/22] [CpasbienBridge] use SimpleHTMLDOM str_get_html function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Pierre Mazière --- bridges/CpasbienBridge.php | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/bridges/CpasbienBridge.php b/bridges/CpasbienBridge.php index 1f470454..6c3b7859 100644 --- a/bridges/CpasbienBridge.php +++ b/bridges/CpasbienBridge.php @@ -1,19 +1,4 @@ MAX_FILE_SIZE) - { - return false; - } - // The second parameter can force the selectors to all be lowercase. - $dom->load($contents, $lowercase, $stripRN); - return $dom; -} - class CpasbienBridge extends HttpCachingBridgeAbstract{ private $request; @@ -51,7 +36,7 @@ class CpasbienBridge extends HttpCachingBridgeAbstract{ if ($episode->getAttribute('class')=='ligne0' || $episode->getAttribute('class')=='ligne1') { - $htmlepisode=content_get_html($this->get_cached($episode->find('a', 0)->getAttribute('href'))); + $htmlepisode=str_get_html($this->get_cached($episode->find('a', 0)->getAttribute('href'))); $item = array(); $item['author'] = $episode->find('a', 0)->text(); From b9207841ccdf16073ec8d94884ac30a5eab4d91c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Mazi=C3=A8re?= Date: Thu, 25 Aug 2016 00:12:33 +0200 Subject: [PATCH 04/22] [CpasbienBridge] fix unhandled case MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Pierre Mazière --- bridges/CpasbienBridge.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bridges/CpasbienBridge.php b/bridges/CpasbienBridge.php index 6c3b7859..4772e599 100644 --- a/bridges/CpasbienBridge.php +++ b/bridges/CpasbienBridge.php @@ -47,7 +47,10 @@ class CpasbienBridge extends HttpCachingBridgeAbstract{ $item['content'] = $textefiche->text(); } else { - $item['content'] = $htmlepisode->find('#textefiche', 0)->find('p',0)->text(); + $p=$htmlepisode->find('#textefiche',0)->find('p'); + if(!empty($p)){ + $item['content'] = $htmlepisode->find('#textefiche', 0)->find('p',0)->text(); + } } $item['id'] = $episode->find('a', 0)->getAttribute('href'); From 6dd45eae579b26669b255fefc38738405ca6947a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Mazi=C3=A8re?= Date: Thu, 25 Aug 2016 00:19:41 +0200 Subject: [PATCH 05/22] [DailymotionBridge] fix parameters 'p' and 's' requirement status MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Pierre Mazière --- bridges/DailymotionBridge.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/bridges/DailymotionBridge.php b/bridges/DailymotionBridge.php index ead37636..89b4cb33 100644 --- a/bridges/DailymotionBridge.php +++ b/bridges/DailymotionBridge.php @@ -17,11 +17,16 @@ class DailymotionBridge extends BridgeAbstract{ $this->parameters["By playlist id"] = array( 'p'=>array( 'name'=>'playlist id', - 'type'=>'text') + 'type'=>'text', + 'required'=>true + ) ); $this->parameters["From search results"] = array( - 's'=>array('name'=>'Search keyword'), + 's'=>array( + 'name'=>'Search keyword', + 'required'=>true + ), 'pa'=>array( 'name'=>'Page', 'type'=>'number' From 946a0744ed6da6ef313537756c87ac204ae48d16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Mazi=C3=A8re?= Date: Thu, 25 Aug 2016 00:33:25 +0200 Subject: [PATCH 06/22] [GiphyBridge] merge parameters context MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Pierre Mazière --- bridges/GiphyBridge.php | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/bridges/GiphyBridge.php b/bridges/GiphyBridge.php index 16c8f8c8..0ad0f910 100644 --- a/bridges/GiphyBridge.php +++ b/bridges/GiphyBridge.php @@ -10,16 +10,14 @@ class GiphyBridge extends BridgeAbstract{ $this->uri = "http://giphy.com/"; $this->description = "Bridge for giphy.com"; - $this->parameters["By tag"] = array( - 's'=>array('name'=>'search tag') + $this->parameters[] = array( + 's'=>array('name'=>'search tag'), + 'n'=>array( + 'name'=>'max number of returned items', + 'type'=>'number' + ) ); - $this->parameters["Without tag"] = array( - 'n'=>array( - 'name'=>'max number of returned items', - 'type'=>'number' - ) - ); } public function collectData(array $param){ From ca9879fac999e3b2c9c57a3b1cc650805a98ee20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Mazi=C3=A8re?= Date: Thu, 25 Aug 2016 00:45:20 +0200 Subject: [PATCH 07/22] [GooglePlusPostBridge] fix parameter 'username' requirement status MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Pierre Mazière --- bridges/GooglePlusPostBridge.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bridges/GooglePlusPostBridge.php b/bridges/GooglePlusPostBridge.php index 2b35c9ba..46d74ac0 100644 --- a/bridges/GooglePlusPostBridge.php +++ b/bridges/GooglePlusPostBridge.php @@ -12,7 +12,10 @@ class GooglePlusPostBridge extends BridgeAbstract $this->description = "Returns user public post (without API)."; $this->parameters[] = array( - 'username'=>array('name'=>'username or Id') + 'username'=>array( + 'name'=>'username or Id', + 'required'=>true + ) ); } From 70a8b88b6f48aaa13fe493519cce9265d39d9a68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Mazi=C3=A8re?= Date: Thu, 25 Aug 2016 00:47:52 +0200 Subject: [PATCH 08/22] [IdenticaBridge] fix parameter 'u' requirement status MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Pierre Mazière --- bridges/IdenticaBridge.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bridges/IdenticaBridge.php b/bridges/IdenticaBridge.php index 0a6d8be5..64f5a6c7 100644 --- a/bridges/IdenticaBridge.php +++ b/bridges/IdenticaBridge.php @@ -11,7 +11,10 @@ class IdenticaBridge extends BridgeAbstract{ $this->description = "Returns user timelines"; $this->parameters[] = array( - 'u'=>array('name'=>'username') + 'u'=>array( + 'name'=>'username', + 'required'=>true + ) ); } From 1bb94aecc6bf60c02307d40c2f3a8766083fa27e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Mazi=C3=A8re?= Date: Thu, 25 Aug 2016 01:07:49 +0200 Subject: [PATCH 09/22] [core] leave $_REQUEST alone MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Pierre Mazière --- index.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/index.php b/index.php index 25f5b549..e3071341 100644 --- a/index.php +++ b/index.php @@ -94,8 +94,6 @@ try{ $action=filter_input(INPUT_GET,'action'); $bridge=filter_input(INPUT_GET,'bridge'); if($action === 'display' && !empty($bridge)){ - unset($_REQUEST['action']); - unset($_REQUEST['bridge']); // DEPRECATED: 'nameBridge' scheme is replaced by 'name' in bridge parameter values // this is to keep compatibility until futher complete removal if(($pos=strpos($bridge,'Bridge'))===(strlen($bridge)-strlen('Bridge'))){ @@ -103,7 +101,6 @@ try{ } $format = filter_input(INPUT_GET,'format'); - unset($_REQUEST['format']); // DEPRECATED: 'nameFormat' scheme is replaced by 'name' in format parameter values // this is to keep compatibility until futher complete removal if(($pos=strpos($format,'Format'))===(strlen($format)-strlen('Format'))){ @@ -130,7 +127,12 @@ try{ $bridge->useProxy=false; } $bridge->loadMetadatas(); - $bridge->setDatas($_REQUEST); + $params=$_REQUEST; + unset($params['action']); + unset($params['bridge']); + unset($params['format']); + unset($params['_noproxy']); + $bridge->setDatas($params); // Data transformation try { $format = Format::create($format); From dea37c8e34c1f7ad558359f9fc6988f915540eea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Mazi=C3=A8re?= Date: Thu, 25 Aug 2016 01:20:12 +0200 Subject: [PATCH 10/22] [core] use BridgeAbstract::parameters to sanitize inputs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This should result in a lot of simplifications in the bridges since data validation is now done upstream. Signed-off-by: Pierre Mazière --- lib/Bridge.php | 65 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 63 insertions(+), 2 deletions(-) diff --git a/lib/Bridge.php b/lib/Bridge.php index 41c71a9b..c5843fcb 100644 --- a/lib/Bridge.php +++ b/lib/Bridge.php @@ -142,11 +142,69 @@ abstract class BridgeAbstract implements BridgeInterface { return $this->items; } + protected function validateData(&$data){ + $validated=true; + foreach($data as $name=>$value){ + foreach($this->parameters as $context=>$set){ + if(array_key_exists($name,$set)){ + if(!isset($set[$name]['type'])){ + $set[$name]['type']='text'; + } + switch($set[$name]['type']){ + case 'number': + $data[$name]=filter_var($value,FILTER_VALIDATE_INT); + if($data[$name]===false && !empty($value)){ + $validated=false; + } + break; + case 'checkbox': + $data[$name]=filter_var($value,FILTER_VALIDATE_BOOLEAN, + FILTER_NULL_ON_FAILURE); + if(is_null($data[$name])){ + $validated=false; + } + break; + case 'list': + $data[$name]=filter_var($value); + if(!in_array($value,$set[$name]['values'])){ + foreach($set[$name]['values'] as $subName=>$subValue){ + if(is_array($subValue) && + in_array($value,$subValue)){ + $data[$name]=filter_var($value); + break 2; + } + } + $validated=false; + $data[$name]=null; + } + break; + default: + case'text': + if(isset($set[$name]['pattern'])){ + $data[$name]=filter_var($value,FILTER_VALIDATE_REGEXP, + array('options'=>array( + 'regexp'=>'/^'.$set[$name]['pattern'].'$/' + )) + ); + }else{ + $data[$name]=filter_var($value); + } + if($data[$name]===false && !empty($value)){ + $validated=false; + } + break; + } + } + } + } + + return $validated; + } + /** * Defined datas with parameters depending choose bridge * Note : you can define a cache with "setCache" - * @param array $param $_REQUEST, $_GET, $_POST, or array with expected - * bridge paramters + * @param array array with expected bridge paramters */ public function setDatas(array $param){ if(!is_null($this->cache)){ @@ -159,6 +217,9 @@ abstract class BridgeAbstract implements BridgeInterface { if($time !== false && (time() - $this->getCacheDuration() < $time)){ $this->items = $this->cache->loadData(); } else { + if(!$this->validateData($param)){ + $this->returnClientError('Invalid parameters value(s)'); + } $this->collectData($param); if(!is_null($this->cache)){ From 117031bf0f4c15311a4a687237479eba3421ab97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Mazi=C3=A8re?= Date: Thu, 25 Aug 2016 01:24:53 +0200 Subject: [PATCH 11/22] [core] store parameters values in BridgeAbstract::parameters MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This way, any BridgeAbstract method can now have access to these values, no only collectData Signed-off-by: Pierre Mazière --- bridges/ABCTabsBridge.php | 2 +- bridges/AcrimedBridge.php | 3 +- bridges/AllocineFRBridge.php | 7 +-- bridges/AnimeUltimeBridge.php | 9 ++-- bridges/ArstechnicaBridge.php | 2 +- bridges/Arte7Bridge.php | 11 +++-- bridges/AskfmBridge.php | 7 +-- bridges/BandcampBridge.php | 7 +-- bridges/BastaBridge.php | 2 +- bridges/BlaguesDeMerdeBridge.php | 2 +- bridges/BooruprojectBridge.php | 19 ++++---- bridges/CADBridge.php | 2 +- bridges/CNETBridge.php | 7 +-- bridges/CastorusBridge.php | 11 +++-- bridges/CollegeDeFranceBridge.php | 2 +- bridges/CommonDreamsBridge.php | 2 +- bridges/CopieDoubleBridge.php | 2 +- bridges/CourrierInternationalBridge.php | 2 +- bridges/CpasbienBridge.php | 7 +-- bridges/CryptomeBridge.php | 7 +-- bridges/DailymotionBridge.php | 15 +++--- bridges/DanbooruBridge.php | 11 +++-- bridges/DansTonChatBridge.php | 2 +- bridges/DauphineLibereBridge.php | 7 +-- bridges/DemoBridge.php | 2 +- bridges/DeveloppezDotComBridge.php | 2 +- bridges/DilbertBridge.php | 2 +- bridges/DollbooruBridge.php | 11 +++-- bridges/DuckDuckGoBridge.php | 5 +- bridges/EZTVBridge.php | 7 +-- bridges/EliteDangerousGalnetBridge.php | 2 +- bridges/ElsevierBridge.php | 7 +-- bridges/EstCeQuonMetEnProdBridge.php | 2 +- bridges/FacebookBridge.php | 17 +++---- bridges/FierPandaBridge.php | 2 +- bridges/FlickrExploreBridge.php | 2 +- bridges/FlickrTagBridge.php | 11 +++-- bridges/FootitoBridge.php | 2 +- bridges/FourchanBridge.php | 7 +-- bridges/FreenewsBridge.php | 3 +- bridges/FuturaSciencesBridge.php | 9 ++-- bridges/GBAtempBridge.php | 9 ++-- bridges/GawkerBridge.php | 9 ++-- bridges/GelbooruBridge.php | 11 +++-- bridges/GiphyBridge.php | 13 ++--- bridges/GithubIssueBridge.php | 9 ++-- bridges/GitlabCommitsBridge.php | 15 +++--- bridges/GizmodoFRBridge.php | 2 +- bridges/GooglePlusPostBridge.php | 6 +-- bridges/GoogleSearchBridge.php | 7 +-- bridges/GuruMedBridge.php | 2 +- bridges/HDWallpapersBridge.php | 9 ++-- bridges/HentaiHavenBridge.php | 2 +- bridges/IdenticaBridge.php | 9 ++-- bridges/InstagramBridge.php | 7 +-- bridges/IsoHuntBridge.php | 23 ++++----- bridges/JapanExpoBridge.php | 5 +- bridges/KonachanBridge.php | 11 +++-- bridges/KoreusBridge.php | 2 +- bridges/KununuBridge.php | 11 +++-- bridges/LWNprevBridge.php | 2 +- bridges/LeBonCoinBridge.php | 9 ++-- bridges/LeJournalDuGeekBridge.php | 2 +- bridges/LeMondeInformatiqueBridge.php | 2 +- bridges/Les400CulsBridge.php | 3 +- bridges/LesJoiesDuCodeBridge.php | 2 +- bridges/LichessBridge.php | 2 +- bridges/LinkedInCompany.php | 5 +- bridges/LolibooruBridge.php | 11 +++-- bridges/MangareaderBridge.php | 17 +++---- bridges/MilbooruBridge.php | 11 +++-- bridges/MondeDiploBridge.php | 2 +- bridges/MsnMondeBridge.php | 2 +- bridges/MspabooruBridge.php | 11 +++-- bridges/NakedSecurityBridge.php | 2 +- bridges/NasaApodBridge.php | 2 +- bridges/NeuviemeArtBridge.php | 2 +- bridges/NextInpactBridge.php | 2 +- bridges/NextgovBridge.php | 5 +- bridges/NiceMatinBridge.php | 2 +- bridges/NovelUpdatesBridge.php | 7 +-- bridges/NumeramaBridge.php | 2 +- bridges/OpenClassroomsBridge.php | 7 +-- bridges/ParuVenduImmoBridge.php | 22 ++++----- bridges/PickyWallpapersBridge.php | 13 ++--- bridges/PinterestBridge.php | 17 +++---- bridges/PlanetLibreBridge.php | 2 +- bridges/ProjectMGameBridge.php | 2 +- bridges/RTBFBridge.php | 7 +-- bridges/Releases3DSBridge.php | 2 +- bridges/ReporterreBridge.php | 2 +- bridges/Rue89Bridge.php | 2 +- bridges/Rule34Bridge.php | 11 +++-- bridges/Rule34pahealBridge.php | 11 +++-- bridges/SafebooruBridge.php | 11 +++-- bridges/SakugabooruBridge.php | 11 +++-- bridges/ScmbBridge.php | 2 +- bridges/ScoopItBridge.php | 7 +-- bridges/SensCritiqueBridge.php | 15 +++--- bridges/Sexactu.php | 2 +- bridges/ShanaprojectBridge.php | 2 +- bridges/SiliconBridge.php | 2 +- bridges/SoundcloudBridge.php | 7 +-- bridges/StripeAPIChangeLogBridge.php | 2 +- bridges/SuperbWallpapersBridge.php | 9 ++-- bridges/T411Bridge.php | 7 +-- bridges/TagBoardBridge.php | 5 +- bridges/TbibBridge.php | 11 +++-- bridges/TheCodingLoveBridge.php | 2 +- bridges/TheHackerNewsBridge.php | 2 +- bridges/TheOatMealBridge.php | 3 +- bridges/ThePirateBayBridge.php | 7 +-- bridges/TwitchApiBridge.php | 21 ++++---- bridges/TwitterBridge.php | 15 +++--- bridges/UnsplashBridge.php | 9 ++-- bridges/ViadeoCompany.php | 5 +- bridges/VineBridge.php | 5 +- bridges/VkBridge.php | 7 +-- bridges/WallpaperStopBridge.php | 13 ++--- bridges/WeLiveSecurityBridge.php | 2 +- bridges/WhydBridge.php | 7 +-- bridges/WikipediaBridge.php | 27 ++++++----- bridges/WordPressBridge.php | 5 +- bridges/WorldOfTanksBridge.php | 11 +++-- bridges/XbooruBridge.php | 11 +++-- bridges/YandereBridge.php | 11 +++-- bridges/YoutubeBridge.php | 19 ++++---- bridges/ZDNetBridge.php | 5 +- bridges/ZatazBridge.php | 2 +- bridges/ZoneTelechargementBridge.php | 7 +-- lib/Bridge.php | 64 +++++++++++++++++++++++-- 131 files changed, 548 insertions(+), 411 deletions(-) diff --git a/bridges/ABCTabsBridge.php b/bridges/ABCTabsBridge.php index 8926102f..6031d316 100644 --- a/bridges/ABCTabsBridge.php +++ b/bridges/ABCTabsBridge.php @@ -12,7 +12,7 @@ class ABCTabsBridge extends BridgeAbstract{ } - public function collectData(array $param){ + public function collectData(){ $html = ''; $html = $this->getSimpleHTMLDOM('http://www.abc-tabs.com/tablatures/nouveautes.html') or $this->returnClientError('No results for this query.'); $table = $html->find('table#myTable', 0)->children(1); diff --git a/bridges/AcrimedBridge.php b/bridges/AcrimedBridge.php index 6446dc36..c84544c2 100644 --- a/bridges/AcrimedBridge.php +++ b/bridges/AcrimedBridge.php @@ -10,7 +10,8 @@ class AcrimedBridge extends RssExpander{ } - public function collectData(array $param){ + public function collectData(){ + $param=$this->parameters[$this->queriedContext]; parent::collectExpandableDatas($param, "http://www.acrimed.org/spip.php?page=backend"); diff --git a/bridges/AllocineFRBridge.php b/bridges/AllocineFRBridge.php index b1a20274..c9c0f0f8 100644 --- a/bridges/AllocineFRBridge.php +++ b/bridges/AllocineFRBridge.php @@ -24,14 +24,15 @@ class AllocineFRBridge extends BridgeAbstract{ ); } - public function collectData(array $params){ + public function collectData(){ + $params=$this->parameters[$this->queriedContext]; // Check all parameters - if(!isset($params['category'])) + if(!isset($params['category']['value'])) $this->returnClientError('You must specify a valid category (&category= )!'); $category = ''; - switch($params['category']){ + switch($params['category']['value']){ case 'faux-raccord': $this->uri = 'http://www.allocine.fr/video/programme-12284/saison-24580/'; $category = 'Faux Raccord'; diff --git a/bridges/AnimeUltimeBridge.php b/bridges/AnimeUltimeBridge.php index c84ae09f..3f0370c7 100644 --- a/bridges/AnimeUltimeBridge.php +++ b/bridges/AnimeUltimeBridge.php @@ -24,13 +24,14 @@ class AnimeUltimeBridge extends BridgeAbstract { ); } - public function collectData(array $param) { + public function collectData(){ + $param=$this->parameters[$this->queriedContext]; //Add type filter if provided $typeFilter = ''; - if (!empty($param['type'])) { - if ($param['type'] == 'A' || $param['type'] == 'D' || $param['type'] == 'T') { - $typeFilter = $param['type']; + if (!empty($param['type']['value'])) { + if ($param['type']['value'] == 'A' || $param['type']['value'] == 'D' || $param['type']['value'] == 'T') { + $typeFilter = $param['type']['value']; if ($typeFilter == 'A') { $this->filter = 'Anime'; } if ($typeFilter == 'D') { $this->filter = 'Drama'; } if ($typeFilter == 'T') { $this->filter = 'Tokusatsu'; } diff --git a/bridges/ArstechnicaBridge.php b/bridges/ArstechnicaBridge.php index 95ad6788..6c5521f4 100644 --- a/bridges/ArstechnicaBridge.php +++ b/bridges/ArstechnicaBridge.php @@ -42,7 +42,7 @@ class ArstechnicaBridge extends BridgeAbstract { return $text; } - public function collectData(array $param) { + public function collectData(){ $html = $this->getSimpleHTMLDOM('http://feeds.arstechnica.com/arstechnica/index') or $this->returnServerError('Could not request NextInpact.'); $limit = 0; diff --git a/bridges/Arte7Bridge.php b/bridges/Arte7Bridge.php index 4fe92bac..bc8725bd 100644 --- a/bridges/Arte7Bridge.php +++ b/bridges/Arte7Bridge.php @@ -61,13 +61,14 @@ class Arte7Bridge extends BridgeAbstract{ return $input; } - public function collectData(array $param){ + public function collectData(){ + $param=$this->parameters[$this->queriedContext]; $category='toutes-les-videos'; $lang='fr'; - if (!empty($param['catfr'])) - $category=$param['catfr']; - if (!empty($param['catde'])) - { $category=$param['catde']; $lang='de'; } + if (!empty($param['catfr']['value'])) + $category=$param['catfr']['value']; + if (!empty($param['catde']['value'])) + { $category=$param['catde']['value']; $lang='de'; } $input_json = $this->extractVideoset($category, $lang); foreach($input_json['videos'] as $element) { diff --git a/bridges/AskfmBridge.php b/bridges/AskfmBridge.php index ac1d0493..0ff36556 100644 --- a/bridges/AskfmBridge.php +++ b/bridges/AskfmBridge.php @@ -16,10 +16,11 @@ class AskfmBridge extends BridgeAbstract{ ); } - public function collectData(array $param){ + public function collectData(){ + $param=$this->parameters[$this->queriedContext]; $html = ''; - if (isset($param['u'])) { - $this->request = $param['u']; + if (isset($param['u']['value'])) { + $this->request = $param['u']['value']; $html = $this->getSimpleHTMLDOM('http://ask.fm/'.urlencode($this->request).'/answers/more?page=0') or $this->returnServerError('Requested username can\'t be found.'); } else { diff --git a/bridges/BandcampBridge.php b/bridges/BandcampBridge.php index 87a69183..b9dbaa27 100644 --- a/bridges/BandcampBridge.php +++ b/bridges/BandcampBridge.php @@ -18,10 +18,11 @@ class BandcampBridge extends BridgeAbstract{ ); } - public function collectData(array $param){ + public function collectData(){ + $param=$this->parameters[$this->queriedContext]; $html = ''; - if (isset($param['tag'])) { - $this->request = $param['tag']; + if (isset($param['tag']['value'])) { + $this->request = $param['tag']['value']; $html = $this->getSimpleHTMLDOM('http://bandcamp.com/tag/'.urlencode($this->request).'?sort_field=date') or $this->returnServerError('No results for this query.'); } else { diff --git a/bridges/BastaBridge.php b/bridges/BastaBridge.php index 32758c18..ec46b5f9 100644 --- a/bridges/BastaBridge.php +++ b/bridges/BastaBridge.php @@ -7,7 +7,7 @@ class BastaBridge extends BridgeAbstract{ $this->description = "Returns the newest articles."; } - public function collectData(array $param){ + public function collectData(){ // Replaces all relative image URLs by absolute URLs. Relative URLs always start with 'local/'! function ReplaceImageUrl($content){ return preg_replace('/src=["\']{1}([^"\']+)/ims', 'src=\'http://www.bastamag.net/$1\'', $content); diff --git a/bridges/BlaguesDeMerdeBridge.php b/bridges/BlaguesDeMerdeBridge.php index c137201b..0f32467d 100644 --- a/bridges/BlaguesDeMerdeBridge.php +++ b/bridges/BlaguesDeMerdeBridge.php @@ -10,7 +10,7 @@ class BlaguesDeMerdeBridge extends BridgeAbstract{ } - public function collectData(array $param){ + public function collectData(){ $html = $this->getSimpleHTMLDOM('http://www.blaguesdemerde.fr/') or $this->returnServerError('Could not request BDM.'); foreach($html->find('article.joke_contener') as $element) { diff --git a/bridges/BooruprojectBridge.php b/bridges/BooruprojectBridge.php index 972ab7bf..a4e3aeb4 100644 --- a/bridges/BooruprojectBridge.php +++ b/bridges/BooruprojectBridge.php @@ -19,29 +19,30 @@ class BooruprojectBridge extends BridgeAbstract{ } - public function collectData(array $param){ + public function collectData(){ + $param=$this->parameters[$this->queriedContext]; $page = 0; $tags = ''; - if (!empty($param['p'])) { - $page = (int)preg_replace("/[^0-9]/",'', $param['p']); + if (!empty($param['p']['value'])) { + $page = (int)preg_replace("/[^0-9]/",'', $param['p']['value']); $page = $page - 1; $page = $page * 20; } - if (!empty($param['t'])) { - $tags = '&tags='.urlencode($param['t']); + if (!empty($param['t']['value'])) { + $tags = '&tags='.urlencode($param['t']['value']); } - if (empty($param['i'])) { + if (empty($param['i']['value'])) { $this->returnServerError('Please enter a ***.booru.org instance.'); } - $html = $this->getSimpleHTMLDOM("http://".$param['i'].".booru.org/index.php?page=post&s=list&pid=".$page.$tags) or $this->returnServerError('Could not request Booruproject.'); + $html = $this->getSimpleHTMLDOM("http://".$param['i']['value'].".booru.org/index.php?page=post&s=list&pid=".$page.$tags) or $this->returnServerError('Could not request Booruproject.'); foreach($html->find('div[class=content] span') as $element) { $item = array(); - $item['uri'] = 'http://'.$param['i'].'.booru.org/'.$element->find('a', 0)->href; + $item['uri'] = 'http://'.$param['i']['value'].'.booru.org/'.$element->find('a', 0)->href; $item['postid'] = (int)preg_replace("/[^0-9]/",'', $element->find('a', 0)->getAttribute('id')); $item['timestamp'] = time(); $item['tags'] = $element->find('img', 0)->getAttribute('title'); - $item['title'] = 'Booruproject '.$param['i'].' | '.$item['postid']; + $item['title'] = 'Booruproject '.$param['i']['value'].' | '.$item['postid']; $item['content'] = '
Tags: '.$item['tags']; $this->items[] = $item; } diff --git a/bridges/CADBridge.php b/bridges/CADBridge.php index d3d191ef..4c695f06 100644 --- a/bridges/CADBridge.php +++ b/bridges/CADBridge.php @@ -34,7 +34,7 @@ class CADBridge extends BridgeAbstract{ return ''; } - public function collectData(array $param){ + public function collectData(){ function CADUrl($string) { $html2 = explode("\"", $string); $string = $html2[1]; diff --git a/bridges/CNETBridge.php b/bridges/CNETBridge.php index 623a9fd6..2fbed359 100644 --- a/bridges/CNETBridge.php +++ b/bridges/CNETBridge.php @@ -15,7 +15,8 @@ class CNETBridge extends BridgeAbstract { ); } - public function collectData(array $param) { + public function collectData(){ + $param=$this->parameters[$this->queriedContext]; function ExtractFromDelimiters($string, $start, $end) { if (strpos($string, $start) !== false) { @@ -42,8 +43,8 @@ class CNETBridge extends BridgeAbstract { return $article_html; } - if (!empty($param['topic'])) - $this->topicName = $param['topic']; + if (!empty($param['topic']['value'])) + $this->topicName = $param['topic']['value']; $pageUrl = 'http://www.cnet.com/'.(empty($this->topicName) ? '' : 'topics/'.$this->topicName.'/'); $html = $this->getSimpleHTMLDOM($pageUrl) or $this->returnServerError('Could not request CNET: '.$pageUrl); diff --git a/bridges/CastorusBridge.php b/bridges/CastorusBridge.php index a682ae0a..73e8a1af 100644 --- a/bridges/CastorusBridge.php +++ b/bridges/CastorusBridge.php @@ -73,12 +73,13 @@ class CastorusBridge extends BridgeAbstract { return $price->innertext; } - public function collectData(array $params){ - if(isset($params['zip'])) - $zip_filter = trim($params['zip']); + public function collectData(){ + $params=$this->parameters[$this->queriedContext]; + if(isset($params['zip']['value'])) + $zip_filter = trim($params['zip']['value']); - if(isset($params['city'])) - $city_filter = trim($params['city']); + if(isset($params['city']['value'])) + $city_filter = trim($params['city']['value']); $html = $this->getSimpleHTMLDOM($this->uri); diff --git a/bridges/CollegeDeFranceBridge.php b/bridges/CollegeDeFranceBridge.php index d9b7266c..241e6f38 100644 --- a/bridges/CollegeDeFranceBridge.php +++ b/bridges/CollegeDeFranceBridge.php @@ -8,7 +8,7 @@ class CollegeDeFranceBridge extends BridgeAbstract{ $this->description = "Returns the latest audio and video from CollegeDeFrance"; } - public function collectData(array $param) { + public function collectData(){ $months = array( '01' => 'janv.', '02' => 'févr.', diff --git a/bridges/CommonDreamsBridge.php b/bridges/CommonDreamsBridge.php index d10748cc..21dfcbe1 100644 --- a/bridges/CommonDreamsBridge.php +++ b/bridges/CommonDreamsBridge.php @@ -16,7 +16,7 @@ class CommonDreamsBridge extends BridgeAbstract{ return $text; } - public function collectData(array $param){ + public function collectData(){ function CommonDreamsUrl($string) { $html2 = explode(" ", $string); diff --git a/bridges/CopieDoubleBridge.php b/bridges/CopieDoubleBridge.php index 80fcd452..a4420e6f 100644 --- a/bridges/CopieDoubleBridge.php +++ b/bridges/CopieDoubleBridge.php @@ -11,7 +11,7 @@ class CopieDoubleBridge extends BridgeAbstract{ } - public function collectData(array $param){ + public function collectData(){ $html = $this->getSimpleHTMLDOM('http://www.copie-double.com/') or $this->returnServerError('Could not request CopieDouble.'); $table = $html->find('table table', 2); diff --git a/bridges/CourrierInternationalBridge.php b/bridges/CourrierInternationalBridge.php index e921d815..62c8feec 100644 --- a/bridges/CourrierInternationalBridge.php +++ b/bridges/CourrierInternationalBridge.php @@ -10,7 +10,7 @@ class CourrierInternationalBridge extends BridgeAbstract{ } - public function collectData(array $param){ + public function collectData(){ $html = ''; diff --git a/bridges/CpasbienBridge.php b/bridges/CpasbienBridge.php index 4772e599..c0583cfc 100644 --- a/bridges/CpasbienBridge.php +++ b/bridges/CpasbienBridge.php @@ -21,11 +21,12 @@ class CpasbienBridge extends HttpCachingBridgeAbstract{ } - public function collectData(array $param){ + public function collectData(){ + $param=$this->parameters[$this->queriedContext]; $this->loadMetadatas(); $html = ''; - if (isset($param['q'])) { /* keyword search mode */ - $this->request = str_replace(" ","-",trim($param['q'])); + if (isset($param['q']['value'])) { /* keyword search mode */ + $this->request = str_replace(" ","-",trim($param['q']['value'])); $html = $this->getSimpleHTMLDOM($this->uri.'/recherche/'.urlencode($this->request).'.html') or $this->returnServerError('No results for this query.'); } else { diff --git a/bridges/CryptomeBridge.php b/bridges/CryptomeBridge.php index 4f40d617..daf404fb 100644 --- a/bridges/CryptomeBridge.php +++ b/bridges/CryptomeBridge.php @@ -18,7 +18,8 @@ class CryptomeBridge extends BridgeAbstract{ } - public function collectData(array $param){ + public function collectData(){ + $param=$this->parameters[$this->queriedContext]; $html = ''; $num = 20; $link = 'http://cryptome.org/'; @@ -26,8 +27,8 @@ class CryptomeBridge extends BridgeAbstract{ //$link = 'https://secure.netsolhost.com/cryptome.org/'; $html = $this->getSimpleHTMLDOM($link) or $this->returnServerError('Could not request Cryptome.'); - if (!empty($param['n'])) { /* number of documents */ - $num = min(max(1, $param['n']+0), $num); + if (!empty($param['n']['value'])) { /* number of documents */ + $num = min(max(1, $param['n']['value']+0), $num); } diff --git a/bridges/DailymotionBridge.php b/bridges/DailymotionBridge.php index 89b4cb33..0a73df8f 100644 --- a/bridges/DailymotionBridge.php +++ b/bridges/DailymotionBridge.php @@ -45,21 +45,22 @@ class DailymotionBridge extends BridgeAbstract{ return $metadata; } - public function collectData(array $param){ + public function collectData(){ + $param=$this->parameters[$this->queriedContext]; $html = ''; $limit = 5; $count = 0; - if (isset($param['u'])) { // user timeline mode - $this->request = $param['u']; + if (isset($param['u']['value'])) { // user timeline mode + $this->request = $param['u']['value']; $html = $this->getSimpleHTMLDOM('http://www.dailymotion.com/user/'.urlencode($this->request).'/1') or $this->returnServerError('Could not request Dailymotion.'); } - else if (isset($param['p'])) { // playlist mode - $this->request = strtok($param['p'], '_'); + else if (isset($param['p']['value'])) { // playlist mode + $this->request = strtok($param['p']['value'], '_'); $html = $this->getSimpleHTMLDOM('http://www.dailymotion.com/playlist/'.urlencode($this->request).'') or $this->returnServerError('Could not request Dailymotion.'); } - else if (isset($param['s'])) { // search mode - $this->request = $param['s']; $page = 1; if (isset($param['pa'])) $page = (int)preg_replace("/[^0-9]/",'', $param['pa']); + else if (isset($param['s']['value'])) { // search mode + $this->request = $param['s']['value']; $page = 1; if (isset($param['pa']['value'])) $page = (int)preg_replace("/[^0-9]/",'', $param['pa']['value']); $html = $this->getSimpleHTMLDOM('http://www.dailymotion.com/search/'.urlencode($this->request).'/'.$page.'') or $this->returnServerError('Could not request Dailymotion.'); } else { diff --git a/bridges/DanbooruBridge.php b/bridges/DanbooruBridge.php index 7b451de6..f41bc776 100644 --- a/bridges/DanbooruBridge.php +++ b/bridges/DanbooruBridge.php @@ -14,13 +14,14 @@ class DanbooruBridge extends BridgeAbstract{ ); } - public function collectData(array $param){ + public function collectData(){ + $param=$this->parameters[$this->queriedContext]; $page = 1;$tags=''; - if (isset($param['p'])) { - $page = (int)preg_replace("/[^0-9]/",'', $param['p']); + if (isset($param['p']['value'])) { + $page = (int)preg_replace("/[^0-9]/",'', $param['p']['value']); } - if (isset($param['t'])) { - $tags = urlencode($param['t']); + if (isset($param['t']['value'])) { + $tags = urlencode($param['t']['value']); } $html = $this->getSimpleHTMLDOM("http://donmai.us/posts?&page=$page&tags=$tags") or $this->returnServerError('Could not request Danbooru.'); foreach($html->find('div[id=posts] article') as $element) { diff --git a/bridges/DansTonChatBridge.php b/bridges/DansTonChatBridge.php index 1492c19d..83f6cd2a 100644 --- a/bridges/DansTonChatBridge.php +++ b/bridges/DansTonChatBridge.php @@ -10,7 +10,7 @@ class DansTonChatBridge extends BridgeAbstract{ } - public function collectData(array $param){ + public function collectData(){ $html = ''; $link = 'http://danstonchat.com/latest.html'; diff --git a/bridges/DauphineLibereBridge.php b/bridges/DauphineLibereBridge.php index f7652745..d97a0a59 100644 --- a/bridges/DauphineLibereBridge.php +++ b/bridges/DauphineLibereBridge.php @@ -40,7 +40,8 @@ class DauphineLibereBridge extends BridgeAbstract { return $text; } - public function collectData(array $param){ + public function collectData(){ + $param=$this->parameters[$this->queriedContext]; // Simulate Mozilla user-agent to fix error 403 (Forbidden) $opts = array('http' => @@ -52,8 +53,8 @@ class DauphineLibereBridge extends BridgeAbstract { $context = stream_context_create($opts); - if (isset($param['u'])) { /* user timeline mode */ - $this->request = $param['u']; + if (isset($param['u']['value'])) { /* user timeline mode */ + $this->request = $param['u']['value']; $html = $this->getSimpleHTMLDOM('http://www.ledauphine.com/'.$this->request.'/rss',false,$context) or $this->returnServerError('Could not request DauphineLibere.'); } else { diff --git a/bridges/DemoBridge.php b/bridges/DemoBridge.php index 6ffb80a7..f6d6efb1 100644 --- a/bridges/DemoBridge.php +++ b/bridges/DemoBridge.php @@ -35,7 +35,7 @@ class DemoBridge extends BridgeAbstract{ ); } - public function collectData(array $param){ + public function collectData(){ $item = array(); $item['author'] = "Me!"; diff --git a/bridges/DeveloppezDotComBridge.php b/bridges/DeveloppezDotComBridge.php index a4c2a52d..ca18fe39 100644 --- a/bridges/DeveloppezDotComBridge.php +++ b/bridges/DeveloppezDotComBridge.php @@ -40,7 +40,7 @@ class DeveloppezDotComBridge extends BridgeAbstract{ return trim($text); } - public function collectData(array $param){ + public function collectData(){ $rssFeed = $this->getSimpleHTMLDOM('http://www.developpez.com/index/rss') or $this->returnServerError('Could not request http://www.developpez.com/index/rss'); $limit = 0; diff --git a/bridges/DilbertBridge.php b/bridges/DilbertBridge.php index 426343c4..e0c23e6f 100644 --- a/bridges/DilbertBridge.php +++ b/bridges/DilbertBridge.php @@ -10,7 +10,7 @@ class DilbertBridge extends BridgeAbstract { } - public function collectData(array $param) { + public function collectData(){ $html = $this->getSimpleHTMLDOM($this->getURI()) or $this->returnServerError('Could not request Dilbert: '.$this->getURI()); diff --git a/bridges/DollbooruBridge.php b/bridges/DollbooruBridge.php index 865fbfff..fb3a5da6 100644 --- a/bridges/DollbooruBridge.php +++ b/bridges/DollbooruBridge.php @@ -18,13 +18,14 @@ class DollbooruBridge extends BridgeAbstract{ ); } - public function collectData(array $param){ + public function collectData(){ + $param=$this->parameters[$this->queriedContext]; $page = 0;$tags=''; - if (isset($param['p'])) { - $page = (int)preg_replace("/[^0-9]/",'', $param['p']); + if (isset($param['p']['value'])) { + $page = (int)preg_replace("/[^0-9]/",'', $param['p']['value']); } - if (isset($param['t'])) { - $tags = urlencode($param['t']); + if (isset($param['t']['value'])) { + $tags = urlencode($param['t']['value']); } $html = $this->getSimpleHTMLDOM("http://dollbooru.org/post/list/$tags/$page") or $this->returnServerError('Could not request Dollbooru.'); diff --git a/bridges/DuckDuckGoBridge.php b/bridges/DuckDuckGoBridge.php index 30282020..1522978e 100644 --- a/bridges/DuckDuckGoBridge.php +++ b/bridges/DuckDuckGoBridge.php @@ -15,9 +15,10 @@ class DuckDuckGoBridge extends BridgeAbstract{ ); } - public function collectData(array $param){ + public function collectData(){ + $param=$this->parameters[$this->queriedContext]; $html = ''; - $link = 'http://duckduckgo.com/html/?q='.$param['u'].'+sort:date'; + $link = 'http://duckduckgo.com/html/?q='.$param['u']['value'].'+sort:date'; $html = $this->getSimpleHTMLDOM($link) or $this->returnServerError('Could not request DuckDuckGo.'); diff --git a/bridges/EZTVBridge.php b/bridges/EZTVBridge.php index 847e70a1..83b93d13 100644 --- a/bridges/EZTVBridge.php +++ b/bridges/EZTVBridge.php @@ -17,7 +17,8 @@ class EZTVBridge extends BridgeAbstract{ ); } - public function collectData(array $param){ + public function collectData(){ + $param=$this->parameters[$this->queriedContext]; // Make timestamp from relative released time in table function makeTimestamp($relativeReleaseTime){ @@ -33,11 +34,11 @@ class EZTVBridge extends BridgeAbstract{ } // Check for ID provided - if (!isset($param['i'])) + if (!isset($param['i']['value'])) $this->returnClientError('You must provide a list of ID (?i=showID1,showID2,...)'); // Loop on show ids - $showList = explode(",",$param['i']); + $showList = explode(",",$param['i']['value']); foreach($showList as $showID){ // Get show page diff --git a/bridges/EliteDangerousGalnetBridge.php b/bridges/EliteDangerousGalnetBridge.php index 13dcf50d..9e9400d0 100644 --- a/bridges/EliteDangerousGalnetBridge.php +++ b/bridges/EliteDangerousGalnetBridge.php @@ -10,7 +10,7 @@ class EliteDangerousGalnetBridge extends BridgeAbstract $this->description = "Returns the latest page of news from Galnet"; } - public function collectData(array $param) + public function collectData() { $html = $this->getSimpleHTMLDOM('https://community.elitedangerous.com/galnet') or $this->returnServerError('Error while downloading the website content'); foreach($html->find('div.article') as $element) { diff --git a/bridges/ElsevierBridge.php b/bridges/ElsevierBridge.php index b336f4c8..25a9446f 100644 --- a/bridges/ElsevierBridge.php +++ b/bridges/ElsevierBridge.php @@ -58,9 +58,10 @@ class ElsevierBridge extends BridgeAbstract{ return ''; } - public function collectData(array $param){ - $uri = 'http://www.journals.elsevier.com/' . $param['j'] . '/recent-articles/'; - $html = $this->getSimpleHTMLDOM($uri) or $this->returnServerError('No results for Elsevier journal '.$param['j']); + public function collectData(){ + $param=$this->parameters[$this->queriedContext]; + $uri = 'http://www.journals.elsevier.com/' . $param['j']['value'] . '/recent-articles/'; + $html = $this->getSimpleHTMLDOM($uri) or $this->returnServerError('No results for Elsevier journal '.$param['j']['value']); foreach($html->find('.pod-listing') as $article){ $item = array(); diff --git a/bridges/EstCeQuonMetEnProdBridge.php b/bridges/EstCeQuonMetEnProdBridge.php index be1fe1ad..383d7712 100644 --- a/bridges/EstCeQuonMetEnProdBridge.php +++ b/bridges/EstCeQuonMetEnProdBridge.php @@ -8,7 +8,7 @@ class EstCeQuonMetEnProdBridge extends BridgeAbstract { $this->description = 'Should we put a website in production today? (French)'; } - public function collectData(array $param) { + public function collectData(){ function ExtractFromDelimiters($string, $start, $end) { if (strpos($string, $start) !== false) { $section_retrieved = substr($string, strpos($string, $start) + strlen($start)); diff --git a/bridges/FacebookBridge.php b/bridges/FacebookBridge.php index efa49f0f..4c67c50e 100644 --- a/bridges/FacebookBridge.php +++ b/bridges/FacebookBridge.php @@ -16,7 +16,8 @@ class FacebookBridge extends BridgeAbstract{ ); } - public function collectData(array $param) { + public function collectData(){ + $param=$this->parameters[$this->queriedContext]; //Extract a string using start and end delimiters function ExtractFromDelimiters($string, $start, $end) { @@ -104,11 +105,11 @@ class FacebookBridge extends BridgeAbstract{ //Retrieve page contents if (is_null($html)) { - if (isset($param['u'])) { - if (!strpos($param['u'], "/")) { - $html = $this->getSimpleHTMLDOM('https://www.facebook.com/'.urlencode($param['u']).'?_fb_noscript=1') or $this->returnServerError('No results for this query.'); + if (isset($param['u']['value'])) { + if (!strpos($param['u']['value'], "/")) { + $html = $this->getSimpleHTMLDOM('https://www.facebook.com/'.urlencode($param['u']['value']).'?_fb_noscript=1') or $this->returnServerError('No results for this query.'); } else { - $html = $this->getSimpleHTMLDOM('https://www.facebook.com/pages/'.$param['u'].'?_fb_noscript=1') or $this->returnServerError('No results for this query.'); + $html = $this->getSimpleHTMLDOM('https://www.facebook.com/pages/'.$param['u']['value'].'?_fb_noscript=1') or $this->returnServerError('No results for this query.'); } } else { $this->returnClientError('You must specify a Facebook username.'); @@ -148,7 +149,7 @@ class FacebookBridge extends BridgeAbstract{ if(isset($element)) { $author = str_replace(' | Facebook', '', $html->find('title#pageTitle', 0)->innertext); - $profilePic = 'https://graph.facebook.com/'.$param['u'].'/picture?width=200&height=200'; + $profilePic = 'https://graph.facebook.com/'.$param['u']['value'].'/picture?width=200&height=200'; $this->name = $author; foreach($element->children() as $post) { @@ -207,8 +208,8 @@ class FacebookBridge extends BridgeAbstract{ } public function setDatas(array $param){ - if (isset($param['captcha_response'])) - unset($param['captcha_response']); + if (isset($param['captcha_response']['value'])) + unset($param['captcha_response']['value']); parent::setDatas($param); } diff --git a/bridges/FierPandaBridge.php b/bridges/FierPandaBridge.php index 5a432fc0..44a792ab 100644 --- a/bridges/FierPandaBridge.php +++ b/bridges/FierPandaBridge.php @@ -10,7 +10,7 @@ Class FierPandaBridge extends BridgeAbstract{ } - public function collectData(array $param){ + public function collectData(){ $link = 'http://www.fier-panda.fr/'; $html = $this->getSimpleHTMLDOM($link) or $this->returnServerError('Could not request Fier Panda.'); diff --git a/bridges/FlickrExploreBridge.php b/bridges/FlickrExploreBridge.php index 25760fd9..09f946e7 100644 --- a/bridges/FlickrExploreBridge.php +++ b/bridges/FlickrExploreBridge.php @@ -10,7 +10,7 @@ class FlickrExploreBridge extends BridgeAbstract{ } - public function collectData(array $param){ + public function collectData(){ $html = $this->getSimpleHTMLDOM('https://www.flickr.com/explore') or $this->returnServerError('Could not request Flickr.'); foreach($html->find('.photo-list-photo-view') as $element) { diff --git a/bridges/FlickrTagBridge.php b/bridges/FlickrTagBridge.php index 424f989b..2c6158d7 100644 --- a/bridges/FlickrTagBridge.php +++ b/bridges/FlickrTagBridge.php @@ -17,14 +17,15 @@ class FlickrTagBridge extends BridgeAbstract{ ); } - public function collectData(array $param){ + public function collectData(){ + $param=$this->parameters[$this->queriedContext]; $html = $this->getSimpleHTMLDOM('http://www.flickr.com/search/?q=vendee&s=rec') or $this->returnServerError('Could not request Flickr.'); - if (isset($param['q'])) { /* keyword search mode */ - $this->request = $param['q']; + if (isset($param['q']['value'])) { /* keyword search mode */ + $this->request = $param['q']['value']; $html = $this->getSimpleHTMLDOM('http://www.flickr.com/search/?q='.urlencode($this->request).'&s=rec') or $this->returnServerError('No results for this query.'); } - elseif (isset($param['u'])) { /* user timeline mode */ - $this->request = $param['u']; + elseif (isset($param['u']['value'])) { /* user timeline mode */ + $this->request = $param['u']['value']; $html = $this->getSimpleHTMLDOM('http://www.flickr.com/photos/'.urlencode($this->request).'/') or $this->returnServerError('Requested username can\'t be found.'); } diff --git a/bridges/FootitoBridge.php b/bridges/FootitoBridge.php index 525aa9e4..326cbd50 100644 --- a/bridges/FootitoBridge.php +++ b/bridges/FootitoBridge.php @@ -10,7 +10,7 @@ class FootitoBridge extends BridgeAbstract{ } - public function collectData(array $param){ + public function collectData(){ $html = $this->getSimpleHTMLDOM('http://www.footito.fr/') or $this->returnServerError('Could not request Footito.'); foreach($html->find('div.post') as $element) { diff --git a/bridges/FourchanBridge.php b/bridges/FourchanBridge.php index 4b3a9b0f..976d8dba 100644 --- a/bridges/FourchanBridge.php +++ b/bridges/FourchanBridge.php @@ -14,12 +14,13 @@ class FourchanBridge extends BridgeAbstract{ } - public function collectData(array $param){ + public function collectData(){ + $param=$this->parameters[$this->queriedContext]; - if (!isset($param['t'])) + if (!isset($param['t']['value'])) $this->returnClientError('You must specify the thread URL (?t=...)'); - $thread = parse_url($param['t']) or $this->returnClientError('This URL seems malformed, please check it.'); + $thread = parse_url($param['t']['value']) or $this->returnClientError('This URL seems malformed, please check it.'); if($thread['host'] !== 'boards.4chan.org') $this->returnClientError('4chan thread URL only.'); diff --git a/bridges/FreenewsBridge.php b/bridges/FreenewsBridge.php index 871d10bd..f84dc7ac 100644 --- a/bridges/FreenewsBridge.php +++ b/bridges/FreenewsBridge.php @@ -14,7 +14,8 @@ class FreenewsBridge extends RssExpander { ); } - public function collectData(array $param){ + public function collectData(){ + $param=$this->parameters[$this->queriedContext]; parent::collectExpandableDatas($param, FREENEWS_RSS); } diff --git a/bridges/FuturaSciencesBridge.php b/bridges/FuturaSciencesBridge.php index 2d0869cd..06033935 100644 --- a/bridges/FuturaSciencesBridge.php +++ b/bridges/FuturaSciencesBridge.php @@ -81,7 +81,8 @@ class FuturaSciencesBridge extends BridgeAbstract { ); } - public function collectData(array $param) { + public function collectData(){ + $param=$this->parameters[$this->queriedContext]; function StripCDATA($string) { $string = str_replace('getURI().'rss/'.$param['feed'].'.xml'; - if (empty($param['feed'])) + $url = $this->getURI().'rss/'.$param['feed']['value'].'.xml'; + if (empty($param['feed']['value'])) $this->returnClientError('Please select a feed to display.'.$url); - if ($param['feed'] !== preg_replace('/[^a-zA-Z-\/]+/', '', $param['feed']) || substr_count($param['feed'], '/') > 1 || strlen($param['feed'] > 64)) + if ($param['feed']['value'] !== preg_replace('/[^a-zA-Z-\/]+/', '', $param['feed']['value']) || substr_count($param['feed']['value'], '/') > 1 || strlen($param['feed']['value'] > 64)) $this->returnClientError('Invalid "feed" parameter.'.$url); $html = $this->getSimpleHTMLDOM($url) or $this->returnServerError('Could not request Futura-Sciences: '.$url); diff --git a/bridges/GBAtempBridge.php b/bridges/GBAtempBridge.php index 4c1bf210..f8fc9ff0 100644 --- a/bridges/GBAtempBridge.php +++ b/bridges/GBAtempBridge.php @@ -63,11 +63,12 @@ class GBAtempBridge extends BridgeAbstract { return $this->cleanup_post_content($content, $site_url); } - public function collectData(array $param) { + public function collectData(){ + $param=$this->parameters[$this->queriedContext]; $typeFilter = ''; - if (!empty($param['type'])) { - if ($param['type'] == 'N' || $param['type'] == 'R' || $param['type'] == 'T' || $param['type'] == 'F') { - $typeFilter = $param['type']; + if (!empty($param['type']['value'])) { + if ($param['type']['value'] == 'N' || $param['type']['value'] == 'R' || $param['type']['value'] == 'T' || $param['type']['value'] == 'F') { + $typeFilter = $param['type']['value']; if ($typeFilter == 'N') { $this->filter = 'News'; } if ($typeFilter == 'R') { $this->filter = 'Review'; } if ($typeFilter == 'T') { $this->filter = 'Tutorial'; } diff --git a/bridges/GawkerBridge.php b/bridges/GawkerBridge.php index ea89af32..cc1ae631 100644 --- a/bridges/GawkerBridge.php +++ b/bridges/GawkerBridge.php @@ -21,12 +21,13 @@ class GawkerBridge extends RssExpander{ return RSS_PREFIX.$name.RSS_SUFFIX; } - public function collectData(array $param){ - if (empty($param['site'])) { + public function collectData(){ + $param=$this->parameters[$this->queriedContext]; + if (empty($param['site']['value'])) { trigger_error("If no site is provided, nothing is gonna happen", E_USER_ERROR); } else { - $this->name = $param['site']; - $url = $this->toURI(strtolower($param['site'])); + $this->name = $param['site']['value']; + $url = $this->toURI(strtolower($param['site']['value'])); } $this->debugMessage("loading feed from ".$this->getURI()); parent::collectExpandableDatas($param, $url); diff --git a/bridges/GelbooruBridge.php b/bridges/GelbooruBridge.php index d463975a..94d35949 100644 --- a/bridges/GelbooruBridge.php +++ b/bridges/GelbooruBridge.php @@ -18,15 +18,16 @@ class GelbooruBridge extends BridgeAbstract{ } - public function collectData(array $param){ + public function collectData(){ + $param=$this->parameters[$this->queriedContext]; $page = 0; - if (isset($param['p'])) { - $page = (int)preg_replace("/[^0-9]/",'', $param['p']); + if (isset($param['p']['value'])) { + $page = (int)preg_replace("/[^0-9]/",'', $param['p']['value']); $page = $page - 1; $page = $page * 63; } - if (isset($param['t'])) { - $tags = urlencode($param['t']); + if (isset($param['t']['value'])) { + $tags = urlencode($param['t']['value']); } $html = $this->getSimpleHTMLDOM("http://gelbooru.com/index.php?page=post&s=list&tags=$tags&pid=$page") or $this->returnServerError('Could not request Gelbooru.'); diff --git a/bridges/GiphyBridge.php b/bridges/GiphyBridge.php index 0ad0f910..b294969b 100644 --- a/bridges/GiphyBridge.php +++ b/bridges/GiphyBridge.php @@ -20,23 +20,24 @@ class GiphyBridge extends BridgeAbstract{ } - public function collectData(array $param){ + public function collectData(){ + $param=$this->parameters[$this->queriedContext]; $html = ''; $base_url = 'http://giphy.com'; - if (isset($param['s'])) { /* keyword search mode */ - $html = $this->getSimpleHTMLDOM($base_url.'/search/'.urlencode($param['s'].'/')) or $this->returnServerError('No results for this query.'); + if (isset($param['s']['value'])) { /* keyword search mode */ + $html = $this->getSimpleHTMLDOM($base_url.'/search/'.urlencode($param['s']['value'].'/')) or $this->returnServerError('No results for this query.'); } else { $this->returnClientError('You must specify a search worf (?s=...).'); } $max = GIPHY_LIMIT; - if (isset($param['n'])) { - $max = (integer) $param['n']; + if (isset($param['n']['value'])) { + $max = (integer) $param['n']['value']; } $limit = 0; - $kw = urlencode($param['s']); + $kw = urlencode($param['s']['value']); foreach($html->find('div.hoverable-gif') as $entry) { if($limit < $max) { $node = $entry->first_child(); diff --git a/bridges/GithubIssueBridge.php b/bridges/GithubIssueBridge.php index 9bfddb84..3374ed8b 100644 --- a/bridges/GithubIssueBridge.php +++ b/bridges/GithubIssueBridge.php @@ -28,12 +28,13 @@ class GithubIssueBridge extends BridgeAbstract{ ); } - public function collectData(array $param){ - $uri = 'https://github.com/'.$param['u'].'/'.$param['p'].'/issues/'.(isset($param['i'])?$param['i']:''); + public function collectData(){ + $param=$this->parameters[$this->queriedContext]; + $uri = 'https://github.com/'.$param['u']['value'].'/'.$param['p']['value'].'/issues/'.(isset($param['i']['value'])?$param['i']['value']:''); $html = $this->getSimpleHTMLDOM($uri) - or $this->returnServerError('No results for Github Issue '.$param['i'].' in project '.$param['u'].'/'.$param['p']); + or $this->returnServerError('No results for Github Issue '.$param['i']['value'].' in project '.$param['u']['value'].'/'.$param['p']['value']); - if(isset($param['i'])){ + if(isset($param['i']['value'])){ foreach($html->find('.js-comment-container') as $comment){ $item = array(); diff --git a/bridges/GitlabCommitsBridge.php b/bridges/GitlabCommitsBridge.php index 762e642a..61c15b57 100644 --- a/bridges/GitlabCommitsBridge.php +++ b/bridges/GitlabCommitsBridge.php @@ -33,29 +33,30 @@ class GitlabCommitsBridge extends BridgeAbstract{ ); } - public function collectData(array $param){ - $uri = $param['uri'].'/'.$param['u'].'/'.$param['p'].'/commits/'; - if(isset($param['b'])){ - $uri.=$param['b']; + public function collectData(){ + $param=$this->parameters[$this->queriedContext]; + $uri = $param['uri']['value'].'/'.$param['u']['value'].'/'.$param['p']['value'].'/commits/'; + if(isset($param['b']['value'])){ + $uri.=$param['b']['value']; }else{ $uri.='master'; } $html = $this->getSimpleHTMLDOM($uri) - or $this->returnServerError('No results for Gitlab Commits of project '.$param['uri'].'/'.$param['u'].'/'.$param['p']); + or $this->returnServerError('No results for Gitlab Commits of project '.$param['uri']['value'].'/'.$param['u']['value'].'/'.$param['p']['value']); foreach($html->find('li.commit') as $commit){ $item = array(); - $item['uri']=$param['uri']; + $item['uri']=$param['uri']['value']; foreach($commit->getElementsByTagName('a') as $a){ $classes=explode(' ',$a->getAttribute("class")); if(in_array('commit-short-id',$classes) || in_array('commit_short_id',$classes)){ $href=$a->getAttribute('href'); - $item['uri'].=substr($href,strpos($href,'/'.$param['u'].'/'.$param['p'])); + $item['uri'].=substr($href,strpos($href,'/'.$param['u']['value'].'/'.$param['p']['value'])); } if(in_array('commit-row-message',$classes)){ $item['title']=$a->plaintext; diff --git a/bridges/GizmodoFRBridge.php b/bridges/GizmodoFRBridge.php index 8bd32176..ce4e96d2 100644 --- a/bridges/GizmodoFRBridge.php +++ b/bridges/GizmodoFRBridge.php @@ -10,7 +10,7 @@ class GizmodoFRBridge extends BridgeAbstract{ } - public function collectData(array $param){ + public function collectData(){ function GizmodoFRExtractContent($url) { $articleHTMLContent = $this->getSimpleHTMLDOM($url); diff --git a/bridges/GooglePlusPostBridge.php b/bridges/GooglePlusPostBridge.php index 46d74ac0..56af4524 100644 --- a/bridges/GooglePlusPostBridge.php +++ b/bridges/GooglePlusPostBridge.php @@ -22,14 +22,14 @@ class GooglePlusPostBridge extends BridgeAbstract const GOOGLE_PLUS_BASE_URL = 'https://plus.google.com/'; - public function collectData(array $param) + public function collectData() { - if (!isset($param['username'])) + if (!isset($param['username']['value'])) { $this->returnClientError('You must specify a username (?username=...).'); } - $this->request = $param['username']; + $this->request = $param['username']['value']; // get content parsed // $html = $this->getSimpleHTMLDOM(__DIR__ . '/../posts2.html' $html = $this->getSimpleHTMLDOM(self::GOOGLE_PLUS_BASE_URL . urlencode($this->request) . '/posts' diff --git a/bridges/GoogleSearchBridge.php b/bridges/GoogleSearchBridge.php index a3746404..5585cea2 100644 --- a/bridges/GoogleSearchBridge.php +++ b/bridges/GoogleSearchBridge.php @@ -25,11 +25,12 @@ class GoogleSearchBridge extends BridgeAbstract{ } - public function collectData(array $param){ + public function collectData(){ + $param=$this->parameters[$this->queriedContext]; $html = ''; - if (isset($param['q'])) { /* keyword search mode */ - $this->request = $param['q']; + if (isset($param['q']['value'])) { /* keyword search mode */ + $this->request = $param['q']['value']; $html = $this->getSimpleHTMLDOM('https://www.google.com/search?q=' . urlencode($this->request) . '&num=100&complete=0&tbs=qdr:y,sbd:1') or $this->returnServerError('No results for this query.'); } else{ diff --git a/bridges/GuruMedBridge.php b/bridges/GuruMedBridge.php index a58ee643..65617559 100644 --- a/bridges/GuruMedBridge.php +++ b/bridges/GuruMedBridge.php @@ -14,7 +14,7 @@ class GuruMedBridge extends BridgeAbstract{ return $string; } - public function collectData(array $param){ + public function collectData(){ $html = $this->getSimpleHTMLDOM('http://gurumed.org/feed') or $this->returnServerError('Could not request Gurumed.'); $limit = 0; diff --git a/bridges/HDWallpapersBridge.php b/bridges/HDWallpapersBridge.php index 1aa8ff78..4aeb5961 100644 --- a/bridges/HDWallpapersBridge.php +++ b/bridges/HDWallpapersBridge.php @@ -21,12 +21,13 @@ class HDWallpapersBridge extends BridgeAbstract { ); } - public function collectData(array $param){ + public function collectData(){ + $param=$this->parameters[$this->queriedContext]; $html = ''; $baseUri = 'http://www.hdwallpapers.in'; - $this->category = $param['c'] ?: 'latest_wallpapers'; // Latest default - $this->resolution = $param['r'] ?: '1920x1200'; // Wide wallpaper default + $this->category = $param['c']['value'] ?: 'latest_wallpapers'; // Latest default + $this->resolution = $param['r']['value'] ?: '1920x1200'; // Wide wallpaper default $category = $this->category; if (strrpos($category, 'wallpapers') !== strlen($category)-strlen('wallpapers')) { @@ -34,7 +35,7 @@ class HDWallpapersBridge extends BridgeAbstract { } $num = 0; - $max = $param['m'] ?: 14; + $max = $param['m']['value'] ?: 14; $lastpage = 1; for ($page = 1; $page <= $lastpage; $page++) { diff --git a/bridges/HentaiHavenBridge.php b/bridges/HentaiHavenBridge.php index 28f69750..22381924 100644 --- a/bridges/HentaiHavenBridge.php +++ b/bridges/HentaiHavenBridge.php @@ -10,7 +10,7 @@ class HentaiHavenBridge extends BridgeAbstract{ } - public function collectData(array $param){ + public function collectData(){ $html = $this->getSimpleHTMLDOM('http://hentaihaven.org/') or $this->returnServerError('Could not request Hentai Haven.'); foreach($html->find('div.zoe-grid') as $element) { $item = array(); diff --git a/bridges/IdenticaBridge.php b/bridges/IdenticaBridge.php index 64f5a6c7..a9d30173 100644 --- a/bridges/IdenticaBridge.php +++ b/bridges/IdenticaBridge.php @@ -19,10 +19,11 @@ class IdenticaBridge extends BridgeAbstract{ } - public function collectData(array $param){ + public function collectData(){ + $param=$this->parameters[$this->queriedContext]; $html = ''; - if (isset($param['u'])) { /* user timeline mode */ - $this->request = $param['u']; + if (isset($param['u']['value'])) { /* user timeline mode */ + $this->request = $param['u']['value']; $html = $this->getSimpleHTMLDOM('https://identi.ca/'.urlencode($this->request)) or $this->returnServerError('Requested username can\'t be found.'); } else { @@ -34,7 +35,7 @@ class IdenticaBridge extends BridgeAbstract{ $item['uri'] = html_entity_decode($dent->find('a', 0)->href); // get dent link $item['timestamp'] = strtotime($dent->find('abbr.easydate', 0)->plaintext); // extract dent timestamp $item['content'] = trim($dent->find('div.activity-content', 0)->innertext); // extract dent text - $item['title'] = $param['u'] . ' | ' . $item['content']; + $item['title'] = $param['u']['value'] . ' | ' . $item['content']; $this->items[] = $item; } } diff --git a/bridges/InstagramBridge.php b/bridges/InstagramBridge.php index 9e99dc42..85709474 100644 --- a/bridges/InstagramBridge.php +++ b/bridges/InstagramBridge.php @@ -16,10 +16,11 @@ class InstagramBridge extends BridgeAbstract{ } - public function collectData(array $param){ + public function collectData(){ + $param=$this->parameters[$this->queriedContext]; $html = ''; - if (isset($param['u'])) { /* user timeline mode */ - $this->request = $param['u']; + if (isset($param['u']['value'])) { /* user timeline mode */ + $this->request = $param['u']['value']; $html = $this->getSimpleHTMLDOM('http://instagram.com/'.urlencode($this->request)) or $this->returnServerError('Could not request Instagram.'); } else { diff --git a/bridges/IsoHuntBridge.php b/bridges/IsoHuntBridge.php index ac32752f..bfeb2fd9 100644 --- a/bridges/IsoHuntBridge.php +++ b/bridges/IsoHuntBridge.php @@ -89,23 +89,24 @@ class IsoHuntBridge extends BridgeAbstract{ ); } - public function collectData(array $params){ + public function collectData(){ + $params=$this->parameters[$this->queriedContext]; $request_path = '/'; // We'll request the main page by default - if(isset($params['latest_category'])){ // Requesting one of the latest categories - $this->request_latest_category($params['latest_category']); - } elseif(isset($params['torrent_category'])){ // Requesting one of the torrent categories + if(isset($params['latest_category']['value'])){ // Requesting one of the latest categories + $this->request_latest_category($params['latest_category']['value']); + } elseif(isset($params['torrent_category']['value'])){ // Requesting one of the torrent categories $order_popularity = false; - if(isset($params['torrent_popularity'])) - $order_popularity = $params['torrent_popularity'] === "on"; + if(isset($params['torrent_popularity']['value'])) + $order_popularity = $params['torrent_popularity']['value']; - $this->request_torrent_category($params['torrent_category'], $order_popularity); - } else if(isset($params['search_name'])){ // Requesting search - if(isset($params['search_category'])) - $this->request_search($params['search_name'], $params['search_category']); + $this->request_torrent_category($params['torrent_category']['value'], $order_popularity); + } else if(isset($params['search_name']['value'])){ // Requesting search + if(isset($params['search_category']['value'])) + $this->request_search($params['search_name']['value'], $params['search_category']['value']); else - $this->request_search($params['search_name']); + $this->request_search($params['search_name']['value']); } else { $this->returnClientError('Unknown request!'); } diff --git a/bridges/JapanExpoBridge.php b/bridges/JapanExpoBridge.php index 125261f2..7ac1f8a7 100644 --- a/bridges/JapanExpoBridge.php +++ b/bridges/JapanExpoBridge.php @@ -18,7 +18,8 @@ class JapanExpoBridge extends BridgeAbstract{ ); } - public function collectData(array $param) { + public function collectData(){ + $param=$this->parameters[$this->queriedContext]; function french_pubdate_to_timestamp($date_to_parse) { return strtotime( @@ -50,7 +51,7 @@ class JapanExpoBridge extends BridgeAbstract{ $link = 'http://www.japan-expo-paris.com/fr/actualites'; $html = $this->getSimpleHTMLDOM($link) or $this->returnServerError('Could not request JapanExpo: '.$link); - $fullcontent = (!empty($param['mode']) && $param['mode'] == 'full'); + $fullcontent = (!empty($param['mode']['value']) && $param['mode']['value'] == 'full'); $count = 0; foreach ($html->find('a._tile2') as $element) { diff --git a/bridges/KonachanBridge.php b/bridges/KonachanBridge.php index b9ef3072..1ae4fff3 100644 --- a/bridges/KonachanBridge.php +++ b/bridges/KonachanBridge.php @@ -17,13 +17,14 @@ class KonachanBridge extends BridgeAbstract{ ); } - public function collectData(array $param){ + public function collectData(){ + $param=$this->parameters[$this->queriedContext]; $page = 1;$tags=''; - if (isset($param['p'])) { - $page = (int)preg_replace("/[^0-9]/",'', $param['p']); + if (isset($param['p']['value'])) { + $page = (int)preg_replace("/[^0-9]/",'', $param['p']['value']); } - if (isset($param['t'])) { - $tags = urlencode($param['t']); + if (isset($param['t']['value'])) { + $tags = urlencode($param['t']['value']); } $html = $this->getSimpleHTMLDOM("http://konachan.com/post?page=$page&tags=$tags") or $this->returnServerError('Could not request Konachan.'); $input_json = explode('Post.register(', $html); diff --git a/bridges/KoreusBridge.php b/bridges/KoreusBridge.php index d211edfc..66fe3733 100644 --- a/bridges/KoreusBridge.php +++ b/bridges/KoreusBridge.php @@ -21,7 +21,7 @@ class KoreusBridge extends BridgeAbstract{ return $text; } - public function collectData(array $param){ + public function collectData(){ $html = $this->getSimpleHTMLDOM('http://feeds.feedburner.com/Koreus-articles') or $this->returnServerError('Could not request Koreus.'); $limit = 0; diff --git a/bridges/KununuBridge.php b/bridges/KununuBridge.php index 0902d200..9e08e917 100644 --- a/bridges/KununuBridge.php +++ b/bridges/KununuBridge.php @@ -39,21 +39,22 @@ class KununuBridge extends BridgeAbstract{ ); } - public function collectData(array $params){ + public function collectData(){ + $params=$this->parameters[$this->queriedContext]; // Get Site - $site = strtolower(trim($params['site'])); + $site = strtolower(trim($params['site']['value'])); if(!isset($site) || empty($site) || !$this->site_is_valid($site)) $this->returnClientError('You must specify a valid site (&site=...)!'); // Get Company (fixing whitespace and umlauts) - $company = $this->encode_umlauts(strtolower(str_replace(' ', '-', trim($params['company'])))); + $company = $this->encode_umlauts(strtolower(str_replace(' ', '-', trim($params['company']['value'])))); if(!isset($company) || empty($company)) $this->returnClientError('You must specify a company (&company=...)!'); $full = false; // By default we'll load only short article - if(isset($params['full'])) - $full = strtolower(trim($params['full'])) === 'on'; + if(isset($params['full']['value'])) + $full = strtolower(trim($params['full']['value'])) === 'on'; // Get reviews section name (depends on site) $section = ''; diff --git a/bridges/LWNprevBridge.php b/bridges/LWNprevBridge.php index fc61d057..32a79447 100644 --- a/bridges/LWNprevBridge.php +++ b/bridges/LWNprevBridge.php @@ -35,7 +35,7 @@ class LWNprevBridge extends BridgeAbstract{ } } - public function collectData(array $param){ + public function collectData(){ // Because the LWN page is written in loose HTML and not XHTML, // Simple HTML Dom is not accurate enough for the job diff --git a/bridges/LeBonCoinBridge.php b/bridges/LeBonCoinBridge.php index e71ba4aa..855600fe 100755 --- a/bridges/LeBonCoinBridge.php +++ b/bridges/LeBonCoinBridge.php @@ -138,14 +138,15 @@ class LeBonCoinBridge extends BridgeAbstract{ } - public function collectData(array $param){ + public function collectData(){ + $param=$this->parameters[$this->queriedContext]; $html = ''; - if (empty($param['c'])) { - $link = 'http://www.leboncoin.fr/annonces/offres/' . $param['r'] . '/?f=a&th=1&q=' . urlencode($param['k']); + if (empty($param['c']['value'])) { + $link = 'http://www.leboncoin.fr/annonces/offres/' . $param['r']['value'] . '/?f=a&th=1&q=' . urlencode($param['k']['value']); } else { - $link = 'http://www.leboncoin.fr/' . $param['c'] . '/offres/' . $param['r'] . '/?f=a&th=1&q=' . urlencode($param['k']); + $link = 'http://www.leboncoin.fr/' . $param['c']['value'] . '/offres/' . $param['r']['value'] . '/?f=a&th=1&q=' . urlencode($param['k']['value']); } $html = $this->getSimpleHTMLDOM($link) or $this->returnServerError('Could not request LeBonCoin.'); diff --git a/bridges/LeJournalDuGeekBridge.php b/bridges/LeJournalDuGeekBridge.php index 84a829a3..19f06e19 100644 --- a/bridges/LeJournalDuGeekBridge.php +++ b/bridges/LeJournalDuGeekBridge.php @@ -36,7 +36,7 @@ class LeJournalDuGeekBridge extends BridgeAbstract{ return $text; } - public function collectData(array $param){ + public function collectData(){ $rssFeed = $this->getSimpleHTMLDOM('http://www.journaldugeek.com/rss') or $this->returnServerError('Could not request http://www.journaldugeek.com/rss'); $limit = 0; diff --git a/bridges/LeMondeInformatiqueBridge.php b/bridges/LeMondeInformatiqueBridge.php index 3465be44..e4fbdbcb 100644 --- a/bridges/LeMondeInformatiqueBridge.php +++ b/bridges/LeMondeInformatiqueBridge.php @@ -10,7 +10,7 @@ class LeMondeInformatiqueBridge extends BridgeAbstract { } - public function collectData(array $param) { + public function collectData(){ function StripCDATA($string) { $string = str_replace('parameters[$this->queriedContext]; parent::collectExpandableDatas($param, SEXE_FEED); } diff --git a/bridges/LesJoiesDuCodeBridge.php b/bridges/LesJoiesDuCodeBridge.php index e9986d88..d3299395 100644 --- a/bridges/LesJoiesDuCodeBridge.php +++ b/bridges/LesJoiesDuCodeBridge.php @@ -10,7 +10,7 @@ class LesJoiesDuCodeBridge extends BridgeAbstract{ } - public function collectData(array $param){ + public function collectData(){ $html = $this->getSimpleHTMLDOM('http://lesjoiesducode.fr/') or $this->returnServerError('Could not request LesJoiesDuCode.'); foreach($html->find('div.blog-post') as $element) { diff --git a/bridges/LichessBridge.php b/bridges/LichessBridge.php index 252fbaec..839b183a 100644 --- a/bridges/LichessBridge.php +++ b/bridges/LichessBridge.php @@ -10,7 +10,7 @@ class LichessBridge extends BridgeAbstract $this->description = 'Returns the 5 newest posts from the Lichess blog (full text)'; } - public function collectData(array $param) + public function collectData() { $xml_feed = $this->getSimpleHTMLDOM('http://fr.lichess.org/blog.atom') or $this->returnServerError('Could not retrieve Lichess blog feed.'); diff --git a/bridges/LinkedInCompany.php b/bridges/LinkedInCompany.php index bf8fd6ac..7640d15b 100644 --- a/bridges/LinkedInCompany.php +++ b/bridges/LinkedInCompany.php @@ -16,9 +16,10 @@ class LinkedInCompany extends BridgeAbstract{ ); } - public function collectData(array $param){ + public function collectData(){ + $param=$this->parameters[$this->queriedContext]; $html = ''; - $link = 'https://www.linkedin.com/company/'.$param['c']; + $link = 'https://www.linkedin.com/company/'.$param['c']['value']; $html = $this->getSimpleHTMLDOM($link) or $this->returnServerError('Could not request LinkedIn.'); diff --git a/bridges/LolibooruBridge.php b/bridges/LolibooruBridge.php index b91168a3..66892167 100644 --- a/bridges/LolibooruBridge.php +++ b/bridges/LolibooruBridge.php @@ -17,13 +17,14 @@ class LolibooruBridge extends BridgeAbstract{ ); } - public function collectData(array $param){ + public function collectData(){ + $param=$this->parameters[$this->queriedContext]; $page = 1; $tags = ''; - if (isset($param['p'])) { - $page = (int)preg_replace("/[^0-9]/",'', $param['p']); + if (isset($param['p']['value'])) { + $page = (int)preg_replace("/[^0-9]/",'', $param['p']['value']); } - if (isset($param['t'])) { - $tags = urlencode($param['t']); + if (isset($param['t']['value'])) { + $tags = urlencode($param['t']['value']); } $html = $this->getSimpleHTMLDOM("http://lolibooru.moe/post?page=$page&tags=$tags") or $this->returnServerError('Could not request Lolibooru.'); $input_json = explode('Post.register(', $html); diff --git a/bridges/MangareaderBridge.php b/bridges/MangareaderBridge.php index b2b5902a..59cb0649 100644 --- a/bridges/MangareaderBridge.php +++ b/bridges/MangareaderBridge.php @@ -76,7 +76,8 @@ class MangareaderBridge extends BridgeAbstract{ ); } - public function collectData(array $param){ + public function collectData(){ + $param=$this->parameters[$this->queriedContext]; $this->request = ''; @@ -84,21 +85,21 @@ class MangareaderBridge extends BridgeAbstract{ $path = "latest"; $limit = MANGAREADER_LIMIT; - if(isset($param['category'])){ // Get popular updates + if(isset($param['category']['value'])){ // Get popular updates $type = "popular"; $path = "popular"; - if($param['category'] !== "all"){ - $path .= "/" . $param['category']; + if($param['category']['value'] !== "all"){ + $path .= "/" . $param['category']['value']; } } - if(isset($param['path'])){ // Get manga updates + if(isset($param['path']['value'])){ // Get manga updates $type = "path"; - $path = $param['path']; + $path = $param['path']['value']; } - if(isset($param['limit']) && $param['limit'] !== ""){ // Get manga updates (optional parameter) - $limit = $param['limit']; + if(isset($param['limit']['value']) && $param['limit']['value'] !== ""){ // Get manga updates (optional parameter) + $limit = $param['limit']['value']; } // We'll use the DOM parser for this as it makes navigation easier diff --git a/bridges/MilbooruBridge.php b/bridges/MilbooruBridge.php index 8c081712..58b539f8 100644 --- a/bridges/MilbooruBridge.php +++ b/bridges/MilbooruBridge.php @@ -17,13 +17,14 @@ class MilbooruBridge extends BridgeAbstract{ ); } - public function collectData(array $param){ + public function collectData(){ + $param=$this->parameters[$this->queriedContext]; $page = 0;$tags=''; - if (isset($param['p'])) { - $page = (int)preg_replace("/[^0-9]/",'', $param['p']); + if (isset($param['p']['value'])) { + $page = (int)preg_replace("/[^0-9]/",'', $param['p']['value']); } - if (isset($param['t'])) { - $tags = urlencode($param['t']); + if (isset($param['t']['value'])) { + $tags = urlencode($param['t']['value']); } $html = $this->getSimpleHTMLDOM("http://sheslostcontrol.net/moe/shimmie/index.php?q=/post/list/$tags/$page") or $this->returnServerError('Could not request Milbooru.'); diff --git a/bridges/MondeDiploBridge.php b/bridges/MondeDiploBridge.php index bc033346..0bbab2a2 100644 --- a/bridges/MondeDiploBridge.php +++ b/bridges/MondeDiploBridge.php @@ -8,7 +8,7 @@ class MondeDiploBridge extends BridgeAbstract{ $this->description = "Returns most recent results from MondeDiplo."; } - public function collectData(array $param){ + public function collectData(){ $html = $this->getSimpleHTMLDOM($this->uri) or $this->returnServerError('Could not request MondeDiplo. for : ' . $link); foreach($html->find('div.unarticle') as $article) { diff --git a/bridges/MsnMondeBridge.php b/bridges/MsnMondeBridge.php index 5d7d48d1..e4af1374 100644 --- a/bridges/MsnMondeBridge.php +++ b/bridges/MsnMondeBridge.php @@ -14,7 +14,7 @@ class MsnMondeBridge extends BridgeAbstract{ $item['timestamp'] = strtotime($html2->find('.authorinfo-txt', 0)->find('time', 0)->datetime); } - public function collectData(array $param){ + public function collectData(){ $html = $this->getSimpleHTMLDOM($this->uri) or $this->returnServerError('Could not request MsnMonde.'); $limit = 0; foreach($html->find('.smalla') as $article) { diff --git a/bridges/MspabooruBridge.php b/bridges/MspabooruBridge.php index 6528b3ca..5a7f8a2b 100644 --- a/bridges/MspabooruBridge.php +++ b/bridges/MspabooruBridge.php @@ -18,15 +18,16 @@ class MspabooruBridge extends BridgeAbstract{ } - public function collectData(array $param){ + public function collectData(){ + $param=$this->parameters[$this->queriedContext]; $page = 0;$tags=''; - if (isset($param['p'])) { - $page = (int)preg_replace("/[^0-9]/",'', $param['p']); + if (isset($param['p']['value'])) { + $page = (int)preg_replace("/[^0-9]/",'', $param['p']['value']); $page = $page - 1; $page = $page * 50; } - if (isset($param['t'])) { - $tags = urlencode($param['t']); + if (isset($param['t']['value'])) { + $tags = urlencode($param['t']['value']); } $html = $this->getSimpleHTMLDOM("http://mspabooru.com/index.php?page=post&s=list&tags=$tags&pid=$page") or $this->returnServerError('Could not request Mspabooru.'); diff --git a/bridges/NakedSecurityBridge.php b/bridges/NakedSecurityBridge.php index 4020b708..0ad8370b 100644 --- a/bridges/NakedSecurityBridge.php +++ b/bridges/NakedSecurityBridge.php @@ -8,7 +8,7 @@ class NakedSecurityBridge extends BridgeAbstract { $this->description = 'Returns the newest articles.'; } - public function collectData(array $param) { + public function collectData(){ function StripRecursiveHTMLSection($string, $tag_name, $tag_start) { $open_tag = '<'.$tag_name; diff --git a/bridges/NasaApodBridge.php b/bridges/NasaApodBridge.php index c8b36c3d..2209c4d3 100644 --- a/bridges/NasaApodBridge.php +++ b/bridges/NasaApodBridge.php @@ -10,7 +10,7 @@ class NasaApodBridge extends BridgeAbstract{ } - public function collectData(array $param) { + public function collectData(){ $html = $this->getSimpleHTMLDOM('http://apod.nasa.gov/apod/archivepix.html') or $this->returnServerError('Error while downloading the website content'); $list = explode("
", $html->find('b', 0)->innertext); diff --git a/bridges/NeuviemeArtBridge.php b/bridges/NeuviemeArtBridge.php index fa6c8c7a..0d7ae981 100644 --- a/bridges/NeuviemeArtBridge.php +++ b/bridges/NeuviemeArtBridge.php @@ -8,7 +8,7 @@ class NeuviemeArtBridge extends BridgeAbstract { $this->description = "Returns the newest articles."; } - public function collectData(array $param) { + public function collectData(){ function StripWithDelimiters($string, $start, $end) { while (strpos($string, $start) !== false) { diff --git a/bridges/NextInpactBridge.php b/bridges/NextInpactBridge.php index b04b972e..93b3a819 100644 --- a/bridges/NextInpactBridge.php +++ b/bridges/NextInpactBridge.php @@ -25,7 +25,7 @@ class NextInpactBridge extends BridgeAbstract { return $text; } - public function collectData(array $param) { + public function collectData(){ $html = $this->getSimpleHTMLDOM('http://www.nextinpact.com/rss/news.xml') or $this->returnServerError('Could not request NextInpact.'); $limit = 0; diff --git a/bridges/NextgovBridge.php b/bridges/NextgovBridge.php index 684df8b8..196c0fac 100644 --- a/bridges/NextgovBridge.php +++ b/bridges/NextgovBridge.php @@ -28,7 +28,8 @@ class NextgovBridge extends BridgeAbstract { ); } - public function collectData(array $param) { + public function collectData(){ + $param=$this->parameters[$this->queriedContext]; function ExtractFromDelimiters($string, $start, $end) { if (strpos($string, $start) !== false) { @@ -46,7 +47,7 @@ class NextgovBridge extends BridgeAbstract { } return $string; } - $category = $param['category']; + $category = $param['category']['value']; if (empty($category)) $category = 'all'; if ($category !== preg_replace('/[^a-z-]+/', '', $category) || strlen($category > 32)) diff --git a/bridges/NiceMatinBridge.php b/bridges/NiceMatinBridge.php index 30a1f346..d56fc275 100644 --- a/bridges/NiceMatinBridge.php +++ b/bridges/NiceMatinBridge.php @@ -22,7 +22,7 @@ class NiceMatinBridge extends BridgeAbstract{ return $text; } - public function collectData(array $param){ + public function collectData(){ $html = $this->getSimpleHTMLDOM('http://www.nicematin.com/derniere-minute/rss') or $this->returnServerError('Could not request NiceMatin.'); $limit = 0; diff --git a/bridges/NovelUpdatesBridge.php b/bridges/NovelUpdatesBridge.php index 0bf451a7..84da2a9d 100644 --- a/bridges/NovelUpdatesBridge.php +++ b/bridges/NovelUpdatesBridge.php @@ -15,10 +15,11 @@ class NovelUpdatesBridge extends BridgeAbstract{ ); } - public function collectData(array $param){ - if (!isset($param['n'])) + public function collectData(){ + $param=$this->parameters[$this->queriedContext]; + if (!isset($param['n']['value'])) $this->returnClientError('You must specify the novel URL (/series/...)'); - $thread = parse_url($param['n']) or $this->returnClientError('This URL seems malformed, please check it.'); + $thread = parse_url($param['n']['value']) or $this->returnClientError('This URL seems malformed, please check it.'); if($thread['host'] !== 'www.novelupdates.com') $this->returnClientError('NovelUpdates URL only.'); if(strpos($thread['path'], 'series/') === FALSE) diff --git a/bridges/NumeramaBridge.php b/bridges/NumeramaBridge.php index d3bf5484..d9ae0835 100644 --- a/bridges/NumeramaBridge.php +++ b/bridges/NumeramaBridge.php @@ -10,7 +10,7 @@ class NumeramaBridge extends BridgeAbstract{ } - public function collectData(array $param) { + public function collectData(){ function NumeramaStripCDATA($string) { $string = str_replace('parameters[$this->queriedContext]; + if (empty($param['u']['value'])) { $this->returnServerError('Error: You must chose a category.'); } $html = ''; - $link = 'https://openclassrooms.com/courses?categories='.$param['u'].'&title=&sort=updatedAt+desc'; + $link = 'https://openclassrooms.com/courses?categories='.$param['u']['value'].'&title=&sort=updatedAt+desc'; $html = $this->getSimpleHTMLDOM($link) or $this->returnServerError('Could not request OpenClassrooms.'); diff --git a/bridges/ParuVenduImmoBridge.php b/bridges/ParuVenduImmoBridge.php index 528cde1c..345ef97d 100644 --- a/bridges/ParuVenduImmoBridge.php +++ b/bridges/ParuVenduImmoBridge.php @@ -29,7 +29,7 @@ class ParuVenduImmoBridge extends BridgeAbstract ); } - public function collectData(array $param) + public function collectData() { $html = ''; $num = 20; @@ -37,22 +37,22 @@ class ParuVenduImmoBridge extends BridgeAbstract $maison = '&tbMai=1&tbVil=1&tbCha=1&tbPro=1&tbHot=1&tbMou=1&tbFer=1'; $link = $this->uri.'/immobilier/annonceimmofo/liste/listeAnnonces?tt=1'.$appartment.$maison; - if (isset($param['minarea'])) { - $this->request .= ' '.$param['minarea'].' m2'; - $link .= '&sur0='.urlencode($param['minarea']); + if (isset($param['minarea']['value'])) { + $this->request .= ' '.$param['minarea']['value'].' m2'; + $link .= '&sur0='.urlencode($param['minarea']['value']); } - if (isset($param['maxprice'])) { - $link .= '&px1='.urlencode($param['maxprice']); + if (isset($param['maxprice']['value'])) { + $link .= '&px1='.urlencode($param['maxprice']['value']); } - if (isset($param['pa'])) { - $link .= '&pa='.urlencode($param['pa']); + if (isset($param['pa']['value'])) { + $link .= '&pa='.urlencode($param['pa']['value']); } - if (isset($param['lo'])) { - $this->request .= ' In: '.$param['lo']; - $link .= '&lo='.urlencode($param['lo']); + if (isset($param['lo']['value'])) { + $this->request .= ' In: '.$param['lo']['value']; + $link .= '&lo='.urlencode($param['lo']['value']); } $html = $this->getSimpleHTMLDOM($link) or $this->returnServerError('Could not request paruvendu.'); diff --git a/bridges/PickyWallpapersBridge.php b/bridges/PickyWallpapersBridge.php index b3512914..b35c9c36 100644 --- a/bridges/PickyWallpapersBridge.php +++ b/bridges/PickyWallpapersBridge.php @@ -28,19 +28,20 @@ class PickyWallpapersBridge extends BridgeAbstract { } - public function collectData(array $param){ + public function collectData(){ + $param=$this->parameters[$this->queriedContext]; $html = ''; - if (!isset($param['c'])) { + if (!isset($param['c']['value'])) { $this->returnClientError('You must specify at least a category (?c=...).'); } else { $baseUri = 'http://www.pickywallpapers.com'; - $this->category = $param['c']; - $this->subcategory = $param['s'] ?: ''; - $this->resolution = $param['r'] ?: '1920x1200'; // Wide wallpaper default + $this->category = $param['c']['value']; + $this->subcategory = $param['s']['value'] ?: ''; + $this->resolution = $param['r']['value'] ?: '1920x1200'; // Wide wallpaper default $num = 0; - $max = $param['m'] ?: 12; + $max = $param['m']['value'] ?: 12; $lastpage = 1; for ($page = 1; $page <= $lastpage; $page++) { diff --git a/bridges/PinterestBridge.php b/bridges/PinterestBridge.php index eb33607d..f82c7c71 100644 --- a/bridges/PinterestBridge.php +++ b/bridges/PinterestBridge.php @@ -22,27 +22,28 @@ class PinterestBridge extends BridgeAbstract{ ); } - public function collectData(array $param){ + public function collectData(){ + $param=$this->parameters[$this->queriedContext]; $html = ''; - if (isset($param['u']) || isset($param['b'])) { + if (isset($param['u']['value']) || isset($param['b']['value'])) { - if (empty($param['u'])) + if (empty($param['u']['value'])) { $this->returnClientError('You must specify a Pinterest username (?u=...).'); } - if (empty($param['b'])) + if (empty($param['b']['value'])) { $this->returnClientError('You must specify a Pinterest board for this username (?b=...).'); } - $this->username = $param['u']; - $this->board = $param['b']; + $this->username = $param['u']['value']; + $this->board = $param['b']['value']; $html = $this->getSimpleHTMLDOM($this->getURI().'/'.urlencode($this->username).'/'.urlencode($this->board)) or $this->returnServerError('Username and/or board not found'); - } else if (isset($param['q'])) + } else if (isset($param['q']['value'])) { - $this->query = $param['q']; + $this->query = $param['q']['value']; $html = $this->getSimpleHTMLDOM($this->getURI().'/search/?q='.urlencode($this->query)) or $this->returnServerError('Could not request Pinterest.'); } diff --git a/bridges/PlanetLibreBridge.php b/bridges/PlanetLibreBridge.php index 5c1c9bbc..02e95355 100644 --- a/bridges/PlanetLibreBridge.php +++ b/bridges/PlanetLibreBridge.php @@ -14,7 +14,7 @@ class PlanetLibreBridge extends BridgeAbstract{ return $text; } - public function collectData(array $param){ + public function collectData(){ $html = $this->getSimpleHTMLDOM('http://www.planet-libre.org/') or $this->returnServerError('Could not request PlanetLibre.'); $limit = 0; foreach($html->find('div.post') as $element) { diff --git a/bridges/ProjectMGameBridge.php b/bridges/ProjectMGameBridge.php index 02fc621a..b6dacbd8 100644 --- a/bridges/ProjectMGameBridge.php +++ b/bridges/ProjectMGameBridge.php @@ -11,7 +11,7 @@ class ProjectMGameBridge extends BridgeAbstract{ } - public function collectData(array $param){ + public function collectData(){ $html = ''; $html = $this->getSimpleHTMLDOM('http://projectmgame.com/en/') or $this->returnServerError('Error while downloading the Project M homepage'); diff --git a/bridges/RTBFBridge.php b/bridges/RTBFBridge.php index 5abea302..561bcc56 100644 --- a/bridges/RTBFBridge.php +++ b/bridges/RTBFBridge.php @@ -15,13 +15,14 @@ class RTBFBridge extends BridgeAbstract { ); } - public function collectData(array $param) { + public function collectData(){ + $param=$this->parameters[$this->queriedContext]; $html = ''; $limit = 10; $count = 0; - if (isset($param['c'])) { - $html = $this->getSimpleHTMLDOM('http://www.rtbf.be/auvio/emissions/detail?id='.$param['c']) or $this->returnServerError('Could not request RTBF.'); + if (isset($param['c']['value'])) { + $html = $this->getSimpleHTMLDOM('http://www.rtbf.be/auvio/emissions/detail?id='.$param['c']['value']) or $this->returnServerError('Could not request RTBF.'); foreach($html->find('section[id!=widget-ml-avoiraussi-] .rtbf-media-grid article') as $element) { if($count < $limit) { diff --git a/bridges/Releases3DSBridge.php b/bridges/Releases3DSBridge.php index 2cff757b..fb85fcb4 100644 --- a/bridges/Releases3DSBridge.php +++ b/bridges/Releases3DSBridge.php @@ -10,7 +10,7 @@ class Releases3DSBridge extends BridgeAbstract { } - public function collectData(array $param) { + public function collectData(){ function ExtractFromDelimiters($string, $start, $end) { if (strpos($string, $start) !== false) { diff --git a/bridges/ReporterreBridge.php b/bridges/ReporterreBridge.php index 3c1672bc..e3103443 100644 --- a/bridges/ReporterreBridge.php +++ b/bridges/ReporterreBridge.php @@ -25,7 +25,7 @@ class ReporterreBridge extends BridgeAbstract{ return $text; } - public function collectData(array $param){ + public function collectData(){ $html = $this->getSimpleHTMLDOM('http://www.reporterre.net/spip.php?page=backend') or $this->returnServerError('Could not request Reporterre.'); $limit = 0; diff --git a/bridges/Rue89Bridge.php b/bridges/Rue89Bridge.php index 76da28e9..39c6c4fc 100644 --- a/bridges/Rue89Bridge.php +++ b/bridges/Rue89Bridge.php @@ -19,7 +19,7 @@ class Rue89Bridge extends BridgeAbstract{ } - public function collectData(array $param){ + public function collectData(){ $html = $this->getSimpleHTMLDOM('http://api.rue89.nouvelobs.com/feed') or $this->returnServerError('Could not request Rue89.'); diff --git a/bridges/Rule34Bridge.php b/bridges/Rule34Bridge.php index e0bc4f1f..12c69259 100644 --- a/bridges/Rule34Bridge.php +++ b/bridges/Rule34Bridge.php @@ -18,15 +18,16 @@ class Rule34Bridge extends BridgeAbstract{ } - public function collectData(array $param){ + public function collectData(){ + $param=$this->parameters[$this->queriedContext]; $page = 0;$tags=''; - if (isset($param['p'])) { - $page = (int)preg_replace("/[^0-9]/",'', $param['p']); + if (isset($param['p']['value'])) { + $page = (int)preg_replace("/[^0-9]/",'', $param['p']['value']); $page = $page - 1; $page = $page * 50; } - if (isset($param['t'])) { - $tags = urlencode($param['t']); + if (isset($param['t']['value'])) { + $tags = urlencode($param['t']['value']); } $html = $this->getSimpleHTMLDOM("http://rule34.xxx/index.php?page=post&s=list&tags=$tags&pid=$page") or $this->returnServerError('Could not request Rule34.'); diff --git a/bridges/Rule34pahealBridge.php b/bridges/Rule34pahealBridge.php index dc569654..76605c66 100644 --- a/bridges/Rule34pahealBridge.php +++ b/bridges/Rule34pahealBridge.php @@ -18,13 +18,14 @@ class Rule34pahealBridge extends BridgeAbstract{ } - public function collectData(array $param){ + public function collectData(){ + $param=$this->parameters[$this->queriedContext]; $page = 0;$tags=''; - if (isset($param['p'])) { - $page = (int)preg_replace("/[^0-9]/",'', $param['p']); + if (isset($param['p']['value'])) { + $page = (int)preg_replace("/[^0-9]/",'', $param['p']['value']); } - if (isset($param['t'])) { - $tags = urlencode($param['t']); + if (isset($param['t']['value'])) { + $tags = urlencode($param['t']['value']); } $html = $this->getSimpleHTMLDOM("http://rule34.paheal.net/post/list/$tags/$page") or $this->returnServerError('Could not request Rule34paheal.'); diff --git a/bridges/SafebooruBridge.php b/bridges/SafebooruBridge.php index 3d3b6387..a6d98919 100644 --- a/bridges/SafebooruBridge.php +++ b/bridges/SafebooruBridge.php @@ -18,15 +18,16 @@ class SafebooruBridge extends BridgeAbstract{ } - public function collectData(array $param){ + public function collectData(){ + $param=$this->parameters[$this->queriedContext]; $page = 0;$tags=''; - if (isset($param['p'])) { - $page = (int)preg_replace("/[^0-9]/",'', $param['p']); + if (isset($param['p']['value'])) { + $page = (int)preg_replace("/[^0-9]/",'', $param['p']['value']); $page = $page - 1; $page = $page * 40; } - if (isset($param['t'])) { - $tags = urlencode($param['t']); + if (isset($param['t']['value'])) { + $tags = urlencode($param['t']['value']); } $html = $this->getSimpleHTMLDOM("http://safebooru.org/index.php?page=post&s=list&tags=$tags&pid=$page") or $this->returnServerError('Could not request Safebooru.'); diff --git a/bridges/SakugabooruBridge.php b/bridges/SakugabooruBridge.php index 03e44ac9..2a386013 100644 --- a/bridges/SakugabooruBridge.php +++ b/bridges/SakugabooruBridge.php @@ -18,13 +18,14 @@ class SakugabooruBridge extends BridgeAbstract{ } - public function collectData(array $param){ + public function collectData(){ + $param=$this->parameters[$this->queriedContext]; $page = 1;$tags=''; - if (isset($param['p'])) { - $page = (int)preg_replace("/[^0-9]/",'', $param['p']); + if (isset($param['p']['value'])) { + $page = (int)preg_replace("/[^0-9]/",'', $param['p']['value']); } - if (isset($param['t'])) { - $tags = urlencode($param['t']); + if (isset($param['t']['value'])) { + $tags = urlencode($param['t']['value']); } $html = $this->getSimpleHTMLDOM("http://sakuga.yshi.org/post?page=$page&tags=$tags") or $this->returnServerError('Could not request Sakugabooru.'); $input_json = explode('Post.register(', $html); diff --git a/bridges/ScmbBridge.php b/bridges/ScmbBridge.php index 13286f90..c1d6031b 100644 --- a/bridges/ScmbBridge.php +++ b/bridges/ScmbBridge.php @@ -10,7 +10,7 @@ class ScmbBridge extends BridgeAbstract{ } - public function collectData(array $param){ + public function collectData(){ $html = ''; $html = $this->getSimpleHTMLDOM('http://secouchermoinsbete.fr/') or $this->returnServerError('Could not request Se Coucher Moins Bete.'); diff --git a/bridges/ScoopItBridge.php b/bridges/ScoopItBridge.php index adb49ee6..6a233d44 100644 --- a/bridges/ScoopItBridge.php +++ b/bridges/ScoopItBridge.php @@ -17,10 +17,11 @@ class ScoopItBridge extends BridgeAbstract{ } - public function collectData(array $param){ + public function collectData(){ + $param=$this->parameters[$this->queriedContext]; $html = ''; - if ($param['u'] != '') { - $this->request = $param['u']; + if ($param['u']['value'] != '') { + $this->request = $param['u']['value']; $link = 'http://scoop.it/search?q=' .urlencode($this->request); $html = $this->getSimpleHTMLDOM($link) or $this->returnServerError('Could not request ScoopIt. for : ' . $link); diff --git a/bridges/SensCritiqueBridge.php b/bridges/SensCritiqueBridge.php index c400106e..0e44bdca 100644 --- a/bridges/SensCritiqueBridge.php +++ b/bridges/SensCritiqueBridge.php @@ -37,18 +37,19 @@ class SensCritiqueBridge extends BridgeAbstract { ); } - public function collectData(array $param) { - if ((isset($param['m']) && $param['m'])) { + public function collectData(){ + $param=$this->parameters[$this->queriedContext]; + if ((isset($param['m']['value']) && $param['m']['value'])) { $this->collectMoviesData(); - } else if ((isset($param['s']) && $param['s'])) { + } else if ((isset($param['s']['value']) && $param['s']['value'])) { $this->collectSeriesData(); - } else if ((isset($param['g']) && $param['g'])) { + } else if ((isset($param['g']['value']) && $param['g']['value'])) { $this->collectGamesData(); - } else if ((isset($param['b']) && $param['b'])) { + } else if ((isset($param['b']['value']) && $param['b']['value'])) { $this->collectBooksData(); - } else if ((isset($param['bd']) && $param['bd'])) { + } else if ((isset($param['bd']['value']) && $param['bd']['value'])) { $this->collectBDsData(); - } else if ((isset($param['mu']) && $param['mu'])) { + } else if ((isset($param['mu']['value']) && $param['mu']['value'])) { $this->collectMusicsData(); } else { $this->returnClientError('You must choose a category'); diff --git a/bridges/Sexactu.php b/bridges/Sexactu.php index 65305c79..839f6dd8 100644 --- a/bridges/Sexactu.php +++ b/bridges/Sexactu.php @@ -10,7 +10,7 @@ class Sexactu extends BridgeAbstract{ } - public function collectData(array $param){ + public function collectData(){ $find = array('janvier', 'février', 'mars', 'avril', 'mai', 'juin', 'juillet', 'août', 'septembre', 'novembre', 'décembre'); $replace = array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'); diff --git a/bridges/ShanaprojectBridge.php b/bridges/ShanaprojectBridge.php index 641e4fa2..5abc31f8 100644 --- a/bridges/ShanaprojectBridge.php +++ b/bridges/ShanaprojectBridge.php @@ -91,7 +91,7 @@ class ShanaprojectBridge extends BridgeAbstract {

Search episodes

'; } - public function collectData (array $param){ + public function collectData(){ $html = $this->LoadSeasonAnimeList(); $animes = $html->find('div.header_display_box_info'); diff --git a/bridges/SiliconBridge.php b/bridges/SiliconBridge.php index 1ef075a0..be064688 100644 --- a/bridges/SiliconBridge.php +++ b/bridges/SiliconBridge.php @@ -10,7 +10,7 @@ class SiliconBridge extends BridgeAbstract { } - public function collectData(array $param) { + public function collectData(){ function StripCDATA($string) { $string = str_replace('parameters[$this->queriedContext]; - if (isset($param['u']) && !empty($param['u'])) + if (isset($param['u']['value']) && !empty($param['u']['value'])) { - $this->request = $param['u']; + $this->request = $param['u']['value']; $res = json_decode($this->getContents('https://api.soundcloud.com/resolve?url=http://www.soundcloud.com/'. urlencode($this->request) .'&client_id=' . self::CLIENT_ID)) or $this->returnServerError('No results for this query'); $tracks = json_decode($this->getContents('https://api.soundcloud.com/users/'. urlencode($res->id) .'/tracks?client_id=' . self::CLIENT_ID)) or $this->returnServerError('No results for this user'); diff --git a/bridges/StripeAPIChangeLogBridge.php b/bridges/StripeAPIChangeLogBridge.php index f6aa7c99..107a9d33 100644 --- a/bridges/StripeAPIChangeLogBridge.php +++ b/bridges/StripeAPIChangeLogBridge.php @@ -14,7 +14,7 @@ class StripeAPIChangeLogBridge extends BridgeAbstract{ $this->description = 'Returns the changes made to the stripe.com API'; } - public function collectData(array $param){ + public function collectData(){ $html = $this->getSimpleHTMLDOM('https://stripe.com/docs/upgrades') or $this->returnServerError('No results for Stripe API Changelog'); diff --git a/bridges/SuperbWallpapersBridge.php b/bridges/SuperbWallpapersBridge.php index f8382066..a5146da9 100644 --- a/bridges/SuperbWallpapersBridge.php +++ b/bridges/SuperbWallpapersBridge.php @@ -26,15 +26,16 @@ class SuperbWallpapersBridge extends BridgeAbstract { } - public function collectData(array $param){ + public function collectData(){ + $param=$this->parameters[$this->queriedContext]; $html = ''; $baseUri = 'http://www.superbwallpapers.com'; - $this->category = $param['c'] ?: ''; // All default - $this->resolution = $param['r'] ?: '1920x1200'; // Wide wallpaper default + $this->category = $param['c']['value'] ?: ''; // All default + $this->resolution = $param['r']['value'] ?: '1920x1200'; // Wide wallpaper default $num = 0; - $max = $param['m'] ?: 36; + $max = $param['m']['value'] ?: 36; $lastpage = 1; // Get last page number diff --git a/bridges/T411Bridge.php b/bridges/T411Bridge.php index 35c73f5a..6791bfaa 100644 --- a/bridges/T411Bridge.php +++ b/bridges/T411Bridge.php @@ -16,7 +16,8 @@ class T411Bridge extends BridgeAbstract { ); } - public function collectData(array $param) { + public function collectData(){ + $param=$this->parameters[$this->queriedContext]; //Utility function for retrieving text based on start and end delimiters function ExtractFromDelimiters($string, $start, $end) { @@ -28,12 +29,12 @@ class T411Bridge extends BridgeAbstract { } //Ensure proper parameters have been provided - if (empty($param['search'])) { + if (empty($param['search']['value'])) { $this->returnClientError('You must specify a search criteria'); } //Retrieve torrent listing from search results, which does not contain torrent description - $url = $this->uri.'torrents/search/?'.$param['search'].'&order=added&type=desc'; + $url = $this->uri.'torrents/search/?'.$param['search']['value'].'&order=added&type=desc'; $html = $this->getSimpleHTMLDOM($url) or $this->returnServerError('Could not request t411: '.$url); $results = $html->find('table.results', 0); if (is_null($results)) diff --git a/bridges/TagBoardBridge.php b/bridges/TagBoardBridge.php index 2467f6c7..a9418dbb 100644 --- a/bridges/TagBoardBridge.php +++ b/bridges/TagBoardBridge.php @@ -17,9 +17,10 @@ class TagBoardBridge extends BridgeAbstract{ } - public function collectData(array $param){ + public function collectData(){ + $param=$this->parameters[$this->queriedContext]; $html = ''; - $this->request = $param['u']; + $this->request = $param['u']['value']; $link = 'https://post-cache.tagboard.com/search/' .$this->request; $html = $this->getSimpleHTMLDOM($link) or $this->returnServerError('Could not request TagBoard for : ' . $link); diff --git a/bridges/TbibBridge.php b/bridges/TbibBridge.php index 1d58d5ca..a7e0a72d 100644 --- a/bridges/TbibBridge.php +++ b/bridges/TbibBridge.php @@ -17,15 +17,16 @@ class TbibBridge extends BridgeAbstract{ ); } - public function collectData(array $param){ + public function collectData(){ + $param=$this->parameters[$this->queriedContext]; $page = 0;$tags=''; - if (isset($param['p'])) { - $page = (int)preg_replace("/[^0-9]/",'', $param['p']); + if (isset($param['p']['value'])) { + $page = (int)preg_replace("/[^0-9]/",'', $param['p']['value']); $page = $page - 1; $page = $page * 50; } - if (isset($param['t'])) { - $tags = urlencode($param['t']); + if (isset($param['t']['value'])) { + $tags = urlencode($param['t']['value']); } $html = $this->getSimpleHTMLDOM("http://tbib.org/index.php?page=post&s=list&tags=$tags&pid=$page") or $this->returnServerError('Could not request Tbib.'); diff --git a/bridges/TheCodingLoveBridge.php b/bridges/TheCodingLoveBridge.php index 704f5ec4..aae75c0e 100644 --- a/bridges/TheCodingLoveBridge.php +++ b/bridges/TheCodingLoveBridge.php @@ -10,7 +10,7 @@ class TheCodingLoveBridge extends BridgeAbstract{ } - public function collectData(array $param){ + public function collectData(){ $html = $this->getSimpleHTMLDOM('http://thecodinglove.com/') or $this->returnServerError('Could not request The Coding Love.'); foreach($html->find('div.post') as $element) { diff --git a/bridges/TheHackerNewsBridge.php b/bridges/TheHackerNewsBridge.php index 118c6754..932efe1c 100644 --- a/bridges/TheHackerNewsBridge.php +++ b/bridges/TheHackerNewsBridge.php @@ -10,7 +10,7 @@ class TheHackerNewsBridge extends BridgeAbstract { } - public function collectData(array $param) { + public function collectData(){ function StripWithDelimiters($string, $start, $end) { while (strpos($string, $start) !== false) { diff --git a/bridges/TheOatMealBridge.php b/bridges/TheOatMealBridge.php index a7bf308a..9cb7caa7 100644 --- a/bridges/TheOatMealBridge.php +++ b/bridges/TheOatMealBridge.php @@ -13,7 +13,8 @@ class TheOatmealBridge extends RssExpander{ } - public function collectData(array $param){ + public function collectData(){ + $param=$this->parameters[$this->queriedContext]; parent::collectExpandableDatas($param, THE_OATMEAL_RSS); } diff --git a/bridges/ThePirateBayBridge.php b/bridges/ThePirateBayBridge.php index 16bbe597..5b995e2b 100644 --- a/bridges/ThePirateBayBridge.php +++ b/bridges/ThePirateBayBridge.php @@ -16,7 +16,8 @@ class ThePirateBayBridge extends BridgeAbstract{ ); } - public function collectData(array $param){ + public function collectData(){ + $param=$this->parameters[$this->queriedContext]; function parseDateTimestamp($element){ $guessedDate = $element->find('font',0)->plaintext; @@ -52,10 +53,10 @@ class ThePirateBayBridge extends BridgeAbstract{ } - if (!isset($param['q'])) + if (!isset($param['q']['value'])) $this->returnClientError('You must specify keywords (?q=...)'); - $keywordsList = explode(";",$param['q']); + $keywordsList = explode(";",$param['q']['value']); foreach($keywordsList as $keywords){ $html = $this->getSimpleHTMLDOM('https://thepiratebay.org/search/'.rawurlencode($keywords).'/0/3/0') or $this->returnServerError('Could not request TPB.'); diff --git a/bridges/TwitchApiBridge.php b/bridges/TwitchApiBridge.php index 898145b1..1214b317 100644 --- a/bridges/TwitchApiBridge.php +++ b/bridges/TwitchApiBridge.php @@ -49,7 +49,8 @@ class TwitchApiBridge extends BridgeAbstract{ ); } - public function collectData(array $param){ + public function collectData(){ + $param=$this->parameters[$this->queriedContext]; /* In accordance with API description: * "When specifying a version for a request to the Twitch API, set the Accept HTTP header to the API version you prefer." @@ -68,19 +69,19 @@ class TwitchApiBridge extends BridgeAbstract{ $broadcasts = TWITCH_BROADCASTS; $requests = 1; - if(isset($param['channel'])) { - $channel = $param['channel']; + if(isset($param['channel']['value'])) { + $channel = $param['channel']['value']; } else { - $this->returnClientError('You must specify a valid channel name! Received: &channel=' . $param['channel']); + $this->returnClientError('You must specify a valid channel name! Received: &channel=' . $param['channel']['value']); } $this->channel = $channel; - if(isset($param['limit'])) { + if(isset($param['limit']['value'])) { try { - $limit = (int)$param['limit']; + $limit = (int)$param['limit']['value']; } catch (Exception $e){ - $this->returnClientError('The limit you specified is not valid! Received: &limit=' . $param['limit'] . ' Expected: &limit= where is any integer number.'); + $this->returnClientError('The limit you specified is not valid! Received: &limit=' . $param['limit']['value'] . ' Expected: &limit= where is any integer number.'); } } else { $limit = TWITCH_LIMIT; @@ -93,10 +94,10 @@ class TwitchApiBridge extends BridgeAbstract{ if($limit % 100 != 0) { $requests++; } } - if(isset($param['broadcasts']) && ($param['broadcasts'] == 'true' || $param['broadcasts'] == 'false')) { - $broadcasts = $param['broadcasts']; + if(isset($param['broadcasts']['value']) && ($param['broadcasts']['value'] == 'true' || $param['broadcasts']['value'] == 'false')) { + $broadcasts = $param['broadcasts']['value']; } else { - $this->returnClientError('The value for broadcasts you specified is not valid! Received: &broadcasts=' . $param['broadcasts'] . ' Expected: &broadcasts=false or &broadcasts=true'); + $this->returnClientError('The value for broadcasts you specified is not valid! Received: &broadcasts=' . $param['broadcasts']['value'] . ' Expected: &broadcasts=false or &broadcasts=true'); } // Build the initial request, see also: https://github.com/justintv/Twitch-API/blob/master/v3_resources/videos.md#get-channelschannelvideos diff --git a/bridges/TwitterBridge.php b/bridges/TwitterBridge.php index 06bcbf8c..2d5eb03c 100644 --- a/bridges/TwitterBridge.php +++ b/bridges/TwitterBridge.php @@ -40,21 +40,22 @@ class TwitterBridge extends BridgeAbstract{ ); } - public function collectData(array $param){ + public function collectData(){ + $param=$this->parameters[$this->queriedContext]; $html = ''; - if (isset($param['q'])) { /* keyword search mode */ - $html = $this->getSimpleHTMLDOM('https://twitter.com/search?q='.urlencode($param['q']).'&f=tweets') or $this->returnServerError('No results for this query.'); + if (isset($param['q']['value'])) { /* keyword search mode */ + $html = $this->getSimpleHTMLDOM('https://twitter.com/search?q='.urlencode($param['q']['value']).'&f=tweets') or $this->returnServerError('No results for this query.'); } - elseif (isset($param['u'])) { /* user timeline mode */ - $html = $this->getSimpleHTMLDOM('https://twitter.com/'.urlencode($param['u']).(isset($param['norep'])?'':'/with_replies')) or $this->returnServerError('Requested username can\'t be found.'); + elseif (isset($param['u']['value'])) { /* user timeline mode */ + $html = $this->getSimpleHTMLDOM('https://twitter.com/'.urlencode($param['u']['value']).(isset($param['norep']['value'])?'':'/with_replies')) or $this->returnServerError('Requested username can\'t be found.'); } else { $this->returnClientError('You must specify a keyword (?q=...) or a Twitter username (?u=...).'); } $hidePictures = false; - if (isset($param['nopic'])) - $hidePictures = $param['nopic'] === 'on'; + if (isset($param['nopic']['value'])) + $hidePictures = $param['nopic']['value'] === 'on'; foreach($html->find('div.js-stream-tweet') as $tweet) { $item = array(); diff --git a/bridges/UnsplashBridge.php b/bridges/UnsplashBridge.php index f9831d44..3295458b 100644 --- a/bridges/UnsplashBridge.php +++ b/bridges/UnsplashBridge.php @@ -24,15 +24,16 @@ class UnsplashBridge extends BridgeAbstract { ); } - public function collectData(array $param){ + public function collectData(){ + $param=$this->parameters[$this->queriedContext]; $html = ''; $baseUri = 'http://unsplash.com'; - $width = $param['w'] ?: '1920'; // Default width + $width = $param['w']['value'] ?: '1920'; // Default width $num = 0; - $max = $param['m'] ?: 20; - $quality = $param['q'] ?: 75; + $max = $param['m']['value'] ?: 20; + $quality = $param['q']['value'] ?: 75; $lastpage = 1; for ($page = 1; $page <= $lastpage; $page++) { diff --git a/bridges/ViadeoCompany.php b/bridges/ViadeoCompany.php index cb062878..0568d590 100644 --- a/bridges/ViadeoCompany.php +++ b/bridges/ViadeoCompany.php @@ -16,9 +16,10 @@ class ViadeoCompany extends BridgeAbstract{ ); } - public function collectData(array $param){ + public function collectData(){ + $param=$this->parameters[$this->queriedContext]; $html = ''; - $link = 'http://www.viadeo.com/fr/company/'.$param['c']; + $link = 'http://www.viadeo.com/fr/company/'.$param['c']['value']; $html = $this->getSimpleHTMLDOM($link) or $this->returnServerError('Could not request Viadeo.'); diff --git a/bridges/VineBridge.php b/bridges/VineBridge.php index 5f30d34c..5865262a 100644 --- a/bridges/VineBridge.php +++ b/bridges/VineBridge.php @@ -16,9 +16,10 @@ class VineBridge extends BridgeAbstract { ); } - public function collectData(array $param){ + public function collectData(){ + $param=$this->parameters[$this->queriedContext]; $html = ''; - $uri = 'http://vine.co/u/'.$param['u'].'?mode=list'; + $uri = 'http://vine.co/u/'.$param['u']['value'].'?mode=list'; $html = $this->getSimpleHTMLDOM($uri) or $this->returnServerError('No results for this query.'); diff --git a/bridges/VkBridge.php b/bridges/VkBridge.php index a7cf6ace..6f016554 100644 --- a/bridges/VkBridge.php +++ b/bridges/VkBridge.php @@ -17,10 +17,11 @@ class VkBridge extends BridgeAbstract { ); } - public function collectData(array $param) { + public function collectData(){ + $param=$this->parameters[$this->queriedContext]; $html = ''; - if (isset($param['u'])) { - $this->request = $param['u']; + if (isset($param['u']['value'])) { + $this->request = $param['u']['value']; $text_html = $this->getSimpleHTMLDOM(urldecode($this->request)) or $this->returnServerError('No results for this query.'); $text_html = iconv('windows-1251', 'utf-8', $text_html); $html = str_get_html($text_html); diff --git a/bridges/WallpaperStopBridge.php b/bridges/WallpaperStopBridge.php index f97e722a..d0bdad2c 100644 --- a/bridges/WallpaperStopBridge.php +++ b/bridges/WallpaperStopBridge.php @@ -27,19 +27,20 @@ class WallpaperStopBridge extends BridgeAbstract { } - public function collectData(array $param){ + public function collectData(){ + $param=$this->parameters[$this->queriedContext]; $html = ''; - if (!isset($param['c'])) { + if (!isset($param['c']['value'])) { $this->returnClientError('You must specify at least a category (?c=...).'); } else { $baseUri = 'http://www.wallpaperstop.com'; - $this->category = $param['c']; - $this->subcategory = $param['s'] ?: ''; - $this->resolution = $param['r'] ?: '1920x1200'; // Wide wallpaper default + $this->category = $param['c']['value']; + $this->subcategory = $param['s']['value'] ?: ''; + $this->resolution = $param['r']['value'] ?: '1920x1200'; // Wide wallpaper default $num = 0; - $max = $param['m'] ?: 20; + $max = $param['m']['value'] ?: 20; $lastpage = 1; for ($page = 1; $page <= $lastpage; $page++) { diff --git a/bridges/WeLiveSecurityBridge.php b/bridges/WeLiveSecurityBridge.php index e9aecdb9..9612f12e 100644 --- a/bridges/WeLiveSecurityBridge.php +++ b/bridges/WeLiveSecurityBridge.php @@ -8,7 +8,7 @@ class WeLiveSecurityBridge extends BridgeAbstract { $this->description = 'Returns the newest articles.'; } - public function collectData(array $param) { + public function collectData(){ function ExtractFromDelimiters($string, $start, $end) { if (strpos($string, $start) !== false) { diff --git a/bridges/WhydBridge.php b/bridges/WhydBridge.php index fbcba55d..5f8fb23f 100644 --- a/bridges/WhydBridge.php +++ b/bridges/WhydBridge.php @@ -20,11 +20,12 @@ class WhydBridge extends BridgeAbstract{ } - public function collectData(array $param){ + public function collectData(){ + $param=$this->parameters[$this->queriedContext]; $html = ''; - if (isset($param['u'])) + if (isset($param['u']['value'])) { - $this->request = $param['u']; + $this->request = $param['u']['value']; if (strlen(preg_replace("/[^0-9a-f]/",'', $this->request)) == 24) { // is input the userid ? $html = $this->getSimpleHTMLDOM('http://www.whyd.com/u/'.preg_replace("/[^0-9a-f]/",'', $this->request)) or $this->returnServerError('No results for this query.'); } else { // input may be the username diff --git a/bridges/WikipediaBridge.php b/bridges/WikipediaBridge.php index 401fd477..5f3ca77b 100644 --- a/bridges/WikipediaBridge.php +++ b/bridges/WikipediaBridge.php @@ -43,18 +43,19 @@ class WikipediaBridge extends BridgeAbstract{ ); } - public function collectData(array $params){ - if(!isset($params['language'])) + public function collectData(){ + $params=$this->parameters[$this->queriedContext]; + if(!isset($params['language']['value'])) $this->returnClientError('You must specify a valid language via \'&language=\'!'); - if(!$this->CheckLanguageCode(strtolower($params['language']))) - $this->returnClientError('The language code you provided (\'' . $params['language'] . '\') is not supported!'); + if(!$this->CheckLanguageCode(strtolower($params['language']['value']))) + $this->returnClientError('The language code you provided (\'' . $params['language']['value'] . '\') is not supported!'); - if(!isset($params['subject'])) + if(!isset($params['subject']['value'])) $this->returnClientError('You must specify a valid subject via \'&subject=\'!'); $subject = WIKIPEDIA_SUBJECT_TFA; - switch($params['subject']){ + switch($params['subject']['value']){ case 'tfa': $subject = WIKIPEDIA_SUBJECT_TFA; break; @@ -67,22 +68,22 @@ class WikipediaBridge extends BridgeAbstract{ } $fullArticle = false; - if(isset($params['fullarticle'])) - $fullArticle = $params['fullarticle'] === 'on' ? true : false; + if(isset($params['fullarticle']['value'])) + $fullArticle = $params['fullarticle']['value'] === 'on' ? true : false; // We store the correct URI as URI of this bridge (so it can be used later!) - $this->uri = 'https://' . strtolower($params['language']) . '.wikipedia.org'; + $this->uri = 'https://' . strtolower($params['language']['value']) . '.wikipedia.org'; // While we at it let's also update the name for the feed switch($subject){ case WIKIPEDIA_SUBJECT_TFA: - $this->name = 'Today\'s featured article from ' . strtolower($params['language']) . '.wikipedia.org'; + $this->name = 'Today\'s featured article from ' . strtolower($params['language']['value']) . '.wikipedia.org'; break; case WIKIPEDIA_SUBJECT_DYK: - $this->name = 'Did you know? - articles from ' . strtolower($params['language']) . '.wikipedia.org'; + $this->name = 'Did you know? - articles from ' . strtolower($params['language']['value']) . '.wikipedia.org'; break; default: - $this->name = 'Articles from ' . strtolower($params['language']) . '.wikipedia.org'; + $this->name = 'Articles from ' . strtolower($params['language']['value']) . '.wikipedia.org'; break; } @@ -97,7 +98,7 @@ class WikipediaBridge extends BridgeAbstract{ * We build the function name automatically, just make sure you create a private function ending * with your desired language code, where the language code is upper case! (en -> GetContentsEN). */ - $function = 'GetContents' . strtoupper($params['language']); + $function = 'GetContents' . strtoupper($params['language']['value']); if(!method_exists($this, $function)) $this->returnServerError('A function to get the contents for your langauage is missing (\'' . $function . '\')!'); diff --git a/bridges/WordPressBridge.php b/bridges/WordPressBridge.php index c7db5ac6..370b772c 100644 --- a/bridges/WordPressBridge.php +++ b/bridges/WordPressBridge.php @@ -53,7 +53,8 @@ class WordPressBridge extends BridgeAbstract { return $content; } - public function collectData(array $param) { + public function collectData(){ + $param=$this->parameters[$this->queriedContext]; $this->processParams($param); if (!$this->hasUrl()) { @@ -145,6 +146,6 @@ class WordPressBridge extends BridgeAbstract { } private function processParams($param) { - $this->url = $param['url']; + $this->url = $param['url']['value']; } } diff --git a/bridges/WorldOfTanksBridge.php b/bridges/WorldOfTanksBridge.php index b76c4834..09ffb750 100644 --- a/bridges/WorldOfTanksBridge.php +++ b/bridges/WorldOfTanksBridge.php @@ -35,14 +35,15 @@ class WorldOfTanksBridge extends HttpCachingBridgeAbstract{ } - public function collectData(array $param){ - if (!empty($param['lang'])) { - $this->lang = $param['lang']; + public function collectData(){ + $param=$this->parameters[$this->queriedContext]; + if (!empty($param['lang']['value'])) { + $this->lang = $param['lang']['value']; } - if(empty($param['category'])) { + if(empty($param['category']['value'])) { $this->uri = WORLD_OF_TANKS.$this->lang.NEWS; } else { - $this->uri = WORLD_OF_TANKS.$this->lang.NEWS.'pc-browser/'.$param['category']."/"; + $this->uri = WORLD_OF_TANKS.$this->lang.NEWS.'pc-browser/'.$param['category']['value']."/"; } $html = $this->getSimpleHTMLDOM($this->getURI()) or $this->returnServerError('Could not request '.$this->getURI()); $this->debugMessage("loaded HTML from ".$this->getURI()); diff --git a/bridges/XbooruBridge.php b/bridges/XbooruBridge.php index 7f4955ad..75fa65f4 100644 --- a/bridges/XbooruBridge.php +++ b/bridges/XbooruBridge.php @@ -17,15 +17,16 @@ class XbooruBridge extends BridgeAbstract{ ); } - public function collectData(array $param){ + public function collectData(){ + $param=$this->parameters[$this->queriedContext]; $page = 0;$tags=''; - if (isset($param['p'])) { - $page = (int)preg_replace("/[^0-9]/",'', $param['p']); + if (isset($param['p']['value'])) { + $page = (int)preg_replace("/[^0-9]/",'', $param['p']['value']); $page = $page - 1; $page = $page * 50; } - if (isset($param['t'])) { - $tags = urlencode($param['t']); + if (isset($param['t']['value'])) { + $tags = urlencode($param['t']['value']); } $html = $this->getSimpleHTMLDOM("http://xbooru.com/index.php?page=post&s=list&tags=$tags&pid=$page") or $this->returnServerError('Could not request Xbooru.'); diff --git a/bridges/YandereBridge.php b/bridges/YandereBridge.php index 5a249833..05391289 100644 --- a/bridges/YandereBridge.php +++ b/bridges/YandereBridge.php @@ -17,13 +17,14 @@ class YandereBridge extends BridgeAbstract{ ); } - public function collectData(array $param){ + public function collectData(){ + $param=$this->parameters[$this->queriedContext]; $page = 1; $tags = ''; - if (isset($param['p'])) { - $page = (int)preg_replace("/[^0-9]/",'', $param['p']); + if (isset($param['p']['value'])) { + $page = (int)preg_replace("/[^0-9]/",'', $param['p']['value']); } - if (isset($param['t'])) { - $tags = urlencode($param['t']); + if (isset($param['t']['value'])) { + $tags = urlencode($param['t']['value']); } $html = $this->getSimpleHTMLDOM("https://yande.re/post?page=$page&tags=$tags") or $this->returnServerError('Could not request Yandere.'); $input_json = explode('Post.register(', $html); diff --git a/bridges/YoutubeBridge.php b/bridges/YoutubeBridge.php index 2f8ac99b..87d58a38 100644 --- a/bridges/YoutubeBridge.php +++ b/bridges/YoutubeBridge.php @@ -105,19 +105,20 @@ class YoutubeBridge extends BridgeAbstract { return html_entity_decode($title,ENT_QUOTES,'UTF-8'); } - public function collectData(array $param) { + public function collectData(){ + $param=$this->parameters[$this->queriedContext]; $xml = ''; $html = ''; $url_feed = ''; $url_listing = ''; - if (isset($param['u'])) { /* User and Channel modes */ - $this->request = $param['u']; + if (isset($param['u']['value'])) { /* User and Channel modes */ + $this->request = $param['u']['value']; $url_feed = $this->uri.'feeds/videos.xml?user='.urlencode($this->request); $url_listing = $this->uri.'user/'.urlencode($this->request).'/videos'; - } else if (isset($param['c'])) { - $this->request = $param['c']; + } else if (isset($param['c']['value'])) { + $this->request = $param['c']['value']; $url_feed = $this->uri.'feeds/videos.xml?channel_id='.urlencode($this->request); $url_listing = $this->uri.'channel/'.urlencode($this->request).'/videos'; } @@ -129,16 +130,16 @@ class YoutubeBridge extends BridgeAbstract { } else $this->returnServerError("Could not request YouTube. Tried:\n - $url_feed\n - $url_listing"); } - else if (isset($param['p'])) { /* playlist mode */ - $this->request = $param['p']; + else if (isset($param['p']['value'])) { /* playlist mode */ + $this->request = $param['p']['value']; $url_listing = $this->uri.'playlist?list='.urlencode($this->request); $html = $this->getSimpleHTMLDOM($url_listing) or $this->returnServerError("Could not request YouTube. Tried:\n - $url_listing"); $this->ytBridgeParseHtmlListing($html, 'tr.pl-video', '.pl-video-title a'); $this->request = 'Playlist: '.str_replace(' - YouTube', '', $html->find('title', 0)->plaintext); } - else if (isset($param['s'])) { /* search mode */ - $this->request = $param['s']; $page = 1; if (isset($param['pa'])) $page = (int)preg_replace("/[^0-9]/",'', $param['pa']); + else if (isset($param['s']['value'])) { /* search mode */ + $this->request = $param['s']['value']; $page = 1; if (isset($param['pa']['value'])) $page = (int)preg_replace("/[^0-9]/",'', $param['pa']['value']); $url_listing = $this->uri.'results?search_query='.urlencode($this->request).'&page='.$page.'&filters=video&search_sort=video_date_uploaded'; $html = $this->getSimpleHTMLDOM($url_listing) or $this->returnServerError("Could not request YouTube. Tried:\n - $url_listing"); $this->ytBridgeParseHtmlListing($html, 'div.yt-lockup', 'h3'); diff --git a/bridges/ZDNetBridge.php b/bridges/ZDNetBridge.php index 947aebde..989c047f 100644 --- a/bridges/ZDNetBridge.php +++ b/bridges/ZDNetBridge.php @@ -162,7 +162,8 @@ class ZDNetBridge extends BridgeAbstract { ); } - public function collectData(array $param) { + public function collectData(){ + $param=$this->parameters[$this->queriedContext]; function StripCDATA($string) { $string = str_replace('getURI(); - $feed = $param['feed']; + $feed = $param['feed']['value']; if (empty($feed)) $this->returnClientError('Please select a feed to display.'); if (strpos($feed, 'downloads!') !== false) { diff --git a/bridges/ZatazBridge.php b/bridges/ZatazBridge.php index b37cd8d3..ce80054f 100644 --- a/bridges/ZatazBridge.php +++ b/bridges/ZatazBridge.php @@ -10,7 +10,7 @@ class ZatazBridge extends BridgeAbstract { } - public function collectData(array $param) { + public function collectData(){ $html = $this->getSimpleHTMLDOM($this->uri) or $this->returnServerError('Could not request ' . $this->uri); $recent_posts = $html->find('#recent-posts-3', 0)->find('ul', 0)->find('li'); diff --git a/bridges/ZoneTelechargementBridge.php b/bridges/ZoneTelechargementBridge.php index 7e8084df..7ff7d3ee 100644 --- a/bridges/ZoneTelechargementBridge.php +++ b/bridges/ZoneTelechargementBridge.php @@ -13,7 +13,8 @@ class ZoneTelechargementBridge extends BridgeAbstract { ); } - public function collectData(array $param) { + public function collectData(){ + $param=$this->parameters[$this->queriedContext]; function StripCDATA($string) { $string = str_replace('getURI().$category.'rss.xml'; $html = $this->getSimpleHTMLDOM($url) or $this->returnServerError('Could not request Zone Telechargement: '.$url); diff --git a/lib/Bridge.php b/lib/Bridge.php index c5843fcb..86a165c7 100644 --- a/lib/Bridge.php +++ b/lib/Bridge.php @@ -103,7 +103,7 @@ EOD; } interface BridgeInterface { - public function collectData(array $param); + public function collectData(); public function getCacheDuration(); public function loadMetadatas(); public function getName(); @@ -121,6 +121,7 @@ abstract class BridgeAbstract implements BridgeInterface { public $maintainer = 'No maintainer'; public $useProxy = true; public $parameters = array(); + protected $queriedContext=''; protected function returnError($message, $code){ throw new \HttpException($message, $code); @@ -201,6 +202,41 @@ abstract class BridgeAbstract implements BridgeInterface { return $validated; } + protected function getQueriedContext(){ + $queriedContexts=array(); + foreach($this->parameters as $context=>$set){ + $queriedContexts[$context]=null; + foreach($set as $id=>$properties){ + if(isset($properties['value']) && + !empty($properties['value'])){ + $queriedContexts[$context]=true; + }elseif(isset($properties['required']) && + $properties['required']===true){ + $queriedContexts[$context]=false; + break; + } + } + } + + if(isset($this->parameters['global']) && + $queriedContexts['global']===false){ + return null; + } + unset($queriedContexts['global']); + + switch(array_sum($queriedContexts)){ + case 0: + foreach($queriedContexts as $context=>$queried){ + if (is_null($queried)){ + return $context; + } + } + return null; + case 1: return array_search(true,$queriedContexts); + default: return false; + } + } + /** * Defined datas with parameters depending choose bridge * Note : you can define a cache with "setCache" @@ -217,10 +253,32 @@ abstract class BridgeAbstract implements BridgeInterface { if($time !== false && (time() - $this->getCacheDuration() < $time)){ $this->items = $this->cache->loadData(); } else { - if(!$this->validateData($param)){ + if($this->validateData($param)){ + foreach($param as $name=>$value){ + foreach($this->parameters as $context=>$set){ + if(isset($this->parameters[$context][$name])) + $this->parameters[$context][$name]['value']=$value; + } + } + if(!empty($this->parameters)){ + $queriedContext=$this->getQueriedContext(); + if(is_null($queriedContext)){ + $this->returnClientError('Required parameter(s) missing'); + }else if($queriedContext===false){ + $this->returnClientError('Mixed context parameters'); + }else{ + $this->queriedContext=$queriedContext; + foreach($param as $name=>$value){ + if(isset($this->parameters['global'][$name])){ + $this->parameters[$queriedContext][$name]['value']=$value; + } + } + } + } + }else{ $this->returnClientError('Invalid parameters value(s)'); } - $this->collectData($param); + $this->collectData(); if(!is_null($this->cache)){ $this->cache->saveData($this->getDatas()); From c34fdfa7fbbcf0089b54c462b788ad9d810b37b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Mazi=C3=A8re?= Date: Thu, 25 Aug 2016 01:49:30 +0200 Subject: [PATCH 12/22] [TwitterBridge] fix bridge name and bridge uri MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Pierre Mazière --- bridges/TwitterBridge.php | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/bridges/TwitterBridge.php b/bridges/TwitterBridge.php index 2d5eb03c..f3ad13bd 100644 --- a/bridges/TwitterBridge.php +++ b/bridges/TwitterBridge.php @@ -40,6 +40,32 @@ class TwitterBridge extends BridgeAbstract{ ); } + public function getName(){ + switch($this->queriedContext){ + case 'By keyword or hashtag': + $specific='search '; + $param='q'; + break; + case 'By username': + $specific='@'; + $param='u'; + break; + } + return 'Twitter '.$specific + .$this->parameters[$this->queriedContext][$param]['value']; + } + + public function getURI(){ + $params=$this->parameters[$this->queriedContext]; + switch($this->queriedContext){ + case 'By keyword or hashtag': + return $this->uri.'search?q='.urlencode($params['q']['value']); + case 'By username': + return $this->uri.urlencode($params['u']['value']). + (isset($params['norep']['value'])?'':'/with_replies'); + } + } + public function collectData(){ $param=$this->parameters[$this->queriedContext]; $html = ''; From af1673d1c4fe23322fd08724caa3478e34655b43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Mazi=C3=A8re?= Date: Thu, 25 Aug 2016 15:40:33 +0200 Subject: [PATCH 13/22] [WelLiveSecurity] fix proxy bypass MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Pierre Mazière --- bridges/WeLiveSecurityBridge.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bridges/WeLiveSecurityBridge.php b/bridges/WeLiveSecurityBridge.php index 9612f12e..dc7c2b58 100644 --- a/bridges/WeLiveSecurityBridge.php +++ b/bridges/WeLiveSecurityBridge.php @@ -36,7 +36,7 @@ class WeLiveSecurityBridge extends BridgeAbstract { $article_image = $element->find('image', 0)->plaintext; $article_url = ExtractFromDelimiters($element->innertext, '', ''); $article_summary = ExtractFromDelimiters($element->innertext, '', '

'); - $article_html = file_get_contents($article_url) or $this->returnServerError('Could not request '.$this->getName().': '.$article_url); + $article_html = $this->getContents($article_url) or $this->returnServerError('Could not request '.$this->getName().': '.$article_url); if (substr($article_html, 0, 2) == "\x1f\x8b") //http://www.gzip.org/zlib/rfc-gzip.html#header-trailer -> GZip ID1 $article_html = gzdecode($article_html); //Response is GZipped even if we didn't accept GZip!? Let's decompress... $article_html = str_get_html($article_html); //Now we have our HTML data. But still, that's an important HTTP violation... From 3bad5ec45c326313b8f8a593f549095da4f57a7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Mazi=C3=A8re?= Date: Thu, 25 Aug 2016 17:07:37 +0200 Subject: [PATCH 14/22] [TwitterBridge] fix 'nopic' feature MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Pierre Mazière --- bridges/TwitterBridge.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bridges/TwitterBridge.php b/bridges/TwitterBridge.php index f3ad13bd..94048240 100644 --- a/bridges/TwitterBridge.php +++ b/bridges/TwitterBridge.php @@ -81,7 +81,7 @@ class TwitterBridge extends BridgeAbstract{ $hidePictures = false; if (isset($param['nopic']['value'])) - $hidePictures = $param['nopic']['value'] === 'on'; + $hidePictures = $param['nopic']['value']; foreach($html->find('div.js-stream-tweet') as $tweet) { $item = array(); From a67a219bf97012a02c89fdffcbe7441b50ecad37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Mazi=C3=A8re?= Date: Thu, 25 Aug 2016 17:11:49 +0200 Subject: [PATCH 15/22] [core] remove '$param' argument from RssExpander::collectExpandableDatas MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Pierre Mazière --- bridges/AcrimedBridge.php | 5 ++--- bridges/CpasbienBridge.php | 18 ++++++------------ bridges/FreenewsBridge.php | 3 +-- bridges/GawkerBridge.php | 2 +- bridges/Les400CulsBridge.php | 5 ++--- bridges/TheOatMealBridge.php | 7 +++---- lib/Bridge.php | 6 +++--- 7 files changed, 18 insertions(+), 28 deletions(-) diff --git a/bridges/AcrimedBridge.php b/bridges/AcrimedBridge.php index c84544c2..8ddbc853 100644 --- a/bridges/AcrimedBridge.php +++ b/bridges/AcrimedBridge.php @@ -11,12 +11,11 @@ class AcrimedBridge extends RssExpander{ } public function collectData(){ - $param=$this->parameters[$this->queriedContext]; - parent::collectExpandableDatas($param, "http://www.acrimed.org/spip.php?page=backend"); + parent::collectExpandableDatas("http://www.acrimed.org/spip.php?page=backend"); } - + protected function parseRSSItem($newsItem) { $hs = new HTMLSanitizer(); diff --git a/bridges/CpasbienBridge.php b/bridges/CpasbienBridge.php index c0583cfc..d41d4423 100644 --- a/bridges/CpasbienBridge.php +++ b/bridges/CpasbienBridge.php @@ -1,8 +1,6 @@ maintainer = "lagaisse"; @@ -23,13 +21,11 @@ class CpasbienBridge extends HttpCachingBridgeAbstract{ public function collectData(){ $param=$this->parameters[$this->queriedContext]; - $this->loadMetadatas(); $html = ''; if (isset($param['q']['value'])) { /* keyword search mode */ - $this->request = str_replace(" ","-",trim($param['q']['value'])); - $html = $this->getSimpleHTMLDOM($this->uri.'/recherche/'.urlencode($this->request).'.html') or $this->returnServerError('No results for this query.'); - } - else { + $request = str_replace(" ","-",trim($param['q']['value'])); + $html = $this->getSimpleHTMLDOM($this->uri.'/recherche/'.urlencode($request).'.html') or $this->returnServerError('No results for this query.'); + } else { $this->returnClientError('You must specify a keyword (?q=...).'); } @@ -46,8 +42,7 @@ class CpasbienBridge extends HttpCachingBridgeAbstract{ $textefiche=$htmlepisode->find('#textefiche', 0)->find('p',1); if (isset($textefiche)) { $item['content'] = $textefiche->text(); - } - else { + } else { $p=$htmlepisode->find('#textefiche',0)->find('p'); if(!empty($p)){ $item['content'] = $htmlepisode->find('#textefiche', 0)->find('p',0)->text(); @@ -59,13 +54,12 @@ class CpasbienBridge extends HttpCachingBridgeAbstract{ $this->items[] = $item; } } - - } public function getName(){ - return (!empty($this->request) ? $this->request .' - ' : '') . $this->name; + return $this->parameters[$this->queriedContext]['q']['value'] + .' : '.$this->name; } public function getCacheDuration(){ diff --git a/bridges/FreenewsBridge.php b/bridges/FreenewsBridge.php index f84dc7ac..bc2c193b 100644 --- a/bridges/FreenewsBridge.php +++ b/bridges/FreenewsBridge.php @@ -15,8 +15,7 @@ class FreenewsBridge extends RssExpander { } public function collectData(){ - $param=$this->parameters[$this->queriedContext]; - parent::collectExpandableDatas($param, FREENEWS_RSS); + parent::collectExpandableDatas(FREENEWS_RSS); } protected function parseRSSItem($newsItem) { diff --git a/bridges/GawkerBridge.php b/bridges/GawkerBridge.php index cc1ae631..65a9ce1f 100644 --- a/bridges/GawkerBridge.php +++ b/bridges/GawkerBridge.php @@ -30,7 +30,7 @@ class GawkerBridge extends RssExpander{ $url = $this->toURI(strtolower($param['site']['value'])); } $this->debugMessage("loading feed from ".$this->getURI()); - parent::collectExpandableDatas($param, $url); + parent::collectExpandableDatas($url); } protected function parseRSSItem($newsItem) { diff --git a/bridges/Les400CulsBridge.php b/bridges/Les400CulsBridge.php index 2fc09125..2dd9883f 100644 --- a/bridges/Les400CulsBridge.php +++ b/bridges/Les400CulsBridge.php @@ -15,10 +15,9 @@ class Les400CulsBridge extends RssExpander{ public function collectData(){ - $param=$this->parameters[$this->queriedContext]; - parent::collectExpandableDatas($param, SEXE_FEED); + parent::collectExpandableDatas(SEXE_FEED); } - + protected function parseRSSItem($newsItem) { $item = array(); $item['title'] = trim((string) $newsItem->title); diff --git a/bridges/TheOatMealBridge.php b/bridges/TheOatMealBridge.php index 9cb7caa7..c6ab0cd0 100644 --- a/bridges/TheOatMealBridge.php +++ b/bridges/TheOatMealBridge.php @@ -14,8 +14,7 @@ class TheOatmealBridge extends RssExpander{ } public function collectData(){ - $param=$this->parameters[$this->queriedContext]; - parent::collectExpandableDatas($param, THE_OATMEAL_RSS); + parent::collectExpandableDatas(THE_OATMEAL_RSS); } @@ -51,14 +50,14 @@ class TheOatmealBridge extends RssExpander{ $content = $articlePage->find('#blog'); } $item['content'] = $content->innertext; - + $this->debugMessage("dc content is ".var_export($dc, true)); $item['author'] = (string) $dc->creator; $item['timestamp'] = DateTime::createFromFormat(DateTime::ISO8601, $dc->date)->getTimestamp(); $this->debugMessage("writtem by ".$item['author']." on ".$item['timestamp']); return $item; } - + public function getCacheDuration(){ return 7200; // 2h hours } diff --git a/lib/Bridge.php b/lib/Bridge.php index 86a165c7..b13ab523 100644 --- a/lib/Bridge.php +++ b/lib/Bridge.php @@ -467,12 +467,12 @@ abstract class HttpCachingBridgeAbstract extends BridgeAbstract { abstract class RssExpander extends HttpCachingBridgeAbstract { - public function collectExpandableDatas(array $param, $name){ + public function collectExpandableDatas($name){ if(empty($name)){ $this->returnServerError('There is no $name for this RSS expander'); } - $this->debugMessage('Loading from ' . $param['url']); + $this->debugMessage('Loading from ' . $name); /* Notice we do not use cache here on purpose: * we want a fresh view of the RSS stream each time @@ -480,7 +480,7 @@ abstract class RssExpander extends HttpCachingBridgeAbstract { $content = $this->getContents($name) or $this->returnServerError('Could not request ' . $name); $rssContent = simplexml_load_string($content); - $this->debugMessage('loaded RSS from ' . $param['url']); + $this->debugMessage('loaded RSS from ' . $name); // TODO insert RSS format detection // For now we always assume RSS 2.0 $this->collect_RSS_2_0_data($rssContent); From 3a0a2a95596c524ef47a9d2174b715c1468ac140 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Mazi=C3=A8re?= Date: Thu, 25 Aug 2016 17:12:23 +0200 Subject: [PATCH 16/22] =?UTF-8?q?[FreenewsBridge]=20remove=20unused=20para?= =?UTF-8?q?meter=20'id'=20Signed-off-by:=20Pierre=20Mazi=C3=A8re=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bridges/FreenewsBridge.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/bridges/FreenewsBridge.php b/bridges/FreenewsBridge.php index bc2c193b..727f9f5f 100644 --- a/bridges/FreenewsBridge.php +++ b/bridges/FreenewsBridge.php @@ -8,10 +8,6 @@ class FreenewsBridge extends RssExpander { $this->name = "Freenews"; $this->uri = "http://freenews.fr"; $this->description = "Un site d'actualité pour les freenautes (mais ne parlant pas que de la freebox). Ne rentrez pas d'id si vous voulez accéder aux actualités générales."; - - $this->parameters[] = array( - 'id'=>array('name'=>'Id de la rubrique (sans le \'-\')') - ); } public function collectData(){ From b6fe424ddb6f85a0b6e26861253ccbcfc92bf693 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Mazi=C3=A8re?= Date: Thu, 25 Aug 2016 17:12:54 +0200 Subject: [PATCH 17/22] [Gawker] fix parameter 'site' requirement status MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Pierre Mazière --- bridges/GawkerBridge.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bridges/GawkerBridge.php b/bridges/GawkerBridge.php index 65a9ce1f..60122208 100644 --- a/bridges/GawkerBridge.php +++ b/bridges/GawkerBridge.php @@ -12,7 +12,10 @@ class GawkerBridge extends RssExpander{ $this->description = "A bridge allowing access to any of the numerous Gawker media blogs (Lifehacker, deadspin, Kotaku, Jezebel, and so on. Notice you have to give its id to find the RSS stream in gawker maze"; $this->parameters[] = array( - 'site'=>array('name'=>'site id to put in uri between feeds.gawker.com and /full .. which is obviously not full AT ALL') + 'site'=>array( + 'name'=>'site id to put in uri between feeds.gawker.com and /full .. which is obviously not full AT ALL', + 'required'=>true + ) ); } From 23a7edebd629b4c60aa456323c92a4f966f0a7fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Mazi=C3=A8re?= Date: Thu, 25 Aug 2016 17:15:52 +0200 Subject: [PATCH 18/22] [WorldOfTanksBridge] code factorization MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Pierre Mazière --- bridges/WorldOfTanksBridge.php | 39 +++++++++++++++++----------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/bridges/WorldOfTanksBridge.php b/bridges/WorldOfTanksBridge.php index 09ffb750..98f27bf0 100644 --- a/bridges/WorldOfTanksBridge.php +++ b/bridges/WorldOfTanksBridge.php @@ -1,11 +1,6 @@ maintainer = "mitsukarenai"; @@ -14,10 +9,10 @@ class WorldOfTanksBridge extends HttpCachingBridgeAbstract{ $this->description = "News about the tank slaughter game."; $this->parameters[] = array( - 'category'=>array( - 'name'=>'ID de la catégorie', - 'type'=>'number' - ), + 'category'=>array( + // TODO: should be a list + 'name'=>'nom de la catégorie' + ), 'lang'=>array( 'name'=>'Langue', 'type'=>'list', @@ -34,17 +29,21 @@ class WorldOfTanksBridge extends HttpCachingBridgeAbstract{ ); } + function getURI(){ + $param=$this->parameters[$this->queriedContext]; + $lang='fr'; + if (!empty($param['lang']['value'])) { + $lang = $param['lang']['value']; + } + + $uri = $this->uri.$lang.'/news/'; + if(!empty($param['category']['value'])) { + $uri .= 'pc-browser/'.$param['category']['value']."/"; + } + return $uri; + } public function collectData(){ - $param=$this->parameters[$this->queriedContext]; - if (!empty($param['lang']['value'])) { - $this->lang = $param['lang']['value']; - } - if(empty($param['category']['value'])) { - $this->uri = WORLD_OF_TANKS.$this->lang.NEWS; - } else { - $this->uri = WORLD_OF_TANKS.$this->lang.NEWS.'pc-browser/'.$param['category']['value']."/"; - } $html = $this->getSimpleHTMLDOM($this->getURI()) or $this->returnServerError('Could not request '.$this->getURI()); $this->debugMessage("loaded HTML from ".$this->getURI()); // customize name @@ -56,12 +55,12 @@ class WorldOfTanksBridge extends HttpCachingBridgeAbstract{ private function parseLine($infoLink) { $item = array(); - $item['uri'] = WORLD_OF_TANKS.$infoLink->href; + $item['uri'] = $this->uri.$infoLink->href; // now load that uri from cache $this->debugMessage("loading page ".$item['uri']); $articlePage = str_get_html($this->get_cached($item['uri'])); $content = $articlePage->find('.l-content', 0); - HTMLSanitizer::defaultImageSrcTo($content, WORLD_OF_TANKS); + HTMLSanitizer::defaultImageSrcTo($content, $this->uri); $item['title'] = $content->find('h1', 0)->innertext; $item['content'] = $content->find('.b-content', 0)->innertext; $item['timestamp'] = $content->find('.b-statistic_time', 0)->getAttribute("data-timestamp"); From 5e33a27f7c2b87cde2e47db72d2b9f0c75199ff6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Mazi=C3=A8re?= Date: Thu, 25 Aug 2016 17:18:26 +0200 Subject: [PATCH 19/22] [KununuBridge] fix 'fullarticle' feature MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Pierre Mazière --- bridges/KununuBridge.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bridges/KununuBridge.php b/bridges/KununuBridge.php index 9e08e917..e81917d8 100644 --- a/bridges/KununuBridge.php +++ b/bridges/KununuBridge.php @@ -54,7 +54,7 @@ class KununuBridge extends BridgeAbstract{ $full = false; // By default we'll load only short article if(isset($params['full']['value'])) - $full = strtolower(trim($params['full']['value'])) === 'on'; + $full = strtolower(trim($params['full']['value'])); // Get reviews section name (depends on site) $section = ''; From b676eca0a2df6fa3902091e10d937705d149a878 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Mazi=C3=A8re?= Date: Thu, 25 Aug 2016 17:18:47 +0200 Subject: [PATCH 20/22] [WikipediaBridge] fix 'fullarticle' feature MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Pierre Mazière --- bridges/WikipediaBridge.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bridges/WikipediaBridge.php b/bridges/WikipediaBridge.php index 5f3ca77b..4ab7be75 100644 --- a/bridges/WikipediaBridge.php +++ b/bridges/WikipediaBridge.php @@ -69,7 +69,7 @@ class WikipediaBridge extends BridgeAbstract{ $fullArticle = false; if(isset($params['fullarticle']['value'])) - $fullArticle = $params['fullarticle']['value'] === 'on' ? true : false; + $fullArticle = $params['fullarticle']['value']; // We store the correct URI as URI of this bridge (so it can be used later!) $this->uri = 'https://' . strtolower($params['language']['value']) . '.wikipedia.org'; From 2670a0e400dcda72ed3cfaaea328f91ac0a792a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Mazi=C3=A8re?= Date: Thu, 25 Aug 2016 17:28:47 +0200 Subject: [PATCH 21/22] [core] get parameters from $_GET rather than $_REQUEST MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit No need to play with parameters that RSS-Bridge did not ask for Signed-off-by: Pierre Mazière --- index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.php b/index.php index e3071341..2e84ab31 100644 --- a/index.php +++ b/index.php @@ -127,7 +127,7 @@ try{ $bridge->useProxy=false; } $bridge->loadMetadatas(); - $params=$_REQUEST; + $params=$_GET; unset($params['action']); unset($params['bridge']); unset($params['format']); From 3f36ca2a9b272ba2a8d073e679fb17c9c764a6d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Mazi=C3=A8re?= Date: Thu, 25 Aug 2016 17:52:44 +0200 Subject: [PATCH 22/22] [core] unexpected input generates a fail MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit because paranoïa is the way to security ! Should this be optional ? Signed-off-by: Pierre Mazière --- lib/Bridge.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/Bridge.php b/lib/Bridge.php index b13ab523..55c85c06 100644 --- a/lib/Bridge.php +++ b/lib/Bridge.php @@ -146,8 +146,10 @@ abstract class BridgeAbstract implements BridgeInterface { protected function validateData(&$data){ $validated=true; foreach($data as $name=>$value){ + $registered=false; foreach($this->parameters as $context=>$set){ if(array_key_exists($name,$set)){ + $registered=true; if(!isset($set[$name]['type'])){ $set[$name]['type']='text'; } @@ -197,6 +199,9 @@ abstract class BridgeAbstract implements BridgeInterface { } } } + if(!$registered){ + $validated=false; + } } return $validated;