From 6af83e3881b3f38104027275913f7fc55251d020 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Fri, 12 Feb 2021 21:43:38 +0300 Subject: drop ENABLE_GZIP_OUTPUT; system prefs: load php info only if needed --- classes/pref/system.php | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'classes/pref') diff --git a/classes/pref/system.php b/classes/pref/system.php index d91339698..a7512915a 100644 --- a/classes/pref/system.php +++ b/classes/pref/system.php @@ -25,6 +25,15 @@ class Pref_System extends Handler_Protected { $this->pdo->query("DELETE FROM ttrss_error_log"); } + function getphpinfo() { + ob_start(); + phpinfo(); + $info = ob_get_contents(); + ob_end_clean(); + + print preg_replace( '%^.*(.*).*$%ms','$1', $info); + } + private function log_viewer(int $page, int $severity) { $errno_values = []; @@ -167,14 +176,11 @@ class Pref_System extends Handler_Protected { print "
"; - ob_start(); - phpinfo(); - $info = ob_get_contents(); - ob_end_clean(); + print ""; - print "
"; - print preg_replace( '%^.*(.*).*$%ms','$1', $info); - print "
"; + print "
" . __("Loading, please wait...") . "
"; print "
"; # accordion pane -- cgit v1.2.3 From 481bd7610059cfa09282a03e1a9c8dbc213f4819 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Fri, 12 Feb 2021 21:51:32 +0300 Subject: pref helpers: move some methods to their own sections --- classes/pref/feeds.php | 2 +- classes/pref/prefs.php | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'classes/pref') diff --git a/classes/pref/feeds.php b/classes/pref/feeds.php index 47e5689ec..ff9e69336 100755 --- a/classes/pref/feeds.php +++ b/classes/pref/feeds.php @@ -1394,7 +1394,7 @@ class Pref_Feeds extends Handler_Protected { print " - "; PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB_SECTION, "prefFeedsPublishedGenerated"); diff --git a/classes/pref/prefs.php b/classes/pref/prefs.php index d40dc87c0..cfe63ce85 100644 --- a/classes/pref/prefs.php +++ b/classes/pref/prefs.php @@ -715,7 +715,7 @@ class Pref_Prefs extends Handler_Protected { print ""; print " "; + onclick=\"Helpers.Prefs.customizeCSS()\">" . __('Customize') . ""; print " "; @@ -830,10 +830,10 @@ class Pref_Prefs extends Handler_Protected { "; - print " "; - print ""; print " "; @@ -968,7 +968,7 @@ class Pref_Prefs extends Handler_Protected { if (count($tmppluginhost->get_all($plugin)) > 0) { if (in_array($name, $system_enabled) || in_array($name, $user_enabled)) { print " "; } } -- cgit v1.2.3 From e7924c6dacef405a6e20b41d078f4a90a210cb51 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sat, 13 Feb 2021 13:17:34 +0300 Subject: label editor: use client dialog --- classes/pref/labels.php | 68 ++++--------------------------------------------- 1 file changed, 5 insertions(+), 63 deletions(-) (limited to 'classes/pref') diff --git a/classes/pref/labels.php b/classes/pref/labels.php index a787ce388..6102ab8dd 100644 --- a/classes/pref/labels.php +++ b/classes/pref/labels.php @@ -10,72 +10,14 @@ class Pref_Labels extends Handler_Protected { function edit() { $label_id = clean($_REQUEST['id']); - $sth = $this->pdo->prepare("SELECT * FROM ttrss_labels2 WHERE + $sth = $this->pdo->prepare("SELECT id, caption, fg_color, bg_color FROM ttrss_labels2 WHERE id = ? AND owner_uid = ?"); $sth->execute([$label_id, $_SESSION['uid']]); - if ($line = $sth->fetch()) { - - print_hidden("id", "$label_id"); - print_hidden("op", "pref-labels"); - print_hidden("method", "save"); - - print "
"; - - print "
".__("Caption")."
"; - - print "
"; - - $fg_color = $line['fg_color']; - $bg_color = $line['bg_color'] ? $line['bg_color'] : '#fff7d5'; - - print ""; - - print "
"; - - print "
" . __("Colors") . "
"; - print "
"; - - print ""; - print ""; - print "
".__("Foreground:")."".__("Background:")."
"; - - print ""; - print ""; - - print "
- -
"; - - print "
"; - - print "
- -
"; - - print "
"; - print "
"; - - print "
"; - print ""; - print ""; - print "
"; - - print "
"; + if ($line = $sth->fetch(PDO::FETCH_ASSOC)) { + print json_encode($line); + } else { + print json_encode(["error" => "LABEL_NOT_FOUND"]); } } -- cgit v1.2.3 From 46f6d7c11a85f78ffaad649b7f591effff52706f Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sat, 13 Feb 2021 13:26:17 +0300 Subject: pref-labels/index: cleanup --- classes/pref/labels.php | 115 +++++++++++++++++++++++------------------------- 1 file changed, 56 insertions(+), 59 deletions(-) (limited to 'classes/pref') diff --git a/classes/pref/labels.php b/classes/pref/labels.php index 6102ab8dd..acaabb233 100644 --- a/classes/pref/labels.php +++ b/classes/pref/labels.php @@ -190,65 +190,62 @@ class Pref_Labels extends Handler_Protected { } function index() { - - print "
"; - print "
"; - print "
"; - - print "
". - "" . __('Select').""; - print "
"; - print "
".__('All')."
"; - print "
".__('None')."
"; - print "
"; - - print" "; - - print " "; - - print ""; - - - print "
"; #toolbar - print "
"; #pane - print "
"; - - print "
- ". - __("Loading, please wait...")."
"; - - print "
-
-
+ ?> +
+
+
+
+ +
+
+
+
+
+ + + + + + + +
+
+ +
+
+ +
+ +
+
+ +
+
+ +
+ + +
+
+ run_hooks(PluginHost::HOOK_PREFS_TAB, "prefLabels") ?>
-
- - -
"; - - print "
"; #pane - - PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB, "prefLabels"); - - print "
"; #container - + Date: Sat, 13 Feb 2021 13:37:57 +0300 Subject: pref-labels index: use cleaner markup --- classes/pref/system.php | 56 +++++++++++++++++++++---------------------------- 1 file changed, 24 insertions(+), 32 deletions(-) (limited to 'classes/pref') diff --git a/classes/pref/system.php b/classes/pref/system.php index a7512915a..763440d78 100644 --- a/classes/pref/system.php +++ b/classes/pref/system.php @@ -150,43 +150,35 @@ class Pref_System extends Handler_Protected { } print ""; + print "
"; + print ""; } function index() { $severity = (int) ($_REQUEST["severity"] ?? E_USER_WARNING); $page = (int) ($_REQUEST["page"] ?? 0); - - print "
"; - print "
"; - - if (LOG_DESTINATION == "sql") { - - $this->log_viewer($page, $severity); - - } else { - print_notice("Please set LOG_DESTINATION to 'sql' in config.php to enable database logging."); - } - - print "
"; # content pane - print "
"; # container - print ""; # accordion pane - - print "
"; - - print ""; - - print "
" . __("Loading, please wait...") . "
"; - - print "
"; # accordion pane - - PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB, "prefSystem"); - - print ""; #container + ?> +
+
'> + log_viewer($page, $severity); + } else { + print_notice("Please set LOG_DESTINATION to 'sql' in config.php to enable database logging."); + } + ?> +
+ +
'> + +
+
+ + run_hooks(PluginHost::HOOK_PREFS_TAB, "prefSystem") ?> +
+ Date: Sat, 13 Feb 2021 13:50:53 +0300 Subject: prefs system: markup cleanup --- classes/pref/labels.php | 2 +- classes/pref/system.php | 164 ++++++++++++++++++++++++------------------------ 2 files changed, 84 insertions(+), 82 deletions(-) (limited to 'classes/pref') diff --git a/classes/pref/labels.php b/classes/pref/labels.php index acaabb233..92acabd9e 100644 --- a/classes/pref/labels.php +++ b/classes/pref/labels.php @@ -139,7 +139,7 @@ class Pref_Labels extends Handler_Protected { $sth->execute([$caption, $old_caption, $_SESSION['uid']]); - print clean($_REQUEST["value"]); + print clean($_REQUEST["caption"]); } else { print $old_caption; } diff --git a/classes/pref/system.php b/classes/pref/system.php index 763440d78..994e024c7 100644 --- a/classes/pref/system.php +++ b/classes/pref/system.php @@ -31,7 +31,7 @@ class Pref_System extends Handler_Protected { $info = ob_get_contents(); ob_end_clean(); - print preg_replace( '%^.*(.*).*$%ms','$1', $info); + print preg_replace( '%^.*(.*).*$%ms','$1', (string)$info); } private function log_viewer(int $page, int $severity) { @@ -71,87 +71,89 @@ class Pref_System extends Handler_Protected { $total_pages = 0; } - print "
"; - - print "
"; - - print ""; - - $prev_page_disabled = $page <= 0 ? "disabled" : ""; - - print ""; - - print ""; - - $next_page_disabled = $page >= $total_pages ? "disabled" : ""; - - print ""; - - print ""; - - print "
"; - - print __("Severity:") . " "; - print_select_hash("severity", $severity, - [ - E_USER_ERROR => __("Errors"), - E_USER_WARNING => __("Warnings"), - E_USER_NOTICE => __("Everything") - ], 'dojoType="fox.form.Select" onchange="Helpers.EventLog.refresh()"'); - - print "
"; # pull-right - - print "
"; # toolbar - - print '
'; - - print ""; - - print " - - - - - - "; - - $sth = $this->pdo->prepare("SELECT - errno, errstr, filename, lineno, created_at, login, context - FROM - ttrss_error_log LEFT JOIN ttrss_users ON (owner_uid = ttrss_users.id) - WHERE - $errno_filter_qpart - ORDER BY - ttrss_error_log.id DESC - LIMIT $limit OFFSET $offset"); - - $sth->execute($errno_values); - - while ($line = $sth->fetch()) { - print ""; - - foreach ($line as $k => $v) { - $line[$k] = htmlspecialchars($v); - } - - print ""; - print ""; - print ""; - print ""; - - print ""; - - print ""; - } + ?> +
+
+ + + + + + + + + + + +
+ + + __("Errors"), + E_USER_WARNING => __("Warnings"), + E_USER_NOTICE => __("Everything") + ], 'dojoType="fox.form.Select" onchange="Helpers.EventLog.refresh()"') ?> +
+
- print "
".__("Error")."".__("Filename")."".__("Message")."".__("User")."".__("Date")."
" . Logger::$errornames[$line["errno"]] . " (" . $line["errno"] . ")" . $line["filename"] . ":" . $line["lineno"] . "" . $line["errstr"] . "\n" . $line["context"] . "" . - TimeHelper::make_local_datetime($line["created_at"], false) . "
"; - print "
"; - print "
"; +
+ + + + + + + + + + + + pdo->prepare("SELECT + errno, errstr, filename, lineno, created_at, login, context + FROM + ttrss_error_log LEFT JOIN ttrss_users ON (owner_uid = ttrss_users.id) + WHERE + $errno_filter_qpart + ORDER BY + ttrss_error_log.id DESC + LIMIT $limit OFFSET $offset"); + + $sth->execute($errno_values); + + while ($line = $sth->fetch()) { + foreach ($line as $k => $v) { $line[$k] = htmlspecialchars($v); } + ?> + + + + + + + + +
+ + + +
+
+ + Date: Sat, 13 Feb 2021 14:05:25 +0300 Subject: pref filters index: markup cleanup --- classes/pref/filters.php | 133 ++++++++++++++++++++++------------------------- 1 file changed, 61 insertions(+), 72 deletions(-) (limited to 'classes/pref') diff --git a/classes/pref/filters.php b/classes/pref/filters.php index a24a05b05..c80a10c64 100755 --- a/classes/pref/filters.php +++ b/classes/pref/filters.php @@ -710,81 +710,70 @@ class Pref_Filters extends Handler_Protected { $filter_search = ($_SESSION["prefs_filter_search"] ?? ""); } - print "
"; - print "
"; - print "
"; - - print "
- - -
"; - - print "
". - "" . __('Select').""; - print "
"; - print "
".__('All')."
"; - print "
".__('None')."
"; - print "
"; - - print " "; - - print " "; - - print " "; - - print " "; - - - print " "; - - print "
"; # toolbar - print "
"; # toolbar-frame - print "
"; + ?> +
+
+
+ +
+ + +
- print "
- ". - __("Loading, please wait...")."
"; +
+ +
+
+
+
+
- print "
-
-
+ + + + + + +
+
+
+
+ +
+
+
+
+
+
+ + +
+
+ run_hooks(PluginHost::HOOK_PREFS_TAB, "prefFilters") ?>
-
- - - -
"; - - print "
"; #pane - - PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB, "prefFilters"); - - print "
"; #container - + Date: Sat, 13 Feb 2021 16:07:52 +0300 Subject: minor fixes re: previous --- classes/pref/filters.php | 2 +- classes/pref/system.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'classes/pref') diff --git a/classes/pref/filters.php b/classes/pref/filters.php index c80a10c64..c83299678 100755 --- a/classes/pref/filters.php +++ b/classes/pref/filters.php @@ -717,7 +717,7 @@ class Pref_Filters extends Handler_Protected {
+ value="">
diff --git a/classes/pref/system.php b/classes/pref/system.php index 994e024c7..72e15e4f3 100644 --- a/classes/pref/system.php +++ b/classes/pref/system.php @@ -146,7 +146,7 @@ class Pref_System extends Handler_Protected { - + -- cgit v1.2.3 From 17413078a72e1298c6dc8953c40e8d83ce38c49c Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sat, 13 Feb 2021 18:32:02 +0300 Subject: pref feeds: index cleanup, split into several methods, use tabs to maximize space for feed tree, persist feed tree state --- classes/pref/feeds.php | 333 +++++++++++++++++++++++++---------------------- classes/pref/filters.php | 6 - classes/pref/labels.php | 7 - 3 files changed, 177 insertions(+), 169 deletions(-) (limited to 'classes/pref') diff --git a/classes/pref/feeds.php b/classes/pref/feeds.php index ff9e69336..d8495a59c 100755 --- a/classes/pref/feeds.php +++ b/classes/pref/feeds.php @@ -1197,12 +1197,7 @@ class Pref_Feeds extends Handler_Protected { $opml->opml_import($_SESSION["uid"]); } - function index() { - - print "
"; - print "
rss_feed ".__('Feeds')."\">"; - + private function index_feeds() { $sth = $this->pdo->prepare("SELECT COUNT(id) AS num_errors FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ?"); $sth->execute([$_SESSION['uid']]); @@ -1214,16 +1209,15 @@ class Pref_Feeds extends Handler_Protected { } if ($num_errors > 0) { - $error_button = ""; + $error_button = ""; } else { $error_button = ""; } - $inactive_button = ""; @@ -1235,175 +1229,202 @@ class Pref_Feeds extends Handler_Protected { $feed_search = $_SESSION["prefs_feed_search"] ?? ""; } - print '
'; - - print "
"; #toolbar - - print "
- - -
"; - - print "
". - "" . __('Select').""; - print "
"; - print "
".__('All')."
"; - print "
".__('None')."
"; - print "
"; - - print "
". - "" . __('Feeds').""; - print "
"; - print "
".__('Subscribe to feed')."
"; - print "
".__('Edit selected feeds')."
"; - print "
".__('Reset sort order')."
"; - print "
".__('Batch subscribe')."
"; - print "
" - .__('Unsubscribe')."
"; - print "
"; - - if (get_pref('ENABLE_FEED_CATS')) { - print "
". - "" . __('Categories').""; - print "
"; - print "
".__('Add category')."
"; - print "
".__('Reset sort order')."
"; - print "
".__('Remove selected')."
"; - print "
"; - - } - - print $error_button; - print $inactive_button; - - print "
"; # toolbar - - //print '
'; - print '
'; - - print "
- ". - __("Loading, please wait...")."
"; - - $auto_expand = $feed_search != "" ? "true" : "false"; - - print "
-
-
+ ?> + +
+
+
+ + +
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+
+
+
+
+
+ + +
+ +
+
+
+
+
+
+ + + +
+
+
+
+ +
+
+ +
" + persist="true" + model="feedModel" + openOnClick="false"> + + +
+
-
- - -
"; - -# print "
-# ".__('Hint: you can drag feeds and categories around.')." -#
"; + '; - print '
'; - - print "
"; # feeds pane + } - print "
"; + private function index_opml() { + ?> - print "

" . __("Using OPML you can export and import your feeds, filters, labels and Tiny Tiny RSS settings.") . "

"; +

- print_notice("Only main settings profile can be migrated using OPML."); + - print "
-
"; # pane - - print "
share ".__('Published & shared articles / Generated feeds')."\">"; - - print "

" . __('Published articles can be subscribed by anyone who knows the following URL:') . "

"; - + private function index_shared() { $rss_url = htmlspecialchars(get_self_url_prefix() . - "/public.php?op=rss&id=-2&view-mode=all_articles");; + "/public.php?op=rss&id=-2&view-mode=all_articles"); + ?> - print " - "; +

- PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB_SECTION, "prefFeedsPublishedGenerated"); + - print "
"; #pane + - PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB, "prefFeeds"); + run_hooks(PluginHost::HOOK_PREFS_TAB_SECTION, "prefFeedsPublishedGenerated"); + } - print "
"; #container + function index() { + ?> + +
+
+ index_feeds() ?> +
+ +
+ index_opml() ?> +
+ +
+ index_shared() ?> +
+ + run_hooks(PluginHost::HOOK_PREFS_TAB, "prefFeeds"); + $plugin_data = trim((string)ob_get_contents()); + ob_end_clean(); + ?> + + +
+ +
+ +
+
+ +
+
-
- -
@@ -758,9 +755,6 @@ class Pref_Filters extends Handler_Protected {
-
-- cgit v1.2.3 From 15fd23c374eb32c50733de1906065f552afbfbc4 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sun, 14 Feb 2021 09:15:51 +0300 Subject: use shortcut echo syntax for php templates --- classes/pref/feeds.php | 74 ++++++++++++++++++++++++------------------------ classes/pref/filters.php | 20 ++++++------- classes/pref/labels.php | 12 ++++---- classes/pref/system.php | 42 +++++++++++++-------------- 4 files changed, 74 insertions(+), 74 deletions(-) (limited to 'classes/pref') diff --git a/classes/pref/feeds.php b/classes/pref/feeds.php index 72a8344ad..6b5df0289 100755 --- a/classes/pref/feeds.php +++ b/classes/pref/feeds.php @@ -1223,52 +1223,52 @@ class Pref_Feeds extends Handler_Protected {
+ value=""> +
- +
+ dojoType="dijit.MenuItem">
+ dojoType="dijit.MenuItem">
- +
+ dojoType="dijit.MenuItem">
+ dojoType="dijit.MenuItem">
+ dojoType="dijit.MenuItem">
+ dojoType="dijit.MenuItem">
-
+
- +
+ dojoType="dijit.MenuItem">
+ dojoType="dijit.MenuItem">
+ dojoType="dijit.MenuItem"> - - + +
" + autoExpand="" persist="true" model="feedModel" openOnClick="false"> @@ -1311,19 +1311,19 @@ class Pref_Feeds extends Handler_Protected { private function index_opml() { ?> -

+

-
+ + + + + diff --git a/classes/pref/labels.php b/classes/pref/labels.php index 22a2dddea..d182a0995 100644 --- a/classes/pref/labels.php +++ b/classes/pref/labels.php @@ -195,23 +195,23 @@ class Pref_Labels extends Handler_Protected {
- +
+ dojoType='dijit.MenuItem'>
+ dojoType='dijit.MenuItem'>
+ + + diff --git a/classes/pref/system.php b/classes/pref/system.php index 72e15e4f3..1adddf116 100644 --- a/classes/pref/system.php +++ b/classes/pref/system.php @@ -76,30 +76,30 @@ class Pref_System extends Handler_Protected {
- -
- + - - - - - + + + + + - + - - - + + + - + @@ -162,7 +162,7 @@ class Pref_System extends Handler_Protected { $page = (int) ($_REQUEST["page"] ?? 0); ?>
-
'> +
'> log_viewer($page, $severity); @@ -172,11 +172,11 @@ class Pref_System extends Handler_Protected { ?>
-
'> +
'> -
+
run_hooks(PluginHost::HOOK_PREFS_TAB, "prefSystem") ?> -- cgit v1.2.3 From 8e75551f95ec2ade517afce2afe76150d5ffda24 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sun, 14 Feb 2021 11:29:38 +0300 Subject: pref prefs: split index into manageable chunks --- classes/pref/prefs.php | 837 +++++++++++++++++++++++++------------------------ 1 file changed, 435 insertions(+), 402 deletions(-) (limited to 'classes/pref') diff --git a/classes/pref/prefs.php b/classes/pref/prefs.php index cfe63ce85..a37ae99b5 100644 --- a/classes/pref/prefs.php +++ b/classes/pref/prefs.php @@ -4,6 +4,7 @@ class Pref_Prefs extends Handler_Protected { private $pref_help = []; private $pref_item_map = []; + private $pref_help_bottom = []; private $pref_blacklist = []; private $profile_blacklist = []; @@ -272,34 +273,7 @@ class Pref_Prefs extends Handler_Protected { echo __("Your preferences are now set to default values."); } - function index() { - - global $access_level_names; - - $_SESSION["prefs_op_result"] = ""; - - print "
"; - print "
person ".__('Personal data / Authentication')."\">"; - - print "
"; - print "
"; - - print "
"; - - print ""; + private function index_auth_personal() { $sth = $this->pdo->prepare("SELECT email,full_name,otp_enabled, access_level FROM ttrss_users @@ -311,179 +285,214 @@ class Pref_Prefs extends Handler_Protected { $full_name = htmlspecialchars($row["full_name"]); $otp_enabled = sql_bool_to_bool($row["otp_enabled"]); - print "
"; - print ""; - print ""; - print "
"; - - print "
"; - print ""; - print ""; - print "
"; - - if (!SINGLE_USER_MODE && !empty($_SESSION["hide_hello"])) { + ?> + - $access_level = $row["access_level"]; - print "
"; - print ""; - print $access_level_names[$access_level]; - print "
"; - } - - print_hidden("op", "pref-prefs"); - print_hidden("method", "changeemail"); - - print "
"; + + - print ""; - - print "
"; + + +
+ + +
+ +
+ + +
+ + +
+ + +
+ + +
+ + + + get_plugin($_SESSION["auth_module"]); } else { $authenticator = false; } - print "
"; + $otp_enabled = $this->is_otp_enabled(); if ($authenticator && method_exists($authenticator, "change_password")) { + ?> - print ""; + - print "
"; + - print ""; + const warn = $('default_pass_warning'); + if (warn) Element.hide(warn); + } - if ($otp_enabled) { - print_notice(__("Changing your current password will disable OTP.")); - } + new Effect.Appear('pwd_change_infobox'); + } + }); + this.reset(); + } + - print "
"; - print ""; - print ""; - print "
"; + - print "
"; - print ""; - print ""; - print "
"; +
+ + +
- print "
"; - print ""; - print ""; - print "
"; +
+ + +
- print_hidden("op", "pref-prefs"); - print_hidden("method", "changepassword"); +
+ + +
- print "
"; +
- print ""; + +
- print ""; + %s) does not provide an ability to set passwords.", $_SESSION["auth_module"])); } + } - print "
"; # content pane + private function index_auth_app_passwords() { + print_notice("You can create separate passwords for API clients. Using one is required if you enable OTP."); + ?> - print "
"; +
+ appPasswordList() ?> +
- print_notice("You can create separate passwords for API clients. Using one is required if you enable OTP."); +
- print "
"; - $this->appPasswordList(); - print "
"; + + + - print "
"; + " . - __('Generate new password') . " "; + private function is_otp_enabled() { + $sth = $this->pdo->prepare("SELECT otp_enabled FROM ttrss_users + WHERE id = ?"); + $sth->execute([$_SESSION["uid"]]); - print ""; + if ($row = $sth->fetch()) { + return sql_bool_to_bool($row["otp_enabled"]); + } - print "
"; # content pane + return false; + } - print "
"; + private function index_auth_2fa() { + $otp_enabled = $this->is_otp_enabled(); if ($_SESSION["auth_module"] == "auth_internal") { - if ($otp_enabled) { - print_warning("One time passwords are currently enabled. Enter your current password below to disable."); + ?> + +
+ + + + - print ""; - - print ""; - - print "
"; - print ""; - print ""; - print "
"; +
+ + +
- print_hidden("op", "pref-prefs"); - print_hidden("method", "otpdisable"); +
- print "
"; + - print ""; +
- print ""; + " . __("Scan the following code by the Authenticator application or copy the key manually") . ""; - $csrf_token_hash = sha1($_SESSION["csrf_token"]); print "otp qr-code"; } else { @@ -500,105 +508,86 @@ class Pref_Prefs extends Handler_Protected { print "

" . __("Use the following OTP key with a compatible Authenticator application") . "

"; } - print "
"; - $otp_secret = $this->otpsecret(); + ?> + + + + + + +
+ + +
+ + - print "
"; - print ""; - print ""; - print "
"; - - print_hidden("op", "pref-prefs"); - print_hidden("method", "otpenable"); - - print ""; - - print "
"; - print ""; - print ""; - print "
"; +
+ + +
- print "
"; - print ""; - print ""; - print "
"; +
+ + +
- print "
"; - print ""; +
- print "
"; + + + auth_internal authentication module."); } + } - print "
"; # content pane - - print "
"; # tab container - - PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB_SECTION, "prefPrefsAuth"); - - print "
"; #pane - - print "
settings ".__('Preferences')."\">"; - - print "
"; - - print ""; - - print '
'; - - print '
'; + private function index_auth() { + ?> +
+
+ index_auth_personal() ?> +
+
+ index_auth_password() ?> +
+
+ index_auth_app_passwords() ?> +
+
+ index_auth_2fa() ?> +
+
+ initialize_user_prefs($_SESSION["uid"], $profile); } else { $this->initialize_user_prefs($_SESSION["uid"]); @@ -660,7 +649,9 @@ class Pref_Prefs extends Handler_Protected { continue; } - if (isset($prefs_available[$pref_name]) &&$item = $prefs_available[$pref_name]) { + if (isset($prefs_available[$pref_name])) { + + $item = $prefs_available[$pref_name]; print "
"; @@ -735,16 +726,16 @@ class Pref_Prefs extends Handler_Protected { array_push($listed_boolean_prefs, $pref_name); - $checked = ($value == "true") ? "checked=\"checked\"" : ""; + $is_checked = ($value == "true") ? "checked=\"checked\"" : ""; if ($pref_name == "PURGE_UNREAD_ARTICLES" && FORCE_ARTICLE_PURGE != 0) { - $disabled = "disabled=\"1\""; - $checked = "checked=\"checked\""; + $is_disabled = "disabled=\"1\""; + $is_checked = "checked=\"checked\""; } else { - $disabled = ""; + $is_disabled = ""; } - print ""; } else if (in_array($pref_name, ['FRESH_ARTICLE_MAX_AGE', @@ -753,19 +744,19 @@ class Pref_Prefs extends Handler_Protected { $regexp = ($type_name == 'integer') ? 'regexp="^\d*$"' : ''; if ($pref_name == "PURGE_OLD_DAYS" && FORCE_ARTICLE_PURGE != 0) { - $disabled = "disabled='1'"; + $is_disabled = "disabled='1'"; $value = FORCE_ARTICLE_PURGE; } else { - $disabled = ""; + $is_disabled = ""; } if ($type_name == 'integer') print ""; else print ""; } else if ($pref_name == "SSL_CERT_SERIAL") { @@ -808,204 +799,246 @@ class Pref_Prefs extends Handler_Protected { } } } + print_hidden("boolean_prefs", htmlspecialchars(join(",", $listed_boolean_prefs))); + } - $listed_boolean_prefs = htmlspecialchars(join(",", $listed_boolean_prefs)); - - print_hidden("boolean_prefs", "$listed_boolean_prefs"); - - PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB_SECTION, "prefPrefsPrefsInside"); - - print '
'; # inside pane - print '
'; - - print_hidden("op", "pref-prefs"); - print_hidden("method", "saveconfig"); + private function index_prefs() { + ?> + + + + + +
+
+ index_prefs_list() ?> + run_hooks(PluginHost::HOOK_PREFS_TAB_SECTION, "prefPrefsPrefsInside") ?> +
+
+ +
+ +
+
+ +
+
+
+ + + + + + run_hooks(PluginHost::HOOK_PREFS_TAB_SECTION, "prefPrefsPrefsOutside") ?> +
-
"; - - print " "; - - print ""; - - print " "; - - PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB_SECTION, "prefPrefsPrefsOutside"); - - print ""; - print '
'; # inner pane - print '
'; # border container - - print "
"; #pane - - print "
extension ".__('Plugins')."\">"; - - print "
"; - - print ""; - - print_hidden("op", "pref-prefs"); - print_hidden("method", "setplugins"); - - print '
'; - print '
'; - - if (ini_get("open_basedir") && function_exists("curl_init") && !defined("NO_CURL")) { - print_warning("Your PHP configuration has open_basedir restrictions enabled. Some plugins relying on CURL for functionality may not work correctly."); - } - - if ($_SESSION["safe_mode"]) { - print_error("You have logged in using safe mode, no user plugins will be actually enabled until you login again."); - } - - $feed_handler_whitelist = [ "Af_Comics" ]; - - $feed_handlers = array_merge( - PluginHost::getInstance()->get_hooks(PluginHost::HOOK_FEED_FETCHED), - PluginHost::getInstance()->get_hooks(PluginHost::HOOK_FEED_PARSED), - PluginHost::getInstance()->get_hooks(PluginHost::HOOK_FETCH_FEED)); - - $feed_handlers = array_filter($feed_handlers, function($plugin) use ($feed_handler_whitelist) { - return in_array(get_class($plugin), $feed_handler_whitelist) === false; }); - - if (count($feed_handlers) > 0) { - print_error( - T_sprintf("The following plugins use per-feed content hooks. This may cause excessive data usage and origin server load resulting in a ban of your instance: %s" , - implode(", ", array_map(function($plugin) { return get_class($plugin); }, $feed_handlers)) - ) . " (".__("More info...").")" - ); - } + + ".__("System plugins").""; + private function index_plugins_system() { print_notice("System plugins are enabled in config.php for all users."); - $system_enabled = array_map("trim", explode(",", PLUGINS)); - $user_enabled = array_map("trim", explode(",", get_pref("_ENABLED_PLUGINS"))); + $system_enabled = array_map("trim", explode(",", (string)PLUGINS)); $tmppluginhost = new PluginHost(); $tmppluginhost->load_all($tmppluginhost::KIND_ALL, $_SESSION["uid"], true); - //$tmppluginhost->load_data(true); foreach ($tmppluginhost->get_plugins() as $name => $plugin) { $about = $plugin->about(); if ($about[3] ?? false) { - if (in_array($name, $system_enabled)) { - $checked = "checked='1'"; - } else { - $checked = ""; - } - - print "
- - "; - - if ($about[4] ?? false) { - print ""; - } - - print "
". - htmlspecialchars(T_sprintf("v%.2f, by %s", $about[0], $about[2])). - "
"; - - print "
"; - + $is_checked = in_array($name, $system_enabled) ? "checked" : ""; + ?> +
+ + + + + + + +
+ +
+
+ ".__("User plugins").""; + private function index_plugins_user() { + $system_enabled = array_map("trim", explode(",", (string)PLUGINS)); + $user_enabled = array_map("trim", explode(",", get_pref("_ENABLED_PLUGINS"))); + + $tmppluginhost = new PluginHost(); + $tmppluginhost->load_all($tmppluginhost::KIND_ALL, $_SESSION["uid"], true); foreach ($tmppluginhost->get_plugins() as $name => $plugin) { $about = $plugin->about(); if (empty($about[3]) || $about[3] == false) { - $checked = ""; - $disabled = ""; + $is_checked = ""; + $is_disabled = ""; if (in_array($name, $system_enabled)) { - $checked = "checked='1'"; - $disabled = "disabled='1'"; + $is_checked = "checked='1'"; + $is_disabled = "disabled='1'"; } else if (in_array($name, $user_enabled)) { - $checked = "checked='1'"; + $is_checked = "checked='1'"; } - print "
- - "; - - if (count($tmppluginhost->get_all($plugin)) > 0) { - if (in_array($name, $system_enabled) || in_array($name, $user_enabled)) { - print " "; - } - } + ?> + +
+ + + + get_all($plugin)) > 0) { + if (in_array($name, $system_enabled) || in_array($name, $user_enabled)) { ?> + + + + + + + +
+ +
+ +
+ - open_in_new ".__("More info...").""; + private function index_plugins() { + ?> +
+ - print "
". - htmlspecialchars(T_sprintf("v%.2f, by %s", $about[0], $about[2])). - "
"; + + - print "
"; - } - } +
+
+ "; #content-pane - print '
'; + $feed_handler_whitelist = [ "Af_Comics" ]; - print ""; + $feed_handlers = array_merge( + PluginHost::getInstance()->get_hooks(PluginHost::HOOK_FEED_FETCHED), + PluginHost::getInstance()->get_hooks(PluginHost::HOOK_FEED_PARSED), + PluginHost::getInstance()->get_hooks(PluginHost::HOOK_FETCH_FEED)); - print ""; - print "
"; #pane + $feed_handlers = array_filter($feed_handlers, function($plugin) use ($feed_handler_whitelist) { + return in_array(get_class($plugin), $feed_handler_whitelist) === false; }); - print "
"; #pane - print "
"; #border-container + if (count($feed_handlers) > 0) { + print_error( + T_sprintf("The following plugins use per-feed content hooks. This may cause excessive data usage and origin server load resulting in a ban of your instance: %s" , + implode(", ", array_map(function($plugin) { return get_class($plugin); }, $feed_handlers)) + ) . " (".__("More info...").")" + ); + } + ?> - print ""; +

+ + index_plugins_system() ?> - PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB, "prefPrefs"); +

- print "
"; #container + index_plugins_user() ?> +
+
+ + +
+
+ + +
+
+ index_auth() ?> +
+
+ index_prefs() ?> +
+
+ index_plugins() ?> +
+ run_hooks(PluginHost::HOOK_PREFS_TAB, "prefPrefs") ?> +
+ Date: Sun, 14 Feb 2021 11:39:26 +0300 Subject: appPasswordList: markup cleanup --- classes/pref/prefs.php | 90 ++++++++++++++++++++++++-------------------------- 1 file changed, 44 insertions(+), 46 deletions(-) (limited to 'classes/pref') diff --git a/classes/pref/prefs.php b/classes/pref/prefs.php index a37ae99b5..ec7fbf607 100644 --- a/classes/pref/prefs.php +++ b/classes/pref/prefs.php @@ -1317,53 +1317,51 @@ class Pref_Prefs extends Handler_Protected { } private function appPasswordList() { - print "
"; - print "
" . - "" . __('Select') . ""; - print "
"; - print "
" . __('All') . "
"; - print "
" . __('None') . "
"; - print "
"; - print "
"; #toolbar - - print "
"; - print ""; - print ""; - print ""; - print ""; - print ""; - print ""; - print ""; - - $sth = $this->pdo->prepare("SELECT id, title, created, last_used - FROM ttrss_app_passwords WHERE owner_uid = ?"); - $sth->execute([$_SESSION['uid']]); - - while ($row = $sth->fetch()) { - - $row_id = $row["id"]; - - print ""; - - print ""; - print ""; - - print ""; - - print ""; - - print ""; - } + ?> +
+
+ +
+
+
+
+
+
- print "
".__("Description")."".__("Created")."".__("Last used")."
- " . htmlspecialchars($row["title"]) . ""; - print TimeHelper::make_local_datetime($row['created'], false); - print ""; - print TimeHelper::make_local_datetime($row['last_used'], false); - print "
"; - print "
"; +
+ + + + + + + + pdo->prepare("SELECT id, title, created, last_used + FROM ttrss_app_passwords WHERE owner_uid = ?"); + $sth->execute([$_SESSION['uid']]); + + while ($row = $sth->fetch()) { ?> + '> + + + + + + +
+ + + + + + + +
+
+ Date: Sun, 14 Feb 2021 12:25:41 +0300 Subject: pref prefs: load secondary tabs when needed --- classes/pref/prefs.php | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'classes/pref') diff --git a/classes/pref/prefs.php b/classes/pref/prefs.php index ec7fbf607..19f5221eb 100644 --- a/classes/pref/prefs.php +++ b/classes/pref/prefs.php @@ -564,7 +564,7 @@ class Pref_Prefs extends Handler_Protected { } } - private function index_auth() { + function index_auth() { ?>
@@ -953,7 +953,7 @@ class Pref_Prefs extends Handler_Protected { } } - private function index_plugins() { + function index_plugins() { ?>
+
index_prefs() ?>
- index_plugins() ?> + +
run_hooks(PluginHost::HOOK_PREFS_TAB, "prefPrefs") ?>
-- cgit v1.2.3 From 1c7e4782aa426dd1a003948756c51cf9d61f2163 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sun, 14 Feb 2021 12:29:08 +0300 Subject: prefs system: load phpinfo using inline method --- classes/pref/prefs.php | 2 -- classes/pref/system.php | 13 +++++++++---- 2 files changed, 9 insertions(+), 6 deletions(-) (limited to 'classes/pref') diff --git a/classes/pref/prefs.php b/classes/pref/prefs.php index 19f5221eb..6e4deb223 100644 --- a/classes/pref/prefs.php +++ b/classes/pref/prefs.php @@ -1032,7 +1032,6 @@ class Pref_Prefs extends Handler_Protected { if (this.domNode.querySelector('.loading')) window.setTimeout(() => { xhrPost("backend.php", {op: 'pref-prefs', method: 'index_auth'}, (transport) => { - console.log(this); this.attr('content', transport.responseText); }); }, 100); @@ -1047,7 +1046,6 @@ class Pref_Prefs extends Handler_Protected { if (this.domNode.querySelector('.loading')) window.setTimeout(() => { xhrPost("backend.php", {op: 'pref-prefs', method: 'index_plugins'}, (transport) => { - console.log(this); this.attr('content', transport.responseText); }); }, 200); diff --git a/classes/pref/system.php b/classes/pref/system.php index 1adddf116..14df6f8d1 100644 --- a/classes/pref/system.php +++ b/classes/pref/system.php @@ -173,10 +173,15 @@ class Pref_System extends Handler_Protected {
'> - -
+ +
run_hooks(PluginHost::HOOK_PREFS_TAB, "prefSystem") ?> -- cgit v1.2.3 From 2547ece0cacb7080060ad3bc32b879fee6b52230 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sun, 14 Feb 2021 14:59:22 +0300 Subject: pref-users: cleanup index --- classes/pref/users.php | 214 +++++++++++++++++++++---------------------------- 1 file changed, 93 insertions(+), 121 deletions(-) (limited to 'classes/pref') diff --git a/classes/pref/users.php b/classes/pref/users.php index 5c622a9b1..0454a1292 100644 --- a/classes/pref/users.php +++ b/classes/pref/users.php @@ -251,12 +251,8 @@ class Pref_Users extends Handler_Protected { print T_sprintf("Added user %s with password %s", $login, $tmp_user_pwd); - $this->initialize_user($new_uid); - } else { - print T_sprintf("Could not create user %s", $login); - } } else { print T_sprintf("User %s already exists.", $login); @@ -303,10 +299,6 @@ class Pref_Users extends Handler_Protected { global $access_level_names; - print "
"; - print "
"; - print "
"; - $user_search = clean($_REQUEST["search"] ?? ""); if (array_key_exists("search", $_REQUEST)) { @@ -315,137 +307,117 @@ class Pref_Users extends Handler_Protected { $user_search = ($_SESSION["prefs_user_search"] ?? ""); } - print "
- - -
"; - $sort = clean($_REQUEST["sort"] ?? ""); if (!$sort || $sort == "undefined") { $sort = "login"; } - print "
". - "" . __('Select').""; - print "
"; - print "
".__('All')."
"; - print "
".__('None')."
"; - print "
"; - - print ""; - - print " - - - "; - - PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB_SECTION, "prefUsersToolbar"); - - print "
"; #toolbar - print "
"; #pane - print "
"; - $sort = $this->validate_field($sort, ["login", "access_level", "created", "num_feeds", "created", "last_login"], "login"); if ($sort != "login") $sort = "$sort DESC"; - $sth = $this->pdo->prepare("SELECT - tu.id, - login,access_level,email, - ".SUBSTRING_FOR_DATE."(last_login,1,16) as last_login, - ".SUBSTRING_FOR_DATE."(created,1,16) as created, - (SELECT COUNT(id) FROM ttrss_feeds WHERE owner_uid = tu.id) AS num_feeds - FROM - ttrss_users tu - WHERE - (:search = '' OR login LIKE :search) AND tu.id > 0 - ORDER BY $sort"); - $sth->execute([":search" => $user_search ? "%$user_search%" : ""]); - - print ""; - - print " - - - - - - "; - - $lnum = 0; - - while ($line = $sth->fetch()) { - - $uid = $line["id"]; - - print ""; - - $line["login"] = htmlspecialchars($line["login"]); - $line["created"] = TimeHelper::make_local_datetime($line["created"], false); - $line["last_login"] = TimeHelper::make_local_datetime($line["last_login"], false); - - print ""; - - print ""; - - print ""; - print ""; - print ""; - print ""; - - print ""; - - ++$lnum; - } - - print "
 ".__('Login')."".__('Access Level')."".__('Subscribed feeds')."".__('Registered')."".__('Last login')."
person " . $line["login"] . "" . $access_level_names[$line["access_level"]] . "" . $line["num_feeds"] . "" . $line["created"] . "" . $line["last_login"] . "
"; - - if ($lnum == 0) { - if (!$user_search) { - print_warning(__('No users defined.')); - } else { - print_warning(__('No matching users found.')); - } - } - - print "
"; #pane - - PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB, "prefUsers"); - - print "
"; #container - - } + ?> + +
+
+
+ +
+ + +
+ +
+ +
+
+
+
+
+ + + + + + + + + + run_hooks(PluginHost::HOOK_PREFS_TAB_SECTION, "prefUsersToolbar") ?> + +
+
+
+ + + + + + + + + + + + + pdo->prepare("SELECT + tu.id, + login,access_level,email, + ".SUBSTRING_FOR_DATE."(last_login,1,16) as last_login, + ".SUBSTRING_FOR_DATE."(created,1,16) as created, + (SELECT COUNT(id) FROM ttrss_feeds WHERE owner_uid = tu.id) AS num_feeds + FROM + ttrss_users tu + WHERE + (:search = '' OR login LIKE :search) AND tu.id > 0 + ORDER BY $sort"); + $sth->execute([":search" => $user_search ? "%$user_search%" : ""]); + + while ($row = $sth->fetch()) { ?> + + + + + + + + + + + +
+ + person
+
+ run_hooks(PluginHost::HOOK_PREFS_TAB, "prefUsers") ?> +
+ prepare("insert into ttrss_feeds (owner_uid,title,feed_url) - values (?, 'Tiny Tiny RSS: Forum', - 'https://tt-rss.org/forum/rss.php')"); - $sth->execute([$uid]); - } - static function logout_user() { if (session_status() === PHP_SESSION_ACTIVE) session_destroy(); -- cgit v1.2.3 From a8cc43a0ff1cf6297577fae8536408287518baf4 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sun, 14 Feb 2021 15:31:03 +0300 Subject: move logout_user() to UserHelper --- classes/pref/users.php | 11 ----------- 1 file changed, 11 deletions(-) (limited to 'classes/pref') diff --git a/classes/pref/users.php b/classes/pref/users.php index 0454a1292..24d28e62a 100644 --- a/classes/pref/users.php +++ b/classes/pref/users.php @@ -418,15 +418,4 @@ class Pref_Users extends Handler_Protected { return $default; } - static function logout_user() { - if (session_status() === PHP_SESSION_ACTIVE) - session_destroy(); - - if (isset($_COOKIE[session_name()])) { - setcookie(session_name(), '', time()-42000, '/'); - - } - session_commit(); - } - } -- cgit v1.2.3 From 0fbf10991237b3f91ee5c77349637d7197a22bdc Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sun, 14 Feb 2021 15:38:45 +0300 Subject: * remove users/filters toolbar edit button (just click on it) * fix title of edit filter dialog always showing create filter --- classes/pref/filters.php | 2 -- classes/pref/users.php | 4 ---- 2 files changed, 6 deletions(-) (limited to 'classes/pref') diff --git a/classes/pref/filters.php b/classes/pref/filters.php index c898a8b67..1c264f642 100755 --- a/classes/pref/filters.php +++ b/classes/pref/filters.php @@ -736,8 +736,6 @@ class Pref_Filters extends Handler_Protected { - - - -- cgit v1.2.3 From 33ea46c2bc5c91d7767f11c230a941cc635c0e67 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sun, 14 Feb 2021 15:42:12 +0300 Subject: pref-users/add: remove unused variable --- classes/pref/users.php | 2 -- 1 file changed, 2 deletions(-) (limited to 'classes/pref') diff --git a/classes/pref/users.php b/classes/pref/users.php index 7adb09ab2..9d9ea4d8e 100644 --- a/classes/pref/users.php +++ b/classes/pref/users.php @@ -246,8 +246,6 @@ class Pref_Users extends Handler_Protected { if ($new_uid = UserHelper::find_user_by_login($login)) { - $new_uid = $row['id']; - print T_sprintf("Added user %s with password %s", $login, $tmp_user_pwd); -- cgit v1.2.3 From 0b7377238a556708035b0cd51a9e58693fb648f6 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sun, 14 Feb 2021 15:50:46 +0300 Subject: add Handler_Administrative --- classes/pref/system.php | 13 +------------ classes/pref/users.php | 13 +------------ 2 files changed, 2 insertions(+), 24 deletions(-) (limited to 'classes/pref') diff --git a/classes/pref/system.php b/classes/pref/system.php index 14df6f8d1..2a97ec6f0 100644 --- a/classes/pref/system.php +++ b/classes/pref/system.php @@ -1,20 +1,9 @@ Date: Sun, 14 Feb 2021 16:44:41 +0300 Subject: pref-users edit: use client dialog --- classes/pref/users.php | 112 +++++++------------------------------------------ 1 file changed, 16 insertions(+), 96 deletions(-) (limited to 'classes/pref') diff --git a/classes/pref/users.php b/classes/pref/users.php index b34f85d88..bc125d0ce 100644 --- a/classes/pref/users.php +++ b/classes/pref/users.php @@ -1,7 +1,7 @@ "; + $id = (int)clean($_REQUEST["id"]); - print '
-
'; - - //print ""; - - $id = (int) clean($_REQUEST["id"]); - - print_hidden("id", "$id"); - print_hidden("op", "pref-users"); - print_hidden("method", "editSave"); - - $sth = $this->pdo->prepare("SELECT * FROM ttrss_users WHERE id = ?"); + $sth = $this->pdo->prepare("SELECT id, login, access_level, email FROM ttrss_users WHERE id = ?"); $sth->execute([$id]); - if ($row = $sth->fetch()) { - - $login = $row["login"]; - $access_level = $row["access_level"]; - $email = $row["email"]; - - $sel_disabled = ($id == $_SESSION["uid"] || $login == "admin") ? "disabled" : ""; - - print "
".__("User")."
"; - print "
"; - - if ($sel_disabled) { - print_hidden("login", "$login"); - } - - print "
"; - print ""; - print ""; - print "
"; - - print "
"; - - print "
".__("Authentication")."
"; - print "
"; - - print "
"; - - print " "; - - if (!$sel_disabled) { - print_select_hash("access_level", $access_level, $access_level_names, - "dojoType=\"fox.form.Select\" $sel_disabled"); - } else { - print_select_hash("", $access_level, $access_level_names, - "dojoType=\"fox.form.Select\" $sel_disabled"); - print_hidden("access_level", "$access_level"); - } - - print "
"; - print "
"; - - print " "; - print ""; - - print "
"; - - print "
"; - - print "
".__("Options")."
"; - print "
"; - - print "
"; - print " "; - print ""; - print "
"; - - print "
"; - - print ""; - + if ($row = $sth->fetch(PDO::FETCH_ASSOC)) { + print json_encode([ + "user" => $row, + "access_level_names" => $access_level_names + ]); + } else { + print json_encode(["error" => "USER_NOT_FOUND"]); } - - print '
'; #tab - print "
"; - - print '
'; - print '
'; - - print "
- - -
"; - - print ""; - - return; } function userdetails() { @@ -186,6 +100,12 @@ class Pref_Users extends Handler_Administrative { $email = clean($_REQUEST["email"]); $password = clean($_REQUEST["password"]); + // no blank usernames + if (!$login) return; + + // forbid renaming admin + if ($uid == 1) $login = "admin"; + if ($password) { $salt = substr(bin2hex(get_random_bytes(125)), 0, 250); $pwd_hash = encrypt_password($password, $salt, true); -- cgit v1.2.3 From a2e688fcb2d463a5db700ebd013c783e3a8f4971 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sun, 14 Feb 2021 22:17:13 +0300 Subject: render headline-specific toolbar on the client --- classes/pref/feeds.php | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'classes/pref') diff --git a/classes/pref/feeds.php b/classes/pref/feeds.php index 6b5df0289..e225949f2 100755 --- a/classes/pref/feeds.php +++ b/classes/pref/feeds.php @@ -1358,14 +1358,12 @@ class Pref_Feeds extends Handler_Protected { } private function index_shared() { - $rss_url = htmlspecialchars(get_self_url_prefix() . - "/public.php?op=rss&id=-2&view-mode=all_articles"); ?>

@@ -1603,11 +1601,23 @@ class Pref_Feeds extends Handler_Protected { print json_encode(["link" => $new_key]); } - function getFeedKey() { + function getsharedurl() { $feed_id = clean($_REQUEST['id']); - $is_cat = clean($_REQUEST['is_cat']); + $is_cat = clean($_REQUEST['is_cat']) == "true"; + $search = clean($_REQUEST['search']); + + $link = get_self_url_prefix() . "/public.php?" . http_build_query([ + 'op' => 'rss', + 'id' => $feed_id, + 'is_cat' => (int)$is_cat, + 'q' => $search, + 'key' => Feeds::get_feed_access_key($feed_id, $is_cat, $_SESSION["uid"]) + ]); - print json_encode(["link" => Feeds::get_feed_access_key($feed_id, $is_cat, $_SESSION["uid"])]); + print json_encode([ + "title" => Feeds::getFeedTitle($feed_id, $is_cat), + "link" => $link + ]); } private function update_feed_access_key($feed_id, $is_cat, $owner_uid) { -- cgit v1.2.3 From 6b006a18e7efef814fa7a59102c85299acb0a0a4 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 15 Feb 2021 15:21:25 +0300 Subject: subscribe to feed: use client dialog --- classes/pref/feeds.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'classes/pref') diff --git a/classes/pref/feeds.php b/classes/pref/feeds.php index e225949f2..af3877159 100755 --- a/classes/pref/feeds.php +++ b/classes/pref/feeds.php @@ -1241,7 +1241,7 @@ class Pref_Feeds extends Handler_Protected {
-
-- cgit v1.2.3 From 020f062a76746a313fae9c82fbcf9b37fcc9d459 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 15 Feb 2021 15:43:07 +0300 Subject: feeds: unify naming --- classes/pref/feeds.php | 24 ++++++++++++------------ classes/pref/filters.php | 12 ++++++------ 2 files changed, 18 insertions(+), 18 deletions(-) (limited to 'classes/pref') diff --git a/classes/pref/feeds.php b/classes/pref/feeds.php index af3877159..edba71c5c 100755 --- a/classes/pref/feeds.php +++ b/classes/pref/feeds.php @@ -98,7 +98,7 @@ class Pref_Feeds extends Handler_Protected { $feed['checkbox'] = false; $feed['unread'] = -1; $feed['error'] = $feed_line['last_error']; - $feed['icon'] = Feeds::getFeedIcon($feed_line['id']); + $feed['icon'] = Feeds::_get_icon($feed_line['id']); $feed['param'] = TimeHelper::make_local_datetime( $feed_line['last_updated'], true); $feed['updates_disabled'] = (int)($feed_line['update_interval'] < 0); @@ -266,7 +266,7 @@ class Pref_Feeds extends Handler_Protected { $feed['name'] = $feed_line['title']; $feed['checkbox'] = false; $feed['error'] = $feed_line['last_error']; - $feed['icon'] = Feeds::getFeedIcon($feed_line['id']); + $feed['icon'] = Feeds::_get_icon($feed_line['id']); $feed['param'] = TimeHelper::make_local_datetime( $feed_line['last_updated'], true); $feed['unread'] = -1; @@ -301,7 +301,7 @@ class Pref_Feeds extends Handler_Protected { $feed['name'] = $feed_line['title']; $feed['checkbox'] = false; $feed['error'] = $feed_line['last_error']; - $feed['icon'] = Feeds::getFeedIcon($feed_line['id']); + $feed['icon'] = Feeds::_get_icon($feed_line['id']); $feed['param'] = TimeHelper::make_local_datetime( $feed_line['last_updated'], true); $feed['unread'] = -1; @@ -777,7 +777,7 @@ class Pref_Feeds extends Handler_Protected { /* Icon */ - print ""; + print ""; print "
@@ -1189,7 +1189,7 @@ class Pref_Feeds extends Handler_Protected { function addCat() { $feed_cat = clean($_REQUEST["cat"]); - Feeds::add_feed_category($feed_cat); + Feeds::_add_cat($feed_cat); } function importOpml() { @@ -1420,9 +1420,9 @@ class Pref_Feeds extends Handler_Protected { $obj['id'] = 'CAT:' . $cat_id; $obj['items'] = array(); - $obj['name'] = Feeds::getCategoryTitle($cat_id); + $obj['name'] = Feeds::_get_cat_title($cat_id); $obj['type'] = 'category'; - $obj['unread'] = -1; //(int) Feeds::getCategoryUnread($cat_id); + $obj['unread'] = -1; //(int) Feeds::_get_cat_unread($cat_id); $obj['bare_id'] = $cat_id; return $obj; @@ -1433,7 +1433,7 @@ class Pref_Feeds extends Handler_Protected { $feed_id = (int) $feed_id; if (!$title) - $title = Feeds::getFeedTitle($feed_id, false); + $title = Feeds::_get_title($feed_id, false); if ($unread === false) $unread = getFeedUnread($feed_id, false); @@ -1444,7 +1444,7 @@ class Pref_Feeds extends Handler_Protected { $obj['type'] = 'feed'; $obj['error'] = $error; $obj['updated'] = $updated; - $obj['icon'] = Feeds::getFeedIcon($feed_id); + $obj['icon'] = Feeds::_get_icon($feed_id); $obj['bare_id'] = $feed_id; $obj['auxcounter'] = 0; @@ -1611,11 +1611,11 @@ class Pref_Feeds extends Handler_Protected { 'id' => $feed_id, 'is_cat' => (int)$is_cat, 'q' => $search, - 'key' => Feeds::get_feed_access_key($feed_id, $is_cat, $_SESSION["uid"]) + 'key' => Feeds::_get_access_key($feed_id, $is_cat, $_SESSION["uid"]) ]); print json_encode([ - "title" => Feeds::getFeedTitle($feed_id, $is_cat), + "title" => Feeds::_get_title($feed_id, $is_cat), "link" => $link ]); } @@ -1627,7 +1627,7 @@ class Pref_Feeds extends Handler_Protected { WHERE feed_id = ? AND is_cat = ? AND owner_uid = ?"); $sth->execute([$feed_id, bool_to_sql_bool($is_cat), $owner_uid]); - return Feeds::get_feed_access_key($feed_id, $is_cat, $owner_uid); + return Feeds::_get_access_key($feed_id, $is_cat, $owner_uid); } // Silent diff --git a/classes/pref/filters.php b/classes/pref/filters.php index 1c264f642..62bcb8f59 100755 --- a/classes/pref/filters.php +++ b/classes/pref/filters.php @@ -189,10 +189,10 @@ class Pref_Filters extends Handler_Protected { if (strpos($feed_id, "CAT:") === 0) { $feed_id = (int)substr($feed_id, 4); - array_push($feeds_fmt, Feeds::getCategoryTitle($feed_id)); + array_push($feeds_fmt, Feeds::_get_cat_title($feed_id)); } else { if ($feed_id) - array_push($feeds_fmt, Feeds::getFeedTitle((int)$feed_id)); + array_push($feeds_fmt, Feeds::_get_title((int)$feed_id)); else array_push($feeds_fmt, __("All feeds")); } @@ -203,9 +203,9 @@ class Pref_Filters extends Handler_Protected { } else { $where = $line["cat_filter"] ? - Feeds::getCategoryTitle($line["cat_id"]) : + Feeds::_get_cat_title($line["cat_id"]) : ($line["feed_id"] ? - Feeds::getFeedTitle($line["feed_id"]) : __("All feeds")); + Feeds::_get_title($line["feed_id"]) : __("All feeds")); } # $where = $line["cat_id"] . "/" . $line["feed_id"]; @@ -494,10 +494,10 @@ class Pref_Filters extends Handler_Protected { if (strpos($feed_id, "CAT:") === 0) { $feed_id = (int)substr($feed_id, 4); - array_push($feeds_fmt, Feeds::getCategoryTitle($feed_id)); + array_push($feeds_fmt, Feeds::_get_cat_title($feed_id)); } else { if ($feed_id) - array_push($feeds_fmt, Feeds::getFeedTitle((int)$feed_id)); + array_push($feeds_fmt, Feeds::_get_title((int)$feed_id)); else array_push($feeds_fmt, __("All feeds")); } -- cgit v1.2.3 From 8e79f1717d5270558ffd30c20cc75840b0ecc955 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 15 Feb 2021 16:07:22 +0300 Subject: prefs: unify naming --- classes/pref/filters.php | 32 ++++++++++++++++---------------- classes/pref/prefs.php | 20 ++++++++++---------- classes/pref/system.php | 4 ++-- classes/pref/users.php | 8 ++++---- 4 files changed, 32 insertions(+), 32 deletions(-) (limited to 'classes/pref') diff --git a/classes/pref/filters.php b/classes/pref/filters.php index 62bcb8f59..95f0fcfc0 100755 --- a/classes/pref/filters.php +++ b/classes/pref/filters.php @@ -162,7 +162,7 @@ class Pref_Filters extends Handler_Protected { print json_encode($rv); } - private function getfilterrules_list($filter_id) { + private function _get_rules_list($filter_id) { $sth = $this->pdo->prepare("SELECT reg_exp, inverse, match_on, @@ -250,7 +250,7 @@ class Pref_Filters extends Handler_Protected { while ($line = $sth->fetch()) { - $name = $this->getFilterName($line["id"]); + $name = $this->_get_name($line["id"]); $match_ok = false; if ($filter_search) { @@ -292,7 +292,7 @@ class Pref_Filters extends Handler_Protected { $filter['checkbox'] = false; $filter['last_triggered'] = $line["last_triggered"] ? TimeHelper::make_local_datetime($line["last_triggered"], false) : null; $filter['enabled'] = sql_bool_to_bool($line["enabled"]); - $filter['rules'] = $this->getfilterrules_list($line['id']); + $filter['rules'] = $this->_get_rules_list($line['id']); if (!$filter_search || $match_ok) { array_push($folder['items'], $filter); @@ -391,7 +391,7 @@ class Pref_Filters extends Handler_Protected { $data = htmlspecialchars((string)json_encode($line)); print "
  • - ".$this->getRuleName($line)."". + ".$this->_get_rule_name($line)."". format_hidden("rule[]", $data)."
  • "; } } @@ -433,7 +433,7 @@ class Pref_Filters extends Handler_Protected { $data = htmlspecialchars((string)json_encode($line)); print "
  • - ".$this->getActionName($line)."". + ".$this->_get_action_name($line)."". format_hidden("action[]", $data)."
  • "; } } @@ -482,7 +482,7 @@ class Pref_Filters extends Handler_Protected { } } - private function getRuleName($rule) { + private function _get_rule_name($rule) { if (!$rule) $rule = json_decode(clean($_REQUEST["rule"]), true); $feeds = $rule["feed_id"]; @@ -523,10 +523,10 @@ class Pref_Filters extends Handler_Protected { } function printRuleName() { - print $this->getRuleName(json_decode(clean($_REQUEST["rule"]), true)); + print $this->_get_rule_name(json_decode(clean($_REQUEST["rule"]), true)); } - private function getActionName($action) { + private function _get_action_name($action) { $sth = $this->pdo->prepare("SELECT description FROM ttrss_filter_actions WHERE id = ?"); $sth->execute([(int)$action["action_id"]]); @@ -561,7 +561,7 @@ class Pref_Filters extends Handler_Protected { } function printActionName() { - print $this->getActionName(json_decode(clean($_REQUEST["action"]), true)); + print $this->_get_action_name(json_decode(clean($_REQUEST["action"]), true)); } function editSave() { @@ -581,7 +581,7 @@ class Pref_Filters extends Handler_Protected { $sth->execute([$enabled, $match_any_rule, $inverse, $title, $filter_id, $_SESSION['uid']]); - $this->saveRulesAndActions($filter_id); + $this->_save_rules_and_actions($filter_id); $this->pdo->commit(); } @@ -596,7 +596,7 @@ class Pref_Filters extends Handler_Protected { $sth->execute(array_merge($ids, [$_SESSION['uid']])); } - private function saveRulesAndActions($filter_id) + private function _save_rules_and_actions($filter_id) { $sth = $this->pdo->prepare("DELETE FROM ttrss_filters2_rules WHERE filter_id = ?"); @@ -696,7 +696,7 @@ class Pref_Filters extends Handler_Protected { if ($row = $sth->fetch()) { $filter_id = $row['id']; - $this->saveRulesAndActions($filter_id); + $this->_save_rules_and_actions($filter_id); } $this->pdo->commit(); @@ -941,7 +941,7 @@ class Pref_Filters extends Handler_Protected { print ""; } - private function getFilterName($id) { + private function _get_name($id) { $sth = $this->pdo->prepare( "SELECT title,match_any_rule,f.inverse AS inverse,COUNT(DISTINCT r.id) AS num_rules,COUNT(DISTINCT a.id) AS num_actions @@ -970,7 +970,7 @@ class Pref_Filters extends Handler_Protected { $actions = ""; if ($line = $sth->fetch()) { - $actions = $this->getActionName($line); + $actions = $this->_get_action_name($line); $num_actions -= 1; } @@ -1012,12 +1012,12 @@ class Pref_Filters extends Handler_Protected { $this->pdo->commit(); - $this->optimizeFilter($base_id); + $this->_optimize($base_id); } } - private function optimizeFilter($id) { + private function _optimize($id) { $this->pdo->beginTransaction(); diff --git a/classes/pref/prefs.php b/classes/pref/prefs.php index 6e4deb223..81b7767eb 100644 --- a/classes/pref/prefs.php +++ b/classes/pref/prefs.php @@ -268,7 +268,7 @@ class Pref_Prefs extends Handler_Protected { AND owner_uid = :uid"); $sth->execute([":profile" => $_SESSION['profile'], ":uid" => $_SESSION['uid']]); - $this->initialize_user_prefs($_SESSION["uid"], $_SESSION["profile"]); + $this->_init_user_prefs($_SESSION["uid"], $_SESSION["profile"]); echo __("Your preferences are now set to default values."); } @@ -588,9 +588,9 @@ class Pref_Prefs extends Handler_Protected { if ($profile) { print_notice(__("Some preferences are only available in default profile.")); - $this->initialize_user_prefs($_SESSION["uid"], $profile); + $this->_init_user_prefs($_SESSION["uid"], $profile); } else { - $this->initialize_user_prefs($_SESSION["uid"]); + $this->_init_user_prefs($_SESSION["uid"]); } $prefs_available = []; @@ -621,7 +621,7 @@ class Pref_Prefs extends Handler_Protected { } $pref_name = $line["pref_name"]; - $short_desc = $this->getShortDesc($pref_name); + $short_desc = $this->_get_short_desc($pref_name); if (!$short_desc) continue; @@ -629,7 +629,7 @@ class Pref_Prefs extends Handler_Protected { $prefs_available[$pref_name] = [ 'type_name' => $line["type_name"], 'value' => $line['value'], - 'help_text' => $this->getHelpText($pref_name), + 'help_text' => $this->_get_help_text($pref_name), 'short_desc' => $short_desc ]; } @@ -1318,14 +1318,14 @@ class Pref_Prefs extends Handler_Protected { } - private function getShortDesc($pref_name) { + private function _get_short_desc($pref_name) { if (isset($this->pref_help[$pref_name][0])) { return $this->pref_help[$pref_name][0]; } return ""; } - private function getHelpText($pref_name) { + private function _get_help_text($pref_name) { if (isset($this->pref_help[$pref_name][1])) { return $this->pref_help[$pref_name][1]; } @@ -1380,7 +1380,7 @@ class Pref_Prefs extends Handler_Protected { encryptAppPassword($new_password); + $new_password_hash = $this->_encrypt_app_password($new_password); print_warning(T_sprintf("Generated password %s for %s. Please remember it for future reference.", $new_password, $title)); @@ -1413,7 +1413,7 @@ class Pref_Prefs extends Handler_Protected { $this->appPasswordList(); } - static function initialize_user_prefs($uid, $profile = false) { + static function _init_user_prefs($uid, $profile = false) { if (get_schema_version() < 63) $profile_qpart = ""; diff --git a/classes/pref/system.php b/classes/pref/system.php index 2a97ec6f0..f0a5f7b7f 100644 --- a/classes/pref/system.php +++ b/classes/pref/system.php @@ -23,7 +23,7 @@ class Pref_System extends Handler_Administrative { print preg_replace( '%^.*(.*).*$%ms','$1', (string)$info); } - private function log_viewer(int $page, int $severity) { + private function _log_viewer(int $page, int $severity) { $errno_values = []; switch ($severity) { @@ -154,7 +154,7 @@ class Pref_System extends Handler_Administrative {
    '> log_viewer($page, $severity); + $this->_log_viewer($page, $severity); } else { print_notice("Please set LOG_DESTINATION to 'sql' in config.php to enable database logging."); } diff --git a/classes/pref/users.php b/classes/pref/users.php index bc125d0ce..d2dd06fd8 100644 --- a/classes/pref/users.php +++ b/classes/pref/users.php @@ -166,7 +166,7 @@ class Pref_Users extends Handler_Administrative { } } - static function resetUserPassword($uid, $format_output = false) { + static function _reset_password($uid, $format_output = false) { $pdo = Db::pdo(); @@ -199,7 +199,7 @@ class Pref_Users extends Handler_Administrative { function resetPass() { $uid = clean($_REQUEST["id"]); - self::resetUserPassword($uid); + self::_reset_password($uid); } function index() { @@ -220,7 +220,7 @@ class Pref_Users extends Handler_Administrative { $sort = "login"; } - $sort = $this->validate_field($sort, + $sort = $this->_validate_field($sort, ["login", "access_level", "created", "num_feeds", "created", "last_login"], "login"); if ($sort != "login") $sort = "$sort DESC"; @@ -314,7 +314,7 @@ class Pref_Users extends Handler_Administrative { Date: Mon, 15 Feb 2021 16:34:44 +0300 Subject: router: add additional logging for refused requests; reject requests for methods starting with _ --- classes/pref/feeds.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'classes/pref') diff --git a/classes/pref/feeds.php b/classes/pref/feeds.php index edba71c5c..4c865e9f0 100755 --- a/classes/pref/feeds.php +++ b/classes/pref/feeds.php @@ -109,6 +109,10 @@ class Pref_Feeds extends Handler_Protected { return $items; } + function _getfeedtree() { + print "OK"; + } + function getfeedtree() { print json_encode($this->makefeedtree()); } -- cgit v1.2.3 From bd3c38de849330b3ed28df05c1220c631c103628 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 15 Feb 2021 16:41:52 +0300 Subject: move bookmarklet-related subscribe_to_feed_url to bookmarklet plugin --- classes/pref/feeds.php | 6 ------ 1 file changed, 6 deletions(-) (limited to 'classes/pref') diff --git a/classes/pref/feeds.php b/classes/pref/feeds.php index 4c865e9f0..cb6ff94fc 100755 --- a/classes/pref/feeds.php +++ b/classes/pref/feeds.php @@ -1655,10 +1655,4 @@ class Pref_Feeds extends Handler_Protected { return $c; } - static function subscribe_to_feed_url() { - $url_path = get_self_url_prefix() . - "/public.php?op=subscribe&feed_url=%s"; - return $url_path; - } - } -- cgit v1.2.3 From 39604bedef15b7d56c23ce101d5e74a93bc5620c Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 15 Feb 2021 16:59:54 +0300 Subject: move reset_password to UserHelper --- classes/pref/users.php | 34 +--------------------------------- 1 file changed, 1 insertion(+), 33 deletions(-) (limited to 'classes/pref') diff --git a/classes/pref/users.php b/classes/pref/users.php index d2dd06fd8..ab1694564 100644 --- a/classes/pref/users.php +++ b/classes/pref/users.php @@ -166,40 +166,8 @@ class Pref_Users extends Handler_Administrative { } } - static function _reset_password($uid, $format_output = false) { - - $pdo = Db::pdo(); - - $sth = $pdo->prepare("SELECT login FROM ttrss_users WHERE id = ?"); - $sth->execute([$uid]); - - if ($row = $sth->fetch()) { - - $login = $row["login"]; - - $new_salt = substr(bin2hex(get_random_bytes(125)), 0, 250); - $tmp_user_pwd = make_password(); - - $pwd_hash = encrypt_password($tmp_user_pwd, $new_salt, true); - - $sth = $pdo->prepare("UPDATE ttrss_users - SET pwd_hash = ?, salt = ?, otp_enabled = false - WHERE id = ?"); - $sth->execute([$pwd_hash, $new_salt, $uid]); - - $message = T_sprintf("Changed password of user %s to %s", "$login", "$tmp_user_pwd"); - - if ($format_output) - print_notice($message); - else - print $message; - - } - } - function resetPass() { - $uid = clean($_REQUEST["id"]); - self::_reset_password($uid); + UserHelper::reset_password(clean($_REQUEST["id"])); } function index() { -- cgit v1.2.3 From 70e293bccbdba7827680c0499cb315ec3f613627 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 15 Feb 2021 17:07:50 +0300 Subject: pref-filters: fix some warnings --- classes/pref/filters.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'classes/pref') diff --git a/classes/pref/filters.php b/classes/pref/filters.php index 95f0fcfc0..930a4eeac 100755 --- a/classes/pref/filters.php +++ b/classes/pref/filters.php @@ -567,7 +567,7 @@ class Pref_Filters extends Handler_Protected { function editSave() { $filter_id = clean($_REQUEST["id"]); $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"] ?? false)); $inverse = checkbox_to_sql_bool(clean($_REQUEST["inverse"] ?? false)); $title = clean($_REQUEST["title"]); @@ -675,10 +675,10 @@ class Pref_Filters extends Handler_Protected { } function add() { - $enabled = checkbox_to_sql_bool(clean($_REQUEST["enabled"])); - $match_any_rule = checkbox_to_sql_bool(clean($_REQUEST["match_any_rule"])); + $enabled = checkbox_to_sql_bool(clean($_REQUEST["enabled"] ?? false)); + $match_any_rule = checkbox_to_sql_bool(clean($_REQUEST["match_any_rule"] ?? false)); $title = clean($_REQUEST["title"]); - $inverse = checkbox_to_sql_bool(clean($_REQUEST["inverse"])); + $inverse = checkbox_to_sql_bool(clean($_REQUEST["inverse"] ?? false)); $this->pdo->beginTransaction(); -- cgit v1.2.3 From cb6b3584ce6160b69ee03f1a31660a430cb06854 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 16 Feb 2021 14:19:06 +0300 Subject: pref-labels: remove unused code --- classes/pref/labels.php | 14 -------------- 1 file changed, 14 deletions(-) (limited to 'classes/pref') diff --git a/classes/pref/labels.php b/classes/pref/labels.php index d182a0995..0b826e13f 100644 --- a/classes/pref/labels.php +++ b/classes/pref/labels.php @@ -167,26 +167,12 @@ class Pref_Labels extends Handler_Protected { $output = clean($_REQUEST["output"]); if ($caption) { - if (Labels::create($caption)) { if (!$output) { print T_sprintf("Created label %s", htmlspecialchars($caption)); } } - - if ($output == "select") { - header("Content-Type: text/xml"); - - print ""; - - print_label_select("select_label", - $caption, ""); - - print ""; - } } - - return; } function index() { -- cgit v1.2.3 From 26d6b84a572b5cbd99acffc5ae727ea6d1be543a Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 16 Feb 2021 14:23:00 +0300 Subject: add namespaced controls with unified naming; deprecated old-style control shortcuts --- classes/pref/feeds.php | 27 +++++++++------------------ classes/pref/filters.php | 21 ++++++++++++--------- classes/pref/prefs.php | 41 ++++++++++++++++++++--------------------- classes/pref/system.php | 4 ++-- 4 files changed, 43 insertions(+), 50 deletions(-) (limited to 'classes/pref') diff --git a/classes/pref/feeds.php b/classes/pref/feeds.php index cb6ff94fc..d97081293 100755 --- a/classes/pref/feeds.php +++ b/classes/pref/feeds.php @@ -563,15 +563,11 @@ class Pref_Feeds extends Handler_Protected { /* Category */ if (get_pref('ENABLE_FEED_CATS')) { - - $cat_id = $row["cat_id"]; - print "
    "; print " "; - print_feed_cat_select("cat_id", $cat_id, - 'dojoType="fox.form.Select"'); + print \Controls\select_feeds_cats("cat_id", $row["cat_id"]); print "
    "; } @@ -601,8 +597,7 @@ class Pref_Feeds extends Handler_Protected { print "
    "; print " "; - print_select("feed_language", $feed_language, $this::get_ts_languages(), - 'dojoType="fox.form.Select"'); + print \Controls\select_tag("feed_language", $feed_language, $this::get_ts_languages()); print "
    "; } @@ -623,8 +618,7 @@ class Pref_Feeds extends Handler_Protected { $local_update_intervals = $update_intervals; $local_update_intervals[0] .= sprintf(" (%s)", $update_intervals[get_pref("DEFAULT_UPDATE_INTERVAL")]); - print_select_hash("update_interval", $update_interval, $local_update_intervals, - 'dojoType="fox.form.Select"'); + print \Controls\select_hash("update_interval", $update_interval, $local_update_intervals); print ""; @@ -650,8 +644,7 @@ class Pref_Feeds extends Handler_Protected { $local_purge_intervals = [ T_nsprintf('%d day', '%d days', $purge_interval, $purge_interval) ]; } - print_select_hash("purge_interval", $purge_interval, $local_purge_intervals, - 'dojoType="fox.form.Select" ' . + print \Controls\select_hash("purge_interval", $purge_interval, $local_purge_intervals, ((FORCE_ARTICLE_PURGE == 0) ? "" : 'disabled="1"')); print ""; @@ -857,8 +850,8 @@ class Pref_Feeds extends Handler_Protected { print "
    "; print " "; - print_select("feed_language", "", $this::get_ts_languages(), - 'disabled="1" dojoType="fox.form.Select"'); + print \Controls\select_tag("feed_language", "", $this::get_ts_languages(), + 'disabled="1"'); $this->batch_edit_cbox("feed_language"); @@ -879,8 +872,7 @@ class Pref_Feeds extends Handler_Protected { $local_update_intervals = $update_intervals; $local_update_intervals[0] .= sprintf(" (%s)", $update_intervals[get_pref("DEFAULT_UPDATE_INTERVAL")]); - print_select_hash("update_interval", "", $local_update_intervals, - 'disabled="1" dojoType="fox.form.Select"'); + print \Controls\select_hash("update_interval", "", $local_update_intervals, 'disabled="1"'); $this->batch_edit_cbox("update_interval"); @@ -902,8 +894,7 @@ class Pref_Feeds extends Handler_Protected { else $local_purge_intervals[0] .= " " . sprintf("(%s)", __("Disabled")); - print_select_hash("purge_interval", "", $local_purge_intervals, - 'disabled="1" dojoType="fox.form.Select"'); + print \Controls\select_hash("purge_interval", "", $local_purge_intervals, 'disabled="1"'); $this->batch_edit_cbox("purge_interval"); @@ -1550,7 +1541,7 @@ class Pref_Feeds extends Handler_Protected { function batchSubscribe() { print json_encode([ "enable_cats" => (int)get_pref('ENABLE_FEED_CATS'), - "cat_select" => format_feed_cat_select("cat", false, 'dojoType="fox.form.Select"') + "cat_select" => \Controls\select_feeds_cats("cat") ]); } diff --git a/classes/pref/filters.php b/classes/pref/filters.php index 930a4eeac..23275a1d6 100755 --- a/classes/pref/filters.php +++ b/classes/pref/filters.php @@ -392,7 +392,7 @@ class Pref_Filters extends Handler_Protected { print "
  • ".$this->_get_rule_name($line)."". - format_hidden("rule[]", $data)."
  • "; + \Controls\hidden_tag("rule[]", $data).""; } } @@ -434,7 +434,7 @@ class Pref_Filters extends Handler_Protected { print "
  • ".$this->_get_action_name($line)."". - format_hidden("action[]", $data)."
  • "; + \Controls\hidden_tag("action[]", $data).""; } } @@ -815,8 +815,7 @@ class Pref_Filters extends Handler_Protected { print "
    "; print " "; - print_select_hash("filter_type", $filter_type, $filter_types, - 'dojoType="fox.form.Select"'); + print \Controls\select_hash("filter_type", $filter_type, $filter_types); print " "; print "
    "; @@ -894,9 +893,13 @@ class Pref_Filters extends Handler_Protected { id='filterDlg_actionParam' style=\"$param_hidden\" name='action_param' value=\"$action_param\">"; - print_label_select("action_param_label", $action_param, + /*print_label_select("action_param_label", $action_param, "id='filterDlg_actionParamLabel' style=\"$label_param_hidden\" - dojoType='fox.form.Select'"); + dojoType='fox.form.Select'");*/ + + print \Controls\select_labels("action_param_label", $action_param, + "style=\"$label_param_hidden\"", + "filterDlg_actionParamLabel"); $filter_actions = PluginHost::getInstance()->get_filter_actions(); $filter_action_hash = array(); @@ -918,9 +921,9 @@ class Pref_Filters extends Handler_Protected { $filter_plugin_disabled = ""; } - print_select_hash("filterDlg_actionParamPlugin", $action_param, $filter_action_hash, - "style=\"$plugin_param_hidden\" dojoType='fox.form.Select' $filter_plugin_disabled", - "action_param_plugin"); + print \Controls\select_hash("action_param_plugin", $action_param, $filter_action_hash, + "style=\"$plugin_param_hidden\" $filter_plugin_disabled", + "filterDlg_actionParamPlugin"); print ""; diff --git a/classes/pref/prefs.php b/classes/pref/prefs.php index 81b7767eb..d8491995d 100644 --- a/classes/pref/prefs.php +++ b/classes/pref/prefs.php @@ -288,8 +288,8 @@ class Pref_Prefs extends Handler_Protected { ?>
    - - + + - - + +
    diff --git a/classes/pref/system.php b/classes/pref/system.php index f0a5f7b7f..d3b733364 100644 --- a/classes/pref/system.php +++ b/classes/pref/system.php @@ -90,12 +90,12 @@ class Pref_System extends Handler_Administrative {
    - __("Errors"), E_USER_WARNING => __("Warnings"), E_USER_NOTICE => __("Everything") - ], 'dojoType="fox.form.Select" onchange="Helpers.EventLog.refresh()"') ?> + ], 'onchange="Helpers.EventLog.refresh()"', "severity") ?>
    -- cgit v1.2.3 From 1f43d7916cda16e9680b9087bda1f52934e8f25b Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 16 Feb 2021 14:32:06 +0300 Subject: replace print_hidden with hidden_tag --- classes/pref/feeds.php | 12 ++++++------ classes/pref/filters.php | 10 +++++----- 2 files changed, 11 insertions(+), 11 deletions(-) (limited to 'classes/pref') diff --git a/classes/pref/feeds.php b/classes/pref/feeds.php index d97081293..d087d026d 100755 --- a/classes/pref/feeds.php +++ b/classes/pref/feeds.php @@ -524,9 +524,9 @@ class Pref_Feeds extends Handler_Protected { $title = htmlspecialchars($row["title"]); - print_hidden("id", "$feed_id"); - print_hidden("op", "pref-feeds"); - print_hidden("method", "editSave"); + print \Controls\hidden_tag("id", "$feed_id"); + print \Controls\hidden_tag("op", "pref-feeds"); + print \Controls\hidden_tag("method", "editSave"); print "
    ".__("Feed")."
    "; print "
    "; @@ -821,9 +821,9 @@ class Pref_Feeds extends Handler_Protected { print "

    "; - print_hidden("ids", "$feed_ids"); - print_hidden("op", "pref-feeds"); - print_hidden("method", "batchEditSave"); + print \Controls\hidden_tag("ids", "$feed_ids"); + print \Controls\hidden_tag("op", "pref-feeds"); + print \Controls\hidden_tag("method", "batchEditSave"); print "

    ".__("Feed")."
    "; print "
    "; diff --git a/classes/pref/filters.php b/classes/pref/filters.php index 23275a1d6..9b740753a 100755 --- a/classes/pref/filters.php +++ b/classes/pref/filters.php @@ -327,16 +327,16 @@ class Pref_Filters extends Handler_Protected { print ""; - print_hidden("op", "pref-filters"); + print \Controls\hidden_tag("op", "pref-filters"); if ($filter_id) { - print_hidden("id", "$filter_id"); - print_hidden("method", "editSave"); + print \Controls\hidden_tag("id", "$filter_id"); + print \Controls\hidden_tag("method", "editSave"); } else { - print_hidden("method", "add"); + print \Controls\hidden_tag("method", "add"); } - print_hidden("csrf_token", $_SESSION['csrf_token']); + print \Controls\hidden_tag("csrf_token", $_SESSION['csrf_token']); print "
    ".__("Caption")."
    -- cgit v1.2.3 From 1f5d81b77cd9a5d5f965af0435688c1f1f229e96 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 16 Feb 2021 15:19:42 +0300 Subject: use a few more control helpers for checkboxes --- classes/pref/feeds.php | 6 +----- classes/pref/filters.php | 10 +++++----- 2 files changed, 6 insertions(+), 10 deletions(-) (limited to 'classes/pref') diff --git a/classes/pref/feeds.php b/classes/pref/feeds.php index d087d026d..636f2d69b 100755 --- a/classes/pref/feeds.php +++ b/classes/pref/feeds.php @@ -663,7 +663,7 @@ class Pref_Feeds extends Handler_Protected { print "
    "; - print ""; @@ -675,10 +675,6 @@ class Pref_Feeds extends Handler_Protected { placeHolder='".__("Password")."' value=\"$auth_pass\">"; - print "
    - ".__('Hint: you need to fill in your login information if your feed requires authentication, except for Twitter feeds.')." -
    "; - print "
    "; print "
    "; diff --git a/classes/pref/filters.php b/classes/pref/filters.php index 9b740753a..36357234b 100755 --- a/classes/pref/filters.php +++ b/classes/pref/filters.php @@ -775,12 +775,12 @@ class Pref_Filters extends Handler_Protected { $reg_exp = htmlspecialchars($rule["reg_exp"]); $filter_type = $rule["filter_type"]; $feed_id = $rule["feed_id"]; - $inverse_checked = isset($rule["inverse"]) ? "checked" : ""; + $inverse_checked = !empty($rule["inverse"]); } else { $reg_exp = ""; $filter_type = 1; $feed_id = ["0"]; - $inverse_checked = ""; + $inverse_checked = false; } print ""; @@ -808,9 +808,9 @@ class Pref_Filters extends Handler_Protected { print "
    "; print "
    "; - print ""; + print ""; print "
    "; print "
    "; -- cgit v1.2.3 From 627af2c236bf4a370a5d31641757b69d679513f6 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 16 Feb 2021 15:36:40 +0300 Subject: amend previous to fix actual underlying problem (double escaping) --- classes/pref/filters.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'classes/pref') diff --git a/classes/pref/filters.php b/classes/pref/filters.php index 36357234b..caefb1ea7 100755 --- a/classes/pref/filters.php +++ b/classes/pref/filters.php @@ -388,11 +388,9 @@ class Pref_Filters extends Handler_Protected { if (!$line["inverse"]) unset($line["inverse"]); unset($line["match_on"]); - $data = htmlspecialchars((string)json_encode($line)); - print "
  • ".$this->_get_rule_name($line)."". - \Controls\hidden_tag("rule[]", $data)."
  • "; + \Controls\hidden_tag("rule[]", (string)json_encode($line)).""; } } @@ -430,11 +428,9 @@ class Pref_Filters extends Handler_Protected { unset($line["filter_id"]); unset($line["id"]); - $data = htmlspecialchars((string)json_encode($line)); - print "
  • ".$this->_get_action_name($line)."". - \Controls\hidden_tag("action[]", $data)."
  • "; + \Controls\hidden_tag("action[]", (string)json_encode($line)).""; } } -- cgit v1.2.3 From bdbbdbb0eddd125bec167da5f42bbd95c770151f Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 16 Feb 2021 16:59:21 +0300 Subject: rework controls to accept parameters as array --- classes/pref/feeds.php | 15 +++++++-------- classes/pref/filters.php | 8 ++++---- classes/pref/prefs.php | 4 ++-- classes/pref/system.php | 2 +- 4 files changed, 14 insertions(+), 15 deletions(-) (limited to 'classes/pref') diff --git a/classes/pref/feeds.php b/classes/pref/feeds.php index 636f2d69b..ce2d321bd 100755 --- a/classes/pref/feeds.php +++ b/classes/pref/feeds.php @@ -644,8 +644,10 @@ class Pref_Feeds extends Handler_Protected { $local_purge_intervals = [ T_nsprintf('%d day', '%d days', $purge_interval, $purge_interval) ]; } - print \Controls\select_hash("purge_interval", $purge_interval, $local_purge_intervals, - ((FORCE_ARTICLE_PURGE == 0) ? "" : 'disabled="1"')); + print \Controls\select_hash("purge_interval", + $purge_interval, + $local_purge_intervals, + (FORCE_ARTICLE_PURGE == 0) ? [] : ["disabled" => 1]); print "
    "; @@ -815,8 +817,6 @@ class Pref_Feeds extends Handler_Protected { print_notice("Enable the options you wish to apply using checkboxes on the right:"); - print "

    "; - print \Controls\hidden_tag("ids", "$feed_ids"); print \Controls\hidden_tag("op", "pref-feeds"); print \Controls\hidden_tag("method", "batchEditSave"); @@ -846,8 +846,7 @@ class Pref_Feeds extends Handler_Protected { print "

    "; print " "; - print \Controls\select_tag("feed_language", "", $this::get_ts_languages(), - 'disabled="1"'); + print \Controls\select_tag("feed_language", "", $this::get_ts_languages(), ["disabled"=> 1]); $this->batch_edit_cbox("feed_language"); @@ -868,7 +867,7 @@ class Pref_Feeds extends Handler_Protected { $local_update_intervals = $update_intervals; $local_update_intervals[0] .= sprintf(" (%s)", $update_intervals[get_pref("DEFAULT_UPDATE_INTERVAL")]); - print \Controls\select_hash("update_interval", "", $local_update_intervals, 'disabled="1"'); + print \Controls\select_hash("update_interval", "", $local_update_intervals, ["disabled" => 1]); $this->batch_edit_cbox("update_interval"); @@ -890,7 +889,7 @@ class Pref_Feeds extends Handler_Protected { else $local_purge_intervals[0] .= " " . sprintf("(%s)", __("Disabled")); - print \Controls\select_hash("purge_interval", "", $local_purge_intervals, 'disabled="1"'); + print \Controls\select_hash("purge_interval", "", $local_purge_intervals, ["disabled" => 1]); $this->batch_edit_cbox("purge_interval"); diff --git a/classes/pref/filters.php b/classes/pref/filters.php index caefb1ea7..e9c58cc3e 100755 --- a/classes/pref/filters.php +++ b/classes/pref/filters.php @@ -894,7 +894,7 @@ class Pref_Filters extends Handler_Protected { dojoType='fox.form.Select'");*/ print \Controls\select_labels("action_param_label", $action_param, - "style=\"$label_param_hidden\"", + ["style" => $label_param_hidden], "filterDlg_actionParamLabel"); $filter_actions = PluginHost::getInstance()->get_filter_actions(); @@ -909,16 +909,16 @@ class Pref_Filters extends Handler_Protected { } if (count($filter_action_hash) == 0) { - $filter_plugin_disabled = "disabled"; + $filter_plugin_disabled = ["disabled" => "1"]; $filter_action_hash["no-data"] = __("No actions available"); } else { - $filter_plugin_disabled = ""; + $filter_plugin_disabled = []; } print \Controls\select_hash("action_param_plugin", $action_param, $filter_action_hash, - "style=\"$plugin_param_hidden\" $filter_plugin_disabled", + array_merge(["style" => $plugin_param_hidden], $filter_plugin_disabled), "filterDlg_actionParamPlugin"); print ""; diff --git a/classes/pref/prefs.php b/classes/pref/prefs.php index d8491995d..3bc8a9a9c 100644 --- a/classes/pref/prefs.php +++ b/classes/pref/prefs.php @@ -664,13 +664,13 @@ class Pref_Prefs extends Handler_Protected { if ($pref_name == "USER_LANGUAGE") { print \Controls\select_hash($pref_name, $value, get_translations(), - "style='width : 220px; margin : 0px'"); + ["style" => 'width : 220px; margin : 0px']); } else if ($pref_name == "USER_TIMEZONE") { $timezones = explode("\n", file_get_contents("lib/timezones.txt")); - print \Controls\select_tag($pref_name, $value, $timezones, 'dojoType="dijit.form.FilteringSelect"'); + print \Controls\select_tag($pref_name, $value, $timezones, ["dojoType" => "dijit.form.FilteringSelect"]); } else if ($pref_name == "BLACKLISTED_TAGS") { # TODO: other possible "; - - print "
    "; - - print "
    "; - print ""; - print "
    "; - - print "
    "; - print " "; - print \Controls\select_hash("filter_type", $filter_type, $filter_types); - print " "; - - print "
    "; - - print "
    "; - print ""; - print $this->feed_multi_select("feed_id", - $feed_id, - 'style="width : 500px; height : 300px" dojoType="dijit.form.MultiSelect"'); - print ""; - - print "
    "; - - print ""; - - print "
    "; - - print ""; - - print " "; - - print ""; - - print "
    "; - - print "";*/ - } - - function newaction() { - $action = json_decode(clean($_REQUEST["action"]), true); - - if ($action) { - $action_param = $action["action_param"]; - $action_id = (int)$action["action_id"]; - } else { - $action_param = ""; - $action_id = 0; - } - - print "
    "; - - print "
    ".__("Perform Action")."
    "; - - print "
    "; - - print ""; - - #$param_box_hidden = ($action_id == 7 || $action_id == 4 || $action_id == 6 || $action_id == 9) ? - # "" : "display : none"; - - #$param_hidden = ($action_id == 4 || $action_id == 6) ? - # "" : "display : none"; - - #$label_param_hidden = ($action_id == 7) ? "" : "display : none"; - #$plugin_param_hidden = ($action_id == 9) ? "" : "display : none"; - - #print ""; - #print " "; - //print " " . __("with parameters:") . " "; - print ""; - - print \Controls\select_labels("action_param_label", $action_param, - ["style" => $label_param_hidden], - "filterDlg_actionParamLabel"); - - $filter_actions = PluginHost::getInstance()->get_filter_actions(); - $filter_action_hash = array(); - - foreach ($filter_actions as $fclass => $factions) { - foreach ($factions as $faction) { - - $filter_action_hash[$fclass . ":" . $faction["action"]] = - $fclass . ": " . $faction["description"]; - } - } - - if (count($filter_action_hash) == 0) { - $filter_plugin_disabled = ["disabled" => "1"]; - - $filter_action_hash["no-data"] = __("No actions available"); - - } else { - $filter_plugin_disabled = []; - } - - print \Controls\select_hash("action_param_plugin", $action_param, $filter_action_hash, - array_merge(["style" => $plugin_param_hidden], $filter_plugin_disabled), - "filterDlg_actionParamPlugin"); - - #print ""; - - print " "; // tiny layout hack - - print "
    "; - - print "
    "; - - print " "; - - print ""; - - print "
    "; - - print "
    "; } private function _get_name($id) { @@ -1152,7 +830,7 @@ class Pref_Filters extends Handler_Protected { $this->pdo->commit(); } - private function feed_multi_select($id, $default_ids = [], + private function _feed_multi_select($id, $default_ids = [], $attributes = "", $include_all_feeds = true, $root_id = null, $nest_level = 0) { @@ -1194,7 +872,7 @@ class Pref_Filters extends Handler_Protected { $line["id"], htmlspecialchars($line["title"])); if ($line["num_children"] > 0) - $rv .= $this->feed_multi_select($id, $default_ids, $attributes, + $rv .= $this->_feed_multi_select($id, $default_ids, $attributes, $include_all_feeds, $line["id"], $nest_level+1); $f_sth = $pdo->prepare("SELECT id,title FROM ttrss_feeds -- cgit v1.2.3 From 810afdaf5a429468d31b09ae5a7f995dd11568f8 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sun, 21 Feb 2021 12:28:25 +0300 Subject: prevent creation of filter rules matching no feeds --- classes/pref/filters.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'classes/pref') diff --git a/classes/pref/filters.php b/classes/pref/filters.php index c00e52bde..9388cc8d7 100755 --- a/classes/pref/filters.php +++ b/classes/pref/filters.php @@ -695,7 +695,7 @@ class Pref_Filters extends Handler_Protected { $feed_ids = explode(",", clean($_REQUEST["ids"])); print json_encode([ - "multiselect" => $this->_feed_multi_select("feed_id", $feed_ids, 'style="width : 540px; height : 300px" dojoType="dijit.form.MultiSelect"') + "multiselect" => $this->_feed_multi_select("feed_id", $feed_ids, 'required="1" style="width : 540px; height : 300px" dojoType="fox.form.ValidationMultiSelect"') ]); } -- cgit v1.2.3 From 2843b9917133e5ed8e1adf4ffd12356459fc16e4 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sun, 21 Feb 2021 13:08:34 +0300 Subject: minor filter UI layout fix --- classes/pref/filters.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'classes/pref') diff --git a/classes/pref/filters.php b/classes/pref/filters.php index 9388cc8d7..fda4a6513 100755 --- a/classes/pref/filters.php +++ b/classes/pref/filters.php @@ -695,7 +695,7 @@ class Pref_Filters extends Handler_Protected { $feed_ids = explode(",", clean($_REQUEST["ids"])); print json_encode([ - "multiselect" => $this->_feed_multi_select("feed_id", $feed_ids, 'required="1" style="width : 540px; height : 300px" dojoType="fox.form.ValidationMultiSelect"') + "multiselect" => $this->_feed_multi_select("feed_id", $feed_ids, 'required="1" style="width : 100%; height : 300px" dojoType="fox.form.ValidationMultiSelect"') ]); } -- cgit v1.2.3 From d1328321bebadcf8a530d3c05f52a8f3c58bb969 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sun, 21 Feb 2021 15:16:39 +0300 Subject: move published OPML endpoint to public.php --- classes/pref/feeds.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'classes/pref') diff --git a/classes/pref/feeds.php b/classes/pref/feeds.php index cf9e7c95e..8d3f84a03 100755 --- a/classes/pref/feeds.php +++ b/classes/pref/feeds.php @@ -1329,14 +1329,14 @@ class Pref_Feeds extends Handler_Protected { } function getOPMLKey() { - print json_encode(["link" => OPML::opml_publish_url()]); + print json_encode(["link" => OPML::get_publish_url()]); } function regenOPMLKey() { $this->update_feed_access_key('OPML:Publish', false, $_SESSION["uid"]); - print json_encode(["link" => OPML::opml_publish_url()]); + print json_encode(["link" => OPML::get_publish_url()]); } function regenFeedKey() { -- cgit v1.2.3 From 521d0b65c73f90d6e86c1a38dcab492b5a23982b Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sun, 21 Feb 2021 16:02:57 +0300 Subject: batch feed editor: use tab layout, cleanup --- classes/pref/feeds.php | 243 +++++++++++++++++++------------------------------ 1 file changed, 95 insertions(+), 148 deletions(-) (limited to 'classes/pref') diff --git a/classes/pref/feeds.php b/classes/pref/feeds.php index 8d3f84a03..c901bc96e 100755 --- a/classes/pref/feeds.php +++ b/classes/pref/feeds.php @@ -22,11 +22,6 @@ class Pref_Feeds extends Handler_Protected { return $rv; } - function batch_edit_cbox($elem, $label = false) { - print ""; - } - function renamecat() { $title = clean($_REQUEST['title']); $id = clean($_REQUEST['id']); @@ -571,165 +566,117 @@ class Pref_Feeds extends Handler_Protected { } } + private function _batch_toggle_checkbox($name) { + return \Controls\checkbox_tag("", false, "", + ["data-control-for" => $name, "title" => __("Check to enable field"), "onchange" => "App.dialogOf(this).toggleField(this)"]); + } + function editfeeds() { global $purge_intervals; global $update_intervals; $feed_ids = clean($_REQUEST["ids"]); - print_notice("Enable the options you wish to apply using checkboxes on the right:"); - - print \Controls\hidden_tag("ids", "$feed_ids"); - print \Controls\hidden_tag("op", "pref-feeds"); - print \Controls\hidden_tag("method", "batchEditSave"); - - print "
    ".__("Feed")."
    "; - print "
    "; - - /* Category */ - - if (get_pref('ENABLE_FEED_CATS')) { - - print "
    "; - - print " "; - - print \Controls\select_feeds_cats("cat_id", null, ['disabled' => '1']); - - $this->batch_edit_cbox("cat_id"); - - print "
    "; - } - - /* FTS Stemming Language */ - - if (DB_TYPE == "pgsql") { - print "
    "; - - print " "; - print \Controls\select_tag("feed_language", "", $this::get_ts_languages(), ["disabled"=> 1]); - - $this->batch_edit_cbox("feed_language"); - - print "
    "; - } - - print "
    "; - - print "
    ".__("Update")."
    "; - print "
    "; - - /* Update Interval */ - - print "
    "; - - print " "; - $local_update_intervals = $update_intervals; $local_update_intervals[0] .= sprintf(" (%s)", $update_intervals[get_pref("DEFAULT_UPDATE_INTERVAL")]); - print \Controls\select_hash("update_interval", "", $local_update_intervals, ["disabled" => 1]); - - $this->batch_edit_cbox("update_interval"); - - print "
    "; - - /* Purge intl */ - - if (FORCE_ARTICLE_PURGE == 0) { - - print "
    "; - - print " "; - - $local_purge_intervals = $purge_intervals; - $default_purge_interval = get_pref("PURGE_OLD_DAYS"); - - if ($default_purge_interval > 0) - $local_purge_intervals[0] .= " " . T_sprintf("(%d days)", $default_purge_interval); - else - $local_purge_intervals[0] .= " " . sprintf("(%s)", __("Disabled")); + $local_purge_intervals = $purge_intervals; + $default_purge_interval = get_pref("PURGE_OLD_DAYS"); - print \Controls\select_hash("purge_interval", "", $local_purge_intervals, ["disabled" => 1]); - - $this->batch_edit_cbox("purge_interval"); - - print "
    "; - } - - print "
    "; - print "
    ".__("Authentication")."
    "; - print "
    "; - - print "
    "; - - print ""; - - $this->batch_edit_cbox("auth_login"); - - print ""; - - $this->batch_edit_cbox("auth_pass"); - - print "
    "; - - print "
    "; - print "
    ".__("Options")."
    "; - print "
    "; - - print "
    "; - print ""; - - print " "; $this->batch_edit_cbox("include_in_digest", "include_in_digest_l"); - - print "
    "; - - print ""; - - print " "; $this->batch_edit_cbox("always_display_enclosures", "always_display_enclosures_l"); - - print "
    "; - - print ""; - - print " "; $this->batch_edit_cbox("hide_images", "hide_images_l"); - - print "
    "; - - print ""; - - print " "; $this->batch_edit_cbox("cache_images", "cache_images_l"); - - print "
    "; + if ($default_purge_interval > 0) + $local_purge_intervals[0] .= " " . T_sprintf("(%d days)", $default_purge_interval); + else + $local_purge_intervals[0] .= " " . sprintf("(%s)", __("Disabled")); - print ""; + $options = [ + "include_in_digest" => __('Include in e-mail digest'), + "always_display_enclosures" => __('Always display image attachments'), + "hide_images" => __('Do not embed media'), + "cache_images" => __('Cache media'), + "mark_unread_on_update" => __('Mark updated articles as unread') + ]; - print " "; $this->batch_edit_cbox("mark_unread_on_update", "mark_unread_on_update_l"); + print_notice("Enable the options you wish to apply using checkboxes on the right."); + ?> - print "
    "; + + + - print "
    "; +
    +
    +
    + +
    + + '1']) ?> + _batch_toggle_checkbox("cat_id") ?> +
    + - print "
    - - -
    "; + +
    + + 1]) ?> + _batch_toggle_checkbox("feed_language") ?> +
    + +
    + +
    + +
    +
    + + 1]) ?> + _batch_toggle_checkbox("update_interval") ?> +
    + + +
    + + 1]) ?> + _batch_toggle_checkbox("purge_interval") ?> +
    + +
    +
    +
    +
    +
    + + + _batch_toggle_checkbox("auth_login") ?> +
    +
    + + + _batch_toggle_checkbox("auth_pass") ?> +
    +
    +
    +
    + $caption) { + ?> +
    + +
    + +
    +
    - return; +
    + + +
    + Date: Sun, 21 Feb 2021 18:04:44 +0300 Subject: move published opml JS code to pref helpers --- classes/pref/feeds.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'classes/pref') diff --git a/classes/pref/feeds.php b/classes/pref/feeds.php index c901bc96e..e583a5f51 100755 --- a/classes/pref/feeds.php +++ b/classes/pref/feeds.php @@ -1043,7 +1043,7 @@ class Pref_Feeds extends Handler_Protected {

    - -- cgit v1.2.3 From f6bfb89b2912933f638416135dff7bb8cb28890d Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sun, 21 Feb 2021 23:18:32 +0300 Subject: pref-prefs: switch to new control shorthand in a few places --- classes/pref/prefs.php | 51 +++++++++++++++++++++----------------------------- 1 file changed, 21 insertions(+), 30 deletions(-) (limited to 'classes/pref') diff --git a/classes/pref/prefs.php b/classes/pref/prefs.php index 2ea2e9f01..a26281fee 100644 --- a/classes/pref/prefs.php +++ b/classes/pref/prefs.php @@ -712,59 +712,50 @@ class Pref_Prefs extends Handler_Protected { array_push($listed_boolean_prefs, $pref_name); - $is_checked = ($value == "true") ? "checked=\"checked\"" : ""; - if ($pref_name == "PURGE_UNREAD_ARTICLES" && FORCE_ARTICLE_PURGE != 0) { - $is_disabled = "disabled=\"1\""; - $is_checked = "checked=\"checked\""; + $is_disabled = true; + $is_checked = true; } else { - $is_disabled = ""; + $is_disabled = false; + $is_checked = ($value == "true"); } - print ""; + print \Controls\checkbox_tag($pref_name, $is_checked, "true", + ["disabled" => $is_disabled], "CB_$pref_name"); } else if (in_array($pref_name, ['FRESH_ARTICLE_MAX_AGE', 'PURGE_OLD_DAYS', 'LONG_DATE_FORMAT', 'SHORT_DATE_FORMAT'])) { - $regexp = ($type_name == 'integer') ? 'regexp="^\d*$"' : ''; - if ($pref_name == "PURGE_OLD_DAYS" && FORCE_ARTICLE_PURGE != 0) { - $is_disabled = "disabled='1'"; + $attributes = ["disabled" => true, "required" => true]; $value = FORCE_ARTICLE_PURGE; } else { - $is_disabled = ""; + $attributes = ["required" => true]; } if ($type_name == 'integer') - print ""; + print \Controls\number_spinner_tag($pref_name, $value, $attributes); else - print ""; + print \Controls\input_tag($pref_name, $value, "text", $attributes); } else if ($pref_name == "SSL_CERT_SERIAL") { - print ""; + print \Controls\input_tag($pref_name, $value, "text", ["readonly" => true], "SSL_CERT_SERIAL"); $cert_serial = htmlspecialchars(get_ssl_certificate_id()); - $has_serial = ($cert_serial) ? "false" : "true"; + $has_serial = ($cert_serial) ? true : false; - print ""; + print \Controls\button_tag(__('Register'), "", [ + "disabled" => !$has_serial, + "onclick" => "dijit.byId('SSL_CERT_SERIAL').attr('value', '$cert_serial')"]); - print ""; + print \Controls\button_tag(__('Clear'), "", [ + "class" => "alt-danger", + "onclick" => "dijit.byId('SSL_CERT_SERIAL').attr('value', '')"]); - print ""; + print \Controls\button_tag(\Controls\icon("help") . " " . __("More info..."), "", [ + "class" => "alt-info", + "onclick" => "window.open('https://tt-rss.org/wiki/SSL%20Certificate%20Authentication')"]); } else if ($pref_name == 'DIGEST_PREFERRED_TIME') { print " Date: Mon, 22 Feb 2021 14:41:09 +0300 Subject: fix several issues reported by phpstan --- classes/pref/prefs.php | 7 ------- 1 file changed, 7 deletions(-) (limited to 'classes/pref') diff --git a/classes/pref/prefs.php b/classes/pref/prefs.php index a26281fee..adb249dac 100644 --- a/classes/pref/prefs.php +++ b/classes/pref/prefs.php @@ -311,13 +311,6 @@ class Pref_Prefs extends Handler_Protected {
    - -
    - - -
    - -
    - +
    1]) ?> @@ -632,7 +632,7 @@ class Pref_Feeds extends Handler_Protected { _batch_toggle_checkbox("update_interval") ?>
    - +
    1]) ?> @@ -1147,7 +1147,7 @@ class Pref_Feeds extends Handler_Protected { function inactiveFeeds() { - if (DB_TYPE == "pgsql") { + if (Config::get(Config::DB_TYPE) == "pgsql") { $interval_qpart = "NOW() - INTERVAL '3 months'"; } else { $interval_qpart = "DATE_SUB(NOW(), INTERVAL 3 MONTH)"; diff --git a/classes/pref/prefs.php b/classes/pref/prefs.php index adb249dac..1ca5b28be 100644 --- a/classes/pref/prefs.php +++ b/classes/pref/prefs.php @@ -236,7 +236,7 @@ class Pref_Prefs extends Handler_Protected { $tpl->setVariable('LOGIN', $row["login"]); $tpl->setVariable('NEWMAIL', $email); - $tpl->setVariable('TTRSS_HOST', SELF_URL_PATH); + $tpl->setVariable('TTRSS_HOST', Config::get(Config::SELF_URL_PATH)); $tpl->addBlock('message'); @@ -625,7 +625,7 @@ class Pref_Prefs extends Handler_Protected { continue; } - if ($pref_name == "DEFAULT_SEARCH_LANGUAGE" && DB_TYPE != "pgsql") { + if ($pref_name == "DEFAULT_SEARCH_LANGUAGE" && Config::get(Config::DB_TYPE) != "pgsql") { continue; } @@ -705,7 +705,7 @@ class Pref_Prefs extends Handler_Protected { array_push($listed_boolean_prefs, $pref_name); - if ($pref_name == "PURGE_UNREAD_ARTICLES" && FORCE_ARTICLE_PURGE != 0) { + if ($pref_name == "PURGE_UNREAD_ARTICLES" && Config::get(Config::FORCE_ARTICLE_PURGE) != 0) { $is_disabled = true; $is_checked = true; } else { @@ -719,9 +719,9 @@ class Pref_Prefs extends Handler_Protected { } else if (in_array($pref_name, ['FRESH_ARTICLE_MAX_AGE', 'PURGE_OLD_DAYS', 'LONG_DATE_FORMAT', 'SHORT_DATE_FORMAT'])) { - if ($pref_name == "PURGE_OLD_DAYS" && FORCE_ARTICLE_PURGE != 0) { + if ($pref_name == "PURGE_OLD_DAYS" && Config::get(Config::FORCE_ARTICLE_PURGE) != 0) { $attributes = ["disabled" => true, "required" => true]; - $value = FORCE_ARTICLE_PURGE; + $value = Config::get(Config::FORCE_ARTICLE_PURGE); } else { $attributes = ["required" => true]; } @@ -829,7 +829,7 @@ class Pref_Prefs extends Handler_Protected { private function index_plugins_system() { print_notice("System plugins are enabled in config.php for all users."); - $system_enabled = array_map("trim", explode(",", (string)PLUGINS)); + $system_enabled = array_map("trim", explode(",", (string)Config::get(Config::PLUGINS))); $tmppluginhost = new PluginHost(); $tmppluginhost->load_all($tmppluginhost::KIND_ALL, $_SESSION["uid"], true); @@ -862,7 +862,7 @@ class Pref_Prefs extends Handler_Protected { } private function index_plugins_user() { - $system_enabled = array_map("trim", explode(",", (string)PLUGINS)); + $system_enabled = array_map("trim", explode(",", (string)Config::get(Config::PLUGINS))); $user_enabled = array_map("trim", explode(",", get_pref("_ENABLED_PLUGINS"))); $tmppluginhost = new PluginHost(); @@ -1135,7 +1135,7 @@ class Pref_Prefs extends Handler_Protected { $tpl->readTemplateFromFile("otp_disabled_template.txt"); $tpl->setVariable('LOGIN', $row["login"]); - $tpl->setVariable('TTRSS_HOST', SELF_URL_PATH); + $tpl->setVariable('TTRSS_HOST', Config::get(Config::SELF_URL_PATH)); $tpl->addBlock('message'); -- cgit v1.2.3 From 211f699aa0c4211e4ee8a02446d51b9811d0c28c Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 22 Feb 2021 22:35:27 +0300 Subject: migrate the rest into Config:: --- classes/pref/feeds.php | 8 ++++---- classes/pref/system.php | 4 ++-- classes/pref/users.php | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) (limited to 'classes/pref') diff --git a/classes/pref/feeds.php b/classes/pref/feeds.php index 229effeb3..7c3a40647 100755 --- a/classes/pref/feeds.php +++ b/classes/pref/feeds.php @@ -441,7 +441,7 @@ class Pref_Feeds extends Handler_Protected { $sth->execute([$feed_id, $_SESSION['uid']]); if ($row = $sth->fetch()) { - @unlink(ICONS_DIR . "/$feed_id.ico"); + @unlink(Config::get(Config::ICONS_DIR) . "/$feed_id.ico"); $sth = $this->pdo->prepare("UPDATE ttrss_feeds SET favicon_avg_color = NULL, favicon_last_checked = '1970-01-01' where id = ?"); @@ -479,7 +479,7 @@ class Pref_Feeds extends Handler_Protected { $sth->execute([$feed_id, $_SESSION['uid']]); if ($row = $sth->fetch()) { - $new_filename = ICONS_DIR . "/$feed_id.ico"; + $new_filename = Config::get(Config::ICONS_DIR) . "/$feed_id.ico"; if (file_exists($new_filename)) unlink($new_filename); @@ -1228,8 +1228,8 @@ class Pref_Feeds extends Handler_Protected { $pdo->commit(); - if (file_exists(ICONS_DIR . "/$id.ico")) { - unlink(ICONS_DIR . "/$id.ico"); + if (file_exists(Config::get(Config::ICONS_DIR) . "/$id.ico")) { + unlink(Config::get(Config::ICONS_DIR) . "/$id.ico"); } } else { diff --git a/classes/pref/system.php b/classes/pref/system.php index bc519a321..35c776463 100644 --- a/classes/pref/system.php +++ b/classes/pref/system.php @@ -153,10 +153,10 @@ class Pref_System extends Handler_Administrative {
    '> _log_viewer($page, $severity); } else { - print_notice("Please set LOG_DESTINATION to 'sql' in config.php to enable database logging."); + print_notice("Please set Config::get(Config::LOG_DESTINATION) to 'sql' in config.php to enable database logging."); } ?>
    diff --git a/classes/pref/users.php b/classes/pref/users.php index 5ac6a7990..f30abe001 100644 --- a/classes/pref/users.php +++ b/classes/pref/users.php @@ -86,7 +86,7 @@ class Pref_Users extends Handler_Administrative { fetch()) { ?>
  • -- cgit v1.2.3 From 2ae0b7059f2ed56b92a8f396c63224b36f71df09 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 23 Feb 2021 09:01:27 +0300 Subject: cleanup some defined-stuff --- classes/pref/prefs.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'classes/pref') diff --git a/classes/pref/prefs.php b/classes/pref/prefs.php index 1ca5b28be..7ee03c21f 100644 --- a/classes/pref/prefs.php +++ b/classes/pref/prefs.php @@ -123,8 +123,8 @@ class Pref_Prefs extends Handler_Protected { function changepassword() { - if (defined('_TTRSS_DEMO_INSTANCE')) { - print "ERROR: ".format_error("Disabled in demo version."); + if (Config::get(Config::FORBID_PASSWORD_CHANGES)) { + print "ERROR: ".format_error("Access forbidden."); return; } -- cgit v1.2.3 From 8d2e3c2528e67f8650c122f014364a34bf690d2a Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 23 Feb 2021 22:26:07 +0300 Subject: drop errors.php and simplify error handling --- classes/pref/feeds.php | 2 -- classes/pref/labels.php | 2 -- classes/pref/prefs.php | 2 +- classes/pref/users.php | 2 -- 4 files changed, 1 insertion(+), 7 deletions(-) (limited to 'classes/pref') diff --git a/classes/pref/feeds.php b/classes/pref/feeds.php index 7c3a40647..086c52697 100755 --- a/classes/pref/feeds.php +++ b/classes/pref/feeds.php @@ -561,8 +561,6 @@ class Pref_Feeds extends Handler_Protected { "all" => $this::get_ts_languages(), ] ]); - } else { - print json_encode(["error" => "FEED_NOT_FOUND"]); } } diff --git a/classes/pref/labels.php b/classes/pref/labels.php index 0b826e13f..5bc094d55 100644 --- a/classes/pref/labels.php +++ b/classes/pref/labels.php @@ -16,8 +16,6 @@ class Pref_Labels extends Handler_Protected { if ($line = $sth->fetch(PDO::FETCH_ASSOC)) { print json_encode($line); - } else { - print json_encode(["error" => "LABEL_NOT_FOUND"]); } } diff --git a/classes/pref/prefs.php b/classes/pref/prefs.php index 7ee03c21f..0d0dcadbc 100644 --- a/classes/pref/prefs.php +++ b/classes/pref/prefs.php @@ -1063,7 +1063,7 @@ class Pref_Prefs extends Handler_Protected { } } else { header("Content-Type: text/json"); - print error_json(6); + print Errors::to_json(Errors::E_UNAUTHORIZED); } } diff --git a/classes/pref/users.php b/classes/pref/users.php index f30abe001..13f808cb3 100644 --- a/classes/pref/users.php +++ b/classes/pref/users.php @@ -19,8 +19,6 @@ class Pref_Users extends Handler_Administrative { "user" => $row, "access_level_names" => $access_level_names ]); - } else { - print json_encode(["error" => "USER_NOT_FOUND"]); } } -- cgit v1.2.3 From 2f14fa1bc367551c1b29b00f366c29a513274729 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 24 Feb 2021 15:53:47 +0300 Subject: add a hack to position labels on a dijit toolbar better --- classes/pref/system.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'classes/pref') diff --git a/classes/pref/system.php b/classes/pref/system.php index 35c776463..67f7133c6 100644 --- a/classes/pref/system.php +++ b/classes/pref/system.php @@ -88,7 +88,7 @@ class Pref_System extends Handler_Administrative {
    - +