From edcbb8c9976faffd9899f16cb4e99a439508d602 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Thu, 13 Jun 2013 12:41:13 +0400 Subject: add plugin for bunicomic.com --- plugins/af_buni/init.php | 62 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 plugins/af_buni/init.php diff --git a/plugins/af_buni/init.php b/plugins/af_buni/init.php new file mode 100644 index 000000000..50166e325 --- /dev/null +++ b/plugins/af_buni/init.php @@ -0,0 +1,62 @@ +host = $host; + + $host->add_hook($host::HOOK_ARTICLE_FILTER, $this); + } + + function hook_article_filter($article) { + $owner_uid = $article["owner_uid"]; + + if (strpos($article["guid"], "bunicomic.com") !== FALSE) { + if (strpos($article["plugin_data"], "buni,$owner_uid:") === FALSE) { + + $doc = new DOMDocument(); + @$doc->loadHTML(fetch_file_contents($article["link"])); + + $basenode = false; + + if ($doc) { + $xpath = new DOMXPath($doc); + $entries = $xpath->query('(//img[@src])'); + + $matches = array(); + + foreach ($entries as $entry) { + + if (preg_match("/(http:\/\/www.bunicomic.com\/comics\/\d{4}.*)/i", $entry->getAttribute("src"), $matches)) { + + $basenode = $entry; + break; + } + } + + if ($basenode) { + $article["content"] = $doc->saveXML($basenode); + $article["plugin_data"] = "buni,$owner_uid:" . $article["plugin_data"]; + } + } + } else if (isset($article["stored"]["content"])) { + $article["content"] = $article["stored"]["content"]; + } + } + + return $article; + } + + function api_version() { + return 2; + } + +} +?> -- cgit v1.2.3