From 5a2a6fbdbaf52697b242a32171e9dbcf02201cdc Mon Sep 17 00:00:00 2001 From: root Date: Tue, 5 May 2015 20:18:12 +0200 Subject: [PATCH 1/3] Add ReporterreBridge.php --- bridges/ReporterreBridge.php | 55 ++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 bridges/ReporterreBridge.php diff --git a/bridges/ReporterreBridge.php b/bridges/ReporterreBridge.php new file mode 100644 index 00000000..3567edb8 --- /dev/null +++ b/bridges/ReporterreBridge.php @@ -0,0 +1,55 @@ +find('div[style=text-align:justify]') as $e) { + $text = $e->outertext; + } + $html2->clear(); + unset ($html2); + return $text; + } + + $html = file_get_html('http://www.reporterre.net/spip.php?page=backend') or $this->returnError('Could not request Reporterre.', 404); + $limit = 0; + + foreach($html->find('item') as $element) { + if($limit < 5) { + $item = new \Item(); + $item->title = html_entity_decode($element->find('title', 0)->plaintext); + $item->timestamp = strtotime($element->find('dc:date', 0)->plaintext); + $item->uri = $element->find('guid', 0)->innertext; + $item->content = html_entity_decode(ExtractContentReporterre($item->uri)); + $this->items[] = $item; + $limit++; + } + } + + } + + public function getName(){ + return 'Reporterre Bridge'; + } + + public function getURI(){ + return 'http://www.reporterre.net/'; + } + + public function getCacheDuration(){ + return 3600; // 1 hours +// return 0; + } +} From ca9cc12b0c5fe9bf4418ce90fafe40188d835945 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 5 May 2015 20:30:26 +0200 Subject: [PATCH 2/3] Fixing cache issue causing memory leak --- bridges/CommonDreamsBridge.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/bridges/CommonDreamsBridge.php b/bridges/CommonDreamsBridge.php index 7dcf33dc..07247e56 100644 --- a/bridges/CommonDreamsBridge.php +++ b/bridges/CommonDreamsBridge.php @@ -22,13 +22,15 @@ class CommonDreamsBridge extends BridgeAbstract{ function CommonDreamsExtractContent($url) { $html3 = file_get_html($url); $text = $html3->find('div[class=field--type-text-with-summary]', 0)->innertext; + $html3->clear(); + unset ($html3); return $text; } $html = file_get_html('http://www.commondreams.org/rss.xml') or $this->returnError('Could not request CommonDreams.', 404); $limit = 0; foreach($html->find('item') as $element) { - if($limit < 2) { + if($limit < 4) { $item = new \Item(); $item->title = $element->find('title', 0)->innertext; $item->uri = CommonDreamsUrl($element->find('guid', 0)->innertext); @@ -50,7 +52,7 @@ class CommonDreamsBridge extends BridgeAbstract{ } public function getCacheDuration(){ -// return 3600*2; // 2 hours - return 0; + return 3600; // 1 hours +// return 0; } } From 222073248d236b666b1599cbef8e986ba5d3a9e8 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 6 May 2015 09:53:21 +0200 Subject: [PATCH 3/3] Fixing issue with sillies --- bridges/CADBridge.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/bridges/CADBridge.php b/bridges/CADBridge.php index fd7c6446..8238eaf9 100644 --- a/bridges/CADBridge.php +++ b/bridges/CADBridge.php @@ -23,21 +23,29 @@ class CADBridge extends BridgeAbstract{ function CADExtractContent($url) { $html3 = file_get_html($url); - preg_match_all("/http:\/\/cdn2\.cad-comic\.com\/comics\/cad-\S*png/", $html3, $url2); + $htmlpart = explode("/", $url); + if ($htmlpart[3] == 'cad') + preg_match_all("/http:\/\/cdn2\.cad-comic\.com\/comics\/cad-\S*png/", $html3, $url2); + if ($htmlpart[3] == 'sillies') + preg_match_all("/http:\/\/cdn2\.cad-comic\.com\/comics\/sillies-\S*gif/", $html3, $url2); $img = implode ($url2[0]); - return $img; + $html3->clear(); + unset ($html3); + if ($img == '') + return 'Daily comic not realease yet'; + return ''; } $html = file_get_html('http://cdn2.cad-comic.com/rss.xml') or $this->returnError('Could not request CAD.', 404); $limit = 0; foreach($html->find('item') as $element) { - if($limit < 3) { + if($limit < 5) { $item = new \Item(); $item->title = $element->find('title', 0)->innertext; $item->uri = CADUrl($element->find('description', 0)->innertext); if ($item->uri != 'notanurl') { $item->timestamp = strtotime($element->find('pubDate', 0)->plaintext); - $item->content = ''; + $item->content = CADExtractContent($item->uri); $this->items[] = $item; $limit++; }