From e6624cf631f772f2a1eac9412e7a96d6545e91e6 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Fri, 12 Feb 2021 21:24:49 +0300 Subject: fix a few more session-related warnings --- classes/handler/protected.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'classes') diff --git a/classes/handler/protected.php b/classes/handler/protected.php index 765b17480..8e9e5ca1d 100644 --- a/classes/handler/protected.php +++ b/classes/handler/protected.php @@ -2,6 +2,6 @@ class Handler_Protected extends Handler { function before($method) { - return parent::before($method) && $_SESSION['uid']; + return parent::before($method) && !empty($_SESSION['uid']); } } -- cgit v1.2.3-54-g00ecf 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 --- api/index.php | 8 +------- backend.php | 4 ---- classes/pref/system.php | 20 +++++++++++++------- config.php-dist | 7 ------- include/sanity_config.php | 4 ++-- js/PrefHelpers.js | 7 +++++++ public.php | 4 ---- 7 files changed, 23 insertions(+), 31 deletions(-) (limited to 'classes') diff --git a/api/index.php b/api/index.php index 77552af46..9e998df84 100644 --- a/api/index.php +++ b/api/index.php @@ -22,13 +22,7 @@ ini_set('session.use_cookies', 0); ini_set("session.gc_maxlifetime", 86400); - if (defined('ENABLE_GZIP_OUTPUT') && ENABLE_GZIP_OUTPUT && - function_exists("ob_gzhandler")) { - - ob_start("ob_gzhandler"); - } else { - ob_start(); - } + ob_start(); $input = file_get_contents("php://input"); diff --git a/backend.php b/backend.php index 2ea396987..030676dcb 100644 --- a/backend.php +++ b/backend.php @@ -38,10 +38,6 @@ header("Content-Type: text/json; charset=utf-8"); - if (ENABLE_GZIP_OUTPUT && function_exists("ob_gzhandler")) { - ob_start("ob_gzhandler"); - } - if (SINGLE_USER_MODE) { UserHelper::authenticate( "admin", null); } 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 diff --git a/config.php-dist b/config.php-dist index cd0ee0078..2ee1c719d 100644 --- a/config.php-dist +++ b/config.php-dist @@ -122,13 +122,6 @@ define('CHECK_FOR_UPDATES', true); // Check for updates automatically if running Git version - define('ENABLE_GZIP_OUTPUT', false); - // Selectively gzip output to improve wire performance. This requires - // PHP Zlib extension on the server. - // Enabling this can break tt-rss in several httpd/php configurations, - // if you experience weird errors and tt-rss failing to start, blank pages - // after login, or content encoding errors, disable it. - define('PLUGINS', 'auth_internal, note'); // Comma-separated list of plugins to load automatically for all users. // System plugins have to be specified here. Please enable at least one diff --git a/include/sanity_config.php b/include/sanity_config.php index 7aa4f6b0f..5059ee83b 100644 --- a/include/sanity_config.php +++ b/include/sanity_config.php @@ -1,3 +1,3 @@ - +$required_defines = array( 'DB_TYPE', 'DB_HOST', 'DB_USER', 'DB_NAME', 'DB_PASS', 'MYSQL_CHARSET', 'SELF_URL_PATH', 'SINGLE_USER_MODE', 'SIMPLE_UPDATE_MODE', 'PHP_EXECUTABLE', 'LOCK_DIRECTORY', 'CACHE_DIR', 'ICONS_DIR', 'ICONS_URL', 'AUTH_AUTO_CREATE', 'AUTH_AUTO_LOGIN', 'FORCE_ARTICLE_PURGE', 'SESSION_COOKIE_LIFETIME', 'SMTP_FROM_NAME', 'SMTP_FROM_ADDRESS', 'DIGEST_SUBJECT', 'CHECK_FOR_UPDATES', 'PLUGINS', 'LOG_DESTINATION', 'CONFIG_VERSION'); ?> diff --git a/js/PrefHelpers.js b/js/PrefHelpers.js index 5bb76d179..3b9e985a6 100644 --- a/js/PrefHelpers.js +++ b/js/PrefHelpers.js @@ -51,6 +51,13 @@ const Helpers = { return false; }, + System: { + getPHPInfo: function(widget) { + xhrPost("backend.php", {op: 'pref-system', method: 'getphpinfo'}, (transport) => { + widget.attr('content', transport.responseText); + }); + } + }, EventLog: { log_page: 0, refresh: function() { diff --git a/public.php b/public.php index 36308e25e..3e4a9e023 100644 --- a/public.php +++ b/public.php @@ -16,10 +16,6 @@ if (!init_plugins()) return; - if (ENABLE_GZIP_OUTPUT && function_exists("ob_gzhandler")) { - ob_start("ob_gzhandler"); - } - $method = $_REQUEST["op"]; $override = PluginHost::getInstance()->lookup_handler("public", $method); -- cgit v1.2.3-54-g00ecf 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 +- js/PrefHelpers.js | 270 +++++++++++++++++++++++++------------------------ 3 files changed, 143 insertions(+), 137 deletions(-) (limited to 'classes') 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 " "; } } diff --git a/js/PrefHelpers.js b/js/PrefHelpers.js index 3b9e985a6..b09beb995 100644 --- a/js/PrefHelpers.js +++ b/js/PrefHelpers.js @@ -40,16 +40,18 @@ const Helpers = { } }, }, - clearFeedAccessKeys: function() { - if (confirm(__("This will invalidate all previously generated feed URLs. Continue?"))) { - Notify.progress("Clearing URLs..."); + Feeds: { + clearFeedAccessKeys: function() { + if (confirm(__("This will invalidate all previously generated feed URLs. Continue?"))) { + Notify.progress("Clearing URLs..."); - xhrPost("backend.php", {op: "pref-feeds", method: "clearKeys"}, () => { - Notify.info("Generated URLs cleared."); - }); - } + xhrPost("backend.php", {op: "pref-feeds", method: "clearKeys"}, () => { + Notify.info("Generated URLs cleared."); + }); + } - return false; + return false; + }, }, System: { getPHPInfo: function(widget) { @@ -90,151 +92,155 @@ const Helpers = { } }, }, - editProfiles: function() { - const dialog = new fox.SingleUseDialog({ - id: "profileEditDlg", - title: __("Settings Profiles"), - getSelectedProfiles: function () { - return Tables.getSelected("pref-profiles-list"); - }, - removeSelected: function () { - const sel_rows = this.getSelectedProfiles(); - - if (sel_rows.length > 0) { - if (confirm(__("Remove selected profiles? Active and default profiles will not be removed."))) { - Notify.progress("Removing selected profiles...", true); - - const query = { - op: "rpc", method: "remprofiles", - ids: sel_rows.toString() - }; + Profiles: { + edit: function() { + const dialog = new fox.SingleUseDialog({ + id: "profileEditDlg", + title: __("Settings Profiles"), + getSelectedProfiles: function () { + return Tables.getSelected("pref-profiles-list"); + }, + removeSelected: function () { + const sel_rows = this.getSelectedProfiles(); + + if (sel_rows.length > 0) { + if (confirm(__("Remove selected profiles? Active and default profiles will not be removed."))) { + Notify.progress("Removing selected profiles...", true); + + const query = { + op: "rpc", method: "remprofiles", + ids: sel_rows.toString() + }; + + xhrPost("backend.php", query, () => { + Notify.close(); + dialog.refresh(); + }); + } + + } else { + alert(__("No profiles selected.")); + } + }, + addProfile: function () { + if (this.validate()) { + Notify.progress("Creating profile...", true); + + const query = {op: "rpc", method: "addprofile", title: dialog.attr('value').newprofile}; xhrPost("backend.php", query, () => { Notify.close(); dialog.refresh(); }); - } - - } else { - alert(__("No profiles selected.")); - } - }, - addProfile: function () { - if (this.validate()) { - Notify.progress("Creating profile...", true); - - const query = {op: "rpc", method: "addprofile", title: dialog.attr('value').newprofile}; - xhrPost("backend.php", query, () => { - Notify.close(); - dialog.refresh(); + } + }, + refresh: function() { + xhrPost("backend.php", {op: 'pref-prefs', method: 'editPrefProfiles'}, (transport) => { + dialog.attr('content', transport.responseText); }); + }, + execute: function () { + const sel_rows = this.getSelectedProfiles(); - } - }, - refresh: function() { - xhrPost("backend.php", {op: 'pref-prefs', method: 'editPrefProfiles'}, (transport) => { - dialog.attr('content', transport.responseText); - }); - }, - execute: function () { - const sel_rows = this.getSelectedProfiles(); + if (sel_rows.length == 1) { + if (confirm(__("Activate selected profile?"))) { + Notify.progress("Loading, please wait..."); - if (sel_rows.length == 1) { - if (confirm(__("Activate selected profile?"))) { - Notify.progress("Loading, please wait..."); + xhrPost("backend.php", {op: "rpc", method: "setprofile", id: sel_rows.toString()}, () => { + window.location.reload(); + }); + } - xhrPost("backend.php", {op: "rpc", method: "setprofile", id: sel_rows.toString()}, () => { - window.location.reload(); - }); + } else { + alert(__("Please choose a profile to activate.")); } + }, + content: "" + }); - } else { - alert(__("Please choose a profile to activate.")); - } - }, - content: "" - }); - - dialog.refresh(); - dialog.show(); + dialog.refresh(); + dialog.show(); + }, }, - customizeCSS: function() { - xhrJson("backend.php", {op: "pref-prefs", method: "customizeCSS"}, (reply) => { + Prefs: { + customizeCSS: function() { + xhrJson("backend.php", {op: "pref-prefs", method: "customizeCSS"}, (reply) => { + + const dialog = new fox.SingleUseDialog({ + title: __("Customize stylesheet"), + apply: function() { + xhrPost("backend.php", this.attr('value'), () => { + new Effect.Appear("css_edit_apply_msg"); + $("user_css_style").innerText = this.attr('value'); + }); + }, + execute: function () { + Notify.progress('Saving data...', true); - const dialog = new fox.SingleUseDialog({ - title: __("Customize stylesheet"), - apply: function() { - xhrPost("backend.php", this.attr('value'), () => { - new Effect.Appear("css_edit_apply_msg"); - $("user_css_style").innerText = this.attr('value'); - }); - }, - execute: function () { - Notify.progress('Saving data...', true); + xhrPost("backend.php", this.attr('value'), () => { + window.location.reload(); + }); + }, + content: ` +
+ ${__("You can override colors, fonts and layout of your currently selected theme with custom CSS declarations here.")} +
- xhrPost("backend.php", this.attr('value'), () => { - window.location.reload(); - }); - }, - content: ` -
- ${__("You can override colors, fonts and layout of your currently selected theme with custom CSS declarations here.")} -
- - ${App.FormFields.hidden('op', 'rpc')} - ${App.FormFields.hidden('method', 'setpref')} - ${App.FormFields.hidden('key', 'USER_STYLESHEET')} - - "; } + function get_metadata_by_id() { + $id = clean($_REQUEST['id']); + + $sth = $this->pdo->prepare("SELECT link, title FROM ttrss_entries, ttrss_user_entries + WHERE ref_id = ? AND ref_id = id AND owner_uid = ?"); + $sth->execute([$id, $_SESSION['uid']]); + + if ($row = $sth->fetch()) { + $link = $row['link']; + $title = $row['title']; + + echo json_encode(["link" => $link, "title" => $title]); + } + } + static function get_article_enclosures($id) { $pdo = Db::pdo(); diff --git a/classes/rpc.php b/classes/rpc.php index f8af1d660..f6b57775d 100755 --- a/classes/rpc.php +++ b/classes/rpc.php @@ -382,23 +382,6 @@ class RPC extends Handler_Protected { $sth->execute(array_merge($ids, [$_SESSION['uid']])); } - function getlinktitlebyid() { - $id = clean($_REQUEST['id']); - - $sth = $this->pdo->prepare("SELECT link, title FROM ttrss_entries, ttrss_user_entries - WHERE ref_id = ? AND ref_id = id AND owner_uid = ?"); - $sth->execute([$id, $_SESSION['uid']]); - - if ($row = $sth->fetch()) { - $link = $row['link']; - $title = $row['title']; - - echo json_encode(array("link" => $link, "title" => $title)); - } else { - echo json_encode(array("error" => "ARTICLE_NOT_FOUND")); - } - } - function log() { $msg = clean($_REQUEST['msg']); $file = basename(clean($_REQUEST['file'])); diff --git a/js/Article.js b/js/Article.js index 61368dfed..f8b0415b9 100644 --- a/js/Article.js +++ b/js/Article.js @@ -123,11 +123,13 @@ const Article = { Article.setActive(0); }, displayUrl: function (id) { - const query = {op: "rpc", method: "getlinktitlebyid", id: id}; + const query = {op: "article", method: "get_metadata_by_id", id: id}; xhrJson("backend.php", query, (reply) => { if (reply && reply.link) { prompt(__("Article URL:"), reply.link); + } else { + alert(__("No URL could be displayed for this article.")); } }); }, diff --git a/js/CommonFilters.js b/js/CommonFilters.js index 802cf478d..15403b8c4 100644 --- a/js/CommonFilters.js +++ b/js/CommonFilters.js @@ -332,7 +332,7 @@ const Filters = { } else { - const query = {op: "rpc", method: "getlinktitlebyid", id: Article.getActive()}; + const query = {op: "article", method: "get_metadata_by_id", id: Article.getActive()}; xhrPost("backend.php", query, (transport) => { const reply = JSON.parse(transport.responseText); -- cgit v1.2.3-54-g00ecf 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 ++------------------ js/App.js | 4 +- js/PrefLabelTree.js | 167 ++++++++++++++++++++++++++++++++---------------- 3 files changed, 120 insertions(+), 119 deletions(-) (limited to 'classes') 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"]); } } diff --git a/js/App.js b/js/App.js index 514a6d4b7..4646145ea 100644 --- a/js/App.js +++ b/js/App.js @@ -18,8 +18,8 @@ const App = { is_prefs: false, LABEL_BASE_INDEX: -1024, FormFields: { - hidden: function(name, value) { - return `` + hidden: function(name, value, id = "") { + return `` } }, Scrollable: { diff --git a/js/PrefLabelTree.js b/js/PrefLabelTree.js index 73f375f2d..88e88b669 100644 --- a/js/PrefLabelTree.js +++ b/js/PrefLabelTree.js @@ -1,5 +1,5 @@ /* eslint-disable prefer-rest-params */ -/* global __, define, lib, dijit, dojo, xhrPost, Notify, fox */ +/* global __, define, lib, dijit, dojo, xhrPost, Notify, fox, App */ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree", "dijit/form/DropDownButton"], function (declare, domConstruct) { @@ -61,70 +61,129 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree", "dijit/f }); }, editLabel: function(id) { - const dialog = new fox.SingleUseDialog({ - id: "labelEditDlg", - title: __("Label Editor"), - style: "width: 650px", - setLabelColor: function (id, fg, bg) { - - let kind = ''; - let color = ''; - - if (fg && bg) { - kind = 'both'; - } else if (fg) { - kind = 'fg'; - color = fg; - } else if (bg) { - kind = 'bg'; - color = bg; - } - - const e = $("icon-label-" + id); - - if (e) { - if (bg) e.style.color = bg; - } + xhrJson("backend.php", {op: "pref-labels", method: "edit", id: id}, (reply) => { - const query = { - op: "pref-labels", method: "colorset", kind: kind, - ids: id, fg: fg, bg: bg, color: color - }; + console.log(reply); - xhrPost("backend.php", query, () => { - const tree = dijit.byId("filterTree"); - if (tree) tree.reload(); // maybe there's labels in there - }); + const fg_color = reply['fg_color']; + const bg_color = reply['bg_color'] ? reply['bg_color'] : '#fff7d5'; + + const dialog = new fox.SingleUseDialog({ + id: "labelEditDlg", + title: __("Label Editor"), + style: "width: 650px", + setLabelColor: function (id, fg, bg) { + + let kind = ''; + let color = ''; - }, - execute: function () { - if (this.validate()) { - const caption = this.attr('value').caption; - const fg_color = this.attr('value').fg_color; - const bg_color = this.attr('value').bg_color; + if (fg && bg) { + kind = 'both'; + } else if (fg) { + kind = 'fg'; + color = fg; + } else if (bg) { + kind = 'bg'; + color = bg; + } - dijit.byId('labelTree').setNameById(id, caption); - this.setLabelColor(id, fg_color, bg_color); - this.hide(); + const e = $("icon-label-" + id); - xhrPost("backend.php", this.attr('value'), () => { + if (e) { + if (bg) e.style.color = bg; + } + + const query = { + op: "pref-labels", method: "colorset", kind: kind, + ids: id, fg: fg, bg: bg, color: color + }; + + xhrPost("backend.php", query, () => { const tree = dijit.byId("filterTree"); if (tree) tree.reload(); // maybe there's labels in there }); - } - }, - content: __("Loading, please wait...") - }); - const tmph = dojo.connect(dialog, 'onShow', function () { - dojo.disconnect(tmph); + }, + execute: function () { + if (this.validate()) { + const caption = this.attr('value').caption; + const fg_color = this.attr('value').fg_color; + const bg_color = this.attr('value').bg_color; + + dijit.byId('labelTree').setNameById(id, caption); + this.setLabelColor(id, fg_color, bg_color); + this.hide(); + + xhrPost("backend.php", this.attr('value'), () => { + const tree = dijit.byId("filterTree"); + if (tree) tree.reload(); // maybe there's labels in there + }); + } + }, + content: ` +
+ +
${__("Caption")}
+
+ +
+ + ${App.FormFields.hidden('id', id)} + ${App.FormFields.hidden('op', 'pref-labels')} + ${App.FormFields.hidden('method', 'save')} + + ${App.FormFields.hidden('fg_color', fg_color, 'labelEdit_fgColor')} + ${App.FormFields.hidden('bg_color', bg_color, 'labelEdit_bgColor')} + +
${__("Colors")}
+
+ + + + + + + + + +
${__("Foreground:")}${__("Background:")}
+
+ +
+
+
+ +
+
+
+ +
+ + +
+ +
+ ` + }); - xhrPost("backend.php", {op: "pref-labels", method: "edit", id: id}, (transport) => { - dialog.attr('content', transport.responseText); - }) - }); + dialog.show(); - dialog.show(); + }); }, resetColors: function() { const labels = this.getSelectedLabels(); -- cgit v1.2.3-54-g00ecf 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') 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') 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') 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') 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') 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-54-g00ecf 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 - js/PrefFeedTree.js | 37 +++++- plugins/share/init.php | 6 +- themes/compact.css | 15 +-- themes/compact_night.css | 15 +-- themes/light.css | 15 +-- themes/light/prefs.less | 14 +- themes/night.css | 15 +-- themes/night_blue.css | 15 +-- 11 files changed, 235 insertions(+), 243 deletions(-) (limited to 'classes') 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 {
-
diff --git a/js/PrefFeedTree.js b/js/PrefFeedTree.js index e17b8744d..e0a2dd932 100644 --- a/js/PrefFeedTree.js +++ b/js/PrefFeedTree.js @@ -209,6 +209,13 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree", "dojo/_b return false; }, + checkErrorFeeds: function() { + xhrJson("backend.php", {op: "pref-feeds", method: "feedsWithErrors"}, (reply) => { + if (reply.length > 0) { + Element.show(dijit.byId("pref_feeds_errors_btn").domNode); + } + }); + }, checkInactiveFeeds: function() { xhrJson("backend.php", {op: "pref-feeds", method: "inactivefeeds"}, (reply) => { if (reply.length > 0) { diff --git a/themes/compact.css b/themes/compact.css index f923b2ee1..36c5aec9f 100644 --- a/themes/compact.css +++ b/themes/compact.css @@ -1456,7 +1456,7 @@ body.ttrss_prefs #feedsTab { body.ttrss_prefs .dijitDialog #pref-profiles-list .dijitInlineEditBoxDisplayMode { padding: 0px; } -body.ttrss_prefs #errorButton { +body.ttrss_prefs #pref_feeds_errors_btn { color: red; } body.ttrss_prefs .user-css-editor { diff --git a/themes/compact_night.css b/themes/compact_night.css index e512e8176..e39b7020a 100644 --- a/themes/compact_night.css +++ b/themes/compact_night.css @@ -1456,7 +1456,7 @@ body.ttrss_prefs #feedsTab { body.ttrss_prefs .dijitDialog #pref-profiles-list .dijitInlineEditBoxDisplayMode { padding: 0px; } -body.ttrss_prefs #errorButton { +body.ttrss_prefs #pref_feeds_errors_btn { color: red; } body.ttrss_prefs .user-css-editor { diff --git a/themes/light.css b/themes/light.css index a19467c41..b6c487b66 100644 --- a/themes/light.css +++ b/themes/light.css @@ -1456,7 +1456,7 @@ body.ttrss_prefs #feedsTab { body.ttrss_prefs .dijitDialog #pref-profiles-list .dijitInlineEditBoxDisplayMode { padding: 0px; } -body.ttrss_prefs #errorButton { +body.ttrss_prefs #pref_feeds_errors_btn { color: red; } body.ttrss_prefs .user-css-editor { diff --git a/themes/light/prefs.less b/themes/light/prefs.less index 0206916ae..ec3006ce5 100644 --- a/themes/light/prefs.less +++ b/themes/light/prefs.less @@ -65,7 +65,7 @@ body.ttrss_prefs { padding : 0px; } - #errorButton { + #pref_feeds_errors_btn { color : red; } diff --git a/themes/night.css b/themes/night.css index e2bd50142..5941fd8e1 100644 --- a/themes/night.css +++ b/themes/night.css @@ -1457,7 +1457,7 @@ body.ttrss_prefs #feedsTab { body.ttrss_prefs .dijitDialog #pref-profiles-list .dijitInlineEditBoxDisplayMode { padding: 0px; } -body.ttrss_prefs #errorButton { +body.ttrss_prefs #pref_feeds_errors_btn { color: red; } body.ttrss_prefs .user-css-editor { diff --git a/themes/night_blue.css b/themes/night_blue.css index 93027e8be..99bb191a2 100644 --- a/themes/night_blue.css +++ b/themes/night_blue.css @@ -1457,7 +1457,7 @@ body.ttrss_prefs #feedsTab { body.ttrss_prefs .dijitDialog #pref-profiles-list .dijitInlineEditBoxDisplayMode { padding: 0px; } -body.ttrss_prefs #errorButton { +body.ttrss_prefs #pref_feeds_errors_btn { color: red; } body.ttrss_prefs .user-css-editor { -- cgit v1.2.3-54-g00ecf 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/feeds.php | 10 +++--- classes/handler/public.php | 44 +++++++++++------------ classes/pref/feeds.php | 74 +++++++++++++++++++------------------- classes/pref/filters.php | 20 +++++------ classes/pref/labels.php | 12 +++---- classes/pref/system.php | 42 +++++++++++----------- include/login_form.php | 34 +++++++++--------- index.php | 78 ++++++++++++++++++++--------------------- plugins/af_redditimgur/init.php | 4 +-- plugins/auth_internal/init.php | 18 +++++----- plugins/toggle_sidebar/init.php | 2 +- prefs.php | 28 +++++++-------- 12 files changed, 183 insertions(+), 183 deletions(-) (limited to 'classes') diff --git a/classes/feeds.php b/classes/feeds.php index 031a671ae..e6bd1459d 100755 --- a/classes/feeds.php +++ b/classes/feeds.php @@ -838,14 +838,14 @@ class Feeds extends Handler_Protected {
-

Feed Debugger: getFeedTitle($feed_id) ?>

+

Feed Debugger: getFeedTitle($feed_id) ?>

- + - +
- +
- +
diff --git a/classes/handler/public.php b/classes/handler/public.php index db8a924ad..481145606 100755 --- a/classes/handler/public.php +++ b/classes/handler/public.php @@ -519,7 +519,7 @@ class Handler_Public extends Handler { - <?php echo __("Share with Tiny Tiny RSS") ?> + <?= __("Share with Tiny Tiny RSS") ?>
- - + +
- - + +
- +
- +
- - - + + +
@@ -635,24 +635,24 @@ class Handler_Public extends Handler { -
+
- + " /> + required="1" value="" />
- + "/> + value=""/>

@@ -660,7 +660,7 @@ class Handler_Public extends Handler {
- +
@@ -781,7 +781,7 @@ class Handler_Public extends Handler { };
-

+

- +
- + Database Updater - +
-

+

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") ?> diff --git a/include/login_form.php b/include/login_form.php index aec305b13..aa6a72260 100755 --- a/include/login_form.php +++ b/include/login_form.php @@ -92,29 +92,29 @@
-

+

-
- +
- + " /> + required="1" value="" />
- + "/> + value=""/>
- +
- +
@@ -143,11 +143,11 @@ +
- +
@@ -155,11 +155,11 @@ +
- +
0) { ?> @@ -167,7 +167,7 @@ @@ -177,7 +177,7 @@
- +
@@ -185,7 +185,7 @@
diff --git a/index.php b/index.php index fa23570ff..8bfca1af2 100644 --- a/index.php +++ b/index.php @@ -47,7 +47,7 @@ } ?> @@ -68,7 +68,7 @@ @@ -50,7 +50,7 @@ "; + 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') 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') 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-54-g00ecf 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 +++++++++---- js/PrefHelpers.js | 6 +----- 3 files changed, 10 insertions(+), 11 deletions(-) (limited to 'classes') 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") ?> diff --git a/js/PrefHelpers.js b/js/PrefHelpers.js index b09beb995..7a3d38d02 100644 --- a/js/PrefHelpers.js +++ b/js/PrefHelpers.js @@ -54,11 +54,7 @@ const Helpers = { }, }, System: { - getPHPInfo: function(widget) { - xhrPost("backend.php", {op: 'pref-system', method: 'getphpinfo'}, (transport) => { - widget.attr('content', transport.responseText); - }); - } + // }, EventLog: { log_page: 0, -- cgit v1.2.3-54-g00ecf 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') 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-54-g00ecf 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/api.php | 2 +- classes/handler/public.php | 2 +- classes/pref/users.php | 11 ----------- classes/userhelper.php | 14 +++++++++++++- 4 files changed, 15 insertions(+), 14 deletions(-) (limited to 'classes') diff --git a/classes/api.php b/classes/api.php index 6a919be64..9299c34ea 100755 --- a/classes/api.php +++ b/classes/api.php @@ -81,7 +81,7 @@ class API extends Handler { } function logout() { - Pref_Users::logout_user(); + UserHelper::logout(); $this->wrap(self::STATUS_OK, array("status" => "OK")); } diff --git a/classes/handler/public.php b/classes/handler/public.php index 481145606..79f3a9e6c 100755 --- a/classes/handler/public.php +++ b/classes/handler/public.php @@ -286,7 +286,7 @@ class Handler_Public extends Handler { function logout() { if (validate_csrf($_POST["csrf_token"])) { - Pref_Users::logout_user(); + UserHelper::logout(); header("Location: index.php"); } else { header("Content-Type: text/json"); 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(); - } - } diff --git a/classes/userhelper.php b/classes/userhelper.php index c9c4dd102..8eb97f5d0 100644 --- a/classes/userhelper.php +++ b/classes/userhelper.php @@ -105,7 +105,7 @@ class UserHelper { } if (empty($_SESSION["uid"])) { - Pref_Users::logout_user(); + UserHelper::logout(); Handler_Public::render_login_form(); exit; @@ -157,4 +157,16 @@ class UserHelper { return false; } + + static function logout() { + if (session_status() === PHP_SESSION_ACTIVE) + session_destroy(); + + if (isset($_COOKIE[session_name()])) { + setcookie(session_name(), '', time()-42000, '/'); + + } + session_commit(); + } + } -- cgit v1.2.3-54-g00ecf 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 ---- js/CommonFilters.js | 2 +- js/PrefFilterTree.js | 17 ----------------- js/PrefUsers.js | 15 --------------- 5 files changed, 1 insertion(+), 39 deletions(-) (limited to 'classes') 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 { - - - diff --git a/js/CommonFilters.js b/js/CommonFilters.js index 15403b8c4..06e0410c7 100644 --- a/js/CommonFilters.js +++ b/js/CommonFilters.js @@ -243,7 +243,7 @@ const Filters = { try { const dialog = new fox.SingleUseDialog({ id: "filterEditDlg", - title: __("Create Filter"), + title: id ? __("Edit Filter") : __("Create Filter"), test: function () { Filters.test(this.attr('value')); }, diff --git a/js/PrefFilterTree.js b/js/PrefFilterTree.js index abfdbb3b0..e7d4efdc1 100644 --- a/js/PrefFilterTree.js +++ b/js/PrefFilterTree.js @@ -119,23 +119,6 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree"], functio }); } }, - editSelectedFilter: function() { - const rows = this.getSelectedFilters(); - - if (rows.length == 0) { - alert(__("No filters selected.")); - return; - } - - if (rows.length > 1) { - alert(__("Please select only one filter.")); - return; - } - - Notify.close(); - - this.editFilter(rows[0]); - }, removeSelectedFilters: function() { const sel_rows = this.getSelectedFilters(); diff --git a/js/PrefUsers.js b/js/PrefUsers.js index 0a7e635fe..e5c281811 100644 --- a/js/PrefUsers.js +++ b/js/PrefUsers.js @@ -93,21 +93,6 @@ const Users = { alert(__("No users selected.")); } }, - editSelected: function() { - const rows = this.getSelection(); - - if (rows.length == 0) { - alert(__("No users selected.")); - return; - } - - if (rows.length > 1) { - alert(__("Please select one user.")); - return; - } - - this.edit(rows[0]); - }, getSelection :function() { return Tables.getSelected("users-list"); } -- cgit v1.2.3-54-g00ecf 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') 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-54-g00ecf 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/handler/administrative.php | 11 +++++++++++ classes/pref/system.php | 13 +------------ classes/pref/users.php | 13 +------------ 3 files changed, 13 insertions(+), 24 deletions(-) create mode 100644 classes/handler/administrative.php (limited to 'classes') diff --git a/classes/handler/administrative.php b/classes/handler/administrative.php new file mode 100644 index 000000000..52dfed8b7 --- /dev/null +++ b/classes/handler/administrative.php @@ -0,0 +1,11 @@ += 10) { + return true; + } + } + return false; + } +} 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 +++++++------------------------------------------ js/App.js | 9 ++++ js/PrefUsers.js | 84 +++++++++++++++++++++++++++++++++++-- 3 files changed, 105 insertions(+), 100 deletions(-) (limited to 'classes') 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); diff --git a/js/App.js b/js/App.js index 4646145ea..1e6e5fdb1 100644 --- a/js/App.js +++ b/js/App.js @@ -20,6 +20,15 @@ const App = { FormFields: { hidden: function(name, value, id = "") { return `` + }, + select_hash: function(name, value, values, attributes) { + return ` + + ` } }, Scrollable: { diff --git a/js/PrefUsers.js b/js/PrefUsers.js index e5c281811..1fe4db150 100644 --- a/js/PrefUsers.js +++ b/js/PrefUsers.js @@ -1,7 +1,7 @@ 'use strict' /* global __ */ -/* global xhrPost, dojo, dijit, Notify, Tables, fox */ +/* global xhrPost, xhrJson, dojo, dijit, Notify, Tables, App, fox */ const Users = { reload: function(sort) { @@ -27,7 +27,10 @@ const Users = { } }, edit: function(id) { - xhrPost('backend.php', {op: 'pref-users', method: 'edit', id: id}, (transport) => { + xhrJson('backend.php', {op: 'pref-users', method: 'edit', id: id}, (reply) => { + const user = reply.user; + const is_disabled = (user.id == 1) ? "disabled='disabled'" : ''; + const dialog = new fox.SingleUseDialog({ id: "userEditDlg", title: __("User Editor"), @@ -35,13 +38,86 @@ const Users = { if (this.validate()) { Notify.progress("Saving data...", true); - xhrPost("backend.php", dojo.formToObject("user_edit_form"), (/* transport */) => { + xhrPost("backend.php", this.attr('value'), () => { dialog.hide(); Users.reload(); }); } }, - content: transport.responseText + content: ` +
+ + ${App.FormFields.hidden('id', user.id.toString())} + ${App.FormFields.hidden('op', 'pref-users')} + ${App.FormFields.hidden('method', 'editSave')} + +
+
+ +
${__("User")}
+ +
+
+ + + + ${is_disabled ? App.FormFields.hidden("login", user.login) : ''} +
+
+ +
${__("Authentication")}
+ +
+
+ + ${App.FormFields.select_hash("access_level", + user.access_level, reply.access_level_names, is_disabled)} + + ${is_disabled ? App.FormFields.hidden("access_level", + user.access_level.toString()) : ''} +
+
+ + +
+
+ +
${__("Options")}
+ +
+
+ + +
+
+
+
+ + ${__("Loading, please wait...")} +
+
+ +
+ + +
+
+ ` }); dialog.show(); -- cgit v1.2.3-54-g00ecf From 68e2ccb35477d9270f598a3e1750782fc81bfb16 Mon Sep 17 00:00:00 2001 From: Joseph Date: Sun, 14 Feb 2021 17:31:01 +0000 Subject: Lazy load image attachments --- classes/article.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'classes') diff --git a/classes/article.php b/classes/article.php index 7f5311668..5ea936985 100755 --- a/classes/article.php +++ b/classes/article.php @@ -443,7 +443,7 @@ class Article extends Handler_Protected { $encsize .= ' height="' . intval($entry['height']) . '"'; if ($entry['width'] > 0) $encsize .= ' width="' . intval($entry['width']) . '"'; - $rv .= "

\"".htmlspecialchars($entry["filename"])."\"

"; -- cgit v1.2.3-54-g00ecf 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/feeds.php | 123 +++++++++-------------------------------------- classes/pref/feeds.php | 22 ++++++--- index.php | 4 +- js/CommonDialogs.js | 13 ++--- js/Headlines.js | 61 +++++++++++++++++++++-- plugins/mail/init.php | 7 ++- plugins/mailto/init.php | 5 ++ themes/compact.css | 5 +- themes/compact_night.css | 5 +- themes/light.css | 5 +- themes/light/tt-rss.less | 4 +- themes/night.css | 5 +- themes/night_blue.css | 5 +- 13 files changed, 136 insertions(+), 128 deletions(-) (limited to 'classes') diff --git a/classes/feeds.php b/classes/feeds.php index e6bd1459d..0a3e77a1a 100755 --- a/classes/feeds.php +++ b/classes/feeds.php @@ -16,103 +16,6 @@ class Feeds extends Handler_Protected { return array_search($method, $csrf_ignored) !== false; } - private function format_headline_subtoolbar($feed_site_url, $feed_title, - $feed_id, $is_cat, $search, - $error, $feed_last_updated) { - - $cat_q = $is_cat ? "&is_cat=$is_cat" : ""; - - if ($search) { - $search_q = "&q=$search"; - } else { - $search_q = ""; - } - - $reply = ""; - - $rss_link = htmlspecialchars(get_self_url_prefix() . - "/public.php?op=rss&id=${feed_id}${cat_q}${search_q}"); - - $reply .= ""; - - $reply .= " - rss_feed"; - - $reply .= ""; - - if ($feed_site_url) { - $last_updated = T_sprintf("Last updated: %s", $feed_last_updated); - - $reply .= "". - truncate_string(strip_tags($feed_title), 30).""; - } else { - $reply .= strip_tags($feed_title); - } - - if ($error) - $reply .= " error"; - - $reply .= ""; - $reply .= ""; - $reply .= ""; - - $reply .= ""; - $reply .= ""; - $reply .= " "; - - $reply .= "
- ".__("Select...")." -
-
".__('All')."
-
".__('Unread')."
-
".__('Invert')."
-
".__('None')."
-
-
".__('Toggle unread')."
-
".__('Toggle starred')."
-
".__('Toggle published')."
-
-
".__('Mark as read')."
-
".__('Set score')."
"; - - // TODO: move to mail plugin - if (PluginHost::getInstance()->get_plugin("mail")) { - $reply .= "
".__('Forward by email')."
"; - } - - // TODO: move to mailto plugin - if (PluginHost::getInstance()->get_plugin("mailto")) { - $reply .= "
".__('Forward by email')."
"; - } - - PluginHost::getInstance()->chain_hooks_callback(PluginHost::HOOK_HEADLINE_TOOLBAR_SELECT_MENU_ITEM, - function ($result) use (&$reply) { - $reply .= $result; - }, - $feed_id, $is_cat); - - if ($feed_id == 0 && !$is_cat) { - $reply .= "
-
".__('Delete permanently')."
"; - } - - $reply .= "
"; /* menu */ - - $reply .= "
"; /* dropdown */ - - PluginHost::getInstance()->chain_hooks_callback(PluginHost::HOOK_HEADLINE_TOOLBAR_BUTTON, - function ($result) use (&$reply) { - $reply .= $result; - }, - $feed_id, $is_cat); - - $reply .= "
"; - - return $reply; - } - private function format_headlines_list($feed, $method, $view_mode, $limit, $cat_view, $offset, $override_order = false, $include_children = false, $check_first_id = false, $skip_first_id_check = false, $order_by = false) { @@ -222,10 +125,28 @@ class Feeds extends Handler_Protected { $reply['search_query'] = [$search, $search_language]; $reply['vfeed_group_enabled'] = $vfeed_group_enabled; - $reply['toolbar'] = $this->format_headline_subtoolbar($feed_site_url, - $feed_title, - $feed, $cat_view, $search, - $last_error, $last_updated); + $plugin_menu_items = ""; + PluginHost::getInstance()->chain_hooks_callback(PluginHost::HOOK_HEADLINE_TOOLBAR_SELECT_MENU_ITEM, + function ($result) use (&$plugin_menu_items) { + $plugin_menu_items .= $result; + }, + $feed, $cat_view); + + $plugin_buttons = ""; + PluginHost::getInstance()->chain_hooks_callback(PluginHost::HOOK_HEADLINE_TOOLBAR_BUTTON, + function ($result) use (&$plugin_buttons) { + $plugin_buttons .= $result; + }, + $feed, $cat_view); + + $reply['toolbar'] = [ + 'site_url' => $feed_site_url, + 'title' => truncate_string(strip_tags($feed_title), 30), + 'error' => $last_error, + 'last_updated' => $last_updated, + 'plugin_menu_items' => $plugin_menu_items, + 'plugin_buttons' => $plugin_buttons, + ]; $reply['content'] = []; 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) { diff --git a/index.php b/index.php index 8bfca1af2..d53fb54a8 100644 --- a/index.php +++ b/index.php @@ -176,9 +176,9 @@ }); ?> -
+
- +
diff --git a/js/CommonDialogs.js b/js/CommonDialogs.js index 5a72f705b..e6b1822c2 100644 --- a/js/CommonDialogs.js +++ b/js/CommonDialogs.js @@ -433,24 +433,19 @@ const CommonDialogs = { } }); }, - generatedFeed: function(feed, is_cat, rss_url, feed_title) { + generatedFeed: function(feed, is_cat, search = "") { Notify.progress("Loading, please wait...", true); - xhrJson("backend.php", {op: "pref-feeds", method: "getFeedKey", id: feed, is_cat: is_cat}, (reply) => { + xhrJson("backend.php", {op: "pref-feeds", method: "getsharedurl", id: feed, is_cat: is_cat, search: search}, (reply) => { try { - if (!feed_title && typeof Feeds != "undefined") - feed_title = Feeds.getName(feed, is_cat); - - const secret_url = rss_url + "&key=" + encodeURIComponent(reply.link); - const dialog = new fox.SingleUseDialog({ title: __("Show as feed"), content: ` -
${__("%s can be accessed via the following secret URL:").replace("%s", feed_title)}
+
${__("%s can be accessed via the following secret URL:").replace("%s", App.escapeHtml(reply.title))}