]> git.wh0rd.org - tt-rss.git/blobdiff - include/functions2.php
fix typo
[tt-rss.git] / include / functions2.php
index d6a399ffcdd9a1fd4db9a5c7740abfe9ceb4d00d..deeaaf2109f5c93479e2d61f4042a60c451189d5 100644 (file)
                                $url = $line["content_url"];
                                $ctype = $line["content_type"];
                                $title = $line["title"];
+                               $width = $line["width"];
+                               $height = $line["height"];
 
                                if (!$ctype) $ctype = __("unknown type");
 
                                $entry["filename"] = $filename;
                                $entry["url"] = $url;
                                $entry["title"] = $title;
+                               $entry["width"] = $width;
+                               $entry["height"] = $height;
 
                                array_push($entries, $entry);
                        }
                                                                preg_match("/\.(jpg|png|gif|bmp)/i", $entry["filename"])) {
 
                                                                if (!$hide_images) {
+                                                                       $encsize = '';
+                                                                       if ($entry['height'] > 0)
+                                                                               $encsize .= ' height="' . intval($entry['width']) . '"';
+                                                                       if ($entry['width'] > 0)
+                                                                               $encsize .= ' width="' . intval($entry['height']) . '"';
                                                                        $rv .= "<p><img
                                                                        alt=\"".htmlspecialchars($entry["filename"])."\"
-                                                                       src=\"" .htmlspecialchars($entry["url"]) . "\"/></p>";
+                                                                       src=\"" .htmlspecialchars($entry["url"]) . "\"
+                                                                       " . $encsize . " /></p>";
                                                                } else {
                                                                        $rv .= "<p><a target=\"_blank\"
                                                                        href=\"".htmlspecialchars($entry["url"])."\"
                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, $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 head
+                       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);
                        if (!isset($_GET['debug'])) {
                                $cached_file = CACHE_DIR . "/js/".basename($js).".js";
 
-                               if (file_exists($cached_file) &&
-                                               is_readable($cached_file) &&
-                                               filemtime($cached_file) >= filemtime("js/$js.js")) {
+                               if (file_exists($cached_file) && is_readable($cached_file) && filemtime($cached_file) >= filemtime("js/$js.js")) {
 
-                                       $rv .= file_get_contents($cached_file);
+                                       list($header, $contents) = explode("\n", file_get_contents($cached_file), 2);
 
-                               } else {
-                                       $minified = JShrink\Minifier::minify(file_get_contents("js/$js.js"));
-                                       file_put_contents($cached_file, $minified);
-                                       $rv .= $minified;
+                                       if ($header && $contents) {
+                                               list($htag, $hversion) = explode(":", $header);
+
+                                               if ($htag == "tt-rss" && $hversion == VERSION) {
+                                                       $rv .= $contents;
+                                                       continue;
+                                               }
+                                       }
                                }
+
+                               $minified = JShrink\Minifier::minify(file_get_contents("js/$js.js"));
+                               file_put_contents($cached_file, "tt-rss:" . VERSION . "\n" . $minified);
+                               $rv .= $minified;
+
                        } else {
-                               $rv .= file_get_contents("js/$js.js");
+                               $rv .= file_get_contents("js/$js.js"); // no cache in debug mode
                        }
                }