few new strings
[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
20define ('SAVE', 5); /// 5. Save or display the settings
21define ('REDIRECT', 6); /// 6. Redirect to index.php
8b5b1028 22///==========================================================================//
23
24
8d783716 25
8b5b1028 26/// Begin the session as we are holding all information in a session
27/// variable until the end.
28
29session_name('MoodleSession');
30@session_start();
31
32if (! isset($_SESSION['INSTALL'])) {
33 $_SESSION['INSTALL'] = array();
34}
35
36$INSTALL = &$_SESSION['INSTALL']; // Makes it easier to reference
37
8d783716 38
39/// If it's our first time through this script then we need to set some default values
40
41if ( empty($INSTALL['language']) and empty($_POST['language']) ) {
8b5b1028 42
43 /// set defaults
44 $INSTALL['language'] = 'en';
45
46 $INSTALL['dbhost'] = 'localhost';
47 $INSTALL['dbuser'] = '';
48 $INSTALL['dbpass'] = '';
49 $INSTALL['dbtype'] = 'mysql';
50 $INSTALL['dbname'] = 'moodle';
51 $INSTALL['prefix'] = 'mdl_';
52
53 $INSTALL['wwwroot'] = '';
54 $INSTALL['dirroot'] = dirname(__FILE__);
55 $INSTALL['dataroot'] = dirname(dirname(__FILE__)) . '/moodledata';
56
57 $INSTALL['admindirname'] = 'admin';
58
3470b39f 59 $INSTALL['stage'] = WELCOME;
8b5b1028 60}
61
62
63
64//==========================================================================//
65
66/// Fake some settings so that we can use selected functions from moodlelib.php and weblib.php
8d783716 67
8b5b1028 68$SESSION->lang = (!empty($_POST['language'])) ? $_POST['language'] : $INSTALL['language'];
69$CFG->dirroot = $INSTALL['dirroot'];
72452dc1 70$CFG->libdir = $INSTALL['dirroot'].'/lib';
8b5b1028 71$CFG->dataroot = $INSTALL['dataroot'];
4b9efec4 72$CFG->directorypermissions = 00777;
8b5b1028 73
74
8d783716 75/// Include some moodle libraries
76
72452dc1 77require_once('./lib/setuplib.php');
8b5b1028 78require_once('./lib/moodlelib.php');
79require_once('./lib/weblib.php');
80require_once('./lib/adodb/adodb.inc.php');
81
82
83/// guess the www root
84if ($INSTALL['wwwroot'] == '') {
85 list($INSTALL['wwwroot'], $xtra) = explode('/install.php', qualified_me());
86}
87
e6f930f3 88$headstagetext = array(WELCOME => get_string('chooselanguagehead', 'install'),
89 COMPATIBILITY => get_string('compatibilitysettingshead', 'install'),
90 DIRECTORY => get_string('directorysettingshead', 'install'),
91 DATABASE => get_string('databasesettingshead', 'install'),
92 ADMIN => get_string('admindirsettinghead', 'install'),
93 SAVE => get_string('configurationcompletehead', 'install')
94 );
8b5b1028 95
e6f930f3 96$substagetext = array(WELCOME => get_string('chooselanguagesub', 'install'),
97 COMPATIBILITY => get_string('compatibilitysettingssub', 'install'),
98 DIRECTORY => get_string('directorysettingssub', 'install'),
99 DATABASE => get_string('databasesettingssub', 'install'),
100 ADMIN => get_string('admindirsettingsub', 'install'),
101 SAVE => get_string('configurationcompletesub', 'install')
102 );
8b5b1028 103
8d783716 104
105
106//==========================================================================//
107
108/// Are we in help mode?
109
110if (isset($_GET['help'])) {
111 $nextstage = -1;
112}
113
114
51e3e0b9 115
edd3a5db 116//==========================================================================//
117
51e3e0b9 118/// Are we in config download mode?
edd3a5db 119
51e3e0b9 120if (isset($_GET['download'])) {
121 header("Content-Type: application/download\n");
122 header("Content-Disposition: attachment; filename=\"config.php\"");
123 echo $INSTALL['config'];
124 exit;
edd3a5db 125}
8d783716 126
51e3e0b9 127
128
8b5b1028 129//==========================================================================//
130
131/// Was data submitted?
8d783716 132
133if (isset($_POST['stage'])) {
8b5b1028 134
135 /// Get the stage for which the form was set and the next stage we are going to
136
137
138 if ( $goforward = (! empty( $_POST['next'] )) ) {
139 $nextstage = $_POST['stage'] + 1;
140 } else {
141 $nextstage = $_POST['stage'] - 1;
142 }
3470b39f 143
144
145 if ($nextstage < 0) $nextstage = WELCOME;
51e3e0b9 146
8b5b1028 147
148 /// Store any posted data
149 foreach ($_POST as $setting=>$value) {
150 $INSTALL[$setting] = $value;
151 }
51e3e0b9 152
8b5b1028 153} else {
154
155 $goforward = true;
3470b39f 156 $nextstage = WELCOME;
51e3e0b9 157
8b5b1028 158}
159
160
161
162//==========================================================================//
163
164/// Check the directory settings
8d783716 165
3470b39f 166if ($INSTALL['stage'] == DIRECTORY) {
8b5b1028 167
168 error_reporting(0);
51e3e0b9 169
170
171 /// check dirroot
172 if (($fh = @fopen($INSTALL['dirroot'].'/install.php', 'r')) === false ) {
173 $CFG->dirroot = dirname(__FILE__);
174 $INSTALL['dirroot'] = dirname(__FILE__);
2df3a721 175 $errormsg .= get_string('dirrooterror', 'install').'<br />';
176 }
177 if ($fh) fclose($fh);
51e3e0b9 178
2df3a721 179 $CFG->dirroot = $INSTALL['dirroot'];
cd0e958e 180
2df3a721 181 /// check wwwroot
182 if (ini_get('allow_url_fopen')) {
51e3e0b9 183 if (($fh = @fopen($INSTALL['wwwroot'].'/install.php', 'r')) === false) {
2df3a721 184 $errormsg .= get_string('wwwrooterror', 'install').'<br />';
8b5b1028 185 }
186 }
2df3a721 187 if ($fh) fclose($fh);
188
189 /// check dataroot
190 $CFG->dataroot = $INSTALL['dataroot'];
191 if (make_upload_directory('sessions', false) === false ) {
192 $errormsg = get_string('datarooterror', 'install').'<br />';
193 }
194 if ($fh) fclose($fh);
8b5b1028 195
3470b39f 196 if (!empty($errormsg)) $nextstage = DIRECTORY;
8b5b1028 197
198 error_reporting(7);
199}
200
201
202
203//==========================================================================//
204
205/// Check database settings if stage 3 data submitted
206/// Try to connect to the database. If that fails then try to create the database
8d783716 207
3470b39f 208if ($INSTALL['stage'] == DATABASE) {
8b5b1028 209
210 if (empty($INSTALL['dbname'])) {
211 $INSTALL['dbname'] = 'moodle';
212 }
51e3e0b9 213
8d783716 214 /// different format for postgres7 by socket
215 if ($INSTALL['dbtype'] == 'postgres7' and ($INSTALL['dbhost'] == 'localhost' || $INSTALL['dbhost'] == '127.0.0.1')) {
8b5b1028 216 $INSTALL['dbhost'] = "user='{$INSTALL['dbuser']}' password='{$INSTALL['dbpass']}' dbname='{$INSTALL['dbname']}'";
8d783716 217 $INSTALL['dbuser'] = '';
218 $INSTALL['dbpass'] = '';
219 $INSTALL['dbname'] = '';
220
8b5b1028 221 if ($INSTALL['prefix'] == '') { /// must have a prefix
222 $INSTALL['prefix'] = 'mdl_';
223 }
224 }
225
fe515206 226 if ($INSTALL['dbtype'] == 'mysql') { /// Check MySQL extension is present
227 if (!extension_loaded('mysql')) {
228 $errormsg = get_string('mysqlextensionisnotpresentinphp', 'install');
3470b39f 229 $nextstage = DATABASE;
fe515206 230 }
231 }
8b5b1028 232
fe515206 233 if (empty($errormsg)) {
234
235 $db = &ADONewConnection($INSTALL['dbtype']);
236
237 error_reporting(0); // Hide errors
238
239 if (! $dbconnected = $db->Connect($INSTALL['dbhost'],$INSTALL['dbuser'],$INSTALL['dbpass'],$INSTALL['dbname'])) {
240 /// The following doesn't seem to work but we're working on it
241 /// If you come up with a solution for creating a database in MySQL
242 /// feel free to put it in and let us know
243 if ($dbconnected = $db->Connect($INSTALL['dbhost'],$INSTALL['dbuser'],$INSTALL['dbpass'])) {
244 switch ($INSTALL['dbtype']) { /// Try to create a database
245 case 'mysql':
246 if ($db->Execute("CREATE DATABASE {$INSTALL['dbname']};")) {
247 $dbconnected = $db->Connect($INSTALL['dbhost'],$INSTALL['dbuser'],$INSTALL['dbpass'],$INSTALL['dbname']);
248 } else {
249 $errormsg = get_string('dbcreationerror', 'install');
3470b39f 250 $nextstage = DATABASE;
fe515206 251 }
252 break;
253 }
8b5b1028 254 }
255 }
256 }
257
258 error_reporting(7);
259
260 if (($dbconnected === false) and (empty($errormsg)) ) {
261 $errormsg = get_string('dbconnectionerror', 'install');
3470b39f 262 $nextstage = DATABASE;
8b5b1028 263 }
264}
265
266
267
268//==========================================================================//
269
270/// If the next stage is admin directory settings OR we have just come from there then
271/// check the admin directory.
272/// If we can open a file then we know that the admin name is correct.
273
3470b39f 274if ($nextstage == ADMIN or $INSTALL['stage'] == ADMIN) {
91099e36 275 if (!ini_get('allow_url_fopen')) {
3470b39f 276 $nextstage = ($goforward) ? SAVE : DATABASE;
91099e36 277 } else if (($fh = @fopen($INSTALL['wwwroot'].'/'.$INSTALL['admindirname'].'/site.html', 'r')) !== false) {
3470b39f 278 $nextstage = ($goforward) ? SAVE : DATABASE;
8b5b1028 279 fclose($fh);
280 } else {
3470b39f 281 if ($nextstage != ADMIN) {
8b5b1028 282 $errormsg = get_string('admindirerror', 'install');
3470b39f 283 $nextstage = ADMIN;
8b5b1028 284 }
285 }
286}
287
288
289
290//==========================================================================//
291
292/// Display or print the data
293/// Put the data into a string
294/// Try to open config file for writing.
8d783716 295
3470b39f 296if ($nextstage == SAVE) {
51e3e0b9 297
298 $str = '<?php /// Moodle Configuration File '."\r\n";
299 $str .= "\r\n";
300
301 $str .= 'unset($CFG);'."\r\n";
302 $str .= "\r\n";
303
304 $str .= '$CFG->dbtype = \''.$INSTALL['dbtype']."';\r\n";
c423badc 305 $str .= '$CFG->dbhost = \''.addslashes($INSTALL['dbhost'])."';\r\n";
59812bc7 306 if (!empty($INSTALL['dbname'])) {
51e3e0b9 307 $str .= '$CFG->dbname = \''.$INSTALL['dbname']."';\r\n";
308 $str .= '$CFG->dbuser = \''.$INSTALL['dbuser']."';\r\n";
309 $str .= '$CFG->dbpass = \''.$INSTALL['dbpass']."';\r\n";
310 }
311 $str .= '$CFG->dbpersist = false;'."\r\n";
312 $str .= '$CFG->prefix = \''.$INSTALL['prefix']."';\r\n";
313 $str .= "\r\n";
314
315 $str .= '$CFG->wwwroot = \''.$INSTALL['wwwroot']."';\r\n";
316 $str .= '$CFG->dirroot = \''.$INSTALL['dirroot']."';\r\n";
317 $str .= '$CFG->dataroot = \''.$INSTALL['dataroot']."';\r\n";
e35d275e 318 $str .= '$CFG->admin = \''.$INSTALL['admindirname']."';\r\n";
51e3e0b9 319 $str .= "\r\n";
320
6e86ae68 321 $str .= '$CFG->directorypermissions = 00777; // try 02777 on a server in Safe Mode'."\r\n";
51e3e0b9 322 $str .= "\r\n";
323
324 $str .= 'require_once("$CFG->dirroot/lib/setup.php");'."\r\n";
325 $str .= '// MAKE SURE WHEN YOU EDIT THIS FILE THAT THERE ARE NO SPACES, BLANK LINES,'."\r\n";
326 $str .= '// RETURNS, OR ANYTHING ELSE AFTER THE TWO CHARACTERS ON THE NEXT LINE.'."\r\n";
327 $str .= '?>';
328
7c561c7a 329 umask(0137);
330
8b5b1028 331 if (( $configsuccess = ($fh = @fopen($configfile, 'w')) ) !== false) {
332 fwrite($fh, $str);
333 fclose($fh);
334 }
7c561c7a 335
51e3e0b9 336
337 $INSTALL['config'] = $str;
8b5b1028 338}
339
340
341
342//==========================================================================//
343
344?>
345
346
347
348<html dir="<?php echo (get_string('this_direction') == 'rtl') ? 'rtl' : 'ltr' ?>">
349<head>
f96660f8 350<link rel="shortcut icon" href="theme/standard/favicon.ico" />
8b5b1028 351<title>Moodle Install</title>
09f97271 352<meta http-equiv="content-type" content="text/html; charset=<?php p(current_charset()) ?>" />
8b5b1028 353<?php css_styles() ?>
354
355</head>
356
357<body>
358
8d783716 359
360<?php
361if (isset($_GET['help'])) {
362 print_install_help($_GET['help']);
51e3e0b9 363 close_window_button();
8d783716 364} else {
365?>
366
8b5b1028 367
368<table class="main" align="center" cellpadding="3" cellspacing="0">
369 <tr>
8d783716 370 <td class="td_mainlogo">
839f2456 371 <p class="p_mainlogo"><img src="pix/moodlelogo-med.gif" width="240" height="60" alt=\"\"></p>
8d783716 372 </td>
373 <td class="td_mainlogo" valign="bottom">
374 <p class="p_mainheader"><?php print_string('installation', 'install') ?></p>
375 </td>
376 </tr>
377
378 <tr>
379 <td class="td_mainheading" colspan="2">
e6f930f3 380 <p class="p_mainheading"><?php echo $headstagetext[$nextstage] ?></p>
381 <?php if (!empty($substagetext[$nextstage])) { ?>
382 <p class="p_subheading"><?php echo $substagetext[$nextstage] ?></p>
383 <?php } ?>
8d783716 384 </td>
8b5b1028 385 </tr>
386
387 <tr>
8d783716 388 <td class="td_main" colspan="2">
51e3e0b9 389
8b5b1028 390<?php
391
392if (!empty($errormsg)) echo "<p class=\"errormsg\" align=\"center\">$errormsg</p>\n";
393
394
3470b39f 395if ($nextstage == SAVE) {
396 $INSTALL['stage'] = WELCOME;
51e3e0b9 397 $options = array();
398 $options['lang'] = $INSTALL['language'];
8b5b1028 399 if ($configsuccess) {
400 echo "<p>".get_string('configfilewritten', 'install')."</p>\n";
51e3e0b9 401
402 echo "<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"100%\">\n";
403 echo "<tr>\n";
404 echo "<td width=\"33.3%\">&nbsp;</td>\n";
405 echo "<td width=\"33.3%\">&nbsp;</td>\n";
406 echo "<td width=\"33.3%\" align=\"right\">\n";
407 print_single_button("index.php", $options, get_string('continue')." &raquo;");
408 echo "</td>\n";
409 echo "</tr>\n";
410 echo "</table>\n";
411
8b5b1028 412 } else {
51e3e0b9 413 echo "<p class=\"errormsg\">".get_string('configfilenotwritten', 'install')."</p>";
414
415 echo "<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"100%\">\n";
416 echo "<tr>\n";
417 echo "<td width=\"33.3%\">&nbsp;</td>\n";
418 echo "<td width=\"33.3%\" align=\"center\">\n";
419 $installoptions = array();
420 $installoptions['download'] = 1;
421 print_single_button("install.php", $installoptions, get_string('download', 'install'));
422 echo "</td>\n";
423 echo "<td width=\"33.3%\" align=\"right\">\n";
424 print_single_button("index.php", $options, get_string('continue')." &raquo;");
425 echo "</td>\n";
426 echo "</tr>\n";
427 echo "</table>\n";
428
8b5b1028 429 echo "<hr />\n";
51e3e0b9 430 echo "<div style=\"text-align: left\">\n";
431 print_object(htmlentities($str));
432 echo "</div>\n";
8b5b1028 433 }
8b5b1028 434} else {
435 $formaction = (isset($_GET['configfile'])) ? "install.php?configfile=".$_GET['configfile'] : "install.php";
436 form_table($nextstage, $formaction);
437}
438
439?>
440
441 </td>
442 </tr>
443</table>
444
8d783716 445<?php
446}
447?>
448
8b5b1028 449</body>
450</html>
451
452
453
454
455
456
457
458
459
460
51e3e0b9 461<?php
8b5b1028 462
463//==========================================================================//
464
465
466function print_object($object) {
467 echo "<pre>\n";
468 print_r($object);
469 echo "</pre>\n";
470}
471
472
473
474//==========================================================================//
475
3470b39f 476function form_table($nextstage = WELCOME, $formaction = "install.php") {
8b5b1028 477 global $INSTALL;
478
479 /// standard lines for all forms
480?>
481
482 <form name="installform" method="post" action="<?php echo $formaction ?>">
483 <input type="hidden" name="stage" value="<?php echo $nextstage ?>" />
484 <table class="install_table" cellspacing="3" cellpadding="3" align="center">
485
486<?php
487 /// what we do depends on the stage we're at
488 switch ($nextstage) {
3470b39f 489 case WELCOME: /// Welcome and language settings
8b5b1028 490?>
491 <tr>
492 <td class="td_left"><p><?php print_string('language') ?></p></td>
493 <td class="td_right">
494 <?php choose_from_menu (get_list_of_languages(), 'language', $INSTALL['language'], '') ?>
495 </td>
496 </tr>
497
498<?php
8d783716 499 break;
3470b39f 500 case COMPATIBILITY: /// Compatibilty check
8d783716 501 $compatsuccess = true;
51e3e0b9 502
8d783716 503 /// Check that PHP is of a sufficient version
51e3e0b9 504 print_compatibility_row(check_php_version("4.1.0"), get_string('phpversion', 'install'), get_string('phpversionerror', 'install'), 'phpversionhelp');
8d783716 505 /// Check session auto start
506 print_compatibility_row(!ini_get_bool('session.auto_start'), get_string('sessionautostart', 'install'), get_string('sessionautostarterror', 'install'), 'sessionautostarthelp');
8d783716 507 /// Check magic quotes
508 print_compatibility_row(!ini_get_bool('magic_quotes_runtime'), get_string('magicquotesruntime', 'install'), get_string('magicquotesruntimeerror', 'install'), 'magicquotesruntimehelp');
4d46a3f0 509 /// Check unsupported PHP configuration
510 print_compatibility_row(ini_get_bool('magic_quotes_gpc') || (!ini_get_bool('register_globals')), get_string('globalsquotes', 'install'), get_string('globalsquoteserror', 'install'), 'globalsquoteshelp');
51e3e0b9 511 /// Check safe mode
512 print_compatibility_row(!ini_get_bool('safe_mode'), get_string('safemode', 'install'), get_string('safemodeerror', 'install'), 'safemodehelp', true);
8d783716 513 /// Check file uploads
51e3e0b9 514 print_compatibility_row(ini_get_bool('file_uploads'), get_string('fileuploads', 'install'), get_string('fileuploadserror', 'install'), 'fileuploadshelp', true);
8d783716 515 /// Check GD version
51e3e0b9 516 print_compatibility_row(check_gd_version(), get_string('gdversion', 'install'), get_string('gdversionerror', 'install'), 'gdversionhelp', true);
8d783716 517 /// Check memory limit
51e3e0b9 518 print_compatibility_row(check_memory_limit(), get_string('memorylimit', 'install'), get_string('memorylimiterror', 'install'), 'memorylimithelp', true);
8d783716 519
520
8b5b1028 521 break;
3470b39f 522 case DIRECTORY: /// Directory settings
8b5b1028 523?>
524
525 <tr>
526 <td class="td_left"><p><?php print_string('wwwroot', 'install') ?></p></td>
527 <td class="td_right">
528 <input type="text" size="40"name="wwwroot" value="<?php echo $INSTALL['wwwroot'] ?>" />
529 </td>
530 </tr>
531 <tr>
532 <td class="td_left"><p><?php print_string('dirroot', 'install') ?></p></td>
533 <td class="td_right">
534 <input type="text" size="40" name="dirroot" value="<?php echo $INSTALL['dirroot'] ?>" />
535 </td>
536 </tr>
537 <tr>
538 <td class="td_left"><p><?php print_string('dataroot', 'install') ?></p></td>
539 <td class="td_right">
540 <input type="text" size="40" name="dataroot" value="<?php echo $INSTALL['dataroot'] ?>" />
541 </td>
542 </tr>
543
544<?php
545 break;
3470b39f 546 case DATABASE: /// Database settings
8b5b1028 547?>
548
549 <tr>
550 <td class="td_left"><p><?php print_string('dbtype', 'install') ?></p></td>
551 <td class="td_right">
552 <?php choose_from_menu (array("mysql" => "mysql", "postgres7" => "postgres7"), 'dbtype', $INSTALL['dbtype'], '') ?>
553 </td>
554 </tr>
555 <tr>
556 <td class="td_left"><p><?php print_string('dbhost', 'install') ?></p></td>
557 <td class="td_right">
558 <input type="text" size="40" name="dbhost" value="<?php echo $INSTALL['dbhost'] ?>" />
559 </td>
560 </tr>
561 <tr>
562 <td class="td_left"><p><?php print_string('database', 'install') ?></p></td>
563 <td class="td_right">
564 <input type="text" size="40" name="dbname" value="<?php echo $INSTALL['dbname'] ?>" />
565 </td>
566 </tr>
567 <tr>
568 <td class="td_left"><p><?php print_string('user') ?></p></td>
569 <td class="td_right">
570 <input type="text" size="40" name="dbuser" value="<?php echo $INSTALL['dbuser'] ?>" />
571 </td>
572 </tr>
573 <tr>
574 <td class="td_left"><p><?php print_string('password') ?></p></td>
575 <td class="td_right">
2df3a721 576 <input type="password" size="40" name="dbpass" value="<?php echo $INSTALL['dbpass'] ?>" />
8b5b1028 577 </td>
578 </tr>
579 <tr>
580 <td class="td_left"><p><?php print_string('dbprefix', 'install') ?></p></td>
581 <td class="td_right">
582 <input type="text" size="40" name="prefix" value="<?php echo $INSTALL['prefix'] ?>" />
583 </td>
584 </tr>
585
586<?php
587 break;
3470b39f 588 case ADMIN: /// Administration directory setting
8b5b1028 589?>
590
591 <tr>
592 <td class="td_left"><p><?php print_string('admindirname', 'install') ?></p></td>
593 <td class="td_right">
594 <input type="text" size="40" name="admindirname" value="<?php echo $INSTALL['admindirname'] ?>" />
595 </td>
596 </tr>
597
598
599<?php
600 break;
601 default:
602 }
603?>
cd0e958e 604
51e3e0b9 605 <tr>
3470b39f 606 <td colspan="<?php echo ($nextstage == COMPATIBILITY) ? 3 : 2; ?>">
51e3e0b9 607
3470b39f 608 <?php echo ($nextstage < SAVE) ? "<input type=\"submit\" name=\"next\" value=\"".get_string('next')." &raquo;\" style=\"float: right\"/>\n" : "&nbsp;\n" ?>
609 <?php echo ($nextstage > WELCOME) ? "<input type=\"submit\" name=\"prev\" value=\"&laquo; ".get_string('previous')."\" style=\"float: left\"/>\n" : "&nbsp;\n" ?>
cd0e958e 610
7c561c7a 611
51e3e0b9 612 </td>
cd0e958e 613
51e3e0b9 614 </tr>
615
616 </table>
8b5b1028 617 </form>
618
619<?php
620}
621
622
623
8d783716 624//==========================================================================//
625
51e3e0b9 626function print_compatibility_row($success, $testtext, $errormessage, $helpfield='', $caution=false) {
8d783716 627 echo "<tr>\n";
51e3e0b9 628 echo "<td class=\"td_left\" valign=\"top\" nowrap width=\"160\"><p>$testtext</p></td>\n";
8d783716 629 if ($success) {
51e3e0b9 630 echo "<td valign=\"top\"><p class=\"p_pass\">".get_string('pass', 'install')."</p></td>\n";
631 echo "<td valign=\"top\">&nbsp;</td>\n";
8d783716 632 } else {
51e3e0b9 633 echo "<td valign=\"top\"";
634 echo ($caution) ? "<p class=\"p_caution\">".get_string('caution', 'install') : "<p class=\"p_fail\">".get_string('fail', 'install');
635 echo "</p></td>\n";
636 echo "<td valign=\"top\">";
637 echo "<p>$errormessage ";
638 install_helpbutton("install.php?help=$helpfield");
639 echo "</p></td>\n";
8d783716 640 }
641 echo "</tr>\n";
642 return $success;
643}
644
645
646//==========================================================================//
647
648function install_helpbutton($url, $title='') {
649 if ($title == '') {
650 $title = get_string('help');
651 }
652 echo "<a href=\"javascript: void(0)\">";
1fd3772b 653 echo "<img src=\"./pix/help.gif\" height=\"17\" width=\"17\" alt=\"$title\"";
839f2456 654 echo "border=\"0\" align=\"middle\" title=\"$title\" ";
8d783716 655 echo "onClick=\"return window.open('$url', 'Help', 'menubar=0,location=0,scrollbars,resizable,width=500,height=400')\">";
656 echo "</a>\n";
657}
51e3e0b9 658
8d783716 659
660
661//==========================================================================//
662
663function print_install_help($help) {
8d783716 664 switch ($help) {
665 case 'phpversionhelp':
666 print_string($help, 'install', phpversion());
667 break;
668 case 'memorylimithelp':
94ba66ce 669 print_string($help, 'install', get_memory_limit());
8d783716 670 break;
671 default:
672 print_string($help, 'install');
673 }
8d783716 674}
675
676
677//==========================================================================//
678
679function get_memory_limit() {
680 if ($limit = ini_get('memory_limit')) {
681 return $limit;
682 } else {
683 return get_cfg_var('memory_limit');
684 }
685}
686
687//==========================================================================//
688
689function check_memory_limit() {
690
691 /// if limit is already 16M or more then we don't care if we can change it or not
692 if ((int)str_replace('M', '', get_memory_limit()) >= 16) {
693 return true;
694 }
695
696 /// Otherwise, see if we can change it ourselves
697 @ini_set('memory_limit', '16M');
698 return ((int)str_replace('M', '', get_memory_limit()) >= 16);
699}
700
8b5b1028 701//==========================================================================//
702
703function css_styles() {
704?>
705
706<style type="text/css">
707
708 body { background-color: #ffeece; }
51e3e0b9 709 p, li {
8d783716 710 font-family: helvetica, arial, sans-serif;
711 font-size: 10pt;
712 }
8b5b1028 713 a { text-decoration: none; color: blue; }
714 .errormsg {
715 color: red;
716 font-weight: bold;
717 }
8d783716 718 blockquote {
51e3e0b9 719 font-family: courier, monospace;
8d783716 720 font-size: 10pt;
721 }
8b5b1028 722 .install_table {
723 width: 500px;
724 }
725 .td_left {
726 text-align: right;
727 font-weight: bold;
728 }
729 .td_right {
730 text-align: left;
731 }
732 .main {
733 width: 500px;
734 border-width: 1px;
735 border-style: solid;
736 border-color: #ffc85f;
737 -moz-border-radius-bottomleft: 15px;
738 -moz-border-radius-bottomright: 15px;
739 }
740 .td_mainheading {
741 background-color: #fee6b9;
8d783716 742 padding: 10px;
8b5b1028 743 }
744 .td_main {
745 text-align: center;
746 }
8d783716 747 .td_mainlogo {
748 }
749 .p_mainlogo {
750 }
8b5b1028 751 .p_mainheading {
8d783716 752 font-size: 11pt;
753 }
182dca14 754 .p_subheading {
755 font-size: 10pt;
756 padding: 10px;
757 }
8d783716 758 .p_mainheader{
759 text-align: right;
760 font-size: 20pt;
761 font-weight: bold;
762 }
763 .p_pass {
764 color: green;
765 font-weight: bold;
766 }
767 .p_fail {
768 color: red;
769 font-weight: bold;
770 }
51e3e0b9 771 .p_caution {
772 color: #ff6600;
773 font-weight: bold;
774 }
8d783716 775 .p_help {
776 text-align: center;
777 font-family: helvetica, arial, sans-serif;
778 font-size: 14pt;
779 font-weight: bold;
780 color: #333333;
8b5b1028 781 }
51e3e0b9 782
8b5b1028 783</style>
784
785<?php
786}
787?>