]> git.wh0rd.org - tt-rss.git/blame - plugins/af_fsckportal/init.php
plugins: remove obsolete plugin_data/stored stuff
[tt-rss.git] / plugins / af_fsckportal / init.php
CommitLineData
1130125a
AD
1<?php
2class Af_Fsckportal extends Plugin {
3
4 private $host;
5
6 function about() {
7 return array(1.0,
8 "Remove feedsportal spamlinks from article content",
9 "fox");
10 }
11
12 function init($host) {
13 $this->host = $host;
14
15 $host->add_hook($host::HOOK_ARTICLE_FILTER, $this);
16 }
17
18 function hook_article_filter($article) {
1130125a
AD
19
20 $doc = new DOMDocument();
21
22 $charset_hack = '<head>
23 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
24 </head>';
25
26 @$doc->loadHTML($charset_hack . $article["content"]);
27
28 if ($doc) {
29 $xpath = new DOMXPath($doc);
30 $entries = $xpath->query('(//img[@src]|//a[@href])');
31
1130125a
AD
32 foreach ($entries as $entry) {
33 if (preg_match("/feedsportal.com/", $entry->getAttribute("src"))) {
34 $entry->parentNode->removeChild($entry);
35 } else if (preg_match("/feedsportal.com/", $entry->getAttribute("href"))) {
36 $entry->parentNode->removeChild($entry);
37 }
38 }
39
3263c9cc 40 $article["content"] = $doc->saveXML();
1130125a 41
1130125a
AD
42 }
43
44 return $article;
45 }
46
47 function api_version() {
48 return 2;
49 }
50
51}
52?>