]>
Commit | Line | Data |
---|---|---|
901dd67a AD |
1 | <?php |
2 | class Af_Comics_Dilbert extends Af_ComicFilter { | |
3 | ||
4 | function supported() { | |
5 | return array("Dilbert"); | |
6 | } | |
7 | ||
8 | function process(&$article) { | |
901dd67a | 9 | if (strpos($article["guid"], "dilbert.com") !== FALSE) { |
9fd58133 AD |
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 | ||
901dd67a | 19 | $doc = new DOMDocument(); |
9fd58133 | 20 | @$doc->loadHTML($res); |
901dd67a AD |
21 | |
22 | $basenode = false; | |
23 | ||
24 | if ($doc) { | |
25 | $xpath = new DOMXPath($doc); | |
9fd58133 AD |
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... | |
901dd67a AD |
30 | |
31 | $matches = array(); | |
32 | ||
33 | foreach ($entries as $entry) { | |
34 | ||
9fd58133 | 35 | if (preg_match("/dyn\/str_strip\/.*strip\.gif$/", $entry->getAttribute("src"), $matches)) { |
901dd67a AD |
36 | |
37 | $entry->setAttribute("src", | |
38 | rewrite_relative_url("http://dilbert.com/", | |
39 | $matches[0])); | |
40 | ||
41 | $basenode = $entry; | |
42 | break; | |
43 | } | |
9fd58133 | 44 | } */ |
901dd67a AD |
45 | |
46 | if ($basenode) { | |
47 | $article["content"] = $doc->saveXML($basenode); | |
901dd67a AD |
48 | } |
49 | } | |
901dd67a AD |
50 | |
51 | return true; | |
52 | } | |
53 | ||
54 | return false; | |
55 | } | |
56 | } | |
57 | ?> |