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