diff --git a/admin/index.php b/admin/index.php
index cee968a..873c37e 100644
--- a/admin/index.php
+++ b/admin/index.php
@@ -33,6 +33,7 @@
$autopilot = optional_param('autopilot', 0, PARAM_BOOL);
$ignoreupgradewarning = optional_param('ignoreupgradewarning', 0, PARAM_BOOL);
$confirmplugincheck = optional_param('confirmplugincheck', 0, PARAM_BOOL);
+ $datarootconfirmsecure = optional_param('datarootconfirmsecure', 0, PARAM_BOOL);
/// check upgrade status first
if ($ignoreupgradewarning and !empty($_SESSION['upgraderunning'])) {
@@ -582,6 +583,11 @@
}
}
+/// Move this check befor the call to admin_get_root().
+ if (empty($CFG->datarootconfirmsecure) && !empty($datarootconfirmsecure)) {
+ set_config('datarootconfirmsecure',true);
+ }
+
$adminroot =& admin_get_root();
/// Check if there are any new admin settings which have still yet to be set
@@ -610,10 +616,17 @@
print_box(get_string('globalswarning', 'admin'), 'generalbox adminwarning');
}
- if (is_dataroot_insecure()) {
- print_box(get_string('datarootsecuritywarning', 'admin', $CFG->dataroot), 'generalbox adminwarning');
- }
+ if (empty($CFG->datarootconfirmsecure) && ($datarooturl = is_dataroot_insecure())) {
+ print_box_start('generalbox adminwarning');
+ print_string('datarootsecuritywarning', 'admin', $datarooturl);
+ $options = array();
+ $options['sesskey'] = $USER->sesskey;
+ $options['datarootconfirmsecure'] = 1;
+ print_single_button('index.php', $options, get_string('datarootconfirmsecure', 'admin'),
+ 'post', '', '', '', '', get_string('confirmverifieddataroot', 'admin'));
+ print_box_end();
+ }
if (defined('WARN_DISPLAY_ERRORS_ENABLED')) {
print_box(get_string('displayerrorswarning', 'admin'), 'generalbox adminwarning');
}
diff --git a/admin/settings/top.php b/admin/settings/top.php
index a892b34..7f385bf 100644
--- a/admin/settings/top.php
+++ b/admin/settings/top.php
@@ -13,7 +13,11 @@ if (get_site()) {
$hassiteconfig = true;
}
-$ADMIN->add('root', new admin_externalpage('adminnotifications', get_string('notifications'), "$CFG->wwwroot/$CFG->admin/index.php"));
+$adminnotifications = get_string('notifications');
+if (empty($CFG->datarootconfirmsecure) && is_dataroot_insecure()) {
+ $adminnotifications .= get_string('securitywarningspending', 'admin');
+}
+$ADMIN->add('root', new admin_externalpage('adminnotifications', $adminnotifications, "$CFG->wwwroot/$CFG->admin/index.php"));
// hidden upgrade script
$ADMIN->add('root', new admin_externalpage('upgradesettings', get_string('upgradesettings', 'admin'), "$CFG->wwwroot/$CFG->admin/upgradesettings.php", 'moodle/site:config', true));
diff --git a/install.php b/install.php
index 99a34fc..10c33ad 100644
--- a/install.php
+++ b/install.php
@@ -236,6 +236,13 @@ if (isset($_GET['download'])) {
/// Check the directory settings
+if (($nextstage == DIRECTORY)) {
+ // Each time we are going to visit the directory settings page, clear the
+ // insecure dataroot confirmation flag (so the user needs to confirm it
+ // again) just in case.
+ unset($INSTALL['datarootconfirmsecure']);
+}
+
if ($INSTALL['stage'] == DIRECTORY) {
error_reporting(0);
@@ -261,7 +268,14 @@ if ($INSTALL['stage'] == DIRECTORY) {
if (make_upload_directory('sessions', false) === false ) {
$errormsg .= get_string('datarooterror', 'install').'
';
}
- if ($fh) fclose($fh);
+ $CFG->wwwroot = $INSTALL['wwwroot']; // We need wwwroot inside is_dataroot_insecure.
+ if (($datarooturl = is_dataroot_insecure()) && (empty($INSTALL['datarootconfirmsecure']))) {
+ if (empty($errormsg)) {
+ // We don't touch $errormsg here, as the error message is printed inside the form_table
+ // function, but we need to make sure we stay in the stage.
+ $nextstage = DIRECTORY;
+ }
+ }
if (!empty($errormsg)) $nextstage = DIRECTORY;
@@ -746,7 +760,7 @@ if ($nextstage == SAVE) {
//==========================================================================//
function form_table($nextstage = WELCOME, $formaction = "install.php") {
- global $INSTALL, $db;
+ global $INSTALL, $db, $CFG;
/// Print the standard form if we aren't in the DOWNLOADLANG page
/// because it has its own form.
@@ -800,6 +814,15 @@ function form_table($nextstage = WELCOME, $formaction = "install.php") {
break;
case DIRECTORY: /// Directory settings
+ if (!empty($INSTALL['wwwrootform'])) {
+ $CFG->wwwroot = $INSTALL['wwwrootform'];
+ if (($datarooturl = is_dataroot_insecure()) && (empty($INSTALL['datarootconfirmsecure']))) {
+ $errormsg = get_string('datarootinsecureerror', 'install', $datarooturl);
+ echo "
$errormsg
\n"; + echo '