From: skodak Date: Sat, 7 Feb 2009 10:20:33 +0000 (+0000) Subject: MDL-17458 rewritten installer X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=3b09331066a91c51a2de1676ca8179ca7c90f64b;p=moodle.git MDL-17458 rewritten installer --- diff --git a/install.php b/install.php index 199b798fd8..992146c940 100644 --- a/install.php +++ b/install.php @@ -1,195 +1,154 @@ 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 = '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').'
'; - $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').'
'; - $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').'
'; + install_print_header($config, 'config.php', + get_string('configurationcompletehead', 'install'), + get_string('configurationcompletesub', 'install').get_string('configfilenotwritten', 'install')); + echo '
';
+            echo p($configphp);
+            echo '
'; - } else if (is_dataroot_insecure(true) == INSECURE_DATAROOT_ERROR) { - $errormsg .= get_string('datarootpublicerror', 'install').'
'; - } + 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 = '

'.$database->get_name().'

'.$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 '
'; + echo '
'; + echo ''; + echo '
'; - 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 '
'; + echo ''; + echo '
'; - if ($dbfamily == 'oracle' and strlen($INSTALL['prefix']) > 2) { // Oracle max prefix = 2cc (30cc limit) - $errormsg = get_string('dbwrongprefix', 'install'); - $nextstage = DATABASE; - } + echo '
'; + echo ''; + echo '
'; - if ($dbfamily == 'oracle' and !empty ($INSTALL['dbhost'])) { // Oracle host must be blank (tnsnames.ora has it) - $errormsg = get_string('dbwronghostserver', 'install'); - $nextstage = DATABASE; - } + echo '
'; + // no password field here, the password may be visible in config.php if we can not write it to disk + echo ''; + echo '
'; - if (empty($errormsg)) { - error_reporting(0); // Hide errors + echo '
'; + echo ''; + echo '
'; - 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 '
'; + echo ''; + echo ''; + echo '
'; } - error_reporting(38911); - -/// Output db connection error - if ((empty($errormsg) and ($dbconnected === false)) ) { - $errormsg = get_string('dbconnectionerror', 'install'); - $nextstage = DATABASE; - } + echo '
'.$hint_database.'
'; + echo '
'; + 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 = ' 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 '
'; + echo '
'; + echo '
'; + echo '
'; - - $INSTALL['config'] = $str; + install_print_footer($config); + die; } -//==========================================================================// - -?> - - - - -Moodle Install - - - +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 - + if ($version_fail or $curl_fail or $zip_fail) { + $config->stage = INSTALL_ENVIRONMENT; - + install_print_header($config, get_string('environment', 'install'), + get_string('errorsinenvironment', 'install'), + get_string('environmentsub2', 'install')); + echo '
'; + if ($version_fail) { + $a = (object)array('needed'=>'5.2.8', 'current'=>phpversion()); + echo '
'.get_string('phpversion', 'install').'
'.get_string('environmentrequireversion', 'admin', $a).'
'; + } + if ($curl_fail) { + echo '
'.get_string('phpextension', 'install', 'cURL').'
'.get_string('environmentrequireinstall', 'admin').'
'; + } + if ($zip_fail) { + echo '
'.get_string('phpextension', 'install', 'Zip').'
'.get_string('environmentrequireinstall', 'admin').'
'; + } + echo '
'; - - - - - - - - - - - - - - - - -
-

- $database) { - echo ''; - echo '
' . $database->get_configuration_hints(); - echo '

' . get_string('databasesettingswillbecreated', 'install') . '

'; - echo '
'; - } - } else { - if (!empty($substagetext[$nextstage])) { - echo '

' . $substagetext[$nextstage] . '

'; - } - } - ?> -
- -$errormsg

\n"; - - -if ($nextstage == SAVE) { - $INSTALL['stage'] = WELCOME; - $options = array(); - $options['lang'] = $INSTALL['language']; - if ($configsuccess) { - echo "

".get_string('configfilewritten', 'install')."

\n"; - - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "
  \n"; - print_single_button("index.php", $options, get_string('continue')); - echo "
\n"; + install_print_footer($config, true); + die; } else { - echo "

".get_string('configfilenotwritten', 'install')."

"; - - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "
 \n"; - $installoptions = array(); - $installoptions['download'] = 1; - print_single_button("install.php", $installoptions, get_string('download', 'install')); - echo "\n"; - print_single_button("index.php", $options, get_string('continue')); - echo "
\n"; - - echo "
\n"; - echo "
\n"; - echo "
\n";
-        p($INSTALL['config']);
-        echo "
\n"; - echo "
\n"; + $config->stage = INSTALL_PATHS; } -} else { - $formaction = (isset($_GET['configfile'])) ? "install.php?configfile=".$_GET['configfile'] : "install.php"; - form_table($nextstage, $formaction, $databases); } -?> - -
- - - - - - - - - - - - - - - -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; -?> -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -'; + foreach ($paths as $path=>$name) { + $sub .= '
'.$name.'
'.get_string('pathssub'.$path, 'install').'
'; } -?> + $sub .= ''; - - - - + echo ''; -

- -

- -

- -

- -

- - $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();') -?> -

- -

- -

- -

- -

- -

- -
- 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 '

'.get_string('dbconnectionerror', 'install').'

'; - } - ?> -
- ".$INSTALL['downloadlangpackerror']."

\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%'); - } - } - } - ?> -
- - - -
- + $strwwwroot = get_string('wwwroot', 'install'); + $strdirroot = get_string('dirroot', 'install'); + $strdataroot = get_string('dataroot', 'install'); + $stradmindirname = get_string('admindirname', 'install'); - \n" : " \n" ?> - WELCOME) ? "
\n" : " \n" ?> + echo '
'; + echo '
'; + echo ''; + echo '
'; - - -'; + echo ''; + if ($hint_dirroot !== '') { + echo '
'.$hint_dirroot.'
'; } -?> - - -
- - -'; + echo ''; + if ($hint_dataroot !== '') { + echo '
'.$hint_dataroot.'
'; } -?> + echo ''; -\n"; - echo "

$testtext

\n"; - if ($success) { - echo "

".get_string('pass', 'install')."

\n"; - echo " \n"; + if (file_exists("$CFG->dirroot/admin/environment.xml")) { + $disabled = 'disabled="disabled"'; } else { - echo ""; - echo ($caution) ? "

".get_string('caution', 'install') : "

".get_string('fail', 'install'); - echo "

\n"; - echo ""; - echo "

$errormessage "; - if ($helpfield !== '') { - install_helpbutton("install.php?help=$helpfield"); - } - echo "

\n"; + $disabled = ''; } - echo "\n"; - return $success; -} - - -//==========================================================================// - -function install_helpbutton($url, $title='') { - if ($title == '') { - $title = get_string('help'); + echo '
'; + echo ''; + if ($hint_admindir !== '') { + echo '
'.$hint_admindir.'
'; } - echo ""; - echo "\"$title\""; - echo "\n"; -} - + echo '
'; + echo ''; -//==========================================================================// - -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) { -?> - - - - +$config->stage = INSTALL_WELCOME; +install_print_header($config, get_string('language'), + get_string('chooselanguagehead', 'install'), + get_string('chooselanguagesub', 'install')); - +echo ''; +echo ''; - diff --git a/install/lang/en_utf8/installer.php b/install/lang/en_utf8/installer.php index df50401b23..0eb04c640f 100644 --- a/install/lang/en_utf8/installer.php +++ b/install/lang/en_utf8/installer.php @@ -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'] = 'Type: fixed to \"mysqli\" by t User: fixed to \"root\" by the installer
Password: your database password
Tables Prefix: 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.
@@ -161,16 +159,10 @@ $string['databasesettingssub_postgres7'] = 'Type: PostgreSQL
User: your database username
Password: your database password
Tables Prefix: prefix to use for all table names (mandatory)'; -$string['databasesettingssub_sqlite3_pdo'] = 'Type: SQLite 3 (PDO) Experimental! (not for use in production)
- Host: 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
- Name: database name, eg moodle (optional)
- User: your database username (optional)
- Password: your database password (optional)
- Tables Prefix: optional prefix to use for all table names
- The name of the database file will be determined by the username, database name and password you entered above.'; $string['databasesettingswillbecreated'] = 'Note: 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.

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: moodleadmin. 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'] = '

Moodle requires a PHP version of at least 5.2.4.

You are currently running version $a

You must upgrade PHP or move to a host with a newer version of PHP!

'; +$string['phpextension'] = '$a PHP extension'; $string['phpversion'] = 'PHP version'; $string['phpversionhelp'] = '

Moodle requires a PHP version of at least 4.3.0 or 5.1.0 (5.0.x has a number of known problems).

You are currently running version $a

@@ -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&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.

You must download the url\">$a->url 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).

You must download the url\">$a->url file manually, copy it to \"$a->dest\" in your server and unzip it there.'; $string['report'] = 'Report'; diff --git a/install/stringnames.txt b/install/stringnames.txt index cbd8b514d6..d3947aa042 100644 --- a/install/stringnames.txt +++ b/install/stringnames.txt @@ -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 diff --git a/lang/en_utf8/install.php b/lang/en_utf8/install.php index 65be7c3738..eb57517e68 100644 --- a/lang/en_utf8/install.php +++ b/lang/en_utf8/install.php @@ -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'] = 'Type: fixed to \"mysqli\" by t User: fixed to \"root\" by the installer
Password: your database password
Tables Prefix: 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.
@@ -135,16 +136,12 @@ $string['databasesettingssub_postgres7'] = 'Type: PostgreSQL
User: your database username
Password: your database password
Tables Prefix: prefix to use for all table names (mandatory)'; -$string['databasesettingssub_sqlite3_pdo'] = 'Type: SQLite 3 (PDO) Experimental! (not for use in production)
- Host: 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
- Name: database name, eg moodle (optional)
- User: your database username (optional)
- Password: your database password (optional)
- Tables Prefix: optional prefix to use for all table names
- The name of the database file will be determined by the username, database name and password you entered above.'; $string['databasesettingswillbecreated'] = 'Note: 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: moodleadmin. 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'] = '

Moodle requires a PHP version of at least 5.2.4.

You are currently running version $a

You must upgrade PHP or move to a host with a newer version of PHP!

'; +$string['phpextension'] = '$a PHP extension'; $string['phpversion'] = 'PHP version'; $string['phpversionhelp'] = '

Moodle requires a PHP version of at least 4.3.0 or 5.1.0 (5.0.x has a number of known problems).

You are currently running version $a

@@ -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) Experimental! (not for use in production)'; +$string['pdosqlite3'] = 'SQLite 3 (PDO) Experimental! (not for use in production)'; $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'; diff --git a/lib/dml/adodb_moodle_database.php b/lib/dml/adodb_moodle_database.php index 703ee48a21..12bbf1e836 100644 --- a/lib/dml/adodb_moodle_database.php +++ b/lib/dml/adodb_moodle_database.php @@ -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; */ diff --git a/lib/dml/moodle_database.php b/lib/dml/moodle_database.php index 08baff21c0..ce8b15b2c7 100644 --- a/lib/dml/moodle_database.php +++ b/lib/dml/moodle_database.php @@ -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; } diff --git a/lib/dml/mysqli_adodb_moodle_database.php b/lib/dml/mysqli_adodb_moodle_database.php index bb95379e03..23d4c48719 100644 --- a/lib/dml/mysqli_adodb_moodle_database.php +++ b/lib/dml/mysqli_adodb_moodle_database.php @@ -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")) { diff --git a/lib/dml/mysqli_native_moodle_database.php b/lib/dml/mysqli_native_moodle_database.php index 4068244493..64517fdb42 100644 --- a/lib/dml/mysqli_native_moodle_database.php +++ b/lib/dml/mysqli_native_moodle_database.php @@ -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); diff --git a/lib/dml/oci_native_moodle_database.php b/lib/dml/oci_native_moodle_database.php index 965d48769b..7d3c070a63 100644 --- a/lib/dml/oci_native_moodle_database.php +++ b/lib/dml/oci_native_moodle_database.php @@ -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, "'\\"); diff --git a/lib/dml/pdo_moodle_database.php b/lib/dml/pdo_moodle_database.php index 647544d055..294174696e 100644 --- a/lib/dml/pdo_moodle_database.php +++ b/lib/dml/pdo_moodle_database.php @@ -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'); } /** diff --git a/lib/dml/pgsql_native_moodle_database.php b/lib/dml/pgsql_native_moodle_database.php index a54797d113..365f4e87a6 100644 --- a/lib/dml/pgsql_native_moodle_database.php +++ b/lib/dml/pgsql_native_moodle_database.php @@ -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 = ""; diff --git a/lib/dml/postgres7_adodb_moodle_database.php b/lib/dml/postgres7_adodb_moodle_database.php index cc2c5ffe1f..678f6586ff 100644 --- a/lib/dml/postgres7_adodb_moodle_database.php +++ b/lib/dml/postgres7_adodb_moodle_database.php @@ -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(); diff --git a/lib/dml/sqlite3_pdo_moodle_database.php b/lib/dml/sqlite3_pdo_moodle_database.php index c97d458e2b..d6439c3d84 100644 --- a/lib/dml/sqlite3_pdo_moodle_database.php +++ b/lib/dml/sqlite3_pdo_moodle_database.php @@ -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; diff --git a/lib/installlib.php b/lib/installlib.php index ad88c0efc1..efc05d1a9b 100644 --- a/lib/installlib.php +++ b/lib/installlib.php @@ -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 ""; + echo "\"$title\""; + echo "\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).'
'.$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 ''; + echo ' + + + + '.get_string('installation','install').' + + + '; + + echo ''; + 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 ''; + 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 ''; + echo ' + + '; + + $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 ''."\n"; + } + + echo ' + '.get_string('installation','install').' - Moodle '.$CFG->release.' + + + '; + + echo ' +
+ + +
'; - /// Otherwise, see if we can change it ourselves - @ini_set('memory_limit', '40M'); - return ((int)str_replace('M', '', get_memory_limit()) >= 40); + echo '

'.$heading.'

'; + + if ($stagetext !== '') { + echo '
'; + echo $stagetext; + echo '
'; + } + // main + echo '
'; + foreach ($config as $name=>$value) { + echo ''; + } } -/** - * 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 = ''; + } else { + $first = ''; + } + + if ($reload) { + $next = ''; + } else { + $next = ''; + } + + echo '
'; + + $homelink = ''; + + echo '
'; + echo ''; + echo '
'; +} + + +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; } diff --git a/lib/moodlelib.php b/lib/moodlelib.php index 656fa5a29c..a45b7f8a22 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -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']; diff --git a/lib/setuplib.php b/lib/setuplib.php index fd92ed0c79..d9873cb464 100644 --- a/lib/setuplib.php +++ b/lib/setuplib.php @@ -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 '
ERROR: You need to create the directory '. $currdir .' with web server write access
'."
\n"; diff --git a/lib/textlib.class.php b/lib/textlib.class.php index 31eb8e1256..2d3222a0d8 100644 --- a/lib/textlib.class.php +++ b/lib/textlib.class.php @@ -24,45 +24,6 @@ // // /////////////////////////////////////////////////////////////////////////// -/// 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 @@ -71,8 +32,51 @@ /// 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;