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