From 556b8a245288dd417cd37f2eecd95a2b578af7aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Mazi=C3=A8re?= Date: Tue, 30 Aug 2016 11:23:15 +0200 Subject: [PATCH 1/2] [core] transform some BridgeAbstract members to class constants MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This concerns $uri, $name, $maintainer, $parameters and $description Signed-off-by: Pierre Mazière --- lib/Bridge.php | 72 ++++++++++++++++++++++++++++------------------- lib/HTMLUtils.php | 15 +++++----- 2 files changed, 51 insertions(+), 36 deletions(-) diff --git a/lib/Bridge.php b/lib/Bridge.php index 8f0c356..d6b1587 100644 --- a/lib/Bridge.php +++ b/lib/Bridge.php @@ -114,12 +114,12 @@ abstract class BridgeAbstract implements BridgeInterface { protected $cache; protected $items = array(); - public $name = 'Unnamed bridge'; - public $uri = ''; - public $description = 'No description provided'; - public $maintainer = 'No maintainer'; + const NAME = 'Unnamed bridge'; + const URI = ''; + const DESCRIPTION = 'No description provided'; + const MAINTAINER = 'No maintainer'; + const PARAMETERS = array(); public $useProxy = true; - public $parameters = array(); public $inputs = array(); protected $queriedContext=''; @@ -199,28 +199,28 @@ abstract class BridgeAbstract implements BridgeInterface { if(!is_array($data)) return false; - 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'])){ // Default to 'text' - $set[$name]['type'] = 'text'; + $validated=true; + foreach($data as $name=>$value){ + $registered=false; + foreach(static::PARAMETERS as $context=>$set){ + if(array_key_exists($name,$set)){ + $registered=true; + if(!isset($set[$name]['type'])){ + $set[$name]['type']='text'; } switch($set[$name]['type']){ - case 'number': + case 'number': $data[$name] = $this->isValidNumberValue($value); break; - case 'checkbox': + case 'checkbox': $data[$name] = $this->isValidCheckboxValue($value); break; - case 'list': + case 'list': $data[$name] = $this->isValidListValue($value, $set[$name]['values']); break; default: - case 'text': + case 'text': if(isset($set[$name]['pattern'])){ $data[$name] = $this->isValidTextValue($value, $set[$name]['pattern']); } else { @@ -245,7 +245,7 @@ abstract class BridgeAbstract implements BridgeInterface { protected function getQueriedContext(){ $queriedContexts=array(); - foreach($this->parameters as $context=>$set){ + foreach(static::PARAMETERS as $context=>$set){ $queriedContexts[$context]=null; foreach($set as $id=>$properties){ if(isset($properties['value']) && @@ -259,7 +259,7 @@ abstract class BridgeAbstract implements BridgeInterface { } } - if(isset($this->parameters['global']) && + if(array_key_exists('global',static::PARAMETERS) && $queriedContexts['global']===false){ return null; } @@ -293,7 +293,7 @@ abstract class BridgeAbstract implements BridgeInterface { } } - if(empty($this->parameters)){ + if(empty(static::PARAMETERS)){ if(!empty($inputs)){ $this->returnClientError('Invalid parameters value(s)'); } @@ -311,8 +311,8 @@ abstract class BridgeAbstract implements BridgeInterface { // Populate BridgeAbstract::parameters with sanitized data foreach($inputs as $name=>$value){ - foreach($this->parameters as $context=>$set){ - if(isset($this->parameters[$context][$name])){ + foreach(static::PARAMETERS as $context=>$set){ + if(array_key_exists($name,static::PARAMETERS[$context])){ $this->inputs[$context][$name]['value']=$value; $this->parameters[$context][$name]['value']=$value; } @@ -331,13 +331,15 @@ abstract class BridgeAbstract implements BridgeInterface { // Apply default values to missing data $contexts=array($this->queriedContext); - if(isset($this->parameters['global'])){ + if(array_key_exists('global',static::PARAMETERS)){ $contexts[]='global'; } foreach($contexts as $context){ - foreach($this->parameters[$context] as $name=>$properties){ + foreach(static::PARAMETERS[$context] as $name=>$properties){ if(!isset($properties['type'])){ - $this->parameters[$context][$name]['type']='text'; + $type='text'; + }else{ + $type=$properties['type']; } if(isset($properties['value'])){ continue; @@ -371,8 +373,8 @@ abstract class BridgeAbstract implements BridgeInterface { } // Copy global parameter values to the guessed context - if(isset($this->parameters['global'])){ - foreach($this->parameters['global'] as $name=>$properties){ + if(array_key_exists('global',static::PARAMETERS)){ + foreach(static::PARAMETERS['global'] as $name=>$properties){ if(isset($inputs[$name])){ $value=$inputs[$name]; }else if(isset($properties['value'])){ @@ -405,11 +407,11 @@ abstract class BridgeAbstract implements BridgeInterface { } public function getName(){ - return $this->name; + return static::NAME; } public function getURI(){ - return $this->uri; + return static::URI; } public function getCacheDuration(){ @@ -585,6 +587,10 @@ abstract class HttpCachingBridgeAbstract extends BridgeAbstract { abstract class RssExpander extends HttpCachingBridgeAbstract { + private $name; + private $uri; + private $description; + public function collectExpandableDatas($name){ if(empty($name)){ $this->returnServerError('There is no $name for this RSS expander'); @@ -632,6 +638,14 @@ abstract class RssExpander extends HttpCachingBridgeAbstract { */ abstract protected function parseRSSItem($item); + public function getURI(){ + return $this->uri; + } + + public function getName(){ + return $this->name; + } + public function getDescription(){ return $this->description; } diff --git a/lib/HTMLUtils.php b/lib/HTMLUtils.php index cbfa0af..7e0061d 100644 --- a/lib/HTMLUtils.php +++ b/lib/HTMLUtils.php @@ -3,12 +3,13 @@ class HTMLUtils { public static function displayBridgeCard($bridgeName, $formats, $isActive = true){ $bridgeElement = Bridge::create($bridgeName); + $bridgeClass=$bridgeName.'Bridge'; if($bridgeElement == false) return ""; - $name = '' . $bridgeElement->name . ''; - $description = $bridgeElement->description; + $name = '' . $bridgeClass::NAME . ''; + $description = $bridgeClass::DESCRIPTION; $card = << @@ -21,7 +22,7 @@ class HTMLUtils { CARD; // If we don't have any parameter for the bridge, we print a generic form to load it. - if(count($bridgeElement->parameters) == 0) { + if(count($bridgeClass::PARAMETERS) == 0) { $card .= HTMLUtils::getFormHeader($bridgeName); @@ -40,13 +41,13 @@ CARD; $card .= '' . PHP_EOL; } - $hasGlobalParameter = array_key_exists('global', $bridgeElement->parameters); + $hasGlobalParameter = array_key_exists('global', $bridgeClass::PARAMETERS); if($hasGlobalParameter){ - $globalParameters = $bridgeElement->parameters['global']; + $globalParameters = $bridgeClass::PARAMETERS['global']; } - foreach($bridgeElement->parameters as $parameterName => $parameter){ + foreach($bridgeClass::PARAMETERS as $parameterName => $parameter){ if(!is_numeric($parameterName) && $parameterName == 'global') continue; @@ -129,7 +130,7 @@ CARD; } $card .= ''; - $card .= '

' . $bridgeElement->maintainer . '

'; + $card .= '

' . $bridgeClass::MAINTAINER . '

'; $card .= ''; return $card; From 9a0da733ef07e2ef2eea9a9776eccdf9719f857a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Mazi=C3=A8re?= Date: Tue, 30 Aug 2016 11:23:55 +0200 Subject: [PATCH 2/2] [bridges] use constants instead of variable members MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Pierre Mazière --- bridges/ABCTabsBridge.php | 8 +++---- bridges/AcrimedBridge.php | 8 +++---- bridges/AllocineFRBridge.php | 16 ++++++------- bridges/AnimeUltimeBridge.php | 20 ++++++++--------- bridges/ArstechnicaBridge.php | 8 +++---- bridges/Arte7Bridge.php | 12 +++++----- bridges/AskfmBridge.php | 18 +++++++-------- bridges/BandcampBridge.php | 12 +++++----- bridges/BastaBridge.php | 12 +++++----- bridges/BlaguesDeMerdeBridge.php | 10 ++++----- bridges/BooruprojectBridge.php | 10 ++++----- bridges/CADBridge.php | 8 +++---- bridges/CNETBridge.php | 14 ++++++------ bridges/CastorusBridge.php | 16 ++++++------- bridges/CollegeDeFranceBridge.php | 12 +++++----- bridges/CommonDreamsBridge.php | 8 +++---- bridges/CopieDoubleBridge.php | 16 ++++++------- bridges/CourrierInternationalBridge.php | 12 +++++----- bridges/CpasbienBridge.php | 16 ++++++------- bridges/CryptomeBridge.php | 16 ++++++------- bridges/DailymotionBridge.php | 14 ++++++------ bridges/DanbooruBridge.php | 16 ++++++------- bridges/DansTonChatBridge.php | 10 ++++----- bridges/DauphineLibereBridge.php | 14 ++++++------ bridges/DemoBridge.php | 10 ++++----- bridges/DeveloppezDotComBridge.php | 12 +++++----- bridges/DilbertBridge.php | 8 +++---- bridges/DollbooruBridge.php | 16 ++++++------- bridges/DuckDuckGoBridge.php | 12 +++++----- bridges/EZTVBridge.php | 14 ++++++------ bridges/EliteDangerousGalnetBridge.php | 12 +++++----- bridges/ElsevierBridge.php | 12 +++++----- bridges/EstCeQuonMetEnProdBridge.php | 8 +++---- bridges/FacebookBridge.php | 20 ++++++++--------- bridges/FierPandaBridge.php | 10 ++++----- bridges/FlickrExploreBridge.php | 12 +++++----- bridges/FlickrTagBridge.php | 16 ++++++------- bridges/FootitoBridge.php | 10 ++++----- bridges/FourchanBridge.php | 10 ++++----- bridges/FreenewsBridge.php | 8 +++---- bridges/FuturaSciencesBridge.php | 10 ++++----- bridges/GBAtempBridge.php | 30 ++++++++++++------------- bridges/GelbooruBridge.php | 14 ++++++------ bridges/GiphyBridge.php | 14 ++++++------ bridges/GithubIssueBridge.php | 14 ++++++------ bridges/GitlabCommitsBridge.php | 10 ++++----- bridges/GizmodoFRBridge.php | 12 +++++----- bridges/GooglePlusPostBridge.php | 26 ++++++++++----------- bridges/GoogleSearchBridge.php | 12 +++++----- bridges/GuruMedBridge.php | 10 ++++----- bridges/HDWallpapersBridge.php | 16 ++++++------- bridges/HentaiHavenBridge.php | 10 ++++----- bridges/IdenticaBridge.php | 12 +++++----- bridges/InstagramBridge.php | 14 ++++++------ bridges/IsoHuntBridge.php | 26 ++++++++++----------- bridges/JapanExpoBridge.php | 14 ++++++------ bridges/KonachanBridge.php | 14 ++++++------ bridges/KoreusBridge.php | 8 +++---- bridges/KununuBridge.php | 18 +++++++-------- bridges/LWNprevBridge.php | 14 ++++++------ bridges/LeBonCoinBridge.php | 12 +++++----- bridges/LeJournalDuGeekBridge.php | 12 +++++----- bridges/LeMondeInformatiqueBridge.php | 12 +++++----- bridges/Les400CulsBridge.php | 10 ++++----- bridges/LesJoiesDuCodeBridge.php | 10 ++++----- bridges/LichessBridge.php | 10 ++++----- bridges/LinkedInCompanyBridge.php | 12 +++++----- bridges/LolibooruBridge.php | 14 ++++++------ bridges/MangareaderBridge.php | 20 ++++++++--------- bridges/MilbooruBridge.php | 16 ++++++------- bridges/MondeDiploBridge.php | 14 ++++++------ bridges/MsnMondeBridge.php | 12 +++++----- bridges/MspabooruBridge.php | 14 ++++++------ bridges/NakedSecurityBridge.php | 8 +++---- bridges/NasaApodBridge.php | 12 +++++----- bridges/NeuviemeArtBridge.php | 14 ++++++------ bridges/NextInpactBridge.php | 10 ++++----- bridges/NextgovBridge.php | 10 ++++----- bridges/NiceMatinBridge.php | 10 ++++----- bridges/NovelUpdatesBridge.php | 12 +++++----- bridges/NumeramaBridge.php | 10 ++++----- bridges/OpenClassroomsBridge.php | 14 ++++++------ bridges/ParuVenduImmoBridge.php | 14 ++++++------ bridges/PickyWallpapersBridge.php | 14 ++++++------ bridges/PinterestBridge.php | 16 ++++++------- bridges/PlanetLibreBridge.php | 10 ++++----- bridges/ProjectMGameBridge.php | 12 +++++----- bridges/RTBFBridge.php | 14 ++++++------ bridges/Releases3DSBridge.php | 10 ++++----- bridges/ReporterreBridge.php | 12 +++++----- bridges/Rue89Bridge.php | 8 +++---- bridges/Rule34Bridge.php | 14 ++++++------ bridges/Rule34pahealBridge.php | 14 ++++++------ bridges/SafebooruBridge.php | 14 ++++++------ bridges/SakugabooruBridge.php | 14 ++++++------ bridges/ScmbBridge.php | 12 +++++----- bridges/ScoopItBridge.php | 12 +++++----- bridges/SensCritiqueBridge.php | 14 ++++++------ bridges/Sexactu.php | 14 ++++++------ bridges/ShanaprojectBridge.php | 8 +++---- bridges/SiliconBridge.php | 10 ++++----- bridges/SoundcloudBridge.php | 16 ++++++------- bridges/StripeAPIChangeLogBridge.php | 12 +++++----- bridges/SuperbWallpapersBridge.php | 16 ++++++------- bridges/T411Bridge.php | 14 ++++++------ bridges/TagBoardBridge.php | 10 ++++----- bridges/TbibBridge.php | 14 ++++++------ bridges/TheCodingLoveBridge.php | 10 ++++----- bridges/TheHackerNewsBridge.php | 8 +++---- bridges/TheOatMealBridge.php | 8 +++---- bridges/ThePirateBayBridge.php | 14 ++++++------ bridges/TwitchApiBridge.php | 10 ++++----- bridges/TwitterBridge.php | 16 ++++++------- bridges/UnsplashBridge.php | 12 +++++----- bridges/ViadeoCompanyBridge.php | 12 +++++----- bridges/VineBridge.php | 12 +++++----- bridges/VkBridge.php | 14 ++++++------ bridges/WallpaperStopBridge.php | 18 +++++++-------- bridges/WeLiveSecurityBridge.php | 8 +++---- bridges/WhydBridge.php | 20 ++++++++--------- bridges/WikipediaBridge.php | 10 ++++----- bridges/WordPressBridge.php | 10 ++++----- bridges/WorldOfTanksBridge.php | 18 +++++++-------- bridges/XbooruBridge.php | 14 ++++++------ bridges/YandereBridge.php | 14 ++++++------ bridges/YoutubeBridge.php | 28 +++++++++++------------ bridges/ZDNetBridge.php | 12 +++++----- bridges/ZatazBridge.php | 10 ++++----- bridges/ZoneTelechargementBridge.php | 10 ++++----- 129 files changed, 834 insertions(+), 834 deletions(-) diff --git a/bridges/ABCTabsBridge.php b/bridges/ABCTabsBridge.php index 51a767a..741d92c 100644 --- a/bridges/ABCTabsBridge.php +++ b/bridges/ABCTabsBridge.php @@ -1,10 +1,10 @@ array( 'name'=>'category', 'type'=>'list', @@ -38,10 +38,10 @@ class AllocineFRBridge extends BridgeAbstract{ } public function getName(){ - return $this->name.' : ' + return self::NAME.' : ' .array_search( $this->getInput('category'), - $this->parameters[$this->queriedContext]['category']['values'] + self::PARAMETERS[$this->queriedContext]['category']['values'] ); } @@ -52,7 +52,7 @@ class AllocineFRBridge extends BridgeAbstract{ $category=array_search( $this->getInput('category'), - $this->parameters[$this->queriedContext]['category']['values'] + self::PARAMETERS[$this->queriedContext]['category']['values'] ); diff --git a/bridges/AnimeUltimeBridge.php b/bridges/AnimeUltimeBridge.php index 629f459..301475f 100644 --- a/bridges/AnimeUltimeBridge.php +++ b/bridges/AnimeUltimeBridge.php @@ -1,11 +1,11 @@ array( 'name'=>'Type', 'type'=>'list', @@ -25,7 +25,7 @@ class AnimeUltimeBridge extends BridgeAbstract { //Add type filter if provided $typeFilter = array_search( $this->getInput('type'), - $this->parameters[$this->queriedContext]['type']['values'] + self::PARAMETERS[$this->queriedContext]['type']['values'] ); //Build date and filters for making requests @@ -37,7 +37,7 @@ class AnimeUltimeBridge extends BridgeAbstract { foreach (array($thismonth, $lastmonth) as $requestFilter) { //Retrive page contents - $url = $this->uri.'history-0-1/'.$requestFilter; + $url = self::URI.'history-0-1/'.$requestFilter; $html = $this->getSimpleHTMLDOM($url) or $this->returnServerError('Could not request Anime-Ultime: '.$url); @@ -58,7 +58,7 @@ class AnimeUltimeBridge extends BridgeAbstract { //Retrieve metadata from table columns $item_link_element = $release->find('td', 0)->find('a', 0); - $item_uri = $this->uri.$item_link_element->href; + $item_uri = self::URI.$item_link_element->href; $item_name = html_entity_decode($item_link_element->plaintext); $item_episode = html_entity_decode(str_pad($release->find('td', 1)->plaintext, 2, '0', STR_PAD_LEFT)); $item_fansub = $release->find('td', 2)->plaintext; @@ -79,7 +79,7 @@ class AnimeUltimeBridge extends BridgeAbstract { strpos($item_description, '
') ); $item_description = str_replace( - 'src="images', 'src="'.$this->uri.'images', + 'src="images', 'src="'.self::URI.'images', $item_description ); $item_description = str_replace("\r", '', $item_description); @@ -109,7 +109,7 @@ class AnimeUltimeBridge extends BridgeAbstract { public function getName() { $typeFilter = array_search( $this->getInput('type'), - $this->parameters[$this->queriedContext]['type']['values'] + self::PARAMETERS[$this->queriedContext]['type']['values'] ); return 'Latest '.$typeFilter.' - Anime-Ultime Bridge'; diff --git a/bridges/ArstechnicaBridge.php b/bridges/ArstechnicaBridge.php index d2a62b2..2620715 100644 --- a/bridges/ArstechnicaBridge.php +++ b/bridges/ArstechnicaBridge.php @@ -3,10 +3,10 @@ #error_reporting(E_ALL); class ArstechnicaBridge extends BridgeAbstract { - public $maintainer = "prysme"; - public $name = "ArstechnicaBridge"; - public $uri = "http://arstechnica.com"; - public $description = "The PC enthusiast's resource. Power users and the tools they love, without computing religion"; + const MAINTAINER = "prysme"; + const NAME = "ArstechnicaBridge"; + const URI = "http://arstechnica.com"; + const DESCRIPTION = "The PC enthusiast's resource. Power users and the tools they love, without computing religion"; function StripWithDelimiters($string, $start, $end) { while (strpos($string, $start) !== false) { diff --git a/bridges/Arte7Bridge.php b/bridges/Arte7Bridge.php index 19e039f..7080648 100644 --- a/bridges/Arte7Bridge.php +++ b/bridges/Arte7Bridge.php @@ -1,11 +1,11 @@ array( 'catfr'=>array( 'type'=>'list', @@ -56,7 +56,7 @@ break; } - $url = $this->uri.'guide/'.$lang.'/plus7/'.$category; + $url = self::URI.'guide/'.$lang.'/plus7/'.$category; $input = $this->getContents($url) or die('Could not request ARTE.'); if(strpos($input, 'categoryVideoSet') !== FALSE){ $input = explode('categoryVideoSet: ', $input); diff --git a/bridges/AskfmBridge.php b/bridges/AskfmBridge.php index 7a8b9e2..a4c22df 100644 --- a/bridges/AskfmBridge.php +++ b/bridges/AskfmBridge.php @@ -1,11 +1,11 @@ array( 'u'=>array( 'name'=>'Username', @@ -20,7 +20,7 @@ class AskfmBridge extends BridgeAbstract{ foreach($html->find('div.streamItem-answer') as $element) { $item = array(); - $item['uri'] = $this->uri.$element->find('a.streamItemsAge',0)->href; + $item['uri'] = self::URI.$element->find('a.streamItemsAge',0)->href; $question = trim($element->find('h1.streamItemContent-question',0)->innertext); $item['title'] = trim(htmlspecialchars_decode($element->find('h1.streamItemContent-question',0)->plaintext, ENT_QUOTES)); $answer = trim($element->find('p.streamItemContent-answer',0)->innertext); @@ -35,18 +35,18 @@ class AskfmBridge extends BridgeAbstract{ } $content = '

' . $question . '

' . $answer . '

' . $visual . '

'; // Fix relative links without breaking // scheme used by YouTube stuff - $content = preg_replace('#href="\/(?!\/)#', 'href="'.$this->uri,$content); + $content = preg_replace('#href="\/(?!\/)#', 'href="'.self::URI,$content); $item['content'] = $content; $this->items[] = $item; } } public function getName(){ - return $this->name.' : '.$this->getInput('u'); + return self::NAME.' : '.$this->getInput('u'); } public function getURI(){ - return $this->uri.urlencode($this->getInput('u')).'/answers/more?page=0'; + return self::URI.urlencode($this->getInput('u')).'/answers/more?page=0'; } public function getCacheDuration(){ diff --git a/bridges/BandcampBridge.php b/bridges/BandcampBridge.php index 4e11091..77b88e6 100644 --- a/bridges/BandcampBridge.php +++ b/bridges/BandcampBridge.php @@ -1,11 +1,11 @@ array( 'name'=>'tag', 'type'=>'text', @@ -33,7 +33,7 @@ class BandcampBridge extends BridgeAbstract{ } public function getURI(){ - return $this->uri.'tag/'.urlencode($this->getInput('tag')).'?sort_field=date'; + return self::URI.'tag/'.urlencode($this->getInput('tag')).'?sort_field=date'; } public function getName(){ diff --git a/bridges/BastaBridge.php b/bridges/BastaBridge.php index a7a7c82..be36662 100644 --- a/bridges/BastaBridge.php +++ b/bridges/BastaBridge.php @@ -1,17 +1,17 @@ uri.'$1\'', $content); + return preg_replace('/src=["\']{1}([^"\']+)/ims', 'src=\''.self::URI.'$1\'', $content); } - $html = $this->getSimpleHTMLDOM($this->uri.'spip.php?page=backend') + $html = $this->getSimpleHTMLDOM(self::URI.'spip.php?page=backend') or $this->returnServerError('Could not request Bastamag.'); $limit = 0; diff --git a/bridges/BlaguesDeMerdeBridge.php b/bridges/BlaguesDeMerdeBridge.php index e0f65e1..0392bed 100644 --- a/bridges/BlaguesDeMerdeBridge.php +++ b/bridges/BlaguesDeMerdeBridge.php @@ -1,14 +1,14 @@ getSimpleHTMLDOM($this->uri) + $html = $this->getSimpleHTMLDOM(self::URI) 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 eb3f5ac..635aae5 100644 --- a/bridges/BooruprojectBridge.php +++ b/bridges/BooruprojectBridge.php @@ -1,12 +1,12 @@ array( 'name'=>'instance (required)', 'required'=>true diff --git a/bridges/CADBridge.php b/bridges/CADBridge.php index 8073f86..47ff165 100644 --- a/bridges/CADBridge.php +++ b/bridges/CADBridge.php @@ -1,9 +1,9 @@ getSimpleHTMLDOM($url); diff --git a/bridges/CNETBridge.php b/bridges/CNETBridge.php index e951976..6d5b8b5 100644 --- a/bridges/CNETBridge.php +++ b/bridges/CNETBridge.php @@ -1,12 +1,12 @@ You may specify a topic found in some section URLs, else all topics are selected.'; + const MAINTAINER = 'ORelio'; + const NAME = 'CNET News'; + const URI = 'http://www.cnet.com/'; + const DESCRIPTION = 'Returns the newest articles.
You may specify a topic found in some section URLs, else all topics are selected.'; - public $parameters = array( array( + const PARAMETERS = array( array( 'topic'=>array('name'=>'Topic name') )); @@ -37,7 +37,7 @@ class CNETBridge extends BridgeAbstract { return $article_html; } - $pageUrl = $this->uri.(empty($this->getInput('topic')) ? '' : 'topics/'.$this->getInput('topic').'/'); + $pageUrl = self::URI.(empty($this->getInput('topic')) ? '' : 'topics/'.$this->getInput('topic').'/'); $html = $this->getSimpleHTMLDOM($pageUrl) or $this->returnServerError('Could not request CNET: '.$pageUrl); $limit = 0; @@ -45,7 +45,7 @@ class CNETBridge extends BridgeAbstract { if ($limit < 8) { $article_title = trim($element->find('h2', 0)->plaintext); - $article_uri = $this->uri.($element->find('a', 0)->href); + $article_uri = self::URI.($element->find('a', 0)->href); $article_timestamp = strtotime($element->find('time.assetTime', 0)->plaintext); $article_author = trim($element->find('a[rel=author]', 0)->plaintext); diff --git a/bridges/CastorusBridge.php b/bridges/CastorusBridge.php index 35736b8..2355542 100644 --- a/bridges/CastorusBridge.php +++ b/bridges/CastorusBridge.php @@ -1,11 +1,11 @@ array(), 'Get latest changes via ZIP code' => array( 'zip'=>array( @@ -44,7 +44,7 @@ class CastorusBridge extends BridgeAbstract { if(!$url) $this->returnServerError('Cannot find url!'); - return $this->uri . $url->href; + return self::URI . $url->href; } // Extracts the time from an activity @@ -77,10 +77,10 @@ class CastorusBridge extends BridgeAbstract { $zip_filter = trim($this->getInput('zip')); $city_filter = trim($this->getInput('city')); - $html = $this->getSimpleHTMLDOM($this->uri); + $html = $this->getSimpleHTMLDOM(self::URI); if(!$html) - $this->returnServerError('Could not load data from ' . $this->uri . '!'); + $this->returnServerError('Could not load data from ' . self::URI . '!'); $activities = $html->find('div#activite/li'); diff --git a/bridges/CollegeDeFranceBridge.php b/bridges/CollegeDeFranceBridge.php index 3d9a21c..a6ae296 100644 --- a/bridges/CollegeDeFranceBridge.php +++ b/bridges/CollegeDeFranceBridge.php @@ -1,10 +1,10 @@ * */ - $html = $this->getSimpleHTMLDOM($this->uri.'components/search-audiovideo.jsp?fulltext=&siteid=1156951719600&lang=FR&type=all') + $html = $this->getSimpleHTMLDOM(self::URI.'components/search-audiovideo.jsp?fulltext=&siteid=1156951719600&lang=FR&type=all') or $this->returnServerError('Could not request CollegeDeFrance.'); foreach($html->find('a[data-target]') as $element) { $item = array(); @@ -62,7 +62,7 @@ class CollegeDeFranceBridge extends BridgeAbstract{ } $item['timestamp'] = $d->format('U'); $item['content'] = $element->find('.lecturer', 0)->innertext . ' - ' . $element->find('.title', 0)->innertext; - $item['uri'] = $this->uri . $element->href; + $item['uri'] = self::URI . $element->href; $this->items[] = $item; } } diff --git a/bridges/CommonDreamsBridge.php b/bridges/CommonDreamsBridge.php index 23627e3..446a6df 100644 --- a/bridges/CommonDreamsBridge.php +++ b/bridges/CommonDreamsBridge.php @@ -1,10 +1,10 @@ getSimpleHTMLDOM($url); diff --git a/bridges/CopieDoubleBridge.php b/bridges/CopieDoubleBridge.php index 6e787db..aa04962 100644 --- a/bridges/CopieDoubleBridge.php +++ b/bridges/CopieDoubleBridge.php @@ -1,13 +1,13 @@ getSimpleHTMLDOM($this->uri) + $html = $this->getSimpleHTMLDOM(self::URI) or $this->returnServerError('Could not request CopieDouble.'); $table = $html->find('table table', 2); @@ -26,10 +26,10 @@ class CopieDoubleBridge extends BridgeAbstract{ elseif(strpos($element->innertext, "/images/suivant.gif") === false) { $a=$element->find("a", 0); - $item['uri'] = $this->uri . $a->href; + $item['uri'] = self::URI . $a->href; - $content = str_replace('src="/', 'src="/'.$this->uri,$element->find("td", 0)->innertext); - $content = str_replace('href="/', 'href="'.$this->uri,$content); + $content = str_replace('src="/', 'src="/'.self::URI,$element->find("td", 0)->innertext); + $content = str_replace('href="/', 'href="'.self::URI,$content); $item['content'] = $content; $this->items[] = $item; } diff --git a/bridges/CourrierInternationalBridge.php b/bridges/CourrierInternationalBridge.php index 09d1aa6..f91916f 100644 --- a/bridges/CourrierInternationalBridge.php +++ b/bridges/CourrierInternationalBridge.php @@ -1,14 +1,14 @@ getSimpleHTMLDOM($this->uri) + $html = $this->getSimpleHTMLDOM(self::URI) or $this->returnServerError('Error.'); $element = $html->find("article"); @@ -22,7 +22,7 @@ class CourrierInternationalBridge extends BridgeAbstract{ $item['uri'] = $article->parent->getAttribute("href"); if(strpos($item['uri'], "http") === FALSE) { - $item['uri'] = $this->uri.$item['uri']; + $item['uri'] = self::URI.$item['uri']; } $page = $this->getSimpleHTMLDOM($item['uri']); diff --git a/bridges/CpasbienBridge.php b/bridges/CpasbienBridge.php index c9b7021..454d239 100644 --- a/bridges/CpasbienBridge.php +++ b/bridges/CpasbienBridge.php @@ -1,12 +1,12 @@ array( 'name'=>'Search', 'required'=>true, @@ -16,7 +16,7 @@ class CpasbienBridge extends HttpCachingBridgeAbstract{ public function collectData(){ $request = str_replace(" ","-",trim($this->getInput('q'))); - $html = $this->getSimpleHTMLDOM($this->uri.'/recherche/'.urlencode($request).'.html') + $html = $this->getSimpleHTMLDOM(self::URI.'/recherche/'.urlencode($request).'.html') or $this->returnServerError('No results for this query.'); foreach ($html->find('#gauche',0)->find('div') as $episode) { @@ -40,7 +40,7 @@ class CpasbienBridge extends HttpCachingBridgeAbstract{ } $item['id'] = $episode->find('a', 0)->getAttribute('href'); - $item['uri'] = $this->uri . $htmlepisode->find('#telecharger',0)->getAttribute('href'); + $item['uri'] = self::URI . $htmlepisode->find('#telecharger',0)->getAttribute('href'); $this->items[] = $item; } } @@ -48,7 +48,7 @@ class CpasbienBridge extends HttpCachingBridgeAbstract{ public function getName(){ - return $this->getInput('q').' : '.$this->name; + return $this->getInput('q').' : '.self::NAME; } public function getCacheDuration(){ diff --git a/bridges/CryptomeBridge.php b/bridges/CryptomeBridge.php index 072fbd5..840c2ae 100644 --- a/bridges/CryptomeBridge.php +++ b/bridges/CryptomeBridge.php @@ -1,12 +1,12 @@ array( 'name'=>'number of elements', 'type'=>'number', @@ -16,7 +16,7 @@ class CryptomeBridge extends BridgeAbstract{ )); public function collectData(){ - $html = $this->getSimpleHTMLDOM($this->uri) + $html = $this->getSimpleHTMLDOM(self::URI) or $this->returnServerError('Could not request Cryptome.'); if (!empty($this->getInput('n'))) { /* number of documents */ $num = min($this->getInput('n'), 20); @@ -26,9 +26,9 @@ class CryptomeBridge extends BridgeAbstract{ foreach($html->find('pre') as $element) { for ( $i = 0; $i < $num; ++$i ) { $item = array(); - $item['uri'] = $this->uri.substr($element->find('a', $i)->href, 20); + $item['uri'] = self::URI.substr($element->find('a', $i)->href, 20); $item['title'] = substr($element->find('b', $i)->plaintext, 22); - $item['content'] = preg_replace('#http://cryptome.org/#', $this->uri, $element->find('b', $i)->innertext); + $item['content'] = preg_replace('#http://cryptome.org/#', self::URI, $element->find('b', $i)->innertext); $this->items[] = $item; } break; diff --git a/bridges/DailymotionBridge.php b/bridges/DailymotionBridge.php index 7849ba6..8e639fe 100644 --- a/bridges/DailymotionBridge.php +++ b/bridges/DailymotionBridge.php @@ -1,12 +1,12 @@ array( 'u'=>array( 'name'=>'username', @@ -35,7 +35,7 @@ class DailymotionBridge extends BridgeAbstract{ function getMetadata($id) { $metadata=array(); - $html2 = $this->getSimpleHTMLDOM($this->uri.'video/'.$id); + $html2 = $this->getSimpleHTMLDOM(self::URI.'video/'.$id); if(!$html2){ return $metadata; } @@ -90,7 +90,7 @@ class DailymotionBridge extends BridgeAbstract{ } public function getURI(){ - $uri=$this->uri; + $uri=self::URI; switch($this->queriedContext){ case 'By username': $uri.='user/' diff --git a/bridges/DanbooruBridge.php b/bridges/DanbooruBridge.php index 9f6f63a..3ee8cb6 100644 --- a/bridges/DanbooruBridge.php +++ b/bridges/DanbooruBridge.php @@ -1,12 +1,12 @@ array( 'name'=>'page', 'type'=>'number' @@ -18,14 +18,14 @@ class DanbooruBridge extends BridgeAbstract{ $page = $this->getInput('p')?$this->getInput('p'):1; $tags = urlencode($this->getInput('t')); - $html = $this->getSimpleHTMLDOM($this->uri."posts?&page=$page&tags=$tags") + $html = $this->getSimpleHTMLDOM(self::URI."posts?&page=$page&tags=$tags") or $this->returnServerError('Could not request Danbooru.'); foreach($html->find('div[id=posts] article') as $element) { $item = array(); - $item['uri'] = $this->uri.$element->find('a', 0)->href; + $item['uri'] = self::URI.$element->find('a', 0)->href; $item['postid'] = (int)preg_replace("/[^0-9]/",'', $element->getAttribute('data-id')); $item['timestamp'] = time(); - $thumbnailUri = $this->uri.$element->find('img', 0)->src; + $thumbnailUri = self::URI.$element->find('img', 0)->src; $item['tags'] = $element->find('img', 0)->getAttribute('alt'); $item['title'] = 'Danbooru | '.$item['postid']; $item['content'] = '
Tags: '.$item['tags']; diff --git a/bridges/DansTonChatBridge.php b/bridges/DansTonChatBridge.php index f94f1ce..30849b4 100644 --- a/bridges/DansTonChatBridge.php +++ b/bridges/DansTonChatBridge.php @@ -1,14 +1,14 @@ getSimpleHTMLDOM($this->uri.'latest.html') + $html = $this->getSimpleHTMLDOM(self::URI.'latest.html') or $this->returnServerError('Could not request DansTonChat.'); foreach($html->find('div.item') as $element) { diff --git a/bridges/DauphineLibereBridge.php b/bridges/DauphineLibereBridge.php index 1084969..143a6c0 100644 --- a/bridges/DauphineLibereBridge.php +++ b/bridges/DauphineLibereBridge.php @@ -1,12 +1,12 @@ array( 'name'=>'Catégorie de l\'article', 'type'=>'list', @@ -42,10 +42,10 @@ class DauphineLibereBridge extends BridgeAbstract { $context = stream_context_create($opts); if (empty($this->getInput('u'))) { - $html = $this->getSimpleHTMLDOM($this->uri.$this->getInput('u').'/rss') + $html = $this->getSimpleHTMLDOM(self::URI.$this->getInput('u').'/rss') or $this->returnServerError('Could not request DauphineLibere.'); } else { - $html = $this->getSimpleHTMLDOM($this->uri.'rss') + $html = $this->getSimpleHTMLDOM(self::URI.'rss') or $this->returnServerError('Could not request DauphineLibere.'); } $limit = 0; diff --git a/bridges/DemoBridge.php b/bridges/DemoBridge.php index 2fff948..a01d15f 100644 --- a/bridges/DemoBridge.php +++ b/bridges/DemoBridge.php @@ -1,12 +1,12 @@ array( 'testCheckbox'=>array( 'type'=>'checkbox', diff --git a/bridges/DeveloppezDotComBridge.php b/bridges/DeveloppezDotComBridge.php index a7958e6..48e2974 100644 --- a/bridges/DeveloppezDotComBridge.php +++ b/bridges/DeveloppezDotComBridge.php @@ -1,10 +1,10 @@ getSimpleHTMLDOM($this->uri.'index/rss') - or $this->returnServerError('Could not request '.$this->uri.'index/rss'); + $rssFeed = $this->getSimpleHTMLDOM(self::URI.'index/rss') + or $this->returnServerError('Could not request '.self::URI.'index/rss'); $limit = 0; foreach($rssFeed->find('item') as $element) { diff --git a/bridges/DilbertBridge.php b/bridges/DilbertBridge.php index 05d94fc..ba5a042 100644 --- a/bridges/DilbertBridge.php +++ b/bridges/DilbertBridge.php @@ -1,10 +1,10 @@ array( 'name'=>'page', 'type'=>'number' @@ -18,16 +18,16 @@ class DollbooruBridge extends BridgeAbstract{ public function collectData(){ $page=$this->getInput('p'); $tags = urlencode($this->getInput('t')); - $html = $this->getSimpleHTMLDOM($this->uri."post/list/$tags/$page") + $html = $this->getSimpleHTMLDOM(self::URI."post/list/$tags/$page") or $this->returnServerError('Could not request Dollbooru.'); foreach($html->find('div[class=shm-image-list] a') as $element) { $item = array(); - $item['uri'] = $this->uri.$element->href; + $item['uri'] = self::URI.$element->href; $item['postid'] = (int)preg_replace("/[^0-9]/",'', $element->getAttribute('data-post-id')); $item['timestamp'] = time(); - $thumbnailUri = $this->uri.$element->find('img', 0)->src; + $thumbnailUri = self::URI.$element->find('img', 0)->src; $item['tags'] = $element->getAttribute('data-tags'); $item['title'] = 'Dollbooru | '.$item['postid']; $item['content'] = '
Tags: '.$item['tags']; diff --git a/bridges/DuckDuckGoBridge.php b/bridges/DuckDuckGoBridge.php index 29719a9..25ec859 100644 --- a/bridges/DuckDuckGoBridge.php +++ b/bridges/DuckDuckGoBridge.php @@ -1,19 +1,19 @@ array( 'name'=>'keyword', 'required'=>true) )); public function collectData(){ - $html = $this->getSimpleHTMLDOM($this->uri.'html/?q='.$this->getInput('u').'+sort:date') + $html = $this->getSimpleHTMLDOM(self::URI.'html/?q='.$this->getInput('u').'+sort:date') or $this->returnServerError('Could not request DuckDuckGo.'); foreach($html->find('div.results_links') as $element) { diff --git a/bridges/EZTVBridge.php b/bridges/EZTVBridge.php index a6ab15e..d2399e0 100644 --- a/bridges/EZTVBridge.php +++ b/bridges/EZTVBridge.php @@ -1,12 +1,12 @@ array( 'name'=>'Show ids', 'exampleValue'=>'showID1,showID2,…', @@ -34,7 +34,7 @@ class EZTVBridge extends BridgeAbstract{ foreach($showList as $showID){ // Get show page - $html = $this->getSimpleHTMLDOM($this->uri.'shows/'.rawurlencode($showID).'/') + $html = $this->getSimpleHTMLDOM(self::URI.'shows/'.rawurlencode($showID).'/') or $this->returnServerError('Could not request EZTV for id "'.$showID.'"'); // Loop on each element that look like an episode entry... @@ -53,7 +53,7 @@ class EZTVBridge extends BridgeAbstract{ // Fill item $item = array(); - $item['uri'] = $this->uri.$epinfo->href; + $item['uri'] = self::URI.$epinfo->href; $item['id'] = $item['uri']; $item['timestamp'] = makeTimestamp($released->plaintext); $item['title'] = $epinfo->plaintext; diff --git a/bridges/EliteDangerousGalnetBridge.php b/bridges/EliteDangerousGalnetBridge.php index a15718a..09d3770 100644 --- a/bridges/EliteDangerousGalnetBridge.php +++ b/bridges/EliteDangerousGalnetBridge.php @@ -1,20 +1,20 @@ getSimpleHTMLDOM($this->uri) + $html = $this->getSimpleHTMLDOM(self::URI) or $this->returnServerError('Error while downloading the website content'); foreach($html->find('div.article') as $element) { $item = array(); $uri = $element->find('h3 a', 0)->href; - $uri = $this->uri . substr($uri,strlen('/galnet/')); + $uri = self::URI . substr($uri,strlen('/galnet/')); $item['uri'] = $uri; $title = $element->find('h3 a', 0)->plaintext; diff --git a/bridges/ElsevierBridge.php b/bridges/ElsevierBridge.php index 0444f63..8905a9e 100644 --- a/bridges/ElsevierBridge.php +++ b/bridges/ElsevierBridge.php @@ -1,11 +1,11 @@ array( 'name'=>'Journal name', 'required'=>true, @@ -56,7 +56,7 @@ class ElsevierBridge extends BridgeAbstract{ } public function collectData(){ - $uri = $this->uri . $this->getInput('j') . '/recent-articles/'; + $uri = self::URI . $this->getInput('j') . '/recent-articles/'; $html = $this->getSimpleHTMLDOM($uri) or $this->returnServerError('No results for Elsevier journal '.$this->getInput('j')); foreach($html->find('.pod-listing') as $article){ diff --git a/bridges/EstCeQuonMetEnProdBridge.php b/bridges/EstCeQuonMetEnProdBridge.php index 531d68b..b4f94b8 100644 --- a/bridges/EstCeQuonMetEnProdBridge.php +++ b/bridges/EstCeQuonMetEnProdBridge.php @@ -1,10 +1,10 @@ array( 'name'=>'Username', 'required'=>true @@ -31,7 +31,7 @@ class FacebookBridge extends BridgeAbstract{ if (is_array($matches) && count($matches) > 1) { $link = $matches[1]; if (strpos($link, '/') === 0) - $link = $this->uri.$link.'"'; + $link = self::URI.$link.'"'; if (strpos($link, 'facebook.com/l.php?u=') !== false) $link = urldecode(ExtractFromDelimiters($link, 'facebook.com/l.php?u=', '&')); return ' href="'.$link.'"'; @@ -104,10 +104,10 @@ class FacebookBridge extends BridgeAbstract{ //Retrieve page contents if (is_null($html)) { if (!strpos($this->getInput('u'), "/")) { - $html = $this->getSimpleHTMLDOM($this->uri.urlencode($this->getInput('u')).'?_fb_noscript=1') + $html = $this->getSimpleHTMLDOM(self::URI.urlencode($this->getInput('u')).'?_fb_noscript=1') or $this->returnServerError('No results for this query.'); } else { - $html = $this->getSimpleHTMLDOM($this->uri.'pages/'.$this->getInput('u').'?_fb_noscript=1') + $html = $this->getSimpleHTMLDOM(self::URI.'pages/'.$this->getInput('u').'?_fb_noscript=1') or $this->returnServerError('No results for this query.'); } } @@ -123,7 +123,7 @@ class FacebookBridge extends BridgeAbstract{ foreach ($captcha->find('input, button') as $input) $captcha_fields[$input->name] = $input->value; $_SESSION['captcha_fields'] = $captcha_fields; - $_SESSION['captcha_action'] = $this->uri.$captcha->find('form', 0)->action; + $_SESSION['captcha_action'] = self::URI.$captcha->find('form', 0)->action; //Show captcha filling form to the viewer, proxying the captcha image $img = base64_encode($this->getContents($captcha->find('img', 0)->src)); @@ -192,7 +192,7 @@ class FacebookBridge extends BridgeAbstract{ $title = substr($title, 0, strpos(wordwrap($title, 64), "\n")).'...'; //Build and add final item - $item['uri'] = $this->uri.$post->find('abbr')[0]->parent()->getAttribute('href'); + $item['uri'] = self::URI.$post->find('abbr')[0]->parent()->getAttribute('href'); $item['content'] = $content; $item['title'] = $title; $item['author'] = $author; diff --git a/bridges/FierPandaBridge.php b/bridges/FierPandaBridge.php index 4cdfa8d..5c574fc 100644 --- a/bridges/FierPandaBridge.php +++ b/bridges/FierPandaBridge.php @@ -1,13 +1,13 @@ getSimpleHTMLDOM($this->uri) or $this->returnServerError('Could not request Fier Panda.'); + $html = $this->getSimpleHTMLDOM(self::URI) or $this->returnServerError('Could not request Fier Panda.'); foreach($html->find('div.container-content article') as $element) { $item = array(); diff --git a/bridges/FlickrExploreBridge.php b/bridges/FlickrExploreBridge.php index 58343f7..f35333f 100644 --- a/bridges/FlickrExploreBridge.php +++ b/bridges/FlickrExploreBridge.php @@ -1,13 +1,13 @@ getSimpleHTMLDOM($this->uri.'explore') + $html = $this->getSimpleHTMLDOM(self::URI.'explore') or $this->returnServerError('Could not request Flickr.'); foreach($html->find('.photo-list-photo-view') as $element) { @@ -32,7 +32,7 @@ class FlickrExploreBridge extends BridgeAbstract{ )) or $this->returnServerError('Could not request Flickr.'); // FIXME: Request time too long... $item = array(); - $item['uri'] = $this->uri.'photo.gne?id='.$imageID; + $item['uri'] = self::URI.'photo.gne?id='.$imageID; $item['content'] = ''; // FIXME: Filter javascript ? $item['title'] = $imageJSON->photo->title->_content; $this->items[] = $item; diff --git a/bridges/FlickrTagBridge.php b/bridges/FlickrTagBridge.php index 2494567..8b3f1b2 100644 --- a/bridges/FlickrTagBridge.php +++ b/bridges/FlickrTagBridge.php @@ -1,12 +1,12 @@ array( 'q'=>array( 'name'=>'keyword', @@ -25,18 +25,18 @@ class FlickrTagBridge extends BridgeAbstract{ public function collectData(){ switch($this->queriedContext){ case 'By keyword': - $html = $this->getSimpleHTMLDOM($this->uri.'search/?q='.urlencode($this->getInput('q')).'&s=rec') + $html = $this->getSimpleHTMLDOM(self::URI.'search/?q='.urlencode($this->getInput('q')).'&s=rec') or $this->returnServerError('No results for this query.'); break; case 'by username': - $html = $this->getSimpleHTMLDOM($this->uri.'photos/'.urlencode($this->getInput('u')).'/') + $html = $this->getSimpleHTMLDOM(self::URI.'photos/'.urlencode($this->getInput('u')).'/') or $this->returnServerError('Requested username can\'t be found.'); break; } foreach($html->find('span.photo_container') as $element) { $item = array(); - $item['uri'] = $this->uri.$element->find('a',0)->href; + $item['uri'] = self::URI.$element->find('a',0)->href; $thumbnailUri = $element->find('img',0)->getAttribute('data-defer-src'); $item['content'] = ''; // FIXME: Filter javascript ? $item['title'] = $element->find('a',0)->title; diff --git a/bridges/FootitoBridge.php b/bridges/FootitoBridge.php index b2c4089..b669ac5 100644 --- a/bridges/FootitoBridge.php +++ b/bridges/FootitoBridge.php @@ -1,13 +1,13 @@ getSimpleHTMLDOM($this->uri) + $html = $this->getSimpleHTMLDOM(self::URI) 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 eddfdde..315bbdb 100644 --- a/bridges/FourchanBridge.php +++ b/bridges/FourchanBridge.php @@ -1,12 +1,12 @@ array( 'name'=>'Thread URL', 'pattern'=>'(https:\/\/)?boards\.4chan\.org\/.*thread\/.*', diff --git a/bridges/FreenewsBridge.php b/bridges/FreenewsBridge.php index 6f98069..60fd34e 100644 --- a/bridges/FreenewsBridge.php +++ b/bridges/FreenewsBridge.php @@ -2,10 +2,10 @@ define("FREENEWS_RSS", 'http://feeds.feedburner.com/Freenews-Freebox?format=xml'); class FreenewsBridge extends RssExpander { - public $maintainer = "mitsukarenai"; - public $name = "Freenews"; - public $uri = "http://freenews.fr"; - public $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."; + const MAINTAINER = "mitsukarenai"; + const NAME = "Freenews"; + const URI = "http://freenews.fr"; + const 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."; public function collectData(){ parent::collectExpandableDatas(FREENEWS_RSS); diff --git a/bridges/FuturaSciencesBridge.php b/bridges/FuturaSciencesBridge.php index 3a91467..e4c8471 100644 --- a/bridges/FuturaSciencesBridge.php +++ b/bridges/FuturaSciencesBridge.php @@ -1,12 +1,12 @@ array( 'name'=>'Feed', 'type'=>'list', diff --git a/bridges/GBAtempBridge.php b/bridges/GBAtempBridge.php index bab42be..0950dc3 100644 --- a/bridges/GBAtempBridge.php +++ b/bridges/GBAtempBridge.php @@ -1,12 +1,12 @@ array( 'name'=>'Type', 'type'=>'list', @@ -65,22 +65,22 @@ class GBAtempBridge extends BridgeAbstract { public function collectData(){ - $html = $this->getSimpleHTMLDOM($this->uri) + $html = $this->getSimpleHTMLDOM(self::URI) or $this->returnServerError('Could not request GBAtemp.'); switch($this->getInput('type')){ case 'N': foreach ($html->find('li[class=news_item full]') as $newsItem) { - $url = $this->uri.$newsItem->find('a', 0)->href; + $url = self::URI.$newsItem->find('a', 0)->href; $time = intval($this->ExtractFromDelimiters($newsItem->find('abbr.DateTime', 0)->outertext, 'data-time="', '"')); $author = $newsItem->find('a.username', 0)->plaintext; $title = $newsItem->find('a', 1)->plaintext; - $content = $this->fetch_post_content($url, $this->uri); + $content = $this->fetch_post_content($url, self::URI); $this->items[] = $this->build_item($url, $title, $author, $time, $content); } case 'R': foreach ($html->find('li.portal_review') as $reviewItem) { - $url = $this->uri.$reviewItem->find('a', 0)->href; + $url = self::URI.$reviewItem->find('a', 0)->href; $title = $reviewItem->find('span.review_title', 0)->plaintext; $content = $this->getSimpleHTMLDOM($url) or $this->returnServerError('Could not request GBAtemp: '.$uri); $author = $content->find('a.username', 0)->plaintext; @@ -90,25 +90,25 @@ class GBAtempBridge extends BridgeAbstract { $subheader = '

'.$content->find('div.review_subheader', 0)->plaintext.'

'; $procons = $content->find('table.review_procons', 0)->outertext; $scores = $content->find('table.reviewscores', 0)->outertext; - $content = $this->cleanup_post_content($intro.$review.$subheader.$procons.$scores, $this->uri); + $content = $this->cleanup_post_content($intro.$review.$subheader.$procons.$scores, self::URI); $this->items[] = $this->build_item($url, $title, $author, $time, $content); } case 'T': foreach ($html->find('li.portal-tutorial') as $tutorialItem) { - $url = $this->uri.$tutorialItem->find('a', 0)->href; + $url = self::URI.$tutorialItem->find('a', 0)->href; $title = $tutorialItem->find('a', 0)->plaintext; $time = intval($this->ExtractFromDelimiters($tutorialItem->find('abbr.DateTime', 0)->outertext, 'data-time="', '"')); $author = $tutorialItem->find('a.username', 0)->plaintext; - $content = $this->fetch_post_content($url, $this->uri); + $content = $this->fetch_post_content($url, self::URI); $this->items[] = $this->build_item($url, $title, $author, $time, $content); } case 'F': foreach ($html->find('li.rc_item') as $postItem) { - $url = $this->uri.$postItem->find('a', 1)->href; + $url = self::URI.$postItem->find('a', 1)->href; $title = $postItem->find('a', 1)->plaintext; $time = intval($this->ExtractFromDelimiters($postItem->find('abbr.DateTime', 0)->outertext, 'data-time="', '"')); $author = $postItem->find('a.username', 0)->plaintext; - $content = $this->fetch_post_content($url, $this->uri); + $content = $this->fetch_post_content($url, self::URI); $this->items[] = $this->build_item($url, $title, $author, $time, $content); } } @@ -117,7 +117,7 @@ class GBAtempBridge extends BridgeAbstract { public function getName() { $type=array_search( $this->getInput('type'), - $this->parameters[$this->queriedContext]['type']['values'] + self::PARAMETERS[$this->queriedContext]['type']['values'] ); return 'GBAtemp '.$type.' Bridge'; } diff --git a/bridges/GelbooruBridge.php b/bridges/GelbooruBridge.php index 811a905..f612c98 100644 --- a/bridges/GelbooruBridge.php +++ b/bridges/GelbooruBridge.php @@ -1,12 +1,12 @@ array( 'name'=>'page', 'type'=>'number' @@ -16,14 +16,14 @@ class GelbooruBridge extends BridgeAbstract{ public function collectData(){ $html = $this->getSimpleHTMLDOM( - $this->uri.'index.php?page=post&s=list&' + self::URI.'index.php?page=post&s=list&' .'&pid='.($this->getInput('p')?($this->getInput('p') -1)*63:'') .'&tags='.urlencode($this->getInput('t')) ) or $this->returnServerError('Could not request Gelbooru.'); foreach($html->find('div[class=content] span') as $element) { $item = array(); - $item['uri'] = $this->uri.$element->find('a', 0)->href; + $item['uri'] = self::URI.$element->find('a', 0)->href; $item['postid'] = (int)preg_replace("/[^0-9]/",'', $element->getAttribute('id')); $item['timestamp'] = time(); $thumbnailUri = $element->find('img', 0)->src; diff --git a/bridges/GiphyBridge.php b/bridges/GiphyBridge.php index 95beea5..dcdff8b 100644 --- a/bridges/GiphyBridge.php +++ b/bridges/GiphyBridge.php @@ -3,12 +3,12 @@ define('GIPHY_LIMIT', 10); class GiphyBridge extends BridgeAbstract{ - public $maintainer = "kraoc"; - public $name = "Giphy Bridge"; - public $uri = "http://giphy.com/"; - public $description = "Bridge for giphy.com"; + const MAINTAINER = "kraoc"; + const NAME = "Giphy Bridge"; + const URI = "http://giphy.com/"; + const DESCRIPTION = "Bridge for giphy.com"; - public $parameters = array( array( + const PARAMETERS = array( array( 's'=>array( 'name'=>'search tag', 'required'=>true @@ -22,7 +22,7 @@ class GiphyBridge extends BridgeAbstract{ public function collectData(){ $html = ''; $base_url = 'http://giphy.com'; - $html = $this->getSimpleHTMLDOM($this->uri.'/search/'.urlencode($this->getInput('s').'/')) + $html = $this->getSimpleHTMLDOM(self::URI.'/search/'.urlencode($this->getInput('s').'/')) or $this->returnServerError('No results for this query.'); $max = GIPHY_LIMIT; @@ -37,7 +37,7 @@ class GiphyBridge extends BridgeAbstract{ $node = $entry->first_child(); $href = $node->getAttribute('href'); - $html2 = $this->getSimpleHTMLDOM($this->uri . $href) + $html2 = $this->getSimpleHTMLDOM(self::URI . $href) or $this->returnServerError('No results for this query.'); $figure = $html2->getElementByTagName('figure'); $img = $figure->firstChild(); diff --git a/bridges/GithubIssueBridge.php b/bridges/GithubIssueBridge.php index 480a244..767d584 100644 --- a/bridges/GithubIssueBridge.php +++ b/bridges/GithubIssueBridge.php @@ -1,12 +1,12 @@ array ( 'u'=>array( 'name'=>'User name', @@ -29,7 +29,7 @@ class GithubIssueBridge extends BridgeAbstract{ ); public function collectData(){ - $uri = $this->uri.$this->getInput('u').'/'.$this->getInput('p') + $uri = self::URI.$this->getInput('u').'/'.$this->getInput('p') .'/issues/'.$this->getInput('i'); $html = $this->getSimpleHTMLDOM($uri) or $this->returnServerError('No results for Github Issue '.$this->getInput('i').' in project '.$this->getInput('u').'/'.$this->getInput('p')); @@ -60,7 +60,7 @@ class GithubIssueBridge extends BridgeAbstract{ $item['title']=$issue->find('.js-navigation-open',0)->plaintext; $comments=$issue->find('.col-5',0)->plaintext; $item['content']='Comments: '.($comments?$comments:'0'); - $item['uri']=$this->uri.$issue->find('.js-navigation-open',0)->getAttribute('href'); + $item['uri']=self::URI.$issue->find('.js-navigation-open',0)->getAttribute('href'); $this->items[]=$item; } break; diff --git a/bridges/GitlabCommitsBridge.php b/bridges/GitlabCommitsBridge.php index f5fe97e..8c7ec71 100644 --- a/bridges/GitlabCommitsBridge.php +++ b/bridges/GitlabCommitsBridge.php @@ -1,12 +1,12 @@ array( 'name'=>'Base URI', 'defaultValue'=>'https://gitlab.com' diff --git a/bridges/GizmodoFRBridge.php b/bridges/GizmodoFRBridge.php index 660da8a..e653130 100644 --- a/bridges/GizmodoFRBridge.php +++ b/bridges/GizmodoFRBridge.php @@ -1,10 +1,10 @@ getSimpleHTMLDOM($this->uri.'/feed') - or $this->returnServerError('Could not request '.$this->uri.'/feed'); + $rssFeed = $this->getSimpleHTMLDOM(self::URI.'/feed') + or $this->returnServerError('Could not request '.self::URI.'/feed'); $limit = 0; foreach($rssFeed->find('item') as $element) { diff --git a/bridges/GooglePlusPostBridge.php b/bridges/GooglePlusPostBridge.php index a55620f..b86151d 100644 --- a/bridges/GooglePlusPostBridge.php +++ b/bridges/GooglePlusPostBridge.php @@ -4,12 +4,12 @@ class GooglePlusPostBridge extends BridgeAbstract protected $_title; protected $_url; - public $maintainer = "Grummfy"; - public $name = "Google Plus Post Bridge"; - public $uri = "https://plus.google.com/"; - public $description = "Returns user public post (without API)."; + const MAINTAINER = "Grummfy"; + const NAME = "Google Plus Post Bridge"; + const URI = "https://plus.google.com/"; + const DESCRIPTION = "Returns user public post (without API)."; - public $parameters = array( array( + const PARAMETERS = array( array( 'username'=>array( 'name'=>'username or Id', 'required'=>true @@ -20,7 +20,7 @@ class GooglePlusPostBridge extends BridgeAbstract { // get content parsed // $html = $this->getSimpleHTMLDOM(__DIR__ . '/../posts2.html' - $html = $this->getSimpleHTMLDOM($this->uri . urlencode($this->getInput('username')) . '/posts' + $html = $this->getSimpleHTMLDOM(self::URI . urlencode($this->getInput('username')) . '/posts' // force language , false, stream_context_create(array('http'=> array( 'header' => 'Accept-Language: fr,fr-be,fr-fr;q=0.8,en;q=0.4,en-us;q=0.2;*' . "\r\n" @@ -48,7 +48,7 @@ class GooglePlusPostBridge extends BridgeAbstract // $item['title'] = $item['fullname'] = $post->find('header.lea', 0)->plaintext; $item['avatar'] = $post->find('div.ys img', 0)->src; // var_dump((($post->find('a.o-U-s', 0)->getAllAttributes()))); - $item['uri'] = $this->uri . $post->find('a.o-U-s', 0)->href; + $item['uri'] = self::URI . $post->find('a.o-U-s', 0)->href; $item['timestamp'] = strtotime($post->find('a.o-U-s', 0)->plaintext); $this->items[] = $item; @@ -56,21 +56,21 @@ class GooglePlusPostBridge extends BridgeAbstract $hashtags = array(); foreach($post->find('a.d-s') as $hashtag) { - $hashtags[ trim($hashtag->plaintext) ] = $this->uri . $hashtag->href; + $hashtags[ trim($hashtag->plaintext) ] = self::URI . $hashtag->href; } $item['content'] = ''; // avatar display - $item['content'] .= ''; $content = $post->find('div.Al', 0); // alter link // $content = $content->innertext; -// $content = str_replace('href="./', 'href="' . $this->uri, $content); -// $content = str_replace('href="photos', 'href="' . $this->uri . 'photos', $content); +// $content = str_replace('href="./', 'href="' . self::URI, $content); +// $content = str_replace('href="photos', 'href="' . self::URI . 'photos', $content); // XXX ugly but I don't have any idea how to do a better stuff, str_replace on link doesn't work as expected and ask too many checks foreach($content->find('a') as $link) { @@ -86,7 +86,7 @@ class GooglePlusPostBridge extends BridgeAbstract { $link->href = substr($link->href, 1); } - $link->href = $this->uri . $link->href; + $link->href = self::URI . $link->href; } } $content = $content->innertext; @@ -107,7 +107,7 @@ class GooglePlusPostBridge extends BridgeAbstract public function getURI() { - return $this->_url ?: $this->uri; + return $this->_url ?: self::URI; } public function getCacheDuration() diff --git a/bridges/GoogleSearchBridge.php b/bridges/GoogleSearchBridge.php index fb3d740..9c3724f 100644 --- a/bridges/GoogleSearchBridge.php +++ b/bridges/GoogleSearchBridge.php @@ -9,12 +9,12 @@ */ class GoogleSearchBridge extends BridgeAbstract{ - public $maintainer = "sebsauvage"; - public $name = "Google search"; - public $uri = "https://www.google.com/"; - public $description = "Returns most recent results from Google search."; + const MAINTAINER = "sebsauvage"; + const NAME = "Google search"; + const URI = "https://www.google.com/"; + const DESCRIPTION = "Returns most recent results from Google search."; - public $parameters = array( array( + const PARAMETERS = array( array( 'q'=>array( 'name'=>"keyword", 'required'=>true @@ -25,7 +25,7 @@ class GoogleSearchBridge extends BridgeAbstract{ public function collectData(){ $html = ''; - $html = $this->getSimpleHTMLDOM($this->uri + $html = $this->getSimpleHTMLDOM(self::URI .'search?q=' . urlencode($this->getInput('q')) .'&num=100&complete=0&tbs=qdr:y,sbd:1') or $this->returnServerError('No results for this query.'); diff --git a/bridges/GuruMedBridge.php b/bridges/GuruMedBridge.php index 297dc56..0c4bf2c 100644 --- a/bridges/GuruMedBridge.php +++ b/bridges/GuruMedBridge.php @@ -1,10 +1,10 @@ getSimpleHTMLDOM($this->uri.'feed') + $html = $this->getSimpleHTMLDOM(self::URI.'feed') or $this->returnServerError('Could not request Gurumed.'); $limit = 0; diff --git a/bridges/HDWallpapersBridge.php b/bridges/HDWallpapersBridge.php index fde1aaa..bfa4979 100644 --- a/bridges/HDWallpapersBridge.php +++ b/bridges/HDWallpapersBridge.php @@ -1,11 +1,11 @@ array( 'name'=>'category', 'defaultValue'=>'latest_wallpapers' @@ -29,7 +29,7 @@ class HDWallpapersBridge extends BridgeAbstract { $lastpage = 1; for ($page = 1; $page <= $lastpage; $page++) { - $link = $this->uri.'/'.$category.'/page/'.$page; + $link = self::URI.'/'.$category.'/page/'.$page; $html = $this->getSimpleHTMLDOM($link) or $this->returnServerError('No results for this query.'); if ($page === 1) { @@ -42,10 +42,10 @@ class HDWallpapersBridge extends BridgeAbstract { $item = array(); // http://www.hdwallpapers.in/download/yosemite_reflections-1680x1050.jpg - $item['uri'] = $this->uri.'/download'.str_replace('wallpapers.html', $this->getInput('r').'.jpg', $element->href); + $item['uri'] = self::URI.'/download'.str_replace('wallpapers.html', $this->getInput('r').'.jpg', $element->href); $item['timestamp'] = time(); $item['title'] = $element->find('p', 0)->text(); - $item['content'] = $item['title'].'
'; + $item['content'] = $item['title'].'
'; $this->items[] = $item; $num++; diff --git a/bridges/HentaiHavenBridge.php b/bridges/HentaiHavenBridge.php index e970d00..2732560 100644 --- a/bridges/HentaiHavenBridge.php +++ b/bridges/HentaiHavenBridge.php @@ -1,13 +1,13 @@ getSimpleHTMLDOM($this->uri) + $html = $this->getSimpleHTMLDOM(self::URI) 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 f99bde7..200634e 100644 --- a/bridges/IdenticaBridge.php +++ b/bridges/IdenticaBridge.php @@ -1,12 +1,12 @@ array( 'name'=>'username', 'required'=>true @@ -32,7 +32,7 @@ class IdenticaBridge extends BridgeAbstract{ } public function getURI(){ - return $this->uri.urlencode($this->getInput('u')); + return self::URI.urlencode($this->getInput('u')); } public function getCacheDuration(){ diff --git a/bridges/InstagramBridge.php b/bridges/InstagramBridge.php index bec19b2..6105603 100644 --- a/bridges/InstagramBridge.php +++ b/bridges/InstagramBridge.php @@ -1,12 +1,12 @@ array( 'name'=>'username', 'required'=>true @@ -46,7 +46,7 @@ class InstagramBridge extends BridgeAbstract{ { $item = array(); - $item['uri'] = $this->uri.'/p/'.$media->code.'/'; + $item['uri'] = self::URI.'/p/'.$media->code.'/'; $item['content'] = ''; if (isset($media->caption)) { @@ -65,7 +65,7 @@ class InstagramBridge extends BridgeAbstract{ } public function getURI(){ - return $this->uri.urlencode($this->getInput('u')); + return self::URI.urlencode($this->getInput('u')); } } diff --git a/bridges/IsoHuntBridge.php b/bridges/IsoHuntBridge.php index f99ceef..4c4b268 100644 --- a/bridges/IsoHuntBridge.php +++ b/bridges/IsoHuntBridge.php @@ -1,11 +1,11 @@ uri; + $uri=self::URI; switch($this->queriedContext){ case 'By "Latest" category': switch($this->getInput('latest_category')){ @@ -132,27 +132,27 @@ class IsoHuntBridge extends BridgeAbstract{ $categoryName = array_search( $this->getInput('latest_category'), - $this->parameters['By "Latest" category']['latest_category']['values'] + self::PARAMETERS['By "Latest" category']['latest_category']['values'] ); - $name = 'Latest '.$categoryName.' - ' . $this->name; + $name = 'Latest '.$categoryName.' - ' . self::NAME; break; case 'By "Torrent" category': $categoryName = array_search( $this->getInput('torrent_category'), - $this->parameters['By "Torrent" category']['torrent_category']['values'] + self::PARAMETERS['By "Torrent" category']['torrent_category']['values'] ); - $name = 'Category: ' . $categoryName . ' - ' . $this->name; + $name = 'Category: ' . $categoryName . ' - ' . self::NAME; break; case 'Search torrent by name': $categoryName = array_search( $this->getInput('search_category'), - $this->parameters['Search torrent by name']['search_category']['values'] + self::PARAMETERS['Search torrent by name']['search_category']['values'] ); - $name = 'Search: "' . $this->getInput('search_name') . '" in category: ' . $categoryName . ' - ' . $this->name; + $name = 'Search: "' . $this->getInput('search_name') . '" in category: ' . $categoryName . ' - ' . self::NAME; break; } @@ -446,7 +446,7 @@ class IsoHuntBridge extends BridgeAbstract{ } private function fix_relative_uri($uri){ - return preg_replace('/\//i', $this->uri, $uri, 1); + return preg_replace('/\//i', self::URI, $uri, 1); } private function build_category_uri($category, $order_popularity = false){ diff --git a/bridges/JapanExpoBridge.php b/bridges/JapanExpoBridge.php index b02304a..db8a202 100644 --- a/bridges/JapanExpoBridge.php +++ b/bridges/JapanExpoBridge.php @@ -1,11 +1,11 @@ array( 'name'=>'Show full contents', 'type'=>'checkbox', @@ -42,8 +42,8 @@ class JapanExpoBridge extends HttpCachingBridgeAbstract { } }; - $html = $this->getSimpleHTMLDOM($this->uri) - or $this->returnServerError('Could not request JapanExpo: '.$this->uri); + $html = $this->getSimpleHTMLDOM(self::URI) + or $this->returnServerError('Could not request JapanExpo: '.self::URI); $fullcontent = $this->getInput('mode'); $count = 0; diff --git a/bridges/KonachanBridge.php b/bridges/KonachanBridge.php index 50730dc..0a213fe 100644 --- a/bridges/KonachanBridge.php +++ b/bridges/KonachanBridge.php @@ -1,12 +1,12 @@ array( 'name'=>'page', 'defaultValue'=>1, @@ -17,7 +17,7 @@ class KonachanBridge extends BridgeAbstract{ public function collectData(){ $html = $this->getSimpleHTMLDOM( - $this->uri.'/post?' + self::URI.'/post?' .'&page='.$this->getInput('p') .'&tags='.urlencode($this->getInput('t')) ) or $this->returnServerError('Could not request Konachan.'); @@ -30,7 +30,7 @@ class KonachanBridge extends BridgeAbstract{ foreach($data as $datai) { $json = json_decode($datai, TRUE); $item = array(); - $item['uri'] = $this->uri.'/post/show/'.$json['id']; + $item['uri'] = self::URI.'/post/show/'.$json['id']; $item['postid'] = $json['id']; $item['timestamp'] = $json['created_at']; $item['imageUri'] = $json['file_url']; diff --git a/bridges/KoreusBridge.php b/bridges/KoreusBridge.php index 4cb86c8..f079bca 100644 --- a/bridges/KoreusBridge.php +++ b/bridges/KoreusBridge.php @@ -1,10 +1,10 @@ array( 'site'=>array( 'name'=>'Site', @@ -55,12 +55,12 @@ class KununuBridge extends HttpCachingBridgeAbstract { break; } - return $this->uri.$site.'/'.$company.'/'.$section; + return self::URI.$site.'/'.$company.'/'.$section; } function getName(){ $company = $this->encode_umlauts(strtolower(str_replace(' ', '-', trim($this->getInput('company'))))); - return ($this->companyName?:$company).' - '.$this->name; + return ($this->companyName?:$company).' - '.self::NAME; } public function collectData(){ @@ -109,7 +109,7 @@ class KununuBridge extends HttpCachingBridgeAbstract { * Fixes relative URLs in the given text */ private function fix_url($text){ - return preg_replace('/href=(\'|\")\//i', 'href="'.$this->uri, $text); + return preg_replace('/href=(\'|\")\//i', 'href="'.self::URI, $text); } /** @@ -184,7 +184,7 @@ class KununuBridge extends HttpCachingBridgeAbstract { if($anchor === false) $this->returnServerError('Cannot find article URI!'); - return $this->uri . $anchor->href; + return self::URI . $anchor->href; } /** diff --git a/bridges/LWNprevBridge.php b/bridges/LWNprevBridge.php index c267362..704c1d5 100644 --- a/bridges/LWNprevBridge.php +++ b/bridges/LWNprevBridge.php @@ -1,12 +1,12 @@ uri.'free/bigpage'; + return self::URI.'free/bigpage'; } private function jumpToNextTag(&$node){ @@ -48,7 +48,7 @@ class LWNprevBridge extends BridgeAbstract{ break; } } - $realURI=$this->uri.$a->getAttribute('href'); + $realURI=self::URI.$a->getAttribute('href'); $URICounter=0; $edition=$html->getElementsByTagName('h1')->item(0)->textContent; @@ -82,7 +82,7 @@ class LWNprevBridge extends BridgeAbstract{ $h2FirstChild=$h2->firstChild; $this->jumpToNextTag($h2FirstChild); if($h2FirstChild->nodeName==='a'){ - $item['uri']=$this->uri.$h2FirstChild->getAttribute('href'); + $item['uri']=self::URI.$h2FirstChild->getAttribute('href'); }else{ $item['uri']=$realURI.'#'.$URICounter; } diff --git a/bridges/LeBonCoinBridge.php b/bridges/LeBonCoinBridge.php index fab1a71..6b89f46 100755 --- a/bridges/LeBonCoinBridge.php +++ b/bridges/LeBonCoinBridge.php @@ -1,12 +1,12 @@ array('name'=>'Mot Clé'), 'r'=>array( 'name'=>'Région', @@ -143,7 +143,7 @@ class LeBonCoinBridge extends BridgeAbstract{ } $html = $this->getSimpleHTMLDOM( - $this->uri.$category.'/offres/' . $this->getInput('r') . '/?' + self::URI.$category.'/offres/' . $this->getInput('r') . '/?' .'f=a&th=1&' .'q=' . urlencode($this->getInput('k')) ) or $this->returnServerError('Could not request LeBonCoin.'); diff --git a/bridges/LeJournalDuGeekBridge.php b/bridges/LeJournalDuGeekBridge.php index f1b89a1..e08f419 100644 --- a/bridges/LeJournalDuGeekBridge.php +++ b/bridges/LeJournalDuGeekBridge.php @@ -1,10 +1,10 @@ getSimpleHTMLDOM($this->uri.'rss') - or $this->returnServerError('Could not request '.$this->uri.'/rss'); + $rssFeed = $this->getSimpleHTMLDOM(self::URI.'rss') + or $this->returnServerError('Could not request '.self::URI.'/rss'); $limit = 0; foreach($rssFeed->find('item') as $element) { diff --git a/bridges/LeMondeInformatiqueBridge.php b/bridges/LeMondeInformatiqueBridge.php index b744e76..8fd1daa 100644 --- a/bridges/LeMondeInformatiqueBridge.php +++ b/bridges/LeMondeInformatiqueBridge.php @@ -1,10 +1,10 @@ getSimpleHTMLDOM($this->uri.'rss/rss.xml') + $html = $this->getSimpleHTMLDOM(self::URI.'rss/rss.xml') or $this->returnServerError('Could not request LeMondeInformatique: ' - .$this->uri.'rss/rss.xml'); + .self::URI.'rss/rss.xml'); $limit = 0; foreach($html->find('item') as $element) { diff --git a/bridges/Les400CulsBridge.php b/bridges/Les400CulsBridge.php index 3fea2ff..ce56537 100644 --- a/bridges/Les400CulsBridge.php +++ b/bridges/Les400CulsBridge.php @@ -1,14 +1,14 @@ collectExpandableDatas($this->uri.'feeds/'); + $this->collectExpandableDatas(self::URI.'feeds/'); } protected function parseRSSItem($newsItem) { diff --git a/bridges/LesJoiesDuCodeBridge.php b/bridges/LesJoiesDuCodeBridge.php index 1d83556..81023b1 100644 --- a/bridges/LesJoiesDuCodeBridge.php +++ b/bridges/LesJoiesDuCodeBridge.php @@ -1,13 +1,13 @@ getSimpleHTMLDOM($this->uri) + $html = $this->getSimpleHTMLDOM(self::URI) 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 4e81e9c..f74c2bd 100644 --- a/bridges/LichessBridge.php +++ b/bridges/LichessBridge.php @@ -2,14 +2,14 @@ class LichessBridge extends HttpCachingBridgeAbstract { - public $maintainer = 'AmauryCarrade'; - public $name = 'Lichess Blog'; - public $uri = 'http://fr.lichess.org/blog'; - public $description = 'Returns the 5 newest posts from the Lichess blog (full text)'; + const MAINTAINER = 'AmauryCarrade'; + const NAME = 'Lichess Blog'; + const URI = 'http://fr.lichess.org/blog'; + const DESCRIPTION = 'Returns the 5 newest posts from the Lichess blog (full text)'; public function collectData() { - $xml_feed = $this->getSimpleHTMLDOM($this->uri.'.atom') + $xml_feed = $this->getSimpleHTMLDOM(self::URI.'.atom') or $this->returnServerError('Could not retrieve Lichess blog feed.'); $posts_loaded = 0; diff --git a/bridges/LinkedInCompanyBridge.php b/bridges/LinkedInCompanyBridge.php index e23f9d4..6ccbba5 100644 --- a/bridges/LinkedInCompanyBridge.php +++ b/bridges/LinkedInCompanyBridge.php @@ -1,12 +1,12 @@ apple)"; + const MAINTAINER = "regisenguehard"; + const NAME = "LinkedIn Company"; + const URI = "https://www.linkedin.com/"; + const DESCRIPTION = "Returns most recent actus from Company on LinkedIn. (https://www.linkedin.com/company/apple)"; - public $parameters = array( array( + const PARAMETERS = array( array( 'c'=>array( 'name'=>'Company name', 'required'=>true @@ -15,7 +15,7 @@ class LinkedInCompanyBridge extends BridgeAbstract{ public function collectData(){ $html = ''; - $link = $this->uri.'company/'.$this->getInput('c'); + $link = self::URI.'company/'.$this->getInput('c'); $html = $this->getSimpleHTMLDOM($link) or $this->returnServerError('Could not request LinkedIn.'); diff --git a/bridges/LolibooruBridge.php b/bridges/LolibooruBridge.php index 1bcf037..d2f9066 100644 --- a/bridges/LolibooruBridge.php +++ b/bridges/LolibooruBridge.php @@ -1,12 +1,12 @@ array( 'name'=>'page', 'defaultValue'=>1, @@ -17,7 +17,7 @@ class LolibooruBridge extends BridgeAbstract{ public function collectData(){ $html = $this->getSimpleHTMLDOM( - $this->uri.'post?' + self::URI.'post?' .'&page='.$this->getInput('p') .'&tags='.urlencode($this->getInput('t')) ) or $this->returnServerError('Could not request Lolibooru.'); @@ -30,7 +30,7 @@ class LolibooruBridge extends BridgeAbstract{ foreach($data as $datai) { $json = json_decode($datai, TRUE); $item = array(); - $item['uri'] = $this->uri.'post/show/'.$json['id']; + $item['uri'] = self::URI.'post/show/'.$json['id']; $item['postid'] = $json['id']; $item['timestamp'] = $json['created_at']; $item['imageUri'] = $json['file_url']; diff --git a/bridges/MangareaderBridge.php b/bridges/MangareaderBridge.php index cdf5a70..ce93ed3 100644 --- a/bridges/MangareaderBridge.php +++ b/bridges/MangareaderBridge.php @@ -2,12 +2,12 @@ define('MANGAREADER_LIMIT', 10); // The default limit class MangareaderBridge extends BridgeAbstract{ - public $maintainer = "logmanoriginal"; - public $name = "Mangareader Bridge"; - public $uri = "http://www.mangareader.net/"; - public $description = "Returns the latest updates, popular mangas or manga updates (new chapters)"; + const MAINTAINER = "logmanoriginal"; + const NAME = "Mangareader Bridge"; + const URI = "http://www.mangareader.net/"; + const DESCRIPTION = "Returns the latest updates, popular mangas or manga updates (new chapters)"; - public $parameters = array( + const PARAMETERS = array( 'Get latest updates' => array(), 'Get popular mangas' => array( 'category'=>array( @@ -108,7 +108,7 @@ class MangareaderBridge extends BridgeAbstract{ if (isset($manga) && $chapters->length >= 1){ $item = array(); - $item['uri'] = $this->uri. htmlspecialchars($manga->getAttribute('href')); + $item['uri'] = self::URI. htmlspecialchars($manga->getAttribute('href')); $item['title'] = htmlspecialchars($manga->nodeValue); // Add each chapter to the feed @@ -118,7 +118,7 @@ class MangareaderBridge extends BridgeAbstract{ if($item['content'] <> ""){ $item['content'] .= "
"; } - $item['content'] .= "" . htmlspecialchars($chapter->nodeValue) . ""; + $item['content'] .= "" . htmlspecialchars($chapter->nodeValue) . ""; } $this->items[] = $item; @@ -142,7 +142,7 @@ class MangareaderBridge extends BridgeAbstract{ $item = array(); $item['title'] = htmlspecialchars($xpath->query(".//*[@class='manga_name']//a", $manga)->item(0)->nodeValue); - $item['uri'] = $this->uri . $xpath->query(".//*[@class='manga_name']//a", $manga)->item(0)->getAttribute('href'); + $item['uri'] = self::URI . $xpath->query(".//*[@class='manga_name']//a", $manga)->item(0)->getAttribute('href'); $item['author'] = htmlspecialchars($xpath->query("//*[@class='author_name']", $manga)->item(0)->nodeValue); $item['chaptercount'] = $xpath->query(".//*[@class='chapter_count']", $manga)->item(0)->nodeValue; $item['genre'] = htmlspecialchars($xpath->query(".//*[@class='manga_genre']", $manga)->item(0)->nodeValue); @@ -170,7 +170,7 @@ class MangareaderBridge extends BridgeAbstract{ foreach ($chapters as $chapter){ $item = array(); $item['title'] = htmlspecialchars($xpath->query("td[1]", $chapter)->item(0)->nodeValue); - $item['uri'] = $this->uri . $xpath->query("td[1]/a", $chapter)->item(0)->getAttribute('href'); + $item['uri'] = self::URI . $xpath->query("td[1]/a", $chapter)->item(0)->getAttribute('href'); $item['timestamp'] = strtotime($xpath->query("td[2]", $chapter)->item(0)->nodeValue); array_unshift($this->items, $item); } @@ -201,7 +201,7 @@ class MangareaderBridge extends BridgeAbstract{ $path = $this->getInput('path'); break; } - return $this->uri . $path; + return self::URI . $path; } diff --git a/bridges/MilbooruBridge.php b/bridges/MilbooruBridge.php index 1dc08cf..43799df 100644 --- a/bridges/MilbooruBridge.php +++ b/bridges/MilbooruBridge.php @@ -2,12 +2,12 @@ class MilbooruBridge extends BridgeAbstract{ - public $maintainer = "mitsukarenai"; - public $name = "Milbooru"; - public $uri = "http://sheslostcontrol.net/moe/shimmie/"; - public $description = "Returns images from given page"; + const MAINTAINER = "mitsukarenai"; + const NAME = "Milbooru"; + const URI = "http://sheslostcontrol.net/moe/shimmie/"; + const DESCRIPTION = "Returns images from given page"; - public $parameters = array( array( + const PARAMETERS = array( array( 'p'=>array( 'name'=>'page', 'type'=>'number' @@ -17,15 +17,15 @@ class MilbooruBridge extends BridgeAbstract{ public function collectData(){ $html = $this->getSimpleHTMLDOM( - $this->uri.'?q=/post/list/'.urlencode($this->getInput('t')).'/'.$this->getInput('p') + self::URI.'?q=/post/list/'.urlencode($this->getInput('t')).'/'.$this->getInput('p') )or $this->returnServerError('Could not request Milbooru.'); foreach($html->find('div[class=shm-image-list] span[class=thumb]') as $element) { $item = array(); - $item['uri'] = $this->uri.$element->find('a', 0)->href; + $item['uri'] = self::URI.$element->find('a', 0)->href; $item['postid'] = (int)preg_replace("/[^0-9]/",'', $element->find('a', 0)->getAttribute('data-post-id')); $item['timestamp'] = time(); - $thumbnailUri = $this->uri.$element->find('img', 0)->src; + $thumbnailUri = self::URI.$element->find('img', 0)->src; $item['tags'] = $element->find('a', 0)->getAttribute('data-tags'); $item['title'] = 'Milbooru | '.$item['postid']; $item['content'] = '
Tags: '.$item['tags']; diff --git a/bridges/MondeDiploBridge.php b/bridges/MondeDiploBridge.php index 2a6afc4..c9d20af 100644 --- a/bridges/MondeDiploBridge.php +++ b/bridges/MondeDiploBridge.php @@ -1,19 +1,19 @@ getSimpleHTMLDOM($this->uri) - or $this->returnServerError('Could not request MondeDiplo. for : ' . $this->uri); + $html = $this->getSimpleHTMLDOM(self::URI) + or $this->returnServerError('Could not request MondeDiplo. for : ' . self::URI); foreach($html->find('div.unarticle') as $article) { $element = $article->parent(); $item = array(); - $item['uri'] = $this->uri . $element->href; + $item['uri'] = self::URI . $element->href; $item['title'] = $element->find('h3', 0)->plaintext; $item['content'] = $element->find('div.dates_auteurs', 0)->plaintext . '
' . strstr($element->find('div', 0)->plaintext, $element->find('div.dates_auteurs', 0)->plaintext, true); $this->items[] = $item; diff --git a/bridges/MsnMondeBridge.php b/bridges/MsnMondeBridge.php index 5e48195..f7b4c77 100644 --- a/bridges/MsnMondeBridge.php +++ b/bridges/MsnMondeBridge.php @@ -1,13 +1,13 @@ uri.'fr-fr/actualite/monde'; + return self::URI.'fr-fr/actualite/monde'; } private function MsnMondeExtractContent($url, &$item) { @@ -23,7 +23,7 @@ class MsnMondeBridge extends BridgeAbstract{ if($limit < 10) { $item = array(); $item['title'] = utf8_decode($article->find('h4', 0)->innertext); - $item['uri'] = $this->uri . utf8_decode($article->find('a', 0)->href); + $item['uri'] = self::URI . utf8_decode($article->find('a', 0)->href); $this->MsnMondeExtractContent($item['uri'], $item); $this->items[] = $item; $limit++; diff --git a/bridges/MspabooruBridge.php b/bridges/MspabooruBridge.php index e255f9e..821207e 100644 --- a/bridges/MspabooruBridge.php +++ b/bridges/MspabooruBridge.php @@ -2,12 +2,12 @@ class MspabooruBridge extends BridgeAbstract{ - public $maintainer = "mitsukarenai"; - public $name = "Mspabooru"; - public $uri = "http://mspabooru.com/"; - public $description = "Returns images from given page"; + const MAINTAINER = "mitsukarenai"; + const NAME = "Mspabooru"; + const URI = "http://mspabooru.com/"; + const DESCRIPTION = "Returns images from given page"; - public $parameters = array( array( + const PARAMETERS = array( array( 'p'=>array( 'name'=>'page', 'type'=>'number' @@ -17,7 +17,7 @@ class MspabooruBridge extends BridgeAbstract{ public function collectData(){ $html = $this->getSimpleHTMLDOM( - $this->uri.'index.php?page=post&s=list&' + self::URI.'index.php?page=post&s=list&' .'&pid='.($this->getInput('p')?($this->getInput('p') -1)*50:'') .'&tags='.urlencode($this->getInput('t')) ) or $this->returnServerError('Could not request Mspabooru.'); @@ -25,7 +25,7 @@ class MspabooruBridge extends BridgeAbstract{ foreach($html->find('div[class=content] span') as $element) { $item = array(); - $item['uri'] = $this->uri.$element->find('a', 0)->href; + $item['uri'] = self::URI.$element->find('a', 0)->href; $item['postid'] = (int)preg_replace("/[^0-9]/",'', $element->getAttribute('id')); $item['timestamp'] = time(); $thumbnailUri = $element->find('img', 0)->src; diff --git a/bridges/NakedSecurityBridge.php b/bridges/NakedSecurityBridge.php index 5d0fb36..893bc87 100644 --- a/bridges/NakedSecurityBridge.php +++ b/bridges/NakedSecurityBridge.php @@ -1,10 +1,10 @@ getSimpleHTMLDOM($this->uri.'archivepix.html') or $this->returnServerError('Error while downloading the website content'); + $html = $this->getSimpleHTMLDOM(self::URI.'archivepix.html') or $this->returnServerError('Error while downloading the website content'); $list = explode("
", $html->find('b', 0)->innertext); for($i = 0; $i < 3;$i++) @@ -17,7 +17,7 @@ class NasaApodBridge extends BridgeAbstract{ $item = array(); $uri_page = $html->find('a',$i + 3)->href; - $uri = $this->uri.$uri_page; + $uri = self::URI.$uri_page; $item['uri'] = $uri; $picture_html = $this->getSimpleHTMLDOM($uri); diff --git a/bridges/NeuviemeArtBridge.php b/bridges/NeuviemeArtBridge.php index 54261c2..6374cf0 100644 --- a/bridges/NeuviemeArtBridge.php +++ b/bridges/NeuviemeArtBridge.php @@ -1,10 +1,10 @@ uri.'9emeart.rss'; + $feedUrl = self::URI.'9emeart.rss'; $html = $this->getSimpleHTMLDOM($feedUrl) or $this->returnServerError('Could not request 9eme Art: '.$feedUrl); $limit = 0; @@ -32,9 +32,9 @@ class NeuviemeArtBridge extends BridgeAbstract { $article_image = $element->find('enclosure', 0)->url; foreach ($article_html->find('img.img_full') as $img) if ($img->alt == $article_title) - $article_image = $this->uri.$img->src; + $article_image = self::URI.$img->src; $article_content = '

' - .str_replace('src="/', 'src="'.$this->uri, $article_html->find('div.newsGenerique_con', 0)->innertext); + .str_replace('src="/', 'src="'.self::URI, $article_html->find('div.newsGenerique_con', 0)->innertext); $article_content = StripWithDelimiters($article_content, ''); $article_content = StripWithDelimiters($article_content, ''); $article_content = StripWithDelimiters($article_content, ''); diff --git a/bridges/NextInpactBridge.php b/bridges/NextInpactBridge.php index c5e39ed..8c35753 100644 --- a/bridges/NextInpactBridge.php +++ b/bridges/NextInpactBridge.php @@ -1,10 +1,10 @@ getSimpleHTMLDOM($this->uri.'rss/news.xml') or $this->returnServerError('Could not request NextInpact.'); + $html = $this->getSimpleHTMLDOM(self::URI.'rss/news.xml') or $this->returnServerError('Could not request NextInpact.'); $limit = 0; foreach($html->find('item') as $element) { diff --git a/bridges/NextgovBridge.php b/bridges/NextgovBridge.php index f7e508e..ee4f299 100644 --- a/bridges/NextgovBridge.php +++ b/bridges/NextgovBridge.php @@ -1,12 +1,12 @@ array( 'name'=>'Category', 'type'=>'list', diff --git a/bridges/NiceMatinBridge.php b/bridges/NiceMatinBridge.php index 69dd8dd..3c18909 100644 --- a/bridges/NiceMatinBridge.php +++ b/bridges/NiceMatinBridge.php @@ -1,10 +1,10 @@ getSimpleHTMLDOM($url); @@ -21,7 +21,7 @@ class NiceMatinBridge extends BridgeAbstract{ } public function collectData(){ - $html = $this->getSimpleHTMLDOM($this->uri.'derniere-minute/rss') + $html = $this->getSimpleHTMLDOM(self::URI.'derniere-minute/rss') or $this->returnServerError('Could not request NiceMatin.'); $limit = 0; diff --git a/bridges/NovelUpdatesBridge.php b/bridges/NovelUpdatesBridge.php index 3e61bec..b865737 100644 --- a/bridges/NovelUpdatesBridge.php +++ b/bridges/NovelUpdatesBridge.php @@ -1,11 +1,11 @@ array( 'name'=>'Novel URL', 'patterns'=>'http:\/\/www.novelupdates.com\/.*', @@ -22,7 +22,7 @@ class NovelUpdatesBridge extends BridgeAbstract{ $this->returnClientError('NovelUpdates URL only.'); if(strpos($thread['path'], 'series/') === FALSE) $this->returnClientError('You must specify the novel URL.'); - $url = $this->uri.$thread['path'].''; + $url = self::URI.$thread['path'].''; $fullhtml = $this->getSimpleHTMLDOM($url) or $this->returnServerError("Could not request NovelUpdates, novel not found"); $this->seriesTitle = $fullhtml->find('h4.seriestitle', 0)->plaintext; // dirty fix for nasty simpledom bug: https://github.com/sebsauvage/rss-bridge/issues/259 diff --git a/bridges/NumeramaBridge.php b/bridges/NumeramaBridge.php index 5754e57..1e80aff 100644 --- a/bridges/NumeramaBridge.php +++ b/bridges/NumeramaBridge.php @@ -1,10 +1,10 @@ uri.'feed/'; + $feed = self::URI.'feed/'; $html = $this->getSimpleHTMLDOM($feed) or $this->returnServerError('Could not request Numerama: '.$feed); $limit = 0; diff --git a/bridges/OpenClassroomsBridge.php b/bridges/OpenClassroomsBridge.php index 39fc87b..ae4ea10 100644 --- a/bridges/OpenClassroomsBridge.php +++ b/bridges/OpenClassroomsBridge.php @@ -1,12 +1,12 @@ array( 'name'=>'Catégorie', 'type'=>'list', @@ -26,7 +26,7 @@ class OpenClassroomsBridge extends BridgeAbstract{ )); public function getURI(){ - return $this->uri.'/courses?categories='.$this->getInput('u').'&' + return self::URI.'/courses?categories='.$this->getInput('u').'&' .'title=&sort=updatedAt+desc'; } @@ -36,7 +36,7 @@ class OpenClassroomsBridge extends BridgeAbstract{ foreach($html->find('.courseListItem') as $element) { $item = array(); - $item['uri'] = $this->uri.$element->find('a', 0)->href; + $item['uri'] = self::URI.$element->find('a', 0)->href; $item['title'] = $element->find('h3', 0)->plaintext; $item['content'] = $element->find('slidingItem__descriptionContent', 0)->plaintext; $this->items[] = $item; diff --git a/bridges/ParuVenduImmoBridge.php b/bridges/ParuVenduImmoBridge.php index 9f1cfd4..e791c7a 100644 --- a/bridges/ParuVenduImmoBridge.php +++ b/bridges/ParuVenduImmoBridge.php @@ -1,13 +1,13 @@ array( 'name'=>'Minimal surface m²', 'type'=>'number' @@ -49,7 +49,7 @@ class ParuVenduImmoBridge extends BridgeAbstract list($href) = explode('#', $element->href); $item = array(); - $item['uri'] = $this->uri.$href; + $item['uri'] = self::URI.$href; $item['title'] = $element->title; $item['content'] = $img.$desc.$price; $this->items[] = $item; @@ -60,7 +60,7 @@ class ParuVenduImmoBridge extends BridgeAbstract public function getURI(){ $appartment = '&tbApp=1&tbDup=1&tbChb=1&tbLof=1&tbAtl=1&tbPla=1'; $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; + $link = self::URI.'/immobilier/annonceimmofo/liste/listeAnnonces?tt=1'.$appartment.$maison; if ($this->getInput('minarea')) { $link .= '&sur0='.urlencode($this->getInput('minarea')); diff --git a/bridges/PickyWallpapersBridge.php b/bridges/PickyWallpapersBridge.php index 001cd1d..1411373 100644 --- a/bridges/PickyWallpapersBridge.php +++ b/bridges/PickyWallpapersBridge.php @@ -1,12 +1,12 @@ array( 'name'=>'category', 'required'=>true @@ -44,7 +44,7 @@ class PickyWallpapersBridge extends BridgeAbstract { foreach($html->find('.items li img') as $element) { $item = array(); - $item['uri'] = str_replace('www', 'wallpaper', $this->uri).'/'.$resolution.'/'.basename($element->src); + $item['uri'] = str_replace('www', 'wallpaper', self::URI).'/'.$resolution.'/'.basename($element->src); $item['timestamp'] = time(); $item['title'] = $element->alt; $item['content'] = $item['title'].'
'.$element.''; @@ -59,7 +59,7 @@ class PickyWallpapersBridge extends BridgeAbstract { public function getURI(){ $subcategory = $this->getInput('s'); - $link = $this->uri.$this->getInput('r').'/'.$this->getInput('c').'/'.$subcategory; + $link = self::URI.$this->getInput('r').'/'.$this->getInput('c').'/'.$subcategory; return $link; } diff --git a/bridges/PinterestBridge.php b/bridges/PinterestBridge.php index 8f12e8b..12e907a 100644 --- a/bridges/PinterestBridge.php +++ b/bridges/PinterestBridge.php @@ -1,12 +1,12 @@ array( 'u'=>array( 'name'=>'username', @@ -77,10 +77,10 @@ class PinterestBridge extends BridgeAbstract{ public function getURI(){ switch($this->queriedContext){ case 'By username and board': - $uri = $this->uri.urlencode($this->getInput('u')).'/'.urlencode($this->getInput('b')); + $uri = self::URI.urlencode($this->getInput('u')).'/'.urlencode($this->getInput('b')); break; case 'From search': - $uri = $this->uri.'search/?q='.urlencode($this->getInput('q')); + $uri = self::URI.'search/?q='.urlencode($this->getInput('q')); break; } @@ -96,6 +96,6 @@ class PinterestBridge extends BridgeAbstract{ $specific = $this->getInput('q'); break; } - return $specific .' - '.$this->name; + return $specific .' - '.self::NAME; } } diff --git a/bridges/PlanetLibreBridge.php b/bridges/PlanetLibreBridge.php index 6e2024f..1a9a118 100644 --- a/bridges/PlanetLibreBridge.php +++ b/bridges/PlanetLibreBridge.php @@ -1,10 +1,10 @@ getSimpleHTMLDOM($url); @@ -13,7 +13,7 @@ class PlanetLibreBridge extends BridgeAbstract{ } public function collectData(){ - $html = $this->getSimpleHTMLDOM($this->uri) + $html = $this->getSimpleHTMLDOM(self::URI) 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 dad98dd..9bfaad0 100644 --- a/bridges/ProjectMGameBridge.php +++ b/bridges/ProjectMGameBridge.php @@ -1,19 +1,19 @@ getSimpleHTMLDOM($this->uri) + $html = $this->getSimpleHTMLDOM(self::URI) or $this->returnServerError('Error while downloading the Project M homepage'); foreach($html->find('article') as $article) { $item = array(); - $item['uri'] = $this->uri.$article->find('section div.info_block a',0)->href; + $item['uri'] = self::URI.$article->find('section div.info_block a',0)->href; $item['title'] = $article->find('h1 p',0)->innertext; $p_list = $article->find('section p'); diff --git a/bridges/RTBFBridge.php b/bridges/RTBFBridge.php index cee0f0e..2805884 100644 --- a/bridges/RTBFBridge.php +++ b/bridges/RTBFBridge.php @@ -1,11 +1,11 @@ array( 'name'=>'series id', 'exampleValue'=>9500, @@ -27,7 +27,7 @@ class RTBFBridge extends BridgeAbstract { } $item = array(); $item['id'] = $element->getAttribute('data-id'); - $item['uri'] = $this->uri.'detail?id='.$item['id']; + $item['uri'] = self::URI.'detail?id='.$item['id']; $thumbnailUriSrcSet = explode(',', $element->find('figure .www-img-16by9 img', 0)->getAttribute('data-srcset')); $thumbnailUriLastSrc = end($thumbnailUriSrcSet); $thumbnailUri = explode(' ', $thumbnailUriLastSrc)[0]; @@ -40,7 +40,7 @@ class RTBFBridge extends BridgeAbstract { } public function getURI(){ - return $this->uri.'detail?id='.$this->getInput('c'); + return self::URI.'detail?id='.$this->getInput('c'); } public function getName(){ diff --git a/bridges/Releases3DSBridge.php b/bridges/Releases3DSBridge.php index 3e4ccae..a69e9ef 100644 --- a/bridges/Releases3DSBridge.php +++ b/bridges/Releases3DSBridge.php @@ -1,10 +1,10 @@ uri.'xml.php'; + $dataUrl = self::URI.'xml.php'; $xml = $this->getContents($dataUrl) or $this->returnServerError('Could not request 3dsdb: '.$dataUrl); $limit = 0; diff --git a/bridges/ReporterreBridge.php b/bridges/ReporterreBridge.php index 676604b..5061cbe 100644 --- a/bridges/ReporterreBridge.php +++ b/bridges/ReporterreBridge.php @@ -1,10 +1,10 @@ getSimpleHTMLDOM($url); @@ -17,14 +17,14 @@ class ReporterreBridge extends BridgeAbstract{ unset ($html2); // Replace all relative urls with absolute ones - $text = preg_replace('/(href|src)(\=[\"\'])(?!http)([^"\']+)/ims', "$1$2" . $this->uri . "$3", $text); + $text = preg_replace('/(href|src)(\=[\"\'])(?!http)([^"\']+)/ims', "$1$2" . self::URI . "$3", $text); $text = strip_tags($text, '


'); return $text; } public function collectData(){ - $html = $this->getSimpleHTMLDOM($this->uri.'spip.php?page=backend') or $this->returnServerError('Could not request Reporterre.'); + $html = $this->getSimpleHTMLDOM(self::URI.'spip.php?page=backend') or $this->returnServerError('Could not request Reporterre.'); $limit = 0; foreach($html->find('item') as $element) { diff --git a/bridges/Rue89Bridge.php b/bridges/Rue89Bridge.php index 978223f..ab18950 100644 --- a/bridges/Rue89Bridge.php +++ b/bridges/Rue89Bridge.php @@ -1,10 +1,10 @@ array( 'name'=>'page', 'type'=>'number' @@ -16,7 +16,7 @@ class Rule34Bridge extends BridgeAbstract{ public function collectData(){ $html = $this->getSimpleHTMLDOM( - $this->uri.'index.php?page=post&s=list&' + self::URI.'index.php?page=post&s=list&' .'&pid='.($this->getInput('p')?($this->getInput('p') -1)*50:'') .'&tags='.urlencode($this->getInput('t')) ) or $this->returnServerError('Could not request Rule34.'); @@ -24,7 +24,7 @@ class Rule34Bridge extends BridgeAbstract{ foreach($html->find('div[class=content] span') as $element) { $item = array(); - $item['uri'] = $this->uri.$element->find('a', 0)->href; + $item['uri'] = self::URI.$element->find('a', 0)->href; $item['postid'] = (int)preg_replace("/[^0-9]/",'', $element->getAttribute('id')); $item['timestamp'] = time(); $thumbnailUri = $element->find('img', 0)->src; diff --git a/bridges/Rule34pahealBridge.php b/bridges/Rule34pahealBridge.php index af3608e..54259a3 100644 --- a/bridges/Rule34pahealBridge.php +++ b/bridges/Rule34pahealBridge.php @@ -1,12 +1,12 @@ array( 'name'=>'page', 'type'=>'number' @@ -16,13 +16,13 @@ class Rule34pahealBridge extends BridgeAbstract{ public function collectData(){ - $html = $this->getSimpleHTMLDOM($this->uri.'post/list/'.$tags.'/'.$page) + $html = $this->getSimpleHTMLDOM(self::URI.'post/list/'.$tags.'/'.$page) or $this->returnServerError('Could not request Rule34paheal.'); foreach($html->find('div[class=shm-image-list] div[class=shm-thumb]') as $element) { $item = array(); - $item['uri'] = $this->uri.$element->find('a', 0)->href; + $item['uri'] = self::URI.$element->find('a', 0)->href; $item['postid'] = (int)preg_replace("/[^0-9]/",'', $element->find('img', 0)->getAttribute('id')); $item['timestamp'] = time(); $thumbnailUri = $element->find('img', 0)->src; diff --git a/bridges/SafebooruBridge.php b/bridges/SafebooruBridge.php index 9397552..d27702c 100644 --- a/bridges/SafebooruBridge.php +++ b/bridges/SafebooruBridge.php @@ -1,12 +1,12 @@ array( 'name'=>'page', 'type'=>'number' @@ -16,14 +16,14 @@ class SafebooruBridge extends BridgeAbstract{ public function collectData(){ $html = $this->getSimpleHTMLDOM( - $this->uri.'index.php?page=post&s=list&' + self::URI.'index.php?page=post&s=list&' .'&pid='.($this->getInput('p')?($this->getInput('p') -1)*40:'') .'&tags='.urlencode($this->getInput('t')) ) or $this->returnServerError('Could not request Safebooru.'); foreach($html->find('div[class=content] span') as $element) { $item = array(); - $item['uri'] = $this->uri.$element->find('a', 0)->href; + $item['uri'] = self::URI.$element->find('a', 0)->href; $item['postid'] = (int)preg_replace("/[^0-9]/",'', $element->getAttribute('id')); $item['timestamp'] = time(); $thumbnailUri = $element->find('img', 0)->src; diff --git a/bridges/SakugabooruBridge.php b/bridges/SakugabooruBridge.php index c83eee5..86ffa5d 100644 --- a/bridges/SakugabooruBridge.php +++ b/bridges/SakugabooruBridge.php @@ -1,12 +1,12 @@ array( 'name'=>'page', 'defaultValue'=>1, @@ -17,7 +17,7 @@ class SakugabooruBridge extends BridgeAbstract{ public function collectData(){ $html = $this->getSimpleHTMLDOM( - $this->uri.'post?' + self::URI.'post?' .'&page='.$this->getInput('p') .'&tags='.urlencode($this->getInput('t')) ) or $this->returnServerError('Could not request Sakugabooru.'); @@ -30,7 +30,7 @@ class SakugabooruBridge extends BridgeAbstract{ foreach($data as $datai) { $json = json_decode($datai, TRUE); $item = array(); - $item['uri'] = $this->uri.'/post/show/'.$json['id']; + $item['uri'] = self::URI.'/post/show/'.$json['id']; $item['postid'] = $json['id']; $item['timestamp'] = $json['created_at']; $item['imageUri'] = $json['file_url']; diff --git a/bridges/ScmbBridge.php b/bridges/ScmbBridge.php index 0e0974b..e22b73c 100644 --- a/bridges/ScmbBridge.php +++ b/bridges/ScmbBridge.php @@ -1,19 +1,19 @@ getSimpleHTMLDOM($this->uri) + $html = $this->getSimpleHTMLDOM(self::URI) or $this->returnServerError('Could not request Se Coucher Moins Bete.'); foreach($html->find('article') as $article) { $item = array(); - $item['uri'] = $this->uri.$article->find('p.summary a',0)->href; + $item['uri'] = self::URI.$article->find('p.summary a',0)->href; $item['title'] = $article->find('header h1 a',0)->innertext; $article->find('span.read-more',0)->outertext=''; // remove text "En savoir plus" from anecdote content diff --git a/bridges/ScoopItBridge.php b/bridges/ScoopItBridge.php index db42428..810edb8 100644 --- a/bridges/ScoopItBridge.php +++ b/bridges/ScoopItBridge.php @@ -1,12 +1,12 @@ array( 'name'=>'keyword', 'required'=>true @@ -15,7 +15,7 @@ class ScoopItBridge extends BridgeAbstract{ public function collectData(){ $this->request = $this->getInput('u'); - $link = $this->uri.'search?q=' .urlencode($this->getInput('u')); + $link = self::URI.'search?q=' .urlencode($this->getInput('u')); $html = $this->getSimpleHTMLDOM($link) or $this->returnServerError('Could not request ScoopIt. for : ' . $link); diff --git a/bridges/SensCritiqueBridge.php b/bridges/SensCritiqueBridge.php index a202e0c..32cd952 100644 --- a/bridges/SensCritiqueBridge.php +++ b/bridges/SensCritiqueBridge.php @@ -1,12 +1,12 @@ array( 'name'=>'Movies', 'type'=>'checkbox' @@ -35,9 +35,9 @@ class SensCritiqueBridge extends BridgeAbstract { public function collectData(){ $categories=array(); - foreach($this->parameters[$this->queriedContext] as $category=>$properties){ + foreach(self::PARAMETERS[$this->queriedContext] as $category=>$properties){ if($this->getInput($category)){ - $uri=$this->uri; + $uri=self::URI; switch($category){ case 'm': $uri.='films/cette-semaine'; break; case 's': $uri.='series/actualite'; break; diff --git a/bridges/Sexactu.php b/bridges/Sexactu.php index f6647b1..e78098b 100644 --- a/bridges/Sexactu.php +++ b/bridges/Sexactu.php @@ -1,10 +1,10 @@ find('h2', 0)->find('a',0); $titleTimestamp =$titleDetails->find('h4',0); $item['title'] = $this->correctCase(trim($titleData->innertext)); - $item['uri'] = $this->uri.$titleData->href; + $item['uri'] = self::URI.$titleData->href; // Fugly date parsing due to the fact my DNS-323 doesn't support php intl extension $dateText = $titleTimestamp->innertext; @@ -40,7 +40,7 @@ $replace = array('January', 'February', 'March', 'April', 'May', 'June', 'July', $elementText = $element->find('.text-container', 0); // don't forget to replace images server url with gq one foreach($elementText->find('img') as $image) { - $image->src = $this->uri.$image->src; + $image->src = self::URI.$image->src; } $item['content'] = $elementText->innertext; $this->items[] = $item; @@ -53,7 +53,7 @@ $replace = array('January', 'February', 'March', 'April', 'May', 'June', 'July', } public function getURI(){ - return $this->uri.'/sexactu'; + return self::URI.'/sexactu'; } public function getCacheDuration(){ diff --git a/bridges/ShanaprojectBridge.php b/bridges/ShanaprojectBridge.php index 6c117e3..875e43c 100644 --- a/bridges/ShanaprojectBridge.php +++ b/bridges/ShanaprojectBridge.php @@ -1,9 +1,9 @@ uri.'feed'; + $feedUrl = self::URI.'feed'; $html = $this->getSimpleHTMLDOM($feedUrl) or $this->returnServerError('Could not request Silicon: '.$feedUrl); $limit = 0; diff --git a/bridges/SoundcloudBridge.php b/bridges/SoundcloudBridge.php index 55304e5..ec04064 100644 --- a/bridges/SoundcloudBridge.php +++ b/bridges/SoundcloudBridge.php @@ -1,12 +1,12 @@ array( 'name'=>'username', 'required'=>true @@ -33,10 +33,10 @@ class SoundCloudBridge extends BridgeAbstract{ $item['author'] = $tracks[$i]->user->username .' - '. $tracks[$i]->title; $item['title'] = $tracks[$i]->user->username .' - '. $tracks[$i]->title; $item['content'] = ''; + $item['content'] = $item['title'].'
'; $this->items[] = $item; $num++; diff --git a/bridges/WeLiveSecurityBridge.php b/bridges/WeLiveSecurityBridge.php index 359a2aa..52fb74a 100644 --- a/bridges/WeLiveSecurityBridge.php +++ b/bridges/WeLiveSecurityBridge.php @@ -1,10 +1,10 @@ array( 'name'=>'username/id', 'required'=>true @@ -20,17 +20,17 @@ class WhydBridge extends BridgeAbstract{ if (strlen(preg_replace("/[^0-9a-f]/",'', $this->getInput('u'))) == 24){ // is input the userid ? $html = $this->getSimpleHTMLDOM( - $this->uri.'u/'.preg_replace("/[^0-9a-f]/",'', $this->getInput('u')) + self::URI.'u/'.preg_replace("/[^0-9a-f]/",'', $this->getInput('u')) ) or $this->returnServerError('No results for this query.'); } else { // input may be the username $html = $this->getSimpleHTMLDOM( - $this->uri.'search?q='.urlencode($this->getInput('u')) + self::URI.'search?q='.urlencode($this->getInput('u')) ) or $this->returnServerError('No results for this query.'); for ($j = 0; $j < 5; $j++) { if (strtolower($html->find('div.user', $j)->find('a',0)->plaintext) == strtolower($this->getInput('u'))) { $html = $this->getSimpleHTMLDOM( - $this->uri . $html->find('div.user', $j)->find('a', 0)->getAttribute('href') + self::URI . $html->find('div.user', $j)->find('a', 0)->getAttribute('href') ) or $this->returnServerError('No results for this query'); break; } @@ -44,8 +44,8 @@ class WhydBridge extends BridgeAbstract{ $item['author'] = $track->find('h2', 0)->plaintext; $item['title'] = $track->find('h2', 0)->plaintext; $item['content'] = $track->find('a.thumb',0) . '
' . $track->find('h2', 0)->plaintext; - $item['id'] = $this->uri . $track->find('a.no-ajaxy',0)->getAttribute('href'); - $item['uri'] = $this->uri . $track->find('a.no-ajaxy',0)->getAttribute('href'); + $item['id'] = self::URI . $track->find('a.no-ajaxy',0)->getAttribute('href'); + $item['uri'] = self::URI . $track->find('a.no-ajaxy',0)->getAttribute('href'); $this->items[] = $item; } } diff --git a/bridges/WikipediaBridge.php b/bridges/WikipediaBridge.php index d8c77f1..d6b59a2 100644 --- a/bridges/WikipediaBridge.php +++ b/bridges/WikipediaBridge.php @@ -4,12 +4,12 @@ define('WIKIPEDIA_SUBJECT_TFA', 0); // Today's featured article define('WIKIPEDIA_SUBJECT_DYK', 1); // Did you know... class WikipediaBridge extends HttpCachingBridgeAbstract { - public $maintainer = 'logmanoriginal'; - public $name = 'Wikipedia bridge for many languages'; - public $uri = 'https://www.wikipedia.org/'; - public $description = 'Returns articles for a language of your choice'; + const MAINTAINER = 'logmanoriginal'; + const NAME = 'Wikipedia bridge for many languages'; + const URI = 'https://www.wikipedia.org/'; + const DESCRIPTION = 'Returns articles for a language of your choice'; - public $parameters = array( array( + const PARAMETERS = array( array( 'language'=>array( 'name'=>'Language', 'type'=>'list', diff --git a/bridges/WordPressBridge.php b/bridges/WordPressBridge.php index 48e44fa..03af466 100644 --- a/bridges/WordPressBridge.php +++ b/bridges/WordPressBridge.php @@ -5,12 +5,12 @@ class WordPressBridge extends HttpCachingBridgeAbstract { public $sitename; // Name of the site - public $maintainer = "aledeg"; - public $name = "Wordpress Bridge"; - public $uri = "https://wordpress.org/"; - public $description = "Returns the 3 newest full posts of a Wordpress blog"; + const MAINTAINER = "aledeg"; + const NAME = "Wordpress Bridge"; + const URI = "https://wordpress.org/"; + const DESCRIPTION = "Returns the 3 newest full posts of a Wordpress blog"; - public $parameters = array( array( + const PARAMETERS = array( array( 'url'=>array( 'name'=>'Blog URL', 'required'=>true diff --git a/bridges/WorldOfTanksBridge.php b/bridges/WorldOfTanksBridge.php index 8b0ec83..b723526 100644 --- a/bridges/WorldOfTanksBridge.php +++ b/bridges/WorldOfTanksBridge.php @@ -1,12 +1,12 @@ array( // TODO: should be a list 'name'=>'nom de la catégorie' @@ -30,7 +30,7 @@ class WorldOfTanksBridge extends HttpCachingBridgeAbstract{ function getURI(){ $lang = $this->getInput('lang'); - $uri = $this->uri.$lang.'/news/'; + $uri = self::URI.$lang.'/news/'; if(!empty($this->getInput('category'))) { $uri .= 'pc-browser/'.$this->getInput('category')."/"; } @@ -38,7 +38,7 @@ class WorldOfTanksBridge extends HttpCachingBridgeAbstract{ } public function getName(){ - return $this->title?:$this->name; + return $this->title?:self::NAME; } public function collectData(){ @@ -54,12 +54,12 @@ class WorldOfTanksBridge extends HttpCachingBridgeAbstract{ private function parseLine($infoLink) { $item = array(); - $item['uri'] = $this->uri.$infoLink->href; + $item['uri'] = self::URI.$infoLink->href; // now load that uri from cache $this->debugMessage("loading page ".$item['uri']); $articlePage = $this->get_cached($item['uri']); $content = $articlePage->find('.l-content', 0); - HTMLSanitizer::defaultImageSrcTo($content, $this->uri); + HTMLSanitizer::defaultImageSrcTo($content, self::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"); diff --git a/bridges/XbooruBridge.php b/bridges/XbooruBridge.php index 3ac643f..a909b06 100644 --- a/bridges/XbooruBridge.php +++ b/bridges/XbooruBridge.php @@ -1,12 +1,12 @@ array( 'name'=>'page', 'type'=>'number' @@ -16,7 +16,7 @@ class XbooruBridge extends BridgeAbstract{ public function collectData(){ $html = $this->getSimpleHTMLDOM( - $this->uri.'index.php?page=post&s=list&' + self::URI.'index.php?page=post&s=list&' .'&pid='.($this->getInput('p')?($this->getInput('p') -1)*50:'') .'&tags='.urlencode($this->getInput('t')) ) or $this->returnServerError('Could not request Xbooru.'); @@ -24,7 +24,7 @@ class XbooruBridge extends BridgeAbstract{ foreach($html->find('div[class=content] span') as $element) { $item = array(); - $item['uri'] = $this->uri.$element->find('a', 0)->href; + $item['uri'] = self::URI.$element->find('a', 0)->href; $item['postid'] = (int)preg_replace("/[^0-9]/",'', $element->getAttribute('id')); $item['timestamp'] = time(); $thumbnailUri = $element->find('img', 0)->src; diff --git a/bridges/YandereBridge.php b/bridges/YandereBridge.php index a26f228..44a6ca1 100644 --- a/bridges/YandereBridge.php +++ b/bridges/YandereBridge.php @@ -1,12 +1,12 @@ array( 'name'=>'page', 'type'=>'number', @@ -17,7 +17,7 @@ class YandereBridge extends BridgeAbstract{ public function collectData(){ $html = $this->getSimpleHTMLDOM( - $this->uri.'post?' + self::URI.'post?' .'&page='.$this->getInput('p') .'&tags='.urlencode($this->getInput('t')) ) or $this->returnServerError('Could not request Yander.'); @@ -30,7 +30,7 @@ class YandereBridge extends BridgeAbstract{ foreach($data as $datai) { $json = json_decode($datai, TRUE); $item = array(); - $item['uri'] = $this->uri.'post/show/'.$json['id']; + $item['uri'] = self::URI.'post/show/'.$json['id']; $item['postid'] = $json['id']; $item['timestamp'] = $json['created_at']; $item['imageUri'] = $json['file_url']; diff --git a/bridges/YoutubeBridge.php b/bridges/YoutubeBridge.php index 53dd0c5..6c258f4 100644 --- a/bridges/YoutubeBridge.php +++ b/bridges/YoutubeBridge.php @@ -8,12 +8,12 @@ */ class YoutubeBridge extends BridgeAbstract { - public $name = 'YouTube Bridge'; - public $uri = 'https://www.youtube.com/'; - public $description = 'Returns the 10 newest videos by username/channel/playlist or search'; - public $maintainer = 'mitsukarenai'; + const NAME = 'YouTube Bridge'; + const URI = 'https://www.youtube.com/'; + const DESCRIPTION = 'Returns the 10 newest videos by username/channel/playlist or search'; + const MAINTAINER = 'mitsukarenai'; - public $parameters = array( + const PARAMETERS = array( 'By username' => array( 'u'=>array( 'name'=>'username', @@ -48,7 +48,7 @@ class YoutubeBridge extends BridgeAbstract { ); private function ytBridgeQueryVideoInfo($vid, &$author, &$desc, &$time) { - $html = $this->getSimpleHTMLDOM($this->uri."watch?v=$vid"); + $html = $this->getSimpleHTMLDOM(self::URI."watch?v=$vid"); $author = $html->innertext; $author = substr($author, strpos($author, '"author=') + 8); $author = substr($author, 0, strpos($author, '\u0026')); @@ -62,8 +62,8 @@ class YoutubeBridge extends BridgeAbstract { $item['title'] = $title; $item['author'] = $author; $item['timestamp'] = $time; - $item['uri'] = $this->uri.'watch?v='.$vid; - $thumbnailUri = str_replace('/www.', '/img.', $this->uri).'vi/'.$vid.'/0.jpg'; + $item['uri'] = self::URI.'watch?v='.$vid; + $thumbnailUri = str_replace('/www.', '/img.', self::URI).'vi/'.$vid.'/0.jpg'; $item['content'] = '
'.$desc; $this->items[] = $item; } @@ -110,12 +110,12 @@ class YoutubeBridge extends BridgeAbstract { if ($this->getInput('u')) { /* User and Channel modes */ $this->request = $this->getInput('u'); - $url_feed = $this->uri.'feeds/videos.xml?user='.urlencode($this->request); - $url_listing = $this->uri.'user/'.urlencode($this->request).'/videos'; + $url_feed = self::URI.'feeds/videos.xml?user='.urlencode($this->request); + $url_listing = self::URI.'user/'.urlencode($this->request).'/videos'; } else if ($this->getInput('c')) { $this->request = $this->getInput('c'); - $url_feed = $this->uri.'feeds/videos.xml?channel_id='.urlencode($this->request); - $url_listing = $this->uri.'channel/'.urlencode($this->request).'/videos'; + $url_feed = self::URI.'feeds/videos.xml?channel_id='.urlencode($this->request); + $url_listing = self::URI.'channel/'.urlencode($this->request).'/videos'; } if (!empty($url_feed) && !empty($url_listing)) { if ($xml = $this->getSimpleHTMLDOM($url_feed)) { @@ -127,7 +127,7 @@ class YoutubeBridge extends BridgeAbstract { else if ($this->getInput('p')) { /* playlist mode */ $this->request = $this->getInput('p'); - $url_listing = $this->uri.'playlist?list='.urlencode($this->request); + $url_listing = self::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); @@ -135,7 +135,7 @@ class YoutubeBridge extends BridgeAbstract { else if ($this->getInput('s')) { /* search mode */ $this->request = $this->getInput('s'); $page = 1; if ($this->getInput('pa')) $page = (int)preg_replace("/[^0-9]/",'', $this->getInput('pa')); - $url_listing = $this->uri.'results?search_query='.urlencode($this->request).'&page='.$page.'&filters=video&search_sort=video_date_uploaded'; + $url_listing = self::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'); $this->request = 'Search: '.str_replace(' - YouTube', '', $html->find('title', 0)->plaintext); diff --git a/bridges/ZDNetBridge.php b/bridges/ZDNetBridge.php index 03f63ba..af0eb87 100644 --- a/bridges/ZDNetBridge.php +++ b/bridges/ZDNetBridge.php @@ -1,13 +1,13 @@ array( 'name'=>'Feed', 'type'=>'list', @@ -207,7 +207,7 @@ class ZDNetBridge extends BridgeAbstract { return $string; } - $baseUri = $this->uri; + $baseUri = self::URI; $feed = $this->getInput('feed'); if (strpos($feed, 'downloads!') !== false) { $feed = str_replace('downloads!', '', $feed); diff --git a/bridges/ZatazBridge.php b/bridges/ZatazBridge.php index e1a87f5..b805d60 100644 --- a/bridges/ZatazBridge.php +++ b/bridges/ZatazBridge.php @@ -1,13 +1,13 @@ getSimpleHTMLDOM($this->uri) or $this->returnServerError('Could not request ' . $this->uri); + $html = $this->getSimpleHTMLDOM(self::URI) or $this->returnServerError('Could not request ' . self::URI); $recent_posts = $html->find('#recent-posts-3', 0)->find('ul', 0)->find('li'); foreach ($recent_posts as $article) { diff --git a/bridges/ZoneTelechargementBridge.php b/bridges/ZoneTelechargementBridge.php index 4a0bf03..86b3ded 100644 --- a/bridges/ZoneTelechargementBridge.php +++ b/bridges/ZoneTelechargementBridge.php @@ -1,12 +1,12 @@ You may specify a category found in RSS URLs, else main feed is selected.'; + const MAINTAINER = 'ORelio'; + const NAME = 'Zone Telechargement Bridge'; + const URI = 'https://www.zone-telechargement.com/'; + const DESCRIPTION = 'RSS proxy returning the newest releases.
You may specify a category found in RSS URLs, else main feed is selected.'; - public $parameters = array( array( + const PARAMETERS = array( array( 'category'=>array('name'=>'Category') ));