]>
Commit | Line | Data |
---|---|---|
73963a21 AD |
1 | <?php |
2 | class Af_Comics_Whomp extends Af_ComicFilter { | |
3 | ||
4 | function supported() { | |
5 | return array("Whomp!"); | |
6 | } | |
7 | ||
8 | function process(&$article) { | |
9 | if (strpos($article["guid"], "whompcomic.com") !== FALSE) { | |
10 | ||
11 | $res = fetch_file_contents($article["link"], false, false, false, | |
12 | false, false, 0, | |
13 | "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)"); | |
14 | ||
15 | global $fetch_last_error_content; | |
16 | ||
17 | if (!$res && $fetch_last_error_content) | |
18 | $res = $fetch_last_error_content; | |
19 | ||
20 | $doc = new DOMDocument(); | |
21 | ||
22 | if (@$doc->loadHTML($res)) { | |
23 | $xpath = new DOMXPath($doc); | |
24 | $basenode = $xpath->query('//img[@id="cc-comic"]')->item(0); | |
25 | ||
26 | if ($basenode) { | |
27 | $article["content"] = $doc->saveXML($basenode); | |
28 | } | |
29 | } | |
30 | ||
31 | return true; | |
32 | } | |
33 | ||
34 | return false; | |
35 | } | |
21ce7d9e | 36 | } |