diff options
author | Art4 <[email protected]> | 2015-02-19 23:17:43 +0100 |
---|---|---|
committer | Art4 <[email protected]> | 2015-02-19 23:17:43 +0100 |
commit | d9c042c4c536f1afbf206aeea09b0b127b7b6418 (patch) | |
tree | 9d7ef18c6d9d4c8f8f4d1c9a5dbfceeb9fd5acf4 /plugins/af_comics/filters | |
parent | cf42b79120290ee5866136a0c4656e6999f06045 (diff) | |
parent | 4ca621a36016de1fbb5447e1c1de0b607ba94a7c (diff) |
Merge branch 'master' into patch-1
Conflicts:
locale/de_DE/LC_MESSAGES/messages.po
Diffstat (limited to 'plugins/af_comics/filters')
-rw-r--r-- | plugins/af_comics/filters/af_comics_dilbert.php | 22 | ||||
-rw-r--r-- | plugins/af_comics/filters/af_comics_explosm.php | 13 | ||||
-rw-r--r-- | plugins/af_comics/filters/af_comics_pa.php | 4 | ||||
-rw-r--r-- | plugins/af_comics/filters/af_comics_tfd.php | 32 |
4 files changed, 52 insertions, 19 deletions
diff --git a/plugins/af_comics/filters/af_comics_dilbert.php b/plugins/af_comics/filters/af_comics_dilbert.php index f0e31cf88..5faba7eb7 100644 --- a/plugins/af_comics/filters/af_comics_dilbert.php +++ b/plugins/af_comics/filters/af_comics_dilbert.php @@ -6,23 +6,33 @@ class Af_Comics_Dilbert extends Af_ComicFilter { } function process(&$article) { - $owner_uid = $article["owner_uid"]; + if (strpos($article["link"], "dilbert.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; - if (strpos($article["guid"], "dilbert.com") !== FALSE) { $doc = new DOMDocument(); - @$doc->loadHTML(fetch_file_contents($article["link"])); + @$doc->loadHTML($res); $basenode = false; if ($doc) { $xpath = new DOMXPath($doc); - $entries = $xpath->query('(//img[@src])'); // we might also check for img[@class='strip'] I guess... + + $basenode = $xpath->query('//img[contains(@class, "img-comic")]')->item(0); + + /* $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)) { + if (preg_match("/dyn\/str_strip\/.*strip\.gif$/", $entry->getAttribute("src"), $matches)) { $entry->setAttribute("src", rewrite_relative_url("http://dilbert.com/", @@ -31,7 +41,7 @@ class Af_Comics_Dilbert extends Af_ComicFilter { $basenode = $entry; break; } - } + } */ if ($basenode) { $article["content"] = $doc->saveXML($basenode); diff --git a/plugins/af_comics/filters/af_comics_explosm.php b/plugins/af_comics/filters/af_comics_explosm.php index cba7ad0ad..30b7e24c9 100644 --- a/plugins/af_comics/filters/af_comics_explosm.php +++ b/plugins/af_comics/filters/af_comics_explosm.php @@ -17,18 +17,7 @@ class Af_Comics_Explosm extends Af_ComicFilter { 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; - } - } + $basenode = $xpath->query('(//img[@id="main-comic"])')->item(0); if ($basenode) { $article["content"] = $doc->saveXML($basenode); diff --git a/plugins/af_comics/filters/af_comics_pa.php b/plugins/af_comics/filters/af_comics_pa.php index a13857cc1..0848adbd0 100644 --- a/plugins/af_comics/filters/af_comics_pa.php +++ b/plugins/af_comics/filters/af_comics_pa.php @@ -56,7 +56,9 @@ class Af_Comics_Pa extends Af_ComicFilter { if ($header->parentNode) { $header->parentNode->removeChild($header); } $avatar = $xpath->query('(//div[@class="avatar"]//img)')->item(0); - $basenode->insertBefore($avatar, $basenode->firstChild); + + if ($basenode) + $basenode->insertBefore($avatar, $basenode->firstChild); $uninteresting = $xpath->query('(//div[@class="avatar"])'); foreach ($uninteresting as $i) { 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; + } +} +?> |