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