summaryrefslogtreecommitdiff
path: root/plugins/af_comics/filters
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/af_comics/filters')
-rw-r--r--plugins/af_comics/filters/af_comics_cad.php36
-rw-r--r--plugins/af_comics/filters/af_comics_comicpress.php46
-rw-r--r--plugins/af_comics/filters/af_comics_darklegacy.php43
-rw-r--r--plugins/af_comics/filters/af_comics_dilbert.php47
-rw-r--r--plugins/af_comics/filters/af_comics_explosm.php44
-rw-r--r--plugins/af_comics/filters/af_comics_gocomics.php53
-rw-r--r--plugins/af_comics/filters/af_comics_pa.php77
-rw-r--r--plugins/af_comics/filters/af_comics_tfd.php32
-rw-r--r--plugins/af_comics/filters/af_comics_twp.php33
9 files changed, 411 insertions, 0 deletions
diff --git a/plugins/af_comics/filters/af_comics_cad.php b/plugins/af_comics/filters/af_comics_cad.php
new file mode 100644
index 000000000..43836724f
--- /dev/null
+++ b/plugins/af_comics/filters/af_comics_cad.php
@@ -0,0 +1,36 @@
+<?php
+class Af_Comics_Cad extends Af_ComicFilter {
+
+ function supported() {
+ return array("Ctrl+Alt+Del");
+ }
+
+ function process(&$article) {
+ $owner_uid = $article["owner_uid"];
+
+ if (strpos($article["link"], "cad-comic.com/cad/") !== FALSE) {
+ if (strpos($article["title"], "News:") === FALSE) {
+
+ $doc = new DOMDocument();
+ @$doc->loadHTML(fetch_file_contents($article["link"]));
+
+ $basenode = false;
+
+ if ($doc) {
+ $xpath = new DOMXPath($doc);
+ $basenode = $xpath->query('(//img[contains(@src, "/comics/cad-")])')->item(0);
+
+ if ($basenode) {
+ $article["content"] = $doc->saveXML($basenode);
+ }
+ }
+
+ }
+
+ return true;
+ }
+
+ return false;
+ }
+}
+?>
diff --git a/plugins/af_comics/filters/af_comics_comicpress.php b/plugins/af_comics/filters/af_comics_comicpress.php
new file mode 100644
index 000000000..ec4b7ac57
--- /dev/null
+++ b/plugins/af_comics/filters/af_comics_comicpress.php
@@ -0,0 +1,46 @@
+<?php
+class Af_Comics_ComicPress extends Af_ComicFilter {
+
+ function supported() {
+ return array("Buni", "Buttersafe", "Whomp!", "Happy Jar", "CSection",
+ "Extra Fabulous Comics");
+ }
+
+ function process(&$article) {
+ $owner_uid = $article["owner_uid"];
+
+ if (strpos($article["guid"], "bunicomic.com") !== FALSE ||
+ strpos($article["guid"], "buttersafe.com") !== FALSE ||
+ strpos($article["guid"], "whompcomic.com") !== FALSE ||
+ strpos($article["guid"], "extrafabulouscomics.com") !== FALSE ||
+ strpos($article["guid"], "happyjar.com") !== FALSE ||
+ strpos($article["guid"], "csectioncomics.com") !== FALSE) {
+
+ // lol at people who block clients by user agent
+ // oh noes my ad revenue Q_Q
+
+ $res = fetch_file_contents($article["link"], false, false, false,
+ false, false, 0,
+ "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)");
+
+ $doc = new DOMDocument();
+ @$doc->loadHTML($res);
+
+ $basenode = false;
+
+ if ($doc) {
+ $xpath = new DOMXPath($doc);
+ $basenode = $xpath->query('//div[@id="comic"]')->item(0);
+
+ if ($basenode) {
+ $article["content"] = $doc->saveXML($basenode);
+ }
+ }
+
+ return true;
+ }
+
+ return false;
+ }
+}
+?>
diff --git a/plugins/af_comics/filters/af_comics_darklegacy.php b/plugins/af_comics/filters/af_comics_darklegacy.php
new file mode 100644
index 000000000..c03919b1d
--- /dev/null
+++ b/plugins/af_comics/filters/af_comics_darklegacy.php
@@ -0,0 +1,43 @@
+<?php
+class Af_Comics_DarkLegacy extends Af_ComicFilter {
+
+ function supported() {
+ return array("Dark Legacy Comics");
+ }
+
+ function process(&$article) {
+ $owner_uid = $article["owner_uid"];
+
+ if (strpos($article["guid"], "darklegacycomics.com") !== FALSE) {
+
+ $res = fetch_file_contents($article["link"], false, false, false,
+ false, false, 0,
+ "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)");
+
+ global $fetch_last_error_content;
+
+ if (!$res && $fetch_last_error_content)
+ $res = $fetch_last_error_content;
+
+ $doc = new DOMDocument();
+ @$doc->loadHTML($res);
+
+ $basenode = false;
+
+ if ($doc) {
+ $xpath = new DOMXPath($doc);
+ $basenode = $xpath->query('//div[@class="comic"]')->item(0);
+
+ if ($basenode) {
+
+ $article["content"] = $doc->saveXML($basenode);
+ }
+ }
+
+ return true;
+ }
+
+ return false;
+ }
+}
+?>
diff --git a/plugins/af_comics/filters/af_comics_dilbert.php b/plugins/af_comics/filters/af_comics_dilbert.php
new file mode 100644
index 000000000..f0e31cf88
--- /dev/null
+++ b/plugins/af_comics/filters/af_comics_dilbert.php
@@ -0,0 +1,47 @@
+<?php
+class Af_Comics_Dilbert extends Af_ComicFilter {
+
+ function supported() {
+ return array("Dilbert");
+ }
+
+ function process(&$article) {
+ $owner_uid = $article["owner_uid"];
+
+ if (strpos($article["guid"], "dilbert.com") !== FALSE) {
+ $doc = new DOMDocument();
+ @$doc->loadHTML(fetch_file_contents($article["link"]));
+
+ $basenode = false;
+
+ if ($doc) {
+ $xpath = new DOMXPath($doc);
+ $entries = $xpath->query('(//img[@src])'); // we might also check for img[@class='strip'] I guess...
+
+ $matches = array();
+
+ foreach ($entries as $entry) {
+
+ if (preg_match("/dyn\/str_strip\/.*zoom\.gif$/", $entry->getAttribute("src"), $matches)) {
+
+ $entry->setAttribute("src",
+ rewrite_relative_url("http://dilbert.com/",
+ $matches[0]));
+
+ $basenode = $entry;
+ break;
+ }
+ }
+
+ if ($basenode) {
+ $article["content"] = $doc->saveXML($basenode);
+ }
+ }
+
+ return true;
+ }
+
+ return false;
+ }
+}
+?>
diff --git a/plugins/af_comics/filters/af_comics_explosm.php b/plugins/af_comics/filters/af_comics_explosm.php
new file mode 100644
index 000000000..cba7ad0ad
--- /dev/null
+++ b/plugins/af_comics/filters/af_comics_explosm.php
@@ -0,0 +1,44 @@
+<?php
+class Af_Comics_Explosm extends Af_ComicFilter {
+
+ function supported() {
+ return array("Cyanide and Happiness");
+ }
+
+ function process(&$article) {
+ $owner_uid = $article["owner_uid"];
+
+ if (strpos($article["link"], "explosm.net/comics") !== FALSE) {
+
+ $doc = new DOMDocument();
+ @$doc->loadHTML(fetch_file_contents($article["link"]));
+
+ $basenode = false;
+
+ if ($doc) {
+ $xpath = new DOMXPath($doc);
+ $entries = $xpath->query('(//img[@src])'); // we might also check for img[@class='strip'] I guess...
+
+ $matches = array();
+
+ foreach ($entries as $entry) {
+
+ if (preg_match("/(http:\/\/.*\/db\/files\/Comics\/.*)/i", $entry->getAttribute("src"), $matches)) {
+
+ $basenode = $entry;
+ break;
+ }
+ }
+
+ if ($basenode) {
+ $article["content"] = $doc->saveXML($basenode);
+ }
+ }
+
+ return true;
+ }
+
+ return false;
+ }
+}
+?>
diff --git a/plugins/af_comics/filters/af_comics_gocomics.php b/plugins/af_comics/filters/af_comics_gocomics.php
new file mode 100644
index 000000000..9b3c787de
--- /dev/null
+++ b/plugins/af_comics/filters/af_comics_gocomics.php
@@ -0,0 +1,53 @@
+<?php
+class Af_Comics_GoComics extends Af_ComicFilter {
+
+ function supported() {
+ return array("GoComics");
+ }
+
+ function process(&$article) {
+ $owner_uid = $article["owner_uid"];
+
+ if (strpos($article["guid"], "gocomics.com") !== FALSE) {
+ $doc = new DOMDocument();
+ @$doc->loadHTML(fetch_file_contents($article["link"]));
+
+ $basenode = false;
+
+ if ($doc) {
+ $xpath = new DOMXPath($doc);
+ $entries = $xpath->query("(//img[@class='strip'])");
+
+ $matches = array();
+
+ if ($entries->length > 1) { // if we have more than one match, then get the zoomed one, which is the second for gocomics
+ $entry = $entries->item(1); // get the second element (items start at 0)
+ if (preg_match("/(http:\/\/assets.amuniversal.com\/.*)/i", $entry->getAttribute("src"), $matches)) {
+ $entry->setAttribute("src", $matches[0]);
+ $basenode = $entry;
+ }
+ }
+
+ if (!$basenode) {
+ // fallback on the smaller version
+ foreach ($entries as $entry) {
+ if (preg_match("/(http:\/\/assets.amuniversal.com\/.*)/i", $entry->getAttribute("src"), $matches)) {
+ $entry->setAttribute("src", $matches[0]);
+ $basenode = $entry;
+ break;
+ }
+ }
+ }
+
+ if ($basenode) {
+ $article["content"] = $doc->saveXML($basenode);
+ }
+ }
+
+ return true;
+ }
+
+ return false;
+ }
+}
+?>
diff --git a/plugins/af_comics/filters/af_comics_pa.php b/plugins/af_comics/filters/af_comics_pa.php
new file mode 100644
index 000000000..a13857cc1
--- /dev/null
+++ b/plugins/af_comics/filters/af_comics_pa.php
@@ -0,0 +1,77 @@
+<?php
+class Af_Comics_Pa extends Af_ComicFilter {
+
+ function supported() {
+ return array("Penny Arcade");
+ }
+
+ function process(&$article) {
+ if (strpos($article["link"], "penny-arcade.com") !== FALSE && strpos($article["title"], "Comic:") !== FALSE) {
+
+ if ($debug_enabled) {
+ _debug("af_pennyarcade: Processing comic");
+ }
+
+ $doc = new DOMDocument();
+ $doc->loadHTML(fetch_file_contents($article["link"]));
+
+ $basenode = false;
+
+ if ($doc) {
+ $xpath = new DOMXPath($doc);
+ $basenode = $xpath->query('(//div[@id="comicFrame"])')->item(0);
+
+ if ($basenode) {
+ $article["content"] = $doc->saveXML($basenode);
+ }
+ }
+
+ return true;
+ }
+
+ if (strpos($article["link"], "penny-arcade.com") !== FALSE && strpos($article["title"], "News Post:") !== FALSE) {
+ if ($debug_enabled) {
+ _debug("af_pennyarcade: Processing news post");
+ }
+ $doc = new DOMDocument();
+ $doc->loadHTML(fetch_file_contents($article["link"]));
+
+ if ($doc) {
+ $xpath = new DOMXPath($doc);
+ $entries = $xpath->query('(//div[@class="post"])');
+
+ $basenode = false;
+
+ foreach ($entries as $entry) {
+ $basenode = $entry;
+ }
+
+ $meta = $xpath->query('(//div[@class="meta"])')->item(0);
+ if ($meta->parentNode) { $meta->parentNode->removeChild($meta); }
+
+ $header = $xpath->query('(//div[@class="postBody"]/h2)')->item(0);
+ if ($header->parentNode) { $header->parentNode->removeChild($header); }
+
+ $header = $xpath->query('(//div[@class="postBody"]/div[@class="comicPost"])')->item(0);
+ if ($header->parentNode) { $header->parentNode->removeChild($header); }
+
+ $avatar = $xpath->query('(//div[@class="avatar"]//img)')->item(0);
+ $basenode->insertBefore($avatar, $basenode->firstChild);
+
+ $uninteresting = $xpath->query('(//div[@class="avatar"])');
+ foreach ($uninteresting as $i) {
+ $i->parentNode->removeChild($i);
+ }
+
+ if ($basenode){
+ $article["content"] = $doc->saveXML($basenode);
+ }
+ }
+
+ return true;
+ }
+
+ return false;
+ }
+}
+?>
diff --git a/plugins/af_comics/filters/af_comics_tfd.php b/plugins/af_comics/filters/af_comics_tfd.php
new file mode 100644
index 000000000..c4e594551
--- /dev/null
+++ b/plugins/af_comics/filters/af_comics_tfd.php
@@ -0,0 +1,32 @@
+<?php
+class Af_Comics_Tfd extends Af_ComicFilter {
+
+ function supported() {
+ return array("Toothpaste For Dinner");
+ }
+
+ function process(&$article) {
+ $owner_uid = $article["owner_uid"];
+
+ if (strpos($article["link"], "toothpastefordinner.com") !== FALSE) {
+ $doc = new DOMDocument();
+
+ @$doc->loadHTML(fetch_file_contents($article["link"]));
+
+ $basenode = false;
+
+ if ($doc) {
+ $xpath = new DOMXPath($doc);
+ $basenode = $xpath->query('//img[@class="comic"]')->item(0);
+
+ if ($basenode) {
+ $article["content"] = $doc->saveXML($basenode);
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+}
+?>
diff --git a/plugins/af_comics/filters/af_comics_twp.php b/plugins/af_comics/filters/af_comics_twp.php
new file mode 100644
index 000000000..ec43c1379
--- /dev/null
+++ b/plugins/af_comics/filters/af_comics_twp.php
@@ -0,0 +1,33 @@
+<?php
+class Af_Comics_Twp extends Af_ComicFilter {
+
+ function supported() {
+ return array("Three Word Phrase");
+ }
+
+ function process(&$article) {
+
+ if (strpos($article["link"], "threewordphrase.com") !== FALSE) {
+
+ $doc = new DOMDocument();
+ @$doc->loadHTML(fetch_file_contents($article["link"]));
+
+ $basenode = false;
+
+ if ($doc) {
+ $xpath = new DOMXpath($doc);
+
+ $basenode = $xpath->query("//td/center/img")->item(0);
+
+ if ($basenode) {
+ $article["content"] = $doc->saveXML($basenode);
+ }
+ }
+
+ return true;
+ }
+
+ return false;
+ }
+}
+?>