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