initial WIP for php8; bump php version requirement to 7.0

This commit is contained in:
Andrew Dolgov 2021-02-05 23:41:32 +03:00
parent b4cbc792cc
commit 403dca154c
28 changed files with 145 additions and 144 deletions

1
.gitignore vendored
View File

@ -1,4 +1,5 @@
Thumbs.db Thumbs.db
/.app_is_ready
/deploy.exclude /deploy.exclude
/deploy.sh /deploy.sh
/messages.mo /messages.mo

View File

@ -3,7 +3,9 @@
get_include_path()); get_include_path());
$op = $_REQUEST["op"]; $op = $_REQUEST["op"];
@$method = $_REQUEST['subop'] ? $_REQUEST['subop'] : $_REQUEST["method"]; $method = !empty($_REQUEST['subop']) ?
$_REQUEST['subop'] :
$_REQUEST["method"] ?? false;
if (!$method) if (!$method)
$method = 'index'; $method = 'index';
@ -19,7 +21,7 @@
return; return;
} }
@$csrf_token = $_POST['csrf_token']; $csrf_token = $_POST['csrf_token'] ?? "";
require_once "autoload.php"; require_once "autoload.php";
require_once "sessions.php"; require_once "sessions.php";

View File

@ -718,8 +718,8 @@ class API extends Handler {
$label_cache = json_decode($label_cache, true); $label_cache = json_decode($label_cache, true);
if ($label_cache) { if ($label_cache) {
if ($label_cache["no-labels"] == 1) if (($label_cache["no-labels"] ?? 0) == 1)
$labels = array(); $labels = [];
else else
$labels = $label_cache; $labels = $label_cache;
} }
@ -762,7 +762,7 @@ class API extends Handler {
} }
// unify label output to ease parsing // unify label output to ease parsing
if ($labels["no-labels"] == 1) $labels = array(); if (($labels["no-labels"] ?? 0) == 1) $labels = [];
$headline_row["labels"] = $labels; $headline_row["labels"] = $labels;

View File

@ -687,7 +687,7 @@ class Article extends Handler_Protected {
if ($label_cache) { if ($label_cache) {
$tmp = json_decode($label_cache, true); $tmp = json_decode($label_cache, true);
if (!$tmp || $tmp["no-labels"] == 1) if (empty($tmp) || ($tmp["no-labels"] ?? 0) == 1)
return $rv; return $rv;
else else
return $tmp; return $tmp;

View File

@ -8,7 +8,7 @@ class Db_Prefs {
$this->pdo = Db::pdo(); $this->pdo = Db::pdo();
$this->cache = array(); $this->cache = array();
if ($_SESSION["uid"]) $this->cache(); if (!empty($_SESSION["uid"])) $this->cache();
} }
private function __clone() { private function __clone() {
@ -24,7 +24,7 @@ class Db_Prefs {
function cache() { function cache() {
$user_id = $_SESSION["uid"]; $user_id = $_SESSION["uid"];
@$profile = $_SESSION["profile"]; $profile = $_SESSION["profile"] ?? false;
if (!is_numeric($profile) || !$profile || get_schema_version() < 63) $profile = null; if (!is_numeric($profile) || !$profile || get_schema_version() < 63) $profile = null;
@ -55,12 +55,12 @@ class Db_Prefs {
if (!$user_id) { if (!$user_id) {
$user_id = $_SESSION["uid"]; $user_id = $_SESSION["uid"];
@$profile = $_SESSION["profile"]; $profile = $_SESSION["profile"] ?? false;
} else { } else {
$profile = false; $profile = false;
} }
if ($user_id == $_SESSION['uid'] && isset($this->cache[$pref_name])) { if ($user_id == ($_SESSION['uid'] ?? false) && isset($this->cache[$pref_name])) {
$tuple = $this->cache[$pref_name]; $tuple = $this->cache[$pref_name];
return $this->convert($tuple["value"], $tuple["type"]); return $this->convert($tuple["value"], $tuple["type"]);
} }
@ -83,7 +83,7 @@ class Db_Prefs {
$value = $row["value"]; $value = $row["value"];
$type_name = $row["type_name"]; $type_name = $row["type_name"];
if ($user_id == $_SESSION["uid"]) { if ($user_id == ($_SESSION["uid"] ?? false)) {
$this->cache[$pref_name]["type"] = $type_name; $this->cache[$pref_name]["type"] = $type_name;
$this->cache[$pref_name]["value"] = $value; $this->cache[$pref_name]["value"] = $value;
} }
@ -113,7 +113,7 @@ class Db_Prefs {
if (!$user_id) { if (!$user_id) {
$user_id = $_SESSION["uid"]; $user_id = $_SESSION["uid"];
@$profile = $_SESSION["profile"]; @$profile = $_SESSION["profile"] ?? false;
} else { } else {
$profile = null; $profile = null;
} }

View File

@ -20,7 +20,7 @@ class Feeds extends Handler_Protected {
$feed_id, $is_cat, $search, $feed_id, $is_cat, $search,
$error, $feed_last_updated) { $error, $feed_last_updated) {
if ($is_cat) $cat_q = "&is_cat=$is_cat"; $cat_q = $is_cat ? "&is_cat=$is_cat" : "";
if ($search) { if ($search) {
$search_q = "&q=$search"; $search_q = "&q=$search";
@ -31,7 +31,7 @@ class Feeds extends Handler_Protected {
$reply = ""; $reply = "";
$rss_link = htmlspecialchars(get_self_url_prefix() . $rss_link = htmlspecialchars(get_self_url_prefix() .
"/public.php?op=rss&id=$feed_id$cat_q$search_q"); "/public.php?op=rss&id=${feed_id}${cat_q}${search_q}");
$reply .= "<span class='left'>"; $reply .= "<span class='left'>";
@ -147,8 +147,8 @@ class Feeds extends Handler_Protected {
} }
} }
@$search = $_REQUEST["query"]; $search = $_REQUEST["query"] ?? "";
@$search_language = $_REQUEST["search_language"]; // PGSQL only $search_language = $_REQUEST["search_language"] ?? ""; // PGSQL only
if ($search) { if ($search) {
$disable_cache = true; $disable_cache = true;
@ -274,7 +274,7 @@ class Feeds extends Handler_Protected {
$label_cache = json_decode($label_cache, true); $label_cache = json_decode($label_cache, true);
if ($label_cache) { if ($label_cache) {
if ($label_cache["no-labels"] == 1) if ($label_cache["no-labels"] ?? false == 1)
$labels = array(); $labels = array();
else else
$labels = $label_cache; $labels = $label_cache;
@ -295,7 +295,7 @@ class Feeds extends Handler_Protected {
$this->mark_timestamp(" labels"); $this->mark_timestamp(" labels");
if (!$line["feed_title"]) $line["feed_title"] = ""; $line["feed_title"] = $line["feed_title"] ?? "";
$line["buttons_left"] = ""; $line["buttons_left"] = "";
foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_ARTICLE_LEFT_BUTTON) as $p) { foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_ARTICLE_LEFT_BUTTON) as $p) {
@ -374,7 +374,7 @@ class Feeds extends Handler_Protected {
} }
//setting feed headline background color, needs to change text color based on dark/light //setting feed headline background color, needs to change text color based on dark/light
$fav_color = $line['favicon_avg_color']; $fav_color = $line['favicon_avg_color'] ?? false;
$this->mark_timestamp(" pre-color"); $this->mark_timestamp(" pre-color");
@ -483,14 +483,14 @@ class Feeds extends Handler_Protected {
$reply = array(); $reply = array();
$feed = $_REQUEST["feed"]; $feed = $_REQUEST["feed"];
$method = $_REQUEST["m"]; $method = $_REQUEST["m"] ?? "";
$view_mode = $_REQUEST["view_mode"]; $view_mode = $_REQUEST["view_mode"];
$limit = 30; $limit = 30;
@$cat_view = $_REQUEST["cat"] == "true"; $cat_view = $_REQUEST["cat"] == "true";
@$next_unread_feed = $_REQUEST["nuf"]; $next_unread_feed = $_REQUEST["nuf"] ?? 0;
@$offset = $_REQUEST["skip"]; $offset = $_REQUEST["skip"] ?? 0;
$order_by = $_REQUEST["order_by"]; $order_by = $_REQUEST["order_by"];
$check_first_id = $_REQUEST["fid"]; $check_first_id = $_REQUEST["fid"] ?? 0;
if (is_numeric($feed)) $feed = (int) $feed; if (is_numeric($feed)) $feed = (int) $feed;
@ -564,7 +564,7 @@ class Feeds extends Handler_Protected {
else else
$reply['headlines']['id'] = $next_unread_feed; $reply['headlines']['id'] = $next_unread_feed;
$reply['headlines']['is_cat'] = (bool) $cat_view; $reply['headlines']['is_cat'] = $cat_view;
$reply['headlines-info'] = ["count" => (int) $headlines_count, $reply['headlines-info'] = ["count" => (int) $headlines_count,
"disable_cache" => (bool) $disable_cache]; "disable_cache" => (bool) $disable_cache];
@ -1794,7 +1794,7 @@ class Feeds extends Handler_Protected {
$sanity_interval_qpart $sanity_interval_qpart
$first_id_query_strategy_part ORDER BY $order_by LIMIT 1"; $first_id_query_strategy_part ORDER BY $order_by LIMIT 1";
if ($_REQUEST["debug"]) { if (!empty($_REQUEST["debug"])) {
print "\n*** FIRST ID QUERY ***\n$query\n"; print "\n*** FIRST ID QUERY ***\n$query\n";
} }
@ -1846,7 +1846,7 @@ class Feeds extends Handler_Protected {
//if ($_REQUEST["debug"]) print $query; //if ($_REQUEST["debug"]) print $query;
if ($_REQUEST["debug"]) { if (!empty($_REQUEST["debug"])) {
print "\n*** HEADLINES QUERY ***\n$query\n"; print "\n*** HEADLINES QUERY ***\n$query\n";
} }
@ -1902,7 +1902,7 @@ class Feeds extends Handler_Protected {
//if ($_REQUEST["debug"]) print $query; //if ($_REQUEST["debug"]) print $query;
if ($_REQUEST["debug"]) { if (!empty($_REQUEST["debug"])) {
print "\n*** TAGS QUERY ***\n$query\n"; print "\n*** TAGS QUERY ***\n$query\n";
} }
@ -2370,10 +2370,9 @@ class Feeds extends Handler_Protected {
function mark_timestamp($label) { function mark_timestamp($label) {
if (!$_REQUEST['timestamps']) if (empty($_REQUEST['timestamps']))
return; return;
if (!$this->viewfeed_timestamp) $this->viewfeed_timestamp = hrtime(true); if (!$this->viewfeed_timestamp) $this->viewfeed_timestamp = hrtime(true);
if (!$this->viewfeed_timestamp_last) $this->viewfeed_timestamp_last = hrtime(true); if (!$this->viewfeed_timestamp_last) $this->viewfeed_timestamp_last = hrtime(true);

View File

@ -731,7 +731,7 @@ class Handler_Public extends Handler {
if ($_SESSION["uid"]) { if ($_SESSION["uid"]) {
$feed_url = trim(clean($_REQUEST["feed_url"])); $feed_url = clean($_REQUEST["feed_url"]);
$csrf_token = clean($_POST["csrf_token"]); $csrf_token = clean($_POST["csrf_token"]);
header('Content-Type: text/html; charset=utf-8'); header('Content-Type: text/html; charset=utf-8');

View File

@ -10,7 +10,7 @@ class Logger_SQL {
if ($this->pdo && get_schema_version() > 117) { if ($this->pdo && get_schema_version() > 117) {
$owner_uid = $_SESSION["uid"] ? $_SESSION["uid"] : null; $owner_uid = $_SESSION["uid"] ?? null;
// limit context length, DOMDocument dumps entire XML in here sometimes, which may be huge // limit context length, DOMDocument dumps entire XML in here sometimes, which may be huge
$context = mb_substr($context, 0, 8192); $context = mb_substr($context, 0, 8192);

View File

@ -128,7 +128,7 @@ class PluginHost {
} }
function get_plugin($name) { function get_plugin($name) {
return $this->plugins[strtolower($name)]; return $this->plugins[strtolower($name)] ?? null;
} }
function run_hooks($type, $method, $args) { function run_hooks($type, $method, $args) {
@ -140,11 +140,11 @@ class PluginHost {
function add_hook($type, $sender, $priority = 50) { function add_hook($type, $sender, $priority = 50) {
$priority = (int) $priority; $priority = (int) $priority;
if (!is_array($this->hooks[$type])) { if (empty($this->hooks[$type])) {
$this->hooks[$type] = []; $this->hooks[$type] = [];
} }
if (!is_array($this->hooks[$type][$priority])) { if (empty($this->hooks[$type][$priority])) {
$this->hooks[$type][$priority] = []; $this->hooks[$type][$priority] = [];
} }
@ -277,7 +277,7 @@ class PluginHost {
function is_system($plugin) { function is_system($plugin) {
$about = $plugin->about(); $about = $plugin->about();
return @$about[3]; return $about[3] ?? false;
} }
// only system plugins are allowed to modify routing // only system plugins are allowed to modify routing
@ -307,7 +307,7 @@ class PluginHost {
$handler = str_replace("-", "_", strtolower($handler)); $handler = str_replace("-", "_", strtolower($handler));
$method = strtolower($method); $method = strtolower($method);
if (is_array($this->handlers[$handler])) { if (isset($this->handlers[$handler])) {
if (isset($this->handlers[$handler]["*"])) { if (isset($this->handlers[$handler]["*"])) {
return $this->handlers[$handler]["*"]; return $this->handlers[$handler]["*"];
} else { } else {
@ -429,9 +429,7 @@ class PluginHost {
function get_all($sender) { function get_all($sender) {
$idx = get_class($sender); $idx = get_class($sender);
$data = $this->storage[$idx]; return $this->storage[$idx] ?? [];
return $data ? $data : [];
} }
function clear_data($sender) { function clear_data($sender) {
@ -461,7 +459,7 @@ class PluginHost {
} }
function get_feeds($cat_id) { function get_feeds($cat_id) {
return $this->feeds[$cat_id]; return $this->feeds[$cat_id] ?? [];
} }
// convert feed_id (e.g. -129) to pfeed_id first // convert feed_id (e.g. -129) to pfeed_id first

View File

@ -42,14 +42,14 @@ class Pref_Feeds extends Handler_Protected {
private function get_category_items($cat_id) { private function get_category_items($cat_id) {
if (clean($_REQUEST['mode']) != 2) if (clean($_REQUEST['mode'] ?? 0) != 2)
$search = $_SESSION["prefs_feed_search"]; $search = $_SESSION["prefs_feed_search"] ?? "";
else else
$search = ""; $search = "";
// first one is set by API // first one is set by API
$show_empty_cats = clean($_REQUEST['force_show_empty']) || $show_empty_cats = clean($_REQUEST['force_show_empty'] ?? false) ||
(clean($_REQUEST['mode']) != 2 && !$search); (clean($_REQUEST['mode'] ?? 0) != 2 && !$search);
$items = array(); $items = array();
@ -117,8 +117,8 @@ class Pref_Feeds extends Handler_Protected {
function makefeedtree() { function makefeedtree() {
if (clean($_REQUEST['mode']) != 2) if (clean($_REQUEST['mode'] ?? 0) != 2)
$search = $_SESSION["prefs_feed_search"]; $search = $_SESSION["prefs_feed_search"] ?? "";
else else
$search = ""; $search = "";
@ -131,7 +131,7 @@ class Pref_Feeds extends Handler_Protected {
$enable_cats = get_pref('ENABLE_FEED_CATS'); $enable_cats = get_pref('ENABLE_FEED_CATS');
if (clean($_REQUEST['mode']) == 2) { if (clean($_REQUEST['mode'] ?? 0) == 2) {
if ($enable_cats) { if ($enable_cats) {
$cat = $this->feedlist_init_cat(-1); $cat = $this->feedlist_init_cat(-1);
@ -208,8 +208,8 @@ class Pref_Feeds extends Handler_Protected {
} }
if ($enable_cats) { if ($enable_cats) {
$show_empty_cats = clean($_REQUEST['force_show_empty']) || $show_empty_cats = clean($_REQUEST['force_show_empty'] ?? false) ||
(clean($_REQUEST['mode']) != 2 && !$search); (clean($_REQUEST['mode'] ?? 0) != 2 && !$search);
$sth = $this->pdo->prepare("SELECT id, title FROM ttrss_feed_categories $sth = $this->pdo->prepare("SELECT id, title FROM ttrss_feed_categories
WHERE owner_uid = ? AND parent_cat IS NULL ORDER BY order_id, title"); WHERE owner_uid = ? AND parent_cat IS NULL ORDER BY order_id, title");
@ -320,7 +320,7 @@ class Pref_Feeds extends Handler_Protected {
$fl['identifier'] = 'id'; $fl['identifier'] = 'id';
$fl['label'] = 'name'; $fl['label'] = 'name';
if (clean($_REQUEST['mode']) != 2) { if (clean($_REQUEST['mode'] ?? 0) != 2) {
$fl['items'] = array($root); $fl['items'] = array($root);
} else { } else {
$fl['items'] = $root['items']; $fl['items'] = $root['items'];
@ -551,11 +551,9 @@ class Pref_Feeds extends Handler_Protected {
regExp='^(http|https)://.*' style='width : 300px' regExp='^(http|https)://.*' style='width : 300px'
name='feed_url' value=\"$feed_url\">"; name='feed_url' value=\"$feed_url\">";
$last_error = $row["last_error"]; if (!empty($row["last_error"])) {
if ($last_error) {
print "&nbsp;<i class=\"material-icons\" print "&nbsp;<i class=\"material-icons\"
title=\"".htmlspecialchars($last_error)."\">error</i>"; title=\"".htmlspecialchars($row["last_error"])."\">error</i>";
} }
print "</fieldset>"; print "</fieldset>";
@ -996,16 +994,16 @@ class Pref_Feeds extends Handler_Protected {
function editsaveops($batch) { function editsaveops($batch) {
$feed_title = trim(clean($_POST["title"])); $feed_title = clean($_POST["title"]);
$feed_url = trim(clean($_POST["feed_url"])); $feed_url = clean($_POST["feed_url"]);
$site_url = trim(clean($_POST["site_url"])); $site_url = clean($_POST["site_url"]);
$upd_intl = (int) clean($_POST["update_interval"]); $upd_intl = (int) clean($_POST["update_interval"]);
$purge_intl = (int) clean($_POST["purge_interval"]); $purge_intl = (int) clean($_POST["purge_interval"]);
$feed_id = (int) clean($_POST["id"]); /* editSave */ $feed_id = (int) clean($_POST["id"]); /* editSave */
$feed_ids = explode(",", clean($_POST["ids"])); /* batchEditSave */ $feed_ids = explode(",", clean($_POST["ids"])); /* batchEditSave */
$cat_id = (int) clean($_POST["cat_id"]); $cat_id = (int) clean($_POST["cat_id"]);
$auth_login = trim(clean($_POST["auth_login"])); $auth_login = clean($_POST["auth_login"]);
$auth_pass = trim(clean($_POST["auth_pass"])); $auth_pass = clean($_POST["auth_pass"]);
$private = checkbox_to_sql_bool(clean($_POST["private"])); $private = checkbox_to_sql_bool(clean($_POST["private"]));
$include_in_digest = checkbox_to_sql_bool( $include_in_digest = checkbox_to_sql_bool(
clean($_POST["include_in_digest"])); clean($_POST["include_in_digest"]));
@ -1019,7 +1017,7 @@ class Pref_Feeds extends Handler_Protected {
$mark_unread_on_update = checkbox_to_sql_bool( $mark_unread_on_update = checkbox_to_sql_bool(
clean($_POST["mark_unread_on_update"])); clean($_POST["mark_unread_on_update"]));
$feed_language = trim(clean($_POST["feed_language"])); $feed_language = clean($_POST["feed_language"]);
if (!$batch) { if (!$batch) {
if (clean($_POST["need_auth"]) !== 'on') { if (clean($_POST["need_auth"]) !== 'on') {
@ -1193,7 +1191,7 @@ class Pref_Feeds extends Handler_Protected {
} }
function addCat() { function addCat() {
$feed_cat = trim(clean($_REQUEST["cat"])); $feed_cat = clean($_REQUEST["cat"]);
Feeds::add_feed_category($feed_cat); Feeds::add_feed_category($feed_cat);
} }
@ -1228,12 +1226,12 @@ class Pref_Feeds extends Handler_Protected {
onclick=\"dijit.byId('feedTree').showInactiveFeeds()\">" . onclick=\"dijit.byId('feedTree').showInactiveFeeds()\">" .
__("Inactive feeds") . "</button>"; __("Inactive feeds") . "</button>";
$feed_search = clean($_REQUEST["search"]); $feed_search = clean($_REQUEST["search"] ?? "");
if (array_key_exists("search", $_REQUEST)) { if (array_key_exists("search", $_REQUEST)) {
$_SESSION["prefs_feed_search"] = $feed_search; $_SESSION["prefs_feed_search"] = $feed_search;
} else { } else {
$feed_search = $_SESSION["prefs_feed_search"]; $feed_search = $_SESSION["prefs_feed_search"] ?? "";
} }
print '<div dojoType="dijit.layout.BorderContainer" gutters="false">'; print '<div dojoType="dijit.layout.BorderContainer" gutters="false">';
@ -1689,7 +1687,7 @@ class Pref_Feeds extends Handler_Protected {
$cat_id = clean($_REQUEST['cat']); $cat_id = clean($_REQUEST['cat']);
$feeds = explode("\n", clean($_REQUEST['feeds'])); $feeds = explode("\n", clean($_REQUEST['feeds']));
$login = clean($_REQUEST['login']); $login = clean($_REQUEST['login']);
$pass = trim(clean($_REQUEST['pass'])); $pass = clean($_REQUEST['pass']);
$csth = $this->pdo->prepare("SELECT id FROM ttrss_feeds $csth = $this->pdo->prepare("SELECT id FROM ttrss_feeds
WHERE feed_url = ? AND owner_uid = ?"); WHERE feed_url = ? AND owner_uid = ?");
@ -1756,8 +1754,8 @@ class Pref_Feeds extends Handler_Protected {
private function calculate_children_count($cat) { private function calculate_children_count($cat) {
$c = 0; $c = 0;
foreach ($cat['items'] as $child) { foreach ($cat['items'] ?? [] as $child) {
if ($child['type'] == 'category') { if ($child['type'] ?? '' == 'category') {
$c += $this->calculate_children_count($child); $c += $this->calculate_children_count($child);
} else { } else {
$c += 1; $c += 1;

View File

@ -599,9 +599,9 @@ class Pref_Filters extends Handler_Protected {
function editSave() { function editSave() {
$filter_id = clean($_REQUEST["id"]); $filter_id = clean($_REQUEST["id"]);
$enabled = checkbox_to_sql_bool(clean($_REQUEST["enabled"])); $enabled = checkbox_to_sql_bool(clean($_REQUEST["enabled"] ?? false));
$match_any_rule = checkbox_to_sql_bool(clean($_REQUEST["match_any_rule"])); $match_any_rule = checkbox_to_sql_bool(clean($_REQUEST["match_any_rule"]));
$inverse = checkbox_to_sql_bool(clean($_REQUEST["inverse"])); $inverse = checkbox_to_sql_bool(clean($_REQUEST["inverse"] ?? false));
$title = clean($_REQUEST["title"]); $title = clean($_REQUEST["title"]);
$this->pdo->beginTransaction(); $this->pdo->beginTransaction();
@ -638,8 +638,8 @@ class Pref_Filters extends Handler_Protected {
$sth = $this->pdo->prepare("DELETE FROM ttrss_filters2_actions WHERE filter_id = ?"); $sth = $this->pdo->prepare("DELETE FROM ttrss_filters2_actions WHERE filter_id = ?");
$sth->execute([$filter_id]); $sth->execute([$filter_id]);
if (!is_array(clean($_REQUEST["rule"]))) $_REQUEST["rule"] = []; if (!is_array(clean($_REQUEST["rule"] ?? ""))) $_REQUEST["rule"] = [];
if (!is_array(clean($_REQUEST["action"]))) $_REQUEST["action"] = []; if (!is_array(clean($_REQUEST["action"] ?? ""))) $_REQUEST["action"] = [];
if ($filter_id) { if ($filter_id) {
/* create rules */ /* create rules */

View File

@ -166,7 +166,7 @@ class Pref_Labels extends Handler_Protected {
function save() { function save() {
$id = clean($_REQUEST["id"]); $id = clean($_REQUEST["id"]);
$caption = trim(clean($_REQUEST["caption"])); $caption = clean($_REQUEST["caption"]);
$this->pdo->beginTransaction(); $this->pdo->beginTransaction();

View File

@ -321,7 +321,7 @@ class Pref_Prefs extends Handler_Protected {
print "<input dojoType='dijit.form.ValidationTextBox' name='email' required='1' value='$email'>"; print "<input dojoType='dijit.form.ValidationTextBox' name='email' required='1' value='$email'>";
print "</fieldset>"; print "</fieldset>";
if (!SINGLE_USER_MODE && !$_SESSION["hide_hello"]) { if (!SINGLE_USER_MODE && !empty($_SESSION["hide_hello"])) {
$access_level = $row["access_level"]; $access_level = $row["access_level"];
print "<fieldset>"; print "<fieldset>";
@ -595,7 +595,7 @@ class Pref_Prefs extends Handler_Protected {
print '<div dojoType="dijit.layout.ContentPane" region="center" style="overflow-y : auto">'; print '<div dojoType="dijit.layout.ContentPane" region="center" style="overflow-y : auto">';
$profile = $_SESSION["profile"]; $profile = $_SESSION["profile"] ?? null;
if ($profile) { if ($profile) {
print_notice(__("Some preferences are only available in default profile.")); print_notice(__("Some preferences are only available in default profile."));
@ -916,7 +916,7 @@ class Pref_Prefs extends Handler_Protected {
foreach ($tmppluginhost->get_plugins() as $name => $plugin) { foreach ($tmppluginhost->get_plugins() as $name => $plugin) {
$about = $plugin->about(); $about = $plugin->about();
if ($about[3]) { if ($about[3] ?? false) {
if (in_array($name, $system_enabled)) { if (in_array($name, $system_enabled)) {
$checked = "checked='1'"; $checked = "checked='1'";
} else { } else {
@ -930,7 +930,7 @@ class Pref_Prefs extends Handler_Protected {
dojoType='dijit.form.CheckBox' $checked type='checkbox'> dojoType='dijit.form.CheckBox' $checked type='checkbox'>
".htmlspecialchars($about[1]). "</label>"; ".htmlspecialchars($about[1]). "</label>";
if (@$about[4]) { if ($about[4] ?? false) {
print "<button dojoType='dijit.form.Button' class='alt-info' print "<button dojoType='dijit.form.Button' class='alt-info'
onclick='window.open(\"".htmlspecialchars($about[4])."\")'> onclick='window.open(\"".htmlspecialchars($about[4])."\")'>
<i class='material-icons'>open_in_new</i> ".__("More info...")."</button>"; <i class='material-icons'>open_in_new</i> ".__("More info...")."</button>";
@ -950,7 +950,7 @@ class Pref_Prefs extends Handler_Protected {
foreach ($tmppluginhost->get_plugins() as $name => $plugin) { foreach ($tmppluginhost->get_plugins() as $name => $plugin) {
$about = $plugin->about(); $about = $plugin->about();
if (!$about[3]) { if ($about[3] ?? false) {
$checked = ""; $checked = "";
$disabled = ""; $disabled = "";
@ -976,7 +976,7 @@ class Pref_Prefs extends Handler_Protected {
} }
} }
if (@$about[4]) { if ($about[4] ?? false) {
print " <button dojoType='dijit.form.Button' class='alt-info' print " <button dojoType='dijit.form.Button' class='alt-info'
onclick='window.open(\"".htmlspecialchars($about[4])."\")'> onclick='window.open(\"".htmlspecialchars($about[4])."\")'>
<i class='material-icons'>open_in_new</i> ".__("More info...")."</button>"; <i class='material-icons'>open_in_new</i> ".__("More info...")."</button>";

View File

@ -191,10 +191,10 @@ class Pref_Users extends Handler_Protected {
} }
function editSave() { function editSave() {
$login = trim(clean($_REQUEST["login"])); $login = clean($_REQUEST["login"]);
$uid = clean($_REQUEST["id"]); $uid = clean($_REQUEST["id"]);
$access_level = (int) clean($_REQUEST["access_level"]); $access_level = (int) clean($_REQUEST["access_level"]);
$email = trim(clean($_REQUEST["email"])); $email = clean($_REQUEST["email"]);
$password = clean($_REQUEST["password"]); $password = clean($_REQUEST["password"]);
if ($password) { if ($password) {
@ -230,7 +230,7 @@ class Pref_Users extends Handler_Protected {
} }
function add() { function add() {
$login = trim(clean($_REQUEST["login"])); $login = clean($_REQUEST["login"]);
$tmp_user_pwd = make_password(); $tmp_user_pwd = make_password();
$salt = substr(bin2hex(get_random_bytes(125)), 0, 250); $salt = substr(bin2hex(get_random_bytes(125)), 0, 250);
$pwd_hash = encrypt_password($tmp_user_pwd, $salt, true); $pwd_hash = encrypt_password($tmp_user_pwd, $salt, true);
@ -315,7 +315,7 @@ class Pref_Users extends Handler_Protected {
print "<div style='padding : 0px' dojoType='dijit.layout.ContentPane' region='top'>"; print "<div style='padding : 0px' dojoType='dijit.layout.ContentPane' region='top'>";
print "<div dojoType='fox.Toolbar'>"; print "<div dojoType='fox.Toolbar'>";
$user_search = trim(clean($_REQUEST["search"])); $user_search = clean($_REQUEST["search"] ?? "");
if (array_key_exists("search", $_REQUEST)) { if (array_key_exists("search", $_REQUEST)) {
$_SESSION["prefs_user_search"] = $user_search; $_SESSION["prefs_user_search"] = $user_search;
@ -330,7 +330,7 @@ class Pref_Users extends Handler_Protected {
__('Search')."</button> __('Search')."</button>
</div>"; </div>";
$sort = clean($_REQUEST["sort"]); $sort = clean($_REQUEST["sort"] ?? "");
if (!$sort || $sort == "undefined") { if (!$sort || $sort == "undefined") {
$sort = "login"; $sort = "login";

View File

@ -15,7 +15,7 @@ class RPC extends Handler_Protected {
} }
function remprofiles() { function remprofiles() {
$ids = explode(",", trim(clean($_REQUEST["ids"]))); $ids = explode(",", clean($_REQUEST["ids"]));
foreach ($ids as $id) { foreach ($ids as $id) {
if ($_SESSION["profile"] != $id) { if ($_SESSION["profile"] != $id) {
@ -28,7 +28,7 @@ class RPC extends Handler_Protected {
// Silent // Silent
function addprofile() { function addprofile() {
$title = trim(clean($_REQUEST["title"])); $title = clean($_REQUEST["title"]);
if ($title) { if ($title) {
$this->pdo->beginTransaction(); $this->pdo->beginTransaction();
@ -63,7 +63,7 @@ class RPC extends Handler_Protected {
function saveprofile() { function saveprofile() {
$id = clean($_REQUEST["id"]); $id = clean($_REQUEST["id"]);
$title = trim(clean($_REQUEST["value"])); $title = clean($_REQUEST["value"]);
if ($id == 0) { if ($id == 0) {
print __("Default profile"); print __("Default profile");
@ -85,7 +85,7 @@ class RPC extends Handler_Protected {
$cat = clean($_REQUEST['cat']); $cat = clean($_REQUEST['cat']);
$need_auth = isset($_REQUEST['need_auth']); $need_auth = isset($_REQUEST['need_auth']);
$login = $need_auth ? clean($_REQUEST['login']) : ''; $login = $need_auth ? clean($_REQUEST['login']) : '';
$pass = $need_auth ? trim(clean($_REQUEST['pass'])) : ''; $pass = $need_auth ? clean($_REQUEST['pass']) : '';
$rc = Feeds::subscribe_to_feed($feed, $cat, $login, $pass); $rc = Feeds::subscribe_to_feed($feed, $cat, $login, $pass);
@ -546,7 +546,7 @@ class RPC extends Handler_Protected {
$data['daemon_is_running'] = (int) file_is_locked("update_daemon.lock"); $data['daemon_is_running'] = (int) file_is_locked("update_daemon.lock");
if (time() - $_SESSION["daemon_stamp_check"] > 30) { if (time() - ($_SESSION["daemon_stamp_check"] ?? 0) > 30) {
$stamp = (int) @file_get_contents(LOCK_DIRECTORY . "/update_daemon.stamp"); $stamp = (int) @file_get_contents(LOCK_DIRECTORY . "/update_daemon.stamp");

View File

@ -10,7 +10,8 @@ class RSSUtils {
continue; continue;
if ($k != "feed" && isset($v)) { if ($k != "feed" && isset($v)) {
$x = strip_tags(is_array($v) ? implode(",", $v) : $v); $x = strip_tags(
is_array($v) ? implode(",", array_keys($v)) : $v);
$tmp .= sha1("$k:" . sha1($x)); $tmp .= sha1("$k:" . sha1($x));
} }

View File

@ -22,7 +22,7 @@ class UrlHelper {
$rel_parts = parse_url($rel_url); $rel_parts = parse_url($rel_url);
if ($rel_parts['host'] && $rel_parts['scheme']) { if (!empty($rel_parts['host']) && !empty($rel_parts['scheme'])) {
return self::validate($rel_url); return self::validate($rel_url);
} else if (strpos($rel_url, "//") === 0) { } else if (strpos($rel_url, "//") === 0) {
# protocol-relative URL (rare but they exist) # protocol-relative URL (rare but they exist)
@ -61,7 +61,7 @@ class UrlHelper {
// this isn't really necessary because filter_var(... FILTER_VALIDATE_URL) requires host and scheme // this isn't really necessary because filter_var(... FILTER_VALIDATE_URL) requires host and scheme
// as per https://php.watch/versions/7.3/filter-var-flag-deprecation but it might save time // as per https://php.watch/versions/7.3/filter-var-flag-deprecation but it might save time
if (!$tokens['host']) if (empty($tokens['host']))
return false; return false;
if (!in_array(strtolower($tokens['scheme']), ['http', 'https'])) if (!in_array(strtolower($tokens['scheme']), ['http', 'https']))
@ -82,7 +82,7 @@ class UrlHelper {
// (used for validation only, we actually request the original URL, in case of urlencode breaking it) // (used for validation only, we actually request the original URL, in case of urlencode breaking it)
$tokens_filter_var = $tokens; $tokens_filter_var = $tokens;
if ($tokens['path']) { if ($tokens['path'] ?? false) {
$tokens_filter_var['path'] = implode("/", $tokens_filter_var['path'] = implode("/",
array_map("rawurlencode", array_map("rawurlencode",
array_map("rawurldecode", array_map("rawurldecode",
@ -96,7 +96,7 @@ class UrlHelper {
return false; return false;
if ($extended_filtering) { if ($extended_filtering) {
if (!in_array($tokens['port'], [80, 443, ''])) if (!in_array($tokens['port'] ?? '', [80, 443, '']))
return false; return false;
if (strtolower($tokens['host']) == 'localhost' || $tokens['host'] == '::1' || strpos($tokens['host'], '127.') === 0) if (strtolower($tokens['host']) == 'localhost' || $tokens['host'] == '::1' || strpos($tokens['host'], '127.') === 0)
@ -166,7 +166,6 @@ class UrlHelper {
global $fetch_effective_url; global $fetch_effective_url;
global $fetch_effective_ip_addr; global $fetch_effective_ip_addr;
global $fetch_curl_used; global $fetch_curl_used;
global $fetch_domain_hits;
$fetch_last_error = false; $fetch_last_error = false;
$fetch_last_error_code = -1; $fetch_last_error_code = -1;
@ -177,9 +176,6 @@ class UrlHelper {
$fetch_effective_url = ""; $fetch_effective_url = "";
$fetch_effective_ip_addr = ""; $fetch_effective_ip_addr = "";
if (!is_array($fetch_domain_hits))
$fetch_domain_hits = [];
if (!is_array($options)) { if (!is_array($options)) {
// falling back on compatibility shim // falling back on compatibility shim
@ -235,13 +231,6 @@ class UrlHelper {
return false; return false;
} }
$fetch_domain_hits[$url_host] += 1;
/*if ($fetch_domain_hits[$url_host] > MAX_FETCH_REQUESTS_PER_HOST) {
user_error("Exceeded fetch request quota for $url_host: " . $fetch_domain_hits[$url_host], E_USER_WARNING);
#return false;
}*/
if (!defined('NO_CURL') && function_exists('curl_init') && !ini_get("open_basedir")) { if (!defined('NO_CURL') && function_exists('curl_init') && !ini_get("open_basedir")) {
$fetch_curl_used = true; $fetch_curl_used = true;

View File

@ -75,7 +75,7 @@ class UserHelper {
if (!$pluginhost) $pluginhost = PluginHost::getInstance(); if (!$pluginhost) $pluginhost = PluginHost::getInstance();
if ($owner_uid && SCHEMA_VERSION >= 100 && !$_SESSION["safe_mode"]) { if ($owner_uid && SCHEMA_VERSION >= 100 && empty($_SESSION["safe_mode"])) {
$plugins = get_pref("_ENABLED_PLUGINS", $owner_uid); $plugins = get_pref("_ENABLED_PLUGINS", $owner_uid);
$pluginhost->load($plugins, PluginHost::KIND_USER, $owner_uid); $pluginhost->load($plugins, PluginHost::KIND_USER, $owner_uid);

View File

@ -44,7 +44,7 @@
return $ERRORS; return $ERRORS;
} }
if ($_REQUEST['mode'] == 'js') { if ($_REQUEST['mode'] ?? "" == 'js') {
header("Content-Type: text/javascript; charset=UTF-8"); header("Content-Type: text/javascript; charset=UTF-8");
print "var ERRORS = [];\n"; print "var ERRORS = [];\n";

View File

@ -10,10 +10,12 @@ function format_backtrace($trace) {
if (is_array($e["args"])) { if (is_array($e["args"])) {
foreach ($e["args"] as $a) { foreach ($e["args"] as $a) {
if (!is_object($a)) { if (is_object($a)) {
array_push($fmt_args, $a);
} else {
array_push($fmt_args, "[" . get_class($a) . "]"); array_push($fmt_args, "[" . get_class($a) . "]");
} else if (is_array($a)) {
array_push($fmt_args, "[" . truncate_string(json_encode($a), 128, "...")) . "]";
} else {
array_push($fmt_args, $a);
} }
} }
} }
@ -21,7 +23,11 @@ function format_backtrace($trace) {
$filename = str_replace(dirname(__DIR__) . "/", "", $e["file"]); $filename = str_replace(dirname(__DIR__) . "/", "", $e["file"]);
$rv .= sprintf("%d. %s(%s): %s(%s)\n", $rv .= sprintf("%d. %s(%s): %s(%s)\n",
$idx, $filename, $e["line"], $e["function"], implode(", ", $fmt_args)); $idx,
$filename,
$e["line"],
$e["function"],
implode(", ", $fmt_args));
$idx++; $idx++;
} }

View File

@ -138,7 +138,11 @@
function startup_gettext() { function startup_gettext() {
# Get locale from Accept-Language header # Get locale from Accept-Language header
if (version_compare(PHP_VERSION, '8.0.0', '<')) {
$lang = al2gt(array_keys(get_translations()), "text/html"); $lang = al2gt(array_keys(get_translations()), "text/html");
} else {
$lang = ""; // FIXME: do something with accept-to-gettext.php
}
if (defined('_TRANSLATION_OVERRIDE_DEFAULT')) { if (defined('_TRANSLATION_OVERRIDE_DEFAULT')) {
$lang = _TRANSLATION_OVERRIDE_DEFAULT; $lang = _TRANSLATION_OVERRIDE_DEFAULT;
@ -222,13 +226,13 @@
/* end compat shims */ /* end compat shims */
function get_ssl_certificate_id() { function get_ssl_certificate_id() {
if ($_SERVER["REDIRECT_SSL_CLIENT_M_SERIAL"]) { if ($_SERVER["REDIRECT_SSL_CLIENT_M_SERIAL"] ?? false) {
return sha1($_SERVER["REDIRECT_SSL_CLIENT_M_SERIAL"] . return sha1($_SERVER["REDIRECT_SSL_CLIENT_M_SERIAL"] .
$_SERVER["REDIRECT_SSL_CLIENT_V_START"] . $_SERVER["REDIRECT_SSL_CLIENT_V_START"] .
$_SERVER["REDIRECT_SSL_CLIENT_V_END"] . $_SERVER["REDIRECT_SSL_CLIENT_V_END"] .
$_SERVER["REDIRECT_SSL_CLIENT_S_DN"]); $_SERVER["REDIRECT_SSL_CLIENT_S_DN"]);
} }
if ($_SERVER["SSL_CLIENT_M_SERIAL"]) { if ($_SERVER["SSL_CLIENT_M_SERIAL"] ?? false) {
return sha1($_SERVER["SSL_CLIENT_M_SERIAL"] . return sha1($_SERVER["SSL_CLIENT_M_SERIAL"] .
$_SERVER["SSL_CLIENT_V_START"] . $_SERVER["SSL_CLIENT_V_START"] .
$_SERVER["SSL_CLIENT_V_END"] . $_SERVER["SSL_CLIENT_V_END"] .
@ -240,11 +244,11 @@
// this is used for user http parameters unless HTML code is actually needed // this is used for user http parameters unless HTML code is actually needed
function clean($param) { function clean($param) {
if (is_array($param)) { if (is_array($param)) {
return array_map("strip_tags", $param); return trim(array_map("strip_tags", $param));
} else if (is_string($param)) { } else if (is_string($param)) {
return strip_tags($param); return trim(strip_tags($param));
} else { } else {
return $param; return trim($param);
} }
} }
@ -407,7 +411,8 @@
} }
function is_server_https() { function is_server_https() {
return (!empty($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] != 'off')) || $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https'; return (!empty($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] != 'off')) ||
(!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https');
} }
function is_prefix_https() { function is_prefix_https() {
@ -577,7 +582,7 @@
if (is_array($ttrss_version) && isset($ttrss_version['version'])) { if (is_array($ttrss_version) && isset($ttrss_version['version'])) {
$git_commit = $ttrss_version['commit']; $git_commit = $ttrss_version['commit'];
$git_timestamp = $ttrss_version['timestamp']; $git_timestamp = $ttrss_version['timestamp'];
$last_error = $ttrss_version['last_error']; $last_error = $ttrss_version['last_error'] ?? "";
return $ttrss_version['version']; return $ttrss_version['version'];
} else { } else {

View File

@ -70,8 +70,8 @@
array_push($errors, "Please don't run this script as root."); array_push($errors, "Please don't run this script as root.");
} }
if (version_compare(PHP_VERSION, '5.6.0', '<')) { if (version_compare(PHP_VERSION, '7.0.0', '<')) {
array_push($errors, "PHP version 5.6.0 or newer required. You're using " . PHP_VERSION . "."); array_push($errors, "PHP version 7.0.0 or newer required. You're using " . PHP_VERSION . ".");
} }
if (!class_exists("UConverter")) { if (!class_exists("UConverter")) {
@ -125,14 +125,14 @@
if (SELF_URL_PATH == "http://example.org/tt-rss/") { if (SELF_URL_PATH == "http://example.org/tt-rss/") {
$hint = $ref_self_url_path ? "(possible value: <b>$ref_self_url_path</b>)" : ""; $hint = $ref_self_url_path ? "(possible value: <b>$ref_self_url_path</b>)" : "";
array_push($errors, array_push($errors,
"Please set SELF_URL_PATH to the correct value for your server $hint"); "Please set SELF_URL_PATH to the correct value for your server: $hint");
} }
if ($ref_self_url_path && if ($ref_self_url_path &&
(!defined('_SKIP_SELF_URL_PATH_CHECKS') || !_SKIP_SELF_URL_PATH_CHECKS) && (!defined('_SKIP_SELF_URL_PATH_CHECKS') || !_SKIP_SELF_URL_PATH_CHECKS) &&
SELF_URL_PATH != $ref_self_url_path && SELF_URL_PATH != mb_substr($ref_self_url_path, 0, mb_strlen($ref_self_url_path)-1)) { SELF_URL_PATH != $ref_self_url_path && SELF_URL_PATH != mb_substr($ref_self_url_path, 0, mb_strlen($ref_self_url_path)-1)) {
array_push($errors, array_push($errors,
"Please set SELF_URL_PATH to the correct value detected for your server: <b>$ref_self_url_path</b>"); "Please set SELF_URL_PATH to the correct value detected for your server: <b>$ref_self_url_path</b> (you're using: <b>" . SELF_URL_PATH . "</b>)");
} }
if (!is_writable(ICONS_DIR)) { if (!is_writable(ICONS_DIR)) {

View File

@ -11,8 +11,8 @@
// we need a separate check here because functions.php might get parsed // we need a separate check here because functions.php might get parsed
// incorrectly before 5.3 because of :: syntax. // incorrectly before 5.3 because of :: syntax.
if (version_compare(PHP_VERSION, '5.6.0', '<')) { if (version_compare(PHP_VERSION, '7.0.0', '<')) {
print "<b>Fatal Error</b>: PHP version 5.6.0 or newer required. You're using " . PHP_VERSION . ".\n"; print "<b>Fatal Error</b>: PHP version 7.0.0 or newer required. You're using " . PHP_VERSION . ".\n";
exit; exit;
} }
@ -262,7 +262,7 @@
} }
?> ?>
<?php if (!$_SESSION["hide_logout"]) { ?> <?php if (empty($_SESSION["hide_logout"])) { ?>
<div dojoType="dijit.MenuItem" onclick="App.onActionSelected('qmcLogout')"><?php echo __('Logout') ?></div> <div dojoType="dijit.MenuItem" onclick="App.onActionSelected('qmcLogout')"><?php echo __('Logout') ?></div>
<?php } ?> <?php } ?>
</div> </div>

View File

@ -84,8 +84,8 @@
function sanity_check($db_type) { function sanity_check($db_type) {
$errors = array(); $errors = array();
if (version_compare(PHP_VERSION, '5.6.0', '<')) { if (version_compare(PHP_VERSION, '7.0.0', '<')) {
array_push($errors, "PHP version 5.6.0 or newer required. You're using " . PHP_VERSION . "."); array_push($errors, "PHP version 7.0.0 or newer required. You're using " . PHP_VERSION . ".");
} }
if (!function_exists("curl_init") && !ini_get("allow_url_fopen")) { if (!function_exists("curl_init") && !ini_get("allow_url_fopen")) {

View File

@ -29,7 +29,7 @@ class Af_Proxy_Http extends Plugin {
$host->add_hook($host::HOOK_PREFS_TAB, $this); $host->add_hook($host::HOOK_PREFS_TAB, $this);
if (!$_SESSION['af_proxy_http_token']) if (empty($_SESSION['af_proxy_http_token']))
$_SESSION['af_proxy_http_token'] = bin2hex(get_random_bytes(16)); $_SESSION['af_proxy_http_token'] = bin2hex(get_random_bytes(16));
} }

View File

@ -101,7 +101,7 @@ class Af_RedditImgur extends Plugin {
private function process_post_media($data, $doc, $xpath, $anchor) { private function process_post_media($data, $doc, $xpath, $anchor) {
$found = 0; $found = 0;
if (is_array($data["media_metadata"])) { if (isset($data["media_metadata"])) {
foreach ($data["media_metadata"] as $media) { foreach ($data["media_metadata"] as $media) {
$media_url = htmlspecialchars_decode($media["s"]["u"]); $media_url = htmlspecialchars_decode($media["s"]["u"]);
@ -134,7 +134,9 @@ class Af_RedditImgur extends Plugin {
} }
} */ } */
if (!$found && $data["post_hint"] == "hosted:video") { $post_hint = $data["post_hint"] ?? false;
if (!$found && $post_hint == "hosted:video") {
$media_url = $data["url"]; $media_url = $data["url"];
if (isset($data["preview"]["images"][0]["source"])) if (isset($data["preview"]["images"][0]["source"]))
@ -154,7 +156,7 @@ class Af_RedditImgur extends Plugin {
} }
} }
if (!$found && $data["post_hint"] == "video") { if (!$found && $post_hint == "video") {
$media_url = $data["url"]; $media_url = $data["url"];
if (isset($data["preview"]["images"][0]["source"])) if (isset($data["preview"]["images"][0]["source"]))
@ -168,7 +170,7 @@ class Af_RedditImgur extends Plugin {
$found = 1; $found = 1;
} }
if (!$found && $data["post_hint"] == "image") { if (!$found && $post_hint == "image") {
$media_url = $data["url"]; $media_url = $data["url"];
Debug::log("found image url: $media_url", Debug::$LOG_VERBOSE); Debug::log("found image url: $media_url", Debug::$LOG_VERBOSE);
@ -177,14 +179,14 @@ class Af_RedditImgur extends Plugin {
$found = 1; $found = 1;
} }
if (!$found && is_array($data["preview"]["images"])) { if (!$found && isset($data["preview"]["images"])) {
foreach ($data["preview"]["images"] as $img) { foreach ($data["preview"]["images"] as $img) {
if (isset($img["source"]["url"])) { if (isset($img["source"]["url"])) {
$media_url = htmlspecialchars_decode($img["source"]["url"]); $media_url = htmlspecialchars_decode($img["source"]["url"]);
$target_url = $data["url"]; $target_url = $data["url"];
if ($media_url) { if ($media_url) {
if ($data["post_hint"] == "self") { if ($post_hint == "self") {
Debug::log("found preview image url: $media_url (link: $target_url)", Debug::$LOG_VERBOSE); Debug::log("found preview image url: $media_url (link: $target_url)", Debug::$LOG_VERBOSE);
$this->handle_as_image($doc, $anchor, $media_url, $target_url); $this->handle_as_image($doc, $anchor, $media_url, $target_url);
@ -229,7 +231,7 @@ class Af_RedditImgur extends Plugin {
$data = $child["data"]; $data = $child["data"];
if (is_array($data["crosspost_parent_list"])) { if (isset($data["crosspost_parent_list"])) {
Debug::log("JSON: processing child crosspost_parent_list", Debug::$LOG_EXTENDED); Debug::log("JSON: processing child crosspost_parent_list", Debug::$LOG_EXTENDED);
foreach ($data["crosspost_parent_list"] as $parent) { foreach ($data["crosspost_parent_list"] as $parent) {

View File

@ -284,7 +284,7 @@
if (!isset($options["pidlock"]) || $options["task"] == 0) if (!isset($options["pidlock"]) || $options["task"] == 0)
RSSUtils::housekeeping_common(); RSSUtils::housekeeping_common();
PluginHost::getInstance()->run_hooks(PluginHost::HOOK_UPDATE_TASK, "hook_update_task", $op); PluginHost::getInstance()->run_hooks(PluginHost::HOOK_UPDATE_TASK, "hook_update_task", $options);
} }
if (isset($options["cleanup-tags"])) { if (isset($options["cleanup-tags"])) {