summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2013-06-13 12:41:13 +0400
committerAndrew Dolgov <[email protected]>2013-06-13 12:41:13 +0400
commitedcbb8c9976faffd9899f16cb4e99a439508d602 (patch)
tree17cd5ac50a061df1c89c3d788709c80c4c21d099 /plugins
parentb5a9ef5ebc052922ff4d57a6f3611b4fb1f29a2c (diff)
add plugin for bunicomic.com
Diffstat (limited to 'plugins')
-rw-r--r--plugins/af_buni/init.php62
1 files changed, 62 insertions, 0 deletions
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 @@
+<?php
+class Af_Buni extends Plugin {
+
+ private $host;
+
+ function about() {
+ return array(1.0,
+ "Fix Buni rss feed",
+ "fox");
+ }
+
+ function init($host) {
+ $this->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;
+ }
+
+}
+?>