}
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);
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;
+ }
+
+ array_push($names, $filter_name);
+
+ $filter = new $filter_name();
- if (is_subclass_of($filter, "Af_ComicFilter")) {
- array_push($this->filters, $filter);
+ 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 "<div dojoType=\"dijit.layout.AccordionPane\" title=\"".__('Feeds supported by af_comics')."\">";
print "<p>".__('GoComics requires a specific URL to workaround their lack of feed support: <code>http://feeds.feedburner.com/uclick/<em>comic_name</em></code> (e.g. <code>http://www.gocomics.com/garfield</code> uses <code>http://feeds.feedburner.com/uclick/garfield</code>).')."</p>";
+ print "<p>".__('Drop any updated filters into <code>filters.local</code> in plugin directory.')."</p>";
+
print "</div>";
}