MDL-17457 migrated all modules to new db/install.php; added upgrade.txt file for...
[moodle.git] / install.php
CommitLineData
8b5b1028 1<?php /// $Id$
2 /// install.php - helps admin user to create a config.php file
3
4/// If config.php exists already then we are not needed.
5
53a0367d 6if (file_exists('./config.php')) {
8b5b1028 7 header('Location: index.php');
51e3e0b9 8 die;
8b5b1028 9} else {
10 $configfile = './config.php';
11}
12
13///==========================================================================//
14/// We are doing this in stages
3470b39f 15define ('WELCOME', 0); /// 0. Welcome and language settings
16define ('COMPATIBILITY', 1); /// 1. Compatibility
17define ('DIRECTORY', 2); /// 2. Directory settings
18define ('DATABASE', 3); /// 2. Database settings
19define ('ADMIN', 4); /// 4. Administration directory name
3b3b8029 20define ('ENVIRONMENT', 5); /// 5. Administration directory name
68a3f81d 21define ('DOWNLOADLANG', 6); /// 6. Load complete lang from download.moodle.org
22define ('SAVE', 7); /// 7. Save or display the settings
23define ('REDIRECT', 8); /// 8. Redirect to index.php
8b5b1028 24///==========================================================================//
25
26
23b86e1c 27/// This has to be defined to avoid a notice in current_language()
28define('SITEID', 0);
8d783716 29
8b5b1028 30/// Begin the session as we are holding all information in a session
31/// variable until the end.
32
33session_name('MoodleSession');
34@session_start();
35
41aa8437 36/// make sure PHP errors are displayed to help diagnose problems
37@error_reporting(1023); //E_ALL not used because we do not want strict notices in PHP5 yet
38@ini_set('display_errors', '1');
39
8b5b1028 40if (! isset($_SESSION['INSTALL'])) {
41 $_SESSION['INSTALL'] = array();
42}
43
44$INSTALL = &$_SESSION['INSTALL']; // Makes it easier to reference
45
d36afd6d 46/// detect if install was attempted from diferent directory, if yes reset session to prevent errors,
47/// dirroot location now fixed in installer
48if (!empty($INSTALL['dirroot']) and $INSTALL['dirroot'] != dirname(__FILE__)) {
49 $_SESSION['INSTALL'] = array();
50}
8d783716 51
52/// If it's our first time through this script then we need to set some default values
53
54if ( empty($INSTALL['language']) and empty($_POST['language']) ) {
8b5b1028 55
56 /// set defaults
b9b4e32a 57 $INSTALL['language'] = 'en_utf8';
8b5b1028 58
59 $INSTALL['dbhost'] = 'localhost';
60 $INSTALL['dbuser'] = '';
61 $INSTALL['dbpass'] = '';
6d5a22b2 62 $INSTALL['dbtype'] = 'mysqli_adodb';
8b5b1028 63 $INSTALL['dbname'] = 'moodle';
64 $INSTALL['prefix'] = 'mdl_';
65
cdef6d42 66 $INSTALL['downloadlangpack'] = false;
67 $INSTALL['showdownloadlangpack'] = true;
68 $INSTALL['downloadlangpackerror'] = '';
69
70/// To be used by the Installer
8b5b1028 71 $INSTALL['wwwroot'] = '';
72 $INSTALL['dirroot'] = dirname(__FILE__);
9b70d314 73 $INSTALL['dataroot'] = dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'moodledata';
8b5b1028 74
cdef6d42 75/// To be configured in the Installer
76 $INSTALL['wwwrootform'] = '';
77 $INSTALL['dirrootform'] = dirname(__FILE__);
78
8b5b1028 79 $INSTALL['admindirname'] = 'admin';
80
3470b39f 81 $INSTALL['stage'] = WELCOME;
8b5b1028 82}
83
3b3b8029 84//==========================================================================//
85
bd507453 86/// Set the page to Unicode always
87
88header('Content-Type: text/html; charset=UTF-8');
89
3b3b8029 90/// Was data submitted?
91
92if (isset($_POST['stage'])) {
93
94 /// Get the stage for which the form was set and the next stage we are going to
95
56ca1c60 96 $gpc = ini_get('magic_quotes_gpc');
97 $gpc = ($gpc == '1' or strtolower($gpc) == 'on');
98
d36afd6d 99 /// Store any posted data
100 foreach ($_POST as $setting=>$value) {
56ca1c60 101 if ($gpc) {
102 $value = stripslashes($value);
103 }
104
d36afd6d 105 $INSTALL[$setting] = $value;
106 }
3b3b8029 107
108 if ( $goforward = (! empty( $_POST['next'] )) ) {
109 $nextstage = $_POST['stage'] + 1;
cdef6d42 110 } else if (! empty( $_POST['prev'])) {
3b3b8029 111 $nextstage = $_POST['stage'] - 1;
d36afd6d 112 $INSTALL['stage'] = $_POST['stage'] - 1;
cdef6d42 113 } else if (! empty( $_POST['same'] )) {
114 $nextstage = $_POST['stage'];
3b3b8029 115 }
116
f49312b6 117 $nextstage = (int)$nextstage;
3b3b8029 118
d36afd6d 119 if ($nextstage < 0) {
120 $nextstage = WELCOME;
3b3b8029 121 }
53a0367d 122
d36afd6d 123
3b3b8029 124} else {
8b5b1028 125
3b3b8029 126 $goforward = true;
127 $nextstage = WELCOME;
53a0367d 128
3b3b8029 129}
8b5b1028 130
131//==========================================================================//
132
133/// Fake some settings so that we can use selected functions from moodlelib.php and weblib.php
8d783716 134
8b5b1028 135$SESSION->lang = (!empty($_POST['language'])) ? $_POST['language'] : $INSTALL['language'];
136$CFG->dirroot = $INSTALL['dirroot'];
72452dc1 137$CFG->libdir = $INSTALL['dirroot'].'/lib';
8b5b1028 138$CFG->dataroot = $INSTALL['dataroot'];
3b3b8029 139$CFG->admin = $INSTALL['admindirname'];
4b9efec4 140$CFG->directorypermissions = 00777;
b9b4e32a 141$CFG->running_installer = true;
e4b89caa 142$CFG->docroot = 'http://docs.moodle.org';
2253a296 143$CFG->httpswwwroot = $INSTALL['wwwrootform']; // Needed by doc_link() in Server Checks page.
70205c74 144$COURSE->id = 0;
8b5b1028 145
8d783716 146/// Include some moodle libraries
147
d36afd6d 148require_once($CFG->libdir.'/setuplib.php');
9d068cd6 149require_once($CFG->libdir.'/installlib.php');
d36afd6d 150require_once($CFG->libdir.'/weblib.php');
251387d0 151require_once($CFG->libdir.'/deprecatedlib.php');
152require_once($CFG->libdir.'/moodlelib.php');
153require_once($CFG->libdir.'/adminlib.php');
d36afd6d 154require_once($CFG->libdir.'/environmentlib.php');
155require_once($CFG->libdir.'/xmlize.php');
156require_once($CFG->libdir.'/componentlib.class.php');
157require_once($CFG->dirroot.'/version.php');
8b5b1028 158
3b3b8029 159/// Set version and release
160$INSTALL['version'] = $version;
161$INSTALL['release'] = $release;
162
6d5a22b2 163/// list all supported drivers - unsupported must be installed manually ;-)
164$supported = array (
165 'mysqli_adodb',
166 'mysql_adodb',
167 'postgres7_adodb',
168 'mssql_n_adodb',
169 'mssql_adodb',
170 'odbc_mssql_adodb',
55946ffd 171 'oci8po_adodb',
172 'sqlite3_pdo',
6d5a22b2 173);
174$databases = array ();
175foreach($supported as $driver) {
176 $classname = $driver.'_moodle_database';
177 require_once ("$CFG->libdir/dml/$classname.php");
178 $databases[$driver] = new $classname ();
179}
8b5b1028 180
bb5a61a1 181/// guess the www root
8b5b1028 182if ($INSTALL['wwwroot'] == '') {
11e7b506 183 $INSTALL['wwwroot'] = install_guess_wwwroot();
cdef6d42 184 $INSTALL['wwwrootform'] = $INSTALL['wwwroot'];
add47d44 185
186 // now try to guess the correct dataroot not accessible via web
187 $CFG->wwwroot = $INSTALL['wwwroot'];
188 $i = 0; //safety check - dirname might return some unexpected results
189 while(is_dataroot_insecure()) {
190 $parrent = dirname($CFG->dataroot);
191 $i++;
b735d140 192 if ($parrent == '/' or $parrent == '.' or preg_match('/^[a-z]:\\\?$/i', $parrent) or ($i > 100)) {
add47d44 193 $CFG->dataroot = ''; //can not find secure location for dataroot
194 break;
195 }
196 $CFG->dataroot = dirname($parrent).'/moodledata';
197 }
46300167 198 $INSTALL['dataroot'] = $CFG->dataroot;
8b5b1028 199}
200
e6f930f3 201$headstagetext = array(WELCOME => get_string('chooselanguagehead', 'install'),
202 COMPATIBILITY => get_string('compatibilitysettingshead', 'install'),
203 DIRECTORY => get_string('directorysettingshead', 'install'),
204 DATABASE => get_string('databasesettingshead', 'install'),
205 ADMIN => get_string('admindirsettinghead', 'install'),
3b3b8029 206 ENVIRONMENT => get_string('environmenthead', 'install'),
68a3f81d 207 DOWNLOADLANG => get_string('downloadlanguagehead', 'install'),
e6f930f3 208 SAVE => get_string('configurationcompletehead', 'install')
209 );
8b5b1028 210
e6f930f3 211$substagetext = array(WELCOME => get_string('chooselanguagesub', 'install'),
212 COMPATIBILITY => get_string('compatibilitysettingssub', 'install'),
213 DIRECTORY => get_string('directorysettingssub', 'install'),
214 DATABASE => get_string('databasesettingssub', 'install'),
215 ADMIN => get_string('admindirsettingsub', 'install'),
3b3b8029 216 ENVIRONMENT => get_string('environmentsub', 'install'),
68a3f81d 217 DOWNLOADLANG => get_string('downloadlanguagesub', 'install'),
e6f930f3 218 SAVE => get_string('configurationcompletesub', 'install')
219 );
8b5b1028 220
8d783716 221
222
223//==========================================================================//
224
225/// Are we in help mode?
226
227if (isset($_GET['help'])) {
228 $nextstage = -1;
229}
230
231
51e3e0b9 232
edd3a5db 233//==========================================================================//
234
51e3e0b9 235/// Are we in config download mode?
edd3a5db 236
51e3e0b9 237if (isset($_GET['download'])) {
53a0367d 238 header("Content-Type: application/x-forcedownload\n");
51e3e0b9 239 header("Content-Disposition: attachment; filename=\"config.php\"");
240 echo $INSTALL['config'];
241 exit;
edd3a5db 242}
8d783716 243
51e3e0b9 244
245
8b5b1028 246
247
248//==========================================================================//
249
250/// Check the directory settings
8d783716 251
3470b39f 252if ($INSTALL['stage'] == DIRECTORY) {
8b5b1028 253
254 error_reporting(0);
53a0367d 255
2df3a721 256 /// check wwwroot
6d5a22b2 257 if (ini_get('allow_url_fopen') && false) { /// This was not reliable
cdef6d42 258 if (($fh = @fopen($INSTALL['wwwrootform'].'/install.php', 'r')) === false) {
2df3a721 259 $errormsg .= get_string('wwwrooterror', 'install').'<br />';
cdef6d42 260 $INSTALL['wwwrootform'] = $INSTALL['wwwroot'];
6d5a22b2 261 fclose($fh);
8b5b1028 262 }
263 }
53a0367d 264
cdef6d42 265 /// check dirroot
6d5a22b2 266 if (($fh = @fopen($INSTALL['dirrootform'].'/install.php', 'r')) === false) {
cdef6d42 267 $errormsg .= get_string('dirrooterror', 'install').'<br />';
268 $INSTALL['dirrootform'] = $INSTALL['dirroot'];
6d5a22b2 269 fclose($fh);
53a0367d 270 }
2df3a721 271
272 /// check dataroot
273 $CFG->dataroot = $INSTALL['dataroot'];
bba0beae 274 $CFG->wwwroot = $INSTALL['wwwroot'];
6d5a22b2 275 if (make_upload_directory('sessions', false) === false) {
cdef6d42 276 $errormsg .= get_string('datarooterror', 'install').'<br />';
bba0beae 277
278 } else if (is_dataroot_insecure(true) == INSECURE_DATAROOT_ERROR) {
279 $errormsg .= get_string('datarootpublicerror', 'install').'<br />';
2df3a721 280 }
8b5b1028 281
6d5a22b2 282 if (!empty($errormsg)) {
283 $nextstage = DIRECTORY;
284 }
8b5b1028 285
6d5a22b2 286 error_reporting(38911);
8b5b1028 287}
288
289
290
291//==========================================================================//
292
293/// Check database settings if stage 3 data submitted
294/// Try to connect to the database. If that fails then try to create the database
8d783716 295
3470b39f 296if ($INSTALL['stage'] == DATABASE) {
53a0367d 297
6d5a22b2 298 $DB = $databases[$INSTALL['dbtype']];
8d783716 299
6d5a22b2 300 $dbfamily = $DB->get_dbfamily();
301 $errormsg = $DB->driver_installed();
8b5b1028 302
6d5a22b2 303 if ($errormsg === true) {
304 $errormsg = '';
305 } else {
306 $nextstage = DATABASE;
86453d8b 307 }
308
6d5a22b2 309 if (empty($INSTALL['prefix']) and $dbfamily != 'mysql') { // All DBs but MySQL require prefix (reserv. words)
86453d8b 310 $errormsg = get_string('dbwrongprefix', 'install');
311 $nextstage = DATABASE;
312 }
313
6d5a22b2 314 if ($dbfamily == 'oracle' and strlen($INSTALL['prefix']) > 2) { // Oracle max prefix = 2cc (30cc limit)
86453d8b 315 $errormsg = get_string('dbwrongprefix', 'install');
316 $nextstage = DATABASE;
317 }
318
6d5a22b2 319 if ($dbfamily == 'oracle' and !empty ($INSTALL['dbhost'])) { // Oracle host must be blank (tnsnames.ora has it)
86453d8b 320 $errormsg = get_string('dbwronghostserver', 'install');
321 $nextstage = DATABASE;
322 }
323
fe515206 324 if (empty($errormsg)) {
53a0367d 325 error_reporting(0); // Hide errors
fe515206 326
2f17b76d 327 if (! $dbconnected = $DB->connect($INSTALL['dbhost'], $INSTALL['dbuser'], $INSTALL['dbpass'], $INSTALL['dbname'], $INSTALL['prefix'])) {
55946ffd 328 if (!$DB->create_database($INSTALL['dbhost'], $INSTALL['dbuser'], $INSTALL['dbpass'], $INSTALL['dbname'])) {
e4c033a9 329 $errormsg = get_string('dbcreationerror', 'install');
330 $nextstage = DATABASE;
331 } else {
2f17b76d 332 $dbconnected = $DB->connect($INSTALL['dbhost'], $INSTALL['dbuser'], $INSTALL['dbpass'], $INSTALL['dbname'], $INSTALL['prefix']);
8b5b1028 333 }
b4dd571d 334 } else {
6d5a22b2 335// TODO: db encoding checks ??
8b5b1028 336 }
337 }
338
6d5a22b2 339 error_reporting(38911);
8b5b1028 340
6d5a22b2 341/// Output db connection error
342 if ((empty($errormsg) and ($dbconnected === false)) ) {
8b5b1028 343 $errormsg = get_string('dbconnectionerror', 'install');
3470b39f 344 $nextstage = DATABASE;
8b5b1028 345 }
346}
347
348
349
350//==========================================================================//
351
352/// If the next stage is admin directory settings OR we have just come from there then
353/// check the admin directory.
354/// If we can open a file then we know that the admin name is correct.
355
3470b39f 356if ($nextstage == ADMIN or $INSTALL['stage'] == ADMIN) {
91099e36 357 if (!ini_get('allow_url_fopen')) {
3b3b8029 358 $nextstage = ($goforward) ? ENVIRONMENT : DATABASE;
78850d9e 359 } else if (($fh = @fopen($INSTALL['wwwrootform'].'/'.$INSTALL['admindirname'].'/environment.xml', 'r')) !== false) {
3b3b8029 360 $nextstage = ($goforward) ? ENVIRONMENT : DATABASE;
8b5b1028 361 fclose($fh);
362 } else {
e2850d15 363 $nextstage = ($goforward) ? ENVIRONMENT : DATABASE;
364 //if ($nextstage != ADMIN) {
365 // $errormsg = get_string('admindirerror', 'install');
366 // $nextstage = ADMIN;
367 // }
8b5b1028 368 }
369}
370
3b3b8029 371//==========================================================================//
372
373// Check if we can navigate from the environemt page (because it's ok)
374
375if ($INSTALL['stage'] == ENVIRONMENT) {
6d5a22b2 376 $DB = $databases[$INSTALL['dbtype']];
377
3b3b8029 378 error_reporting(0); // Hide errors
2f17b76d 379 $dbconnected = $DB->connect($INSTALL['dbhost'], $INSTALL['dbuser'], $INSTALL['dbpass'], $INSTALL['dbname'], $INSTALL['prefix']);
6d5a22b2 380 error_reporting(38911); // Show errors
3b3b8029 381 if ($dbconnected) {
382 /// Execute environment check, printing results
383 if (!check_moodle_environment($INSTALL['release'], $environment_results, false)) {
384 $nextstage = ENVIRONMENT;
385 }
386 } else {
387 /// We never should reach this because DB has been tested before arriving here
388 $errormsg = get_string('dbconnectionerror', 'install');
389 $nextstage = DATABASE;
390 }
391}
8b5b1028 392
cdef6d42 393
394
395//==========================================================================//
396
397// Try to download the lang pack if it has been selected
398
399if ($INSTALL['stage'] == DOWNLOADLANG && $INSTALL['downloadlangpack']) {
400
401 $downloadsuccess = false;
402 $downloaderror = '';
403
404 error_reporting(0); // Hide errors
405
406/// Create necessary lang dir
407 if (!make_upload_directory('lang', false)) {
408 $downloaderror = get_string('cannotcreatelangdir', 'error');
409 }
410
411/// Download and install component
412 if (($cd = new component_installer('http://download.moodle.org', 'lang16',
413 $INSTALL['language'].'.zip', 'languages.md5', 'lang')) && empty($errormsg)) {
f85236dc 414 $status = $cd->install(); //returns COMPONENT_(ERROR | UPTODATE | INSTALLED)
cdef6d42 415 switch ($status) {
f85236dc 416 case COMPONENT_ERROR:
a7d43f0d 417 if ($cd->get_error() == 'remotedownloaderror') {
cdef6d42 418 $a = new stdClass();
6a525ce2 419 $a->url = 'http://download.moodle.org/lang16/'.$INSTALL['language'].'.zip';
cdef6d42 420 $a->dest= $CFG->dataroot.'/lang';
421 $downloaderror = get_string($cd->get_error(), 'error', $a);
422 } else {
423 $downloaderror = get_string($cd->get_error(), 'error');
424 }
425 break;
f85236dc 426 case COMPONENT_UPTODATE:
427 case COMPONENT_INSTALLED:
cdef6d42 428 $downloadsuccess = true;
429 break;
430 default:
431 //We shouldn't reach this point
432 }
433 } else {
434 //We shouldn't reach this point
435 }
436
6d5a22b2 437 error_reporting(38911); // Show errors
cdef6d42 438
439 if ($downloadsuccess) {
440 $INSTALL['downloadlangpack'] = false;
441 $INSTALL['showdownloadlangpack'] = false;
442 $INSTALL['downloadlangpackerror'] = $downloaderror;
443 } else {
444 $INSTALL['downloadlangpack'] = false;
445 $INSTALL['showdownloadlangpack'] = false;
446 $INSTALL['downloadlangpackerror'] = $downloaderror;
447 }
53a0367d 448}
cdef6d42 449
450
451
8b5b1028 452//==========================================================================//
453
454/// Display or print the data
455/// Put the data into a string
456/// Try to open config file for writing.
8d783716 457
3470b39f 458if ($nextstage == SAVE) {
51e3e0b9 459
6d5a22b2 460 $str = '<?php /// Moodle Configuration File ' . "\r\n";
51e3e0b9 461 $str .= "\r\n";
462
463 $str .= 'unset($CFG);'."\r\n";
6d5a22b2 464 $str .= '$CFG = new stdClass();'."\r\n"; // prevent PHP5 strict warnings
51e3e0b9 465 $str .= "\r\n";
466
b553527e 467 $DB = $databases[$INSTALL['dbtype']];
beaa43db 468 $dbconfig = $DB->export_dbconfig($INSTALL['dbhost'], $INSTALL['dbuser'], $INSTALL['dbpass'], $INSTALL['dbname'], $INSTALL['prefix']);
6d5a22b2 469
470 foreach ($dbconfig as $key=>$value) {
471 $key = str_pad($key, 9);
16a5642c 472 $str .= '$CFG->'.$key.' = '.var_export($value, true).";\r\n";
51e3e0b9 473 }
51e3e0b9 474 $str .= "\r\n";
475
16a5642c 476 $str .= '$CFG->wwwroot = '.var_export($INSTALL['wwwrootform'], true).";\r\n";
477 $str .= '$CFG->dirroot = '.var_export($INSTALL['dirrootform'], true).";\r\n";
478 $str .= '$CFG->dataroot = '.var_export($INSTALL['dataroot'], true).";\r\n";
479 $str .= '$CFG->admin = '.var_export($INSTALL['admindirname'], true).";\r\n";
51e3e0b9 480 $str .= "\r\n";
481
6e86ae68 482 $str .= '$CFG->directorypermissions = 00777; // try 02777 on a server in Safe Mode'."\r\n";
51e3e0b9 483 $str .= "\r\n";
484
485 $str .= 'require_once("$CFG->dirroot/lib/setup.php");'."\r\n";
486 $str .= '// MAKE SURE WHEN YOU EDIT THIS FILE THAT THERE ARE NO SPACES, BLANK LINES,'."\r\n";
487 $str .= '// RETURNS, OR ANYTHING ELSE AFTER THE TWO CHARACTERS ON THE NEXT LINE.'."\r\n";
488 $str .= '?>';
489
7c561c7a 490 umask(0137);
491
8b5b1028 492 if (( $configsuccess = ($fh = @fopen($configfile, 'w')) ) !== false) {
493 fwrite($fh, $str);
494 fclose($fh);
495 }
53a0367d 496
51e3e0b9 497
498 $INSTALL['config'] = $str;
8b5b1028 499}
500
501
502
503//==========================================================================//
504
505?>
dc71bb7d 506<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
dfcdf072 507<html dir="<?php echo (right_to_left() ? 'rtl' : 'ltr'); ?>">
8b5b1028 508<head>
f96660f8 509<link rel="shortcut icon" href="theme/standard/favicon.ico" />
8b5b1028 510<title>Moodle Install</title>
bd507453 511<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
6d5a22b2 512<?php css_styles($databases) ?>
513<?php database_js($databases) ?>
8b5b1028 514
515</head>
516
517<body>
518
8d783716 519
520<?php
521if (isset($_GET['help'])) {
522 print_install_help($_GET['help']);
51e3e0b9 523 close_window_button();
8d783716 524} else {
525?>
526
8b5b1028 527
dc71bb7d 528<table class="main" cellpadding="3" cellspacing="0">
8b5b1028 529 <tr>
8d783716 530 <td class="td_mainlogo">
dc71bb7d 531 <p class="p_mainlogo"><img src="pix/moodlelogo-med.gif" width="240" height="60" alt="Moodle logo"/></p>
8d783716 532 </td>
533 <td class="td_mainlogo" valign="bottom">
534 <p class="p_mainheader"><?php print_string('installation', 'install') ?></p>
535 </td>
536 </tr>
537
538 <tr>
539 <td class="td_mainheading" colspan="2">
e6f930f3 540 <p class="p_mainheading"><?php echo $headstagetext[$nextstage] ?></p>
86453d8b 541 <?php /// Exceptionaly, depending of the DB selected, we show some different text
542 /// from the standard one to show better instructions for each DB
543 if ($nextstage == DATABASE) {
6d5a22b2 544 foreach ($databases as $driver=>$database) {
545 echo '<script type="text/javascript" defer="defer">window.onload=toggledbinfo;</script>';
546 echo '<div id="'.$driver.'">' . $database->get_configuration_hints();
547 echo '<p style="text-align: center">' . get_string('databasesettingswillbecreated', 'install') . '</p>';
548 echo '</div>';
549 }
86453d8b 550 } else {
551 if (!empty($substagetext[$nextstage])) {
552 echo '<p class="p_subheading">' . $substagetext[$nextstage] . '</p>';
553 }
554 }
555 ?>
8d783716 556 </td>
8b5b1028 557 </tr>
558
559 <tr>
8d783716 560 <td class="td_main" colspan="2">
53a0367d 561
8b5b1028 562<?php
563
dc71bb7d 564if (!empty($errormsg)) echo "<p class=\"errormsg\" style=\"text-align:center\">$errormsg</p>\n";
8b5b1028 565
566
3470b39f 567if ($nextstage == SAVE) {
568 $INSTALL['stage'] = WELCOME;
51e3e0b9 569 $options = array();
570 $options['lang'] = $INSTALL['language'];
8b5b1028 571 if ($configsuccess) {
dc71bb7d 572 echo "<p class=\"p_install\">".get_string('configfilewritten', 'install')."</p>\n";
51e3e0b9 573
574 echo "<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"100%\">\n";
575 echo "<tr>\n";
dc71bb7d 576 echo "<td>&nbsp;</td>\n";
577 echo "<td>&nbsp;</td>\n";
578 echo "<td align=\"right\">\n";
5bc28e71 579 print_single_button("index.php", $options, get_string('continue'));
51e3e0b9 580 echo "</td>\n";
581 echo "</tr>\n";
582 echo "</table>\n";
583
8b5b1028 584 } else {
51e3e0b9 585 echo "<p class=\"errormsg\">".get_string('configfilenotwritten', 'install')."</p>";
53a0367d 586
51e3e0b9 587 echo "<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"100%\">\n";
588 echo "<tr>\n";
dc71bb7d 589 echo "<td>&nbsp;</td>\n";
590 echo "<td align=\"center\">\n";
51e3e0b9 591 $installoptions = array();
53a0367d 592 $installoptions['download'] = 1;
51e3e0b9 593 print_single_button("install.php", $installoptions, get_string('download', 'install'));
594 echo "</td>\n";
dc71bb7d 595 echo "<td align=\"right\">\n";
5bc28e71 596 print_single_button("index.php", $options, get_string('continue'));
51e3e0b9 597 echo "</td>\n";
598 echo "</tr>\n";
599 echo "</table>\n";
600
8b5b1028 601 echo "<hr />\n";
99238bf4 602 echo "<div style=\"text-align: ".fix_align_rtl("left")."\">\n";
3efc0668 603 echo "<pre>\n";
6d5a22b2 604 p($INSTALL['config']);
3efc0668 605 echo "</pre>\n";
51e3e0b9 606 echo "</div>\n";
8b5b1028 607 }
8b5b1028 608} else {
609 $formaction = (isset($_GET['configfile'])) ? "install.php?configfile=".$_GET['configfile'] : "install.php";
6d5a22b2 610 form_table($nextstage, $formaction, $databases);
8b5b1028 611}
612
613?>
614
615 </td>
616 </tr>
617</table>
618
8d783716 619<?php
620}
621?>
622
8b5b1028 623</body>
624</html>
625
626
627
628
629
630
631
632
633
634
53a0367d 635<?php
8b5b1028 636
8b5b1028 637
638//==========================================================================//
639
6d5a22b2 640function form_table($nextstage, $formaction, $databases) {
08d9fb36 641 global $INSTALL, $DB;
8b5b1028 642
627d326a 643 $enablenext = true;
644
cdef6d42 645 /// Print the standard form if we aren't in the DOWNLOADLANG page
646 /// because it has its own form.
647 if ($nextstage != DOWNLOADLANG) {
648 $needtoopenform = false;
8b5b1028 649?>
d2ce367f 650 <form id="installform" method="post" action="<?php echo $formaction ?>">
dc71bb7d 651 <div><input type="hidden" name="stage" value="<?php echo $nextstage ?>" /></div>
8b5b1028 652
cdef6d42 653<?php
654 } else {
655 $needtoopenform = true;
656 }
657?>
dc71bb7d 658 <table class="install_table" cellspacing="3" cellpadding="3">
8b5b1028 659
660<?php
661 /// what we do depends on the stage we're at
662 switch ($nextstage) {
3470b39f 663 case WELCOME: /// Welcome and language settings
8b5b1028 664?>
665 <tr>
dc71bb7d 666 <td class="td_left"><p class="p_install"><?php print_string('language') ?></p></td>
8b5b1028 667 <td class="td_right">
b9b4e32a 668 <?php choose_from_menu (get_installer_list_of_languages(), 'language', $INSTALL['language'], '') ?>
8b5b1028 669 </td>
670 </tr>
671
672<?php
8d783716 673 break;
3470b39f 674 case COMPATIBILITY: /// Compatibilty check
8d783716 675 $compatsuccess = true;
53a0367d 676
8d783716 677 /// Check that PHP is of a sufficient version
b4ac6245 678 print_compatibility_row(inst_check_php_version(), get_string('phpversion', 'install'), get_string('php52versionerror', 'install'), 'php52versionhelp');
627d326a 679 $enablenext = $enablenext && inst_check_php_version();
8d783716 680 /// Check session auto start
681 print_compatibility_row(!ini_get_bool('session.auto_start'), get_string('sessionautostart', 'install'), get_string('sessionautostarterror', 'install'), 'sessionautostarthelp');
627d326a 682 $enablenext = $enablenext && !ini_get_bool('session.auto_start');
8d783716 683 /// Check magic quotes
684 print_compatibility_row(!ini_get_bool('magic_quotes_runtime'), get_string('magicquotesruntime', 'install'), get_string('magicquotesruntimeerror', 'install'), 'magicquotesruntimehelp');
627d326a 685 $enablenext = $enablenext && !ini_get_bool('magic_quotes_runtime');
4d46a3f0 686 /// Check unsupported PHP configuration
627d326a 687 print_compatibility_row(!ini_get_bool('register_globals'), get_string('globalsquotes', 'install'), get_string('globalswarning', 'install'));
688 $enablenext = $enablenext && !ini_get_bool('register_globals');
53a0367d 689 /// Check safe mode
51e3e0b9 690 print_compatibility_row(!ini_get_bool('safe_mode'), get_string('safemode', 'install'), get_string('safemodeerror', 'install'), 'safemodehelp', true);
8d783716 691 /// Check file uploads
51e3e0b9 692 print_compatibility_row(ini_get_bool('file_uploads'), get_string('fileuploads', 'install'), get_string('fileuploadserror', 'install'), 'fileuploadshelp', true);
8d783716 693 /// Check GD version
51e3e0b9 694 print_compatibility_row(check_gd_version(), get_string('gdversion', 'install'), get_string('gdversionerror', 'install'), 'gdversionhelp', true);
8d783716 695 /// Check memory limit
51e3e0b9 696 print_compatibility_row(check_memory_limit(), get_string('memorylimit', 'install'), get_string('memorylimiterror', 'install'), 'memorylimithelp', true);
8d783716 697
698
8b5b1028 699 break;
3470b39f 700 case DIRECTORY: /// Directory settings
8b5b1028 701?>
702
703 <tr>
dc71bb7d 704 <td class="td_left"><p class="p_install"><?php print_string('wwwroot', 'install') ?></p></td>
8b5b1028 705 <td class="td_right">
9914f093 706 <input type="text" size="40"name="wwwrootform" value="<?php p($INSTALL['wwwrootform'],true) ?>" />
8b5b1028 707 </td>
708 </tr>
709 <tr>
dc71bb7d 710 <td class="td_left"><p class="p_install"><?php print_string('dirroot', 'install') ?></p></td>
8b5b1028 711 <td class="td_right">
d36afd6d 712 <input type="text" size="40" name="dirrootform" disabled="disabled" value="<?php p($INSTALL['dirrootform'],true) ?>" />
8b5b1028 713 </td>
714 </tr>
715 <tr>
dc71bb7d 716 <td class="td_left"><p class="p_install"><?php print_string('dataroot', 'install') ?></p></td>
8b5b1028 717 <td class="td_right">
9914f093 718 <input type="text" size="40" name="dataroot" value="<?php p($INSTALL['dataroot'],true) ?>" />
8b5b1028 719 </td>
720 </tr>
721
722<?php
723 break;
3470b39f 724 case DATABASE: /// Database settings
8b5b1028 725?>
726
727 <tr>
dc71bb7d 728 <td class="td_left"><p class="p_install"><?php print_string('dbtype', 'install') ?></p></td>
8b5b1028 729 <td class="td_right">
6d5a22b2 730
731 <?php
732
733 $options = array ();
734 foreach ($databases as $type => $database) {
735 $name = $database->get_name();
736 if ($database->driver_installed() !== true) {
737 $name = "$name - driver not installed"; // TODO: improve missing driver notification
738 }
739 $options[$type] = $name;
740 }
741 choose_from_menu($options, 'dbtype', $INSTALL['dbtype'], '', 'toggledbinfo();')
742?>
8b5b1028 743 </td>
744 </tr>
745 <tr>
dc71bb7d 746 <td class="td_left"><p class="p_install"><?php print_string('dbhost', 'install') ?></p></td>
8b5b1028 747 <td class="td_right">
dc71bb7d 748 <input type="text" class="input_database" name="dbhost" value="<?php p($INSTALL['dbhost']) ?>" />
8b5b1028 749 </td>
750 </tr>
751 <tr>
dc71bb7d 752 <td class="td_left"><p class="p_install"><?php print_string('database', 'install') ?></p></td>
8b5b1028 753 <td class="td_right">
dc71bb7d 754 <input type="text" class="input_database" name="dbname" value="<?php p($INSTALL['dbname']) ?>" />
8b5b1028 755 </td>
756 </tr>
757 <tr>
dc71bb7d 758 <td class="td_left"><p class="p_install"><?php print_string('user') ?></p></td>
8b5b1028 759 <td class="td_right">
dc71bb7d 760 <input type="text" class="input_database" name="dbuser" value="<?php p($INSTALL['dbuser']) ?>" />
8b5b1028 761 </td>
762 </tr>
763 <tr>
dc71bb7d 764 <td class="td_left"><p class="p_install"><?php print_string('password') ?></p></td>
8b5b1028 765 <td class="td_right">
dc71bb7d 766 <input type="password" class="input_database" name="dbpass" value="<?php p($INSTALL['dbpass']) ?>" />
8b5b1028 767 </td>
768 </tr>
769 <tr>
dc71bb7d 770 <td class="td_left"><p class="p_install"><?php print_string('dbprefix', 'install') ?></p></td>
8b5b1028 771 <td class="td_right">
dc71bb7d 772 <input type="text" class="input_database" name="prefix" value="<?php p($INSTALL['prefix']) ?>" />
8b5b1028 773 </td>
774 </tr>
775
776<?php
777 break;
3470b39f 778 case ADMIN: /// Administration directory setting
8b5b1028 779?>
780
781 <tr>
dc71bb7d 782 <td class="td_left"><p class="p_install"><?php print_string('admindirname', 'install') ?></p></td>
8b5b1028 783 <td class="td_right">
f49312b6 784 <input type="text" size="40" name="admindirname" value="<?php p($INSTALL['admindirname']) ?>" />
8b5b1028 785 </td>
786 </tr>
787
788
3b3b8029 789<?php
790 break;
791 case ENVIRONMENT: /// Environment checks
792?>
793
794 <tr>
795 <td colspan="2">
796 <?php
797 error_reporting(0); // Hide errors
2f17b76d 798 $dbconnected = $DB->connect($INSTALL['dbhost'],$INSTALL['dbuser'],$INSTALL['dbpass'],$INSTALL['dbname'], $INSTALL['prefix']);
6d5a22b2 799 error_reporting(38911); // Show errors
3b3b8029 800 if ($dbconnected) {
801 /// Execute environment check, printing results
802 check_moodle_environment($INSTALL['release'], $environment_results, true);
803 } else {
804 /// We never should reach this because DB has been tested before arriving here
805 $errormsg = get_string('dbconnectionerror', 'install');
806 $nextstage = DATABASE;
dc71bb7d 807 echo '<p class="errormsg" style="text-align:center">'.get_string('dbconnectionerror', 'install').'</p>';
3b3b8029 808 }
809 ?>
810 </td>
811 </tr>
812
68a3f81d 813<?php
814 break;
815 case DOWNLOADLANG: /// Download language from download.moodle.org
816?>
817
818 <tr>
819 <td colspan="2">
820 <?php
cdef6d42 821 /// Get array of languages, we are going to use it
822 $languages=get_installer_list_of_languages();
823 /// Print the download form (button) if necessary
824 if ($INSTALL['showdownloadlangpack'] == true && substr($INSTALL['language'],0,2) != 'en') {
825 $options = array();
826 $options['downloadlangpack'] = true;
827 $options['stage'] = DOWNLOADLANG;
828 $options['same'] = true;
829 print_simple_box_start('center');
dc71bb7d 830 print_single_button('install.php', $options, get_string('downloadlanguagebutton','install', $languages[$INSTALL['language']]), 'post');
cdef6d42 831 print_simple_box_end();
68a3f81d 832 } else {
53a0367d 833 /// Show result info
cdef6d42 834 /// English lang packs aren't downloaded
835 if (substr($INSTALL['language'],0,2) == 'en') {
836 print_simple_box(get_string('downloadlanguagenotneeded', 'install', $languages[$INSTALL['language']]), 'center', '80%');
837 } else {
838 if ($INSTALL['downloadlangpackerror']) {
839 echo "<p class=\"errormsg\" align=\"center\">".$INSTALL['downloadlangpackerror']."</p>\n";
840 print_simple_box(get_string('langdownloaderror', 'install', $languages[$INSTALL['language']]), 'center', '80%');
841 } else {
842 print_simple_box(get_string('langdownloadok', 'install', $languages[$INSTALL['language']]), 'center', '80%');
843 }
844 }
68a3f81d 845 }
846 ?>
847 </td>
848 </tr>
3b3b8029 849
8b5b1028 850<?php
851 break;
852 default:
853 }
854?>
cd0e958e 855
51e3e0b9 856 <tr>
3470b39f 857 <td colspan="<?php echo ($nextstage == COMPATIBILITY) ? 3 : 2; ?>">
51e3e0b9 858
cdef6d42 859<?php
860 if ($needtoopenform) {
861?>
d2ce367f 862 <form id="installform" method="post" action="<?php echo $formaction ?>">
dc71bb7d 863 <div><input type="hidden" name="stage" value="<?php echo $nextstage ?>" /></div>
cdef6d42 864<?php
865 }
627d326a 866
867 $disabled = $enablenext ? '' : 'disabled="disabled"';
cdef6d42 868?>
869
627d326a 870 <?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" ?>
dc71bb7d 871 <?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" ?>
cd0e958e 872
cdef6d42 873<?php
874 if ($needtoopenform) {
875?>
876 </form>
877<?php
878 }
879?>
880
7c561c7a 881
51e3e0b9 882 </td>
cd0e958e 883
51e3e0b9 884 </tr>
53a0367d 885
51e3e0b9 886 </table>
cdef6d42 887<?php
888 if (!$needtoopenform) {
889?>
8b5b1028 890 </form>
cdef6d42 891<?php
892 }
893?>
8b5b1028 894
895<?php
896}
897
898
899
8d783716 900//==========================================================================//
901
51e3e0b9 902function print_compatibility_row($success, $testtext, $errormessage, $helpfield='', $caution=false) {
8d783716 903 echo "<tr>\n";
dc71bb7d 904 echo "<td class=\"td_left_nowrap\" valign=\"top\"><p class=\"p_install\">$testtext</p></td>\n";
8d783716 905 if ($success) {
51e3e0b9 906 echo "<td valign=\"top\"><p class=\"p_pass\">".get_string('pass', 'install')."</p></td>\n";
907 echo "<td valign=\"top\">&nbsp;</td>\n";
8d783716 908 } else {
dc71bb7d 909 echo "<td valign=\"top\">";
51e3e0b9 910 echo ($caution) ? "<p class=\"p_caution\">".get_string('caution', 'install') : "<p class=\"p_fail\">".get_string('fail', 'install');
911 echo "</p></td>\n";
912 echo "<td valign=\"top\">";
dc71bb7d 913 echo "<p class=\"p_install\">$errormessage ";
627d326a 914 if ($helpfield !== '') {
915 install_helpbutton("install.php?help=$helpfield");
916 }
51e3e0b9 917 echo "</p></td>\n";
8d783716 918 }
919 echo "</tr>\n";
920 return $success;
921}
922
923
924//==========================================================================//
925
926function install_helpbutton($url, $title='') {
927 if ($title == '') {
928 $title = get_string('help');
929 }
dc71bb7d 930 echo "<a href=\"javascript:void(0)\" ";
931 echo "onclick=\"return window.open('$url','Help','menubar=0,location=0,scrollbars,resizable,width=500,height=400')\"";
932 echo ">";
933 echo "<img src=\"pix/help.gif\" class=\"iconhelp\" alt=\"$title\" title=\"$title\"/>";
8d783716 934 echo "</a>\n";
935}
53a0367d 936
8d783716 937
938
939//==========================================================================//
940
941function print_install_help($help) {
8d783716 942 switch ($help) {
943 case 'phpversionhelp':
944 print_string($help, 'install', phpversion());
945 break;
946 case 'memorylimithelp':
94ba66ce 947 print_string($help, 'install', get_memory_limit());
8d783716 948 break;
949 default:
950 print_string($help, 'install');
951 }
8d783716 952}
953
b9b4e32a 954//==========================================================================//
8b5b1028 955
6d5a22b2 956function css_styles($databases) {
8b5b1028 957?>
958
959<style type="text/css">
960
961 body { background-color: #ffeece; }
53a0367d 962 p, li, td {
8d783716 963 font-family: helvetica, arial, sans-serif;
964 font-size: 10pt;
965 }
8b5b1028 966 a { text-decoration: none; color: blue; }
5782d818 967 a img {
968 border: none;
969 }
8b5b1028 970 .errormsg {
971 color: red;
972 font-weight: bold;
973 }
8d783716 974 blockquote {
51e3e0b9 975 font-family: courier, monospace;
8d783716 976 font-size: 10pt;
977 }
dc71bb7d 978 .input_database {
979 width: 270px;
980 }
8b5b1028 981 .install_table {
982 width: 500px;
dc71bb7d 983 margin-left:auto;
984 margin-right:auto;
8b5b1028 985 }
986 .td_left {
99238bf4 987 text-align: <?php echo fix_align_rtl("right") ?>;
8b5b1028 988 font-weight: bold;
989 }
dc71bb7d 990 .td_left_nowrap{
991 text-align: <?php echo fix_align_rtl("right") ?>;
992 font-weight: bold;
993 white-space: nowrap;
994 width: 160px;
995 padding-left: 10px;
996 }
8b5b1028 997 .td_right {
99238bf4 998 text-align: <?php echo fix_align_rtl("left") ?>;
8b5b1028 999 }
1000 .main {
46300167 1001 width: 80%;
8b5b1028 1002 border-width: 1px;
1003 border-style: solid;
1004 border-color: #ffc85f;
dc71bb7d 1005 margin-left:auto;
1006 margin-right:auto;
8b5b1028 1007 -moz-border-radius-bottomleft: 15px;
1008 -moz-border-radius-bottomright: 15px;
1009 }
1010 .td_mainheading {
1011 background-color: #fee6b9;
dc71bb7d 1012 padding-left: 10px;
8b5b1028 1013 }
1014 .td_main {
1015 text-align: center;
1016 }
8d783716 1017 .td_mainlogo {
dc71bb7d 1018 vertical-align: middle;
8d783716 1019 }
1020 .p_mainlogo {
dc71bb7d 1021 margin-top: 0px;
1022 margin-bottom: 0px;
8d783716 1023 }
8b5b1028 1024 .p_mainheading {
8d783716 1025 font-size: 11pt;
dc71bb7d 1026 margin-top: 16px;
1027 margin-bottom: 16px;
8d783716 1028 }
182dca14 1029 .p_subheading {
1030 font-size: 10pt;
dc71bb7d 1031 padding-left: 10px;
1032 margin-top: 16px;
1033 margin-bottom: 16px;
182dca14 1034 }
8d783716 1035 .p_mainheader{
6d5a22b2 1036 text-align: right;
8d783716 1037 font-size: 20pt;
1038 font-weight: bold;
dc71bb7d 1039 margin-top: 0px;
1040 margin-bottom: 0px;
8d783716 1041 }
1042 .p_pass {
1043 color: green;
1044 font-weight: bold;
dc71bb7d 1045 margin-top: 0px;
1046 margin-bottom: 0px;
8d783716 1047 }
1048 .p_fail {
1049 color: red;
1050 font-weight: bold;
dc71bb7d 1051 margin-top: 0px;
1052 margin-bottom: 0px;
8d783716 1053 }
51e3e0b9 1054 .p_caution {
1055 color: #ff6600;
1056 font-weight: bold;
dc71bb7d 1057 margin-top: 0px;
1058 margin-bottom: 0px;
51e3e0b9 1059 }
8d783716 1060 .p_help {
1061 text-align: center;
1062 font-family: helvetica, arial, sans-serif;
1063 font-size: 14pt;
1064 font-weight: bold;
1065 color: #333333;
dc71bb7d 1066 margin-top: 0px;
1067 margin-bottom: 0px;
1068 }
1069 /* This override the p tag for every p tag in this installation script,
6d5a22b2 1070 but not in lang\xxx\installer.php
dc71bb7d 1071 */
1072 .p_install {
1073 margin-top: 0px;
6d5a22b2 1074 margin-bottom: 0px;
8b5b1028 1075 }
3b3b8029 1076 .environmenttable {
1077 font-size: 10pt;
1078 border-color: #ffc85f;
1079 }
53a0367d 1080 table.environmenttable .error {
1081 background-color : red;
1082 color : inherit;
1083 }
1084
1085 table.environmenttable .warn {
1086 background-color : yellow;
1087 }
1088
1089 table.environmenttable .ok {
1090 background-color : lightgreen;
1091 }
3b3b8029 1092 .header {
1093 background-color: #fee6b9;
1094 font-size: 10pt;
1095 }
1096 .cell {
1097 background-color: #ffeece;
1098 font-size: 10pt;
1099 }
1100 .error {
1101 color: #ff0000;
1102 }
1103 .errorboxcontent {
1104 text-align: center;
1105 font-weight: bold;
dc71bb7d 1106 padding-left: 20px;
3b3b8029 1107 color: #ff0000;
1108 }
69cb58ef 1109 .invisiblefieldset {
1110 display:inline;
1111 border:0px;
1112 padding:0px;
1113 margin:0px;
1114 }
6d5a22b2 1115 <?php
1116 $list = array();
1117 foreach ($databases as $driver=>$unused) {
1118 $list[] = '#'.$driver;
1119 }
1120 $list = implode(',', $list);
1121 echo ($list);
1122 ?> {
86453d8b 1123 display: none;
1124 }
3b3b8029 1125
8b5b1028 1126</style>
1127
86453d8b 1128<?php
1129}
1130
1131//==========================================================================//
1132
6d5a22b2 1133function database_js($databases) {
86453d8b 1134?>
1135
a09f3b7d 1136<script type="text/javascript" defer="defer">
86453d8b 1137function toggledbinfo() {
1138 //Calculate selected value
1139 var showid = 'mysql';
3facbe66 1140 if (document.getElementById('installform').dbtype.value) {
1141 showid = document.getElementById('installform').dbtype.value;
86453d8b 1142 }
1143 if (document.getElementById) {
1144 //Hide all the divs
6d5a22b2 1145 <?php
1146 $list = array();
1147 foreach ($databases as $driver=>$unused) {
1148 echo "document.getElementById('$driver').style.display = '';";
1149 }
1150 ?>
86453d8b 1151 //Show the selected div
1152 document.getElementById(showid).style.display = 'block';
1153 } else if (document.all) {
1154 //This is the way old msie versions work
1155 //Hide all the divs
6d5a22b2 1156 <?php
1157 $list = array();
1158 foreach ($databases as $driver=>$unused) {
1159 echo "document.all['$driver'].style.display = '';";
1160 }
1161 ?>
86453d8b 1162 //Show the selected div
1163 document.all[showid].style.display = 'block';
1164 } else if (document.layers) {
1165 //This is the way nn4 works
1166 //Hide all the divs
6d5a22b2 1167 <?php
1168 $list = array();
1169 foreach ($databases as $driver=>$unused) {
1170 echo "document.layers['$driver'].style.display = '';";
1171 }
1172 ?>
86453d8b 1173 //Show the selected div
1174 document.layers[showid].style.display = 'block';
1175 }
1176}
1177</script>
1178
8b5b1028 1179<?php
1180}
2961367e 1181
8b5b1028 1182?>