]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-17458 rewritten installer
authorskodak <skodak>
Sat, 7 Feb 2009 10:20:33 +0000 (10:20 +0000)
committerskodak <skodak>
Sat, 7 Feb 2009 10:20:33 +0000 (10:20 +0000)
17 files changed:
install.php
install/lang/en_utf8/installer.php
install/stringnames.txt
lang/en_utf8/install.php
lib/dml/adodb_moodle_database.php
lib/dml/moodle_database.php
lib/dml/mysqli_adodb_moodle_database.php
lib/dml/mysqli_native_moodle_database.php
lib/dml/oci_native_moodle_database.php
lib/dml/pdo_moodle_database.php
lib/dml/pgsql_native_moodle_database.php
lib/dml/postgres7_adodb_moodle_database.php
lib/dml/sqlite3_pdo_moodle_database.php
lib/installlib.php
lib/moodlelib.php
lib/setuplib.php
lib/textlib.class.php

index 199b798fd818face455fd29cd12f6cded43878f7..992146c94088ed5e0579a8e0752097b206ff0684 100644 (file)
 <?php /// $Id$
       /// install.php - helps admin user to create a config.php file
 
-/// If config.php exists already then we are not needed.
 
-if (file_exists('./config.php')) {
-    header('Location: index.php');
-    die;
+if (isset($_REQUEST['lang'])) {
+    $lang = eregi_replace('[^A-Za-z0-9_-]', '', $_REQUEST['lang']);
 } else {
-    $configfile = './config.php';
+    $lang = 'en_utf8';
 }
 
-die('Working on a new installer, please create config.php manually. Sorry for the complication, skodak ;-)');
-
-///==========================================================================//
-/// We are doing this in stages
-define ('WELCOME',            0); /// 0. Welcome and language settings
-define ('COMPATIBILITY',      1); /// 1. Compatibility
-define ('DIRECTORY',          2); /// 2. Directory settings
-define ('DATABASE',           3); /// 2. Database settings
-define ('ADMIN',              4); /// 4. Administration directory name
-define ('ENVIRONMENT',        5); /// 5. Administration directory name
-define ('DOWNLOADLANG',       6); /// 6. Load complete lang from download.moodle.org
-define ('SAVE',               7); /// 7. Save or display the settings
-define ('REDIRECT',           8); /// 8. Redirect to index.php
-///==========================================================================//
-
-
-/// This has to be defined to avoid a notice in current_language()
-define('SITEID', 0);
-
-/// Defined to avoid some notices in weblib and so on. This is a web installer, so set it to false
-define('CLI_SCRIPT', false);
-
-/// Begin the session as we are holding all information in a session
-/// variable until the end.
-
-session_name('MoodleSession');
-@session_start();
-
-/// make sure PHP errors are displayed to help diagnose problems
-@error_reporting(1023); //E_ALL not used because we do not want strict notices in PHP5 yet
-@ini_set('display_errors', '1');
-
-if (! isset($_SESSION['INSTALL'])) {
-    $_SESSION['INSTALL'] = array();
+if (isset($_REQUEST['admin'])) {
+    $admin = eregi_replace('[^A-Za-z0-9_-]', '', $_REQUEST['admin']);
+} else {
+    $admin = 'admin';
 }
 
-$INSTALL = &$_SESSION['INSTALL'];   // Makes it easier to reference
-
-/// detect if install was attempted from diferent directory, if yes reset session to prevent errors,
-/// dirroot location now fixed in installer
-if (!empty($INSTALL['dirroot']) and $INSTALL['dirroot'] != dirname(__FILE__)) {
-    $_SESSION['INSTALL'] = array();
+/// If config.php exists we just created config.php and need to redirect to continue installation
+$configfile = './config.php';
+if (file_exists($configfile)) {
+    header("Location: $admin/index.php?lang=$lang");
+    die;
 }
 
-/// 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_utf8';
-
-    $INSTALL['dbhost']          = 'localhost';
-    $INSTALL['dbuser']          = '';
-    $INSTALL['dbpass']          = '';
-    $INSTALL['dbtype']          = 'mysqli_adodb';
-    $INSTALL['dbname']          = 'moodle';
-    $INSTALL['prefix']          = 'mdl_';
-
-    $INSTALL['downloadlangpack']       = false;
-    $INSTALL['showdownloadlangpack']   = true;
-    $INSTALL['downloadlangpackerror']  = '';
-
-/// To be used by the Installer
-    $INSTALL['wwwroot']         = '';
-    $INSTALL['dirroot']         = dirname(__FILE__);
-    $INSTALL['dataroot']        = dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'moodledata';
-
-/// To be configured in the Installer
-    $INSTALL['wwwrootform']         = '';
-    $INSTALL['dirrootform']         = dirname(__FILE__);
-
-    $INSTALL['admindirname']    = 'admin';
-
-    $INSTALL['stage'] = WELCOME;
+/// make sure PHP errors are displayed - helps with diagnosing of problems
+@error_reporting(E_ALL);
+@ini_set('display_errors', '1');
+// we need a lot of memory
+@ini_set('memory_limit', '40M');
+
+/// Check that PHP is of a sufficient version
+if (version_compare(phpversion(), "5.2.0") < 0) {
+    $phpversion = phpversion();
+    // do NOT localise - lang strings would not work here and we CAN not move it after installib
+    echo "Sorry, Moodle 2.0 requires PHP 5.2.8 or later (currently using version $phpversion). ";
+    echo "Please upgrade your server software or install latest Moodle 1.9.x instead.";
+    die;
 }
 
-//==========================================================================//
-
-/// Set the page to Unicode always
-
-header('Content-Type: text/html; charset=UTF-8');
+require dirname(__FILE__).'/lib/installlib.php';
 
-/// Was data submitted?
+// TODO: add lang detection here if empty $_REQUEST['lang']
 
-if (isset($_POST['stage'])) {
+$config = new stdClass();
+$config->lang = $lang;
 
-    /// Get the stage for which the form was set and the next stage we are going to
+if (!empty($_POST)) {
+    if (install_ini_get_bool('magic_quotes_gpc')) {
+        $_POST = array_map($_POST, 'stripslashes');
+    }
 
-    $gpc = ini_get('magic_quotes_gpc');
-    $gpc = ($gpc == '1' or strtolower($gpc) == 'on');
+    $config->stage = (int)$_POST['stage'];
 
-    /// Store any posted data
-    foreach ($_POST as $setting=>$value) {
-        if ($gpc) {
-            $value = stripslashes($value);
+    if (isset($_POST['previous'])) {
+        $config->stage--;
+        if ($config->stage == INSTALL_ENVIRONMENT or $config->stage == INSTALL_DOWNLOADLANG) {
+            $config->stage--;
         }
-
-        $INSTALL[$setting] = $value;
+    } else if (isset($_POST['next'])) {
+        $config->stage++;
     }
 
-    if ( $goforward = (! empty( $_POST['next'] )) ) {
-        $nextstage = $_POST['stage'] + 1;
-    } else if (! empty( $_POST['prev'])) {
-        $nextstage = $_POST['stage'] - 1;
-        $INSTALL['stage'] = $_POST['stage'] - 1;
-    } else if (! empty( $_POST['same'] )) {
-        $nextstage = $_POST['stage'];
-    }
+    $config->dbtype   = trim($_POST['dbtype']);
+    $config->dbhost   = trim($_POST['dbhost']);
+    $config->dbuser   = trim($_POST['dbuser']);
+    $config->dbpass   = trim($_POST['dbpass']);
+    $config->dbname   = trim($_POST['dbname']);
+    $config->prefix   = trim($_POST['prefix']);
+    $config->dbsocket = (int)(!empty($_POST['dbsocket']));
 
-    $nextstage = (int)$nextstage;
-
-    if ($nextstage < 0) {
-        $nextstage = WELCOME;
-    }
+    $config->dirroot  = trim($_POST['dirroot']);
+    $config->admin    = empty($_POST['admin']) ? 'admin' : trim($_POST['admin']);
 
+    $config->dataroot = trim($_POST['dataroot']);
 
 } else {
+    $config->stage    = INSTALL_WELCOME;
 
-    $goforward = true;
-    $nextstage = WELCOME;
+    $config->dbtype   = '';
+    $config->dbhost   = 'localhost';
+    $config->dbuser   = '';
+    $config->dbpass   = '';
+    $config->dbname   = 'moodle';
+    $config->prefix   = 'mdl_';
+    $config->dbsocket = 0;
 
-}
+    $config->dirroot  = dirname(__FILE__);
+    $config->admin    = 'admin';
 
-//==========================================================================//
+    $config->dataroot = null; // initialised later after including libs
+}
 
 /// 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->libdir = $INSTALL['dirroot'].'/lib';
-$CFG->dataroot = $INSTALL['dataroot'];
-$CFG->admin = $INSTALL['admindirname'];
+$CFG = new stdClass();
+$CFG->lang                 = $config->lang;
+$CFG->dirroot              = dirname(__FILE__);
+$CFG->libdir               = "$CFG->dirroot/lib";
+$CFG->wwwroot              = install_guess_wwwroot(); // can not be changed - ppl must use the real address when installing
+$CFG->httpswwwroot         = $CFG->wwwroot;
+$CFG->httpsthemewww        = $CFG->wwwroot;
+$CFG->dataroot             = $config->dataroot;
+$CFG->admin                = $config->admin;
+$CFG->docroot              = 'http://docs.moodle.org';
 $CFG->directorypermissions = 00777;
-$CFG->running_installer = true;
-$CFG->docroot = 'http://docs.moodle.org';
-$CFG->httpswwwroot = $INSTALL['wwwrootform']; // Needed by doc_link() in Server Checks page.
-$COURSE->id = 0;
-
-/// Include some moodle libraries
+$CFG->running_installer    = true;
 
+/// Require all needed libs
 require_once($CFG->libdir.'/setuplib.php');
-require_once($CFG->libdir.'/installlib.php');
+require_once($CFG->libdir.'/textlib.class.php');
 require_once($CFG->libdir.'/weblib.php');
-require_once($CFG->libdir.'/deprecatedlib.php');
+require_once($CFG->libdir.'/dmllib.php');
 require_once($CFG->libdir.'/moodlelib.php');
+require_once($CFG->libdir.'/deprecatedlib.php');
 require_once($CFG->libdir.'/adminlib.php');
 require_once($CFG->libdir.'/environmentlib.php');
 require_once($CFG->libdir.'/xmlize.php');
 require_once($CFG->libdir.'/componentlib.class.php');
-require_once($CFG->dirroot.'/version.php');
-
-/// Set version and release
-$INSTALL['version'] = $version;
-$INSTALL['release'] = $release;
-
-/// list all supported drivers - unsupported must be installed manually ;-)
-$supported = array (
-    'mysqli_adodb',
-    'mysql_adodb',
-    'postgres7_adodb',
-    'mssql_n_adodb',
-    'mssql_adodb',
-    'odbc_mssql_adodb',
-    'oci8po_adodb',
-    'sqlite3_pdo',
-);
-$databases = array ();
-foreach($supported as $driver) {
-    $classname = $driver.'_moodle_database';
-    require_once ("$CFG->libdir/dml/$classname.php");
-    $databases[$driver] = new $classname ();
+
+require('version.php');
+$CFG->release = $release;
+
+$SESSION = new object();
+$SESSION->lang = $CFG->lang;
+
+$USER = new object();
+$USER->id = 0;
+
+$COURSE = new object();
+$COURSE->id = 0;
+
+$SITE = $COURSE;
+define('SITEID', 0);
+
+$hint_dataroot = '';
+$hint_dirroot  = '';
+$hint_admindir = '';
+$hint_database = '';
+
+/// Are we in help mode?
+if (isset($_GET['help'])) {
+    install_print_help_page($_GET['help']);
+}
+
+/// send css?
+if (isset($_GET['css'])) {
+    install_css_styles();
 }
 
-/// guess the www root
-if ($INSTALL['wwwroot'] == '') {
-    $INSTALL['wwwroot'] = install_guess_wwwroot();
-    $INSTALL['wwwrootform'] = $INSTALL['wwwroot'];
+///first time here? find out suitable dataroot
+if (is_null($CFG->dataroot)) {
+    $CFG->dataroot = str_replace('\\', '/', dirname(dirname(__FILE__)).'/moodledata');
 
-    // 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);
@@ -200,988 +159,364 @@ if ($INSTALL['wwwroot'] == '') {
         }
         $CFG->dataroot = dirname($parrent).'/moodledata';
     }
-        $INSTALL['dataroot'] = $CFG->dataroot;
+    $config->dataroot = $CFG->dataroot;
+    $config->stage    = INSTALL_WELCOME;
 }
 
-$headstagetext = array(WELCOME       => get_string('chooselanguagehead', 'install'),
-                       COMPATIBILITY => get_string('compatibilitysettingshead', 'install'),
-                       DIRECTORY     => get_string('directorysettingshead', 'install'),
-                       DATABASE      => get_string('databasesettingshead', 'install'),
-                       ADMIN         => get_string('admindirsettinghead', 'install'),
-                       ENVIRONMENT   => get_string('environmenthead', 'install'),
-                       DOWNLOADLANG  => get_string('downloadlanguagehead', 'install'),
-                       SAVE          => get_string('configurationcompletehead', 'install')
-                        );
-
-$substagetext = array(WELCOME       => get_string('chooselanguagesub', 'install'),
-                      COMPATIBILITY => get_string('compatibilitysettingssub', 'install'),
-                      DIRECTORY     => get_string('directorysettingssub', 'install'),
-                      DATABASE      => get_string('databasesettingssub', 'install'),
-                      ADMIN         => get_string('admindirsettingsub', 'install'),
-                      ENVIRONMENT   => get_string('environmentsub', 'install'),
-                      DOWNLOADLANG  => get_string('downloadlanguagesub', 'install'),
-                      SAVE          => get_string('configurationcompletesub', 'install')
-                       );
-
-
-
-//==========================================================================//
-
-/// Are we in help mode?
-
-if (isset($_GET['help'])) {
-    $nextstage = -1;
+// now let's do the stage work
+if ($config->stage < INSTALL_WELCOME) {
+    $config->stage = INSTALL_WELCOME;
+}
+if ($config->stage > INSTALL_SAVE) {
+    $config->stage = INSTALL_SAVE;
 }
 
 
 
-//==========================================================================//
-
-/// Are we in config download mode?
+if ($config->stage == INSTALL_SAVE) {
+    $database = moodle_database::get_driver_instance($config->dbtype, 'native');
+    if (!$database->driver_installed()) {
+        $config->stage = INSTALL_DATABASETYPE;
+    } else {
+        $hint_database = install_db_validate($database, $config->dbhost, $config->dbuser, $config->dbpass, $config->dbname, $config->prefix, array('dbpersit'=>0, 'dbsocket'=>$config->dbsocket));
 
-if (isset($_GET['download'])) {
-    header("Content-Type: application/x-forcedownload\n");
-    header("Content-Disposition: attachment; filename=\"config.php\"");
-    echo $INSTALL['config'];
-    exit;
-}
+        if ($hint_database === '') {
+            $configphp = '<?php  /// Moodle Configuration File ' . "\r\n\r\n";
 
+            $configphp .= 'unset($CFG);'."\r\n";
+            $configphp .= '$CFG = new stdClass();'."\r\n\r\n"; // prevent PHP5 strict warnings
 
+            $dbconfig = $database->export_dbconfig();
 
+            foreach ($dbconfig as $key=>$value) {
+                $key = str_pad($key, 9);
+                $configphp .= '$CFG->'.$key.' = '.var_export($value, true).";\r\n";
+            }
+            $configphp .= "\r\n";
 
+            $configphp .= '$CFG->wwwroot   = '.var_export($CFG->wwwroot, true).";\r\n";
 
-//==========================================================================//
+            if ($CFG->dirroot !== $config->dirroot) {
+                $configphp .= '$CFG->dirroot   = realpath('.var_export($config->dirroot, true).");\r\n"; // fix for sym links
+            } else {
+                $dirroot = str_replace('\\', '/', $CFG->dirroot); // win32 fix
+                $dirroot = rtrim($dirroot, '/');  // no trailing /
+                $configphp .= '$CFG->dirroot   = '.var_export($dirroot, true).";\r\n";
+            }
 
-/// Check the directory settings
+            $dataroot = str_replace('\\', '/', $config->dataroot); // win32 fix
+            $dataroot = rtrim($dataroot, '/');  // no trailing /
+            $configphp .= '$CFG->dataroot  = '.var_export($dataroot, true).";\r\n";
 
-if ($INSTALL['stage'] == DIRECTORY) {
+            $configphp .= '$CFG->admin     = '.var_export($config->admin, true).";\r\n\r\n";
 
-    error_reporting(0);
+            $configphp .= '$CFG->directorypermissions = 00777;  // try 02777 on a server in Safe Mode'."\r\n";
+            $configphp .= "\r\n";
 
-    /// check wwwroot
-    if (ini_get('allow_url_fopen') && false) { /// This was not reliable
-        if (($fh = @fopen($INSTALL['wwwrootform'].'/install.php', 'r')) === false) {
-            $errormsg .= get_string('wwwrooterror', 'install').'<br />';
-            $INSTALL['wwwrootform'] = $INSTALL['wwwroot'];
-            fclose($fh);
-        }
-    }
+            $configphp .= 'require_once("$CFG->dirroot/lib/setup.php");'."\r\n\r\n";
+            $configphp .= '// There is no php closing tag in this file,'."\r\n";
+            $configphp .= '// it is intentional because it prevents trailing whitespace problems!'."\r\n";
 
-    /// check dirroot
-    if (($fh = @fopen($INSTALL['dirrootform'].'/install.php', 'r')) === false) {
-        $errormsg .= get_string('dirrooterror', 'install').'<br />';
-        $INSTALL['dirrootform'] = $INSTALL['dirroot'];
-        fclose($fh);
-    }
+            umask(0137);
+    
+            if (($fh = @fopen($configfile, 'w')) !== false) {
+                fwrite($fh, $configphp);
+                fclose($fh);
+            }
+    
+            if (file_exists($configfile)) {
+                // config created, let's continue!
+                redirect("$CFG->wwwroot/$config->admin/index.php?lang=$config->lang");
+            }
 
-    /// check dataroot
-    $CFG->dataroot = $INSTALL['dataroot'];
-    $CFG->wwwroot  = $INSTALL['wwwroot'];
-    if (make_upload_directory('sessions', false) === false) {
-        $errormsg .= get_string('datarooterror', 'install').'<br />';
+            install_print_header($config, 'config.php',
+                                          get_string('configurationcompletehead', 'install'),
+                                          get_string('configurationcompletesub', 'install').get_string('configfilenotwritten', 'install'));
+            echo '<div class="configphp"><pre>';
+            echo p($configphp);
+            echo '</pre></div>';
 
-    } else if (is_dataroot_insecure(true) == INSECURE_DATAROOT_ERROR) {
-        $errormsg .= get_string('datarootpublicerror', 'install').'<br />';
-    }
+            install_print_footer($config);
+            die;
 
-    if (!empty($errormsg)) {
-        $nextstage = DIRECTORY;
+        } else {
+            $config->stage = INSTALL_DATABASE;
+        }
     }
-
-    error_reporting(38911);
 }
 
 
 
-//==========================================================================//
+if ($config->stage == INSTALL_DATABASE) {
+    $database = moodle_database::get_driver_instance($config->dbtype, 'native');
 
-/// Check database settings if stage 3 data submitted
-/// Try to connect to the database. If that fails then try to create the database
+    $sub = '<h3>'.$database->get_name().'</h3>'.$database->get_configuration_help();
 
-if ($INSTALL['stage'] == DATABASE) {
+    install_print_header($config, get_string('database', 'install'), get_string('databasehead', 'install'), $sub);
 
-    $DB = $databases[$INSTALL['dbtype']];
+    $strdbhost   = get_string('databasehost', 'install');
+    $strdbname   = get_string('databasename', 'install');
+    $strdbuser   = get_string('databaseuser', 'install');
+    $strdbpass   = get_string('databasepass', 'install');
+    $strprefix   = get_string('dbprefix', 'install');
+    $strdbsocket = get_string('databasesocket', 'install');
 
-    $dbfamily = $DB->get_dbfamily();
-    $errormsg = $DB->driver_installed();
+    echo '<div class="userinput">';
+    echo '<div class="formrow"><label for="id_dbhost" class="formlabel">'.$strdbhost.'</label>';
+    echo '<input id="id_dbhost" name="dbhost" type="text" value="'.s($config->dbhost).'" size="30" class="forminput" />';
+    echo '</div>';
 
-    if ($errormsg === true) {
-        $errormsg = '';
-    } else {
-        $nextstage = DATABASE;
-    }
-
-    if (empty($INSTALL['prefix']) and $dbfamily != 'mysql') { // All DBs but MySQL require prefix (reserv. words)
-        $errormsg = get_string('dbwrongprefix', 'install');
-        $nextstage = DATABASE;
-    }
+    echo '<div class="formrow"><label for="id_dbname" class="formlabel">'.$strdbname.'</label>';
+    echo '<input id="id_dbname" name="dbname" type="text" value="'.s($config->dbname).'" size="30" class="forminput" />';
+    echo '</div>';
 
-    if ($dbfamily == 'oracle' and strlen($INSTALL['prefix']) > 2) { // Oracle max prefix = 2cc (30cc limit)
-        $errormsg = get_string('dbwrongprefix', 'install');
-        $nextstage = DATABASE;
-    }
+    echo '<div class="formrow"><label for="id_dbuser" class="formlabel">'.$strdbuser.'</label>';
+    echo '<input id="id_dbuser" name="dbuser" type="text" value="'.s($config->dbuser).'" size="30" class="forminput" />';
+    echo '</div>';
 
-    if ($dbfamily == 'oracle' and !empty ($INSTALL['dbhost'])) { // Oracle host must be blank (tnsnames.ora has it)
-        $errormsg = get_string('dbwronghostserver', 'install');
-        $nextstage = DATABASE;
-    }
+    echo '<div class="formrow"><label for="id_dbpass" class="formlabel">'.$strdbpass.'</label>';
+    // no password field here, the password may be visible in config.php if we can not write it to disk
+    echo '<input id="id_dbpass" name="dbpass" type="text" value="'.s($config->dbpass).'" size="30" class="forminput" />';
+    echo '</div>';
 
-    if (empty($errormsg)) {
-        error_reporting(0);  // Hide errors
+    echo '<div class="formrow"><label for="id_prefix" class="formlabel">'.$strprefix.'</label>';
+    echo '<input id="id_prefix" name="prefix" type="text" value="'.s($config->prefix).'" size="10" class="forminput" />';
+    echo '</div>';
 
-        if (! $dbconnected = $DB->connect($INSTALL['dbhost'], $INSTALL['dbuser'], $INSTALL['dbpass'], $INSTALL['dbname'], $INSTALL['prefix'])) {
-            if (!$DB->create_database($INSTALL['dbhost'], $INSTALL['dbuser'], $INSTALL['dbpass'], $INSTALL['dbname'])) {
-                 $errormsg = get_string('dbcreationerror', 'install');
-                 $nextstage = DATABASE;
-            } else {
-                $dbconnected = $DB->connect($INSTALL['dbhost'], $INSTALL['dbuser'], $INSTALL['dbpass'], $INSTALL['dbname'], $INSTALL['prefix']);
-            }
-        } else {
-// TODO: db encoding checks ??
-        }
+    if (!(stristr(PHP_OS, 'win') && !stristr(PHP_OS, 'darwin'))) {
+        $checked = $config->dbsocket ? 'checked="checked' : '';
+        echo '<div class="formrow"><label for="id_dbsocket" class="formlabel">'.$strdbsocket.'</label>';
+        echo '<input type="hidden" value="0" name="dbsocket" />';
+        echo '<input type="checkbox" id="id_dbsocket" value="1" name="dbsocket" '.$checked.' class="forminput" />';
+        echo '</div>';
     }
 
-    error_reporting(38911);
-
-/// Output db connection error
-    if ((empty($errormsg) and ($dbconnected === false)) ) {
-        $errormsg = get_string('dbconnectionerror', 'install');
-        $nextstage = DATABASE;
-    }
+    echo '<div class="hint">'.$hint_database.'</div>';
+    echo '</div>';
+    install_print_footer($config);
+    die;
 }
 
 
 
-//==========================================================================//
+if ($config->stage == INSTALL_DOWNLOADLANG) {
+    if (empty($CFG->dataroot)) {
+        $config->stage = INSTALL_PATHS;
 
-/// If the next stage is admin directory settings OR we have just come from there then
-/// check the admin directory.
-/// If we can open a file then we know that the admin name is correct.
+    } else if (is_dataroot_insecure()) {
+        $hint_dataroot = get_string('pathsunsecuredataroot', 'install');
+        $config->stage = INSTALL_PATHS;
 
-if ($nextstage == ADMIN or $INSTALL['stage'] == ADMIN) {
-    if (!ini_get('allow_url_fopen')) {
-        $nextstage = ($goforward) ? ENVIRONMENT : DATABASE;
-    } else if (($fh = @fopen($INSTALL['wwwrootform'].'/'.$INSTALL['admindirname'].'/environment.xml', 'r')) !== false) {
-        $nextstage = ($goforward) ? ENVIRONMENT : DATABASE;
-        fclose($fh);
-    } else {
-        $nextstage = ($goforward) ? ENVIRONMENT : DATABASE;
-        //if ($nextstage != ADMIN) {
-        //    $errormsg = get_string('admindirerror', 'install');
-        //    $nextstage = ADMIN;
-        // }
+    } else if (!is_writable($CFG->dataroot)) {
+        $hint_dataroot = get_string('pathsrodataroot', 'install');
+        $config->stage = INSTALL_PATHS;
     }
-}
 
-//==========================================================================//
-
-// Check if we can navigate from the environemt page (because it's ok)
-
-if ($INSTALL['stage'] == ENVIRONMENT) {
-    $DB = $databases[$INSTALL['dbtype']];
+    if ($config->dirroot === '' or !file_exists($config->dirroot)) {
+        $hint_dirroot = get_string('pathswrongdirroot', 'install');
+        $config->stage = INSTALL_PATHS;
+    }
 
-    error_reporting(0);  // Hide errors
-    $dbconnected = $DB->connect($INSTALL['dbhost'], $INSTALL['dbuser'], $INSTALL['dbpass'], $INSTALL['dbname'], $INSTALL['prefix']);
-    error_reporting(38911);  // Show errors
-    if ($dbconnected) {
-    /// Execute environment check, printing results
-        if (!check_moodle_environment($INSTALL['release'], $environment_results, false)) {
-             $nextstage = ENVIRONMENT;
-        }
-    } else {
-    /// We never should reach this because DB has been tested before arriving here
-        $errormsg = get_string('dbconnectionerror', 'install');
-        $nextstage = DATABASE;
+    if ($config->admin === '' or !file_exists($config->dirroot.'/'.$config->admin.'/environment.xml')) {
+        $hint_admindir = get_string('pathswrongadmindir', 'install');
+        $config->stage = INSTALL_PATHS;
     }
 }
 
 
 
-//==========================================================================//
+if ($config->stage == INSTALL_DOWNLOADLANG) {
+    if ($CFG->lang == 'en_utf8') {
+        $config->stage = INSTALL_DATABASETYPE;
+    }
+}
 
-// Try to download the lang pack if it has been selected
 
-if ($INSTALL['stage'] == DOWNLOADLANG && $INSTALL['downloadlangpack']) {
 
-    $downloadsuccess = false;
+if ($config->stage == INSTALL_DOWNLOADLANG) {
     $downloaderror = '';
 
-    error_reporting(0);  // Hide errors
-
 /// Create necessary lang dir
     if (!make_upload_directory('lang', false)) {
         $downloaderror = get_string('cannotcreatelangdir', 'error');
-    }
 
-/// Download and install component
-    if (($cd = new component_installer('http://download.moodle.org', 'lang16',
-        $INSTALL['language'].'.zip', 'languages.md5', 'lang')) && empty($errormsg)) {
-        $status = $cd->install(); //returns COMPONENT_(ERROR | UPTODATE | INSTALLED)
-        switch ($status) {
-            case COMPONENT_ERROR:
-                if ($cd->get_error() == 'remotedownloaderror') {
-                    $a = new stdClass();
-                    $a->url = 'http://download.moodle.org/lang16/'.$INSTALL['language'].'.zip';
-                    $a->dest= $CFG->dataroot.'/lang';
-                    $downloaderror = get_string($cd->get_error(), 'error', $a);
-                } else {
-                    $downloaderror = get_string($cd->get_error(), 'error');
-                }
-            break;
-            case COMPONENT_UPTODATE:
-            case COMPONENT_INSTALLED:
-                $downloadsuccess = true;
-            break;
-            default:
-                //We shouldn't reach this point
+/// Download and install lang component
+    } else if ($cd = new component_installer('http://download.moodle.org', 'lang16', $CFG->lang.'.zip', 'languages.md5', 'lang')) {
+        if ($cd->install() == COMPONENT_ERROR) {
+            if ($cd->get_error() == 'remotedownloaderror') {
+                $a = new stdClass();
+                $a->url  = 'http://download.moodle.org/lang16/'.$INSTALL['language'].'.zip';
+                $a->dest = $CFG->dataroot.'/lang';
+                $downloaderror = get_string($cd->get_error(), 'error', $a);
+            } else {
+                $downloaderror = get_string($cd->get_error(), 'error');
+            }
         }
-    } else {
-        //We shouldn't reach this point
     }
 
-    error_reporting(38911);  // Show errors
-
-    if ($downloadsuccess) {
-        $INSTALL['downloadlangpack']       = false;
-        $INSTALL['showdownloadlangpack']   = false;
-        $INSTALL['downloadlangpackerror']  = $downloaderror;
+    if ($downloaderror !== '') {
+        install_print_header($config, get_string('language'), get_string('langdownloaderror', 'install', $CFG->lang), $downloaderror);
+        install_print_footer($config);
+        die;
     } else {
-        $INSTALL['downloadlangpack']       = false;
-        $INSTALL['showdownloadlangpack']   = false;
-        $INSTALL['downloadlangpackerror']  = $downloaderror;
+        $config->stage = INSTALL_DATABASETYPE;
     }
 }
 
 
 
-//==========================================================================//
-
-/// Display or print the data
-/// Put the data into a string
-/// Try to open config file for writing.
-
-if ($nextstage == SAVE) {
+if ($config->stage == INSTALL_DATABASETYPE) {
+    /// Finally ask for DB type
+    install_print_header($config, get_string('database', 'install'),
+                                  get_string('databasetypehead', 'install'),
+                                  get_string('databasetypesub', 'install'));
 
-    $str = '<?php  /// Moodle Configuration File ' . "\r\n";
-    $str .= "\r\n";
+    // TODO: move this PHP5 code to lib/installib.php so that this file parses in PHP4
+    $databases = array('mysqli' => moodle_database::get_driver_instance('mysqli', 'native'),
+                       'pgsql'  => moodle_database::get_driver_instance('pgsql',  'native'),
+                       'oci'    => moodle_database::get_driver_instance('oci',    'native'),
+                       //'sqlsrv' => moodle_database::get_driver_instance('sqlsrv', 'native'), // new MS sql driver - win32 only
+                       //'mssql'  => moodle_database::get_driver_instance('mssql',  'native'), // FreeTDS driver
+                      );
 
-    $str .= 'unset($CFG);'."\r\n";
-    $str .= '$CFG = new stdClass();'."\r\n"; // prevent PHP5 strict warnings
-    $str .= "\r\n";
-
-    $DB = $databases[$INSTALL['dbtype']];
-    $dbconfig = $DB->export_dbconfig($INSTALL['dbhost'], $INSTALL['dbuser'], $INSTALL['dbpass'], $INSTALL['dbname'], $INSTALL['prefix']);
-
-    foreach ($dbconfig as $key=>$value) {
-        $key = str_pad($key, 9);
-        $str .= '$CFG->'.$key.' = '.var_export($value, true).";\r\n";
+    echo '<div class="userinput">';
+    echo '<div class="formrow"><label class="formlabel" for="dbtype">'.get_string('dbtype', 'install').'</label>';
+    echo '<select id="dbtype" name="dbtype" class="forminput">';
+    $disabled = array();
+    $options = array();
+    foreach ($databases as $type=>$database) {
+        if ($database->driver_installed() !== true) {
+            $disabled[$type] = $database;
+            continue;
+        }
+        echo '<option value="'.s($type).'">'.$database->get_name().'</option>';
     }
-    $str .= "\r\n";
-
-    $str .= '$CFG->wwwroot   = '.var_export($INSTALL['wwwrootform'], true).";\r\n";
-    $str .= '$CFG->dirroot   = '.var_export($INSTALL['dirrootform'], true).";\r\n";
-    $str .= '$CFG->dataroot  = '.var_export($INSTALL['dataroot'], true).";\r\n";
-    $str .= '$CFG->admin     = '.var_export($INSTALL['admindirname'], true).";\r\n";
-    $str .= "\r\n";
-
-    $str .= '$CFG->directorypermissions = 00777;  // try 02777 on a server in Safe Mode'."\r\n";
-    $str .= "\r\n";
-
-    $str .= 'require_once("$CFG->dirroot/lib/setup.php");'."\r\n";
-    $str .= '// MAKE SURE WHEN YOU EDIT THIS FILE THAT THERE ARE NO SPACES, BLANK LINES,'."\r\n";
-    $str .= '// RETURNS, OR ANYTHING ELSE AFTER THE TWO CHARACTERS ON THE NEXT LINE.'."\r\n";
-    $str .= '?>';
-
-    umask(0137);
-
-    if (( $configsuccess = ($fh = @fopen($configfile, 'w')) ) !== false) {
-        fwrite($fh, $str);
-        fclose($fh);
+    if ($disabled) {
+        echo '<optgroup label="'.s(get_string('notavailable')).'">';
+        foreach ($disabled as $type=>$database) {
+            echo '<option value="'.s($type).'" class="notavailable">'.$database->get_name().'</option>';
+        }
+        echo '</optgroup>';
     }
+    echo '</select></div>';
+    echo '</div>';
 
-
-    $INSTALL['config'] = $str;
+    install_print_footer($config);
+    die;
 }
 
 
 
-//==========================================================================//
-
-?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html dir="<?php echo (right_to_left() ? 'rtl' : 'ltr'); ?>">
-<head>
-<link rel="shortcut icon" href="theme/standard/favicon.ico" />
-<title>Moodle Install</title>
-<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
-<?php css_styles($databases) ?>
-<?php database_js($databases) ?>
+if ($config->stage == INSTALL_ENVIRONMENT or $config->stage == INSTALL_PATHS) {
+    $version_fail = (version_compare(phpversion(), "5.2.8") < 0);
+    $curl_fail    = ($lang !== 'en_utf8' and !extension_loaded('curl')); // needed for lang pack download
+    $zip_fail     = ($lang !== 'en_utf8' and !extension_loaded('zip'));  // needed for lang pack download
 
-</head>
+    if ($version_fail or $curl_fail or $zip_fail) {
+        $config->stage = INSTALL_ENVIRONMENT;
 
-<body>
+        install_print_header($config, get_string('environment', 'install'),
+                                      get_string('errorsinenvironment', 'install'),
+                                      get_string('environmentsub2', 'install'));
 
+        echo '<div id="envresult"><dl>';
+        if ($version_fail) {
+            $a = (object)array('needed'=>'5.2.8', 'current'=>phpversion());
+            echo '<dt>'.get_string('phpversion', 'install').'</dt><dd>'.get_string('environmentrequireversion', 'admin', $a).'</dd>';
+        }
+        if ($curl_fail) {
+            echo '<dt>'.get_string('phpextension', 'install', 'cURL').'</dt><dd>'.get_string('environmentrequireinstall', 'admin').'</dd>';
+        }
+        if ($zip_fail) {
+            echo '<dt>'.get_string('phpextension', 'install', 'Zip').'</dt><dd>'.get_string('environmentrequireinstall', 'admin').'</dd>';
+        }
+        echo '</dl></div>';
 
-<?php
-if (isset($_GET['help'])) {
-    print_install_help($_GET['help']);
-    close_window_button();
-} else {
-?>
-
-
-<table class="main" cellpadding="3" cellspacing="0">
-    <tr>
-        <td class="td_mainlogo">
-            <p class="p_mainlogo"><img src="pix/moodlelogo-med.gif" width="240" height="60" alt="Moodle logo"/></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 $headstagetext[$nextstage] ?></p>
-            <?php /// Exceptionaly, depending of the DB selected, we show some different text
-                  /// from the standard one to show better instructions for each DB
-                if ($nextstage == DATABASE) {
-                    foreach ($databases as $driver=>$database) {
-                        echo '<script type="text/javascript" defer="defer">window.onload=toggledbinfo;</script>';
-                        echo '<div id="'.$driver.'">' . $database->get_configuration_hints();
-                        echo '<p style="text-align: center">' . get_string('databasesettingswillbecreated', 'install') . '</p>';
-                        echo '</div>';
-                    }
-                } else {
-                    if (!empty($substagetext[$nextstage])) {
-                        echo '<p class="p_subheading">' . $substagetext[$nextstage] . '</p>';
-                    }
-                }
-            ?>
-        </td>
-    </tr>
-
-    <tr>
-        <td class="td_main" colspan="2">
-
-<?php
-
-if (!empty($errormsg)) echo "<p class=\"errormsg\" style=\"text-align:center\">$errormsg</p>\n";
-
-
-if ($nextstage == SAVE) {
-    $INSTALL['stage'] = WELCOME;
-    $options = array();
-    $options['lang'] = $INSTALL['language'];
-    if ($configsuccess) {
-        echo "<p class=\"p_install\">".get_string('configfilewritten', 'install')."</p>\n";
-
-        echo "<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"100%\">\n";
-        echo "<tr>\n";
-        echo "<td>&nbsp;</td>\n";
-        echo "<td>&nbsp;</td>\n";
-        echo "<td align=\"right\">\n";
-        print_single_button("index.php", $options, get_string('continue'));
-        echo "</td>\n";
-        echo "</tr>\n";
-        echo "</table>\n";
+        install_print_footer($config, true);
+        die;
 
     } else {
-        echo "<p class=\"errormsg\">".get_string('configfilenotwritten', 'install')."</p>";
-
-        echo "<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"100%\">\n";
-        echo "<tr>\n";
-        echo "<td>&nbsp;</td>\n";
-        echo "<td align=\"center\">\n";
-        $installoptions = array();
-        $installoptions['download'] = 1;
-        print_single_button("install.php", $installoptions, get_string('download', 'install'));
-        echo "</td>\n";
-        echo "<td align=\"right\">\n";
-        print_single_button("index.php", $options, get_string('continue'));
-        echo "</td>\n";
-        echo "</tr>\n";
-        echo "</table>\n";
-
-        echo "<hr />\n";
-        echo "<div style=\"text-align: ".fix_align_rtl("left")."\">\n";
-        echo "<pre>\n";
-        p($INSTALL['config']);
-        echo "</pre>\n";
-        echo "</div>\n";
+        $config->stage = INSTALL_PATHS;
     }
-} else {
-    $formaction = (isset($_GET['configfile'])) ? "install.php?configfile=".$_GET['configfile'] : "install.php";
-    form_table($nextstage, $formaction, $databases);
 }
 
-?>
-
-        </td>
-    </tr>
-</table>
-
-<?php
-}
-?>
-
-</body>
-</html>
-
-
-
-
-
-
-
-
-
-
-<?php
-
-
-//==========================================================================//
 
-function form_table($nextstage, $formaction, $databases) {
-    global $INSTALL, $DB;
 
-    $enablenext = true;
+if ($config->stage == INSTALL_PATHS) {
+    $paths = array('wwwroot'  => get_string('wwwroot', 'install'),
+                   'dirroot'  => get_string('dirroot', 'install'),
+                   'dataroot' => get_string('dataroot', 'install'),
+                   'admindir' => get_string('admindirname', 'install'));
 
-    /// Print the standard form if we aren't in the DOWNLOADLANG page
-    /// because it has its own form.
-    if ($nextstage != DOWNLOADLANG) {
-        $needtoopenform = false;
-?>
-        <form id="installform" method="post" action="<?php echo $formaction ?>">
-        <div><input type="hidden" name="stage" value="<?php echo $nextstage ?>" /></div>
-
-<?php
-    } else {
-        $needtoopenform = true;
-    }
-?>
-    <table class="install_table" cellspacing="3" cellpadding="3">
-
-<?php
-    /// what we do depends on the stage we're at
-    switch ($nextstage) {
-        case WELCOME: /// Welcome and language settings
-?>
-            <tr>
-                <td class="td_left"><p class="p_install"><?php print_string('language') ?></p></td>
-                <td class="td_right">
-                <?php choose_from_menu (get_installer_list_of_languages(), 'language', $INSTALL['language'], '') ?>
-                </td>
-            </tr>
-
-<?php
-            break;
-        case COMPATIBILITY: /// Compatibilty check
-            $compatsuccess = true;
-
-            /// Check that PHP is of a sufficient version
-            print_compatibility_row(inst_check_php_version(), get_string('phpversion', 'install'), get_string('php52versionerror', 'install'), 'php52versionhelp');
-            $enablenext = $enablenext && inst_check_php_version();
-            /// Check session auto start
-            print_compatibility_row(!ini_get_bool('session.auto_start'), get_string('sessionautostart', 'install'), get_string('sessionautostarterror', 'install'), 'sessionautostarthelp');
-            $enablenext = $enablenext && !ini_get_bool('session.auto_start');
-            /// Check magic quotes
-            print_compatibility_row(!ini_get_bool('magic_quotes_runtime'), get_string('magicquotesruntime', 'install'), get_string('magicquotesruntimeerror', 'install'), 'magicquotesruntimehelp');
-            $enablenext = $enablenext && !ini_get_bool('magic_quotes_runtime');
-            /// Check unsupported PHP configuration
-            print_compatibility_row(!ini_get_bool('register_globals'), get_string('globalsquotes', 'install'), get_string('globalswarning', 'install'));
-            $enablenext = $enablenext && !ini_get_bool('register_globals');
-            /// Check safe mode
-            print_compatibility_row(!ini_get_bool('safe_mode'), get_string('safemode', 'install'), get_string('safemodeerror', 'install'), 'safemodehelp', true);
-            /// Check file uploads
-            print_compatibility_row(ini_get_bool('file_uploads'), get_string('fileuploads', 'install'), get_string('fileuploadserror', 'install'), 'fileuploadshelp', true);
-            /// Check GD version
-            print_compatibility_row(check_gd_version(), get_string('gdversion', 'install'), get_string('gdversionerror', 'install'), 'gdversionhelp', true);
-            /// Check memory limit
-            print_compatibility_row(check_memory_limit(), get_string('memorylimit', 'install'), get_string('memorylimiterror', 'install'), 'memorylimithelp', true);
-
-
-            break;
-        case DIRECTORY: /// Directory settings
-?>
-
-            <tr>
-                <td class="td_left"><p class="p_install"><?php print_string('wwwroot', 'install') ?></p></td>
-                <td class="td_right">
-                    <input type="text" size="40"name="wwwrootform" value="<?php p($INSTALL['wwwrootform'],true) ?>" />
-                </td>
-            </tr>
-            <tr>
-                <td class="td_left"><p class="p_install"><?php print_string('dirroot', 'install') ?></p></td>
-                <td class="td_right">
-                    <input type="text" size="40" name="dirrootform" disabled="disabled" value="<?php p($INSTALL['dirrootform'],true) ?>" />
-                </td>
-            </tr>
-            <tr>
-                <td class="td_left"><p class="p_install"><?php print_string('dataroot', 'install') ?></p></td>
-                <td class="td_right">
-                    <input type="text" size="40" name="dataroot" value="<?php p($INSTALL['dataroot'],true) ?>" />
-                </td>
-            </tr>
-
-<?php
-            break;
-        case DATABASE: /// Database settings
-?>
-
-            <tr>
-                <td class="td_left"><p class="p_install"><?php print_string('dbtype', 'install') ?></p></td>
-                <td class="td_right">
-
-                <?php
-
-            $options = array ();
-            foreach ($databases as $type => $database) {
-                $name = $database->get_name();
-                if ($database->driver_installed() !== true) {
-                    $name = "$name - driver not installed"; // TODO: improve missing driver notification
-                }
-                $options[$type] = $name;
-            }
-            choose_from_menu($options, 'dbtype', $INSTALL['dbtype'], '', 'toggledbinfo();')
-?>
-                </td>
-            </tr>
-            <tr>
-                <td class="td_left"><p class="p_install"><?php print_string('dbhost', 'install') ?></p></td>
-                <td class="td_right">
-                    <input type="text" class="input_database" name="dbhost" value="<?php p($INSTALL['dbhost']) ?>" />
-                </td>
-            </tr>
-            <tr>
-                <td class="td_left"><p class="p_install"><?php print_string('database', 'install') ?></p></td>
-                <td class="td_right">
-                    <input type="text" class="input_database" name="dbname" value="<?php p($INSTALL['dbname']) ?>" />
-                </td>
-            </tr>
-            <tr>
-                <td class="td_left"><p class="p_install"><?php print_string('user') ?></p></td>
-                <td class="td_right">
-                    <input type="text" class="input_database" name="dbuser" value="<?php p($INSTALL['dbuser']) ?>" />
-                </td>
-            </tr>
-            <tr>
-                <td class="td_left"><p class="p_install"><?php print_string('password') ?></p></td>
-                <td class="td_right">
-                    <input type="password" class="input_database" name="dbpass" value="<?php p($INSTALL['dbpass']) ?>" />
-                </td>
-            </tr>
-            <tr>
-                <td class="td_left"><p class="p_install"><?php print_string('dbprefix', 'install') ?></p></td>
-                <td class="td_right">
-                    <input type="text" class="input_database" name="prefix" value="<?php p($INSTALL['prefix']) ?>" />
-                </td>
-            </tr>
-
-<?php
-            break;
-        case ADMIN: /// Administration directory setting
-?>
-
-            <tr>
-                <td class="td_left"><p class="p_install"><?php print_string('admindirname', 'install') ?></p></td>
-                <td class="td_right">
-                    <input type="text" size="40" name="admindirname" value="<?php p($INSTALL['admindirname']) ?>" />
-                </td>
-            </tr>
-
-
-<?php
-            break;
-        case ENVIRONMENT: /// Environment checks
-?>
-
-            <tr>
-                <td colspan="2">
-                <?php
-                    error_reporting(0);  // Hide errors
-                    $dbconnected = $DB->connect($INSTALL['dbhost'],$INSTALL['dbuser'],$INSTALL['dbpass'],$INSTALL['dbname'], $INSTALL['prefix']);
-                    error_reporting(38911);  // Show errors
-                    if ($dbconnected) {
-                    /// Execute environment check, printing results
-                        check_moodle_environment($INSTALL['release'], $environment_results, true);
-                    } else {
-                    /// We never should reach this because DB has been tested before arriving here
-                        $errormsg = get_string('dbconnectionerror', 'install');
-                        $nextstage = DATABASE;
-                        echo '<p class="errormsg" style="text-align:center">'.get_string('dbconnectionerror', 'install').'</p>';
-                    }
-                ?>
-                </td>
-            </tr>
-
-<?php
-            break;
-        case DOWNLOADLANG: /// Download language from download.moodle.org
-?>
-
-            <tr>
-                <td colspan="2">
-                <?php
-                /// Get array of languages, we are going to use it
-                    $languages=get_installer_list_of_languages();
-                /// Print the download form (button) if necessary
-                    if ($INSTALL['showdownloadlangpack'] == true && substr($INSTALL['language'],0,2) != 'en') {
-                        $options = array();
-                        $options['downloadlangpack'] = true;
-                        $options['stage'] = DOWNLOADLANG;
-                        $options['same'] = true;
-                        print_simple_box_start('center');
-                        print_single_button('install.php', $options, get_string('downloadlanguagebutton','install', $languages[$INSTALL['language']]), 'post');
-                        print_simple_box_end();
-                    } else {
-                /// Show result info
-                    /// English lang packs aren't downloaded
-                        if (substr($INSTALL['language'],0,2) == 'en') {
-                            print_simple_box(get_string('downloadlanguagenotneeded', 'install', $languages[$INSTALL['language']]), 'center', '80%');
-                        } else {
-                            if ($INSTALL['downloadlangpackerror']) {
-                                echo "<p class=\"errormsg\" align=\"center\">".$INSTALL['downloadlangpackerror']."</p>\n";
-                                print_simple_box(get_string('langdownloaderror', 'install', $languages[$INSTALL['language']]), 'center', '80%');
-                            } else {
-                                print_simple_box(get_string('langdownloadok', 'install', $languages[$INSTALL['language']]), 'center', '80%');
-                            }
-                        }
-                    }
-                ?>
-                </td>
-            </tr>
-
-<?php
-            break;
-        default:
+    $sub = '<dl>';
+    foreach ($paths as $path=>$name) {
+        $sub .= '<dt>'.$name.'</dt><dd>'.get_string('pathssub'.$path, 'install').'</dd>';
     }
-?>
+    $sub .= '</dl>';
 
-    <tr>
-        <td colspan="<?php echo ($nextstage == COMPATIBILITY) ? 3 : 2; ?>">
-
-<?php
-    if ($needtoopenform) {
-?>
-            <form id="installform" method="post" action="<?php echo $formaction ?>">
-            <div><input type="hidden" name="stage" value="<?php echo $nextstage ?>" /></div>
-<?php
-    }
+    install_print_header($config, get_string('paths', 'install'), get_string('pathshead', 'install'), $sub);
 
-    $disabled = $enablenext ? '' : 'disabled="disabled"';
-?>
+    $strwwwroot      = get_string('wwwroot', 'install');
+    $strdirroot      = get_string('dirroot', 'install');
+    $strdataroot     = get_string('dataroot', 'install');
+    $stradmindirname = get_string('admindirname', 'install');
 
-            <?php echo ($nextstage < SAVE) ? "<div><input $disabled type=\"submit\" name=\"next\" value=\"".get_string('next')."  &raquo;\" style=\"float: ".fix_align_rtl("right")."\"/></div>\n" : "&nbsp;\n" ?>
-            <?php echo ($nextstage > WELCOME) ? "<div><input type=\"submit\" name=\"prev\" value=\"&laquo;  ".get_string('previous')."\" style=\"float: ".fix_align_rtl("left")."\"/></div>\n" : "&nbsp;\n" ?>
+    echo '<div class="userinput">';
+    echo '<div class="formrow"><label for="id_wwwroot" class="formlabel">'.$paths['wwwroot'].'</label>';
+    echo '<input id="id_wwwroot" name="wwwroot" type="text" value="'.s($CFG->wwwroot).'" disabled="disabled" size="45" class="forminput" />';
+    echo '</div>';
 
-<?php
-    if ($needtoopenform) {
-?>
-            </form>
-<?php
+    echo '<div class="formrow"><label for="id_dirroot" class="formlabel">'.$paths['dirroot'].'</label>';
+    echo '<input id="id_dirroot" name="dirroot" type="text" value="'.s($config->dirroot).'" size="45"class="forminput" />';
+    if ($hint_dirroot !== '') {
+        echo '<div class="hint">'.$hint_dirroot.'</div>';
     }
-?>
-
-
-        </td>
-
-    </tr>
+    echo '</div>';
 
-    </table>
-<?php
-    if (!$needtoopenform) {
-?>
-    </form>
-<?php
+    echo '<div class="formrow"><label for="id_dataroot" class="formlabel">'.$paths['dataroot'].'</label>';
+    echo '<input id="id_dataroot" name="dataroot" type="text" value="'.s($config->dataroot).'" size="45" class="forminput" />';
+    if ($hint_dataroot !== '') {
+        echo '<div class="hint">'.$hint_dataroot.'</div>';
     }
-?>
+    echo '</div>';
 
-<?php
-}
-
-
-
-//==========================================================================//
 
-function print_compatibility_row($success, $testtext, $errormessage, $helpfield='', $caution=false) {
-    echo "<tr>\n";
-    echo "<td class=\"td_left_nowrap\" valign=\"top\"><p class=\"p_install\">$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\">&nbsp;</td>\n";
+    if (file_exists("$CFG->dirroot/admin/environment.xml")) {
+        $disabled = 'disabled="disabled"';
     } else {
-        echo "<td valign=\"top\">";
-        echo ($caution) ? "<p class=\"p_caution\">".get_string('caution', 'install') : "<p class=\"p_fail\">".get_string('fail', 'install');
-        echo "</p></td>\n";
-        echo "<td valign=\"top\">";
-        echo "<p class=\"p_install\">$errormessage ";
-        if ($helpfield !== '') {
-            install_helpbutton("install.php?help=$helpfield");
-        }
-        echo "</p></td>\n";
+        $disabled = '';
     }
-    echo "</tr>\n";
-    return $success;
-}
-
-
-//==========================================================================//
-
-function install_helpbutton($url, $title='') {
-    if ($title == '') {
-        $title = get_string('help');
+    echo '<div class="formrow"><label for="id_admin" class="formlabel">'.$paths['admindir'].'</label>';
+    echo '<input id="id_admin" name="admin" type="text" value="'.s($config->admin).'" '.$disabled.' size="10" class="forminput" />';
+    if ($hint_admindir !== '') {
+        echo '<div class="hint">'.$hint_admindir.'</div>';
     }
-    echo "<a href=\"javascript:void(0)\" ";
-    echo "onclick=\"return window.open('$url','Help','menubar=0,location=0,scrollbars,resizable,width=500,height=400')\"";
-    echo ">";
-    echo "<img src=\"pix/help.gif\" class=\"iconhelp\" alt=\"$title\" title=\"$title\"/>";
-    echo "</a>\n";
-}
-
+    echo '</div>';
 
+    echo '</div>';
 
-//==========================================================================//
-
-function print_install_help($help) {
-    switch ($help) {
-        case 'phpversionhelp':
-            print_string($help, 'install', phpversion());
-            break;
-        case 'memorylimithelp':
-            print_string($help, 'install', get_memory_limit());
-            break;
-        default:
-            print_string($help, 'install');
-    }
+    install_print_footer($config);
+    die;
 }
 
-//==========================================================================//
-
-function css_styles($databases) {
-?>
-
-<style type="text/css">
-
-    body { background-color: #ffeece; }
-    p, li, td {
-        font-family: helvetica, arial, sans-serif;
-        font-size: 10pt;
-    }
-    a { text-decoration: none; color: blue; }
-    a img {
-        border: none;
-    }
-    .errormsg {
-        color: red;
-        font-weight: bold;
-    }
-    blockquote {
-        font-family: courier, monospace;
-        font-size: 10pt;
-    }
-    .input_database {
-        width: 270px;
-    }
-    .install_table {
-        width: 500px;
-        margin-left:auto;
-        margin-right:auto;
-    }
-    .td_left {
-        text-align: <?php echo fix_align_rtl("right") ?>;
-        font-weight: bold;
-    }
-    .td_left_nowrap{
-        text-align: <?php echo fix_align_rtl("right") ?>;
-        font-weight: bold;
-        white-space: nowrap;
-        width: 160px;
-        padding-left: 10px;
-    }
-    .td_right {
-        text-align: <?php echo fix_align_rtl("left") ?>;
-    }
-    .main {
-        width: 80%;
-        border-width: 1px;
-        border-style: solid;
-        border-color: #ffc85f;
-        margin-left:auto;
-        margin-right:auto;
-        -moz-border-radius-bottomleft: 15px;
-        -moz-border-radius-bottomright: 15px;
-    }
-    .td_mainheading {
-        background-color: #fee6b9;
-        padding-left: 10px;
-    }
-    .td_main {
-        text-align: center;
-    }
-    .td_mainlogo {
-        vertical-align: middle;
-    }
-    .p_mainlogo {
-        margin-top: 0px;
-        margin-bottom: 0px;
-    }
-    .p_mainheading {
-        font-size: 11pt;
-        margin-top: 16px;
-        margin-bottom: 16px;
-    }
-    .p_subheading {
-        font-size: 10pt;
-        padding-left: 10px;
-        margin-top: 16px;
-        margin-bottom: 16px;
-    }
-    .p_mainheader{
-        text-align: right;
-        font-size: 20pt;
-        font-weight: bold;
-        margin-top: 0px;
-        margin-bottom: 0px;
-    }
-    .p_pass {
-        color: green;
-        font-weight: bold;
-        margin-top: 0px;
-        margin-bottom: 0px;
-    }
-    .p_fail {
-        color: red;
-        font-weight: bold;
-        margin-top: 0px;
-        margin-bottom: 0px;
-    }
-    .p_caution {
-        color: #ff6600;
-        font-weight: bold;
-        margin-top: 0px;
-        margin-bottom: 0px;
-    }
-    .p_help {
-        text-align: center;
-        font-family: helvetica, arial, sans-serif;
-        font-size: 14pt;
-        font-weight: bold;
-        color: #333333;
-        margin-top: 0px;
-        margin-bottom: 0px;
-    }
-    /* This override the p tag for every p tag in this installation script,
-       but not in lang\xxx\installer.php
-      */
-    .p_install {
-        margin-top: 0px;
-        margin-bottom: 0px;
-    }
-    .environmenttable {
-        font-size: 10pt;
-        border-color: #ffc85f;
-    }
-    table.environmenttable .error {
-        background-color : red;
-        color : inherit;
-    }
-
-    table.environmenttable .warn {
-        background-color : yellow;
-    }
-
-    table.environmenttable .ok {
-        background-color : lightgreen;
-    }
-    .header {
-        background-color: #fee6b9;
-        font-size: 10pt;
-    }
-    .cell {
-        background-color: #ffeece;
-        font-size: 10pt;
-    }
-    .error {
-        color: #ff0000;
-    }
-    .errorboxcontent {
-        text-align: center;
-        font-weight: bold;
-        padding-left: 20px;
-        color: #ff0000;
-    }
-    .invisiblefieldset {
-      display:inline;
-      border:0px;
-      padding:0px;
-      margin:0px;
-    }
-    <?php
-        $list = array();
-        foreach ($databases as $driver=>$unused) {
-            $list[] = '#'.$driver;
-        }
-        $list = implode(',', $list);
-        echo ($list);
-    ?> {
-        display: none;
-    }
-
-</style>
-
-<?php
-}
 
-//==========================================================================//
 
-function database_js($databases) {
-?>
+$config->stage = INSTALL_WELCOME;
+install_print_header($config, get_string('language'),
+                              get_string('chooselanguagehead', 'install'),
+                              get_string('chooselanguagesub', 'install'));
 
-<script type="text/javascript" defer="defer">
-function toggledbinfo() {
-    //Calculate selected value
-    var showid = 'mysql';
-    if (document.getElementById('installform').dbtype.value) {
-        showid = document.getElementById('installform').dbtype.value;
-    }
-    if (document.getElementById) {
-        //Hide all the divs
-    <?php
-        $list = array();
-        foreach ($databases as $driver=>$unused) {
-            echo "document.getElementById('$driver').style.display = '';";
-        }
-    ?>
-        //Show the selected div
-        document.getElementById(showid).style.display = 'block';
-    } else if (document.all) {
-        //This is the way old msie versions work
-        //Hide all the divs
-    <?php
-        $list = array();
-        foreach ($databases as $driver=>$unused) {
-            echo "document.all['$driver'].style.display = '';";
-        }
-    ?>
-        //Show the selected div
-        document.all[showid].style.display = 'block';
-    } else if (document.layers) {
-        //This is the way nn4 works
-        //Hide all the divs
-    <?php
-        $list = array();
-        foreach ($databases as $driver=>$unused) {
-            echo "document.layers['$driver'].style.display = '';";
-        }
-    ?>
-        //Show the selected div
-        document.layers[showid].style.display = 'block';
-    }
+$languages = install_get_list_of_languages();
+echo '<div class="userinput">';
+echo '<div class="formrow"><label class="formlabel" for="langselect">'.get_string('language').'</label>';
+echo '<select id="langselect" name="lang" class="forminput">';
+foreach ($languages as $name=>$value) {
+    $selected = ($name == $CFG->lang) ? 'selected="selected"' : '';
+    echo '<option value="'.s($name).'" '.$selected.'>'.$value.'</option>';
 }
-</script>
+echo '</select></div>';
+echo '</div>';
 
-<?php
-}
+install_print_footer($config);
+die;
 
-?>
index df50401b233932bcf2808998ef80c74274c0dae2..0eb04c640f5454ab32ec3a5f46740e210f51d8f6 100644 (file)
@@ -49,8 +49,9 @@ $string['check'] = 'Check';
 $string['checkingphpsettings']='Checking PHP Settings';
 $string['chooselanguage'] = 'Choose a language';
 $string['chooselanguagehead'] = 'Choose a language';
-$string['chooselanguagesub'] = 'Please choose a language for the installation ONLY. You will be able to choose site and user languages on a later screen.';
+$string['chooselanguagesub'] = 'Please choose a language for the installation. This language will also be used as the default language for the site, though it may be changed later.';
 $string['closewindow'] = 'Close this window';
+$string['compatibility'] = 'Compatibility';
 $string['compatibilitysettings'] = 'Checking your PHP settings ...';
 $string['compatibilitysettingshead'] = 'Checking your PHP settings ...';
 $string['compatibilitysettingssub'] = 'Your server should pass all these tests to make Moodle run properly';
@@ -96,9 +97,6 @@ $string['databasecreationsettingssub2'] = '<b>Type:</b> fixed to \"mysqli\" by t
        <b>User:</b> fixed to \"root\" by the installer<br />
        <b>Password:</b> your database password<br />
        <b>Tables Prefix:</b> optional prefix to use for all table names';
-$string['databasehost']='Database host :';
-$string['databasename']='Database name : ';
-$string['databasepass']='Database password :';
 $string['databasesettings'] = 'Now you need to configure the database where most Moodle data
     will be stored.  This database must already have been created
     and a username and password created to access it.<br />
@@ -161,16 +159,10 @@ $string['databasesettingssub_postgres7'] = '<b>Type:</b> PostgreSQL<br />
        <b>User:</b> your database username<br />
        <b>Password:</b> your database password<br />
        <b>Tables Prefix:</b> prefix to use for all table names (mandatory)';
-$string['databasesettingssub_sqlite3_pdo'] = '<b>Type:</b> SQLite 3 (PDO) <b><strong  class=\"errormsg\">Experimental! (not for use in production)</strong></b><br />
-       <b>Host:</b> path to the directory where the database file will be saved (use a full path); use localhost or leave blank to use Moodle data directory<br />
-       <b>Name:</b> database name, eg moodle (optional)<br />
-       <b>User:</b> your database username (optional)<br />
-       <b>Password:</b> your database password (optional)<br />
-       <b>Tables Prefix:</b> optional prefix to use for all table names<br />
-          The name of the database file will be determined by the username, database name and password you entered above.';
 $string['databasesettingswillbecreated'] = '<b>Note:</b> The installer will try to create the database automatically if not exists.';
 $string['databasetype']='Database type :';
-$string['databaseuser']='Database user :';
+$string['databasetypehead'] = 'Choose database driver';
+$string['databasetypesub'] = 'Moodle supports several types of database servers. Please contact server administrator if you do not know which type to use.';
 $string['dataroot'] = 'Data Directory';
 $string['datarooterror'] = 'The \'Data Directory\' you specified could not be found or created.  Either correct the path or create that directory manually.';
 $string['datarootpublicerror'] = 'The \'Data Directory\' you specified is directly accessible via web, you must use different directory.';
@@ -231,6 +223,7 @@ $string['downloadlanguagepack']='Do you want to download language pack now(yes/n
 $string['downloadlanguagesub'] = 'You now have the option of downloading a language pack and continuing the installation process in this language.<br /><br />If you are unable to download the language pack, the installation process will continue in English. (Once the installation process is complete, you will have the opportunity to download and install additional language packs.)';
 $string['downloadsuccess'] = 'Language Pack Downloaded Successfuly';
 $string['doyouagree'] = 'Do you agree ? (yes/no):';
+$string['environment'] = 'Environment';
 $string['environmenterrortodo'] = 'You must solve all the environmental problems (errors) found above before proceeding to install this Moodle version!';
 $string['environmenthead'] = 'Checking your environment ...';
 $string['environmentrecommendcustomcheck'] = 'if this test fails, it indicates a potential problem';
@@ -240,9 +233,11 @@ $string['environmentrequirecustomcheck'] = 'this test must pass';
 $string['environmentrequireinstall'] = 'must be installed and enabled';
 $string['environmentrequireversion'] = 'version $a->needed is required and you are running $a->current';
 $string['environmentsub'] = 'We are checking if the various components of your system meet the system requirements';
+$string['environmentsub2'] = 'Each Moodle release has some minimum PHP version requirement and a number of mandatory PHP extensions.
+Full environment check is done before each install and upgrade. Please contact server administrator if you do not know how to install new version or enable PHP extensions.';
 $string['environmentxmlerror'] = 'Error reading environment data ($a->error_code)';
 $string['error'] = 'Error';
-$string['errorsinenvironment'] ='Errors in the environment!';
+$string['errorsinenvironment'] ='Environment check failed!';
 $string['fail'] = 'Fail';
 $string['fileuploads'] = 'File Uploads';
 $string['fileuploadserror'] = 'This should be on';
@@ -360,12 +355,30 @@ $string['ok'] = 'OK';
 $string['opensslrecommended'] = 'Installing the optional OpenSSL library is highly recommended -- it enables Moodle Networking functionality.';
 $string['pass'] = 'Pass';
 $string['password'] = 'Password';
+$string['pass'] = 'Pass';
+$string['paths'] = 'Paths';
+$string['pathshead'] = 'Confirm paths';
+$string['pathsrodataroot'] = 'Dataroot directory is not writable.';
+$string['pathssubwwwroot'] = 'Full web address where moodle will be accessed.
+It\'s not possible to access Moodle using multiple addresses.
+If your site has multiple public addresses you must setup permanent redirects on all of them except this one.
+If your site is accessible both from intranet and Internet use the public address here and setup DNS so that the inranet users may use the public adress too.';
+$string['pathssubdirroot'] = 'Full directory path to moodle installation. Change only if you need to use symbolic links.';
+$string['pathssubdataroot'] = '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 must not be accessible directly via the web.';
+$string['pathssubadmindir'] = 'A very few webhosts use /admin as a special URL for you to access a
+control panel or something.  Unfortunately this conflicts with the standard location for the Moodle admin pages.  You can fix this by
+renaming the admin directory in your installation, and putting that  new name here.  For example: <em>moodleadmin</em>. This will fix admin links in Moodle.';
+$string['pathsunsecuredataroot'] = 'Dataroot location is not secure';
+$string['pathswrongdirroot'] = 'Incorrect dirroot localtion';
+$string['pathswrongadmindir'] = 'Admin directory does not exist';
 $string['pgsqlextensionisnotpresentinphp'] = 'PHP has not been properly configured with the PGSQL extension so that it can communicate with PostgreSQL.  Please check your php.ini file or recompile PHP.';
 $string['php50restricted'] = 'PHP 5.0.x has a number of known problems, please upgrade to 5.1.x or downgrade to 4.3.x or 4.4.x';
 $string['php52versionerror'] = 'PHP version must be at least 5.2.4.';
 $string['php52versionhelp'] = '<p>Moodle requires a PHP version of at least 5.2.4.</p>
 <p>You are currently running version $a</p>
 <p>You must upgrade PHP or move to a host with a newer version of PHP!</p>';
+$string['phpextension'] = '$a PHP extension';
 $string['phpversion'] = 'PHP version';
 $string['phpversionhelp'] = '<p>Moodle requires a PHP version of at least 4.3.0 or 5.1.0 (5.0.x has a number of known problems).</p>
 <p>You are currently running version $a</p>
@@ -380,6 +393,7 @@ $string['previous'] = 'Previous';
 $string['qtyperqpwillberemoved'] = 'During the upgrade, the RQP question type will be removed. You were not using this question type, so you should not experience any problems.';
 $string['qtyperqpwillberemovedanyway'] = 'During the upgrade, the RQP question type will be removed. You have some RQP questions in your database, and these will stop working unless you reinstall the code from http://moodle.org/mod/data/view.php?d=13&amp;rid=797 before continuing with the upgrade.';
 $string['releasenoteslink'] = 'For information about this version of Moodle, please see Release Notes at $a';
+$string['reload'] = 'Reload';
 $string['remotedownloaderror'] = 'Download of component to your server failed, please verify proxy settings, PHP cURL extension is highly recommended.<br /><br />You must download the <a href=\"$a->url\">$a->url</a> file manually, copy it to \"$a->dest\" in your server and unzip it there.';
 $string['remotedownloadnotallowed'] = 'Download of components to your server isn\'t allowed (allow_url_fopen is disabled).<br /><br />You must download the <a href=\"$a->url\">$a->url</a> file manually, copy it to \"$a->dest\" in your server and unzip it there.';
 $string['report'] = 'Report';
index cbd8b514d686b146fde7ef8c2e89462c0e335331..d3947aa042ef73d4c50919c3506d3c818c8e12c9 100644 (file)
@@ -1,21 +1,8 @@
-aborting
-abortinstallation
 admindirerror
 admindirname
-admindirsetting
 admindirsettinghead
 admindirsettingsub
-adminemail
-adminfirstname
-admininfo
-adminlastname
-adminpassword
-adminusername
-askcontinue
-availabledbtypes
-availablelangs
 bypassed
-cannotconnecttodb
 cannotcreatelangdir
 cannotcreatetempdir
 cannotdownloadcomponents
@@ -26,40 +13,28 @@ cannotsavezipfile
 cannotunzipfile
 caution
 check
-checkingphpsettings
-chooselanguage
 chooselanguagehead
 chooselanguagesub
 closewindow
-compatibilitysettings
+compatibility
 compatibilitysettingshead
 compatibilitysettingssub
 componentisuptodate
-configfilecreated
-configfiledoesnotexist
 configfilenotwritten
 configfilewritten
-configurationcomplete
 configurationcompletehead
 configurationcompletesub
-configurationfileexist
 continue
-creatingconfigfile
 ctyperecommended
 ctyperequired
 curlrecommended
 curlrequired
 customcheck
 database
-databasecreationsettings
 databasecreationsettingshead
 databasecreationsettingssub
 databasecreationsettingssub2
-databasehost
-databasename
-databasepass
 databasesettings
-databasesettingsformoodle
 databasesettingshead
 databasesettingssub
 databasesettingssub_mssql
@@ -69,38 +44,32 @@ databasesettingssub_mysqli
 databasesettingssub_oci8po
 databasesettingssub_odbc_mssql
 databasesettingssub_postgres7
-databasesettingssub_sqlite3_pdo
 databasesettingswillbecreated
-databasetype
-databaseuser
+databasetypehead
+databasetypesub
 dataroot
 datarooterror
 datarootpublicerror
 dbconnectionerror
 dbcreationerror
 dbhost
-dbpass
 dbprefix
 dbtype
 dbwrongencoding
 dbwronghostserver
 dbwrongnlslang
 dbwrongprefix
-directorysettings
 directorysettingshead
 directorysettingssub
 dirroot
 dirrooterror
-disagreelicense
 download
 downloadedfilecheckfailed
 downloadlanguagebutton
 downloadlanguagehead
 downloadlanguagenotneeded
-downloadlanguagepack
 downloadlanguagesub
-downloadsuccess
-doyouagree
+environment
 environmenterrortodo
 environmenthead
 environmentrecommendcustomcheck
@@ -110,47 +79,29 @@ environmentrequirecustomcheck
 environmentrequireinstall
 environmentrequireversion
 environmentsub
+environmentsub2
 environmentxmlerror
 error
 errorsinenvironment
 fail
 fileuploads
 fileuploadserror
-fileuploadshelp
 gdversion
 gdversionerror
 gdversionhelp
 globalsquotes
 globalsquoteserror
-globalsquoteshelp
 globalswarning
 help
 iconvrecommended
 info
-inputdatadirectory
-inputwebadress
-inputwebdirectory
 installation
-installationiscomplete
-invalidargumenthelp
-invalidemail
-invalidhost
-invalidint
-invalidintrange
 invalidmd5
-invalidpath
-invalidsetelement
-invalidtextvalue
-invalidurl
-invalidvalueforlanguage
-invalidyesno
 langdownloaderror
 langdownloadok
 language
-locationanddirectories
 magicquotesruntime
 magicquotesruntimeerror
-magicquotesruntimehelp
 mbstringrecommended
 memorylimit
 memorylimiterror
@@ -168,7 +119,6 @@ mysqlextensionisnotpresentinphp
 mysqliextensionisnotpresentinphp
 name
 nativemysqli
-newline
 next
 oci8po
 ociextensionisnotpresentinphp
@@ -179,11 +129,21 @@ opensslrecommended
 parentlanguage
 pass
 password
-pearargerror
+paths
+pathsrodataroot
+pathshead
+pathssubwwwroot
+pathssubdirroot
+pathssubdataroot
+pathssubadmindir
+pathsunsecuredataroot
+pathswrongadmindir
+pathswrongdirroot
 pgsqlextensionisnotpresentinphp
 php50restricted
 php52versionerror
 php52versionhelp
+phpextension
 phpversion
 phpversionerror
 phpversionhelp
@@ -193,7 +153,7 @@ prefixtoolong
 previous
 qtyperqpwillberemoved
 qtyperqpwillberemovedanyway
-releasenoteslink
+reload
 remotedownloaderror
 remotedownloadnotallowed
 report
@@ -201,19 +161,10 @@ requiredentrieschanged
 restricted
 safemode
 safemodeerror
-safemodehelp
-selectlanguage
 serverchecks
 sessionautostart
 sessionautostarterror
-sessionautostarthelp
-sitefullname
-siteinfo
-sitenewsitems
-siteshortname
-sitesummary
 skipdbencodingtest
-sqlite3_pdo
 sqliteextensionisnotpresentinphp
 status
 this_direction
@@ -226,20 +177,7 @@ unicoderequired
 upgradingactivitymodule
 upgradingbackupdb
 upgradingblocksdb
-upgradingblocksplugin
-upgradingcompleted
-upgradingcourseformatplugin
-upgradingenrolplugin
-upgradinggradeexportplugin
-upgradinggradeimportplugin
-upgradinggradereportplugin
-upgradinglocaldb
-upgradingmessageoutputpluggin
-upgradingqtypeplugin
-upgradingrpcfunctions
-usagehelp
 user
-versionerror
 welcomep10
 welcomep20
 welcomep30
@@ -247,8 +185,6 @@ welcomep40
 welcomep50
 welcomep60
 welcomep70
-welcometext
-writetoconfigfilefaild
 wrongdestpath
 wrongsourcebase
 wrongzipfilename
index 65be7c37389de1ca42e618d1a7aa66f393ad6b67..eb57517e68dbc3700c8c9ce0616f95da03009e1e 100644 (file)
@@ -31,7 +31,7 @@ $string['caution'] = 'Caution';
 $string['checkingphpsettings']='Checking PHP Settings';
 $string['chooselanguage'] = 'Choose a language';
 $string['chooselanguagehead'] = 'Choose a language';
-$string['chooselanguagesub'] = 'Please choose a language for the installation ONLY. You will be able to choose site and user languages on a later screen.';
+$string['chooselanguagesub'] = 'Please choose a language for the installation. This language will also be used as the default language for the site, though it may be changed later.';
 $string['compatibilitysettings'] = 'Checking your PHP settings ...';
 $string['compatibilitysettingshead'] = 'Checking your PHP settings ...';
 $string['compatibilitysettingssub'] = 'Your server should pass all these tests to make Moodle run properly';
@@ -70,9 +70,10 @@ $string['databasecreationsettingssub2'] = '<b>Type:</b> fixed to \"mysqli\" by t
        <b>User:</b> fixed to \"root\" by the installer<br />
        <b>Password:</b> your database password<br />
        <b>Tables Prefix:</b> optional prefix to use for all table names';
-$string['databasehost']='Database host :';
-$string['databasename']='Database name : ';
-$string['databasepass']='Database password :';
+$string['databasehead'] = 'Database settings';
+$string['databasehost'] = 'Database host';
+$string['databasename'] = 'Database name';
+$string['databasepass'] = 'Database password';
 $string['databasesettings'] = 'Now you need to configure the database where most Moodle data
     will be stored.  This database must already have been created
     and a username and password created to access it.<br />
@@ -135,16 +136,12 @@ $string['databasesettingssub_postgres7'] = '<b>Type:</b> PostgreSQL<br />
        <b>User:</b> your database username<br />
        <b>Password:</b> your database password<br />
        <b>Tables Prefix:</b> prefix to use for all table names (mandatory)';
-$string['databasesettingssub_sqlite3_pdo'] = '<b>Type:</b> SQLite 3 (PDO) <b><strong  class=\"errormsg\">Experimental! (not for use in production)</strong></b><br />
-       <b>Host:</b> path to the directory where the database file will be saved (use a full path); use localhost or leave blank to use Moodle data directory<br />
-       <b>Name:</b> database name, eg moodle (optional)<br />
-       <b>User:</b> your database username (optional)<br />
-       <b>Password:</b> your database password (optional)<br />
-       <b>Tables Prefix:</b> optional prefix to use for all table names<br />
-          The name of the database file will be determined by the username, database name and password you entered above.';
 $string['databasesettingswillbecreated'] = '<b>Note:</b> The installer will try to create the database automatically if not exists.';
+$string['databasesocket'] = 'Unix socket';
 $string['databasetype']='Database type :';
-$string['databaseuser']='Database user :';
+$string['databasetypehead'] = 'Choose database driver';
+$string['databasetypesub'] = 'Moodle supports several types of database servers. Please contact server administrator if you do not know which type to use.';
+$string['databaseuser'] = 'Database user';
 $string['dataroot'] = 'Data Directory';
 $string['datarooterror'] = 'The \'Data Directory\' you specified could not be found or created.  Either correct the path or create that directory manually.';
 $string['datarootpublicerror'] = 'The \'Data Directory\' you specified is directly accessible via web, you must use different directory.';
@@ -206,7 +203,9 @@ $string['downloadsuccess'] = 'Language Pack Downloaded Successfuly';
 $string['doyouagree'] = 'Do you agree ? (yes/no):';
 $string['environmenthead'] = 'Checking your environment ...';
 $string['environmentsub'] = 'We are checking if the various components of your system meet the system requirements';
-$string['errorsinenvironment'] ='Errors in the environment!';
+$string['environmentsub2'] = 'Each Moodle release has some minimum PHP version requirement and a number of mandatory PHP extensions.
+Full environment check is done before each install and upgrade. Please contact server administrator if you do not know how to install new version or enable PHP extensions.';
+$string['errorsinenvironment'] ='Environment check failed!';
 $string['fail'] = 'Fail';
 $string['fileuploads'] = 'File Uploads';
 $string['fileuploadserror'] = 'This should be on';
@@ -260,7 +259,7 @@ $string['invalidtextvalue'] = 'Invalid Text Value';
 $string['invalidurl'] = 'Invalid URL ';
 $string['invalidvalueforlanguage']='Invalid value for --lang option. Type --help for more help';
 $string['invalidyesno'] = 'Error: value is not a valid yes/no argument';
-$string['langdownloaderror'] = 'Unfortunately the language \"$a\" was not installed. The installation process will continue in English.';
+$string['langdownloaderror'] = 'Unfortunately the language \"$a\" could not be downloaded. The installation process will continue in English.';
 $string['langdownloadok'] = 'The language \"$a\" was installed successfully. The installation process will continue in this language.';
 $string['locationanddirectories']= 'Location and directories';
 $string['magicquotesruntime'] = 'Magic Quotes Run Time';
@@ -302,16 +301,39 @@ $string['mysqli'] = 'Improved MySQL (mysqli)';
 $string['mysqlextensionisnotpresentinphp'] = 'PHP has not been properly configured with the MySQL extension so that it can communicate with MySQL.  Please check your php.ini file or recompile PHP.';
 $string['mysqliextensionisnotpresentinphp'] = 'PHP has not been properly configured with the MySQLi extension so that it can communicate with MySQL.  Please check your php.ini file or recompile PHP.  MySQLi extension is not available for PHP 4.';
 $string['nativemysqli'] = 'Improved MySQL (native/mysqli)';
+$string['nativemysqlihelp'] = 'Now you need to configure the database where most Moodle data will be stored.
+Database may be created if database user has needed permissions, username and password must already exist. Table prefix is optional.';
+$string['nativepgsql'] = 'PostgreSQL (native/pgsql)';
+$string['nativepgsqlhelp'] = 'Now you need to configure the database where most Moodle data will be stored.
+This database must already have been created and a username and password created to access it. Table prefix is mandatory.';
+$string['nativeoci'] = 'Oracle (native/oci)';
 $string['oci8po'] = 'Oracle (oci8po)';
 $string['ociextensionisnotpresentinphp'] = 'PHP has not been properly configured with the OCI8 extension so that it can communicate with Oracle.  Please check your php.ini file or recompile PHP.';
 $string['odbc_mssql'] = 'SQL*Server over ODBC (odbc_mssql)';
 $string['odbcextensionisnotpresentinphp'] = 'PHP has not been properly configured with the ODBC extension so that it can communicate with SQL*Server.  Please check your php.ini file or recompile PHP.';
 $string['pass'] = 'Pass';
+$string['paths'] = 'Paths';
+$string['pathshead'] = 'Confirm paths';
+$string['pathsrodataroot'] = 'Dataroot directory is not writable.';
+$string['pathssubwwwroot'] = 'Full web address where moodle will be accessed.
+It\'s not possible to access Moodle using multiple addresses.
+If your site has multiple public addresses you must setup permanent redirects on all of them except this one.
+If your site is accessible both from intranet and Internet use the public address here and setup DNS so that the inranet users may use the public adress too.';
+$string['pathssubdirroot'] = 'Full directory path to moodle installation. Change only if you need to use symbolic links.';
+$string['pathssubdataroot'] = '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 must not be accessible directly via the web.';
+$string['pathssubadmindir'] = 'A very few webhosts use /admin as a special URL for you to access a
+control panel or something.  Unfortunately this conflicts with the standard location for the Moodle admin pages.  You can fix this by
+renaming the admin directory in your installation, and putting that  new name here.  For example: <em>moodleadmin</em>. This will fix admin links in Moodle.';
+$string['pathsunsecuredataroot'] = 'Dataroot location is not secure';
+$string['pathswrongdirroot'] = 'Incorrect dirroot localtion';
+$string['pathswrongadmindir'] = 'Admin directory does not exist';
 $string['pgsqlextensionisnotpresentinphp'] = 'PHP has not been properly configured with the PGSQL extension so that it can communicate with PostgreSQL.  Please check your php.ini file or recompile PHP.';
 $string['php52versionerror'] = 'PHP version must be at least 5.2.4.';
 $string['php52versionhelp'] = '<p>Moodle requires a PHP version of at least 5.2.4.</p>
 <p>You are currently running version $a</p>
 <p>You must upgrade PHP or move to a host with a newer version of PHP!</p>';
+$string['phpextension'] = '$a PHP extension';
 $string['phpversion'] = 'PHP version';
 $string['phpversionhelp'] = '<p>Moodle requires a PHP version of at least 4.3.0 or 5.1.0 (5.0.x has a number of known problems).</p>
 <p>You are currently running version $a</p>
@@ -340,7 +362,7 @@ $string['sitenewsitems'] = 'News Items :';
 $string['siteshortname'] = 'Site short name :';
 $string['sitesummary'] ='Site summary :';
 $string['skipdbencodingtest'] = 'Skip DB Encoding Test';
-$string['sqlite3_pdo'] = 'SQLite 3 (PDO) <b><strong  class=\"errormsg\">Experimental! (not for use in production)</strong></b>';
+$string['pdosqlite3'] = 'SQLite 3 (PDO) <b><strong  class=\"errormsg\">Experimental! (not for use in production)</strong></b>';
 $string['sqliteextensionisnotpresentinphp'] = 'PHP has not been properly configured with the SQLite extension.  Please check your php.ini file or recompile PHP.';
 $string['tableprefix']='Table prefix :';
 $string['upgradingactivitymodule']= 'Upgrading Activity Module';
index 703ee48a2183c77d9667dd4bac0fc6c813144273..12bbf1e8362c30c67a6e75563d3c1d4bb8289086 100644 (file)
@@ -30,6 +30,16 @@ abstract class adodb_moodle_database extends moodle_database {
         return get_string($dbtype, 'install');
     }
 
+    /**
+     * Returns localised database configuration help.
+     * Note: can be used before connect()
+     * @return string
+     */
+    public function get_configuration_help() {
+        $dbtype = $this->get_dbtype();
+        return get_string($dbtype.'help', 'install');
+    }
+
     /**
      * Adodb preconnection routines, ususally sets up needed defines;
      */
index 08baff21c0417a592565e26bfb373df54904bc94..ce8b15b2c755bb97edb0a2265cbca2ccac2c5103 100644 (file)
@@ -50,14 +50,14 @@ abstract class moodle_database {
     protected $prefix;
 
     /**
-     * Non-moodle external database used.
+     * Database or driver specific options, such as sockets or TCPIP db connections
      */
-    protected $external;
+    protected $dboptions;
 
     /**
-     * Database or driver specific options, such as sockets or TCPIP db connections
+     * Non-moodle external database used.
      */
-    protected $dboptions;
+    protected $external;
 
     /**
      * The database reads (performance counter).
@@ -163,20 +163,24 @@ abstract class moodle_database {
     public abstract function get_name();
 
     /**
-     * Returns localised database description
+     * Returns localised database configuration help.
      * Note: can be used before connect()
      * @return string
      */
-    public abstract function get_configuration_hints();
+    public abstract function get_configuration_help();
 
     /**
-     * Returns db related part of config.php
+     * Returns localised database description
      * Note: can be used before connect()
      * @return string
      */
-    public function export_dbconfig($dbhost, $dbuser, $dbpass, $dbname, $prefix, array $dboptions=null) {
-        $this->store_settings($dbhost, $dbuser, $dbpass, $dbname, $prefix, $dboptions);
+    public abstract function get_configuration_hints();
 
+    /**
+     * Returns db related part of config.php
+     * @return object
+     */
+    public function export_dbconfig() {
         $cfg = new stdClass();
         $cfg->dbtype    = $this->get_dbtype();
         $cfg->dblibrary = $this->get_dblibrary();
@@ -234,7 +238,7 @@ abstract class moodle_database {
      *
      * @return bool success
      */
-    public function create_database($dbhost, $dbuser, $dbpass, $dbname) {
+    public function create_database($dbhost, $dbuser, $dbpass, $dbname, array $dboptions=null) {
         return false;
     }
 
index bb95379e0367fff7b25c88df82f9984c7d63edea..23d4c48719b8f43bc1c07382f902a838468cb971 100644 (file)
@@ -18,7 +18,7 @@ class mysqli_adodb_moodle_database extends adodb_moodle_database {
      * @return bool success
      * @throws dml_exception if error
      */
-    public function create_database($dbhost, $dbuser, $dbpass, $dbname) {
+    public function create_database($dbhost, $dbuser, $dbpass, $dbname, array $dboptions=null) {
         $this->adodb->database = ''; // reset database name cached by ADODB. Trick from MDL-9609
         if ($this->adodb->Connect($dbhost, $dbuser, $dbpass)) { /// Try to connect without DB
             if ($this->adodb->Execute("CREATE DATABASE $dbname DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci")) {
index 40682444930d926101b9cbdf9a9405c92fb2f51a..64517fdb42b8158c39e5126de5ab42ddc22beceb 100644 (file)
@@ -21,7 +21,7 @@ class mysqli_native_moodle_database extends moodle_database {
      * @throws dml_exception if error
      */
     /// TODO: Decide if this method should go to DDL instead of being here
-    public function create_database($dbhost, $dbuser, $dbpass, $dbname) {
+    public function create_database($dbhost, $dbuser, $dbpass, $dbname, array $dboptions=null) {
         ob_start();
         $conn = new mysqli($dbhost, $dbuser, $dbpass); /// Connect without db
         $dberr = ob_get_contents();
@@ -91,6 +91,15 @@ class mysqli_native_moodle_database extends moodle_database {
         return get_string('nativemysqli', 'install');
     }
 
+    /**
+     * Returns localised database configuration help.
+     * Note: can be used before connect()
+     * @return string
+     */
+    public function get_configuration_help() {
+        return get_string('nativemysqlihelp', 'install');
+    }
+
     /**
      * Returns localised database description
      * Note: can be used before connect()
@@ -119,6 +128,7 @@ class mysqli_native_moodle_database extends moodle_database {
         }
 
         $this->store_settings($dbhost, $dbuser, $dbpass, $dbname, $prefix, $dboptions);
+        unset($this->dboptions['dbsocket']);
 
         ob_start();
         $this->mysqli = new mysqli($dbhost, $dbuser, $dbpass, $dbname);
index 965d48769b177c0a10cc84ef9517a8089bf3a0cc..7d3c070a6326fbadf31224d45eec2f28a54e236a 100644 (file)
@@ -62,6 +62,15 @@ class oci_native_moodle_database extends moodle_database {
         return get_string('nativeoci', 'install'); // TODO: localise
     }
 
+    /**
+     * Returns localised database configuration help.
+     * Note: can be used before connect()
+     * @return string
+     */
+    public function get_configuration_help() {
+        return get_string('nativeocihelp', 'install');
+    }
+
     /**
      * Returns localised database description
      * Note: can be used before connect()
@@ -101,6 +110,7 @@ class oci_native_moodle_database extends moodle_database {
         }
 
         $this->store_settings($dbhost, $dbuser, $dbpass, $dbname, $prefix, $dboptions);
+        unset($this->dboptions['dbsocket']);
 
         $pass = addcslashes($this->dbpass, "'\\");
 
index 647544d0558268a52dc9f38ad4f7e817d233107d..294174696e0e271718c57a488d279aec59a6b046 100644 (file)
@@ -84,7 +84,16 @@ abstract class pdo_moodle_database extends moodle_database {
      * @return string
      */
     public function get_name() {
-        return get_string($this->get_dbtype() . '_pdo', 'install');
+        return get_string('pdo'.$this->get_dbtype(), 'install');
+    }
+
+    /**
+     * Returns localised database configuration help.
+     * Note: can be used before connect()
+     * @return string
+     */
+    public function get_configuration_help() {
+        return get_string('pdo'.$this->get_dbtype().'help', 'install');
     }
 
     /**
index a54797d113caa8b250440d9ecdb4967c53747871..365f4e87a65db51ad80cdbbb43ed28da1347c520 100644 (file)
@@ -62,6 +62,15 @@ class pgsql_native_moodle_database extends moodle_database {
         return get_string('nativepgsql', 'install'); // TODO: localise
     }
 
+    /**
+     * Returns localised database configuration help.
+     * Note: can be used before connect()
+     * @return string
+     */
+    public function get_configuration_help() {
+        return get_string('nativepgsqlhelp', 'install');
+    }
+
     /**
      * Returns localised database description
      * Note: can be used before connect()
@@ -103,6 +112,7 @@ class pgsql_native_moodle_database extends moodle_database {
         if (!empty($this->dboptions['dbsocket']) and ($this->dbhost === 'localhost' or $this->dbhost === '127.0.0.1')) {
             $connection = "user='$this->dbuser' password='$pass' dbname='$this->dbname'";
         } else {
+            $this->dboptions['dbsocket'] = 0;
             if (empty($this->dbname)) {
                 // probably old style socket connection - do not add port
                 $port = "";
index cc2c5ffe1f95dce9d351162fc52ac9ead1e3dd67..678f6586ff5a3a1341c124ed7021de5192f2e8c9 100644 (file)
@@ -73,12 +73,9 @@ class postgres7_adodb_moodle_database extends adodb_moodle_database {
 
     /**
      * Returns db related part of config.php
-     * Note: can be used before connect()
-     * @return string
+     * @return object
      */
-    public function export_dbconfig($dbhost, $dbuser, $dbpass, $dbname, $prefix, array $dboptions=null) {
-        $this->store_settings($dbhost, $dbuser, $dbpass, $dbname, $prefix, $dboptions);
-
+    public function export_dbconfig() {
         $cfg = new stdClass();
         $cfg->dbtype     = $this->get_dbtype();
         $cfg->dblibrary  = $this->get_dblibrary();
index c97d458e2be25f1e51baaad865fd75edd76c8a2c..d6439c3d84e6a2a2255c3a0615dd5592d6bf3fda 100644 (file)
@@ -58,7 +58,7 @@ class sqlite3_pdo_moodle_database extends pdo_moodle_database {
      *
      * @return bool success
      */
-    public function create_database($dbhost, $dbuser, $dbpass, $dbname) {
+    public function create_database($dbhost, $dbuser, $dbpass, $dbname, array $dboptions=null) {
         $this->dbhost = $dbhost;
         $this->dbuser = $dbuser;
         $this->dbpass = $dbpass;
index ad88c0efc1acdb3670c1cd09629bbfede71c9cd0..efc05d1a9b2e5a9c008179fe52271b96baf366f5 100644 (file)
@@ -4,6 +4,14 @@
  * Functions to support installation process
  */
 
+define('INSTALL_WELCOME',       0);
+define('INSTALL_ENVIRONMENT', 1);
+define('INSTALL_PATHS',         2);
+define('INSTALL_DOWNLOADLANG',  3);
+define('INSTALL_DATABASETYPE',  4);
+define('INSTALL_DATABASE',      5);
+define('INSTALL_SAVE',          6);
+
 /**
  *Tries to detect the right www root setting.
  *
@@ -28,14 +36,52 @@ function install_guess_wwwroot() {
     return $wwwroot;
 }
 
+function install_ini_get_bool($ini_get_arg) {
+    $temp = ini_get($ini_get_arg);
+
+    if ($temp == '1' or strtolower($temp) == 'on') {
+        return true;
+    }
+    return false;
+}
+
+function install_helpbutton($url, $title='') {
+    if ($title == '') {
+        $title = get_string('help');
+    }
+    echo "<a href=\"javascript:void(0)\" ";
+    echo "onclick=\"return window.open('$url','Help','menubar=0,location=0,scrollbars,resizable,width=500,height=400')\"";
+    echo ">";
+    echo "<img src=\"pix/help.gif\" class=\"iconhelp\" alt=\"$title\" title=\"$title\"/>";
+    echo "</a>\n";
+}
+
+function install_db_validate($database, $dbhost, $dbuser, $dbpass, $dbname, $prefix, $dboptions) {
+    // this is in function because we want the /install.php to parse in PHP4
+    try {
+        try {
+            $database->connect($dbhost, $dbuser, $dbpass, $dbname, $prefix, $dboptions);
+        } catch (moodle_exception $e) {
+            // let's try to create new database
+            if ($database->create_database($dbhost, $dbuser, $dbpass, $dbname, $dboptions)) {
+                $database->connect($dbhost, $dbuser, $dbpass, $dbname, $prefix, $dboptions);
+            } else {
+                throw $e;
+            }
+        }
+        return '';
+    } catch (dml_exception $ex) {
+        return get_string($ex->errorcode, $ex->module, $ex->a).'<br />'.$ex->debuginfo;
+    }
+}
+
 /**
  * This function returns a list of languages and their full names. The
  * list of available languages is fetched from install/lang/xx/installer.php
  * and it's used exclusively by the installation process
  * @return array An associative array with contents in the form of LanguageCode => LanguageName
  */
-function get_installer_list_of_languages() {
-
+function install_get_list_of_languages() {
     global $CFG;
 
     $languages = array();
@@ -45,61 +91,250 @@ function get_installer_list_of_languages() {
     asort($langdirs);
 /// Get some info from each lang
     foreach ($langdirs as $lang) {
-        if (file_exists($CFG->dirroot .'/install/lang/'. $lang .'/installer.php')) {
-            include($CFG->dirroot .'/install/lang/'. $lang .'/installer.php');
-            if (substr($lang, -5) == '_utf8') {   //Remove the _utf8 suffix from the lang to show
+        if ($lang == 'en') {
+            continue;
+        }
+        if (file_exists($CFG->dirroot.'/install/lang/'.$lang.'/installer.php')) {
+            $string = array();
+            include($CFG->dirroot.'/install/lang/'.$lang.'/installer.php');
+            if (substr($lang, -5) === '_utf8') {   //Remove the _utf8 suffix from the lang to show
                 $shortlang = substr($lang, 0, -5);
             } else {
                 $shortlang = $lang;
             }
-/*            if ($lang == 'en') {  //Explain this is non-utf8 en
-                $shortlang = 'non-utf8 en';
-            }*/
             if (!empty($string['thislanguage'])) {
-                $languages[$lang] = $string['thislanguage'] .' ('. $shortlang .')';
+                $languages[$lang] = $string['thislanguage'].' ('.$shortlang.')';
             }
-            unset($string);
         }
     }
 /// Return array
     return $languages;
 }
 
-/**
- * Get memeory limit
- *
- * @return int
- */
-function get_memory_limit() {
-    if ($limit = ini_get('memory_limit')) {
-        return $limit;
-    } else {
-        return get_cfg_var('memory_limit');
+function install_print_help_page($help) {
+    global $CFG;
+
+    @header('Content-Type: text/html; charset=UTF-8');
+    @header('Cache-Control: no-store, no-cache, must-revalidate');
+    @header('Cache-Control: post-check=0, pre-check=0', false);
+    @header('Pragma: no-cache');
+    @header('Expires: Mon, 20 Aug 1969 09:23:00 GMT');
+    @header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
+
+    echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
+    echo '<html dir="'.(right_to_left() ? 'rtl' : 'ltr').'">
+          <head>
+          <link rel="shortcut icon" href="theme/standard/favicon.ico" />
+          <link rel="stylesheet" type="text/css" href="'.$CFG->wwwroot.'/install.php?css=1" />
+          <title>'.get_string('installation','install').'</title>
+          <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
+          <meta http-equiv="pragma" content="no-cache" />
+          <meta http-equiv="expires" content="0" />';
+
+    echo '</head><body>';
+    switch ($help) {
+        case 'phpversionhelp':
+            print_string($help, 'install', phpversion());
+            break;
+        case 'memorylimithelp':
+            print_string($help, 'install', get_memory_limit());
+            break;
+        default:
+            print_string($help, 'install');
     }
+    close_window_button();
+    echo '</body></html>';
+    die;
 }
 
-/**
- * Check memory limit
- *
- * @return boolean
- */
-function check_memory_limit() {
+function install_print_header($config, $stagename, $heading, $stagetext) {
+    global $CFG;
 
-    /// if limit is already 40 or more then we don't care if we can change it or not
-    if ((int)str_replace('M', '', get_memory_limit()) >= 40) {
-        return true;
+    @header('Content-Type: text/html; charset=UTF-8');
+    @header('Cache-Control: no-store, no-cache, must-revalidate');
+    @header('Cache-Control: post-check=0, pre-check=0', false);
+    @header('Pragma: no-cache');
+    @header('Expires: Mon, 20 Aug 1969 09:23:00 GMT');
+    @header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
+
+    echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
+    echo '<html dir="'.(right_to_left() ? 'rtl' : 'ltr').'">
+          <head>
+          <link rel="shortcut icon" href="theme/standard/favicon.ico" />';
+
+    $sheets = array('styles_layout', 'styles_fonts', 'styles_color', 'styles_moz');
+    $csss = array();
+    foreach ($sheets as $sheet) {
+        $csss[] = $CFG->wwwroot.'/theme/standard/'.$sheet.'.css';
+    }
+    $sheets = array('gradients');
+    foreach ($sheets as $sheet) {
+        $csss[] = $CFG->wwwroot.'/theme/standardwhite/'.$sheet.'.css';
     }
+    foreach ($csss as $css) {
+        echo '<link rel="stylesheet" type="text/css" href="'.$css.'" />'."\n";
+    }
+
+    echo '<link rel="stylesheet" type="text/css" href="'.$CFG->wwwroot.'/install.php?css=1" />
+          <title>'.get_string('installation','install').' - Moodle '.$CFG->release.'</title>
+          <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
+          <meta http-equiv="pragma" content="no-cache" />
+          <meta http-equiv="expires" content="0" />';
+
+    echo '</head><body class="notloggedin">
+            <div id="page" class="stage'.$config->stage.'">
+                <div id="header" class=" clearfix"><h1 class="headermain">'.get_string('installation','install').'</h1>
+                    <div class="headermenu">&nbsp;</div></div><div class="navbar clearfix">
+                    <div class="breadcrumb">
+                        <ul><li class="first">'.$stagename.'</li></ul>
+                    </div>
+                    <div class="navbutton">&nbsp;</div>
+                </div>
+          <!-- END OF HEADER -->
+          <div id="installdiv">';
 
-    /// Otherwise, see if we can change it ourselves
-    @ini_set('memory_limit', '40M');
-    return ((int)str_replace('M', '', get_memory_limit()) >= 40);
+    echo '<h2>'.$heading.'</h2>';
+
+    if ($stagetext !== '') {
+        echo '<div class="stage generalbox box">';
+        echo $stagetext;
+        echo '</div>';
+    }
+    // main
+    echo '<form id="installform" method="post" action="install.php"><fieldset>';
+    foreach ($config as $name=>$value) {
+        echo '<input type="hidden" name="'.$name.'" value="'.s($value).'" />';
+    }
 }
 
-/**
- * Check php version
- *
- * @return boolean
- */
-function inst_check_php_version() {
-    return check_php_version("5.2.4");
+function install_print_footer($config, $reload=false) {
+    global $CFG;
+
+    if ($config->stage > INSTALL_WELCOME) {
+        $first = '<input type="submit" name="previous" value="&laquo; '.s(get_string('previous')).'" />';
+    } else {
+        $first = '';
+    }
+
+    if ($reload) {
+        $next = '<input type="submit" name="next" value="'.s(get_string('reload', 'admin')).'" />';
+    } else {
+        $next = '<input type="submit" name="next" value="'.s(get_string('next')).' &raquo;" />';
+    }
+
+    echo '</fieldset><fieldset id="nav_buttons">'.$first.$next.'</fieldset>';
+
+    $homelink  = '<div class="sitelink">'.
+       '<a title="Moodle '. $CFG->release .'" href="http://docs.moodle.org/en/Administrator_documentation" onclick="this.target=\'_blank\'">'.
+       '<img style="width:100px;height:30px" src="pix/moodlelogo.gif" alt="moodlelogo" /></a></div>';
+
+    echo '</form></div>';
+    echo '<div id="footer"><hr />'.$homelink.'</div>';
+    echo '</div></body></html>';
+}
+
+
+function install_css_styles() {
+    global $CFG;
+
+    @header('Content-type: text/css');  // Correct MIME type
+    @header('Cache-Control: no-store, no-cache, must-revalidate');
+    @header('Cache-Control: post-check=0, pre-check=0', false);
+    @header('Pragma: no-cache');
+    @header('Expires: Mon, 20 Aug 1969 09:23:00 GMT');
+    @header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
+
+//TODO: add rtl support here
+
+    echo '
+
+h2 {
+  text-align:center;
+}
+
+#installdiv {
+  width: 800px;
+  margin-left:auto;
+  margin-right:auto;
+}
+
+#installdiv dt {
+  font-weight: bold;
+}
+
+#installdiv dd {
+  padding-bottom: 0.5em;
+}
+
+.stage {
+  margin-top: 2em;
+  margin-bottom: 2em;
+  width: 100%;
+  padding:25px;
+}
+
+#installform {
+  width: 100%;
+}
+
+#nav_buttons input {
+  margin: 5px;
+}
+
+#envresult {
+  text-align:left;
+  width: auto;
+  margin-left:10em;
+}
+
+#envresult dd {
+  color: red;
+}
+
+.formrow {
+  clear:both;
+  text-align:left;
+  padding: 8px;
+}
+
+.formrow label.formlabel {
+  display:block;
+  float:left;
+  width: 260px;
+  margin-right:5px;
+  text-align:right;
+}
+
+.formrow .forminput {
+  display:block;
+  float:left;
+}
+
+fieldset {
+  text-align:center;
+  border:none;
+}
+
+.hint {
+  display:block;
+  clear:both;
+  padding-left: 265px;
+  color: red;
+}
+
+.configphp {
+  text-align:left;
+  background-color:white;
+  padding:1em;
+  width:95%;
+}
+
+.stage6 .stage {
+  font-weight: bold;
+  color: red;
+}
+
+';
+
+    die;
 }
index 656fa5a29c3d0f0c4a57afa7d2bb0469a06e73dd..a45b7f8a221d0889e4dfdac9442a43f19de3accd 100644 (file)
@@ -5363,19 +5363,24 @@ function get_string($identifier, $module='', $a=NULL, $extralocations=NULL) {
         }
     }
 
-    if (isset($CFG->running_installer)) {
-        $module = 'installer';
-        $filetocheck = 'installer.php';
-        $locations[] = $CFG->dirroot.'/install/lang/';
-        $locations[] = $CFG->dataroot.'/lang/';
-        $locations[] = $CFG->dirroot.'/lang/';
-        $defaultlang = 'en_utf8';
-    } else {
-        $locations[] = $CFG->dataroot.'/lang/';
-        $locations[] = $CFG->dirroot.'/lang/';
-        $locations[] = $CFG->dirroot.'/local/lang/';
+    if (!empty($CFG->running_installer) and $lang !== 'en_utf8') {
+        static $stringnames = null;
+        if (!$stringnames) {
+            $stringnames = file($CFG->dirroot.'/install/stringnames.txt');
+            $stringnames = array_map('trim', $stringnames);
+        }
+        if (array_search($identifier, $stringnames) !== false) {
+            $module = 'installer';
+            $filetocheck = 'installer.php';
+            $defaultlang = 'en_utf8';
+            $locations[] = $CFG->dirroot.'/install/lang/';
+        }
     }
 
+    $locations[] = $CFG->dataroot.'/lang/';
+    $locations[] = $CFG->dirroot.'/lang/';
+    $locations[] = $CFG->dirroot.'/local/lang/';
+
 /// Add extra places to look for strings for particular plugin types.
     $rules = places_to_search_for_lang_strings();
     $exceptions = $rules['__exceptions'];
index fd92ed0c797ff1956ec7d9fc8698634054671b92..d9873cb4641f4b6b7f3eb65ee13f2837b3e57d10 100644 (file)
@@ -327,7 +327,7 @@ function make_upload_directory($directory, $shownotices=true) {
     umask(0000);
 
     if (!file_exists($currdir)) {
-        if (! mkdir($currdir, $CFG->directorypermissions)) {
+        if (!is_writable($currdir) or !mkdir($currdir, $CFG->directorypermissions)) {
             if ($shownotices) {
                 echo '<div class="notifyproblem" align="center">ERROR: You need to create the directory '.
                      $currdir .' with web server write access</div>'."<br />\n";
index 31eb8e12561410be3761014a84cf8d97c54a27c5..2d3222a0d8d6cbe64f907cd0a1d3eee8ba44c37e 100644 (file)
 //                                                                       //
 ///////////////////////////////////////////////////////////////////////////
 
-/// Required files
-    require_once($CFG->libdir.'/typo3/class.t3lib_cs.php');
-    require_once($CFG->libdir.'/typo3/class.t3lib_div.php');
-
-/// If ICONV is available, lets Typo3 library use it for convert
-    if (extension_loaded('iconv')) {
-        $GLOBALS['TYPO3_CONF_VARS']['SYS']['t3lib_cs_convMethod'] = 'iconv';
-    /// Else if mbstring is available, lets Typo3 library use it
-    } else if (extension_loaded('mbstring')) {
-        $GLOBALS['TYPO3_CONF_VARS']['SYS']['t3lib_cs_convMethod'] = 'mbstring';
-    /// Else if recode is available, lets Typo3 library use it
-    } else if (extension_loaded('recode')) {
-        $GLOBALS['TYPO3_CONF_VARS']['SYS']['t3lib_cs_convMethod'] = 'recode';
-    } else {
-        $GLOBALS['TYPO3_CONF_VARS']['SYS']['t3lib_cs_convMethod'] = '';
-    }
-
-/// If mbstring is available, lets Typo3 library use it for functions
-    if (extension_loaded('mbstring')) {
-        $GLOBALS['TYPO3_CONF_VARS']['SYS']['t3lib_cs_utils'] = 'mbstring';
-    } else {
-        $GLOBALS['TYPO3_CONF_VARS']['SYS']['t3lib_cs_utils'] = '';
-    }
-
-/// And this directory must exist to allow Typo to cache conversion
-/// tables when using internal functions
-    make_upload_directory('temp/typo3temp/cs');
-
-/// Default mask for Typo
-    $GLOBALS['TYPO3_CONF_VARS']['BE']['fileCreateMask'] = $CFG->directorypermissions;
-
-/// This full path constants must be defined too, transforming backslashes
-/// to forward slashed beacuse Typo3 requires it.
-    define ('PATH_t3lib', str_replace('\\','/',$CFG->libdir.'/typo3/'));
-    define ('PATH_typo3', str_replace('\\','/',$CFG->libdir.'/typo3/'));
-    define ('PATH_site', str_replace('\\','/',$CFG->dataroot.'/temp/'));
-    define ('TYPO3_OS', stristr(PHP_OS,'win')&&!stristr(PHP_OS,'darwin')?'WIN':'');
-
-
 /// As we implement the singleton pattern to use this class (only one instance
 /// is shared globally), we need this helper function
 
 ///                 from every wrapper function!
 
 function textlib_get_instance() {
-    static $instance;
-    if (!is_object($instance)) {
+    global $CFG;
+
+    static $instance = null;
+
+    if (!$instance) {
+        /// initialisation is delayed because we do not want this on each page ;-)
+
+    /// Required files
+        require_once($CFG->libdir.'/typo3/class.t3lib_cs.php');
+        require_once($CFG->libdir.'/typo3/class.t3lib_div.php');
+
+    /// If ICONV is available, lets Typo3 library use it for convert
+        if (extension_loaded('iconv')) {
+            $GLOBALS['TYPO3_CONF_VARS']['SYS']['t3lib_cs_convMethod'] = 'iconv';
+        /// Else if mbstring is available, lets Typo3 library use it
+        } else if (extension_loaded('mbstring')) {
+            $GLOBALS['TYPO3_CONF_VARS']['SYS']['t3lib_cs_convMethod'] = 'mbstring';
+        /// Else if recode is available, lets Typo3 library use it
+        } else if (extension_loaded('recode')) {
+            $GLOBALS['TYPO3_CONF_VARS']['SYS']['t3lib_cs_convMethod'] = 'recode';
+        } else {
+            $GLOBALS['TYPO3_CONF_VARS']['SYS']['t3lib_cs_convMethod'] = '';
+        }
+
+    /// If mbstring is available, lets Typo3 library use it for functions
+        if (extension_loaded('mbstring')) {
+            $GLOBALS['TYPO3_CONF_VARS']['SYS']['t3lib_cs_utils'] = 'mbstring';
+        } else {
+            $GLOBALS['TYPO3_CONF_VARS']['SYS']['t3lib_cs_utils'] = '';
+        }
+
+    /// And this directory must exist to allow Typo to cache conversion
+    /// tables when using internal functions
+        make_upload_directory('temp/typo3temp/cs');
+
+    /// Default mask for Typo
+        $GLOBALS['TYPO3_CONF_VARS']['BE']['fileCreateMask'] = $CFG->directorypermissions;
+
+    /// This full path constants must be defined too, transforming backslashes
+    /// to forward slashed beacuse Typo3 requires it.
+        define ('PATH_t3lib', str_replace('\\','/',$CFG->libdir.'/typo3/'));
+        define ('PATH_typo3', str_replace('\\','/',$CFG->libdir.'/typo3/'));
+        define ('PATH_site', str_replace('\\','/',$CFG->dataroot.'/temp/'));
+        define ('TYPO3_OS', stristr(PHP_OS,'win')&&!stristr(PHP_OS,'darwin')?'WIN':'');
+
         $instance = new textlib();
     }
     return $instance;