diff --git a/plugins/af_comics/filters.local/.empty b/plugins/af_comics/filters.local/.empty new file mode 100644 index 000000000..e69de29bb diff --git a/plugins/af_comics/filters/af_comics_cad.php b/plugins/af_comics/filters/af_comics_cad.php index 7c0670918..6846f3cb0 100644 --- a/plugins/af_comics/filters/af_comics_cad.php +++ b/plugins/af_comics/filters/af_comics_cad.php @@ -6,14 +6,23 @@ class Af_Comics_Cad extends Af_ComicFilter { } function process(&$article) { - if (strpos($article["link"], "cad-comic.com/cad/") !== FALSE) { + if (strpos($article["link"], "cad-comic.com") !== FALSE) { if (strpos($article["title"], "News:") === FALSE) { + global $fetch_last_error_content; + $doc = new DOMDocument(); - if (@$doc->loadHTML(fetch_file_contents($article["link"]))) { + $res = fetch_file_contents($article["link"], false, false, false, + false, false, 0, + "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:50.0) Gecko/20100101 Firefox/50.0"); + + if (!$res && $fetch_last_error_content) + $res = $fetch_last_error_content; + + if (@$doc->loadHTML($res)) { $xpath = new DOMXPath($doc); - $basenode = $xpath->query('(//img[contains(@src, "/comics/cad-")])')->item(0); + $basenode = $xpath->query('//div[@class="comicpage"]/a/img')->item(0); if ($basenode) { $article["content"] = $doc->saveXML($basenode); diff --git a/plugins/af_comics/init.php b/plugins/af_comics/init.php index 15af1d1a6..09e903379 100644 --- a/plugins/af_comics/init.php +++ b/plugins/af_comics/init.php @@ -19,23 +19,31 @@ class Af_Comics extends Plugin { require_once __DIR__ . "/filter_base.php"; - $filters = glob(__DIR__ . "/filters/*.php"); + $filters = array_merge(glob(__DIR__ . "/filters.local/*.php"), glob(__DIR__ . "/filters/*.php")); + $names = []; foreach ($filters as $file) { - require_once $file; $filter_name = preg_replace("/\..*$/", "", basename($file)); - $filter = new $filter_name(); + if (array_search($filter_name, $names) === FALSE) { + if (!class_exists($filter_name)) { + require_once $file; + } - if (is_subclass_of($filter, "Af_ComicFilter")) { - array_push($this->filters, $filter); + array_push($names, $filter_name); + + $filter = new $filter_name(); + + if (is_subclass_of($filter, "Af_ComicFilter")) { + array_push($this->filters, $filter); + array_push($names, $filter_name); + } } } - } function hook_prefs_tab($args) { - if ($args != "prefPrefs") return; + if ($args != "prefFeeds") return; print "
".__('GoComics requires a specific URL to workaround their lack of feed support: http://feeds.feedburner.com/uclick/comic_name
(e.g. http://www.gocomics.com/garfield
uses http://feeds.feedburner.com/uclick/garfield
).')."
".__('Drop any updated filters into filters.local
in plugin directory.')."