$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])');
-
$ttrss_uses_https = parse_url(get_self_url_prefix(), PHP_URL_SCHEME) === 'https';
+ $rewrite_base_url = $site_url ? $site_url : SELF_URL_PATH;
+
+ $entries = $xpath->query('(//a[@href]|//img[@src]|//video/source[@src])');
foreach ($entries as $entry) {
- if ($site_url) {
+ if ($entry->hasAttribute('href')) {
+ $entry->setAttribute('href',
+ rewrite_relative_url($rewrite_base_url, $entry->getAttribute('href')));
+
+ $entry->setAttribute('rel', 'noopener noreferrer');
+ }
+
+ if ($entry->hasAttribute('src')) {
+ $src = rewrite_relative_url($rewrite_base_url, $entry->getAttribute('src'));
+
+ $extension = $entry->tagName == 'source' ? '.mp4' : '.png';
+ $cached_filename = CACHE_DIR . '/images/' . sha1($src) . $extension;
- if ($entry->hasAttribute('href')) {
- $entry->setAttribute('href',
- rewrite_relative_url($site_url, $entry->getAttribute('href')));
+ if (file_exists($cached_filename)) {
+ $src = get_self_url_prefix() . '/public.php?op=cached_image&hash=' . sha1($src) . $extension;
- $entry->setAttribute('rel', 'noopener noreferrer');
+ if ($entry->hasAttribute('srcset')) {
+ $entry->removeAttribute('srcset');
+ }
+
+ if ($entry->hasAttribute('sizes')) {
+ $entry->removeAttribute('sizes');
+ }
}
- if ($entry->hasAttribute('src')) {
- $src = rewrite_relative_url($site_url, $entry->getAttribute('src'));
+ $entry->setAttribute('src', $src);
+ }
+
+ if ($entry->nodeName == 'img') {
- $cached_filename = CACHE_DIR . '/images/' . sha1($src) . '.png';
+ if ($entry->hasAttribute('src')) {
+ $is_https_url = parse_url($entry->getAttribute('src'), PHP_URL_SCHEME) === 'https';
- if (file_exists($cached_filename)) {
- $src = SELF_URL_PATH . '/public.php?op=cached_image&hash=' . sha1($src);
+ if ($ttrss_uses_https && !$is_https_url) {
if ($entry->hasAttribute('srcset')) {
$entry->removeAttribute('srcset');
$entry->removeAttribute('sizes');
}
}
-
- $entry->setAttribute('src', $src);
}
- if ($entry->nodeName == 'img') {
- if ($entry->hasAttribute('src')) {
- $is_https_url = parse_url($entry->getAttribute('src'), PHP_URL_SCHEME) === 'https';
+ if (($owner && get_pref("STRIP_IMAGES", $owner)) ||
+ $force_remove_images || $_SESSION["bw_limit"]) {
- if ($ttrss_uses_https && !$is_https_url) {
+ $p = $doc->createElement('p');
- if ($entry->hasAttribute('srcset')) {
- $entry->removeAttribute('srcset');
- }
-
- if ($entry->hasAttribute('sizes')) {
- $entry->removeAttribute('sizes');
- }
- }
- }
-
- if (($owner && get_pref("STRIP_IMAGES", $owner)) ||
- $force_remove_images || $_SESSION["bw_limit"]) {
-
- $p = $doc->createElement('p');
-
- $a = $doc->createElement('a');
- $a->setAttribute('href', $entry->getAttribute('src'));
+ $a = $doc->createElement('a');
+ $a->setAttribute('href', $entry->getAttribute('src'));
- $a->appendChild(new DOMText($entry->getAttribute('src')));
- $a->setAttribute('target', '_blank');
+ $a->appendChild(new DOMText($entry->getAttribute('src')));
+ $a->setAttribute('target', '_blank');
+ $a->setAttribute('rel', 'noopener noreferrer');
- $p->appendChild($a);
+ $p->appendChild($a);
- $entry->parentNode->replaceChild($p, $entry);
- }
+ $entry->parentNode->replaceChild($p, $entry);
}
}
if (strtolower($entry->nodeName) == "a") {
$entry->setAttribute("target", "_blank");
+ $entry->setAttribute("rel", "noopener noreferrer");
}
}
</object>";
}
- if ($entry) $entry .= " <a target=\"_blank\"
+ if ($entry) $entry .= " <a target=\"_blank\" rel=\"noopener noreferrer\"
href=\"$url\">" . basename($url) . "</a>";
return $entry;
/* $filename = substr($url, strrpos($url, "/")+1);
- $entry .= " <a target=\"_blank\" href=\"" . htmlspecialchars($url) . "\">" .
+ $entry .= " <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"" . htmlspecialchars($url) . "\">" .
$filename . " (" . $ctype . ")" . "</a>"; */
}
num_comments,
tag_cache,
author,
+ guid,
orig_feed_id,
note
FROM ttrss_entries,ttrss_user_entries
$comments_url = htmlspecialchars($line["link"]);
}
$entry_comments = "<a class=\"postComments\"
- target='_blank' href=\"$comments_url\">$num_comments ".
+ target='_blank' rel=\"noopener noreferrer\" href=\"$comments_url\">$num_comments ".
_ngettext("comment", "comments", $num_comments)."</a>";
} else {
if ($line["comments"] && $line["link"] != $line["comments"]) {
- $entry_comments = "<a class=\"postComments\" target='_blank' href=\"".htmlspecialchars($line["comments"])."\">".__("comments")."</a>";
+ $entry_comments = "<a class=\"postComments\" target='_blank' rel=\"noopener noreferrer\" href=\"".htmlspecialchars($line["comments"])."\">".__("comments")."</a>";
}
}
$rv['content'] .= "<div class=\"postDate\">$parsed_updated</div>";
if ($line["link"]) {
- $rv['content'] .= "<div class='postTitle'><a target='_blank'
+ $rv['content'] .= "<div class='postTitle'><a target='_blank' rel='noopener noreferrer'
title=\"".htmlspecialchars($line['title'])."\"
href=\"" .
htmlspecialchars($line["link"]) . "\">" .
$tmp_line = db_fetch_assoc($tmp_result);
- $rv['content'] .= "<a target='_blank'
+ $rv['content'] .= "<a target='_blank' rel='noopener noreferrer'
href=' " . htmlspecialchars($tmp_line['site_url']) . "'>" .
$tmp_line['title'] . "</a>";
$rv['content'] .= " ";
- $rv['content'] .= "<a target='_blank' href='" . htmlspecialchars($tmp_line['feed_url']) . "'>";
+ $rv['content'] .= "<a target='_blank' rel='noopener noreferrer' href='" . htmlspecialchars($tmp_line['feed_url']) . "'>";
$rv['content'] .= "<img title='".__('Feed URL')."' class='tinyFeedIcon' src='images/pub_set.png'></a>";
$rv['content'] .= "</div>";
if ($player) array_push($entries_inline, $player);
-# $entry .= " <a target=\"_blank\" href=\"" . htmlspecialchars($url) . "\">" .
+# $entry .= " <a target=\"_blank\" href=\"" . htmlspecialchars($url) . "\" rel=\"noopener noreferrer\">" .
# $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);
src=\"" .htmlspecialchars($entry["url"]) . "\"
" . $encsize . " /></p>";
} else {
- $rv .= "<p><a target=\"_blank\"
+ $rv .= "<p><a target=\"_blank\" rel=\"noopener noreferrer\"
href=\"".htmlspecialchars($entry["url"])."\"
>" .htmlspecialchars($entry["url"]) . "</a></p>";
}
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 "";
+ }
+ }
?>