]>
git.wh0rd.org - tt-rss.git/blob - plugins/af_fsckportal/init.php
2 class Af_Fsckportal
extends Plugin
{
8 "Remove feedsportal spamlinks from article content",
12 function init($host) {
15 $host->add_hook($host::HOOK_ARTICLE_FILTER
, $this);
18 function hook_article_filter($article) {
19 $owner_uid = $article["owner_uid"];
21 if (strpos($article["plugin_data"], "fsckportal,$owner_uid:") === FALSE) {
23 $doc = new DOMDocument();
25 $charset_hack = '<head>
26 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
29 @$doc->loadHTML($charset_hack . $article["content"]);
32 $xpath = new DOMXPath($doc);
33 $entries = $xpath->query('(//img[@src]|//a[@href])');
35 foreach ($entries as $entry) {
36 if (preg_match("/feedsportal.com/", $entry->getAttribute("src"))) {
37 $entry->parentNode
->removeChild($entry);
38 } else if (preg_match("/feedsportal.com/", $entry->getAttribute("href"))) {
39 $entry->parentNode
->removeChild($entry);
43 $article["content"] = $doc->saveXML();
44 $article["plugin_data"] = "fsckportal,$owner_uid:" . $article["plugin_data"];
47 } else if (isset($article["stored"]["content"])) {
48 $article["content"] = $article["stored"]["content"];
54 function api_version() {