]> git.wh0rd.org - tt-rss.git/blob - plugins/af_comics/filters/af_comics_comicpress.php
af_comics: split filters to separate files to ease maintenance
[tt-rss.git] / plugins / af_comics / filters / af_comics_comicpress.php
1 <?php
2 class Af_Comics_ComicPress extends Af_ComicFilter {
3
4 function supported() {
5 return array("Buni", "Buttersafe", "Whomp!", "Happy Jar", "CSection");
6 }
7
8 function process(&$article) {
9 $owner_uid = $article["owner_uid"];
10
11 if (strpos($article["guid"], "bunicomic.com") !== FALSE ||
12 strpos($article["guid"], "buttersafe.com") !== FALSE ||
13 strpos($article["guid"], "whompcomic.com") !== FALSE ||
14 strpos($article["guid"], "happyjar.com") !== FALSE ||
15 strpos($article["guid"], "csectioncomics.com") !== FALSE) {
16
17 if (strpos($article["plugin_data"], "af_comics,$owner_uid:") === FALSE) {
18
19 // lol at people who block clients by user agent
20 // oh noes my ad revenue Q_Q
21
22 $res = fetch_file_contents($article["link"], false, false, false,
23 false, false, 0,
24 "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)");
25
26 $doc = new DOMDocument();
27 @$doc->loadHTML($res);
28
29 $basenode = false;
30
31 if ($doc) {
32 $xpath = new DOMXPath($doc);
33 $basenode = $xpath->query('//div[@id="comic"]')->item(0);
34
35 if ($basenode) {
36 $article["content"] = $doc->saveXML($basenode);
37 $article["plugin_data"] = "af_comics,$owner_uid:" . $article["plugin_data"];
38 }
39 }
40 } else if (isset($article["stored"]["content"])) {
41 $article["content"] = $article["stored"]["content"];
42 }
43
44 return true;
45 }
46
47 return false;
48 }
49 }
50 ?>