add basic safe mode which doesn't load any user plugins

This commit is contained in:
Andrew Dolgov 2020-09-18 15:48:22 +03:00
parent 3588d5186e
commit 03a337a660
4 changed files with 15 additions and 1 deletions

View File

@ -673,6 +673,7 @@ class Handler_Public extends Handler {
$login = clean($_POST["login"]);
$password = clean($_POST["password"]);
$remember_me = clean($_POST["remember_me"]);
$safe_mode = checkbox_to_sql_bool(clean($_POST["safe_mode"]));
if ($remember_me) {
@session_set_cookie_params(SESSION_COOKIE_LIFETIME);
@ -689,6 +690,7 @@ class Handler_Public extends Handler {
$_SESSION["ref_schema_version"] = get_schema_version(true);
$_SESSION["bw_limit"] = !!clean($_POST["bw_limit"]);
$_SESSION["safe_mode"] = $safe_mode;
if (clean($_POST["profile"])) {

View File

@ -858,6 +858,10 @@ class Pref_Prefs extends Handler_Protected {
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(

View File

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

View File

@ -146,6 +146,14 @@
<?php echo __("Does not display images in articles, reduces automatic refreshes."); ?>
</div>
<fieldset class="narrow">
<label> </label>
<label ><input dojoType="dijit.form.CheckBox" name="safe_mode" id="safe_mode"
type="checkbox">
<?php echo __("Safe mode (no plugins)") ?></label>
</fieldset>
<?php if (SESSION_COOKIE_LIFETIME > 0) { ?>
<fieldset class="narrow">