]> git.wh0rd.org - tt-rss.git/commitdiff
geturl: if head request is denied because host is still living in 20th century, try...
authorAndrew Dolgov <noreply@fakecake.org>
Wed, 20 Aug 2014 08:01:41 +0000 (12:01 +0400)
committerAndrew Dolgov <noreply@fakecake.org>
Wed, 20 Aug 2014 08:01:41 +0000 (12:01 +0400)
include/functions.php
include/functions2.php

index c595944e19c754684fe5a67c76721936bda08604..ac8fb6302904237725ecd88f77f097483d8d6c21 100644 (file)
 
                        $fetch_curl_used = true;
 
-                       if (ini_get("safe_mode") || ini_get("open_basedir")) {
+                       if (ini_get("safe_mode") || ini_get("open_basedir") || defined("FORCE_GETURL")) {
                                $new_url = geturl($url);
                                if (!$new_url) {
                                    // geturl has already populated $fetch_last_error
index 9d8bc76aad7493dadff1ab6347b88aa97be068d0..555aa04e9623dc20e3af5c166fbcd7806a91cfd4 100644 (file)
                return in_array($interface, class_implements($class));
        }
 
-       function geturl($url, $depth = 0){
+       function geturl($url, $depth = 0, $nobody = true){
 
                if ($depth == 20) return $url;
 
                curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 5.1; rv:5.0) Gecko/20100101 Firefox/5.0 Firefox/5.0');
                curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
                curl_setopt($curl, CURLOPT_HEADER, true);
-               curl_setopt($curl, CURLOPT_NOBODY, true);
+               curl_setopt($curl, CURLOPT_NOBODY, $nobody);
                curl_setopt($curl, CURLOPT_REFERER, $url);
                curl_setopt($curl, CURLOPT_ENCODING, 'gzip,deflate');
                curl_setopt($curl, CURLOPT_AUTOREFERER, true);
                $status = curl_getinfo($curl);
 
                if($status['http_code']!=200){
+
+                       // idiot site not allowing http get
+                       if($status['http_code'] == 405) {
+                               curl_close($curl);
+                               return geturl($url, $depth +1, false);
+                       }
+
                        if($status['http_code'] == 301 || $status['http_code'] == 302) {
                                curl_close($curl);
                                list($header) = explode("\r\n\r\n", $html, 2);