]>
Commit | Line | Data |
---|---|---|
1 | <?php | |
2 | class Af_Comics_Dilbert extends Af_ComicFilter { | |
3 | ||
4 | function supported() { | |
5 | return array("Dilbert"); | |
6 | } | |
7 | ||
8 | function process(&$article) { | |
9 | if (strpos($article["guid"], "dilbert.com") !== FALSE) { | |
10 | $res = fetch_file_contents($article["link"], false, false, false, | |
11 | false, false, 0, | |
12 | "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)"); | |
13 | ||
14 | global $fetch_last_error_content; | |
15 | ||
16 | if (!$res && $fetch_last_error_content) | |
17 | $res = $fetch_last_error_content; | |
18 | ||
19 | $doc = new DOMDocument(); | |
20 | @$doc->loadHTML($res); | |
21 | ||
22 | $basenode = false; | |
23 | ||
24 | if ($doc) { | |
25 | $xpath = new DOMXPath($doc); | |
26 | ||
27 | $basenode = $xpath->query('//div[@class="STR_Image"]')->item(0); | |
28 | ||
29 | /* $entries = $xpath->query('(//img[@src])'); // we might also check for img[@class='strip'] I guess... | |
30 | ||
31 | $matches = array(); | |
32 | ||
33 | foreach ($entries as $entry) { | |
34 | ||
35 | if (preg_match("/dyn\/str_strip\/.*strip\.gif$/", $entry->getAttribute("src"), $matches)) { | |
36 | ||
37 | $entry->setAttribute("src", | |
38 | rewrite_relative_url("http://dilbert.com/", | |
39 | $matches[0])); | |
40 | ||
41 | $basenode = $entry; | |
42 | break; | |
43 | } | |
44 | } */ | |
45 | ||
46 | if ($basenode) { | |
47 | $article["content"] = $doc->saveXML($basenode); | |
48 | } | |
49 | } | |
50 | ||
51 | return true; | |
52 | } | |
53 | ||
54 | return false; | |
55 | } | |
56 | } | |
57 | ?> |