summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2021-03-04 15:07:55 +0300
committerAndrew Dolgov <[email protected]>2021-03-04 15:07:55 +0300
commitade6c5b6ba99c9436310accde69f624da26c7071 (patch)
tree37e863d2f5788c7226e7938d68f934ddbaf77e7f
initial
-rw-r--r--init.php44
1 files changed, 44 insertions, 0 deletions
diff --git a/init.php b/init.php
new file mode 100644
index 0000000..4e81fde
--- /dev/null
+++ b/init.php
@@ -0,0 +1,44 @@
+<?php
+class Af_Fsckportal extends Plugin {
+
+ private $host;
+
+ function about() {
+ return array(null,
+ "Remove feedsportal spamlinks from article content",
+ "fox");
+ }
+
+ function init($host) {
+ $this->host = $host;
+
+ $host->add_hook($host::HOOK_ARTICLE_FILTER, $this);
+ }
+
+ function hook_article_filter($article) {
+
+ $doc = new DOMDocument();
+
+ if (@$doc->loadHTML('<?xml encoding="UTF-8">' . $article["content"])) {
+ $xpath = new DOMXPath($doc);
+ $entries = $xpath->query('(//img[@src]|//a[@href])');
+
+ foreach ($entries as $entry) {
+ if (preg_match("/feedsportal.com/", $entry->getAttribute("src"))) {
+ $entry->parentNode->removeChild($entry);
+ } else if (preg_match("/feedsportal.com/", $entry->getAttribute("href"))) {
+ $entry->parentNode->removeChild($entry);
+ }
+ }
+
+ $article["content"] = $doc->saveHTML();
+ }
+
+ return $article;
+ }
+
+ function api_version() {
+ return 2;
+ }
+
+}