summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/af_comics/filters/af_comics_cad.php6
-rw-r--r--plugins/af_comics/filters/af_comics_comicclass.php4
-rwxr-xr-xplugins/af_comics/filters/af_comics_comicpress.php18
-rw-r--r--plugins/af_comics/filters/af_comics_darklegacy.php4
-rw-r--r--plugins/af_comics/filters/af_comics_dilbert.php6
-rw-r--r--plugins/af_comics/filters/af_comics_explosm.php4
-rw-r--r--plugins/af_comics/filters/af_comics_gocomics.php6
-rw-r--r--plugins/af_comics/filters/af_comics_gocomics_farside.php5
-rw-r--r--plugins/af_comics/filters/af_comics_pa.php8
-rw-r--r--plugins/af_comics/filters/af_comics_pvp.php4
-rw-r--r--plugins/af_comics/filters/af_comics_tfd.php8
-rw-r--r--plugins/af_comics/filters/af_comics_twp.php4
-rw-r--r--plugins/af_comics/filters/af_comics_whomp.php4
-rwxr-xr-xplugins/af_comics/init.php2
-rw-r--r--plugins/af_proxy_http/init.php46
-rw-r--r--plugins/af_psql_trgm/init.php12
-rw-r--r--plugins/af_readability/init.js4
-rwxr-xr-xplugins/af_readability/init.php16
-rwxr-xr-xplugins/af_redditimgur/init.php31
-rwxr-xr-xplugins/af_unburn/init.php8
-rw-r--r--plugins/auth_internal/init.php14
-rwxr-xr-xplugins/cache_starred_images/init.php8
-rw-r--r--plugins/hotkeys_force_top/init.js6
-rw-r--r--plugins/hotkeys_force_top/init.php24
-rw-r--r--plugins/hotkeys_noscroll/init.php2
-rw-r--r--plugins/hotkeys_swap_jk/init.php (renamed from plugins/swap_jk/init.php)4
-rw-r--r--plugins/mail/init.php14
-rw-r--r--plugins/mailto/init.php6
-rw-r--r--plugins/no_iframes/init.php4
-rw-r--r--plugins/shorten_expanded/init.js2
30 files changed, 149 insertions, 135 deletions
diff --git a/plugins/af_comics/filters/af_comics_cad.php b/plugins/af_comics/filters/af_comics_cad.php
index d2eb38caf..5da82ae3f 100644
--- a/plugins/af_comics/filters/af_comics_cad.php
+++ b/plugins/af_comics/filters/af_comics_cad.php
@@ -6,14 +6,14 @@ class Af_Comics_Cad extends Af_ComicFilter {
}
function process(&$article) {
- if (strpos($article["link"], "cad-comic.com") !== FALSE) {
- if (strpos($article["title"], "News:") === FALSE) {
+ if (strpos($article["link"], "cad-comic.com") !== false) {
+ if (strpos($article["title"], "News:") === false) {
global $fetch_last_error_content;
$doc = new DOMDocument();
- $res = fetch_file_contents($article["link"], false, false, false,
+ $res = UrlHelper::fetch($article["link"], false, false, false,
false, false, 0,
"Mozilla/5.0 (Windows NT 6.1; WOW64; rv:50.0) Gecko/20100101 Firefox/50.0");
diff --git a/plugins/af_comics/filters/af_comics_comicclass.php b/plugins/af_comics/filters/af_comics_comicclass.php
index b4b3a962c..ff32375d3 100644
--- a/plugins/af_comics/filters/af_comics_comicclass.php
+++ b/plugins/af_comics/filters/af_comics_comicclass.php
@@ -6,12 +6,12 @@ class Af_Comics_ComicClass extends Af_ComicFilter {
}
function process(&$article) {
- if (strpos($article["guid"], "loadingartist.com") !== FALSE) {
+ if (strpos($article["guid"], "loadingartist.com") !== false) {
// lol at people who block clients by user agent
// oh noes my ad revenue Q_Q
- $res = fetch_file_contents($article["link"], false, false, false,
+ $res = UrlHelper::fetch($article["link"], false, false, false,
false, false, 0,
"Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)");
diff --git a/plugins/af_comics/filters/af_comics_comicpress.php b/plugins/af_comics/filters/af_comics_comicpress.php
index 7755bcb1a..29b064612 100755
--- a/plugins/af_comics/filters/af_comics_comicpress.php
+++ b/plugins/af_comics/filters/af_comics_comicpress.php
@@ -7,18 +7,18 @@ class Af_Comics_ComicPress extends Af_ComicFilter {
}
function process(&$article) {
- if (strpos($article["guid"], "bunicomic.com") !== FALSE ||
- strpos($article["guid"], "buttersafe.com") !== FALSE ||
- strpos($article["guid"], "extrafabulouscomics.com") !== FALSE ||
- strpos($article["guid"], "happyjar.com") !== FALSE ||
- strpos($article["guid"], "nedroid.com") !== FALSE ||
- strpos($article["guid"], "stonetoss.com") !== FALSE ||
- strpos($article["guid"], "csectioncomics.com") !== FALSE) {
+ if (strpos($article["guid"], "bunicomic.com") !== false ||
+ strpos($article["guid"], "buttersafe.com") !== false ||
+ strpos($article["guid"], "extrafabulouscomics.com") !== false ||
+ strpos($article["guid"], "happyjar.com") !== false ||
+ strpos($article["guid"], "nedroid.com") !== false ||
+ strpos($article["guid"], "stonetoss.com") !== false ||
+ strpos($article["guid"], "csectioncomics.com") !== false) {
// lol at people who block clients by user agent
// oh noes my ad revenue Q_Q
- $res = fetch_file_contents(["url" => $article["link"],
+ $res = UrlHelper::fetch(["url" => $article["link"],
"useragent" => "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)"]);
$doc = new DOMDocument();
@@ -37,7 +37,7 @@ class Af_Comics_ComicPress extends Af_ComicFilter {
if ($webtoon_link) {
- $res = fetch_file_contents(["url" => $webtoon_link->getAttribute("href"),
+ $res = UrlHelper::fetch(["url" => $webtoon_link->getAttribute("href"),
"useragent" => "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)"]);
if (@$doc->loadHTML($res)) {
diff --git a/plugins/af_comics/filters/af_comics_darklegacy.php b/plugins/af_comics/filters/af_comics_darklegacy.php
index 0882514d0..978545431 100644
--- a/plugins/af_comics/filters/af_comics_darklegacy.php
+++ b/plugins/af_comics/filters/af_comics_darklegacy.php
@@ -7,9 +7,9 @@ class Af_Comics_DarkLegacy extends Af_ComicFilter {
function process(&$article) {
- if (strpos($article["guid"], "darklegacycomics.com") !== FALSE) {
+ if (strpos($article["guid"], "darklegacycomics.com") !== false) {
- $res = fetch_file_contents($article["link"], false, false, false,
+ $res = UrlHelper::fetch($article["link"], false, false, false,
false, false, 0,
"Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)");
diff --git a/plugins/af_comics/filters/af_comics_dilbert.php b/plugins/af_comics/filters/af_comics_dilbert.php
index a40f8a9ba..31a72d88d 100644
--- a/plugins/af_comics/filters/af_comics_dilbert.php
+++ b/plugins/af_comics/filters/af_comics_dilbert.php
@@ -7,10 +7,10 @@ class Af_Comics_Dilbert extends Af_ComicFilter {
}
function process(&$article) {
- if (strpos($article["link"], "dilbert.com") !== FALSE ||
- strpos($article["link"], "/DilbertDailyStrip") !== FALSE) {
+ if (strpos($article["link"], "dilbert.com") !== false ||
+ strpos($article["link"], "/DilbertDailyStrip") !== false) {
- $res = fetch_file_contents($article["link"], false, false, false,
+ $res = UrlHelper::fetch($article["link"], false, false, false,
false, false, 0,
"Mozilla/5.0 (Windows NT 6.1; WOW64; rv:50.0) Gecko/20100101 Firefox/50.0");
diff --git a/plugins/af_comics/filters/af_comics_explosm.php b/plugins/af_comics/filters/af_comics_explosm.php
index c47014da4..bfe38e53b 100644
--- a/plugins/af_comics/filters/af_comics_explosm.php
+++ b/plugins/af_comics/filters/af_comics_explosm.php
@@ -7,11 +7,11 @@ class Af_Comics_Explosm extends Af_ComicFilter {
function process(&$article) {
- if (strpos($article["link"], "explosm.net/comics") !== FALSE) {
+ if (strpos($article["link"], "explosm.net/comics") !== false) {
$doc = new DOMDocument();
- if (@$doc->loadHTML(fetch_file_contents($article["link"]))) {
+ if (@$doc->loadHTML(UrlHelper::fetch($article["link"]))) {
$xpath = new DOMXPath($doc);
$basenode = $xpath->query('(//img[@id="main-comic"])')->item(0);
diff --git a/plugins/af_comics/filters/af_comics_gocomics.php b/plugins/af_comics/filters/af_comics_gocomics.php
index 791dc07d3..949b7a235 100644
--- a/plugins/af_comics/filters/af_comics_gocomics.php
+++ b/plugins/af_comics/filters/af_comics_gocomics.php
@@ -29,15 +29,13 @@ class Af_Comics_Gocomics extends Af_ComicFilter {
$article_link = $site_url . date('/Y/m/d');
- $body = fetch_file_contents(array('url' => $article_link, 'type' => 'text/html', 'followlocation' => false));
-
- require_once 'lib/MiniTemplator.class.php';
+ $body = UrlHelper::fetch(array('url' => $article_link, 'type' => 'text/html', 'followlocation' => false));
$feed_title = htmlspecialchars($comic[1]);
$site_url = htmlspecialchars($site_url);
$article_link = htmlspecialchars($article_link);
- $tpl = new MiniTemplator();
+ $tpl = new Templator();
$tpl->readTemplateFromFile('templates/generated_feed.txt');
diff --git a/plugins/af_comics/filters/af_comics_gocomics_farside.php b/plugins/af_comics/filters/af_comics_gocomics_farside.php
index 783907e17..9663da8f9 100644
--- a/plugins/af_comics/filters/af_comics_gocomics_farside.php
+++ b/plugins/af_comics/filters/af_comics_gocomics_farside.php
@@ -25,11 +25,10 @@ class Af_Comics_Gocomics_FarSide extends Af_ComicFilter {
public function on_fetch($url) {
if (preg_match("#^https?://www\.thefarside\.com#", $url)) {
- require_once 'lib/MiniTemplator.class.php';
$article_link = htmlspecialchars("https://www.thefarside.com" . date('/Y/m/d'));
- $tpl = new MiniTemplator();
+ $tpl = new Templator();
$tpl->readTemplateFromFile('templates/generated_feed.txt');
@@ -38,7 +37,7 @@ class Af_Comics_Gocomics_FarSide extends Af_ComicFilter {
$tpl->setVariable('FEED_URL', htmlspecialchars($url), true);
$tpl->setVariable('SELF_URL', htmlspecialchars($url), true);
- $body = fetch_file_contents(['url' => $article_link, 'type' => 'text/html', 'followlocation' => false]);
+ $body = UrlHelper::fetch(['url' => $article_link, 'type' => 'text/html', 'followlocation' => false]);
if ($body) {
$doc = new DOMDocument();
diff --git a/plugins/af_comics/filters/af_comics_pa.php b/plugins/af_comics/filters/af_comics_pa.php
index 7a60feabb..380e84596 100644
--- a/plugins/af_comics/filters/af_comics_pa.php
+++ b/plugins/af_comics/filters/af_comics_pa.php
@@ -6,11 +6,11 @@ class Af_Comics_Pa extends Af_ComicFilter {
}
function process(&$article) {
- if (strpos($article["link"], "penny-arcade.com") !== FALSE && strpos($article["title"], "Comic:") !== FALSE) {
+ if (strpos($article["link"], "penny-arcade.com") !== false && strpos($article["title"], "Comic:") !== false) {
$doc = new DOMDocument();
- if ($doc->loadHTML(fetch_file_contents($article["link"]))) {
+ if ($doc->loadHTML(UrlHelper::fetch($article["link"]))) {
$xpath = new DOMXPath($doc);
$basenode = $xpath->query('(//div[@id="comicFrame"])')->item(0);
@@ -22,10 +22,10 @@ class Af_Comics_Pa extends Af_ComicFilter {
return true;
}
- if (strpos($article["link"], "penny-arcade.com") !== FALSE && strpos($article["title"], "News Post:") !== FALSE) {
+ if (strpos($article["link"], "penny-arcade.com") !== false && strpos($article["title"], "News Post:") !== false) {
$doc = new DOMDocument();
- if ($doc->loadHTML(fetch_file_contents($article["link"]))) {
+ if ($doc->loadHTML(UrlHelper::fetch($article["link"]))) {
$xpath = new DOMXPath($doc);
$entries = $xpath->query('(//div[@class="post"])');
diff --git a/plugins/af_comics/filters/af_comics_pvp.php b/plugins/af_comics/filters/af_comics_pvp.php
index cf0b79d78..105d3f490 100644
--- a/plugins/af_comics/filters/af_comics_pvp.php
+++ b/plugins/af_comics/filters/af_comics_pvp.php
@@ -6,9 +6,9 @@ class Af_Comics_Pvp extends Af_ComicFilter {
}
function process(&$article) {
- if (strpos($article["guid"], "pvponline.com") !== FALSE) {
+ if (strpos($article["guid"], "pvponline.com") !== false) {
- $res = fetch_file_contents($article["link"], false, false, false,
+ $res = UrlHelper::fetch($article["link"], false, false, false,
false, false, 0,
"Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)");
diff --git a/plugins/af_comics/filters/af_comics_tfd.php b/plugins/af_comics/filters/af_comics_tfd.php
index 376ec0714..e0216705c 100644
--- a/plugins/af_comics/filters/af_comics_tfd.php
+++ b/plugins/af_comics/filters/af_comics_tfd.php
@@ -6,9 +6,9 @@ class Af_Comics_Tfd extends Af_ComicFilter {
}
function process(&$article) {
- if (strpos($article["link"], "toothpastefordinner.com") !== FALSE ||
- strpos($article["link"], "marriedtothesea.com") !== FALSE) {
- $res = fetch_file_contents($article["link"], false, false, false,
+ if (strpos($article["link"], "toothpastefordinner.com") !== false ||
+ strpos($article["link"], "marriedtothesea.com") !== false) {
+ $res = UrlHelper::fetch($article["link"], false, false, false,
false, false, 0,
"Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)");
@@ -16,7 +16,7 @@ class Af_Comics_Tfd extends Af_ComicFilter {
$doc = new DOMDocument();
- if (@$doc->loadHTML(fetch_file_contents($article["link"]))) {
+ if (@$doc->loadHTML(UrlHelper::fetch($article["link"]))) {
$xpath = new DOMXPath($doc);
$basenode = $xpath->query('//img[contains(@src, ".gif")]')->item(0);
diff --git a/plugins/af_comics/filters/af_comics_twp.php b/plugins/af_comics/filters/af_comics_twp.php
index f53b89b63..38a8ca32b 100644
--- a/plugins/af_comics/filters/af_comics_twp.php
+++ b/plugins/af_comics/filters/af_comics_twp.php
@@ -7,11 +7,11 @@ class Af_Comics_Twp extends Af_ComicFilter {
function process(&$article) {
- if (strpos($article["link"], "threewordphrase.com") !== FALSE) {
+ if (strpos($article["link"], "threewordphrase.com") !== false) {
$doc = new DOMDocument();
- if (@$doc->loadHTML(fetch_file_contents($article["link"]))) {
+ if (@$doc->loadHTML(UrlHelper::fetch($article["link"]))) {
$xpath = new DOMXpath($doc);
$basenode = $xpath->query("//td/center/img")->item(0);
diff --git a/plugins/af_comics/filters/af_comics_whomp.php b/plugins/af_comics/filters/af_comics_whomp.php
index d574bf5d3..021a2952a 100644
--- a/plugins/af_comics/filters/af_comics_whomp.php
+++ b/plugins/af_comics/filters/af_comics_whomp.php
@@ -6,9 +6,9 @@ class Af_Comics_Whomp extends Af_ComicFilter {
}
function process(&$article) {
- if (strpos($article["guid"], "whompcomic.com") !== FALSE) {
+ if (strpos($article["guid"], "whompcomic.com") !== false) {
- $res = fetch_file_contents($article["link"], false, false, false,
+ $res = UrlHelper::fetch($article["link"], false, false, false,
false, false, 0,
"Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)");
diff --git a/plugins/af_comics/init.php b/plugins/af_comics/init.php
index d07220894..c99d4b1d8 100755
--- a/plugins/af_comics/init.php
+++ b/plugins/af_comics/init.php
@@ -27,7 +27,7 @@ class Af_Comics extends Plugin {
foreach ($filters as $file) {
$filter_name = preg_replace("/\..*$/", "", basename($file));
- if (array_search($filter_name, $names) === FALSE) {
+ if (array_search($filter_name, $names) === false) {
if (!class_exists($filter_name)) {
require_once $file;
}
diff --git a/plugins/af_proxy_http/init.php b/plugins/af_proxy_http/init.php
index 80100160d..2d9ae59b5 100644
--- a/plugins/af_proxy_http/init.php
+++ b/plugins/af_proxy_http/init.php
@@ -28,6 +28,9 @@ class Af_Proxy_Http extends Plugin {
$host->add_hook($host::HOOK_ENCLOSURE_ENTRY, $this);
$host->add_hook($host::HOOK_PREFS_TAB, $this);
+
+ if (!$_SESSION['af_proxy_http_token'])
+ $_SESSION['af_proxy_http_token'] = bin2hex(get_random_bytes(16));
}
function hook_enclosure_entry($enc) {
@@ -45,11 +48,10 @@ class Af_Proxy_Http extends Plugin {
}
public function imgproxy() {
-
- $url = rewrite_relative_url(get_self_url_prefix(), $_REQUEST["url"]);
+ $url = UrlHelper::validate(clean($_REQUEST["url"]));
// called without user context, let's just redirect to original URL
- if (!$_SESSION["uid"]) {
+ if (!$_SESSION["uid"] || $_REQUEST['af_proxy_http_token'] != $_SESSION['af_proxy_http_token']) {
header("Location: $url");
return;
}
@@ -59,22 +61,14 @@ class Af_Proxy_Http extends Plugin {
if ($this->cache->exists($local_filename)) {
header("Location: " . $this->cache->getUrl($local_filename));
return;
- //$this->cache->send($local_filename);
} else {
- $data = fetch_file_contents(["url" => $url, "max_size" => MAX_CACHE_FILE_SIZE]);
+ $data = UrlHelper::fetch(["url" => $url, "max_size" => MAX_CACHE_FILE_SIZE]);
if ($data) {
-
- $disable_cache = $this->host->get($this, "disable_cache");
-
- if (!$disable_cache) {
- if ($this->cache->put($local_filename, $data)) {
- header("Location: " . $this->cache->getUrl($local_filename));
- return;
- }
+ if ($this->cache->put($local_filename, $data)) {
+ header("Location: " . $this->cache->getUrl($local_filename));
+ return;
}
-
- print $data;
} else {
global $fetch_last_error;
global $fetch_last_error_code;
@@ -97,14 +91,13 @@ class Af_Proxy_Http extends Plugin {
imagedestroy($img);
} else {
- header("Content-type: text/html");
+ header("Content-type: text/plain");
http_response_code(400);
- print "<h1>Proxy request failed.</h1>";
- print "<p>Fetch error $fetch_last_error ($fetch_last_error_code)</p>";
- print "<p>URL: $url</p>";
- print "<textarea cols='80' rows='25'>" . htmlspecialchars($fetch_last_error_content) . "</textarea>";
+ print "Proxy request failed.\n".
+ "Fetch error $fetch_last_error ($fetch_last_error_code)\n".
+ "Requested URL: $url";
}
}
}
@@ -132,7 +125,7 @@ class Af_Proxy_Http extends Plugin {
foreach (explode(" " , $this->ssl_known_whitelist) as $host) {
if (substr(strtolower($parts['host']), -strlen($host)) === strtolower($host)) {
$parts['scheme'] = 'https';
- $url = build_url($parts);
+ $url = UrlHelper::build_url($parts);
if ($all_remote && $is_remote) {
break;
} else {
@@ -141,7 +134,8 @@ class Af_Proxy_Http extends Plugin {
}
}
- return $this->host->get_public_method_url($this, "imgproxy", ["url" => $url]);
+ return $this->host->get_public_method_url($this, "imgproxy",
+ ["url" => $url, "af_proxy_http_token" => $_SESSION["af_proxy_http_token"]]);
}
}
}
@@ -208,7 +202,7 @@ class Af_Proxy_Http extends Plugin {
function hook_prefs_tab($args) {
if ($args != "prefFeeds") return;
- print "<div dojoType=\"dijit.layout.AccordionPane\"
+ print "<div dojoType=\"dijit.layout.AccordionPane\"
title=\"<i class='material-icons'>extension</i> ".__('Image proxy settings (af_proxy_http)')."\">";
print "<form dojoType=\"dijit.form.Form\">";
@@ -235,10 +229,6 @@ class Af_Proxy_Http extends Plugin {
print_checkbox("proxy_all", $proxy_all);
print "&nbsp;<label for=\"proxy_all\">" . __("Enable proxy for all remote images.") . "</label><br/>";
- $disable_cache = $this->host->get($this, "disable_cache");
- print_checkbox("disable_cache", $disable_cache);
- print "&nbsp;<label for=\"disable_cache\">" . __("Don't cache files locally.") . "</label>";
-
print "<p>"; print_button("submit", __("Save"));
print "</form>";
@@ -248,10 +238,8 @@ class Af_Proxy_Http extends Plugin {
function save() {
$proxy_all = checkbox_to_sql_bool($_POST["proxy_all"]);
- $disable_cache = checkbox_to_sql_bool($_POST["disable_cache"]);
$this->host->set($this, "proxy_all", $proxy_all, false);
- $this->host->set($this, "disable_cache", $disable_cache);
echo __("Configuration saved");
}
diff --git a/plugins/af_psql_trgm/init.php b/plugins/af_psql_trgm/init.php
index dbc99cfe4..20e3981ce 100644
--- a/plugins/af_psql_trgm/init.php
+++ b/plugins/af_psql_trgm/init.php
@@ -98,7 +98,7 @@ class Af_Psql_Trgm extends Plugin {
print "</div>";
- print "<div style='text-align : right' class='text-muted'>" . smart_date_time(strtotime($line["updated"])) . "</div>";
+ print "<div style='text-align : right' class='text-muted'>" . TimeHelper::smart_date_time(strtotime($line["updated"])) . "</div>";
print "</li>";
}
@@ -123,7 +123,7 @@ class Af_Psql_Trgm extends Plugin {
function hook_prefs_tab($args) {
if ($args != "prefFeeds") return;
- print "<div dojoType=\"dijit.layout.AccordionPane\"
+ print "<div dojoType=\"dijit.layout.AccordionPane\"
title=\"<i class='material-icons'>extension</i> ".__('Mark similar articles as read')."\">";
if (DB_TYPE != "pgsql") {
@@ -228,7 +228,7 @@ class Af_Psql_Trgm extends Plugin {
if (!array($enabled_feeds)) $enabled_feeds = array();
$key = array_search($feed_id, $enabled_feeds);
- $checked = $key !== FALSE ? "checked" : "";
+ $checked = $key !== false ? "checked" : "";
print "<fieldset>";
@@ -248,11 +248,11 @@ class Af_Psql_Trgm extends Plugin {
$key = array_search($feed_id, $enabled_feeds);
if ($enable) {
- if ($key === FALSE) {
+ if ($key === false) {
array_push($enabled_feeds, $feed_id);
}
} else {
- if ($key !== FALSE) {
+ if ($key !== false) {
unset($enabled_feeds[$key]);
}
}
@@ -272,7 +272,7 @@ class Af_Psql_Trgm extends Plugin {
if (!$enable_globally) {
$enabled_feeds = $this->host->get($this, "enabled_feeds");
$key = array_search($article["feed"]["id"], $enabled_feeds);
- if ($key === FALSE) return $article;
+ if ($key === false) return $article;
}
$similarity = (float) $this->host->get($this, "similarity");
diff --git a/plugins/af_readability/init.js b/plugins/af_readability/init.js
index 644dff9fe..3155475cc 100644
--- a/plugins/af_readability/init.js
+++ b/plugins/af_readability/init.js
@@ -9,7 +9,7 @@ Plugins.Af_Readability = {
content.innerHTML = content.getAttribute(self.orig_attr_name);
content.removeAttribute(self.orig_attr_name);
- if (App.isCombinedMode()) Article.cdmScrollToId(id);
+ if (App.isCombinedMode()) Article.cdmMoveToId(id);
return;
}
@@ -23,7 +23,7 @@ Plugins.Af_Readability = {
content.innerHTML = reply.content;
Notify.close();
- if (App.isCombinedMode()) Article.cdmScrollToId(id);
+ if (App.isCombinedMode()) Article.cdmMoveToId(id);
} else {
Notify.error("Unable to fetch full text for this article");
diff --git a/plugins/af_readability/init.php b/plugins/af_readability/init.php
index 9c62a4772..111462c4b 100755
--- a/plugins/af_readability/init.php
+++ b/plugins/af_readability/init.php
@@ -133,7 +133,7 @@ class Af_Readability extends Plugin {
if (!is_array($enabled_feeds)) $enabled_feeds = array();
$key = array_search($feed_id, $enabled_feeds);
- $checked = $key !== FALSE ? "checked" : "";
+ $checked = $key !== false ? "checked" : "";
print "<fieldset>";
@@ -153,11 +153,11 @@ class Af_Readability extends Plugin {
$key = array_search($feed_id, $enabled_feeds);
if ($enable) {
- if ($key === FALSE) {
+ if ($key === false) {
array_push($enabled_feeds, $feed_id);
}
} else {
- if ($key !== FALSE) {
+ if ($key !== false) {
unset($enabled_feeds[$key]);
}
}
@@ -176,7 +176,7 @@ class Af_Readability extends Plugin {
global $fetch_effective_url;
- $tmp = fetch_file_contents([
+ $tmp = UrlHelper::fetch([
"url" => $url,
"http_accept" => "text/*",
"type" => "text/html"]);
@@ -235,7 +235,7 @@ class Af_Readability extends Plugin {
$extracted_content = $this->extract_content($article["link"]);
# let's see if there's anything of value in there
- $content_test = trim(strip_tags(sanitize($extracted_content)));
+ $content_test = trim(strip_tags(Sanitizer::sanitize($extracted_content)));
if ($content_test) {
$article["content"] = $extracted_content;
@@ -250,7 +250,7 @@ class Af_Readability extends Plugin {
if (!is_array($enabled_feeds)) return $article;
$key = array_search($article["feed"]["id"], $enabled_feeds);
- if ($key === FALSE) return $article;
+ if ($key === false) return $article;
return $this->process_article($article);
@@ -264,7 +264,7 @@ class Af_Readability extends Plugin {
$extracted_content = $this->extract_content($link);
# let's see if there's anything of value in there
- $content_test = trim(strip_tags(sanitize($extracted_content)));
+ $content_test = trim(strip_tags(Sanitizer::sanitize($extracted_content)));
if ($content_test) {
return $extracted_content;
@@ -303,7 +303,7 @@ class Af_Readability extends Plugin {
$ret = [];
if ($row = $sth->fetch()) {
- $ret["content"] = sanitize($this->extract_content($row["link"]));
+ $ret["content"] = Sanitizer::sanitize($this->extract_content($row["link"]));
}
print json_encode($ret);
diff --git a/plugins/af_redditimgur/init.php b/plugins/af_redditimgur/init.php
index d28e072f4..2c213c10b 100755
--- a/plugins/af_redditimgur/init.php
+++ b/plugins/af_redditimgur/init.php
@@ -94,7 +94,7 @@ class Af_RedditImgur extends Plugin {
//$debug = 1;
foreach ($entries as $entry) {
- if ($entry->hasAttribute("href") && strpos($entry->getAttribute("href"), "reddit.com") === FALSE) {
+ if ($entry->hasAttribute("href") && strpos($entry->getAttribute("href"), "reddit.com") === false) {
Debug::log("processing href: " . $entry->getAttribute("href"), Debug::$LOG_VERBOSE);
@@ -103,7 +103,7 @@ class Af_RedditImgur extends Plugin {
if (!$found && preg_match("/^https?:\/\/twitter.com\/(.*?)\/status\/(.*)/", $entry->getAttribute("href"), $matches)) {
Debug::log("handling as twitter: " . $matches[1] . " " . $matches[2], Debug::$LOG_VERBOSE);
- $oembed_result = fetch_file_contents("https://publish.twitter.com/oembed?url=" . urlencode($entry->getAttribute("href")));
+ $oembed_result = UrlHelper::fetch("https://publish.twitter.com/oembed?url=" . urlencode($entry->getAttribute("href")));
if ($oembed_result) {
$oembed_result = json_decode($oembed_result, true);
@@ -140,7 +140,7 @@ class Af_RedditImgur extends Plugin {
$content_type = $this->get_content_type($source_stream);
- if (strpos($content_type, "video/") !== FALSE) {
+ if (strpos($content_type, "video/") !== false) {
$this->handle_as_video($doc, $entry, $source_stream, $poster_url);
$found = 1;
}
@@ -165,7 +165,7 @@ class Af_RedditImgur extends Plugin {
$source_stream = false;
if ($source_article_url) {
- $j = json_decode(fetch_file_contents($source_article_url.".json"), true);
+ $j = json_decode(UrlHelper::fetch($source_article_url.".json"), true);
if ($j) {
foreach ($j as $listing) {
@@ -195,7 +195,7 @@ class Af_RedditImgur extends Plugin {
Debug::log("Handling as Streamable", Debug::$LOG_VERBOSE);
- $tmp = fetch_file_contents($entry->getAttribute("href"));
+ $tmp = UrlHelper::fetch($entry->getAttribute("href"));
if ($tmp) {
$tmpdoc = new DOMDocument();
@@ -230,7 +230,7 @@ class Af_RedditImgur extends Plugin {
$source_stream = str_replace(".gifv", ".mp4", $entry->getAttribute("href"));
- if (strpos($source_stream, "imgur.com") !== FALSE)
+ if (strpos($source_stream, "imgur.com") !== false)
$poster_url = str_replace(".mp4", "h.jpg", $source_stream);
$this->handle_as_video($doc, $entry, $source_stream, $poster_url);
@@ -265,8 +265,8 @@ class Af_RedditImgur extends Plugin {
}
if (!$found && (preg_match("/\.(jpg|jpeg|gif|png)(\?[0-9][0-9]*)?[$\?]/i", $entry->getAttribute("href")) ||
- mb_strpos($entry->getAttribute("href"), "i.reddituploads.com") !== FALSE ||
- mb_strpos($this->get_content_type($entry->getAttribute("href")), "image/") !== FALSE)) {
+ mb_strpos($entry->getAttribute("href"), "i.reddituploads.com") !== false ||
+ mb_strpos($this->get_content_type($entry->getAttribute("href")), "image/") !== false)) {
Debug::log("Handling as a picture", Debug::$LOG_VERBOSE);
@@ -285,7 +285,7 @@ class Af_RedditImgur extends Plugin {
Debug::log("handling as imgur page/whatever", Debug::$LOG_VERBOSE);
- $content = fetch_file_contents(["url" => $entry->getAttribute("href"),
+ $content = UrlHelper::fetch(["url" => $entry->getAttribute("href"),
"http_accept" => "text/*"]);
if ($content) {
@@ -331,7 +331,7 @@ class Af_RedditImgur extends Plugin {
if (!$found) {
Debug::log("looking for meta og:image", Debug::$LOG_VERBOSE);
- $content = fetch_file_contents(["url" => $entry->getAttribute("href"),
+ $content = UrlHelper::fetch(["url" => $entry->getAttribute("href"),
"http_accept" => "text/*"]);
if ($content) {
@@ -393,7 +393,7 @@ class Af_RedditImgur extends Plugin {
function hook_article_filter($article) {
- if (strpos($article["link"], "reddit.com/r/") !== FALSE) {
+ if (strpos($article["link"], "reddit.com/r/") !== false) {
$doc = new DOMDocument();
@$doc->loadHTML($article["content"]);
$xpath = new DOMXPath($doc);
@@ -437,6 +437,7 @@ class Af_RedditImgur extends Plugin {
if ($node && $found) {
$article["content"] = $doc->saveHTML($node);
+ $article["enclosures"] = [];
} else if ($content_link) {
$article = $this->readability($article, $content_link->getAttribute("href"), $doc, $xpath);
}
@@ -470,11 +471,11 @@ class Af_RedditImgur extends Plugin {
$entry->parentNode->insertBefore($video, $entry);
$entry->parentNode->insertBefore($br, $entry);
- $img = $doc->createElement('img');
+ /*$img = $doc->createElement('img');
$img->setAttribute("src",
"data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs%3D");
- $entry->parentNode->insertBefore($img, $entry);
+ $entry->parentNode->insertBefore($img, $entry);*/
}
function testurl() {
@@ -542,7 +543,7 @@ class Af_RedditImgur extends Plugin {
// do not try to embed posts linking back to other reddit posts
// readability.php requires PHP 5.6
- if ($url && strpos($url, "reddit.com") === FALSE && version_compare(PHP_VERSION, '5.6.0', '>=')) {
+ if ($url && strpos($url, "reddit.com") === false && version_compare(PHP_VERSION, '5.6.0', '>=')) {
/* link may lead to a huge video file or whatever, we need to check content type before trying to
parse it which p much requires curl */
@@ -550,7 +551,7 @@ class Af_RedditImgur extends Plugin {
$useragent_compat = "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)";
$content_type = $this->get_content_type($url, $useragent_compat);
- if ($content_type && strpos($content_type, "text/html") !== FALSE) {
+ if ($content_type && strpos($content_type, "text/html") !== false) {
foreach ($this->host->get_hooks(PluginHost::HOOK_GET_FULL_TEXT) as $p) {
$extracted_content = $p->hook_get_full_text($url);
diff --git a/plugins/af_unburn/init.php b/plugins/af_unburn/init.php
index bfd0f66e1..d867e83be 100755
--- a/plugins/af_unburn/init.php
+++ b/plugins/af_unburn/init.php
@@ -24,9 +24,9 @@ class Af_Unburn extends Plugin {
if (defined('NO_CURL') || !function_exists("curl_init") || ini_get("open_basedir"))
return $article;
- if ((strpos($article["link"], "feedproxy.google.com") !== FALSE ||
- strpos($article["link"], "/~r/") !== FALSE ||
- strpos($article["link"], "feedsportal.com") !== FALSE)) {
+ if ((strpos($article["link"], "feedproxy.google.com") !== false ||
+ strpos($article["link"], "/~r/") !== false ||
+ strpos($article["link"], "feedsportal.com") !== false)) {
$ch = curl_init($article["link"]);
@@ -52,7 +52,7 @@ class Af_Unburn extends Plugin {
$query = parse_url($real_url, PHP_URL_QUERY);
- if ($query && strpos($query, "utm_source") !== FALSE) {
+ if ($query && strpos($query, "utm_source") !== false) {
$args = array();
parse_str($query, $args);
diff --git a/plugins/auth_internal/init.php b/plugins/auth_internal/init.php
index 8dbc37fb3..0ad3e9436 100644
--- a/plugins/auth_internal/init.php
+++ b/plugins/auth_internal/init.php
@@ -22,7 +22,7 @@ class Auth_Internal extends Plugin implements IAuthModule {
$pwd_hash1 = encrypt_password($password);
$pwd_hash2 = encrypt_password($password, $login);
- $otp = $_REQUEST["otp"];
+ $otp = (int)$_REQUEST["otp"];
if (get_schema_version() > 96) {
@@ -52,7 +52,7 @@ class Auth_Internal extends Plugin implements IAuthModule {
$totp_legacy = new \OTPHP\TOTP($secret_legacy);
$otp_check_legacy = $totp_legacy->now();
- if ($otp != $otp_check && $otp != $otp_check_legacy) {
+ if ($otp !== $otp_check && $otp !== $otp_check_legacy) {
return false;
}
} else {
@@ -235,11 +235,9 @@ class Auth_Internal extends Plugin implements IAuthModule {
if ($row = $sth->fetch()) {
$mailer = new Mailer();
- require_once "lib/MiniTemplator.class.php";
+ $tpl = new Templator();
- $tpl = new MiniTemplator;
-
- $tpl->readTemplateFromFile("templates/password_change_template.txt");
+ $tpl->readTemplateFromFile("password_change_template.txt");
$tpl->setVariable('LOGIN', $row["login"]);
$tpl->setVariable('TTRSS_HOST', SELF_URL_PATH);
@@ -262,8 +260,8 @@ class Auth_Internal extends Plugin implements IAuthModule {
}
private function check_app_password($login, $password, $service) {
- $sth = $this->pdo->prepare("SELECT p.id, p.pwd_hash, u.id AS uid
- FROM ttrss_app_passwords p, ttrss_users u
+ $sth = $this->pdo->prepare("SELECT p.id, p.pwd_hash, u.id AS uid
+ FROM ttrss_app_passwords p, ttrss_users u
WHERE p.owner_uid = u.id AND u.login = ? AND service = ?");
$sth->execute([$login, $service]);
diff --git a/plugins/cache_starred_images/init.php b/plugins/cache_starred_images/init.php
index ae369f56e..5fe963e32 100755
--- a/plugins/cache_starred_images/init.php
+++ b/plugins/cache_starred_images/init.php
@@ -40,16 +40,16 @@ class Cache_Starred_Images extends Plugin {
Debug::log("caching media of starred articles for user " . $this->host->get_owner_uid() . "...");
- $sth = $this->pdo->prepare("SELECT content, ttrss_entries.title,
+ $sth = $this->pdo->prepare("SELECT content, ttrss_entries.title,
ttrss_user_entries.owner_uid, link, site_url, ttrss_entries.id, plugin_data
FROM ttrss_entries, ttrss_user_entries LEFT JOIN ttrss_feeds ON
(ttrss_user_entries.feed_id = ttrss_feeds.id)
WHERE ref_id = ttrss_entries.id AND
marked = true AND
- site_url != '' AND
+ site_url != '' AND
ttrss_user_entries.owner_uid = ? AND
plugin_data NOT LIKE '%starred_cache_images%'
- ORDER BY ".sql_random_function()." LIMIT 100");
+ ORDER BY ".Db::sql_random_function()." LIMIT 100");
if ($sth->execute([$this->host->get_owner_uid()])) {
@@ -139,7 +139,7 @@ class Cache_Starred_Images extends Plugin {
if (!$this->cache->exists($local_filename)) {
Debug::log("cache_images: downloading: $url to $local_filename", Debug::$LOG_VERBOSE);
- $data = fetch_file_contents(["url" => $url, "max_size" => MAX_CACHE_FILE_SIZE]);
+ $data = UrlHelper::fetch(["url" => $url, "max_size" => MAX_CACHE_FILE_SIZE]);
if ($data)
return $this->cache->put($local_filename, $data);;
diff --git a/plugins/hotkeys_force_top/init.js b/plugins/hotkeys_force_top/init.js
new file mode 100644
index 000000000..8d6280fc9
--- /dev/null
+++ b/plugins/hotkeys_force_top/init.js
@@ -0,0 +1,6 @@
+require(['dojo/_base/kernel', 'dojo/ready'], function (dojo, ready) {
+ ready(function () {
+ Headlines.default_force_to_top = true;
+ });
+});
+
diff --git a/plugins/hotkeys_force_top/init.php b/plugins/hotkeys_force_top/init.php
new file mode 100644
index 000000000..faddc9148
--- /dev/null
+++ b/plugins/hotkeys_force_top/init.php
@@ -0,0 +1,24 @@
+<?php
+class Hotkeys_Force_Top extends Plugin {
+ private $host;
+
+ function about() {
+ return array(1.0,
+ "Force open article to the top",
+ "itsamenathan");
+ }
+
+ function init($host) {
+ $this->host = $host;
+
+ }
+
+ function get_js() {
+ return file_get_contents(__DIR__ . "/init.js");
+ }
+
+ function api_version() {
+ return 2;
+ }
+
+}
diff --git a/plugins/hotkeys_noscroll/init.php b/plugins/hotkeys_noscroll/init.php
index 2038997f5..b31ee92ae 100644
--- a/plugins/hotkeys_noscroll/init.php
+++ b/plugins/hotkeys_noscroll/init.php
@@ -4,7 +4,7 @@ class Hotkeys_Noscroll extends Plugin {
function about() {
return array(1.0,
- "n/p hotkeys move between articles without scrolling",
+ "n/p (and up/down) hotkeys move between articles without scrolling",
"fox");
}
diff --git a/plugins/swap_jk/init.php b/plugins/hotkeys_swap_jk/init.php
index d85149ef3..b1e3dbe04 100644
--- a/plugins/swap_jk/init.php
+++ b/plugins/hotkeys_swap_jk/init.php
@@ -1,5 +1,5 @@
<?php
-class Swap_JK extends Plugin {
+class Hotkeys_Swap_JK extends Plugin {
private $host;
@@ -27,4 +27,4 @@ class Swap_JK extends Plugin {
return 2;
}
-} \ No newline at end of file
+}
diff --git a/plugins/mail/init.php b/plugins/mail/init.php
index e85053566..40d147fc9 100644
--- a/plugins/mail/init.php
+++ b/plugins/mail/init.php
@@ -92,18 +92,20 @@ class Mail extends Plugin {
if ($row = $sth->fetch()) {
$user_email = htmlspecialchars($row['email']);
$user_name = htmlspecialchars($row['full_name']);
+ } else {
+ $user_name = "";
+ $user_email = "";
}
- if (!$user_name) $user_name = $_SESSION['name'];
+ if (!$user_name)
+ $user_name = $_SESSION['name'];
print_hidden("from_email", "$user_email");
print_hidden("from_name", "$user_name");
- require_once "lib/MiniTemplator.class.php";
-
- $tpl = new MiniTemplator;
+ $tpl = new Templator();
- $tpl->readTemplateFromFile("templates/email_article_template.txt");
+ $tpl->readTemplateFromFile("email_article_template.txt");
$tpl->setVariable('USER_NAME', $_SESSION["name"], true);
$tpl->setVariable('USER_EMAIL', $user_email, true);
@@ -116,6 +118,8 @@ class Mail extends Plugin {
if (count($ids) > 1) {
$subject = __("[Forwarded]") . " " . __("Multiple articles");
+ } else {
+ $subject = "";
}
while ($line = $sth->fetch()) {
diff --git a/plugins/mailto/init.php b/plugins/mailto/init.php
index 421d5fd59..390984b71 100644
--- a/plugins/mailto/init.php
+++ b/plugins/mailto/init.php
@@ -29,11 +29,9 @@ class MailTo extends Plugin {
$ids = explode(",", $_REQUEST['param']);
$ids_qmarks = arr_qmarks($ids);
- require_once "lib/MiniTemplator.class.php";
+ $tpl = new Templator();
- $tpl = new MiniTemplator;
-
- $tpl->readTemplateFromFile("templates/email_article_template.txt");
+ $tpl->readTemplateFromFile("email_article_template.txt");
$tpl->setVariable('USER_NAME', $_SESSION["name"], true);
//$tpl->setVariable('USER_EMAIL', $user_email, true);
diff --git a/plugins/no_iframes/init.php b/plugins/no_iframes/init.php
index 18cc3ba17..9711eeb24 100644
--- a/plugins/no_iframes/init.php
+++ b/plugins/no_iframes/init.php
@@ -23,7 +23,7 @@ class No_Iframes extends Plugin {
$entries = $xpath->query('//iframe');
foreach ($entries as $entry) {
- if (!iframe_whitelisted($entry))
+ if (!Sanitizer::iframe_whitelisted($entry))
$entry->parentNode->removeChild($entry);
}
@@ -34,4 +34,4 @@ class No_Iframes extends Plugin {
return 2;
}
-} \ No newline at end of file
+}
diff --git a/plugins/shorten_expanded/init.js b/plugins/shorten_expanded/init.js
index 6371bd1c6..587fcea42 100644
--- a/plugins/shorten_expanded/init.js
+++ b/plugins/shorten_expanded/init.js
@@ -42,8 +42,6 @@ require(['dojo/_base/kernel', 'dojo/ready'], function (dojo, ready) {
${__("Click to expand article")}</button>`;
dojo.parser.parse(c_inner);
-
- Headlines.unpackVisible();
}
}
}, 150);