]> git.wh0rd.org Git - tt-rss.git/commitdiff
geturl: limit amount of redirects
authorAndrew Dolgov <fox@madoka.volgo-balt.ru>
Wed, 10 Jul 2013 16:18:20 +0000 (20:18 +0400)
committerAndrew Dolgov <fox@madoka.volgo-balt.ru>
Wed, 10 Jul 2013 16:18:20 +0000 (20:18 +0400)
include/functions.php

index d71f81ac4f7c001990a22a3a69da8c341dec9158..8a8f7b5d013e4950b845891fc2d9064bdccff0bb 100644 (file)
                return in_array($interface, class_implements($class));
        }
 
-       function geturl($url){
+       function geturl($url, $depth = 0){
+
+               if ($depth == 20) return $url;
 
                if (!function_exists('curl_init'))
                        return user_error('CURL Must be installed for geturl function to work. Ask your host to enable it or uncomment extension=php_curl.dll in php.ini', E_USER_ERROR);
                                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):'';
+                               return (isset($url_parsed))? geturl($url, $depth + 1):'';
                        }
 
                        global $fetch_last_error;