///==========================================================================//
/// We are doing this in stages
-/// 1. Welcome and language settings
+/// 0. Welcome and language settings
+/// 1. Compatibility
/// 2. Database settings
/// 3. Host settings
/// 4. Administration directory name
///==========================================================================//
+
/// Begin the session as we are holding all information in a session
/// variable until the end.
$INSTALL = &$_SESSION['INSTALL']; // Makes it easier to reference
-if ( empty($INSTALL['language']) and empty($_POST['language']) ) { // First time through this script
+
+/// If it's our first time through this script then we need to set some default values
+
+if ( empty($INSTALL['language']) and empty($_POST['language']) ) {
/// set defaults
$INSTALL['language'] = 'en';
$INSTALL['admindirname'] = 'admin';
- $INSTALL['stage'] = 1;
+ $INSTALL['stage'] = 0;
}
//==========================================================================//
/// Fake some settings so that we can use selected functions from moodlelib.php and weblib.php
+
$SESSION->lang = (!empty($_POST['language'])) ? $_POST['language'] : $INSTALL['language'];
$CFG->dirroot = $INSTALL['dirroot'];
$CFG->dataroot = $INSTALL['dataroot'];
$CFG->directorypermissions = 0777;
+/// Include some moodle libraries
+
require_once('./lib/moodlelib.php');
require_once('./lib/weblib.php');
require_once('./lib/adodb/adodb.inc.php');
list($INSTALL['wwwroot'], $xtra) = explode('/install.php', qualified_me());
}
-$stagetext = array(1 => get_string('chooselanguage', 'install'),
- get_string('directorysettings', 'install'),
- get_string('databasesettings', 'install'),
- get_string('admindirsetting', 'install'),
- get_string('configurationcomplete', 'install')
+$stagetext = array(0 => get_string('chooselanguage', 'install'),
+ get_string('compatibilitysettings', 'install'),
+ get_string('directorysettings', 'install'),
+ get_string('databasesettings', 'install'),
+ get_string('admindirsetting', 'install'),
+ get_string('configurationcomplete', 'install')
);
+
+
+//==========================================================================//
+
+/// Are we in help mode?
+
+if (isset($_GET['help'])) {
+ $nextstage = -1;
+}
+
+
+
//==========================================================================//
/// Was data submitted?
-if (!empty($_POST['stage'])) {
+
+if (isset($_POST['stage'])) {
/// Get the stage for which the form was set and the next stage we are going to
$nextstage = $_POST['stage'] - 1;
}
- if ($nextstage < 1) $nextstage = 1;
+ if ($nextstage < 0) $nextstage = 0;
/// Store any posted data
} else {
$goforward = true;
- $nextstage = 1;
+ $nextstage = 0;
}
//==========================================================================//
/// Check the directory settings
+
if ($INSTALL['stage'] == 2) {
error_reporting(0);
/// Check database settings if stage 3 data submitted
/// Try to connect to the database. If that fails then try to create the database
+
if ($INSTALL['stage'] == 3) {
if (empty($INSTALL['dbname'])) {
$INSTALL['dbname'] = 'moodle';
}
- /// different format for postgres7
- if ($INSTALL['dbtype'] == 'postgres7') {
+ /// different format for postgres7 by socket
+ if ($INSTALL['dbtype'] == 'postgres7' and ($INSTALL['dbhost'] == 'localhost' || $INSTALL['dbhost'] == '127.0.0.1')) {
$INSTALL['dbhost'] = "user='{$INSTALL['dbuser']}' password='{$INSTALL['dbpass']}' dbname='{$INSTALL['dbname']}'";
+ $INSTALL['dbuser'] = '';
+ $INSTALL['dbpass'] = '';
+ $INSTALL['dbname'] = '';
+
if ($INSTALL['prefix'] == '') { /// must have a prefix
$INSTALL['prefix'] = 'mdl_';
}
/// Display or print the data
/// Put the data into a string
/// Try to open config file for writing.
+
if ($nextstage == 5) {
$str = '<?php /// Moodle Configuration File '."\n";
<body>
-<h1 align="center">MOODLE INSTALL</h1>
+<table align="center">
+</table>
+
+
+<?php
+if (isset($_GET['help'])) {
+ print_install_help($_GET['help']);
+} else {
+?>
+
<table class="main" align="center" cellpadding="3" cellspacing="0">
<tr>
- <td class="td_mainheading"><p class="p_mainheading"><?php echo $stagetext[$nextstage] ?></p></td>
+ <td class="td_mainlogo">
+ <p class="p_mainlogo"><img src="pix/moodlelogo-med.gif" width="240" height="60"></p>
+ </td>
+ <td class="td_mainlogo" valign="bottom">
+ <p class="p_mainheader"><?php print_string('installation', 'install') ?></p>
+ </td>
+ </tr>
+
+ <tr>
+ <td class="td_mainheading" colspan="2">
+ <p class="p_mainheading"><?php echo $stagetext[$nextstage] ?></p>
+ </td>
</tr>
<tr>
- <td class="td_main">
+ <td class="td_main" colspan="2">
<?php
echo "</div>\n";
echo "<hr />\n";
}
- echo "<p>(<a href=\"index.php?lang={$INSTALL['language']}\">Continue</a>)</p>\n";
+ $options = array();
+ $options['lang'] = $INSTALL['language'];
+ print_single_button("index.php", $options, get_string('continue')." »");
} else {
$formaction = (isset($_GET['configfile'])) ? "install.php?configfile=".$_GET['configfile'] : "install.php";
form_table($nextstage, $formaction);
</tr>
</table>
+<?php
+}
+?>
+
</body>
</html>
//==========================================================================//
-function form_table($nextstage = 1, $formaction = "install.php") {
+function form_table($nextstage = 0, $formaction = "install.php") {
global $INSTALL;
/// standard lines for all forms
<?php
/// what we do depends on the stage we're at
switch ($nextstage) {
- case 1: /// Language settings
+ case 0: /// Language settings
?>
<tr>
<td class="td_left"><p><?php print_string('language') ?></p></td>
</tr>
<?php
+ break;
+ case 1: /// Compatibilty check
+ $compatsuccess = true;
+
+ /// Check that PHP is of a sufficient version
+ print_compatibility_row(check_php_version("4.1.0"), get_string('PHPversion', 'install'), get_string('PHPversionerror', 'install'), 'phpversionhelp');
+ /// Check safe mode
+ print_compatibility_row(!ini_get_bool('safe_mode'), get_string('safemode', 'install'), get_string('safemodeerror', 'install'), 'safemodehelp');
+ /// Check session auto start
+ print_compatibility_row(!ini_get_bool('session.auto_start'), get_string('sessionautostart', 'install'), get_string('sessionautostarterror', 'install'), 'sessionautostarthelp');
+ /// Check session save path
+ print_compatibility_row(!ini_get_bool('session.save_path'), get_string('sessionsavepath', 'install'), get_string('sessionsavepatherror', 'install'), 'sessionsavepathhelp');
+ /// Check magic quotes
+ print_compatibility_row(!ini_get_bool('magic_quotes_runtime'), get_string('magicquotesruntime', 'install'), get_string('magicquotesruntimeerror', 'install'), 'magicquotesruntimehelp');
+ /// Check file uploads
+ print_compatibility_row(ini_get_bool('file_uploads'), get_string('fileuploads', 'install'), get_string('fileuploadserror', 'install'), 'fileuploadshelp');
+ /// Check GD version
+ print_compatibility_row(check_gd_version(), get_string('gdversion', 'install'), get_string('gdversionerror', 'install'), 'gdversionhelp');
+ /// Check memory limit
+ print_compatibility_row(check_memory_limit(), get_string('memorylimit', 'install'), get_string('memorylimiterror', 'install'), 'memorylimithelp');
+
+
break;
case 2: /// Directory settings
?>
<tr>
<td align="left">
- <?php echo ($nextstage > 1) ? "<input type=\"submit\" name=\"prev\" value=\"".get_string('previous')."\" />\n" : " \n" ?>
+ <?php echo ($nextstage > 0) ? "<input type=\"submit\" name=\"prev\" value=\"« ".get_string('previous')."\" />\n" : " \n" ?>
</td>
+ <?php if ($nextstage == 1) echo "<td> </td>\n"; ?>
<td align="right">
- <?php echo ($nextstage < 5) ? "<input type=\"submit\" name=\"next\" value=\"".get_string('next')."\" />\n" : " \n" ?>
+ <?php echo ($nextstage < 5) ? "<input type=\"submit\" name=\"next\" value=\"".get_string('next')." »\" />\n" : " \n" ?>
</td>
</tr>
+//==========================================================================//
+
+function print_compatibility_row($success, $testtext, $errormessage, $helpfield='') {
+ echo "<tr>\n";
+ echo "<td class=\"td_left\" valign=\"top\" nowrap><p>$testtext</p></td>\n";
+ if ($success) {
+ echo "<td valign=\"top\"><p class=\"p_pass\">".get_string('pass', 'install')."</p></td>\n";
+ echo "<td valign=\"top\"> </td>\n";
+ } else {
+ echo "<td valign=\"top\"><p class=\"p_fail\">".get_string('fail', 'install')."</p></td>\n";
+ echo "<td valign=\"top\">";
+ echo "<p>$errormessage ";
+ install_helpbutton("install.php?help=$helpfield");
+ echo "</p></td>\n";
+ }
+ echo "</tr>\n";
+ return $success;
+}
+
+
+//==========================================================================//
+
+function install_helpbutton($url, $title='') {
+ if ($title == '') {
+ $title = get_string('help');
+ }
+ echo "<a href=\"javascript: void(0)\">";
+ echo "<img src=\"./pix/help.gif\" height=\"17\" width=\"22\" alt=\"$title\"";
+ echo "border=\"0\" align=\"absmiddle\" title=\"$title\" ";
+ echo "onClick=\"return window.open('$url', 'Help', 'menubar=0,location=0,scrollbars,resizable,width=500,height=400')\">";
+ echo "</a>\n";
+}
+
+
+
+//==========================================================================//
+
+function print_install_help($help) {
+ echo "<p class=\"p_help\">";
+ switch ($help) {
+ case 'phpversionhelp':
+ print_string($help, 'install', phpversion());
+ break;
+ case 'memorylimithelp':
+ print_string($help, 'install', ini_get('memory_limit'));
+ break;
+ default:
+ print_string($help, 'install');
+ }
+ echo "</p>\n";
+}
+
+
+//==========================================================================//
+
+function get_memory_limit() {
+ if ($limit = ini_get('memory_limit')) {
+ return $limit;
+ } else {
+ return get_cfg_var('memory_limit');
+ }
+}
+
+//==========================================================================//
+
+function check_memory_limit() {
+
+ /// if limit is already 16M or more then we don't care if we can change it or not
+ if ((int)str_replace('M', '', get_memory_limit()) >= 16) {
+ return true;
+ }
+
+ /// Otherwise, see if we can change it ourselves
+ @ini_set('memory_limit', '16M');
+ return ((int)str_replace('M', '', get_memory_limit()) >= 16);
+}
+
//==========================================================================//
function css_styles() {
<style type="text/css">
body { background-color: #ffeece; }
- p { font-family: helvetica, arial, sans-serif; size: normal; }
+ p {
+ font-family: helvetica, arial, sans-serif;
+ font-size: 10pt;
+ }
a { text-decoration: none; color: blue; }
.errormsg {
color: red;
font-weight: bold;
}
+ blockquote {
+ font-family: helvetica, arial, sans-serif;
+ font-size: 10pt;
+ }
.install_table {
width: 500px;
}
}
.td_mainheading {
background-color: #fee6b9;
+ padding: 10px;
}
.td_main {
text-align: center;
}
+ .td_mainlogo {
+ }
+ .p_mainlogo {
+ }
.p_mainheading {
- font-size: 10pt;
+ font-size: 11pt;
+ }
+ .p_mainheader{
+ text-align: right;
+ font-size: 20pt;
+ font-weight: bold;
+ }
+ .p_pass {
+ color: green;
+ font-weight: bold;
+ }
+ .p_fail {
+ color: red;
+ font-weight: bold;
+ }
+ .p_help {
+ text-align: center;
+ font-family: helvetica, arial, sans-serif;
+ font-size: 14pt;
+ font-weight: bold;
+ color: #333333;
}
-
</style>
<?php
$string['admindirerror'] = 'The admin directory specified is incorrect';\r
$string['admindirname'] = 'Admin Directory';\r
$string['admindirsetting'] = "\r
- <p>A very few webhosts use /admin as a special URL for you to access a \r
+ A very few webhosts use /admin as a special URL for you to access a \r
control panel or something. Unfortunately this conflicts with the \r
standard location for the Moodle admin pages. You can fix this by \r
renaming the admin directory in your installation, and putting that \r
- new name here. For example: <blockquote> moodleadmin</blockquote>. \r
- This will fix admin links in Moodle.</p>";\r
+ new name here. For example: <br/> <br /><b>moodleadmin</b><br /> <br />\r
+ This will fix admin links in Moodle.";\r
$string['chooselanguage'] = 'Choose a language';\r
+$string['compatibilitysettings'] = 'The following is a check on the compatibility of the server to run Moodle';\r
$string['configfilenotwritten'] = "The installer script was not able to automatically create a config.php file containing your chosen settings. Please copy the following code into a file named config.php within the root directory of Moodle.";\r
$string['configfilewritten'] = "config.php has been successfully created";\r
$string['configurationcomplete'] = 'Configuration completed';\r
\r
$string['database'] = 'Database';\r
$string['databasesettings'] = "\r
- <p>Now you need to configure the database where most Moodle data\r
+ Now you need to configure the database where most Moodle data\r
will be stored. This database must already have been created\r
- and a username and password created to access it.</p>\r
- <p>Type: mysql or postgres7<br />\r
- Host Server: eg localhost or db.isp.com<br />\r
- Name: database name, eg moodle<br />\r
- User: your database username<br />\r
- Password: your database password<br />\r
- Tables Prefix: prefix to use for all table names</p>";\r
+ and a username and password created to access it.<br/>\r
+ <br /> <br />\r
+ <b>Type:</b> mysql or postgres7<br />\r
+ <b>Host:</b> eg localhost or db.isp.com<br />\r
+ <b>Name:</b> database name, eg moodle<br />\r
+ <b>User:</b> your database username<br />\r
+ <b>Password:</b> your database password<br />\r
+ <b>Tables Prefix:</b> prefix to use for all table names";\r
$string['dataroot'] = 'Data';\r
$string['datarooterror'] = "The 'Data' setting is incorrect";\r
$string['dbconnectionerror'] = 'Database connection error. Please check your database settings';\r
$string['dbprefix'] = 'Tables prefix';\r
$string['dbtype'] = 'Type';\r
$string['directorysettings'] = "\r
- <p><b>WWW:</b>\r
+ <b>WWW:</b>\r
You need to tell Moodle where it is located. Specify the full\r
web address to where moodle has been installed. If your web site \r
is accessible via multiple URLs then choose the most natural one \r
- that your students would use. Do not include a trailing slash</p>\r
- <p><b>Directory:</b>\r
+ that your students would use. Do not include a trailing slash<br/> <br/>\r
+ <b>Directory:</b>\r
Specify the full OS directory path to this same location\r
- Make sure the upper/lower case is correct</p>\r
- <p><b>Data:</b>\r
+ Make sure the upper/lower case is correct<br/> <br/>\r
+ <b>Data:</b>\r
You need a place where Moodle can save uploaded files. This\r
directory should be readable AND WRITEABLE by the web server user \r
(usually 'nobody' or 'apache'), but it should not be accessible \r
- directly via the web.</p>";\r
+ directly via the web.";\r
\r
$string['dirroot'] = 'Directory';\r
$string['dirrooterror'] = "The 'Directory' setting was incorrect. Try the following setting";\r
+$string['fail'] = 'Fail';\r
+$string['fileuploads'] = 'File Uploads';\r
+$string['fileuploadserror'] = 'This should be on';\r
+$string['fileuploadshelp'] = 'Moodle requires file uploading to be switched on';\r
+$string['gdversion'] = 'GD version';\r
+$string['gdversionerror'] = 'The GD library should be present to process and create images';\r
+$string['gdversionhelp'] = 'The GD library should be present to process and create images';\r
+$string['installation'] = 'Installation';\r
+$string['memorylimit'] = 'Memory Limit';\r
+$string['memorylimiterror'] = 'The memory limit needs to be set to 16M or more or be changeable';\r
+$string['memorylimithelp'] = "The memory limit needs to be set to 16M or more or be changeable. Your current memory limit is set to \$a";\r
+$string['pass'] = 'Pass';\r
+$string['PHPversion'] = 'PHP version';\r
+$string['PHPversionerror'] = 'PHP version must be at least 4.1.0';\r
+$string['phpversionhelp'] = "Moodle requires a PHP version of at least 4.1.0. You are currently running version \$a";\r
+$string['safemode'] = 'Safe Mode';\r
+$string['safemodeerror'] = 'Moodle can not handle files properly with safe mode on';\r
+$string['safemodehelp'] = 'Moodle can not handle files properly with safe mode on';\r
+$string['sessionautostart'] = 'Session Auto Start';\r
+$string['sessionautostarterror'] = 'This should be off';\r
+$string['sessionautostarthelp'] = 'Session auto start should be turned off';\r
+$string['sessionsavepath'] = 'Session Save Path';\r
+$string['sessionsavepatherror'] = 'It seems your server does not support sessions';\r
+$string['sessionsavepathhelp'] = 'Moodle requires session support';\r
+$string['magicquotesruntime'] = 'Magic Quotes Run Time';\r
+$string['magicquotesruntimeerror'] = 'This should be off';\r
+$string['magicquotesruntimehelp'] = 'Magic quotes should be turned off';\r
$string['wwwroot'] = 'WWW';\r
$string['wwwrooterror'] = "The 'WWW' setting is incorrect";\r
\r