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