]> git.wh0rd.org - tt-rss.git/blobdiff - plugins/af_unburn/init.php
Fixing bugs found by static analysis
[tt-rss.git] / plugins / af_unburn / init.php
index a0c51c97eadff495e151e7db1294be9118061599..a97502b12a7ebfd988916722ddc71f7f63496c6f 100644 (file)
@@ -1,7 +1,5 @@
 <?php
 class Af_Unburn extends Plugin {
-
-       private $link;
        private $host;
 
        function about() {
@@ -11,7 +9,6 @@ class Af_Unburn extends Plugin {
        }
 
        function init($host) {
-               $this->link = $host->get_link();
                $this->host = $host;
 
                $host->add_hook($host::HOOK_ARTICLE_FILTER, $this);
@@ -29,11 +26,16 @@ class Af_Unburn extends Plugin {
 
                        if (strpos($article["plugin_data"], "unburn,$owner_uid:") === FALSE) {
 
-                               $ch = curl_init(geturl($article["link"]));
+                               if (ini_get("safe_mode") || ini_get("open_basedir")) {
+                                       $ch = curl_init(geturl($article["link"]));
+                               } else {
+                                       $ch = curl_init($article["link"]);
+                               }
+
                                curl_setopt($ch, CURLOPT_TIMEOUT, 5);
                                curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
                                curl_setopt($ch, CURLOPT_HEADER, true);
-                               //curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
+                               curl_setopt($ch, CURLOPT_FOLLOWLOCATION, !ini_get("safe_mode") && !ini_get("open_basedir"));
                                curl_setopt($ch, CURLOPT_USERAGENT, SELF_USER_AGENT);
 
                                $contents = @curl_exec($ch);
@@ -74,7 +76,7 @@ class Af_Unburn extends Plugin {
 
                return $article;
        }
-       
+
                function geturl($url){
 
                (function_exists('curl_init')) ? '' : die('cURL Must be installed for geturl function to work. Ask your host to enable it or uncomment extension=php_curl.dll in php.ini');
@@ -112,7 +114,7 @@ class Af_Unburn extends Plugin {
                                preg_match("/(Location:|URI:)[^(\n)]*/", $header, $matches);
                                $url = trim(str_replace($matches[1],"",$matches[0]));
                                $url_parsed = parse_url($url);
-                               return (isset($url_parsed))? geturl($url, $referer):'';
+                               return (isset($url_parsed))? geturl($url):'';
                        }
                        $oline='';
                        foreach($status as $key=>$eline){$oline.='['.$key.']'.$eline.' ';}
@@ -123,5 +125,10 @@ class Af_Unburn extends Plugin {
                }
                return $url;
        }
+
+       function api_version() {
+               return 2;
+       }
+
 }
 ?>