diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/functions.php | 53 | ||||
-rwxr-xr-x | include/login_form.php | 108 | ||||
-rwxr-xr-x | include/sanity_check.php | 2 |
3 files changed, 90 insertions, 73 deletions
diff --git a/include/functions.php b/include/functions.php index 537139d18..3e37d1d28 100644 --- a/include/functions.php +++ b/include/functions.php @@ -66,11 +66,12 @@ define_default('MAX_CONDITIONAL_INTERVAL', 3600*12); // max interval between forced unconditional updates for servers // not complying with http if-modified-since (seconds) - define_default('MAX_FETCH_REQUESTS_PER_HOST', 25); + // define_default('MAX_FETCH_REQUESTS_PER_HOST', 25); // a maximum amount of allowed HTTP requests per destination host // during a single update (i.e. within PHP process lifetime) // this is used to not cause excessive load on the origin server on // e.g. feed subscription when all articles are being processes + // (not implemented) /* tunables end here */ @@ -243,10 +244,10 @@ $url_host = parse_url($url, PHP_URL_HOST); $fetch_domain_hits[$url_host] += 1; - if ($fetch_domain_hits[$url_host] > MAX_FETCH_REQUESTS_PER_HOST) { + /*if ($fetch_domain_hits[$url_host] > MAX_FETCH_REQUESTS_PER_HOST) { user_error("Exceeded fetch request quota for $url_host: " . $fetch_domain_hits[$url_host], E_USER_WARNING); #return false; - } + }*/ if (!defined('NO_CURL') && function_exists('curl_init') && !ini_get("open_basedir")) { @@ -730,24 +731,7 @@ if ($_SESSION["uid"]) { startup_gettext(); load_user_plugins($_SESSION["uid"]); - - /* cleanup ccache */ - - $sth = $pdo->prepare("DELETE FROM ttrss_counters_cache WHERE owner_uid = ? - AND - (SELECT COUNT(id) FROM ttrss_feeds WHERE - ttrss_feeds.id = feed_id) = 0"); - - $sth->execute([$_SESSION['uid']]); - - $sth = $pdo->prepare("DELETE FROM ttrss_cat_counters_cache WHERE owner_uid = ? - AND - (SELECT COUNT(id) FROM ttrss_feed_categories WHERE - ttrss_feed_categories.id = feed_id) = 0"); - - $sth->execute([$_SESSION['uid']]); } - } } @@ -1069,7 +1053,7 @@ "close_article" => __("Close/collapse article"), "toggle_expand" => __("Toggle article expansion (combined mode)"), "toggle_widescreen" => __("Toggle widescreen mode"), - "toggle_embed_original" => __("Toggle embed original")), + "toggle_full_text" => __("Toggle full article text via Readability")), __("Article selection") => array( "select_all" => __("Select all articles"), "select_unread" => __("Select unread"), @@ -1140,7 +1124,7 @@ "N" => "article_scroll_down", "P" => "article_scroll_up", "a W" => "toggle_widescreen", - "a e" => "toggle_embed_original", + "a e" => "toggle_full_text", "e" => "email_article", "a q" => "close_article", "a a" => "select_all", @@ -1298,6 +1282,7 @@ if ($entry->nodeName == 'img') { $entry->setAttribute('referrerpolicy', 'no-referrer'); + $entry->setAttribute('loading', 'lazy'); $entry->removeAttribute('width'); $entry->removeAttribute('height'); @@ -1768,9 +1753,6 @@ } function get_theme_path($theme) { - if ($theme == "default.php") - return "css/default.css"; - $check = "themes/$theme"; if (file_exists($check)) return $check; @@ -1889,12 +1871,13 @@ directory, its contents are displayed instead of git commit-based version, this could be generated based on source git tree commit used when creating the package */ - function get_version(&$git_commit = false, &$git_timestamp = false) { + function get_version(&$git_commit = false, &$git_timestamp = false, &$last_error = false) { global $ttrss_version; if (is_array($ttrss_version) && isset($ttrss_version['version'])) { $git_commit = $ttrss_version['commit']; $git_timestamp = $ttrss_version['timestamp']; + $last_error = $ttrss_version['last_error']; return $ttrss_version['version']; } else { @@ -1919,13 +1902,13 @@ $cwd = getcwd(); chdir($root_dir); - exec('git log --pretty='.escapeshellarg('%ct %h').' -n1 HEAD 2>&1', $output, $rc); + exec('git --no-pager log --pretty='.escapeshellarg('version: %ct %h').' -n1 HEAD 2>&1', $output, $rc); chdir($cwd); - if ($rc == 0) { - if (is_array($output) && count($output) > 0) { - list ($timestamp, $commit) = explode(" ", $output[0], 2); + if (is_array($output) && count($output) > 0) { + list ($test, $timestamp, $commit) = explode(" ", $output[0], 3); + if ($test == "version:") { $git_commit = $commit; $git_timestamp = $timestamp; @@ -1933,8 +1916,14 @@ $ttrss_version['commit'] = $commit; $ttrss_version['timestamp'] = $timestamp; } - } else { - user_error("Unable to determine version (using $root_dir): " . implode("\n", $output), E_USER_WARNING); + } + + if (!isset($ttrss_version['commit'])) { + $last_error = "Unable to determine version (using $root_dir): RC=$rc; OUTPUT=" . implode("\n", $output); + + $ttrss_version["last_error"] = $last_error; + + user_error($last_error, E_USER_WARNING); } } diff --git a/include/login_form.php b/include/login_form.php index 941321fc0..74f85f314 100755 --- a/include/login_form.php +++ b/include/login_form.php @@ -3,62 +3,85 @@ <html> <head> <title>Tiny Tiny RSS : Login</title> - <?php echo stylesheet_tag("css/default.css") ?> <link rel="shortcut icon" type="image/png" href="images/favicon.png"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <?php foreach (array("lib/prototype.js", "lib/dojo/dojo.js", "lib/dojo/tt-rss-layer.js", - "js/common.js", + "lib/prototype.js", + "js/common.js", + "js/utility.js", "errors.php?mode=js") as $jsfile) { echo javascript_tag($jsfile); } ?> + <style type="text/css"> + @media (prefers-color-scheme: dark) { + body { + background : #303030; + } + } + + body.css_loading * { + display : none; + } + </style> + <script type="text/javascript"> require({cache:{}}); </script> </head> -<body class="flat ttrss_utility ttrss_login"> +<body class="flat ttrss_utility ttrss_login css_loading"> <script type="text/javascript"> -require(['dojo/parser', "dojo/ready", 'dijit/form/Button','dijit/form/CheckBox', 'dijit/form/Form', - 'dijit/form/Select','dijit/form/TextBox','dijit/form/ValidationTextBox'],function(parser, ready){ - ready(function() { - parser.parse(); - - dijit.byId("bw_limit").attr("checked", Cookie.get("ttrss_bwlimit") == 'true'); - dijit.byId("login").focus(); - }); -}); - -function fetchProfiles() { - xhrJson("public.php", { op: "getprofiles", login: dijit.byId("login").attr('value') }, - (reply) => { - const profile = dijit.byId('profile'); - - profile.removeOption(profile.getOptions()); - - reply.each((p) => { - profile - .attr("disabled", false) - .addOption(p); - }); - }); -} - -function gotoRegForm() { - window.location.href = "register.php"; - return false; -} - -function bwLimitChange(elem) { - Cookie.set("ttrss_bwlimit", elem.checked, - <?php print SESSION_COOKIE_LIFETIME ?>); -} + const UtilityApp = { + previousLogin: "", + init: function() { /* invoked by UtilityJS */ + require(['dojo/parser', "dojo/ready", 'dijit/form/Button','dijit/form/CheckBox', 'dijit/form/Form', + 'dijit/form/Select','dijit/form/TextBox','dijit/form/ValidationTextBox'],function(parser, ready){ + ready(function() { + parser.parse(); + + dijit.byId("bw_limit").attr("checked", Cookie.get("ttrss_bwlimit") == 'true'); + dijit.byId("login").focus(); + }); + }); + }, + fetchProfiles: function() { + const login = dijit.byId("login").attr('value'); + + if (login && login != this.previousLogin) { + this.previousLogin = login; + + xhrJson("public.php", {op: "getprofiles", login: login}, + (reply) => { + const profile = dijit.byId('profile'); + + profile.removeOption(profile.getOptions()); + + reply.each((p) => { + profile + .attr("disabled", false) + .addOption(p); + }); + }); + } + }, + gotoRegForm: function() { + window.location.href = "register.php"; + return false; + }, + bwLimitChange: function(elem) { + Cookie.set("ttrss_bwlimit", elem.checked, + <?php print SESSION_COOKIE_LIFETIME ?>); + } + }; + + </script> <?php $return = urlencode(make_self_url()) ?> @@ -80,7 +103,9 @@ function bwLimitChange(elem) { <fieldset> <label><?php echo __("Login:") ?></label> <input name="login" id="login" dojoType="dijit.form.TextBox" type="text" - onchange="fetchProfiles()" onfocus="fetchProfiles()" onblur="fetchProfiles()" + onchange="UtilityApp.fetchProfiles()" + onfocus="UtilityApp.fetchProfiles()" + onblur="UtilityApp.fetchProfiles()" required="1" value="<?php echo $_SESSION["fake_login"] ?>" /> </fieldset> @@ -90,6 +115,9 @@ function bwLimitChange(elem) { <input type="password" name="password" required="1" dojoType="dijit.form.TextBox" class="input input-text" + onchange="UtilityApp.fetchProfiles()" + onfocus="UtilityApp.fetchProfiles()" + onblur="UtilityApp.fetchProfiles()" value="<?php echo $_SESSION["fake_password"] ?>"/> </fieldset> <?php if (strpos(PLUGINS, "auth_internal") !== FALSE) { ?> @@ -110,7 +138,7 @@ function bwLimitChange(elem) { <label> </label> <label id="bw_limit_label"><input dojoType="dijit.form.CheckBox" name="bw_limit" id="bw_limit" - type="checkbox" onchange="bwLimitChange(this)"> + type="checkbox" onchange="UtilityApp.bwLimitChange(this)"> <?php echo __("Use less traffic") ?></label> </fieldset> @@ -138,7 +166,7 @@ function bwLimitChange(elem) { <button dojoType="dijit.form.Button" type="submit" class="alt-primary"><?php echo __('Log in') ?></button> <?php if (defined('ENABLE_REGISTRATION') && ENABLE_REGISTRATION) { ?> - <button onclick="return gotoRegForm()" dojoType="dijit.form.Button"> + <button onclick="return UtilityApp.gotoRegForm()" dojoType="dijit.form.Button"> <?php echo __("Create new account") ?></button> <?php } ?> </fieldset> diff --git a/include/sanity_check.php b/include/sanity_check.php index b1b4571b2..3998416f5 100755 --- a/include/sanity_check.php +++ b/include/sanity_check.php @@ -207,7 +207,7 @@ <head> <title>Startup failed</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> - <link rel="stylesheet" type="text/css" href="css/default.css"> + <link rel="stylesheet" type="text/css" href="themes/light.css"> </head> <body class='sanity_failed claro ttrss_utility'> <div class="content"> |