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