]> git.wh0rd.org - tt-rss.git/blobdiff - include/functions2.php
pass several image files used in notify messages to frontend as base64 to prevent...
[tt-rss.git] / include / functions2.php
index ff4ac2c771f358fec01c23b630889a188f9d7154..56676b1655cb56f461a6cdbe39c1a779cecbf844 100644 (file)
 
                $params['simple_update'] = defined('SIMPLE_UPDATE_MODE') && SIMPLE_UPDATE_MODE;
 
+               $params["icon_alert"] = base64_img("images/alert.png");
+               $params["icon_information"] = base64_img("images/information.png");
+               $params["icon_cross"] = base64_img("images/cross.png");
+               $params["icon_indicator_white"] = base64_img("images/indicator_white.gif");
+
                return $params;
        }
 
                $doc->loadHTML($charset_hack . $res);
                $xpath = new DOMXPath($doc);
 
-               $entries = $xpath->query('(//a[@href]|//img[@src])');
+               $entries = $xpath->query('(//a[@href]|//img[@src]|//video/source[@src])');
 
                $ttrss_uses_https = parse_url(get_self_url_prefix(), PHP_URL_SCHEME) === 'https';
 
                                if ($entry->hasAttribute('src')) {
                                        $src = rewrite_relative_url($site_url, $entry->getAttribute('src'));
 
-                                       $cached_filename = CACHE_DIR . '/images/' . sha1($src) . '.png';
+                                       $extension = $entry->tagName == 'source' ? '.mp4' : '.png';
+                                       $cached_filename = CACHE_DIR . '/images/' . sha1($src) . $extension;
 
                                        if (file_exists($cached_filename)) {
-                                               $src = SELF_URL_PATH . '/public.php?op=cached_image&hash=' . sha1($src);
+                                               $src = SELF_URL_PATH . '/public.php?op=cached_image&hash=' . sha1($src) . $extension;
 
                                                if ($entry->hasAttribute('srcset')) {
                                                        $entry->removeAttribute('srcset');
 
                                        $entry->setAttribute('src', $src);
                                }
-
+                               
                                if ($entry->nodeName == 'img') {
+
                                        if ($entry->hasAttribute('src')) {
                                                $is_https_url = parse_url($entry->getAttribute('src'), PHP_URL_SCHEME) === 'https';
 
                        num_comments,
                        tag_cache,
                        author,
+                       guid,
                        orig_feed_id,
                        note
                        FROM ttrss_entries,ttrss_user_entries
 #                              $entry .= " <a target=\"_blank\" href=\"" . htmlspecialchars($url) . "\">" .
 #                                      $filename . " (" . $ctype . ")" . "</a>";
 
-                               $entry = "<div onclick=\"window.open('".htmlspecialchars($url)."')\"
+                               $entry = "<div onclick=\"openUrlPopup('".htmlspecialchars($url)."')\"
                                        dojoType=\"dijit.MenuItem\">$filename ($ctype)</div>";
 
                                array_push($entries_html, $entry);
                                else
                                        $filename = "";
 
-                               $rv .= "<div onclick='window.open(\"".htmlspecialchars($entry["url"])."\")'
+                               $rv .= "<div onclick='openUrlPopup(\"".htmlspecialchars($entry["url"])."\")'
                                        dojoType=\"dijit.MenuItem\">".$filename . $title."</div>";
 
                        };
        }
 
        function theme_valid($theme) {
-               if ($theme == "default.css" || $theme == "night.css") return true; // needed for array_filter
+               $bundled_themes = [ "default.php", "night.css", "compact.css" ];
+               
+               if (in_array($theme, $bundled_themes)) return true;
+
                $file = "themes/" . basename($theme);
 
                if (!file_exists($file)) $file = "themes.local/" . basename($theme);
 
                return $errors[$code];
        }
+
+       function base64_img($filename) {
+               if (file_exists($filename)) {
+                        $ext = pathinfo($filename, PATHINFO_EXTENSION);
+
+                       return "data:image/$ext;base64," . base64_encode(file_get_contents($filename));
+               } else {
+                       return "";
+               }
+       }
 ?>