1
0
Fork 0
forked from blallo/rss-bridge

[phpcs] Add missing rules

- Do not add spaces after opening or before closing parenthesis

  // Wrong
  if( !is_null($var) ) {
    ...
  }

  // Right
  if(!is_null($var)) {
    ...
  }

- Add space after closing parenthesis

  // Wrong
  if(true){
    ...
  }

  // Right
  if(true) {
    ...
  }

- Add body into new line
- Close body in new line

  // Wrong
  if(true) { ... }

  // Right
  if(true) {
    ...
  }

Notice: Spaces after keywords are not detected:

  // Wrong (not detected)
  // -> space after 'if' and missing space after 'else'
  if (true) {
    ...
  } else{
    ...
  }

  // Right
  if(true) {
    ...
  } else {
    ...
  }
This commit is contained in:
logmanoriginal 2017-07-29 19:28:00 +02:00
parent 38b56bf23a
commit a4b9611e66
128 changed files with 692 additions and 694 deletions

View file

@ -13,8 +13,7 @@ class ABCTabsBridge extends BridgeAbstract {
$table = $html->find('table#myTable', 0)->children(1); $table = $html->find('table#myTable', 0)->children(1);
foreach ($table->find('tr') as $tab) foreach ($table->find('tr') as $tab) {
{
$item = array(); $item = array();
$item['author'] = $tab->find('td', 1)->plaintext $item['author'] = $tab->find('td', 1)->plaintext
. ' - ' . ' - '

View file

@ -22,9 +22,9 @@ class AllocineFRBridge extends BridgeAbstract {
)); ));
public function getURI(){ public function getURI(){
if(!is_null($this->getInput('category'))){ if(!is_null($this->getInput('category'))) {
switch($this->getInput('category')){ switch($this->getInput('category')) {
case 'faux-raccord': case 'faux-raccord':
$uri = static::URI . 'video/programme-12284/saison-29841/'; $uri = static::URI . 'video/programme-12284/saison-29841/';
break; break;
@ -43,7 +43,7 @@ class AllocineFRBridge extends BridgeAbstract {
} }
public function getName(){ public function getName(){
if(!is_null($this->getInput('category'))){ if(!is_null($this->getInput('category'))) {
return self::NAME . ' : ' return self::NAME . ' : '
.array_search( .array_search(
$this->getInput('category'), $this->getInput('category'),
@ -64,15 +64,14 @@ class AllocineFRBridge extends BridgeAbstract {
self::PARAMETERS[$this->queriedContext]['category']['values'] self::PARAMETERS[$this->queriedContext]['category']['values']
); );
foreach($html->find('figure.media-meta-fig') as $element){ foreach($html->find('figure.media-meta-fig') as $element) {
$item = array(); $item = array();
$title = $element->find('div.titlebar h3.title a', 0); $title = $element->find('div.titlebar h3.title a', 0);
$content = trim($element->innertext); $content = trim($element->innertext);
$figCaption = strpos($content, $category); $figCaption = strpos($content, $category);
if($figCaption !== false) if($figCaption !== false) {
{
$content = str_replace('src="/', 'src="' . static::URI, $content); $content = str_replace('src="/', 'src="' . static::URI, $content);
$content = str_replace('href="/', 'href="' . static::URI, $content); $content = str_replace('href="/', 'href="' . static::URI, $content);
$content = str_replace('src=\'/', 'src=\'' . static::URI, $content); $content = str_replace('src=\'/', 'src=\'' . static::URI, $content);

View file

@ -51,7 +51,7 @@ class AmazonBridge extends BridgeAbstract {
)); ));
public function getName(){ public function getName(){
if(!is_null($this->getInput('tld')) && !is_null($this->getInput('q'))){ if(!is_null($this->getInput('tld')) && !is_null($this->getInput('q'))) {
return 'Amazon.'.$this->getInput('tld').': '.$this->getInput('q'); return 'Amazon.'.$this->getInput('tld').': '.$this->getInput('q');
} }

View file

@ -120,7 +120,7 @@ class AnimeUltimeBridge extends BridgeAbstract {
} }
public function getName() { public function getName() {
if(!is_null($this->getInput('type'))){ if(!is_null($this->getInput('type'))) {
$typeFilter = array_search( $typeFilter = array_search(
$this->getInput('type'), $this->getInput('type'),
self::PARAMETERS[$this->queriedContext]['type']['values'] self::PARAMETERS[$this->queriedContext]['type']['values']

View file

@ -44,7 +44,7 @@ class Arte7Bridge extends BridgeAbstract {
); );
public function collectData(){ public function collectData(){
switch($this->queriedContext){ switch($this->queriedContext) {
case 'Catégorie (Français)': case 'Catégorie (Français)':
$category = $this->getInput('catfr'); $category = $this->getInput('catfr');
$lang = 'fr'; $lang = 'fr';
@ -58,7 +58,7 @@ class Arte7Bridge extends BridgeAbstract {
$url = self::URI . 'guide/' . $lang . '/plus7/' . $category; $url = self::URI . 'guide/' . $lang . '/plus7/' . $category;
$input = getContents($url) or die('Could not request ARTE.'); $input = getContents($url) or die('Could not request ARTE.');
if(strpos($input, 'categoryVideoSet') !== false){ if(strpos($input, 'categoryVideoSet') !== false) {
$input = explode('categoryVideoSet="', $input); $input = explode('categoryVideoSet="', $input);
$input = explode('}}', $input[1]); $input = explode('}}', $input[1]);
$input = $input[0] . '}}'; $input = $input[0] . '}}';

View file

@ -19,7 +19,7 @@ class AskfmBridge extends BridgeAbstract {
$html = getSimpleHTMLDOM($this->getURI()) $html = getSimpleHTMLDOM($this->getURI())
or returnServerError('Requested username can\'t be found.'); or returnServerError('Requested username can\'t be found.');
foreach($html->find('div.streamItem-answer') as $element){ foreach($html->find('div.streamItem-answer') as $element) {
$item = array(); $item = array();
$item['uri'] = self::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); $question = trim($element->find('h1.streamItemContent-question', 0)->innertext);
@ -38,7 +38,7 @@ class AskfmBridge extends BridgeAbstract {
// This probably should be cleaned up, especially for YouTube embeds // This probably should be cleaned up, especially for YouTube embeds
$visual = $element->find('div.streamItemContent-visual', 0)->innertext; $visual = $element->find('div.streamItemContent-visual', 0)->innertext;
//Fix tracking links, also doesn't work //Fix tracking links, also doesn't work
foreach($element->find('a') as $link){ foreach($element->find('a') as $link) {
if(strpos($link->href, 'l.ask.fm') !== false) { if(strpos($link->href, 'l.ask.fm') !== false) {
// Too slow // Too slow
@ -57,7 +57,7 @@ class AskfmBridge extends BridgeAbstract {
} }
public function getName(){ public function getName(){
if(!is_null($this->getInput('u'))){ if(!is_null($this->getInput('u'))) {
return self::NAME . ' : ' . $this->getInput('u'); return self::NAME . ' : ' . $this->getInput('u');
} }
@ -65,7 +65,7 @@ class AskfmBridge extends BridgeAbstract {
} }
public function getURI(){ public function getURI(){
if(!is_null($this->getInput('u'))){ if(!is_null($this->getInput('u'))) {
return self::URI . urlencode($this->getInput('u')) . '/answers/more?page=0'; return self::URI . urlencode($this->getInput('u')) . '/answers/more?page=0';
} }

View file

@ -18,7 +18,7 @@ class BandcampBridge extends BridgeAbstract {
$html = getSimpleHTMLDOM($this->getURI()) $html = getSimpleHTMLDOM($this->getURI())
or returnServerError('No results for this query.'); or returnServerError('No results for this query.');
foreach($html->find('li.item') as $release){ foreach($html->find('li.item') as $release) {
$script = $release->find('div.art', 0)->getAttribute('onclick'); $script = $release->find('div.art', 0)->getAttribute('onclick');
$uri = ltrim($script, "return 'url("); $uri = ltrim($script, "return 'url(");
$uri = rtrim($uri, "')"); $uri = rtrim($uri, "')");
@ -46,7 +46,7 @@ class BandcampBridge extends BridgeAbstract {
} }
public function getURI(){ public function getURI(){
if(!is_null($this->getInput('tag'))){ if(!is_null($this->getInput('tag'))) {
return self::URI . 'tag/' . urlencode($this->getInput('tag')) . '?sort_field=date'; return self::URI . 'tag/' . urlencode($this->getInput('tag')) . '?sort_field=date';
} }
@ -54,7 +54,7 @@ class BandcampBridge extends BridgeAbstract {
} }
public function getName(){ public function getName(){
if(!is_null($this->getInput('tag'))){ if(!is_null($this->getInput('tag'))) {
return $this->getInput('tag') . ' - Bandcamp Tag'; return $this->getInput('tag') . ' - Bandcamp Tag';
} }

View file

@ -19,8 +19,8 @@ class BastaBridge extends BridgeAbstract {
$limit = 0; $limit = 0;
foreach($html->find('item') as $element){ foreach($html->find('item') as $element) {
if($limit < 10){ if($limit < 10) {
$item = array(); $item = array();
$item['title'] = $element->find('title', 0)->innertext; $item['title'] = $element->find('title', 0)->innertext;
$item['uri'] = $element->find('guid', 0)->plaintext; $item['uri'] = $element->find('guid', 0)->plaintext;

View file

@ -11,11 +11,11 @@ class BlaguesDeMerdeBridge extends BridgeAbstract {
$html = getSimpleHTMLDOM(self::URI) $html = getSimpleHTMLDOM(self::URI)
or returnServerError('Could not request BDM.'); or returnServerError('Could not request BDM.');
foreach($html->find('article.joke_contener') as $element){ foreach($html->find('article.joke_contener') as $element) {
$item = array(); $item = array();
$temp = $element->find('a'); $temp = $element->find('a');
if(isset($temp[2])){ if(isset($temp[2])) {
$item['content'] = trim($element->find('div.joke_text_contener', 0)->innertext); $item['content'] = trim($element->find('div.joke_text_contener', 0)->innertext);
$uri = $temp[2]->href; $uri = $temp[2]->href;
$item['uri'] = $uri; $item['uri'] = $uri;

View file

@ -28,7 +28,7 @@ class BooruprojectBridge extends GelbooruBridge {
const PIDBYPAGE = 20; const PIDBYPAGE = 20;
public function getURI(){ public function getURI(){
if(!is_null($this->getInput('i'))){ if(!is_null($this->getInput('i'))) {
return 'http://' . $this->getInput('i') . '.booru.org/'; return 'http://' . $this->getInput('i') . '.booru.org/';
} }
@ -36,7 +36,7 @@ class BooruprojectBridge extends GelbooruBridge {
} }
public function getName(){ public function getName(){
if(!is_null($this->getInput('i'))){ if(!is_null($this->getInput('i'))) {
return static::NAME . ' ' . $this->getInput('i'); return static::NAME . ' ' . $this->getInput('i');
} }

View file

@ -25,7 +25,7 @@ class CADBridge extends FeedExpander {
$htmlpart = explode("/", $url); $htmlpart = explode("/", $url);
switch ($htmlpart[3]){ switch ($htmlpart[3]) {
case 'cad': case 'cad':
preg_match_all("/http:\/\/cdn2\.cad-comic\.com\/comics\/cad-\S*png/", $html3, $url2); preg_match_all("/http:\/\/cdn2\.cad-comic\.com\/comics\/cad-\S*png/", $html3, $url2);
break; break;

View file

@ -17,7 +17,7 @@ topic found in some section URLs, else all topics are selected.';
public function collectData(){ public function collectData(){
function extractFromDelimiters($string, $start, $end){ function extractFromDelimiters($string, $start, $end){
if(strpos($string, $start) !== false){ if(strpos($string, $start) !== false) {
$section_retrieved = substr($string, strpos($string, $start) + strlen($start)); $section_retrieved = substr($string, strpos($string, $start) + strlen($start));
$section_retrieved = substr($section_retrieved, 0, strpos($section_retrieved, $end)); $section_retrieved = substr($section_retrieved, 0, strpos($section_retrieved, $end));
return $section_retrieved; return $section_retrieved;
@ -27,7 +27,7 @@ topic found in some section URLs, else all topics are selected.';
} }
function stripWithDelimiters($string, $start, $end){ function stripWithDelimiters($string, $start, $end){
while(strpos($string, $start) !== false){ while(strpos($string, $start) !== false) {
$section_to_remove = substr($string, strpos($string, $start)); $section_to_remove = substr($string, strpos($string, $start));
$section_to_remove = substr($section_to_remove, 0, strpos($section_to_remove, $end) + strlen($end)); $section_to_remove = substr($section_to_remove, 0, strpos($section_to_remove, $end) + strlen($end));
$string = str_replace($section_to_remove, '', $string); $string = str_replace($section_to_remove, '', $string);
@ -49,14 +49,14 @@ topic found in some section URLs, else all topics are selected.';
$html = getSimpleHTMLDOM($pageUrl) or returnServerError('Could not request CNET: ' . $pageUrl); $html = getSimpleHTMLDOM($pageUrl) or returnServerError('Could not request CNET: ' . $pageUrl);
$limit = 0; $limit = 0;
foreach($html->find('div.assetBody') as $element){ foreach($html->find('div.assetBody') as $element) {
if($limit < 8){ if($limit < 8) {
$article_title = trim($element->find('h2', 0)->plaintext); $article_title = trim($element->find('h2', 0)->plaintext);
$article_uri = self::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_timestamp = strtotime($element->find('time.assetTime', 0)->plaintext);
$article_author = trim($element->find('a[rel=author]', 0)->plaintext); $article_author = trim($element->find('a[rel=author]', 0)->plaintext);
if(!empty($article_title) && !empty($article_uri) && strpos($article_uri, '/news/') !== false){ if(!empty($article_title) && !empty($article_uri) && strpos($article_uri, '/news/') !== false) {
$article_html = getSimpleHTMLDOM($article_uri) $article_html = getSimpleHTMLDOM($article_uri)
or returnServerError('Could not request CNET: ' . $article_uri); or returnServerError('Could not request CNET: ' . $article_uri);
$article_content = trim( $article_content = trim(
@ -83,7 +83,7 @@ topic found in some section URLs, else all topics are selected.';
} }
public function getName(){ public function getName(){
if(!is_null($this->getInput('topic'))){ if(!is_null($this->getInput('topic'))) {
$topic = $this->getInput('topic'); $topic = $this->getInput('topic');
return 'CNET News Bridge' . (empty($topic) ? '' : ' - ' . $topic); return 'CNET News Bridge' . (empty($topic) ? '' : ' - ' . $topic);
} }

View file

@ -57,7 +57,7 @@ class CastorusBridge extends BridgeAbstract {
if(!$nodes) if(!$nodes)
returnServerError('Cannot find nodes!'); returnServerError('Cannot find nodes!');
foreach($nodes as $node){ foreach($nodes as $node) {
$node->outertext = ''; $node->outertext = '';
} }
@ -88,7 +88,7 @@ class CastorusBridge extends BridgeAbstract {
if(!$activities) if(!$activities)
returnServerError('Failed to find activities!'); returnServerError('Failed to find activities!');
foreach($activities as $activity){ foreach($activities as $activity) {
$item = array(); $item = array();
$item['title'] = $this->extractActivityTitle($activity); $item['title'] = $this->extractActivityTitle($activity);
@ -103,12 +103,12 @@ class CastorusBridge extends BridgeAbstract {
. '</p>'; . '</p>';
if(isset($zip_filter) if(isset($zip_filter)
&& !(substr($item['title'], 0, strlen($zip_filter)) === $zip_filter)){ && !(substr($item['title'], 0, strlen($zip_filter)) === $zip_filter)) {
continue; // Skip this item continue; // Skip this item
} }
if(isset($city_filter) if(isset($city_filter)
&& !(substr($item['title'], strpos($item['title'], ' ') + 1, strlen($city_filter)) === $city_filter)){ && !(substr($item['title'], strpos($item['title'], ' ') + 1, strlen($city_filter)) === $city_filter)) {
continue; // Skip this item continue; // Skip this item
} }

View file

@ -37,7 +37,7 @@ class CollegeDeFranceBridge extends BridgeAbstract {
. 'components/search-audiovideo.jsp?fulltext=&siteid=1156951719600&lang=FR&type=all') . 'components/search-audiovideo.jsp?fulltext=&siteid=1156951719600&lang=FR&type=all')
or returnServerError('Could not request CollegeDeFrance.'); or returnServerError('Could not request CollegeDeFrance.');
foreach($html->find('a[data-target]') as $element){ foreach($html->find('a[data-target]') as $element) {
$item = array(); $item = array();
$item['title'] = $element->find('.title', 0)->plaintext; $item['title'] = $element->find('.title', 0)->plaintext;
@ -60,7 +60,7 @@ class CollegeDeFranceBridge extends BridgeAbstract {
$timezone $timezone
); );
if(!$d){ if(!$d) {
$d = DateTime::createFromFormat( $d = DateTime::createFromFormat(
'!d m Y', '!d m Y',
trim(str_replace( trim(str_replace(

View file

@ -13,16 +13,16 @@ class CopieDoubleBridge extends BridgeAbstract {
$table = $html->find('table table', 2); $table = $html->find('table table', 2);
foreach($table->find('tr') as $element){ foreach($table->find('tr') as $element) {
$td = $element->find('td', 0); $td = $element->find('td', 0);
if($td->class === 'couleur_1'){ if($td->class === 'couleur_1') {
$item = array(); $item = array();
$title = $td->innertext; $title = $td->innertext;
$pos = strpos($title, '<a'); $pos = strpos($title, '<a');
$title = substr($title, 0, $pos); $title = substr($title, 0, $pos);
$item['title'] = $title; $item['title'] = $title;
} elseif(strpos($element->innertext, '/images/suivant.gif') === false){ } elseif(strpos($element->innertext, '/images/suivant.gif') === false) {
$a = $element->find('a', 0); $a = $element->find('a', 0);
$item['uri'] = self::URI . $a->href; $item['uri'] = self::URI . $a->href;
$content = str_replace('src="/', 'src="/' . self::URI, $element->find("td", 0)->innertext); $content = str_replace('src="/', 'src="/' . self::URI, $element->find("td", 0)->innertext);

View file

@ -14,12 +14,12 @@ class CourrierInternationalBridge extends BridgeAbstract {
$element = $html->find("article"); $element = $html->find("article");
$article_count = 1; $article_count = 1;
foreach($element as $article){ foreach($element as $article) {
$item = array(); $item = array();
$item['uri'] = $article->parent->getAttribute('href'); $item['uri'] = $article->parent->getAttribute('href');
if(strpos($item['uri'], 'http') === false){ if(strpos($item['uri'], 'http') === false) {
$item['uri'] = self::URI . $item['uri']; $item['uri'] = self::URI . $item['uri'];
} }
@ -27,7 +27,7 @@ class CourrierInternationalBridge extends BridgeAbstract {
$content = $page->find('.article-text', 0); $content = $page->find('.article-text', 0);
if(!$content){ if(!$content) {
$content = $page->find('.depeche-text', 0); $content = $page->find('.depeche-text', 0);
} }

View file

@ -20,9 +20,9 @@ class CpasbienBridge extends BridgeAbstract {
$html = getSimpleHTMLDOM(self::URI . '/recherche/' . urlencode($request) . '.html') $html = getSimpleHTMLDOM(self::URI . '/recherche/' . urlencode($request) . '.html')
or returnServerError('No results for this query.'); or returnServerError('No results for this query.');
foreach($html->find('#gauche', 0)->find('div') as $episode){ foreach($html->find('#gauche', 0)->find('div') as $episode) {
if($episode->getAttribute('class') == 'ligne0' if($episode->getAttribute('class') == 'ligne0'
|| $episode->getAttribute('class') == 'ligne1'){ || $episode->getAttribute('class') == 'ligne1') {
$urlepisode = $episode->find('a', 0)->getAttribute('href'); $urlepisode = $episode->find('a', 0)->getAttribute('href');
$htmlepisode = getSimpleHTMLDOMCached($urlepisode, 86400 * 366 * 30); $htmlepisode = getSimpleHTMLDOMCached($urlepisode, 86400 * 366 * 30);
@ -33,11 +33,11 @@ class CpasbienBridge extends BridgeAbstract {
$item['pubdate'] = $this->getCachedDate($urlepisode); $item['pubdate'] = $this->getCachedDate($urlepisode);
$textefiche = $htmlepisode->find('#textefiche', 0)->find('p', 1); $textefiche = $htmlepisode->find('#textefiche', 0)->find('p', 1);
if(isset($textefiche)){ if(isset($textefiche)) {
$item['content'] = $textefiche->text(); $item['content'] = $textefiche->text();
} else { } else {
$p = $htmlepisode->find('#textefiche', 0)->find('p'); $p = $htmlepisode->find('#textefiche', 0)->find('p');
if(!empty($p)){ if(!empty($p)) {
$item['content'] = $htmlepisode->find('#textefiche', 0)->find('p', 0)->text(); $item['content'] = $htmlepisode->find('#textefiche', 0)->find('p', 0)->text();
} }
} }
@ -50,7 +50,7 @@ class CpasbienBridge extends BridgeAbstract {
} }
public function getName(){ public function getName(){
if(!is_null($this->getInput('q'))){ if(!is_null($this->getInput('q'))) {
return $this->getInput('q') . ' : ' . self::NAME; return $this->getInput('q') . ' : ' . self::NAME;
} }

View file

@ -23,12 +23,12 @@ class CryptomeBridge extends BridgeAbstract {
$number = $this->getInput('n'); $number = $this->getInput('n');
/* number of documents */ /* number of documents */
if(!empty($number)){ if(!empty($number)) {
$num = min($number, 20); $num = min($number, 20);
} }
foreach($html->find('pre') as $element){ foreach($html->find('pre') as $element) {
for($i = 0; $i < $num; ++$i){ for($i = 0; $i < $num; ++$i) {
$item = array(); $item = array();
$item['uri'] = self::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['title'] = substr($element->find('b', $i)->plaintext, 22);

View file

@ -35,7 +35,7 @@ class DailymotionBridge extends BridgeAbstract {
protected function getMetadata($id){ protected function getMetadata($id){
$metadata = array(); $metadata = array();
$html2 = getSimpleHTMLDOM(self::URI . 'video/' . $id); $html2 = getSimpleHTMLDOM(self::URI . 'video/' . $id);
if(!$html2){ if(!$html2) {
return $metadata; return $metadata;
} }
@ -56,12 +56,12 @@ class DailymotionBridge extends BridgeAbstract {
$html = getSimpleHTMLDOM($this->getURI()) $html = getSimpleHTMLDOM($this->getURI())
or returnServerError('Could not request Dailymotion.'); or returnServerError('Could not request Dailymotion.');
foreach($html->find('div.media a.preview_link') as $element){ foreach($html->find('div.media a.preview_link') as $element) {
if($count < $limit){ if($count < $limit) {
$item = array(); $item = array();
$item['id'] = str_replace('/video/', '', strtok($element->href, '_')); $item['id'] = str_replace('/video/', '', strtok($element->href, '_'));
$metadata = $this->getMetadata($item['id']); $metadata = $this->getMetadata($item['id']);
if(empty($metadata)){ if(empty($metadata)) {
continue; continue;
} }
$item['uri'] = $metadata['uri']; $item['uri'] = $metadata['uri'];
@ -85,7 +85,7 @@ class DailymotionBridge extends BridgeAbstract {
} }
public function getName(){ public function getName(){
switch($this->queriedContext){ switch($this->queriedContext) {
case 'By username': case 'By username':
$specific = $this->getInput('u'); $specific = $this->getInput('u');
break; break;
@ -103,7 +103,7 @@ class DailymotionBridge extends BridgeAbstract {
public function getURI(){ public function getURI(){
$uri = self::URI; $uri = self::URI;
switch($this->queriedContext){ switch($this->queriedContext) {
case 'By username': case 'By username':
$uri .= 'user/' . urlencode($this->getInput('u')) . '/1'; $uri .= 'user/' . urlencode($this->getInput('u')) . '/1';
break; break;
@ -112,7 +112,7 @@ class DailymotionBridge extends BridgeAbstract {
break; break;
case 'From search results': case 'From search results':
$uri .= 'search/' . urlencode($this->getInput('s')); $uri .= 'search/' . urlencode($this->getInput('s'));
if($this->getInput('pa')){ if($this->getInput('pa')) {
$uri .= '/' . $this->getInput('pa'); $uri .= '/' . $this->getInput('pa');
} }
break; break;

View file

@ -12,7 +12,7 @@ class DansTonChatBridge extends BridgeAbstract {
$html = getSimpleHTMLDOM(self::URI . 'latest.html') $html = getSimpleHTMLDOM(self::URI . 'latest.html')
or returnServerError('Could not request DansTonChat.'); or returnServerError('Could not request DansTonChat.');
foreach($html->find('div.item') as $element){ foreach($html->find('div.item') as $element) {
$item = array(); $item = array();
$item['uri'] = $element->find('a', 0)->href; $item['uri'] = $element->find('a', 0)->href;
$item['title'] = 'DansTonChat ' . $element->find('a', 1)->plaintext; $item['title'] = 'DansTonChat ' . $element->find('a', 1)->plaintext;

View file

@ -34,7 +34,7 @@ class DauphineLibereBridge extends FeedExpander {
public function collectData(){ public function collectData(){
$url = self::URI . 'rss'; $url = self::URI . 'rss';
if(empty($this->getInput('u'))){ if(empty($this->getInput('u'))) {
$url = self::URI . $this->getInput('u') . '/rss'; $url = self::URI . $this->getInput('u') . '/rss';
} }

View file

@ -12,7 +12,7 @@ class DilbertBridge extends BridgeAbstract {
$html = getSimpleHTMLDOM($this->getURI()) $html = getSimpleHTMLDOM($this->getURI())
or returnServerError('Could not request Dilbert: ' . $this->getURI()); or returnServerError('Could not request Dilbert: ' . $this->getURI());
foreach($html->find('section.comic-item') as $element){ foreach($html->find('section.comic-item') as $element) {
$img = $element->find('img', 0); $img = $element->find('img', 0);
$link = $element->find('a', 0); $link = $element->find('a', 0);

View file

@ -31,7 +31,7 @@ class DuckDuckGoBridge extends BridgeAbstract {
$html = getSimpleHTMLDOM(self::URI . 'html/?kd=-1&q=' . $this->getInput('u') . $this->getInput('sort')) $html = getSimpleHTMLDOM(self::URI . 'html/?kd=-1&q=' . $this->getInput('u') . $this->getInput('sort'))
or returnServerError('Could not request DuckDuckGo.'); or returnServerError('Could not request DuckDuckGo.');
foreach($html->find('div.results_links') as $element){ foreach($html->find('div.results_links') as $element) {
$item = array(); $item = array();
$item['uri'] = $element->find('a', 0)->href; $item['uri'] = $element->find('a', 0)->href;
$item['title'] = $element->find('a', 1)->innertext; $item['title'] = $element->find('a', 1)->innertext;

View file

@ -23,7 +23,7 @@ on EZTV. Get showID from URLs in https://eztv.ch/shows/showID/show-full-name.';
$relativeDays = 0; $relativeDays = 0;
$relativeHours = 0; $relativeHours = 0;
foreach(explode(" ", $relativeReleaseTime) as $relativeTimeElement){ foreach(explode(" ", $relativeReleaseTime) as $relativeTimeElement) {
if(substr($relativeTimeElement, -1) == "d") $relativeDays = substr($relativeTimeElement, 0, -1); if(substr($relativeTimeElement, -1) == "d") $relativeDays = substr($relativeTimeElement, 0, -1);
if(substr($relativeTimeElement, -1) == "h") $relativeHours = substr($relativeTimeElement, 0, -1); if(substr($relativeTimeElement, -1) == "h") $relativeHours = substr($relativeTimeElement, 0, -1);
} }
@ -32,14 +32,14 @@ on EZTV. Get showID from URLs in https://eztv.ch/shows/showID/show-full-name.';
// Loop on show ids // Loop on show ids
$showList = explode(",", $this->getInput('i')); $showList = explode(",", $this->getInput('i'));
foreach($showList as $showID){ foreach($showList as $showID) {
// Get show page // Get show page
$html = getSimpleHTMLDOM(self::URI . 'shows/' . rawurlencode($showID) . '/') $html = getSimpleHTMLDOM(self::URI . 'shows/' . rawurlencode($showID) . '/')
or returnServerError('Could not request EZTV for id "' . $showID . '"'); or returnServerError('Could not request EZTV for id "' . $showID . '"');
// Loop on each element that look like an episode entry... // Loop on each element that look like an episode entry...
foreach($html->find('.forum_header_border') as $element){ foreach($html->find('.forum_header_border') as $element) {
// Filter entries that are not episode entries // Filter entries that are not episode entries
$ep = $element->find('td', 1); $ep = $element->find('td', 1);

View file

@ -11,7 +11,7 @@ class EliteDangerousGalnetBridge extends BridgeAbstract {
$html = getSimpleHTMLDOM(self::URI) $html = getSimpleHTMLDOM(self::URI)
or returnServerError('Error while downloading the website content'); or returnServerError('Error while downloading the website content');
foreach($html->find('div.article') as $element){ foreach($html->find('div.article') as $element) {
$item = array(); $item = array();
$uri = $element->find('h3 a', 0)->href; $uri = $element->find('h3 a', 0)->href;

View file

@ -27,7 +27,7 @@ class ElsevierBridge extends BridgeAbstract {
// Extracts the timestamp from an article // Extracts the timestamp from an article
private function extractArticleTimestamp($article){ private function extractArticleTimestamp($article){
$time = $article->find('.article-info', 0); $time = $article->find('.article-info', 0);
if($time){ if($time) {
$timestring = trim($time->plaintext); $timestring = trim($time->plaintext);
/* /*
The format depends on the age of an article: The format depends on the age of an article:
@ -35,11 +35,11 @@ class ElsevierBridge extends BridgeAbstract {
- July 2016 - July 2016
- MayJune 2016 - MayJune 2016
*/ */
if(preg_match('/\S*(\d+\s\S+\s\d{4})/ims', $timestring, $matches)){ if(preg_match('/\S*(\d+\s\S+\s\d{4})/ims', $timestring, $matches)) {
return strtotime($matches[0]); return strtotime($matches[0]);
} elseif (preg_match('/[A-Za-z]+\-([A-Za-z]+\s\d{4})/ims', $timestring, $matches)){ } elseif (preg_match('/[A-Za-z]+\-([A-Za-z]+\s\d{4})/ims', $timestring, $matches)) {
return strtotime($matches[0]); return strtotime($matches[0]);
} elseif (preg_match('/([A-Za-z]+\s\d{4})/ims', $timestring, $matches)){ } elseif (preg_match('/([A-Za-z]+\s\d{4})/ims', $timestring, $matches)) {
return strtotime($matches[0]); return strtotime($matches[0]);
} else { } else {
return 0; return 0;
@ -51,7 +51,7 @@ class ElsevierBridge extends BridgeAbstract {
// Extracts the content from an article // Extracts the content from an article
private function extractArticleContent($article){ private function extractArticleContent($article){
$content = $article->find('.article-content', 0); $content = $article->find('.article-content', 0);
if($content){ if($content) {
return trim($content->plaintext); return trim($content->plaintext);
} }
return ''; return '';
@ -62,7 +62,7 @@ class ElsevierBridge extends BridgeAbstract {
$html = getSimpleHTMLDOM($uri) $html = getSimpleHTMLDOM($uri)
or returnServerError('No results for Elsevier journal ' . $this->getInput('j')); or returnServerError('No results for Elsevier journal ' . $this->getInput('j'));
foreach($html->find('.pod-listing') as $article){ foreach($html->find('.pod-listing') as $article) {
$item = array(); $item = array();
$item['uri'] = $article->find('.pod-listing-header>a', 0)->getAttribute('href') . '?np=y'; $item['uri'] = $article->find('.pod-listing-header>a', 0)->getAttribute('href') . '?np=y';
$item['title'] = $article->find('.pod-listing-header>a', 0)->plaintext; $item['title'] = $article->find('.pod-listing-header>a', 0)->plaintext;

View file

@ -9,7 +9,7 @@ class EstCeQuonMetEnProdBridge extends BridgeAbstract {
public function collectData(){ public function collectData(){
function extractFromDelimiters($string, $start, $end){ function extractFromDelimiters($string, $start, $end){
if(strpos($string, $start) !== false){ if(strpos($string, $start) !== false) {
$section_retrieved = substr($string, strpos($string, $start) + strlen($start)); $section_retrieved = substr($string, strpos($string, $start) + strlen($start));
$section_retrieved = substr($section_retrieved, 0, strpos($section_retrieved, $end)); $section_retrieved = substr($section_retrieved, 0, strpos($section_retrieved, $end));
return $section_retrieved; return $section_retrieved;

View file

@ -38,7 +38,7 @@ class EtsyBridge extends BridgeAbstract {
$results = $html->find('div.block-grid-item'); $results = $html->find('div.block-grid-item');
foreach($results as $result){ foreach($results as $result) {
// Skip banner cards (ads for categories) // Skip banner cards (ads for categories)
if($result->find('a.banner-card')) if($result->find('a.banner-card'))
continue; continue;
@ -57,7 +57,7 @@ class EtsyBridge extends BridgeAbstract {
$image = $result->find('img.placeholder', 0)->src; $image = $result->find('img.placeholder', 0)->src;
if($this->getInput('showimage')){ if($this->getInput('showimage')) {
$item['content'] .= '<img src="' . $image . '">'; $item['content'] .= '<img src="' . $image . '">';
} }
@ -68,10 +68,10 @@ class EtsyBridge extends BridgeAbstract {
} }
public function getURI(){ public function getURI(){
if(!is_null($this->getInput('query'))){ if(!is_null($this->getInput('query'))) {
$uri = self::URI . '/search?q=' . urlencode($this->getInput('query')); $uri = self::URI . '/search?q=' . urlencode($this->getInput('query'));
if(!is_null($this->getInput('queryextension'))){ if(!is_null($this->getInput('queryextension'))) {
$uri .= $this->getInput('queryextension'); $uri .= $this->getInput('queryextension');
} }

View file

@ -18,7 +18,7 @@ class FB2Bridge extends BridgeAbstract {
public function collectData(){ public function collectData(){
function extractFromDelimiters($string, $start, $end){ function extractFromDelimiters($string, $start, $end){
if(strpos($string, $start) !== false){ if(strpos($string, $start) !== false) {
$section_retrieved = substr($string, strpos($string, $start) + strlen($start)); $section_retrieved = substr($string, strpos($string, $start) + strlen($start));
$section_retrieved = substr($section_retrieved, 0, strpos($section_retrieved, $end)); $section_retrieved = substr($section_retrieved, 0, strpos($section_retrieved, $end));
return $section_retrieved; return $section_retrieved;
@ -29,7 +29,7 @@ class FB2Bridge extends BridgeAbstract {
//Utility function for cleaning a Facebook link //Utility function for cleaning a Facebook link
$unescape_fb_link = function($matches){ $unescape_fb_link = function($matches){
if(is_array($matches) && count($matches) > 1){ if(is_array($matches) && count($matches) > 1) {
$link = $matches[1]; $link = $matches[1];
if(strpos($link, '/') === 0) if(strpos($link, '/') === 0)
$link = self::URI . $link . '"'; $link = self::URI . $link . '"';
@ -72,12 +72,12 @@ class FB2Bridge extends BridgeAbstract {
return $matches[0]; return $matches[0];
}; };
if($this->getInput('u') !== null){ if($this->getInput('u') !== null) {
$page = 'https://touch.facebook.com/' . $this->getInput('u'); $page = 'https://touch.facebook.com/' . $this->getInput('u');
$cookies = $this->getCookies($page); $cookies = $this->getCookies($page);
$pageID = $this->getPageID($page, $cookies); $pageID = $this->getPageID($page, $cookies);
if($pageID === null){ if($pageID === null) {
echo <<<EOD echo <<<EOD
Unable to get the page id. You should consider getting the ID by hand, then importing it into FB2Bridge Unable to get the page id. You should consider getting the ID by hand, then importing it into FB2Bridge
EOD; EOD;
@ -103,7 +103,7 @@ EOD;
$html = $this->buildContent($fileContent); $html = $this->buildContent($fileContent);
$author = $this->getInput('u'); $author = $this->getInput('u');
foreach($html->find("article") as $content){ foreach($html->find("article") as $content) {
$item = array(); $item = array();
@ -223,8 +223,8 @@ EOD;
//First request to get the cookie //First request to get the cookie
$cookies = ""; $cookies = "";
foreach($http_response_header as $hdr){ foreach($http_response_header as $hdr) {
if(strpos($hdr, "Set-Cookie") !== false){ if(strpos($hdr, "Set-Cookie") !== false) {
$cLine = explode(":", $hdr)[1]; $cLine = explode(":", $hdr)[1];
$cLine = explode(";", $cLine)[0]; $cLine = explode(";", $cLine)[0];
$cookies .= ";" . $cLine; $cookies .= ";" . $cLine;
@ -255,7 +255,7 @@ EOD;
$regex = "/page_id=([0-9]*)&/"; $regex = "/page_id=([0-9]*)&/";
preg_match($regex, $pageContent, $matches); preg_match($regex, $pageContent, $matches);
if(count($matches) > 0){ if(count($matches) > 0) {
return $matches[1]; return $matches[1];
} }

View file

@ -32,7 +32,7 @@ class FacebookBridge extends BridgeAbstract {
//Extract a string using start and end delimiters //Extract a string using start and end delimiters
function extractFromDelimiters($string, $start, $end){ function extractFromDelimiters($string, $start, $end){
if(strpos($string, $start) !== false){ if(strpos($string, $start) !== false) {
$section_retrieved = substr($string, strpos($string, $start) + strlen($start)); $section_retrieved = substr($string, strpos($string, $start) + strlen($start));
$section_retrieved = substr($section_retrieved, 0, strpos($section_retrieved, $end)); $section_retrieved = substr($section_retrieved, 0, strpos($section_retrieved, $end));
return $section_retrieved; return $section_retrieved;
@ -43,7 +43,7 @@ class FacebookBridge extends BridgeAbstract {
//Utility function for cleaning a Facebook link //Utility function for cleaning a Facebook link
$unescape_fb_link = function($matches){ $unescape_fb_link = function($matches){
if(is_array($matches) && count($matches) > 1){ if(is_array($matches) && count($matches) > 1) {
$link = $matches[1]; $link = $matches[1];
if(strpos($link, '/') === 0) if(strpos($link, '/') === 0)
$link = self::URI . $link . '"'; $link = self::URI . $link . '"';
@ -89,12 +89,10 @@ class FacebookBridge extends BridgeAbstract {
$html = null; $html = null;
//Handle captcha response sent by the viewer //Handle captcha response sent by the viewer
if (isset($_POST['captcha_response'])) if (isset($_POST['captcha_response'])) {
{
if (session_status() == PHP_SESSION_NONE) if (session_status() == PHP_SESSION_NONE)
session_start(); session_start();
if (isset($_SESSION['captcha_fields'], $_SESSION['captcha_action'])) if (isset($_SESSION['captcha_fields'], $_SESSION['captcha_action'])) {
{
$captcha_action = $_SESSION['captcha_action']; $captcha_action = $_SESSION['captcha_action'];
$captcha_fields = $_SESSION['captcha_fields']; $captcha_fields = $_SESSION['captcha_fields'];
$captcha_fields['captcha_response'] = preg_replace("/[^a-zA-Z0-9]+/", "", $_POST['captcha_response']); $captcha_fields['captcha_response'] = preg_replace("/[^a-zA-Z0-9]+/", "", $_POST['captcha_response']);
@ -110,7 +108,7 @@ class FacebookBridge extends BridgeAbstract {
$context = stream_context_create($http_options); $context = stream_context_create($http_options);
$html = getContents($captcha_action, false, $context); $html = getContents($captcha_action, false, $context);
if($html === false){ if($html === false) {
returnServerError('Failed to submit captcha response back to Facebook'); returnServerError('Failed to submit captcha response back to Facebook');
} }
unset($_SESSION['captcha_fields']); unset($_SESSION['captcha_fields']);
@ -121,7 +119,7 @@ class FacebookBridge extends BridgeAbstract {
} }
//Retrieve page contents //Retrieve page contents
if(is_null($html)){ if(is_null($html)) {
$http_options = array( $http_options = array(
'http' => array( 'http' => array(
'method' => 'GET', 'method' => 'GET',
@ -130,7 +128,7 @@ class FacebookBridge extends BridgeAbstract {
) )
); );
$context = stream_context_create($http_options); $context = stream_context_create($http_options);
if(!strpos($this->getInput('u'), "/")){ if(!strpos($this->getInput('u'), "/")) {
$html = getSimpleHTMLDOM(self::URI . urlencode($this->getInput('u')) . '?_fb_noscript=1', $html = getSimpleHTMLDOM(self::URI . urlencode($this->getInput('u')) . '?_fb_noscript=1',
false, false,
$context) $context)
@ -145,8 +143,7 @@ class FacebookBridge extends BridgeAbstract {
//Handle captcha form? //Handle captcha form?
$captcha = $html->find('div.captcha_interstitial', 0); $captcha = $html->find('div.captcha_interstitial', 0);
if (!is_null($captcha)) if (!is_null($captcha)) {
{
//Save form for submitting after getting captcha response //Save form for submitting after getting captcha response
if (session_status() == PHP_SESSION_NONE) if (session_status() == PHP_SESSION_NONE)
session_start(); session_start();
@ -182,7 +179,7 @@ EOD;
->next_sibling() ->next_sibling()
->children(0); ->children(0);
if(isset($element)){ if(isset($element)) {
$author = str_replace(' | Facebook', '', $html->find('title#pageTitle', 0)->innertext); $author = str_replace(' | Facebook', '', $html->find('title#pageTitle', 0)->innertext);
$profilePic = 'https://graph.facebook.com/' $profilePic = 'https://graph.facebook.com/'
@ -191,17 +188,17 @@ EOD;
$this->authorName = $author; $this->authorName = $author;
foreach($element->children() as $cell){ foreach($element->children() as $cell) {
// Manage summary posts // Manage summary posts
if(strpos($cell->class, '_3xaf') !== false){ if(strpos($cell->class, '_3xaf') !== false) {
$posts = $cell->children(); $posts = $cell->children();
} else { } else {
$posts = array($cell); $posts = array($cell);
} }
foreach($posts as $post){ foreach($posts as $post) {
// Check media type // Check media type
switch($this->getInput('media_type')){ switch($this->getInput('media_type')) {
case 'all': break; case 'all': break;
case 'video': case 'video':
if(empty($post->find('[aria-label=Video]'))) continue 2; if(empty($post->find('[aria-label=Video]'))) continue 2;
@ -214,7 +211,7 @@ EOD;
$item = array(); $item = array();
if(count($post->find('abbr')) > 0){ if(count($post->find('abbr')) > 0) {
//Retrieve post contents //Retrieve post contents
$content = preg_replace( $content = preg_replace(
@ -270,7 +267,7 @@ EOD;
//Retrieve date of the post //Retrieve date of the post
$date = $post->find("abbr")[0]; $date = $post->find("abbr")[0];
if(isset($date) && $date->hasAttribute('data-utime')){ if(isset($date) && $date->hasAttribute('data-utime')) {
$date = $date->getAttribute('data-utime'); $date = $date->getAttribute('data-utime');
} else { } else {
$date = 0; $date = 0;
@ -298,7 +295,7 @@ EOD;
} }
public function getName(){ public function getName(){
if(!empty($this->authorName)){ if(!empty($this->authorName)) {
return isset($this->extraInfos['name']) ? $this->extraInfos['name'] : $this->authorName return isset($this->extraInfos['name']) ? $this->extraInfos['name'] : $this->authorName
. ' - Facebook Bridge'; . ' - Facebook Bridge';
} }

View file

@ -25,7 +25,7 @@ class FeedExpanderExampleBridge extends FeedExpander {
); );
public function collectData(){ public function collectData(){
switch($this->getInput('version')){ switch($this->getInput('version')) {
case 'rss_0_9_1': case 'rss_0_9_1':
parent::collectExpandableDatas('http://static.userland.com/gems/backend/sampleRss.xml'); parent::collectExpandableDatas('http://static.userland.com/gems/backend/sampleRss.xml');
break; break;
@ -43,7 +43,7 @@ class FeedExpanderExampleBridge extends FeedExpander {
} }
protected function parseItem($newsItem) { protected function parseItem($newsItem) {
switch($this->getInput('version')){ switch($this->getInput('version')) {
case 'rss_0_9_1': case 'rss_0_9_1':
return $this->parseRSS_0_9_1_Item($newsItem); return $this->parseRSS_0_9_1_Item($newsItem);
break; break;

View file

@ -11,7 +11,7 @@ class FierPandaBridge extends BridgeAbstract {
$html = getSimpleHTMLDOM(self::URI) $html = getSimpleHTMLDOM(self::URI)
or returnServerError('Could not request Fier Panda.'); or returnServerError('Could not request Fier Panda.');
foreach($html->find('div.container-content article') as $element){ foreach($html->find('div.container-content article') as $element) {
$item = array(); $item = array();
$item['uri'] = $this->getURI() . $element->find('a', 0)->href; $item['uri'] = $this->getURI() . $element->find('a', 0)->href;
$item['title'] = trim($element->find('h1 a', 0)->innertext); $item['title'] = trim($element->find('h1 a', 0)->innertext);

View file

@ -31,7 +31,7 @@ class FilterBridge extends FeedExpander {
protected function parseItem($newItem){ protected function parseItem($newItem){
$item = parent::parseItem($newItem); $item = parent::parseItem($newItem);
switch(true){ switch(true) {
case $this->getFilterType() === 'permit': case $this->getFilterType() === 'permit':
if (preg_match($this->getFilter(), $item['title'])) { if (preg_match($this->getFilter(), $item['title'])) {
return $item; return $item;
@ -57,20 +57,20 @@ class FilterBridge extends FeedExpander {
public function getURI(){ public function getURI(){
$url = $this->getInput('url'); $url = $this->getInput('url');
if(empty($url)){ if(empty($url)) {
$url = parent::getURI(); $url = parent::getURI();
} }
return $url; return $url;
} }
public function collectData(){ public function collectData(){
if($this->getInput('url') && substr($this->getInput('url'), 0, strlen('http')) !== 'http'){ if($this->getInput('url') && substr($this->getInput('url'), 0, strlen('http')) !== 'http') {
// just in case someone find a way to access local files by playing with the url // just in case someone find a way to access local files by playing with the url
returnClientError('The url parameter must either refer to http or https protocol.'); returnClientError('The url parameter must either refer to http or https protocol.');
} }
try{ try{
$this->collectExpandableDatas($this->getURI()); $this->collectExpandableDatas($this->getURI());
}catch (HttpException $e){ } catch (HttpException $e) {
$this->collectExpandableDatas($this->getURI()); $this->collectExpandableDatas($this->getURI());
} }
} }

View file

@ -34,7 +34,7 @@ class FlickrBridge extends BridgeAbstract {
); );
public function collectData(){ public function collectData(){
switch($this->queriedContext){ switch($this->queriedContext) {
case 'Explore': case 'Explore':
$key = 'photos'; $key = 'photos';
$html = getSimpleHTMLDOM(self::URI . 'explore') $html = getSimpleHTMLDOM(self::URI . 'explore')
@ -68,7 +68,7 @@ class FlickrBridge extends BridgeAbstract {
$model_json = json_decode($model_text, true); $model_json = json_decode($model_text, true);
foreach($html->find('.photo-list-photo-view') as $element){ foreach($html->find('.photo-list-photo-view') as $element) {
// Get the styles // Get the styles
$style = explode(';', $element->style); $style = explode(';', $element->style);
@ -83,17 +83,17 @@ class FlickrBridge extends BridgeAbstract {
$imageID = reset($imageURIs); $imageID = reset($imageURIs);
// Use JSON data to build items // Use JSON data to build items
foreach(reset($model_json)[0][$key]['_data'] as $element){ foreach(reset($model_json)[0][$key]['_data'] as $element) {
if($element['id'] === $imageID){ if($element['id'] === $imageID) {
$item = array(); $item = array();
/* Author name depends on scope. On a keyword search the /* Author name depends on scope. On a keyword search the
* author is part of the picture data. On a username search * author is part of the picture data. On a username search
* the author is part of the owner data. * the author is part of the owner data.
*/ */
if(array_key_exists('username', $element)){ if(array_key_exists('username', $element)) {
$item['author'] = $element['username']; $item['author'] = $element['username'];
} elseif (array_key_exists('owner', reset($model_json)[0])){ } elseif (array_key_exists('owner', reset($model_json)[0])) {
$item['author'] = reset($model_json)[0]['owner']['username']; $item['author'] = reset($model_json)[0]['owner']['username'];
} }

View file

@ -10,7 +10,7 @@ class FootitoBridge extends BridgeAbstract {
$html = getSimpleHTMLDOM(self::URI) $html = getSimpleHTMLDOM(self::URI)
or returnServerError('Could not request Footito.'); or returnServerError('Could not request Footito.');
foreach($html->find('div.post') as $element){ foreach($html->find('div.post') as $element) {
$item = array(); $item = array();
$content = trim($element->innertext); $content = trim($element->innertext);

View file

@ -20,7 +20,7 @@ class FourchanBridge extends BridgeAbstract {
)); ));
public function getURI(){ public function getURI(){
if(!is_null($this->getInput('c')) && !is_null($this->getInput('t'))){ if(!is_null($this->getInput('c')) && !is_null($this->getInput('t'))) {
return static::URI . $this->getInput('c') . '/thread/' . $this->getInput('t'); return static::URI . $this->getInput('c') . '/thread/' . $this->getInput('t');
} }
@ -32,7 +32,7 @@ class FourchanBridge extends BridgeAbstract {
$html = getSimpleHTMLDOM($this->getURI()) $html = getSimpleHTMLDOM($this->getURI())
or returnServerError("Could not request 4chan, thread not found"); or returnServerError("Could not request 4chan, thread not found");
foreach($html->find('div.postContainer') as $element){ foreach($html->find('div.postContainer') as $element) {
$item = array(); $item = array();
$item['id'] = $element->find('.post', 0)->getAttribute('id'); $item['id'] = $element->find('.post', 0)->getAttribute('id');
$item['uri'] = $this->getURI() . '#' . $item['id']; $item['uri'] = $this->getURI() . '#' . $item['id'];
@ -41,19 +41,19 @@ class FourchanBridge extends BridgeAbstract {
$file = $element->find('.file', 0); $file = $element->find('.file', 0);
if(!empty($file)){ if(!empty($file)) {
$item['image'] = $element->find('.file a', 0)->href; $item['image'] = $element->find('.file a', 0)->href;
$item['imageThumb'] = $element->find('.file img', 0)->src; $item['imageThumb'] = $element->find('.file img', 0)->src;
if(!isset($item['imageThumb']) and strpos($item['image'], '.swf') !== false) if(!isset($item['imageThumb']) and strpos($item['image'], '.swf') !== false)
$item['imageThumb'] = 'http://i.imgur.com/eO0cxf9.jpg'; $item['imageThumb'] = 'http://i.imgur.com/eO0cxf9.jpg';
} }
if(!empty($element->find('span.subject', 0)->innertext)){ if(!empty($element->find('span.subject', 0)->innertext)) {
$item['subject'] = $element->find('span.subject', 0)->innertext; $item['subject'] = $element->find('span.subject', 0)->innertext;
} }
$item['title'] = 'reply ' . $item['id'] . ' | ' . $item['author']; $item['title'] = 'reply ' . $item['id'] . ' | ' . $item['author'];
if(isset($item['subject'])){ if(isset($item['subject'])) {
$item['title'] = $item['subject'] . ' - ' . $item['title']; $item['title'] = $item['subject'] . ' - ' . $item['title'];
} }
@ -61,7 +61,7 @@ class FourchanBridge extends BridgeAbstract {
$content = str_replace('href="#p', 'href="' . $this->getURI() . '#p', $content); $content = str_replace('href="#p', 'href="' . $this->getURI() . '#p', $content);
$item['content'] = '<span id="' . $item['id'] . '">' . $content . '</span>'; $item['content'] = '<span id="' . $item['id'] . '">' . $content . '</span>';
if(isset($item['image'])){ if(isset($item['image'])) {
$item['content'] = '<a href="' $item['content'] = '<a href="'
. $item['image'] . $item['image']
. '"><img alt="' . '"><img alt="'

View file

@ -95,7 +95,7 @@ class FuturaSciencesBridge extends FeedExpander {
} }
private function stripWithDelimiters($string, $start, $end){ private function stripWithDelimiters($string, $start, $end){
while(strpos($string, $start) !== false){ while(strpos($string, $start) !== false) {
$section_to_remove = substr($string, strpos($string, $start)); $section_to_remove = substr($string, strpos($string, $start));
$section_to_remove = substr($section_to_remove, 0, strpos($section_to_remove, $end) + strlen($end)); $section_to_remove = substr($section_to_remove, 0, strpos($section_to_remove, $end) + strlen($end));
$string = str_replace($section_to_remove, '', $string); $string = str_replace($section_to_remove, '', $string);
@ -106,8 +106,8 @@ class FuturaSciencesBridge extends FeedExpander {
$open_tag = '<' . $tag_name; $open_tag = '<' . $tag_name;
$close_tag = '</' . $tag_name . '>'; $close_tag = '</' . $tag_name . '>';
$close_tag_length = strlen($close_tag); $close_tag_length = strlen($close_tag);
if(strpos($tag_start, $open_tag) === 0){ if(strpos($tag_start, $open_tag) === 0) {
while(strpos($string, $tag_start) !== false){ while(strpos($string, $tag_start) !== false) {
$max_recursion = 100; $max_recursion = 100;
$section_to_remove = null; $section_to_remove = null;
$section_start = strpos($string, $tag_start); $section_start = strpos($string, $tag_start);
@ -165,7 +165,7 @@ class FuturaSciencesBridge extends FeedExpander {
// Extracts the author from an article or element // Extracts the author from an article or element
private function extractAuthor($article){ private function extractAuthor($article){
$article_author = $article->find('h3.epsilon', 0); $article_author = $article->find('h3.epsilon', 0);
if($article_author){ if($article_author) {
return trim(str_replace(', Futura-Sciences', '', $article_author->plaintext)); return trim(str_replace(', Futura-Sciences', '', $article_author->plaintext));
} }
return ''; return '';

View file

@ -21,7 +21,7 @@ class GBAtempBridge extends BridgeAbstract {
)); ));
private function extractFromDelimiters($string, $start, $end){ private function extractFromDelimiters($string, $start, $end){
if(strpos($string, $start) !== false){ if(strpos($string, $start) !== false) {
$section_retrieved = substr($string, strpos($string, $start) + strlen($start)); $section_retrieved = substr($string, strpos($string, $start) + strlen($start));
$section_retrieved = substr($section_retrieved, 0, strpos($section_retrieved, $end)); $section_retrieved = substr($section_retrieved, 0, strpos($section_retrieved, $end));
return $section_retrieved; return $section_retrieved;
@ -31,7 +31,7 @@ class GBAtempBridge extends BridgeAbstract {
} }
private function stripWithDelimiters($string, $start, $end){ private function stripWithDelimiters($string, $start, $end){
while(strpos($string, $start) !== false){ while(strpos($string, $start) !== false) {
$section_to_remove = substr($string, strpos($string, $start)); $section_to_remove = substr($string, strpos($string, $start));
$section_to_remove = substr($section_to_remove, 0, strpos($section_to_remove, $end) + strlen($end)); $section_to_remove = substr($section_to_remove, 0, strpos($section_to_remove, $end) + strlen($end));
$string = str_replace($section_to_remove, '', $string); $string = str_replace($section_to_remove, '', $string);
@ -59,7 +59,7 @@ class GBAtempBridge extends BridgeAbstract {
private function fetchPostContent($uri, $site_url){ private function fetchPostContent($uri, $site_url){
$html = getSimpleHTMLDOM($uri); $html = getSimpleHTMLDOM($uri);
if(!$html){ if(!$html) {
return 'Could not request GBAtemp ' . $uri; return 'Could not request GBAtemp ' . $uri;
} }
@ -72,9 +72,9 @@ class GBAtempBridge extends BridgeAbstract {
$html = getSimpleHTMLDOM(self::URI) $html = getSimpleHTMLDOM(self::URI)
or returnServerError('Could not request GBAtemp.'); or returnServerError('Could not request GBAtemp.');
switch($this->getInput('type')){ switch($this->getInput('type')) {
case 'N': case 'N':
foreach($html->find('li[class=news_item full]') as $newsItem){ foreach($html->find('li[class=news_item full]') as $newsItem) {
$url = self::URI . $newsItem->find('a', 0)->href; $url = self::URI . $newsItem->find('a', 0)->href;
$time = intval( $time = intval(
$this->extractFromDelimiters( $this->extractFromDelimiters(
@ -89,7 +89,7 @@ class GBAtempBridge extends BridgeAbstract {
$this->items[] = $this->buildItem($url, $title, $author, $time, $content); $this->items[] = $this->buildItem($url, $title, $author, $time, $content);
} }
case 'R': case 'R':
foreach($html->find('li.portal_review') as $reviewItem){ foreach($html->find('li.portal_review') as $reviewItem) {
$url = self::URI . $reviewItem->find('a', 0)->href; $url = self::URI . $reviewItem->find('a', 0)->href;
$title = $reviewItem->find('span.review_title', 0)->plaintext; $title = $reviewItem->find('span.review_title', 0)->plaintext;
$content = getSimpleHTMLDOM($url) $content = getSimpleHTMLDOM($url)
@ -111,7 +111,7 @@ class GBAtempBridge extends BridgeAbstract {
$this->items[] = $this->buildItem($url, $title, $author, $time, $content); $this->items[] = $this->buildItem($url, $title, $author, $time, $content);
} }
case 'T': case 'T':
foreach($html->find('li.portal-tutorial') as $tutorialItem){ foreach($html->find('li.portal-tutorial') as $tutorialItem) {
$url = self::URI . $tutorialItem->find('a', 0)->href; $url = self::URI . $tutorialItem->find('a', 0)->href;
$title = $tutorialItem->find('a', 0)->plaintext; $title = $tutorialItem->find('a', 0)->plaintext;
$time = intval( $time = intval(
@ -126,7 +126,7 @@ class GBAtempBridge extends BridgeAbstract {
$this->items[] = $this->buildItem($url, $title, $author, $time, $content); $this->items[] = $this->buildItem($url, $title, $author, $time, $content);
} }
case 'F': case 'F':
foreach($html->find('li.rc_item') as $postItem){ foreach($html->find('li.rc_item') as $postItem) {
$url = self::URI . $postItem->find('a', 1)->href; $url = self::URI . $postItem->find('a', 1)->href;
$title = $postItem->find('a', 1)->plaintext; $title = $postItem->find('a', 1)->plaintext;
$time = intval( $time = intval(
@ -144,7 +144,7 @@ class GBAtempBridge extends BridgeAbstract {
} }
public function getName() { public function getName() {
if(!is_null($this->getInput('type'))){ if(!is_null($this->getInput('type'))) {
$type = array_search( $type = array_search(
$this->getInput('type'), $this->getInput('type'),
self::PARAMETERS[$this->queriedContext]['type']['values'] self::PARAMETERS[$this->queriedContext]['type']['values']

View file

@ -27,14 +27,14 @@ class GiphyBridge extends BridgeAbstract {
or returnServerError('No results for this query.'); or returnServerError('No results for this query.');
$max = GIPHY_LIMIT; $max = GIPHY_LIMIT;
if($this->getInput('n')){ if($this->getInput('n')) {
$max = $this->getInput('n'); $max = $this->getInput('n');
} }
$limit = 0; $limit = 0;
$kw = urlencode($this->getInput('s')); $kw = urlencode($this->getInput('s'));
foreach($html->find('div.hoverable-gif') as $entry){ foreach($html->find('div.hoverable-gif') as $entry) {
if($limit < $max){ if($limit < $max) {
$node = $entry->first_child(); $node = $entry->first_child();
$href = $node->getAttribute('href'); $href = $node->getAttribute('href');
@ -54,7 +54,7 @@ class GiphyBridge extends BridgeAbstract {
$title = str_replace($kw, '', $title); $title = str_replace($kw, '', $title);
$title = preg_replace('/\s+/', ' ', $title); $title = preg_replace('/\s+/', ' ', $title);
$title = trim($title); $title = trim($title);
if(strlen($title) <= 0){ if(strlen($title) <= 0) {
$title = $item['id']; $title = $item['id'];
} }
$item['title'] = trim($title); $item['title'] = trim($title);

View file

@ -35,9 +35,9 @@ class GithubIssueBridge extends BridgeAbstract {
public function getName(){ public function getName(){
$name = $this->getInput('u') . '/' . $this->getInput('p'); $name = $this->getInput('u') . '/' . $this->getInput('p');
switch($this->queriedContext){ switch($this->queriedContext) {
case 'Project Issues': case 'Project Issues':
if($this->getInput('c')){ if($this->getInput('c')) {
$prefix = static::NAME . 's comments for '; $prefix = static::NAME . 's comments for ';
} else { } else {
$prefix = static::NAME . 's for '; $prefix = static::NAME . 's for ';
@ -53,11 +53,11 @@ class GithubIssueBridge extends BridgeAbstract {
} }
public function getURI(){ public function getURI(){
if(!is_null($this->getInput('u')) && !is_null($this->getInput('p'))){ if(!is_null($this->getInput('u')) && !is_null($this->getInput('p'))) {
$uri = static::URI . $this->getInput('u') . '/' . $this->getInput('p') . '/issues'; $uri = static::URI . $this->getInput('u') . '/' . $this->getInput('p') . '/issues';
if($this->queriedContext === 'Issue comments'){ if($this->queriedContext === 'Issue comments') {
$uri .= '/' . $this->getInput('i'); $uri .= '/' . $this->getInput('i');
} elseif($this->getInput('c')){ } elseif($this->getInput('c')) {
$uri .= '?q=is%3Aissue+sort%3Aupdated-desc'; $uri .= '?q=is%3Aissue+sort%3Aupdated-desc';
} }
return $uri; return $uri;
@ -70,29 +70,29 @@ class GithubIssueBridge extends BridgeAbstract {
$class = $comment->getAttribute('class'); $class = $comment->getAttribute('class');
$classes = explode(' ', $class); $classes = explode(' ', $class);
$event = false; $event = false;
if(in_array('discussion-item', $classes)){ if(in_array('discussion-item', $classes)) {
$event = true; $event = true;
} }
$author = 'unknown'; $author = 'unknown';
if($comment->find('.author', 0)){ if($comment->find('.author', 0)) {
$author = $comment->find('.author', 0)->plaintext; $author = $comment->find('.author', 0)->plaintext;
} }
$uri = static::URI . $this->getInput('u') . '/' . $this->getInput('p') . '/issues/' . $issueNbr; $uri = static::URI . $this->getInput('u') . '/' . $this->getInput('p') . '/issues/' . $issueNbr;
$comment = $comment->firstChild(); $comment = $comment->firstChild();
if(!$event){ if(!$event) {
$comment = $comment->nextSibling(); $comment = $comment->nextSibling();
} }
if($event){ if($event) {
$title .= ' / ' . substr($class, strpos($class, 'discussion-item-') + strlen('discussion-item-')); $title .= ' / ' . substr($class, strpos($class, 'discussion-item-') + strlen('discussion-item-'));
if(!$comment->hasAttribute('id')){ if(!$comment->hasAttribute('id')) {
$items = array(); $items = array();
$timestamp = strtotime($comment->find('relative-time', 0)->getAttribute('datetime')); $timestamp = strtotime($comment->find('relative-time', 0)->getAttribute('datetime'));
$content = $comment->innertext; $content = $comment->innertext;
while($comment = $comment->nextSibling()){ while($comment = $comment->nextSibling()) {
$item = array(); $item = array();
$item['author'] = $author; $item['author'] = $author;
$item['title'] = html_entity_decode($title, ENT_QUOTES, 'UTF-8'); $item['title'] = html_entity_decode($title, ENT_QUOTES, 'UTF-8');
@ -123,12 +123,12 @@ class GithubIssueBridge extends BridgeAbstract {
$title = $issue->find('.gh-header-title', 0)->plaintext; $title = $issue->find('.gh-header-title', 0)->plaintext;
$issueNbr = trim(substr($issue->find('.gh-header-number', 0)->plaintext, 1)); $issueNbr = trim(substr($issue->find('.gh-header-number', 0)->plaintext, 1));
$comments = $issue->find('.js-discussion', 0); $comments = $issue->find('.js-discussion', 0);
foreach($comments->children() as $comment){ foreach($comments->children() as $comment) {
$classes = explode(' ', $comment->getAttribute('class')); $classes = explode(' ', $comment->getAttribute('class'));
if(in_array('discussion-item', $classes) if(in_array('discussion-item', $classes)
|| in_array('timeline-comment-wrapper', $classes)){ || in_array('timeline-comment-wrapper', $classes)) {
$item = $this->extractIssueComment($issueNbr, $title, $comment); $item = $this->extractIssueComment($issueNbr, $title, $comment);
if(array_keys($item) !== range(0, count($item) - 1)){ if(array_keys($item) !== range(0, count($item) - 1)) {
$item = array($item); $item = array($item);
} }
$items = array_merge($items, $item); $items = array_merge($items, $item);
@ -141,22 +141,22 @@ class GithubIssueBridge extends BridgeAbstract {
$html = getSimpleHTMLDOM($this->getURI()) $html = getSimpleHTMLDOM($this->getURI())
or returnServerError('No results for Github Issue ' . $this->getURI()); or returnServerError('No results for Github Issue ' . $this->getURI());
switch($this->queriedContext){ switch($this->queriedContext) {
case 'Issue comments': case 'Issue comments':
$this->items = $this->extractIssueComments($html); $this->items = $this->extractIssueComments($html);
break; break;
case 'Project Issues': case 'Project Issues':
foreach($html->find('.js-active-navigation-container .js-navigation-item') as $issue){ foreach($html->find('.js-active-navigation-container .js-navigation-item') as $issue) {
$info = $issue->find('.opened-by', 0); $info = $issue->find('.opened-by', 0);
$issueNbr = substr(trim($info->plaintext), 1, strpos(trim($info->plaintext), ' ')); $issueNbr = substr(trim($info->plaintext), 1, strpos(trim($info->plaintext), ' '));
$item = array(); $item = array();
$item['content'] = ''; $item['content'] = '';
if($this->getInput('c')){ if($this->getInput('c')) {
$uri = static::URI . $this->getInput('u') . '/' . $this->getInput('p') . '/issues/' . $issueNbr; $uri = static::URI . $this->getInput('u') . '/' . $this->getInput('p') . '/issues/' . $issueNbr;
$issue = getSimpleHTMLDOMCached($uri, static::CACHE_TIMEOUT); $issue = getSimpleHTMLDOMCached($uri, static::CACHE_TIMEOUT);
if($issue){ if($issue) {
$this->items = array_merge($this->items, $this->extractIssueComments($issue)); $this->items = array_merge($this->items, $this->extractIssueComments($issue));
continue; continue;
} }

View file

@ -24,7 +24,7 @@ class GithubSearchBridge extends BridgeAbstract {
$html = getSimpleHTMLDOM($url) $html = getSimpleHTMLDOM($url)
or returnServerError('Error while downloading the website content'); or returnServerError('Error while downloading the website content');
foreach($html->find('div.repo-list-item') as $element){ foreach($html->find('div.repo-list-item') as $element) {
$item = array(); $item = array();
$uri = $element->find('h3 a', 0)->href; $uri = $element->find('h3 a', 0)->href;
@ -34,10 +34,9 @@ class GithubSearchBridge extends BridgeAbstract {
$title = $element->find('h3', 0)->plaintext; $title = $element->find('h3', 0)->plaintext;
$item['title'] = $title; $item['title'] = $title;
if (count($element->find('p')) == 2){ if (count($element->find('p')) == 2) {
$content = $element->find('p', 0)->innertext; $content = $element->find('p', 0)->innertext;
} } else{
else{
$content = ''; $content = '';
} }
$item['content'] = $content; $item['content'] = $content;

View file

@ -11,11 +11,11 @@ class GizmodoBridge extends FeedExpander {
$item = parent::parseItem($item); $item = parent::parseItem($item);
$articleHTMLContent = getSimpleHTMLDOMCached($item['uri']); $articleHTMLContent = getSimpleHTMLDOMCached($item['uri']);
if(!$articleHTMLContent){ if(!$articleHTMLContent) {
$text = 'Could not load ' . $item['uri']; $text = 'Could not load ' . $item['uri'];
} else { } else {
$text = $articleHTMLContent->find('div.entry-content', 0)->innertext; $text = $articleHTMLContent->find('div.entry-content', 0)->innertext;
foreach($articleHTMLContent->find('pagespeed_iframe') as $element){ foreach($articleHTMLContent->find('pagespeed_iframe') as $element) {
$text .= '<p>link to a iframe (could be a video): <a href="' $text .= '<p>link to a iframe (could be a video): <a href="'
. $element->src . $element->src
. '">' . '">'

View file

@ -18,7 +18,7 @@ class GoComicsBridge extends BridgeAbstract {
$html = getSimpleHTMLDOM($this->getURI()) $html = getSimpleHTMLDOM($this->getURI())
or returnServerError('Could not request GoComics: ' . $this->getURI()); or returnServerError('Could not request GoComics: ' . $this->getURI());
foreach($html->find('div.item-comic-container') as $element){ foreach($html->find('div.item-comic-container') as $element) {
$img = $element->find('img', 0); $img = $element->find('img', 0);
$link = $element->find('a.item-comic-link', 0); $link = $element->find('a.item-comic-link', 0);
@ -42,7 +42,7 @@ class GoComicsBridge extends BridgeAbstract {
} }
public function getURI(){ public function getURI(){
if(!is_null($this->getInput('comicname'))){ if(!is_null($this->getInput('comicname'))) {
return self::URI . urlencode($this->getInput('comicname')); return self::URI . urlencode($this->getInput('comicname'));
} }
@ -50,7 +50,7 @@ class GoComicsBridge extends BridgeAbstract {
} }
public function getName(){ public function getName(){
if(!is_null($this->getInput('comicname'))){ if(!is_null($this->getInput('comicname'))) {
return $this->getInput('comicname') . ' - GoComics'; return $this->getInput('comicname') . ' - GoComics';
} }

View file

@ -21,7 +21,7 @@ class GooglePlusPostBridge extends BridgeAbstract{
$username = $this->getInput('username'); $username = $this->getInput('username');
// Usernames start with a + if it's not an ID // Usernames start with a + if it's not an ID
if(!is_numeric($username) && substr($username, 0, 1) !== '+'){ if(!is_numeric($username) && substr($username, 0, 1) !== '+') {
$username = '+' . $username; $username = '+' . $username;
} }
@ -34,7 +34,7 @@ class GooglePlusPostBridge extends BridgeAbstract{
$this->_url = $html->find('meta[property=og:url]', 0)->getAttribute('content'); $this->_url = $html->find('meta[property=og:url]', 0)->getAttribute('content');
// I don't even know where to start with this discusting html... // I don't even know where to start with this discusting html...
foreach($html->find('div[jsname=WsjYwc]') as $post){ foreach($html->find('div[jsname=WsjYwc]') as $post) {
$item = array(); $item = array();
$item['author'] = $item['fullname'] = $post->find('div div div div a', 0)->innertext; $item['author'] = $item['fullname'] = $post->find('div div div div a', 0)->innertext;
@ -44,7 +44,7 @@ class GooglePlusPostBridge extends BridgeAbstract{
$timestamp = $post->find('a.qXj2He span', 0); $timestamp = $post->find('a.qXj2He span', 0);
if($timestamp){ if($timestamp) {
$item['timestamp'] = strtotime('+' . preg_replace( $item['timestamp'] = strtotime('+' . preg_replace(
'/[^0-9A-Za-z]/', '/[^0-9A-Za-z]/',
'', '',
@ -77,15 +77,15 @@ class GooglePlusPostBridge extends BridgeAbstract{
// XXX ugly but I don't have any idea how to do a better stuff, // 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 // str_replace on link doesn't work as expected and ask too many checks
foreach($content->find('a') as $link){ foreach($content->find('a') as $link) {
$hasHttp = strpos($link->href, 'http'); $hasHttp = strpos($link->href, 'http');
$hasDoubleSlash = strpos($link->href, '//'); $hasDoubleSlash = strpos($link->href, '//');
if((!$hasHttp && !$hasDoubleSlash) if((!$hasHttp && !$hasDoubleSlash)
|| (false !== $hasHttp && strpos($link->href, 'http') != 0) || (false !== $hasHttp && strpos($link->href, 'http') != 0)
|| (false === $hasHttp && false !== $hasDoubleSlash && $hasDoubleSlash != 0)){ || (false === $hasHttp && false !== $hasDoubleSlash && $hasDoubleSlash != 0)) {
// skipp bad link, for some hashtag or other stuff // skipp bad link, for some hashtag or other stuff
if(strpos($link->href, '/') == 0){ if(strpos($link->href, '/') == 0) {
$link->href = substr($link->href, 1); $link->href = substr($link->href, 1);
} }

View file

@ -33,8 +33,8 @@ class GoogleSearchBridge extends BridgeAbstract {
$emIsRes = $html->find('div[id=ires]', 0); $emIsRes = $html->find('div[id=ires]', 0);
if(!is_null($emIsRes)){ if(!is_null($emIsRes)) {
foreach($emIsRes->find('div[class=g]') as $element){ foreach($emIsRes->find('div[class=g]') as $element) {
$item = array(); $item = array();
@ -42,7 +42,7 @@ class GoogleSearchBridge extends BridgeAbstract {
$t = $element->find('a[href]', 0)->href; $t = $element->find('a[href]', 0)->href;
$item['uri'] = '' . $t; $item['uri'] = '' . $t;
parse_str(parse_url($t, PHP_URL_QUERY), $parameters); parse_str(parse_url($t, PHP_URL_QUERY), $parameters);
if(isset($parameters['q'])){ if(isset($parameters['q'])) {
$item['uri'] = $parameters['q']; $item['uri'] = $parameters['q'];
} }
@ -55,7 +55,7 @@ class GoogleSearchBridge extends BridgeAbstract {
} }
public function getName(){ public function getName(){
if(!is_null($this->getInput('q'))){ if(!is_null($this->getInput('q'))) {
return $this->getInput('q') . ' - Google search'; return $this->getInput('q') . ' - Google search';
} }

View file

@ -23,7 +23,7 @@ class HDWallpapersBridge extends BridgeAbstract {
public function collectData(){ public function collectData(){
$category = $this->category; $category = $this->category;
if(strrpos($category, 'wallpapers') !== strlen($category) - strlen('wallpapers')){ if(strrpos($category, 'wallpapers') !== strlen($category) - strlen('wallpapers')) {
$category .= '-desktop-wallpapers'; $category .= '-desktop-wallpapers';
} }
@ -31,17 +31,17 @@ class HDWallpapersBridge extends BridgeAbstract {
$max = $this->getInput('m') ?: 14; $max = $this->getInput('m') ?: 14;
$lastpage = 1; $lastpage = 1;
for($page = 1; $page <= $lastpage; $page++){ for($page = 1; $page <= $lastpage; $page++) {
$link = self::URI . '/' . $category . '/page/' . $page; $link = self::URI . '/' . $category . '/page/' . $page;
$html = getSimpleHTMLDOM($link) $html = getSimpleHTMLDOM($link)
or returnServerError('No results for this query.'); or returnServerError('No results for this query.');
if($page === 1){ if($page === 1) {
preg_match('/page\/(\d+)$/', $html->find('.pagination a', -2)->href, $matches); preg_match('/page\/(\d+)$/', $html->find('.pagination a', -2)->href, $matches);
$lastpage = min($matches[1], ceil($max / 14)); $lastpage = min($matches[1], ceil($max / 14));
} }
foreach($html->find('.wallpapers .wall a') as $element){ foreach($html->find('.wallpapers .wall a') as $element) {
$thumbnail = $element->find('img', 0); $thumbnail = $element->find('img', 0);
$item = array(); $item = array();
@ -70,7 +70,7 @@ class HDWallpapersBridge extends BridgeAbstract {
} }
public function getName(){ public function getName(){
if(!is_null($this->getInput('c')) && !is_null($this->getInput('r'))){ if(!is_null($this->getInput('c')) && !is_null($this->getInput('r'))) {
return 'HDWallpapers - ' return 'HDWallpapers - '
. str_replace(['__', '_'], [' & ', ' '], $this->getInput('c')) . str_replace(['__', '_'], [' & ', ' '], $this->getInput('c'))
. ' [' . ' ['

View file

@ -11,7 +11,7 @@ class HentaiHavenBridge extends BridgeAbstract {
$html = getSimpleHTMLDOM(self::URI) $html = getSimpleHTMLDOM(self::URI)
or returnServerError('Could not request Hentai Haven.'); or returnServerError('Could not request Hentai Haven.');
foreach($html->find('div.zoe-grid') as $element){ foreach($html->find('div.zoe-grid') as $element) {
$item = array(); $item = array();
$item['uri'] = $element->find('div.brick-content h3 a', 0)->href; $item['uri'] = $element->find('div.brick-content h3 a', 0)->href;
$thumbnailUri = $element->find('a.thumbnail-image img', 0)->getAttribute('data-src'); $thumbnailUri = $element->find('a.thumbnail-image img', 0)->getAttribute('data-src');

View file

@ -18,7 +18,7 @@ class IdenticaBridge extends BridgeAbstract {
$html = getSimpleHTMLDOM($this->getURI()) $html = getSimpleHTMLDOM($this->getURI())
or returnServerError('Requested username can\'t be found.'); or returnServerError('Requested username can\'t be found.');
foreach($html->find('li.major') as $dent){ foreach($html->find('li.major') as $dent) {
$item = array(); $item = array();
// get dent link // get dent link
@ -35,7 +35,7 @@ class IdenticaBridge extends BridgeAbstract {
} }
public function getName(){ public function getName(){
if(!is_null($this->getInput('u'))){ if(!is_null($this->getInput('u'))) {
return $this->getInput('u') . ' - Identica Bridge'; return $this->getInput('u') . ' - Identica Bridge';
} }
@ -43,7 +43,7 @@ class IdenticaBridge extends BridgeAbstract {
} }
public function getURI(){ public function getURI(){
if(!is_null($this->getInput('u'))){ if(!is_null($this->getInput('u'))) {
return self::URI . urlencode($this->getInput('u')); return self::URI . urlencode($this->getInput('u'));
} }

View file

@ -30,13 +30,13 @@ class InstagramBridge extends BridgeAbstract {
$innertext = null; $innertext = null;
foreach($html->find('script') as $script){ foreach($html->find('script') as $script) {
if('' === $script->innertext){ if('' === $script->innertext) {
continue; continue;
} }
$pos = strpos(trim($script->innertext), 'window._sharedData'); $pos = strpos(trim($script->innertext), 'window._sharedData');
if(0 !== $pos){ if(0 !== $pos) {
continue; continue;
} }
@ -49,9 +49,9 @@ class InstagramBridge extends BridgeAbstract {
$userMedia = $data->entry_data->ProfilePage[0]->user->media->nodes; $userMedia = $data->entry_data->ProfilePage[0]->user->media->nodes;
foreach($userMedia as $media){ foreach($userMedia as $media) {
// Check media type // Check media type
switch($this->getInput('media_type')){ switch($this->getInput('media_type')) {
case 'all': break; case 'all': break;
case 'video': case 'video':
if($media->is_video === false) continue 2; if($media->is_video === false) continue 2;
@ -65,7 +65,7 @@ class InstagramBridge extends BridgeAbstract {
$item = array(); $item = array();
$item['uri'] = self::URI . 'p/' . $media->code . '/'; $item['uri'] = self::URI . 'p/' . $media->code . '/';
$item['content'] = '<img src="' . htmlentities($media->display_src) . '" />'; $item['content'] = '<img src="' . htmlentities($media->display_src) . '" />';
if (isset($media->caption)){ if (isset($media->caption)) {
$item['title'] = $media->caption; $item['title'] = $media->caption;
} else { } else {
$item['title'] = basename($media->display_src); $item['title'] = basename($media->display_src);
@ -76,7 +76,7 @@ class InstagramBridge extends BridgeAbstract {
} }
public function getName(){ public function getName(){
if(!is_null($this->getInput('u'))){ if(!is_null($this->getInput('u'))) {
return $this->getInput('u') . ' - Instagram Bridge'; return $this->getInput('u') . ' - Instagram Bridge';
} }
@ -84,7 +84,7 @@ class InstagramBridge extends BridgeAbstract {
} }
public function getURI(){ public function getURI(){
if(!is_null($this->getInput('u'))){ if(!is_null($this->getInput('u'))) {
return self::URI . urlencode($this->getInput('u')); return self::URI . urlencode($this->getInput('u'));
} }

View file

@ -92,9 +92,9 @@ class IsoHuntBridge extends BridgeAbstract {
public function getURI(){ public function getURI(){
$uri = self::URI; $uri = self::URI;
switch($this->queriedContext){ switch($this->queriedContext) {
case 'By "Latest" category': case 'By "Latest" category':
switch($this->getInput('latest_category')){ switch($this->getInput('latest_category')) {
case 'hot_torrents': case 'hot_torrents':
$uri .= 'statistic/hot/torrents'; $uri .= 'statistic/hot/torrents';
break; break;
@ -128,7 +128,7 @@ class IsoHuntBridge extends BridgeAbstract {
} }
public function getName(){ public function getName(){
switch($this->queriedContext){ switch($this->queriedContext) {
case 'By "Latest" category': case 'By "Latest" category':
$categoryName = array_search( $categoryName = array_search(
$this->getInput('latest_category'), $this->getInput('latest_category'),
@ -163,9 +163,9 @@ class IsoHuntBridge extends BridgeAbstract {
public function collectData(){ public function collectData(){
$html = $this->loadHtml($this->getURI()); $html = $this->loadHtml($this->getURI());
switch($this->queriedContext){ switch($this->queriedContext) {
case 'By "Latest" category': case 'By "Latest" category':
switch($this->getInput('latest_category')){ switch($this->getInput('latest_category')) {
case 'hot_torrents': case 'hot_torrents':
$this->getLatestHotTorrents($html); $this->getLatestHotTorrents($html);
break; break;
@ -179,7 +179,7 @@ class IsoHuntBridge extends BridgeAbstract {
} }
break; break;
case 'By "Torrent" category': case 'By "Torrent" category':
if($this->getInput('torrent_category') === 'movies'){ if($this->getInput('torrent_category') === 'movies') {
// This one is special (content wise) // This one is special (content wise)
$this->getMovieTorrents($html); $this->getMovieTorrents($html);
} else { } else {
@ -187,7 +187,7 @@ class IsoHuntBridge extends BridgeAbstract {
} }
break; break;
case 'Search torrent by name': case 'Search torrent by name':
if( $this->getInput('search_category') === 'movies'){ if($this->getInput('search_category') === 'movies') {
// This one is special (content wise) // This one is special (content wise)
$this->getMovieTorrents($html); $this->getMovieTorrents($html);
} else { } else {
@ -208,7 +208,7 @@ class IsoHuntBridge extends BridgeAbstract {
if(!$torrents) if(!$torrents)
returnServerError('Unable to find torrents!'); returnServerError('Unable to find torrents!');
foreach($torrents as $torrent){ foreach($torrents as $torrent) {
$anchor = $torrent->find('a', 0); $anchor = $torrent->find('a', 0);
if(!$anchor) if(!$anchor)
@ -246,7 +246,7 @@ class IsoHuntBridge extends BridgeAbstract {
// Remove first element (header row) // Remove first element (header row)
$torrents = array_slice($torrents, 1); $torrents = array_slice($torrents, 1);
foreach($torrents as $torrent){ foreach($torrents as $torrent) {
$cell = $torrent->find('td', 0); $cell = $torrent->find('td', 0);
if(!$cell) if(!$cell)
@ -281,7 +281,7 @@ class IsoHuntBridge extends BridgeAbstract {
if(!$posts) if(!$posts)
returnServerError('Unable to find posts!'); returnServerError('Unable to find posts!');
foreach($posts as $post){ foreach($posts as $post) {
$item = array(); $item = array();
$item['uri'] = $this->latestNewsExtractUri($post); $item['uri'] = $this->latestNewsExtractUri($post);
@ -316,7 +316,7 @@ class IsoHuntBridge extends BridgeAbstract {
$timestamp = strtotime($matches[1]); $timestamp = strtotime($matches[1]);
// Make sure date is not in the future (dates are given like 'Nov. 20' without year) // Make sure date is not in the future (dates are given like 'Nov. 20' without year)
if($timestamp > time()){ if($timestamp > time()) {
$timestamp = strtotime('-1 year', $timestamp); $timestamp = strtotime('-1 year', $timestamp);
} }
@ -345,12 +345,12 @@ class IsoHuntBridge extends BridgeAbstract {
returnServerError('Unable to find content!'); returnServerError('Unable to find content!');
// Remove <h2>...</h2> (title) // Remove <h2>...</h2> (title)
foreach($content->find('h2') as $element){ foreach($content->find('h2') as $element) {
$element->outertext = ''; $element->outertext = '';
} }
// Remove <small>...</small> (author) // Remove <small>...</small> (author)
foreach($content->find('small') as $element){ foreach($content->find('small') as $element) {
$element->outertext = ''; $element->outertext = '';
} }
@ -370,7 +370,7 @@ class IsoHuntBridge extends BridgeAbstract {
if(!$torrents) if(!$torrents)
returnServerError('Unable to find torrents!'); returnServerError('Unable to find torrents!');
foreach($torrents as $torrent){ foreach($torrents as $torrent) {
$item = array(); $item = array();
$item['uri'] = $this->latestTorrentsExtractUri($torrent); $item['uri'] = $this->latestTorrentsExtractUri($torrent);
@ -444,7 +444,7 @@ class IsoHuntBridge extends BridgeAbstract {
} }
private function buildCategoryUri($category, $order_popularity = false){ private function buildCategoryUri($category, $order_popularity = false){
switch($category){ switch($category) {
case 'anime': $index = 1; break; case 'anime': $index = 1; break;
case 'software' : $index = 2; break; case 'software' : $index = 2; break;
case 'games' : $index = 3; break; case 'games' : $index = 3; break;

View file

@ -38,7 +38,7 @@ class JapanExpoBridge extends BridgeAbstract {
} }
$convert_article_images = function($matches){ $convert_article_images = function($matches){
if(is_array($matches) && count($matches) > 1){ if(is_array($matches) && count($matches) > 1) {
return '<img src="' . $matches[1] . '" />'; return '<img src="' . $matches[1] . '" />';
} }
}; };
@ -48,7 +48,7 @@ class JapanExpoBridge extends BridgeAbstract {
$fullcontent = $this->getInput('mode'); $fullcontent = $this->getInput('mode');
$count = 0; $count = 0;
foreach($html->find('a._tile2') as $element){ foreach($html->find('a._tile2') as $element) {
$url = $element->href; $url = $element->href;
$thumbnail = 'http://s.japan-expo.com/katana/images/JES049/paris.png'; $thumbnail = 'http://s.japan-expo.com/katana/images/JES049/paris.png';
@ -57,8 +57,8 @@ class JapanExpoBridge extends BridgeAbstract {
if(count($img_search_result) >= 2) if(count($img_search_result) >= 2)
$thumbnail = trim($img_search_result[1], "'"); $thumbnail = trim($img_search_result[1], "'");
if($fullcontent){ if($fullcontent) {
if($count >= 5){ if($count >= 5) {
break; break;
} }

View file

@ -49,23 +49,22 @@ class KATBridge extends BridgeAbstract {
return $timestamp; return $timestamp;
} }
$catBool = $this->getInput('cat_check'); $catBool = $this->getInput('cat_check');
if($catBool){ if($catBool) {
$catNum = $this->getInput('cat'); $catNum = $this->getInput('cat');
} }
$critList = $this->getInput('crit'); $critList = $this->getInput('crit');
$trustedBool = $this->getInput('trusted'); $trustedBool = $this->getInput('trusted');
$keywordsList = explode(';', $this->getInput('q')); $keywordsList = explode(';', $this->getInput('q'));
foreach($keywordsList as $keywords){ foreach($keywordsList as $keywords) {
switch($critList){ switch($critList) {
case 'search': case 'search':
if($catBool == false){ if($catBool == false) {
$html = getSimpleHTMLDOM( $html = getSimpleHTMLDOM(
self::URI . self::URI .
'torrents-search.php?search=' . 'torrents-search.php?search=' .
rawurlencode($keywords) rawurlencode($keywords)
) or returnServerError('Could not request KAT.'); ) or returnServerError('Could not request KAT.');
} } else {
else {
$html = getSimpleHTMLDOM( $html = getSimpleHTMLDOM(
self::URI . self::URI .
'torrents-search.php?search=' . 'torrents-search.php?search=' .
@ -92,10 +91,10 @@ class KATBridge extends BridgeAbstract {
} }
if ($html->find('table.ttable_headinner', 0) == false) if ($html->find('table.ttable_headinner', 0) == false)
returnServerError('No result for query ' . $keywords); returnServerError('No result for query ' . $keywords);
foreach($html->find('tr.t-row') as $element){ foreach($html->find('tr.t-row') as $element) {
if(!$trustedBool if(!$trustedBool
|| !is_null($element->find('i[title="Elite Uploader"]', 0)) || !is_null($element->find('i[title="Elite Uploader"]', 0))
|| !is_null($element->find('i[title="Verified Uploader"]', 0))){ || !is_null($element->find('i[title="Verified Uploader"]', 0))) {
$item = array(); $item = array();
$item['uri'] = self::URI . $element->find('a', 2)->href; $item['uri'] = self::URI . $element->find('a', 2)->href;
$item['id'] = self::URI . $element->find('a.cellMainLink', 0)->href; $item['id'] = self::URI . $element->find('a.cellMainLink', 0)->href;

View file

@ -66,18 +66,18 @@ class KernelBugTrackerBridge extends BridgeAbstract {
// Get and limit comments // Get and limit comments
$comments = $html->find('div.bz_comment'); $comments = $html->find('div.bz_comment');
if($limit > 0 && count($comments) > $limit){ if($limit > 0 && count($comments) > $limit) {
$comments = array_slice($comments, count($comments) - $limit, $limit); $comments = array_slice($comments, count($comments) - $limit, $limit);
} }
// Order comments // Order comments
switch($sorting){ switch($sorting) {
case 'lf': $comments = array_reverse($comments, true); case 'lf': $comments = array_reverse($comments, true);
case 'of': case 'of':
default: // Nothing to do, keep original order default: // Nothing to do, keep original order
} }
foreach($comments as $comment){ foreach($comments as $comment) {
$comment = $this->inlineStyles($comment); $comment = $this->inlineStyles($comment);
$item = array(); $item = array();
@ -99,7 +99,7 @@ class KernelBugTrackerBridge extends BridgeAbstract {
} }
public function getURI(){ public function getURI(){
switch($this->queriedContext){ switch($this->queriedContext) {
case 'Bug comments': case 'Bug comments':
return parent::getURI() return parent::getURI()
. '/show_bug.cgi?id=' . '/show_bug.cgi?id='
@ -110,7 +110,7 @@ class KernelBugTrackerBridge extends BridgeAbstract {
} }
public function getName(){ public function getName(){
switch($this->queriedContext){ switch($this->queriedContext) {
case 'Bug comments': case 'Bug comments':
return 'Bug ' return 'Bug '
. $this->bugid . $this->bugid
@ -142,7 +142,7 @@ class KernelBugTrackerBridge extends BridgeAbstract {
* attributes. * attributes.
*/ */
private function inlineStyles($html){ private function inlineStyles($html){
foreach($html->find('.bz_obsolete') as $element){ foreach($html->find('.bz_obsolete') as $element) {
$element->style = 'text-decoration:line-through;'; $element->style = 'text-decoration:line-through;';
} }

View file

@ -41,13 +41,13 @@ class KununuBridge extends BridgeAbstract {
private $companyName = ''; private $companyName = '';
public function getURI(){ public function getURI(){
if(!is_null($this->getInput('company')) && !is_null($this->getInput('site'))){ if(!is_null($this->getInput('company')) && !is_null($this->getInput('site'))) {
$company = $this->fixCompanyName($this->getInput('company')); $company = $this->fixCompanyName($this->getInput('company'));
$site = $this->getInput('site'); $site = $this->getInput('site');
$section = ''; $section = '';
switch($site){ switch($site) {
case 'at': case 'at':
case 'de': case 'de':
case 'ch': case 'ch':
@ -65,7 +65,7 @@ class KununuBridge extends BridgeAbstract {
} }
function getName(){ function getName(){
if(!is_null($this->getInput('company'))){ if(!is_null($this->getInput('company'))) {
$company = $this->fixCompanyName($this->getInput('company')); $company = $this->fixCompanyName($this->getInput('company'));
return ($this->companyName ?: $company) . ' - ' . self::NAME; return ($this->companyName ?: $company) . ' - ' . self::NAME;
} }
@ -94,7 +94,7 @@ class KununuBridge extends BridgeAbstract {
returnServerError('Unable to find articles!'); returnServerError('Unable to find articles!');
// Go through all articles // Go through all articles
foreach($articles as $article){ foreach($articles as $article) {
$item = array(); $item = array();
$item['author'] = $this->extractArticleAuthorPosition($article); $item['author'] = $this->extractArticleAuthorPosition($article);
@ -208,8 +208,8 @@ class KununuBridge extends BridgeAbstract {
// Go through all h2 elements to find index of required span (I know... it's stupid) // Go through all h2 elements to find index of required span (I know... it's stupid)
$author_position = 'Unknown'; $author_position = 'Unknown';
foreach($user_content->find('div') as $content){ foreach($user_content->find('div') as $content) {
if(stristr(strtolower($content->plaintext), 'position')){ /* This works for at, ch, de, us */ if(stristr(strtolower($content->plaintext), 'position')) { /* This works for at, ch, de, us */
$author_position = $content->next_sibling()->plaintext; $author_position = $content->next_sibling()->plaintext;
break; break;
} }

View file

@ -11,9 +11,9 @@ class LWNprevBridge extends BridgeAbstract{
} }
private function jumpToNextTag(&$node){ private function jumpToNextTag(&$node){
while($node && $node->nodeType === XML_TEXT_NODE){ while($node && $node->nodeType === XML_TEXT_NODE) {
$nextNode = $node->nextSibling; $nextNode = $node->nextSibling;
if(!$nextNode){ if(!$nextNode) {
break; break;
} }
$node = $nextNode; $node = $nextNode;
@ -21,9 +21,9 @@ class LWNprevBridge extends BridgeAbstract{
} }
private function jumpToPreviousTag(&$node){ private function jumpToPreviousTag(&$node){
while($node && $node->nodeType === XML_TEXT_NODE){ while($node && $node->nodeType === XML_TEXT_NODE) {
$previousNode = $node->previousSibling; $previousNode = $node->previousSibling;
if(!$previousNode){ if(!$previousNode) {
break; break;
} }
$node = $previousNode; $node = $previousNode;
@ -44,8 +44,8 @@ class LWNprevBridge extends BridgeAbstract{
$cat1 = ''; $cat1 = '';
$cat2 = ''; $cat2 = '';
foreach($html->getElementsByTagName('a') as $a){ foreach($html->getElementsByTagName('a') as $a) {
if($a->textContent === 'Multi-page format'){ if($a->textContent === 'Multi-page format') {
break; break;
} }
} }
@ -57,8 +57,8 @@ class LWNprevBridge extends BridgeAbstract{
substr($edition, strpos($edition, 'for ') + strlen('for ')) substr($edition, strpos($edition, 'for ') + strlen('for '))
); );
foreach($html->getElementsByTagName('h2') as $h2){ foreach($html->getElementsByTagName('h2') as $h2) {
if($h2->getAttribute('class') !== 'SummaryHL'){ if($h2->getAttribute('class') !== 'SummaryHL') {
continue; continue;
} }
@ -67,7 +67,7 @@ class LWNprevBridge extends BridgeAbstract{
$h2NextSibling = $h2->nextSibling; $h2NextSibling = $h2->nextSibling;
$this->jumpToNextTag($h2NextSibling); $this->jumpToNextTag($h2NextSibling);
switch($h2NextSibling->getAttribute('class')){ switch($h2NextSibling->getAttribute('class')) {
case 'FeatureByline': case 'FeatureByline':
$item['author'] = $h2NextSibling->getElementsByTagName('b')->item(0)->textContent; $item['author'] = $h2NextSibling->getElementsByTagName('b')->item(0)->textContent;
break; break;
@ -82,9 +82,9 @@ class LWNprevBridge extends BridgeAbstract{
$h2FirstChild = $h2->firstChild; $h2FirstChild = $h2->firstChild;
$this->jumpToNextTag($h2FirstChild); $this->jumpToNextTag($h2FirstChild);
if($h2FirstChild->nodeName === 'a'){ if($h2FirstChild->nodeName === 'a') {
$item['uri'] = self::URI . $h2FirstChild->getAttribute('href'); $item['uri'] = self::URI . $h2FirstChild->getAttribute('href');
}else{ } else{
$item['uri'] = $realURI . '#' . $URICounter; $item['uri'] = $realURI . '#' . $URICounter;
} }
$URICounter++; $URICounter++;
@ -93,12 +93,12 @@ class LWNprevBridge extends BridgeAbstract{
$h2PrevSibling = $h2->previousSibling; $h2PrevSibling = $h2->previousSibling;
$this->jumpToPreviousTag($h2PrevSibling); $this->jumpToPreviousTag($h2PrevSibling);
switch($h2PrevSibling->getAttribute('class')){ switch($h2PrevSibling->getAttribute('class')) {
case 'Cat2HL': case 'Cat2HL':
$cat2 = $h2PrevSibling->textContent; $cat2 = $h2PrevSibling->textContent;
$h2PrevSibling = $h2PrevSibling->previousSibling; $h2PrevSibling = $h2PrevSibling->previousSibling;
$this->jumpToPreviousTag($h2PrevSibling); $this->jumpToPreviousTag($h2PrevSibling);
if($h2PrevSibling->getAttribute('class') !== 'Cat1HL'){ if($h2PrevSibling->getAttribute('class') !== 'Cat1HL') {
break; break;
} }
$cat1 = $h2PrevSibling->textContent; $cat1 = $h2PrevSibling->textContent;
@ -113,7 +113,7 @@ class LWNprevBridge extends BridgeAbstract{
$h2PrevSibling = null; $h2PrevSibling = null;
$item['title'] = ''; $item['title'] = '';
if(!empty($cat1)){ if(!empty($cat1)) {
$item['title'] .= '[' . $cat1 . ($cat2 ? '/' . $cat2 : '') . '] '; $item['title'] .= '[' . $cat1 . ($cat2 ? '/' . $cat2 : '') . '] ';
} }
$item['title'] .= $h2->textContent; $item['title'] .= $h2->textContent;
@ -121,7 +121,7 @@ class LWNprevBridge extends BridgeAbstract{
$node = $h2; $node = $h2;
$content = ''; $content = '';
$contentEnd = false; $contentEnd = false;
while(!$contentEnd){ while(!$contentEnd) {
$node = $node->nextSibling; $node = $node->nextSibling;
if(!$node || ( if(!$node || (
$node->nodeType !== XML_TEXT_NODE && ( $node->nodeType !== XML_TEXT_NODE && (
@ -132,9 +132,9 @@ class LWNprevBridge extends BridgeAbstract{
) )
) )
) )
){ ) {
$contentEnd = true; $contentEnd = true;
}else{ } else{
$content .= $node->C14N(); $content .= $node->C14N();
} }
} }

View file

@ -141,7 +141,7 @@ region, and optionally a category and a keyword .';
public function collectData(){ public function collectData(){
$category = $this->getInput('c'); $category = $this->getInput('c');
if(empty($category)){ if(empty($category)) {
$category = 'annonces'; $category = 'annonces';
} }
@ -154,13 +154,13 @@ region, and optionally a category and a keyword .';
or returnServerError('Could not request LeBonCoin.'); or returnServerError('Could not request LeBonCoin.');
$list = $html->find('.tabsContent', 0); $list = $html->find('.tabsContent', 0);
if($list === null){ if($list === null) {
return; return;
} }
$tags = $list->find('li'); $tags = $list->find('li');
foreach($tags as $element){ foreach($tags as $element) {
$element = $element->find('a', 0); $element = $element->find('a', 0);
@ -169,7 +169,7 @@ region, and optionally a category and a keyword .';
$title = html_entity_decode($element->getAttribute('title')); $title = html_entity_decode($element->getAttribute('title'));
$content_image = $element->find('div.item_image', 0)->find('.lazyload', 0); $content_image = $element->find('div.item_image', 0)->find('.lazyload', 0);
if($content_image !== null){ if($content_image !== null) {
$content = '<img src="' . $content_image->getAttribute('data-imgsrc') . '" alt="thumbnail">'; $content = '<img src="' . $content_image->getAttribute('data-imgsrc') . '" alt="thumbnail">';
} else { } else {
$content = ""; $content = "";

View file

@ -27,7 +27,7 @@ class LeMondeInformatiqueBridge extends FeedExpander {
} }
private function stripWithDelimiters($string, $start, $end){ private function stripWithDelimiters($string, $start, $end){
while(strpos($string, $start) !== false){ while(strpos($string, $start) !== false) {
$section_to_remove = substr($string, strpos($string, $start)); $section_to_remove = substr($string, strpos($string, $start));
$section_to_remove = substr($section_to_remove, 0, strpos($section_to_remove, $end) + strlen($end)); $section_to_remove = substr($section_to_remove, 0, strpos($section_to_remove, $end) + strlen($end));
$string = str_replace($section_to_remove, '', $string); $string = str_replace($section_to_remove, '', $string);

View file

@ -19,10 +19,10 @@ class LegifranceJOBridge extends BridgeAbstract {
$item['uri'] = $this->uri . '#' . count($this->items); $item['uri'] = $this->uri . '#' . count($this->items);
$item['title'] = $section->plaintext; $item['title'] = $section->plaintext;
if(!is_null($origin)){ if(!is_null($origin)) {
$item['title'] = '[ ' . $item['title'] . ' / ' . $subsection->plaintext . ' ] ' . $origin->plaintext; $item['title'] = '[ ' . $item['title'] . ' / ' . $subsection->plaintext . ' ] ' . $origin->plaintext;
$data = $origin; $data = $origin;
} elseif(!is_null($subsection)){ } elseif(!is_null($subsection)) {
$item['title'] = '[ ' . $item['title'] . ' ] ' . $subsection->plaintext; $item['title'] = '[ ' . $item['title'] . ' ] ' . $subsection->plaintext;
$data = $subsection; $data = $subsection;
} else { } else {
@ -30,7 +30,7 @@ class LegifranceJOBridge extends BridgeAbstract {
} }
$item['content'] = ''; $item['content'] = '';
foreach($data->nextSibling()->find('a') as $content){ foreach($data->nextSibling()->find('a') as $content) {
$text = $content->plaintext; $text = $content->plaintext;
$href = $content->nextSibling()->getAttribute('resource'); $href = $content->nextSibling()->getAttribute('resource');
$item['content'] .= '<p><a href="' . $href . '">' . $text . '</a></p>'; $item['content'] .= '<p><a href="' . $href . '">' . $text . '</a></p>';
@ -47,19 +47,19 @@ class LegifranceJOBridge extends BridgeAbstract {
$this->uri = trim(substr($uri, strpos($uri, 'https'))); $this->uri = trim(substr($uri, strpos($uri, 'https')));
$this->timestamp = strtotime(substr($this->uri, strpos($this->uri, 'eli/jo/') + strlen('eli/jo/'))); $this->timestamp = strtotime(substr($this->uri, strpos($this->uri, 'eli/jo/') + strlen('eli/jo/')));
foreach($html->find('h3') as $section){ foreach($html->find('h3') as $section) {
$subsections = $section->nextSibling()->find('h4'); $subsections = $section->nextSibling()->find('h4');
foreach($subsections as $subsection){ foreach($subsections as $subsection) {
$origins = $subsection->nextSibling()->find('h5'); $origins = $subsection->nextSibling()->find('h5');
foreach($origins as $origin){ foreach($origins as $origin) {
$this->items[] = $this->extractItem($section, $subsection, $origin); $this->items[] = $this->extractItem($section, $subsection, $origin);
} }
if(!empty($origins)){ if(!empty($origins)) {
continue; continue;
} }
$this->items[] = $this->extractItem($section, $subsection); $this->items[] = $this->extractItem($section, $subsection);
} }
if(!empty($subsections)){ if(!empty($subsections)) {
continue; continue;
} }
$this->items[] = $this->extractItem($section); $this->items[] = $this->extractItem($section);

View file

@ -11,7 +11,7 @@ class LesJoiesDuCodeBridge extends BridgeAbstract {
$html = getSimpleHTMLDOM(self::URI) $html = getSimpleHTMLDOM(self::URI)
or returnServerError('Could not request LesJoiesDuCode.'); or returnServerError('Could not request LesJoiesDuCode.');
foreach($html->find('div.blog-post') as $element){ foreach($html->find('div.blog-post') as $element) {
$item = array(); $item = array();
$temp = $element->find('h1 a', 0); $temp = $element->find('h1 a', 0);
$titre = html_entity_decode($temp->innertext); $titre = html_entity_decode($temp->innertext);
@ -21,7 +21,7 @@ class LesJoiesDuCodeBridge extends BridgeAbstract {
// retrieve .gif instead of static .jpg // retrieve .gif instead of static .jpg
$images = $temp->find('p img'); $images = $temp->find('p img');
foreach($images as $image){ foreach($images as $image) {
$img_src = str_replace(".jpg", ".gif", $image->src); $img_src = str_replace(".jpg", ".gif", $image->src);
$image->src = $img_src; $image->src = $img_src;
} }
@ -30,7 +30,7 @@ class LesJoiesDuCodeBridge extends BridgeAbstract {
$auteur = $temp->find('i', 0); $auteur = $temp->find('i', 0);
$pos = strpos($auteur->innertext, "by"); $pos = strpos($auteur->innertext, "by");
if($pos > 0){ if($pos > 0) {
$auteur = trim(str_replace("*/", "", substr($auteur->innertext, ($pos + 2)))); $auteur = trim(str_replace("*/", "", substr($auteur->innertext, ($pos + 2))));
$item['author'] = $auteur; $item['author'] = $auteur;
} }

View file

@ -22,9 +22,9 @@ class LinkedInCompanyBridge extends BridgeAbstract {
$html = getSimpleHTMLDOM($link) $html = getSimpleHTMLDOM($link)
or returnServerError('Could not request LinkedIn.'); or returnServerError('Could not request LinkedIn.');
foreach($html->find('//*[@id="my-feed-post"]/li') as $element){ foreach($html->find('//*[@id="my-feed-post"]/li') as $element) {
$title = $element->find('span.share-body', 0)->innertext; $title = $element->find('span.share-body', 0)->innertext;
if($title){ if($title) {
$item = array(); $item = array();
$item['uri'] = $link; $item['uri'] = $link;
$item['title'] = mb_substr(strip_tags($element->find('span.share-body', 0)->innertext), 0, 100); $item['title'] = mb_substr(strip_tags($element->find('span.share-body', 0)->innertext), 0, 100);

View file

@ -80,7 +80,7 @@ class MangareaderBridge extends BridgeAbstract {
public function collectData(){ public function collectData(){
// We'll use the DOM parser for this as it makes navigation easier // We'll use the DOM parser for this as it makes navigation easier
$html = getContents($this->getURI()); $html = getContents($this->getURI());
if(!$html){ if(!$html) {
returnClientError('Could not receive data for ' . $path . '!'); returnClientError('Could not receive data for ' . $path . '!');
} }
libxml_use_internal_errors(true); libxml_use_internal_errors(true);
@ -92,7 +92,7 @@ class MangareaderBridge extends BridgeAbstract {
$xpath = new DomXPath($doc); $xpath = new DomXPath($doc);
$this->request = ''; $this->request = '';
switch($this->queriedContext){ switch($this->queriedContext) {
case 'Get latest updates': case 'Get latest updates':
$this->request = 'Latest updates'; $this->request = 'Latest updates';
$this->getLatestUpdates($xpath); $this->getLatestUpdates($xpath);
@ -105,7 +105,7 @@ class MangareaderBridge extends BridgeAbstract {
break; break;
case 'Get manga updates': case 'Get manga updates':
$limit = $this->getInput('limit'); $limit = $this->getInput('limit');
if(empty($limit)){ if(empty($limit)) {
$limit = self::PARAMETERS[$this->queriedContext]['limit']['defaultValue']; $limit = self::PARAMETERS[$this->queriedContext]['limit']['defaultValue'];
} }
@ -118,7 +118,7 @@ class MangareaderBridge extends BridgeAbstract {
} }
// Return some dummy-data if no content available // Return some dummy-data if no content available
if(empty($this->items)){ if(empty($this->items)) {
$item = array(); $item = array();
$item['content'] = "<p>No updates available</p>"; $item['content'] = "<p>No updates available</p>";
@ -130,14 +130,14 @@ class MangareaderBridge extends BridgeAbstract {
// Query each item (consists of Manga + chapters) // Query each item (consists of Manga + chapters)
$nodes = $xpath->query("//*[@id='latestchapters']/table//td"); $nodes = $xpath->query("//*[@id='latestchapters']/table//td");
foreach ($nodes as $node){ foreach ($nodes as $node) {
// Query the manga // Query the manga
$manga = $xpath->query("a[@class='chapter']", $node)->item(0); $manga = $xpath->query("a[@class='chapter']", $node)->item(0);
// Collect the chapters for each Manga // Collect the chapters for each Manga
$chapters = $xpath->query("a[@class='chaptersrec']", $node); $chapters = $xpath->query("a[@class='chaptersrec']", $node);
if (isset($manga) && $chapters->length >= 1){ if (isset($manga) && $chapters->length >= 1) {
$item = array(); $item = array();
$item['uri'] = self::URI . htmlspecialchars($manga->getAttribute('href')); $item['uri'] = self::URI . htmlspecialchars($manga->getAttribute('href'));
$item['title'] = htmlspecialchars($manga->nodeValue); $item['title'] = htmlspecialchars($manga->nodeValue);
@ -145,8 +145,8 @@ class MangareaderBridge extends BridgeAbstract {
// Add each chapter to the feed // Add each chapter to the feed
$item['content'] = ""; $item['content'] = "";
foreach ($chapters as $chapter){ foreach ($chapters as $chapter) {
if($item['content'] <> ""){ if($item['content'] <> "") {
$item['content'] .= "<br>"; $item['content'] .= "<br>";
} }
$item['content'] .= "<a href='" $item['content'] .= "<a href='"
@ -166,7 +166,7 @@ class MangareaderBridge extends BridgeAbstract {
// Query all mangas // Query all mangas
$mangas = $xpath->query("//*[@id='mangaresults']/*[@class='mangaresultitem']"); $mangas = $xpath->query("//*[@id='mangaresults']/*[@class='mangaresultitem']");
foreach ($mangas as $manga){ foreach ($mangas as $manga) {
// The thumbnail is encrypted in a css-style... // The thumbnail is encrypted in a css-style...
// format: "background-image:url('<the part which is actually interesting>')" // format: "background-image:url('<the part which is actually interesting>')"
@ -203,13 +203,13 @@ EOD;
private function getMangaUpdates($xpath, $limit){ private function getMangaUpdates($xpath, $limit){
$query = "(.//*[@id='listing']//tr)[position() > 1]"; $query = "(.//*[@id='listing']//tr)[position() > 1]";
if($limit !== -1){ if($limit !== -1) {
$query = "(.//*[@id='listing']//tr)[position() > 1][position() > last() - {$limit}]"; $query = "(.//*[@id='listing']//tr)[position() > 1][position() > last() - {$limit}]";
} }
$chapters = $xpath->query($query); $chapters = $xpath->query($query);
foreach ($chapters as $chapter){ foreach ($chapters as $chapter) {
$item = array(); $item = array();
$item['title'] = htmlspecialchars($xpath->query("td[1]", $chapter) $item['title'] = htmlspecialchars($xpath->query("td[1]", $chapter)
->item(0) ->item(0)
@ -225,13 +225,13 @@ EOD;
} }
public function getURI(){ public function getURI(){
switch($this->queriedContext){ switch($this->queriedContext) {
case 'Get latest updates': case 'Get latest updates':
$path = "latest"; $path = "latest";
break; break;
case 'Get popular mangas': case 'Get popular mangas':
$path = "popular"; $path = "popular";
if($this->getInput('category') !== "all"){ if($this->getInput('category') !== "all") {
$path .= "/" . $this->getInput('category'); $path .= "/" . $this->getInput('category');
} }
break; break;

View file

@ -16,7 +16,7 @@ class MixCloudBridge extends BridgeAbstract {
)); ));
public function getName(){ public function getName(){
if(!is_null($this->getInput('u'))){ if(!is_null($this->getInput('u'))) {
return 'MixCloud - ' . $this->getInput('u'); return 'MixCloud - ' . $this->getInput('u');
} }
@ -28,7 +28,7 @@ class MixCloudBridge extends BridgeAbstract {
$html = getSimpleHTMLDOM(self::URI . $this->getInput('u')) $html = getSimpleHTMLDOM(self::URI . $this->getInput('u'))
or returnServerError('Could not request MixCloud.'); or returnServerError('Could not request MixCloud.');
foreach($html->find('section.card') as $element){ foreach($html->find('section.card') as $element) {
$item = array(); $item = array();
@ -40,7 +40,7 @@ class MixCloudBridge extends BridgeAbstract {
$image = $element->find('a.album-art img', 0); $image = $element->find('a.album-art img', 0);
if($image){ if($image) {
$item['content'] = '<img src="' . $image->getAttribute('src') . '" />'; $item['content'] = '<img src="' . $image->getAttribute('src') . '" />';
} }

View file

@ -35,7 +35,7 @@ class MoebooruBridge extends BridgeAbstract {
$data[] = preg_replace('/}\)(.*)/', '}', $element); $data[] = preg_replace('/}\)(.*)/', '}', $element);
unset($data[0]); unset($data[0]);
foreach($data as $datai){ foreach($data as $datai) {
$json = json_decode($datai, true); $json = json_decode($datai, true);
$item = array(); $item = array();
$item['uri'] = $this->getURI() . '/post/show/' . $json['id']; $item['uri'] = $this->getURI() . '/post/show/' . $json['id'];

View file

@ -92,17 +92,17 @@ class MoinMoinBridge extends BridgeAbstract {
$sections = $this->splitSections($html); $sections = $this->splitSections($html);
foreach($sections as $section){ foreach($sections as $section) {
$item = array(); $item = array();
$item['uri'] = $this->findSectionAnchor($section[0]); $item['uri'] = $this->findSectionAnchor($section[0]);
switch($this->getInput('content')){ switch($this->getInput('content')) {
case 'none': // Do not return any content case 'none': // Do not return any content
break; break;
case 'follow': // Follow the anchor case 'follow': // Follow the anchor
// We can only follow anchors (use default otherwise) // We can only follow anchors (use default otherwise)
if($this->getInput('separator') === 'a'){ if($this->getInput('separator') === 'a') {
$content = $this->followAnchor($item['uri']); $content = $this->followAnchor($item['uri']);
// Return only actual content // Return only actual content
@ -124,14 +124,14 @@ class MoinMoinBridge extends BridgeAbstract {
$item['title'] = strip_tags($section[1]); $item['title'] = strip_tags($section[1]);
// Skip items with empty title // Skip items with empty title
if(empty(trim($item['title']))){ if(empty(trim($item['title']))) {
continue; continue;
} }
$this->items[] = $item; $this->items[] = $item;
if($this->getInput('limit') > 0 if($this->getInput('limit') > 0
&& count($this->items) >= $this->getInput('limit')){ && count($this->items) >= $this->getInput('limit')) {
break; break;
} }
} }
@ -177,7 +177,7 @@ class MoinMoinBridge extends BridgeAbstract {
); );
// Some pages don't use headers, return page as one feed // Some pages don't use headers, return page as one feed
if(count($sections) === 0){ if(count($sections) === 0) {
return array( return array(
array( array(
$content, $content,
@ -198,13 +198,13 @@ class MoinMoinBridge extends BridgeAbstract {
// For IDs // For IDs
$anchor = $html->find($this->getInput('separator') . '[id=]', 0); $anchor = $html->find($this->getInput('separator') . '[id=]', 0);
if(!is_null($anchor)){ if(!is_null($anchor)) {
return $this->getInput('source') . '#' . $anchor->id; return $this->getInput('source') . '#' . $anchor->id;
} }
// For actual anchors // For actual anchors
$anchor = $html->find($this->getInput('separator') . '[href=]', 0); $anchor = $html->find($this->getInput('separator') . '[href=]', 0);
if(!is_null($anchor)){ if(!is_null($anchor)) {
return $anchor->href; return $anchor->href;
} }
@ -225,11 +225,11 @@ class MoinMoinBridge extends BridgeAbstract {
*/ */
$pageinfo = $html->find('[id="pageinfo"]', 0); $pageinfo = $html->find('[id="pageinfo"]', 0);
if(is_null($pageinfo)){ if(is_null($pageinfo)) {
return null; return null;
} else { } else {
$author = $pageinfo->find('[title=]', 0); $author = $pageinfo->find('[title=]', 0);
if(is_null($author)){ if(is_null($author)) {
return null; return null;
} else { } else {
return trim(explode('@', $author->title)[0]); return trim(explode('@', $author->title)[0]);
@ -246,7 +246,7 @@ class MoinMoinBridge extends BridgeAbstract {
// See example of findAuthor() // See example of findAuthor()
$pageinfo = $html->find('[id="pageinfo"]', 0); $pageinfo = $html->find('[id="pageinfo"]', 0);
if(is_null($pageinfo)){ if(is_null($pageinfo)) {
return null; return null;
} else { } else {
$timestamp = $pageinfo->innertext; $timestamp = $pageinfo->innertext;
@ -264,8 +264,8 @@ class MoinMoinBridge extends BridgeAbstract {
$source = $source ?: $this->getURI(); $source = $source ?: $this->getURI();
foreach($html->find('a') as $anchor){ foreach($html->find('a') as $anchor) {
switch(substr($anchor->href, 0, 1)){ switch(substr($anchor->href, 0, 1)) {
case 'h': // http or https, no actions required case 'h': // http or https, no actions required
break; break;
case '/': // some relative path case '/': // some relative path
@ -287,12 +287,12 @@ class MoinMoinBridge extends BridgeAbstract {
* wiki domain) * wiki domain)
*/ */
private function followAnchor($anchor){ private function followAnchor($anchor){
if(strrpos($anchor, $this->findDomain($this->getInput('source')) === false)){ if(strrpos($anchor, $this->findDomain($this->getInput('source')) === false)) {
return null; return null;
} }
$html = getSimpleHTMLDOMCached($anchor); $html = getSimpleHTMLDOMCached($anchor);
if(!$html){ // Cannot load article if(!$html) { // Cannot load article
return null; return null;
} }
@ -310,7 +310,7 @@ class MoinMoinBridge extends BridgeAbstract {
/* This function is a copy from CNETBridge */ /* This function is a copy from CNETBridge */
private function stripWithDelimiters($string, $start, $end){ private function stripWithDelimiters($string, $start, $end){
while(strpos($string, $start) !== false){ while(strpos($string, $start) !== false) {
$section_to_remove = substr($string, strpos($string, $start)); $section_to_remove = substr($string, strpos($string, $start));
$section_to_remove = substr($section_to_remove, 0, strpos($section_to_remove, $end) + strlen($end)); $section_to_remove = substr($section_to_remove, 0, strpos($section_to_remove, $end) + strlen($end));
$string = str_replace($section_to_remove, '', $string); $string = str_replace($section_to_remove, '', $string);

View file

@ -11,7 +11,7 @@ class MondeDiploBridge extends BridgeAbstract {
$html = getSimpleHTMLDOM(self::URI) $html = getSimpleHTMLDOM(self::URI)
or returnServerError('Could not request MondeDiplo. for : ' . self::URI); or returnServerError('Could not request MondeDiplo. for : ' . self::URI);
foreach($html->find('div.unarticle') as $article){ foreach($html->find('div.unarticle') as $article) {
$element = $article->parent(); $element = $article->parent();
$item = array(); $item = array();
$item['uri'] = self::URI . $element->href; $item['uri'] = self::URI . $element->href;

View file

@ -21,8 +21,8 @@ class MsnMondeBridge extends BridgeAbstract {
or returnServerError('Could not request MsnMonde.'); or returnServerError('Could not request MsnMonde.');
$limit = 0; $limit = 0;
foreach($html->find('.smalla') as $article){ foreach($html->find('.smalla') as $article) {
if($limit < 10){ if($limit < 10) {
$item = array(); $item = array();
$item['title'] = utf8_decode($article->find('h4', 0)->innertext); $item['title'] = utf8_decode($article->find('h4', 0)->innertext);
$item['uri'] = self::URI . utf8_decode($article->find('a', 0)->href); $item['uri'] = self::URI . utf8_decode($article->find('a', 0)->href);

View file

@ -14,7 +14,7 @@ class NasaApodBridge extends BridgeAbstract {
$list = explode("<br>", $html->find('b', 0)->innertext); $list = explode("<br>", $html->find('b', 0)->innertext);
for($i = 0; $i < 3; $i++){ for($i = 0; $i < 3; $i++) {
$line = $list[$i]; $line = $list[$i];
$item = array(); $item = array();

View file

@ -7,7 +7,7 @@ class NeuviemeArtBridge extends FeedExpander {
const DESCRIPTION = 'Returns the newest articles.'; const DESCRIPTION = 'Returns the newest articles.';
private function stripWithDelimiters($string, $start, $end){ private function stripWithDelimiters($string, $start, $end){
while(strpos($string, $start) !== false){ while(strpos($string, $start) !== false) {
$section_to_remove = substr($string, strpos($string, $start)); $section_to_remove = substr($string, strpos($string, $start));
$section_to_remove = substr($section_to_remove, 0, strpos($section_to_remove, $end) + strlen($end)); $section_to_remove = substr($section_to_remove, 0, strpos($section_to_remove, $end) + strlen($end));
$string = str_replace($section_to_remove, '', $string); $string = str_replace($section_to_remove, '', $string);
@ -20,21 +20,21 @@ class NeuviemeArtBridge extends FeedExpander {
$item = parent::parseItem($item); $item = parent::parseItem($item);
$article_html = getSimpleHTMLDOMCached($item['uri']); $article_html = getSimpleHTMLDOMCached($item['uri']);
if(!$article_html){ if(!$article_html) {
$item['content'] = 'Could not request 9eme Art: ' . $item['uri']; $item['content'] = 'Could not request 9eme Art: ' . $item['uri'];
return $item; return $item;
} }
$article_image = ''; $article_image = '';
foreach ($article_html->find('img.img_full') as $img){ foreach ($article_html->find('img.img_full') as $img) {
if ($img->alt == $item['title']){ if ($img->alt == $item['title']) {
$article_image = self::URI . $img->src; $article_image = self::URI . $img->src;
break; break;
} }
} }
$article_content = ''; $article_content = '';
if($article_image){ if($article_image) {
$article_content = '<p><img src="' . $article_image . '" /></p>'; $article_content = '<p><img src="' . $article_image . '" /></p>';
} }
$article_content .= str_replace( $article_content .= str_replace(

View file

@ -35,9 +35,9 @@ class NextgovBridge extends FeedExpander {
$item['content'] = ''; $item['content'] = '';
$namespaces = $newsItem->getNamespaces(true); $namespaces = $newsItem->getNamespaces(true);
if(isset($namespaces['media'])){ if(isset($namespaces['media'])) {
$media = $newsItem->children($namespaces['media']); $media = $newsItem->children($namespaces['media']);
if(isset($media->content)){ if(isset($media->content)) {
$attributes = $media->content->attributes(); $attributes = $media->content->attributes();
$item['content'] = '<img src="' . $attributes['url'] . '">'; $item['content'] = '<img src="' . $attributes['url'] . '">';
} }

View file

@ -17,7 +17,7 @@ class NovelUpdatesBridge extends BridgeAbstract {
private $seriesTitle = ''; private $seriesTitle = '';
public function getURI(){ public function getURI(){
if(!is_null($this->getInput('n'))){ if(!is_null($this->getInput('n'))) {
return static::URI . '/series/' . $this->getInput('n') . '/'; return static::URI . '/series/' . $this->getInput('n') . '/';
} }
@ -35,7 +35,7 @@ class NovelUpdatesBridge extends BridgeAbstract {
$html = stristr($html, '<tbody>'); //strip thead $html = stristr($html, '<tbody>'); //strip thead
$html = stristr($html, '<tr>'); //remove tbody $html = stristr($html, '<tr>'); //remove tbody
$html = str_get_html(stristr($html, '</tbody>', true)); //remove last tbody and get back as an array $html = str_get_html(stristr($html, '</tbody>', true)); //remove last tbody and get back as an array
foreach($html->find('tr') as $element){ foreach($html->find('tr') as $element) {
$item = array(); $item = array();
$item['uri'] = $element->find('td', 2)->find('a', 0)->href; $item['uri'] = $element->find('td', 2)->find('a', 0)->href;
$item['title'] = $element->find('td', 2)->find('a', 0)->plaintext; $item['title'] = $element->find('td', 2)->find('a', 0)->plaintext;
@ -60,7 +60,7 @@ class NovelUpdatesBridge extends BridgeAbstract {
} }
public function getName(){ public function getName(){
if(!empty($this->seriesTitle)){ if(!empty($this->seriesTitle)) {
return $this->seriesTitle . ' - ' . static::NAME; return $this->seriesTitle . ' - ' . static::NAME;
} }

View file

@ -27,7 +27,7 @@ class OpenClassroomsBridge extends BridgeAbstract {
)); ));
public function getURI(){ public function getURI(){
if(!is_null($this->getInput('u'))){ if(!is_null($this->getInput('u'))) {
return self::URI . '/courses?categories=' . $this->getInput('u') . '&title=&sort=updatedAt+desc'; return self::URI . '/courses?categories=' . $this->getInput('u') . '&title=&sort=updatedAt+desc';
} }
@ -38,7 +38,7 @@ class OpenClassroomsBridge extends BridgeAbstract {
$html = getSimpleHTMLDOM($this->getURI()) $html = getSimpleHTMLDOM($this->getURI())
or returnServerError('Could not request OpenClassrooms.'); or returnServerError('Could not request OpenClassrooms.');
foreach($html->find('.courseListItem') as $element){ foreach($html->find('.courseListItem') as $element) {
$item = array(); $item = array();
$item['uri'] = self::URI . $element->find('a', 0)->href; $item['uri'] = self::URI . $element->find('a', 0)->href;
$item['title'] = $element->find('h3', 0)->plaintext; $item['title'] = $element->find('h3', 0)->plaintext;

View file

@ -29,15 +29,15 @@ class ParuVenduImmoBridge extends BridgeAbstract {
$html = getSimpleHTMLDOM($this->getURI()) $html = getSimpleHTMLDOM($this->getURI())
or returnServerError('Could not request paruvendu.'); or returnServerError('Could not request paruvendu.');
foreach($html->find('div.annonce a') as $element){ foreach($html->find('div.annonce a') as $element) {
if(!$element->title){ if(!$element->title) {
continue; continue;
} }
$img = ''; $img = '';
foreach($element->find('span.img img') as $img){ foreach($element->find('span.img img') as $img) {
if($img->original){ if($img->original) {
$img = '<img src="' . $img->original . '" />'; $img = '<img src="' . $img->original . '" />';
} }
} }
@ -65,33 +65,33 @@ class ParuVenduImmoBridge extends BridgeAbstract {
. $appartment . $appartment
. $maison; . $maison;
if($this->getInput('minarea')){ if($this->getInput('minarea')) {
$link .= '&sur0=' . urlencode($this->getInput('minarea')); $link .= '&sur0=' . urlencode($this->getInput('minarea'));
} }
if($this->getInput('maxprice')){ if($this->getInput('maxprice')) {
$link .= '&px1=' . urlencode($this->getInput('maxprice')); $link .= '&px1=' . urlencode($this->getInput('maxprice'));
} }
if($this->getInput('pa')){ if($this->getInput('pa')) {
$link .= '&pa=' . urlencode($this->getInput('pa')); $link .= '&pa=' . urlencode($this->getInput('pa'));
} }
if($this->getInput('lo')){ if($this->getInput('lo')) {
$link .= '&lo=' . urlencode($this->getInput('lo')); $link .= '&lo=' . urlencode($this->getInput('lo'));
} }
return $link; return $link;
} }
public function getName(){ public function getName(){
if(!is_null($this->getInput('minarea'))){ if(!is_null($this->getInput('minarea'))) {
$request = ''; $request = '';
$minarea = $this->getInput('minarea'); $minarea = $this->getInput('minarea');
if(!empty($minarea)){ if(!empty($minarea)) {
$request .= ' ' . $minarea . ' m2'; $request .= ' ' . $minarea . ' m2';
} }
$location = $this->getInput('lo'); $location = $this->getInput('lo');
if(!empty($location)){ if(!empty($location)) {
$request .= ' In: ' . $location; $request .= ' In: ' . $location;
} }
return 'Paru Vendu Immobilier' . $request; return 'Paru Vendu Immobilier' . $request;

View file

@ -34,16 +34,16 @@ class PickyWallpapersBridge extends BridgeAbstract {
$max = $this->getInput('m'); $max = $this->getInput('m');
$resolution = $this->getInput('r'); // Wide wallpaper default $resolution = $this->getInput('r'); // Wide wallpaper default
for($page = 1; $page <= $lastpage; $page++){ for($page = 1; $page <= $lastpage; $page++) {
$html = getSimpleHTMLDOM($this->getURI() . '/page-' . $page . '/') $html = getSimpleHTMLDOM($this->getURI() . '/page-' . $page . '/')
or returnServerError('No results for this query.'); or returnServerError('No results for this query.');
if($page === 1){ if($page === 1) {
preg_match('/page-(\d+)\/$/', $html->find('.pages li a', -2)->href, $matches); preg_match('/page-(\d+)\/$/', $html->find('.pages li a', -2)->href, $matches);
$lastpage = min($matches[1], ceil($max / 12)); $lastpage = min($matches[1], ceil($max / 12));
} }
foreach($html->find('.items li img') as $element){ foreach($html->find('.items li img') as $element) {
$item = array(); $item = array();
$item['uri'] = str_replace('www', 'wallpaper', self::URI) $item['uri'] = str_replace('www', 'wallpaper', self::URI)
. '/' . '/'
@ -70,7 +70,7 @@ class PickyWallpapersBridge extends BridgeAbstract {
} }
public function getURI(){ public function getURI(){
if(!is_null($this->getInput('s')) && !is_null($this->getInput('r')) && !is_null($this->getInput('c'))){ if(!is_null($this->getInput('s')) && !is_null($this->getInput('r')) && !is_null($this->getInput('c'))) {
$subcategory = $this->getInput('s'); $subcategory = $this->getInput('s');
$link = self::URI $link = self::URI
. $this->getInput('r') . $this->getInput('r')
@ -86,7 +86,7 @@ class PickyWallpapersBridge extends BridgeAbstract {
} }
public function getName(){ public function getName(){
if(!is_null($this->getInput('s'))){ if(!is_null($this->getInput('s'))) {
$subcategory = $this->getInput('s'); $subcategory = $this->getInput('s');
return 'PickyWallpapers - ' return 'PickyWallpapers - '
. $this->getInput('c') . $this->getInput('c')

View file

@ -32,9 +32,9 @@ class PinterestBridge extends FeedExpander {
); );
public function collectData(){ public function collectData(){
switch($this->queriedContext){ switch($this->queriedContext) {
case 'By username and board': case 'By username and board':
if($this->getInput('r')){ if($this->getInput('r')) {
$html = getSimpleHTMLDOMCached($this->getURI()); $html = getSimpleHTMLDOMCached($this->getURI());
$this->getUserResults($html); $this->getUserResults($html);
} else { } else {
@ -55,7 +55,7 @@ class PinterestBridge extends FeedExpander {
$fullname = $json['resourceDataCache'][0]['data']['owner']['full_name']; $fullname = $json['resourceDataCache'][0]['data']['owner']['full_name'];
$avatar = $json['resourceDataCache'][0]['data']['owner']['image_small_url']; $avatar = $json['resourceDataCache'][0]['data']['owner']['image_small_url'];
foreach($results as $result){ foreach($results as $result) {
$item = array(); $item = array();
$item['uri'] = $result['link']; $item['uri'] = $result['link'];
@ -97,7 +97,7 @@ class PinterestBridge extends FeedExpander {
$json = json_decode($html->find('#jsInit1', 0)->innertext, true); $json = json_decode($html->find('#jsInit1', 0)->innertext, true);
$results = $json['resourceDataCache'][0]['data']['results']; $results = $json['resourceDataCache'][0]['data']['results'];
foreach($results as $result){ foreach($results as $result) {
$item = array(); $item = array();
$item['uri'] = self::URI . $result['board']['url']; $item['uri'] = self::URI . $result['board']['url'];
@ -136,7 +136,7 @@ class PinterestBridge extends FeedExpander {
} }
public function getURI(){ public function getURI(){
switch($this->queriedContext){ switch($this->queriedContext) {
case 'By username and board': case 'By username and board':
$uri = self::URI . '/' . urlencode($this->getInput('u')) . '/' . urlencode($this->getInput('b'));// . '.rss'; $uri = self::URI . '/' . urlencode($this->getInput('u')) . '/' . urlencode($this->getInput('b'));// . '.rss';
break; break;
@ -149,7 +149,7 @@ class PinterestBridge extends FeedExpander {
} }
public function getName(){ public function getName(){
switch($this->queriedContext){ switch($this->queriedContext) {
case 'By username and board': case 'By username and board':
$specific = $this->getInput('u') . ' - ' . $this->getInput('b'); $specific = $this->getInput('u') . ' - ' . $this->getInput('b');
break; break;

View file

@ -16,8 +16,8 @@ class PlanetLibreBridge extends BridgeAbstract {
$html = getSimpleHTMLDOM(self::URI) $html = getSimpleHTMLDOM(self::URI)
or returnServerError('Could not request PlanetLibre.'); or returnServerError('Could not request PlanetLibre.');
$limit = 0; $limit = 0;
foreach($html->find('div.post') as $element){ foreach($html->find('div.post') as $element) {
if($limit < 5){ if($limit < 5) {
$item = array(); $item = array();
$item['title'] = $element->find('h1', 0)->plaintext; $item['title'] = $element->find('h1', 0)->plaintext;
$item['uri'] = $element->find('a', 0)->href; $item['uri'] = $element->find('a', 0)->href;

View file

@ -22,8 +22,8 @@ class RTBFBridge extends BridgeAbstract {
$html = getSimpleHTMLDOM($this->getURI()) $html = getSimpleHTMLDOM($this->getURI())
or returnServerError('Could not request RTBF.'); or returnServerError('Could not request RTBF.');
foreach($html->find('section[id!=widget-ml-avoiraussi-] .rtbf-media-grid article') as $element){ foreach($html->find('section[id!=widget-ml-avoiraussi-] .rtbf-media-grid article') as $element) {
if($count >= $limit){ if($count >= $limit) {
break; break;
} }
@ -49,7 +49,7 @@ class RTBFBridge extends BridgeAbstract {
} }
public function getURI(){ public function getURI(){
if(!is_null($this->getInput('c'))){ if(!is_null($this->getInput('c'))) {
return self::URI . 'emissions/detail?id=' . $this->getInput('c'); return self::URI . 'emissions/detail?id=' . $this->getInput('c');
} }
@ -57,7 +57,7 @@ class RTBFBridge extends BridgeAbstract {
} }
public function getName(){ public function getName(){
if(!is_null($this->getInput('c'))){ if(!is_null($this->getInput('c'))) {
return $this->getInput('c') .' - RTBF Bridge'; return $this->getInput('c') .' - RTBF Bridge';
} }

View file

@ -17,7 +17,7 @@ class RainbowSixSiegeBridge extends BridgeAbstract {
$json = $json['items']; $json = $json['items'];
// Start at index 2 to remove highlighted articles // Start at index 2 to remove highlighted articles
for($i = 0; $i < count($json); $i++){ for($i = 0; $i < count($json); $i++) {
$jsonItem = $json[$i]['Content']; $jsonItem = $json[$i]['Content'];
$article = str_get_html($jsonItem); $article = str_get_html($jsonItem);

View file

@ -26,11 +26,11 @@ class ReadComicsBridge extends BridgeAbstract {
} }
$keywordsList = explode(";", $this->getInput('q')); $keywordsList = explode(";", $this->getInput('q'));
foreach($keywordsList as $keywords){ foreach($keywordsList as $keywords) {
$html = $this->getSimpleHTMLDOM(self::URI . 'comic/' . rawurlencode($keywords)) $html = $this->getSimpleHTMLDOM(self::URI . 'comic/' . rawurlencode($keywords))
or $this->returnServerError('Could not request readcomics.tv.'); or $this->returnServerError('Could not request readcomics.tv.');
foreach($html->find('li') as $element){ foreach($html->find('li') as $element) {
$item = array(); $item = array();
$item['uri'] = $element->find('a.ch-name', 0)->href; $item['uri'] = $element->find('a.ch-name', 0)->href;
$item['id'] = $item['uri']; $item['id'] = $item['uri'];

View file

@ -10,7 +10,7 @@ class Releases3DSBridge extends BridgeAbstract {
public function collectData(){ public function collectData(){
function extractFromDelimiters($string, $start, $end){ function extractFromDelimiters($string, $start, $end){
if(strpos($string, $start) !== false){ if(strpos($string, $start) !== false) {
$section_retrieved = substr($string, strpos($string, $start) + strlen($start)); $section_retrieved = substr($string, strpos($string, $start) + strlen($start));
$section_retrieved = substr($section_retrieved, 0, strpos($section_retrieved, $end)); $section_retrieved = substr($section_retrieved, 0, strpos($section_retrieved, $end));
return $section_retrieved; return $section_retrieved;
@ -20,7 +20,7 @@ class Releases3DSBridge extends BridgeAbstract {
} }
function typeToString($type){ function typeToString($type){
switch($type){ switch($type) {
case 1: return '3DS Game'; case 1: return '3DS Game';
case 4: return 'eShop'; case 4: return 'eShop';
default: return '??? (' . $type . ')'; default: return '??? (' . $type . ')';
@ -28,7 +28,7 @@ class Releases3DSBridge extends BridgeAbstract {
} }
function cardToString($card){ function cardToString($card){
switch($card){ switch($card) {
case 1: return 'Regular (CARD1)'; case 1: return 'Regular (CARD1)';
case 2: return 'NAND (CARD2)'; case 2: return 'NAND (CARD2)';
default: return '??? (' . $card . ')'; default: return '??? (' . $card . ')';
@ -40,17 +40,17 @@ class Releases3DSBridge extends BridgeAbstract {
or returnServerError('Could not request 3dsdb: ' . $dataUrl); or returnServerError('Could not request 3dsdb: ' . $dataUrl);
$limit = 0; $limit = 0;
foreach(array_reverse(explode('<release>', $xml)) as $element){ foreach(array_reverse(explode('<release>', $xml)) as $element) {
if($limit >= 5){ if($limit >= 5) {
break; break;
} }
if(strpos($element, '</release>') === false){ if(strpos($element, '</release>') === false) {
continue; continue;
} }
$releasename = extractFromDelimiters($element, '<releasename>', '</releasename>'); $releasename = extractFromDelimiters($element, '<releasename>', '</releasename>');
if(empty($releasename)){ if(empty($releasename)) {
continue; continue;
} }
@ -77,7 +77,7 @@ class Releases3DSBridge extends BridgeAbstract {
$ignCoverArt = ''; $ignCoverArt = '';
$ignSearchUrl = 'http://www.ign.com/search?q=' . urlencode($name); $ignSearchUrl = 'http://www.ign.com/search?q=' . urlencode($name);
if($ignResult = getSimpleHTMLDOM($ignSearchUrl)){ if($ignResult = getSimpleHTMLDOM($ignSearchUrl)) {
$ignCoverArt = $ignResult->find('div.search-item-media', 0)->find('img', 0)->src; $ignCoverArt = $ignResult->find('div.search-item-media', 0)->find('img', 0)->src;
$ignDesc = $ignResult->find('div.search-item-description', 0)->plaintext; $ignDesc = $ignResult->find('div.search-item-description', 0)->plaintext;
$ignLink = $ignResult->find('div.search-item-sub-title', 0)->find('a', 1)->href; $ignLink = $ignResult->find('div.search-item-sub-title', 0)->find('a', 1)->href;

View file

@ -9,7 +9,7 @@ class ReporterreBridge extends BridgeAbstract {
private function extractContent($url){ private function extractContent($url){
$html2 = getSimpleHTMLDOM($url); $html2 = getSimpleHTMLDOM($url);
foreach($html2->find('div[style=text-align:justify]') as $e){ foreach($html2->find('div[style=text-align:justify]') as $e) {
$text = $e->outertext; $text = $e->outertext;
} }
@ -32,7 +32,7 @@ class ReporterreBridge extends BridgeAbstract {
or returnServerError('Could not request Reporterre.'); or returnServerError('Could not request Reporterre.');
$limit = 0; $limit = 0;
foreach($html->find('item') as $element){ foreach($html->find('item') as $element) {
if($limit < 5) { if($limit < 5) {
$item = array(); $item = array();
$item['title'] = html_entity_decode($element->find('title', 0)->plaintext); $item['title'] = html_entity_decode($element->find('title', 0)->plaintext);

View file

@ -12,7 +12,7 @@ class ScmbBridge extends BridgeAbstract {
$html = getSimpleHTMLDOM(self::URI) $html = getSimpleHTMLDOM(self::URI)
or returnServerError('Could not request Se Coucher Moins Bete.'); or returnServerError('Could not request Se Coucher Moins Bete.');
foreach($html->find('article') as $article){ foreach($html->find('article') as $article) {
$item = array(); $item = array();
$item['uri'] = self::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; $item['title'] = $article->find('header h1 a', 0)->innertext;

View file

@ -21,7 +21,7 @@ class ScoopItBridge extends BridgeAbstract {
$html = getSimpleHTMLDOM($link) $html = getSimpleHTMLDOM($link)
or returnServerError('Could not request ScoopIt. for : ' . $link); or returnServerError('Could not request ScoopIt. for : ' . $link);
foreach($html->find('div.post-view') as $element){ foreach($html->find('div.post-view') as $element) {
$item = array(); $item = array();
$item['uri'] = $element->find('a', 0)->href; $item['uri'] = $element->find('a', 0)->href;
$item['title'] = preg_replace( $item['title'] = preg_replace(

View file

@ -36,10 +36,10 @@ class SensCritiqueBridge extends BridgeAbstract {
public function collectData(){ public function collectData(){
$categories = array(); $categories = array();
foreach(self::PARAMETERS[$this->queriedContext] as $category => $properties){ foreach(self::PARAMETERS[$this->queriedContext] as $category => $properties) {
if($this->getInput($category)){ if($this->getInput($category)) {
$uri = self::URI; $uri = self::URI;
switch($category){ switch($category) {
case 'm': $uri .= 'films/cette-semaine'; case 'm': $uri .= 'films/cette-semaine';
break; break;
case 's': $uri .= 'series/actualite'; case 's': $uri .= 'series/actualite';
@ -63,11 +63,11 @@ class SensCritiqueBridge extends BridgeAbstract {
} }
private function extractDataFromList($list){ private function extractDataFromList($list){
if($list === null){ if($list === null) {
returnClientError('Cannot extract data from list'); returnClientError('Cannot extract data from list');
} }
foreach($list->find('li') as $movie){ foreach($list->find('li') as $movie) {
$item = array(); $item = array();
$item['author'] = htmlspecialchars_decode($movie->find('.elco-title a', 0)->plaintext, ENT_QUOTES) $item['author'] = htmlspecialchars_decode($movie->find('.elco-title a', 0)->plaintext, ENT_QUOTES)
. ' ' . ' '

View file

@ -24,11 +24,11 @@ class SexactuBridge extends BridgeAbstract {
$sexactu = $html->find('.container_sexactu', 0); $sexactu = $html->find('.container_sexactu', 0);
$rowList = $sexactu->find('.row'); $rowList = $sexactu->find('.row');
foreach($rowList as $row){ foreach($rowList as $row) {
// only use first list as second one only contains pages numbers // only use first list as second one only contains pages numbers
$title = $row->find('.title', 0); $title = $row->find('.title', 0);
if($title){ if($title) {
$item = array(); $item = array();
$item['author'] = self::AUTHOR; $item['author'] = self::AUTHOR;
$item['title'] = $title->plaintext; $item['title'] = $title->plaintext;
@ -36,9 +36,9 @@ class SexactuBridge extends BridgeAbstract {
$uri = $title->$urlAttribute; $uri = $title->$urlAttribute;
if($uri === false) if($uri === false)
continue; continue;
if(substr($uri, 0, 1) === 'h'){ // absolute uri if(substr($uri, 0, 1) === 'h') { // absolute uri
$item['uri'] = $uri; $item['uri'] = $uri;
} else if(substr($uri, 0, 1) === '/'){ // domain relative url } else if(substr($uri, 0, 1) === '/') { // domain relative url
$item['uri'] = self::URI . $uri; $item['uri'] = self::URI . $uri;
} else { } else {
$item['uri'] = $this->getURI() . $uri; $item['uri'] = $this->getURI() . $uri;
@ -66,7 +66,7 @@ class SexactuBridge extends BridgeAbstract {
$html = getSimpleHTMLDOMCached($uri); $html = getSimpleHTMLDOMCached($uri);
$content = $html->find('#article', 0); $content = $html->find('#article', 0);
if($content){ if($content) {
return $content; return $content;
} }

View file

@ -110,7 +110,7 @@ class ShanaprojectBridge extends BridgeAbstract {
if(!$animes) if(!$animes)
returnServerError('Could not find anime headers!'); returnServerError('Could not find anime headers!');
foreach($animes as $anime){ foreach($animes as $anime) {
$item = array(); $item = array();
$item['title'] = $this->extractAnimeTitle($anime); $item['title'] = $this->extractAnimeTitle($anime);
$item['author'] = $this->extractAnimeAuthor($anime); $item['author'] = $this->extractAnimeAuthor($anime);

View file

@ -32,7 +32,7 @@ class SoundCloudBridge extends BridgeAbstract {
. self::CLIENT_ID . self::CLIENT_ID
)) or returnServerError('No results for this user'); )) or returnServerError('No results for this user');
for($i = 0; $i < 10; $i++){ for($i = 0; $i < 10; $i++) {
$item = array(); $item = array();
$item['author'] = $tracks[$i]->user->username . ' - ' . $tracks[$i]->title; $item['author'] = $tracks[$i]->user->username . ' - ' . $tracks[$i]->title;
$item['title'] = $tracks[$i]->user->username . ' - ' . $tracks[$i]->title; $item['title'] = $tracks[$i]->user->username . ' - ' . $tracks[$i]->title;
@ -55,7 +55,7 @@ class SoundCloudBridge extends BridgeAbstract {
} }
public function getName(){ public function getName(){
if(!is_null($this->getInput('u'))){ if(!is_null($this->getInput('u'))) {
return self::NAME . ' - ' . $this->getInput('u'); return self::NAME . ' - ' . $this->getInput('u');
} }

View file

@ -10,7 +10,7 @@ class StripeAPIChangeLogBridge extends BridgeAbstract {
$html = getSimpleHTMLDOM(self::URI) $html = getSimpleHTMLDOM(self::URI)
or returnServerError('No results for Stripe API Changelog'); or returnServerError('No results for Stripe API Changelog');
foreach($html->find('h3') as $change){ foreach($html->find('h3') as $change) {
$item = array(); $item = array();
$item['title'] = trim($change->plaintext); $item['title'] = trim($change->plaintext);
$item['uri'] = self::URI . '#' . $item['title']; $item['uri'] = self::URI . '#' . $item['title'];

View file

@ -38,12 +38,12 @@ class SuperbWallpapersBridge extends BridgeAbstract {
$lastpage = min($html->find('.paging .cpage', 0)->innertext(), ceil($max / 36)); $lastpage = min($html->find('.paging .cpage', 0)->innertext(), ceil($max / 36));
for($page = 1; $page <= $lastpage; $page++){ for($page = 1; $page <= $lastpage; $page++) {
$link = self::URI . '/' . $category . '/' . $page . '.html'; $link = self::URI . '/' . $category . '/' . $page . '.html';
$html = getSimpleHTMLDOM($link) $html = getSimpleHTMLDOM($link)
or returnServerError('No results for this query.'); or returnServerError('No results for this query.');
foreach($html->find('.wpl .i a') as $element){ foreach($html->find('.wpl .i a') as $element) {
$thumbnail = $element->find('img', 0); $thumbnail = $element->find('img', 0);
$item = array(); $item = array();
@ -61,7 +61,7 @@ class SuperbWallpapersBridge extends BridgeAbstract {
} }
public function getName(){ public function getName(){
if(!is_null($this->getInput('c')) && !is_null($this->getInput('r'))){ if(!is_null($this->getInput('c')) && !is_null($this->getInput('r'))) {
return self::NAME . '- ' . $this->getInput('c') . ' [' . $this->getInput('r') . ']'; return self::NAME . '- ' . $this->getInput('c') . ' [' . $this->getInput('r') . ']';
} }

View file

@ -18,7 +18,7 @@ class T411Bridge extends BridgeAbstract {
//Utility function for retrieving text based on start and end delimiters //Utility function for retrieving text based on start and end delimiters
function extractFromDelimiters($string, $start, $end){ function extractFromDelimiters($string, $start, $end){
if(strpos($string, $start) !== false){ if(strpos($string, $start) !== false) {
$section_retrieved = substr($string, strpos($string, $start) + strlen($start)); $section_retrieved = substr($string, strpos($string, $start) + strlen($start));
$section_retrieved = substr($section_retrieved, 0, strpos($section_retrieved, $end)); $section_retrieved = substr($section_retrieved, 0, strpos($section_retrieved, $end));
return $section_retrieved; return $section_retrieved;
@ -42,13 +42,13 @@ class T411Bridge extends BridgeAbstract {
$limit = 0; $limit = 0;
//Process each item individually //Process each item individually
foreach($results->find('tr') as $element){ foreach($results->find('tr') as $element) {
//Limit total amount of requests and ignore table header //Limit total amount of requests and ignore table header
if($limit >= 10){ if($limit >= 10) {
break; break;
} }
if(is_object($element->find('th', 0))){ if(is_object($element->find('th', 0))) {
continue; continue;
} }
@ -65,7 +65,7 @@ class T411Bridge extends BridgeAbstract {
//Retrieve full description from torrent page //Retrieve full description from torrent page
$item_html = getSimpleHTMLDOM($item_uri); $item_html = getSimpleHTMLDOM($item_uri);
if(!$item_html){ if(!$item_html) {
continue; continue;
} }

View file

@ -21,12 +21,12 @@ class TagBoardBridge extends BridgeAbstract {
or returnServerError('Could not request TagBoard for : ' . $link); or returnServerError('Could not request TagBoard for : ' . $link);
$parsed_json = json_decode($html); $parsed_json = json_decode($html);
foreach($parsed_json->{'posts'} as $element){ foreach($parsed_json->{'posts'} as $element) {
$item = array(); $item = array();
$item['uri'] = $element->{'permalink'}; $item['uri'] = $element->{'permalink'};
$item['title'] = $element->{'text'}; $item['title'] = $element->{'text'};
$thumbnailUri = $element->{'photos'}[0]->{'m'}; $thumbnailUri = $element->{'photos'}[0]->{'m'};
if(isset($thumbnailUri)){ if(isset($thumbnailUri)) {
$item['content'] = '<a href="' $item['content'] = '<a href="'
. $item['uri'] . $item['uri']
. '"><img src="' . '"><img src="'
@ -40,7 +40,7 @@ class TagBoardBridge extends BridgeAbstract {
} }
public function getName(){ public function getName(){
if(!is_null($this->getInput('u'))){ if(!is_null($this->getInput('u'))) {
return 'tagboard - ' . $this->getInput('u'); return 'tagboard - ' . $this->getInput('u');
} }

View file

@ -11,7 +11,7 @@ class TheCodingLoveBridge extends BridgeAbstract {
$html = getSimpleHTMLDOM(self::URI) $html = getSimpleHTMLDOM(self::URI)
or returnServerError('Could not request The Coding Love.'); or returnServerError('Could not request The Coding Love.');
foreach($html->find('div.post') as $element){ foreach($html->find('div.post') as $element) {
$item = array(); $item = array();
$temp = $element->find('h3 a', 0); $temp = $element->find('h3 a', 0);
@ -22,7 +22,7 @@ class TheCodingLoveBridge extends BridgeAbstract {
// retrieve .gif instead of static .jpg // retrieve .gif instead of static .jpg
$images = $temp->find('p.e img'); $images = $temp->find('p.e img');
foreach($images as $image){ foreach($images as $image) {
$img_src = str_replace('.jpg', '.gif', $image->src); $img_src = str_replace('.jpg', '.gif', $image->src);
$image->src = $img_src; $image->src = $img_src;
} }
@ -31,7 +31,7 @@ class TheCodingLoveBridge extends BridgeAbstract {
$auteur = $temp->find('i', 0); $auteur = $temp->find('i', 0);
$pos = strpos($auteur->innertext, 'by'); $pos = strpos($auteur->innertext, 'by');
if($pos > 0){ if($pos > 0) {
$auteur = trim(str_replace('*/', '', substr($auteur->innertext, ($pos + 2)))); $auteur = trim(str_replace('*/', '', substr($auteur->innertext, ($pos + 2))));
$item['author'] = $auteur; $item['author'] = $auteur;
} }

View file

@ -9,7 +9,7 @@ class TheHackerNewsBridge extends BridgeAbstract {
public function collectData(){ public function collectData(){
function stripWithDelimiters($string, $start, $end){ function stripWithDelimiters($string, $start, $end){
while(strpos($string, $start) !== false){ while(strpos($string, $start) !== false) {
$section_to_remove = substr($string, strpos($string, $start)); $section_to_remove = substr($string, strpos($string, $start));
$section_to_remove = substr($section_to_remove, 0, strpos($section_to_remove, $end) + strlen($end)); $section_to_remove = substr($section_to_remove, 0, strpos($section_to_remove, $end) + strlen($end));
$string = str_replace($section_to_remove, '', $string); $string = str_replace($section_to_remove, '', $string);
@ -22,8 +22,8 @@ class TheHackerNewsBridge extends BridgeAbstract {
$open_tag = '<' . $tag_name; $open_tag = '<' . $tag_name;
$close_tag = '</' . $tag_name . '>'; $close_tag = '</' . $tag_name . '>';
$close_tag_length = strlen($close_tag); $close_tag_length = strlen($close_tag);
if(strpos($tag_start, $open_tag) === 0){ if(strpos($tag_start, $open_tag) === 0) {
while(strpos($string, $tag_start) !== false){ while(strpos($string, $tag_start) !== false) {
$max_recursion = 100; $max_recursion = 100;
$section_to_remove = null; $section_to_remove = null;
$section_start = strpos($string, $tag_start); $section_start = strpos($string, $tag_start);
@ -51,8 +51,8 @@ class TheHackerNewsBridge extends BridgeAbstract {
or returnServerError('Could not request TheHackerNews: ' . $this->getURI()); or returnServerError('Could not request TheHackerNews: ' . $this->getURI());
$limit = 0; $limit = 0;
foreach($html->find('article') as $element){ foreach($html->find('article') as $element) {
if($limit < 5){ if($limit < 5) {
$article_url = $element->find('a.entry-title', 0)->href; $article_url = $element->find('a.entry-title', 0)->href;
$article_author = trim($element->find('span.vcard', 0)->plaintext); $article_author = trim($element->find('span.vcard', 0)->plaintext);

View file

@ -45,7 +45,7 @@ class ThePirateBayBridge extends BridgeAbstract {
$guessedDate = explode('Uploaded ', $guessedDate)[1]; $guessedDate = explode('Uploaded ', $guessedDate)[1];
$guessedDate = explode(',', $guessedDate)[0]; $guessedDate = explode(',', $guessedDate)[0];
if(count(explode(':', $guessedDate)) == 1){ if(count(explode(':', $guessedDate)) == 1) {
$guessedDate = strptime($guessedDate, '%m-%d&nbsp;%Y'); $guessedDate = strptime($guessedDate, '%m-%d&nbsp;%Y');
$timestamp = mktime( $timestamp = mktime(
0, 0,
@ -55,7 +55,7 @@ class ThePirateBayBridge extends BridgeAbstract {
$guessedDate['tm_mday'], $guessedDate['tm_mday'],
1900 + $guessedDate['tm_year'] 1900 + $guessedDate['tm_year']
); );
} elseif(explode('&nbsp;', $guessedDate)[0] == 'Today'){ } elseif(explode('&nbsp;', $guessedDate)[0] == 'Today') {
$guessedDate = strptime( $guessedDate = strptime(
explode('&nbsp;', $guessedDate)[1], '%H:%M' explode('&nbsp;', $guessedDate)[1], '%H:%M'
); );
@ -68,7 +68,7 @@ class ThePirateBayBridge extends BridgeAbstract {
date('d'), date('d'),
date('Y') date('Y')
); );
} elseif(explode('&nbsp;', $guessedDate)[0] == 'Y-day'){ } elseif(explode('&nbsp;', $guessedDate)[0] == 'Y-day') {
$guessedDate = strptime( $guessedDate = strptime(
explode('&nbsp;', $guessedDate)[1], '%H:%M' explode('&nbsp;', $guessedDate)[1], '%H:%M'
); );
@ -95,17 +95,17 @@ class ThePirateBayBridge extends BridgeAbstract {
} }
$catBool = $this->getInput('cat_check'); $catBool = $this->getInput('cat_check');
if($catBool){ if($catBool) {
$catNum = $this->getInput('cat'); $catNum = $this->getInput('cat');
} }
$critList = $this->getInput('crit'); $critList = $this->getInput('crit');
$trustedBool = $this->getInput('trusted'); $trustedBool = $this->getInput('trusted');
$keywordsList = explode(';', $this->getInput('q')); $keywordsList = explode(';', $this->getInput('q'));
foreach($keywordsList as $keywords){ foreach($keywordsList as $keywords) {
switch($critList){ switch($critList) {
case 'search': case 'search':
if($catBool == false){ if($catBool == false) {
$html = getSimpleHTMLDOM( $html = getSimpleHTMLDOM(
self::URI . self::URI .
'search/' . 'search/' .
@ -143,11 +143,11 @@ class ThePirateBayBridge extends BridgeAbstract {
if ($html->find('table#searchResult', 0) == false) if ($html->find('table#searchResult', 0) == false)
returnServerError('No result for query ' . $keywords); returnServerError('No result for query ' . $keywords);
foreach($html->find('tr') as $element){ foreach($html->find('tr') as $element) {
if(!$trustedBool if(!$trustedBool
|| !is_null($element->find('img[alt=VIP]', 0)) || !is_null($element->find('img[alt=VIP]', 0))
|| !is_null($element->find('img[alt=Trusted]', 0))){ || !is_null($element->find('img[alt=Trusted]', 0))) {
$item = array(); $item = array();
$item['uri'] = $element->find('a', 3)->href; $item['uri'] = $element->find('a', 3)->href;
$item['id'] = self::URI . $element->find('a.detLink', 0)->href; $item['id'] = self::URI . $element->find('a.detLink', 0)->href;

View file

@ -55,7 +55,7 @@ class TheTVDBBridge extends BridgeAbstract {
$result = curl_exec($ch); $result = curl_exec($ch);
curl_close($ch); curl_close($ch);
$token_json = (array)json_decode($result); $token_json = (array)json_decode($result);
if(isset($token_json['Error'])){ if(isset($token_json['Error'])) {
throw new Exception($token_json['Error']); throw new Exception($token_json['Error']);
die; die;
} }
@ -78,7 +78,7 @@ class TheTVDBBridge extends BridgeAbstract {
$result = curl_exec($ch); $result = curl_exec($ch);
curl_close($ch); curl_close($ch);
$result_array = (array)json_decode($result); $result_array = (array)json_decode($result);
if(isset($result_array['Error'])){ if(isset($result_array['Error'])) {
throw new Exception($result_array['Error']); throw new Exception($result_array['Error']);
die; die;
} }
@ -118,7 +118,7 @@ class TheTVDBBridge extends BridgeAbstract {
//than 100 episodes in every season //than 100 episodes in every season
$episodes = (array)$episodes['data']; $episodes = (array)$episodes['data'];
$episodes = array_slice($episodes, -$nbepisodemin, $nbepisodemin); $episodes = array_slice($episodes, -$nbepisodemin, $nbepisodemin);
foreach($episodes as $episode){ foreach($episodes as $episode) {
$episodedata = array(); $episodedata = array();
$episodedata['uri'] = $this->getURI() $episodedata['uri'] = $this->getURI()
. '?tab=episode&seriesid=' . '?tab=episode&seriesid='
@ -129,7 +129,7 @@ class TheTVDBBridge extends BridgeAbstract {
. $episode->id; . $episode->id;
// check if the absoluteNumber exist // check if the absoluteNumber exist
if(isset($episode->absoluteNumber)){ if(isset($episode->absoluteNumber)) {
$episodedata['title'] = 'S' $episodedata['title'] = 'S'
. $episode->airedSeason . $episode->airedSeason
. 'E' . 'E'
@ -166,7 +166,7 @@ class TheTVDBBridge extends BridgeAbstract {
$maxseason = $this->getLatestSeasonNumber($token, $serie_id); $maxseason = $this->getLatestSeasonNumber($token, $serie_id);
$seriename = $this->getSerieName($token, $serie_id); $seriename = $this->getSerieName($token, $serie_id);
$season = $maxseason; $season = $maxseason;
while(sizeof($episodelist) < $nbepisode && $season >= 1){ while(sizeof($episodelist) < $nbepisode && $season >= 1) {
$nbepisodetmp = $nbepisode - sizeof($episodelist); $nbepisodetmp = $nbepisode - sizeof($episodelist);
$this->getSeasonEpisodes( $this->getSeasonEpisodes(
$token, $token,
@ -189,7 +189,7 @@ class TheTVDBBridge extends BridgeAbstract {
$episodelist, $episodelist,
$nbepisode $nbepisode
); );
} catch(Exception $e){ } catch(Exception $e) {
unset($e); unset($e);
} }
// sort and keep the 10 last episodes, works bad with the netflix serie // sort and keep the 10 last episodes, works bad with the netflix serie

View file

@ -36,7 +36,7 @@ class Torrent9Bridge extends BridgeAbstract {
public function collectData(){ public function collectData(){
if($this->queriedContext === 'From search'){ if($this->queriedContext === 'From search') {
$request = str_replace(' ', '-', trim($this->getInput('q'))); $request = str_replace(' ', '-', trim($this->getInput('q')));
$page = self::URI . '/search_torrent/' . urlencode($request) . '.html'; $page = self::URI . '/search_torrent/' . urlencode($request) . '.html';
} else { } else {
@ -47,8 +47,8 @@ class Torrent9Bridge extends BridgeAbstract {
$html = getSimpleHTMLDOM($page) $html = getSimpleHTMLDOM($page)
or returnServerError('No results for this query.'); or returnServerError('No results for this query.');
foreach($html->find('table', 0)->find('tr') as $episode){ foreach($html->find('table', 0)->find('tr') as $episode) {
if($episode->parent->tag == 'tbody'){ if($episode->parent->tag == 'tbody') {
$urlepisode = self::URI . $episode->find('a', 0)->getAttribute('href'); $urlepisode = self::URI . $episode->find('a', 0)->getAttribute('href');
@ -62,11 +62,11 @@ class Torrent9Bridge extends BridgeAbstract {
$item['pubdate'] = $this->getCachedDate($urlepisode); $item['pubdate'] = $this->getCachedDate($urlepisode);
$textefiche = $htmlepisode->find('.movie-information', 0)->find('p', 1); $textefiche = $htmlepisode->find('.movie-information', 0)->find('p', 1);
if(isset($textefiche)){ if(isset($textefiche)) {
$item['content'] = $textefiche->text(); $item['content'] = $textefiche->text();
} else { } else {
$p = $htmlepisode->find('.movie-information', 0)->find('p'); $p = $htmlepisode->find('.movie-information', 0)->find('p');
if(!empty($p)){ if(!empty($p)) {
$item['content'] = $htmlepisode->find('.movie-information', 0)->find('p', 0)->text(); $item['content'] = $htmlepisode->find('.movie-information', 0)->find('p', 0)->text();
} }
} }
@ -81,7 +81,7 @@ class Torrent9Bridge extends BridgeAbstract {
public function getName(){ public function getName(){
if(!is_null($this->getInput('q'))){ if(!is_null($this->getInput('q'))) {
return $this->getInput('q') . ' : ' . self::NAME; return $this->getInput('q') . ' : ' . self::NAME;
} }

View file

@ -48,7 +48,7 @@ class TwitterBridge extends BridgeAbstract {
); );
public function getName(){ public function getName(){
switch($this->queriedContext){ switch($this->queriedContext) {
case 'By keyword or hashtag': case 'By keyword or hashtag':
$specific = 'search '; $specific = 'search ';
$param = 'q'; $param = 'q';
@ -63,7 +63,7 @@ class TwitterBridge extends BridgeAbstract {
} }
public function getURI(){ public function getURI(){
switch($this->queriedContext){ switch($this->queriedContext) {
case 'By keyword or hashtag': case 'By keyword or hashtag':
return self::URI return self::URI
. 'search?q=' . 'search?q='
@ -82,8 +82,8 @@ class TwitterBridge extends BridgeAbstract {
$html = ''; $html = '';
$html = getSimpleHTMLDOM($this->getURI()); $html = getSimpleHTMLDOM($this->getURI());
if(!$html){ if(!$html) {
switch($this->queriedContext){ switch($this->queriedContext) {
case 'By keyword or hashtag': case 'By keyword or hashtag':
returnServerError('No results for this query.'); returnServerError('No results for this query.');
case 'By username': case 'By username':
@ -93,16 +93,16 @@ class TwitterBridge extends BridgeAbstract {
$hidePictures = $this->getInput('nopic'); $hidePictures = $this->getInput('nopic');
foreach($html->find('div.js-stream-tweet') as $tweet){ foreach($html->find('div.js-stream-tweet') as $tweet) {
// Skip retweets? // Skip retweets?
if($this->getInput('noretweet') if($this->getInput('noretweet')
&& $tweet->getAttribute('data-screen-name') !== $this->getInput('u')){ && $tweet->getAttribute('data-screen-name') !== $this->getInput('u')) {
continue; continue;
} }
// remove 'invisible' content // remove 'invisible' content
foreach($tweet->find('.invisible') as $invisible){ foreach($tweet->find('.invisible') as $invisible) {
$invisible->outertext = ''; $invisible->outertext = '';
} }
@ -139,7 +139,7 @@ class TwitterBridge extends BridgeAbstract {
// Add picture to content // Add picture to content
$picture_html = ''; $picture_html = '';
if(!$hidePictures){ if(!$hidePictures) {
$picture_html = <<<EOD $picture_html = <<<EOD
<a href="https://twitter.com/{$item['username']}"> <a href="https://twitter.com/{$item['username']}">
<img <img
@ -154,7 +154,7 @@ EOD;
// Add embeded image to content // Add embeded image to content
$image_html = ''; $image_html = '';
$image = $this->getImageURI($tweet); $image = $this->getImageURI($tweet);
if(!$this->getInput('noimg') && !is_null($image)){ if(!$this->getInput('noimg') && !is_null($image)) {
// add enclosures // add enclosures
$item['enclosures'] = array($image . ':orig'); $item['enclosures'] = array($image . ':orig');
@ -182,7 +182,7 @@ EOD;
// add quoted tweet // add quoted tweet
$quotedTweet = $tweet->find('div.QuoteTweet', 0); $quotedTweet = $tweet->find('div.QuoteTweet', 0);
if($quotedTweet){ if($quotedTweet) {
// get tweet text // get tweet text
$cleanedQuotedTweet = str_replace( $cleanedQuotedTweet = str_replace(
'href="/', 'href="/',
@ -196,7 +196,7 @@ EOD;
// Add embeded image to content // Add embeded image to content
$quotedImage_html = ''; $quotedImage_html = '';
$quotedImage = $this->getQuotedImageURI($tweet); $quotedImage = $this->getQuotedImageURI($tweet);
if(!$this->getInput('noimg') && !is_null($quotedImage)){ if(!$this->getInput('noimg') && !is_null($quotedImage)) {
// add enclosures // add enclosures
$item['enclosures'] = array($quotedImage . ':orig'); $item['enclosures'] = array($quotedImage . ':orig');
@ -228,15 +228,15 @@ EOD;
private function processEmojis($tweet){ private function processEmojis($tweet){
// process emojis (reduce size) // process emojis (reduce size)
foreach($tweet->find('img.Emoji') as $img){ foreach($tweet->find('img.Emoji') as $img) {
$img->style .= ' height: 1em;'; $img->style .= ' height: 1em;';
} }
} }
private function processContentLinks($tweet){ private function processContentLinks($tweet){
// processing content links // processing content links
foreach($tweet->find('a') as $link){ foreach($tweet->find('a') as $link) {
if($link->hasAttribute('data-expanded-url')){ if($link->hasAttribute('data-expanded-url')) {
$link->href = $link->getAttribute('data-expanded-url'); $link->href = $link->getAttribute('data-expanded-url');
} }
$link->removeAttribute('data-expanded-url'); $link->removeAttribute('data-expanded-url');
@ -260,7 +260,7 @@ EOD;
private function getImageURI($tweet){ private function getImageURI($tweet){
// Find media in tweet // Find media in tweet
$container = $tweet->find('div.AdaptiveMedia-container', 0); $container = $tweet->find('div.AdaptiveMedia-container', 0);
if($container && $container->find('img', 0)){ if($container && $container->find('img', 0)) {
return $container->find('img', 0)->src; return $container->find('img', 0)->src;
} }
@ -270,7 +270,7 @@ EOD;
private function getQuotedImageURI($tweet){ private function getQuotedImageURI($tweet){
// Find media in tweet // Find media in tweet
$container = $tweet->find('div.QuoteMedia-container', 0); $container = $tweet->find('div.QuoteMedia-container', 0);
if($container && $container->find('img', 0)){ if($container && $container->find('img', 0)) {
return $container->find('img', 0)->src; return $container->find('img', 0)->src;
} }

View file

@ -32,12 +32,12 @@ class UnsplashBridge extends BridgeAbstract {
$quality = $this->getInput('q'); $quality = $this->getInput('q');
$lastpage = 1; $lastpage = 1;
for($page = 1; $page <= $lastpage; $page++){ for($page = 1; $page <= $lastpage; $page++) {
$link = self::URI . '/grid?page=' . $page; $link = self::URI . '/grid?page=' . $page;
$html = getSimpleHTMLDOM($link) $html = getSimpleHTMLDOM($link)
or returnServerError('No results for this query.'); or returnServerError('No results for this query.');
if($page === 1){ if($page === 1) {
preg_match( preg_match(
'/=(\d+)$/', '/=(\d+)$/',
$html->find('.pagination > a[!class]', -1)->href, $html->find('.pagination > a[!class]', -1)->href,
@ -47,7 +47,7 @@ class UnsplashBridge extends BridgeAbstract {
$lastpage = min($matches[1], ceil($max / 40)); $lastpage = min($matches[1], ceil($max / 40));
} }
foreach($html->find('.photo') as $element){ foreach($html->find('.photo') as $element) {
$thumbnail = $element->find('img', 0); $thumbnail = $element->find('img', 0);
$thumbnail->src = str_replace('https://', 'http://', $thumbnail->src); $thumbnail->src = str_replace('https://', 'http://', $thumbnail->src);

View file

@ -31,11 +31,11 @@ class UsbekEtRicaBridge extends BridgeAbstract {
$articles = $html->find('div.details'); $articles = $html->find('div.details');
foreach($articles as $article){ foreach($articles as $article) {
$item = array(); $item = array();
$title = $article->find('div.card-title', 0); $title = $article->find('div.card-title', 0);
if($title){ if($title) {
$item['title'] = $title->plaintext; $item['title'] = $title->plaintext;
} else { } else {
// Sometimes we get rubbish, ignore. // Sometimes we get rubbish, ignore.
@ -43,32 +43,32 @@ class UsbekEtRicaBridge extends BridgeAbstract {
} }
$author = $article->find('div.author span', 0); $author = $article->find('div.author span', 0);
if($author){ if($author) {
$item['author'] = $author->plaintext; $item['author'] = $author->plaintext;
} }
$uri = $article->find('a.read', 0)->href; $uri = $article->find('a.read', 0)->href;
if(substr($uri, 0, 1) === 'h'){ // absolute uri if(substr($uri, 0, 1) === 'h') { // absolute uri
$item['uri'] = $uri; $item['uri'] = $uri;
} else { // relative uri } else { // relative uri
$item['uri'] = $this->getURI() . $uri; $item['uri'] = $this->getURI() . $uri;
} }
if($fullarticle){ if($fullarticle) {
$content = $this->loadFullArticle($item['uri']); $content = $this->loadFullArticle($item['uri']);
} }
if($fullarticle && !is_null($content)){ if($fullarticle && !is_null($content)) {
$item['content'] = $content; $item['content'] = $content;
} else { } else {
$excerpt = $article->find('div.card-excerpt', 0); $excerpt = $article->find('div.card-excerpt', 0);
if($excerpt){ if($excerpt) {
$item['content'] = $excerpt->plaintext; $item['content'] = $excerpt->plaintext;
} }
} }
$image = $article->find('div.card-img img', 0); $image = $article->find('div.card-img img', 0);
if($image){ if($image) {
$item['enclosures'] = array( $item['enclosures'] = array(
$image->src $image->src
); );
@ -76,7 +76,7 @@ class UsbekEtRicaBridge extends BridgeAbstract {
$this->items[] = $item; $this->items[] = $item;
if($limit > 0 && count($this->items) >= $limit){ if($limit > 0 && count($this->items) >= $limit) {
break; break;
} }
} }
@ -91,7 +91,7 @@ class UsbekEtRicaBridge extends BridgeAbstract {
$html = getSimpleHTMLDOMCached($uri); $html = getSimpleHTMLDOMCached($uri);
$content = $html->find('section.main', 0); $content = $html->find('section.main', 0);
if($content){ if($content) {
return $this->replaceUriInHtmlElement($content); return $this->replaceUriInHtmlElement($content);
} }

View file

@ -22,9 +22,9 @@ class ViadeoCompanyBridge extends BridgeAbstract {
$html = getSimpleHTMLDOM($link) $html = getSimpleHTMLDOM($link)
or returnServerError('Could not request Viadeo.'); or returnServerError('Could not request Viadeo.');
foreach($html->find('//*[@id="company-newsfeed"]/ul/li') as $element){ foreach($html->find('//*[@id="company-newsfeed"]/ul/li') as $element) {
$title = $element->find('p', 0)->innertext; $title = $element->find('p', 0)->innertext;
if($title){ if($title) {
$item = array(); $item = array();
$item['uri'] = $link; $item['uri'] = $link;
$item['title'] = mb_substr($element->find('p', 0)->innertext, 0, 100); $item['title'] = mb_substr($element->find('p', 0)->innertext, 0, 100);

View file

@ -20,7 +20,7 @@ class VineBridge extends BridgeAbstract {
$html = getSimpleHTMLDOM($uri) $html = getSimpleHTMLDOM($uri)
or returnServerError('No results for this query.'); or returnServerError('No results for this query.');
foreach($html->find('.post') as $element){ foreach($html->find('.post') as $element) {
$a = $element->find('a', 0); $a = $element->find('a', 0);
$a->href = str_replace('https://', 'http://', $a->href); $a->href = str_replace('https://', 'http://', $a->href);
$time = strtotime(ltrim($element->find('p', 0)->plaintext, ' Uploaded at ')); $time = strtotime(ltrim($element->find('p', 0)->plaintext, ' Uploaded at '));

Some files were not shown because too many files have changed in this diff Show more