]> git.wh0rd.org - tt-rss.git/blobdiff - classes/pref/prefs.php
simplify error handling
[tt-rss.git] / classes / pref / prefs.php
index d36e31f0b02d7c9651083990b21f39525c83a43d..5ec7079dc8a405b4cd67816b5096f6a7d15bd434 100644 (file)
@@ -164,7 +164,7 @@ class Pref_Prefs extends Handler_Protected {
 
                global $access_level_names;
 
-               $prefs_blacklist = array("STRIP_UNSAFE_TAGS", "REVERSE_HEADLINES",
+               $prefs_blacklist = array("ALLOW_DUPLICATE_POSTS", "STRIP_UNSAFE_TAGS", "REVERSE_HEADLINES",
                        "SORT_HEADLINES_BY_FEED_DATE", "DEFAULT_ARTICLE_LIMIT",
                        "FEEDS_SORT_BY_UNREAD");
 
@@ -226,8 +226,8 @@ class Pref_Prefs extends Handler_Protected {
 
                print "</table>";
 
-               print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pref-prefs\">";
-               print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"changeemail\">";
+               print_hidden("op", "pref-prefs");
+               print_hidden("method", "changeemail");
 
                print "<p><button dojoType=\"dijit.form.Button\" type=\"submit\">".
                        __("Save data")."</button>";
@@ -305,8 +305,8 @@ class Pref_Prefs extends Handler_Protected {
 
                        print "</table>";
 
-                       print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pref-prefs\">";
-                       print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"changepassword\">";
+                       print_hidden("op", "pref-prefs");
+                       print_hidden("method", "changepassword");
 
                        print "<p><button dojoType=\"dijit.form.Button\" type=\"submit\">".
                                __("Change password")."</button>";
@@ -351,8 +351,8 @@ class Pref_Prefs extends Handler_Protected {
 
                                print "</table>";
 
-                               print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pref-prefs\">";
-                               print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"otpdisable\">";
+                               print_hidden("op", "pref-prefs");
+                               print_hidden("method", "otpdisable");
 
                                print "<p><button dojoType=\"dijit.form.Button\" type=\"submit\">".
                                        __("Disable OTP")."</button>";
@@ -371,8 +371,8 @@ class Pref_Prefs extends Handler_Protected {
 
                                        print "<form dojoType=\"dijit.form.Form\" id=\"changeOtpForm\">";
 
-                                       print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pref-prefs\">";
-                                       print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"otpenable\">";
+                                       print_hidden("op", "pref-prefs");
+                                       print_hidden("method", "otpenable");
 
                                        print "<script type=\"dojo/method\" event=\"onSubmit\" args=\"evt\">
                                        evt.preventDefault();
@@ -565,11 +565,13 @@ class Pref_Prefs extends Handler_Protected {
 
                        } else if ($pref_name == "USER_CSS_THEME") {
 
-                               $themes = array_merge(glob("themes/*.css"), glob("themes.local/*.css"));
+                               $themes = array_merge(glob("themes/*.php"), glob("themes/*.css"), glob("themes.local/*.css"));
                                $themes = array_map("basename", $themes);
                                $themes = array_filter($themes, "theme_valid");
                                asort($themes);
 
+                               if (!theme_valid($value)) $value = "default.php";
+
                                print_select($pref_name, $value, $themes,
                                        'dojoType="dijit.form.Select"');
 
@@ -622,6 +624,8 @@ class Pref_Prefs extends Handler_Protected {
                                $cert_serial = htmlspecialchars(get_ssl_certificate_id());
                                $has_serial = ($cert_serial) ? "false" : "true";
 
+                               print "<br/>";
+
                                print " <button dojoType=\"dijit.form.Button\" disabled=\"$has_serial\"
                                        onclick=\"insertSSLserial('$cert_serial')\">" .
                                        __('Register') . "</button>";
@@ -654,7 +658,7 @@ class Pref_Prefs extends Handler_Protected {
 
                $listed_boolean_prefs = htmlspecialchars(join(",", $listed_boolean_prefs));
 
-               print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"boolean_prefs\" value=\"$listed_boolean_prefs\">";
+               print_hidden("boolean_prefs", "$listed_boolean_prefs");
 
                PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB_SECTION,
                        "hook_prefs_tab_section", "prefPrefsPrefsInside");
@@ -662,8 +666,8 @@ class Pref_Prefs extends Handler_Protected {
                print '</div>'; # inside pane
                print '<div dojoType="dijit.layout.ContentPane" region="bottom">';
 
-               print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pref-prefs\">";
-               print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"saveconfig\">";
+               print_hidden("op", "pref-prefs");
+               print_hidden("method", "saveconfig");
 
                print "<div dojoType=\"dijit.form.ComboButton\" type=\"submit\">
                        <span>".__('Save configuration')."</span>
@@ -682,16 +686,6 @@ class Pref_Prefs extends Handler_Protected {
 
                print "&nbsp;";
 
-               /* $checked = $_SESSION["prefs_show_advanced"] ? "checked='1'" : "";
-
-               print "<input onclick='toggleAdvancedPrefs()'
-                               id='prefs_show_advanced'
-                               dojoType=\"dijit.form.CheckBox\"
-                               $checked
-                               type=\"checkbox\"></input>
-                               <label for='prefs_show_advanced'>" .
-                               __("Show additional preferences") . "</label>"; */
-
                PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB_SECTION,
                        "hook_prefs_tab_section", "prefPrefsPrefsOutside");
 
@@ -707,6 +701,10 @@ class Pref_Prefs extends Handler_Protected {
 
                print_notice(__("Download more plugins at tt-rss.org <a class=\"visibleLink\" target=\"_blank\" href=\"http://tt-rss.org/forum/viewforum.php?f=22\">forums</a> or <a target=\"_blank\" class=\"visibleLink\" href=\"http://tt-rss.org/wiki/Plugins\">wiki</a>."));
 
+               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.");
+               }
+
                print "<form dojoType=\"dijit.form.Form\" id=\"changePluginsForm\">";
 
                print "<script type=\"dojo/method\" event=\"onSubmit\" args=\"evt\">
@@ -726,8 +724,8 @@ class Pref_Prefs extends Handler_Protected {
                }
                </script>";
 
-               print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pref-prefs\">";
-               print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"setplugins\">";
+               print_hidden("op", "pref-prefs");
+               print_hidden("method", "setplugins");
 
                print "<table width='100%' class='prefPluginsList'>";
 
@@ -744,13 +742,13 @@ class Pref_Prefs extends Handler_Protected {
                $user_enabled = array_map("trim", explode(",", get_pref("_ENABLED_PLUGINS")));
 
                $tmppluginhost = new PluginHost();
-               $tmppluginhost->load_all($tmppluginhost::KIND_ALL, $_SESSION["uid"]);
+               $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] && strpos($name, "example") === FALSE) {
+                       if ($about[3]) {
                                if (in_array($name, $system_enabled)) {
                                        $checked = "checked='1'";
                                } else {
@@ -768,7 +766,7 @@ class Pref_Prefs extends Handler_Protected {
                                print "<td><label><img src='images/$plugin_icon' alt=''> $name</label></td>";
                                print "<td>" . htmlspecialchars($about[1]);
                                if (@$about[4]) {
-                                       print " &mdash; <a target=\"_blank\" class=\"visibleLink\"
+                                       print " &mdash; <a target=\"_blank\" rel=\"noopener noreferrer\" class=\"visibleLink\"
                                                href=\"".htmlspecialchars($about[4])."\">".__("more info")."</a>";
                                }
                                print "</td>";
@@ -800,7 +798,7 @@ class Pref_Prefs extends Handler_Protected {
                foreach ($tmppluginhost->get_plugins() as $name => $plugin) {
                        $about = $plugin->about();
 
-                       if (!$about[3] && strpos($name, "example") === FALSE) {
+                       if (!$about[3]) {
 
                                if (in_array($name, $system_enabled)) {
                                        $checked = "checked='1'";
@@ -827,7 +825,7 @@ class Pref_Prefs extends Handler_Protected {
                                print "<td><label for='FPCHK-$name'><img src='images/$plugin_icon' alt=''> $name</label></td>";
                                print "<td><label for='FPCHK-$name'>" . htmlspecialchars($about[1]) . "</label>";
                                if (@$about[4]) {
-                                       print " &mdash; <a target=\"_blank\" class=\"visibleLink\"
+                                       print " &mdash; <a target=\"_blank\" rel=\"noopener noreferrer\" class=\"visibleLink\"
                                                href=\"".htmlspecialchars($about[4])."\">".__("more info")."</a>";
                                }
                                print "</td>";
@@ -967,13 +965,13 @@ class Pref_Prefs extends Handler_Protected {
 
                print_notice(T_sprintf("You can override colors, fonts and layout of your currently selected theme with custom CSS declarations here. <a target=\"_blank\" class=\"visibleLink\" href=\"%s\">This file</a> can be used as a baseline.", "css/tt-rss.css"));
 
-               print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"rpc\">";
-               print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"setpref\">";
-               print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"key\" value=\"USER_STYLESHEET\">";
+               print_hidden("op", "rpc");
+               print_hidden("method", "setpref");
+               print_hidden("key", "USER_STYLESHEET");
 
                print "<table width='100%'><tr><td>";
                print "<textarea dojoType=\"dijit.form.SimpleTextarea\"
-                       style='font-size : 12px; width : 100%; height: 200px;'
+                       style='font-size : 12px; width : 98%; height: 200px;'
                        placeHolder='body#ttrssMain { font-size : 14px; };'
                        name='value'>$value</textarea>";
                print "</td></tr></table>";