]> git.wh0rd.org - tt-rss.git/blame - plugins/af_unburn/init.php
add af_unburn
[tt-rss.git] / plugins / af_unburn / init.php
CommitLineData
9b725068
AD
1<?php
2class Af_Unburn extends Plugin {
3
4 private $link;
5 private $host;
6
7 function about() {
8 return array(1.0,
9 "Resolve feedburner URLs (requires CURL)",
10 "fox");
11 }
12
13 function init($host) {
14 $this->link = $host->get_link();
15 $this->host = $host;
16
17 $host->add_hook($host::HOOK_ARTICLE_FILTER, $this);
18 }
19
20 function hook_article_filter($article) {
21 $owner_uid = $article["owner_uid"];
22
23 if (!function_exists("curl_init"))
24 return $article;
25
26 if (strpos($article["link"], "feedproxy.google.com") !== FALSE &&
27 strpos($article["guid"], "unburn,$owner_uid:") === FALSE) {
28
29 $ch = curl_init($article["link"]);
30 curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
31 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
32 curl_setopt($ch, CURLOPT_HEADER, true);
33 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
34
35 $contents = @curl_exec($ch);
36
37 $real_url = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
38
39 if ($real_url) {
40 $article["guid"] = "unburn,$owner_uid:" . $article["guid"];
41 $article["link"] = $real_url;
42 }
43 }
44
45 return $article;
46 }
47}
48?>