2014-02-17 10:00:25 +01:00
|
|
|
<?php
|
|
|
|
class Af_Comics_Dilbert extends Af_ComicFilter {
|
|
|
|
|
|
|
|
function supported() {
|
|
|
|
return array("Dilbert");
|
|
|
|
}
|
|
|
|
|
|
|
|
function process(&$article) {
|
2015-01-15 07:23:45 +01:00
|
|
|
if (strpos($article["link"], "dilbert.com") !== FALSE) {
|
2014-12-03 20:43:25 +01:00
|
|
|
$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;
|
|
|
|
|
2014-02-17 10:00:25 +01:00
|
|
|
$doc = new DOMDocument();
|
2014-12-03 20:43:25 +01:00
|
|
|
@$doc->loadHTML($res);
|
2014-02-17 10:00:25 +01:00
|
|
|
|
|
|
|
$basenode = false;
|
|
|
|
|
|
|
|
if ($doc) {
|
|
|
|
$xpath = new DOMXPath($doc);
|
2014-12-03 20:43:25 +01:00
|
|
|
|
2015-01-15 07:23:45 +01:00
|
|
|
$basenode = $xpath->query('//img[contains(@class, "img-comic")]')->item(0);
|
2014-12-03 20:43:25 +01:00
|
|
|
|
|
|
|
/* $entries = $xpath->query('(//img[@src])'); // we might also check for img[@class='strip'] I guess...
|
2014-02-17 10:00:25 +01:00
|
|
|
|
|
|
|
$matches = array();
|
|
|
|
|
|
|
|
foreach ($entries as $entry) {
|
|
|
|
|
2014-12-03 20:43:25 +01:00
|
|
|
if (preg_match("/dyn\/str_strip\/.*strip\.gif$/", $entry->getAttribute("src"), $matches)) {
|
2014-02-17 10:00:25 +01:00
|
|
|
|
|
|
|
$entry->setAttribute("src",
|
|
|
|
rewrite_relative_url("http://dilbert.com/",
|
|
|
|
$matches[0]));
|
|
|
|
|
|
|
|
$basenode = $entry;
|
|
|
|
break;
|
|
|
|
}
|
2014-12-03 20:43:25 +01:00
|
|
|
} */
|
2014-02-17 10:00:25 +01:00
|
|
|
|
|
|
|
if ($basenode) {
|
|
|
|
$article["content"] = $doc->saveXML($basenode);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|