From add47d44d087d42efe90abef0fb5b29d9f12d189 Mon Sep 17 00:00:00 2001
From: skodak
Date: Mon, 28 Aug 2006 20:54:16 +0000
Subject: [PATCH] check suggested dataroot in install.php SC#295
---
install.php | 15 +++++++++++++++
lang/en_utf8/install.php | 2 +-
2 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/install.php b/install.php
index 67dbab7131..438cb9949d 100644
--- a/install.php
+++ b/install.php
@@ -125,6 +125,7 @@ $CFG->running_installer = true;
/// Include some moodle libraries
+require_once('./lib/adminlib.php');
require_once('./lib/setuplib.php');
require_once('./lib/moodlelib.php');
require_once('./lib/weblib.php');
@@ -145,6 +146,20 @@ $db = &ADONewConnection($INSTALL['dbtype']);
if ($INSTALL['wwwroot'] == '') {
list($INSTALL['wwwroot'], $xtra) = explode('/install.php', qualified_me());
$INSTALL['wwwrootform'] = $INSTALL['wwwroot'];
+
+ // now try to guess the correct dataroot not accessible via web
+ $CFG->wwwroot = $INSTALL['wwwroot'];
+ $i = 0; //safety check - dirname might return some unexpected results
+ while(is_dataroot_insecure()) {
+ $parrent = dirname($CFG->dataroot);
+ $i++;
+ if ($parrent == '/' or $parrent == '.' or preg_match('/^[a-z]:\\?$/i', $parrent) or ($i > 100)) {
+ $CFG->dataroot = ''; //can not find secure location for dataroot
+ break;
+ }
+ $CFG->dataroot = dirname($parrent).'/moodledata';
+ }
+ $INSTALL['dataroot'] = $CFG->dataroot;
}
$headstagetext = array(WELCOME => get_string('chooselanguagehead', 'install'),
diff --git a/lang/en_utf8/install.php b/lang/en_utf8/install.php
index 83e271a0f7..d7cc4b67c0 100644
--- a/lang/en_utf8/install.php
+++ b/lang/en_utf8/install.php
@@ -92,7 +92,7 @@ Make sure the upper/lower case is correct.
Data Directory:
You need a place where Moodle can save uploaded files. This
directory should be readable AND WRITEABLE by the web server user
-(usually \'nobody\' or \'apache\'), but it should not be accessible
+(usually \'nobody\' or \'apache\'), but it must not be accessible
directly via the web.
';
$string['directorysettingshead'] = 'Please confirm the locations of this Moodle installation';
$string['directorysettingssub'] ='Web Address:
--
2.39.5