2004-08-12 15:53:32 +00:00
|
|
|
<?php /// $Id$
|
|
|
|
/// install.php - helps admin user to create a config.php file
|
|
|
|
|
|
|
|
/// If config.php exists already then we are not needed.
|
|
|
|
|
2004-08-19 08:53:23 +00:00
|
|
|
if (file_exists('./config.php')) {
|
2004-08-12 15:53:32 +00:00
|
|
|
header('Location: index.php');
|
2004-08-19 08:53:23 +00:00
|
|
|
die;
|
2004-08-12 15:53:32 +00:00
|
|
|
} else {
|
|
|
|
$configfile = './config.php';
|
|
|
|
}
|
|
|
|
|
|
|
|
///==========================================================================//
|
|
|
|
/// We are doing this in stages
|
2004-08-17 13:51:41 +00:00
|
|
|
/// 0. Welcome and language settings
|
|
|
|
/// 1. Compatibility
|
2004-08-12 15:53:32 +00:00
|
|
|
/// 2. Database settings
|
|
|
|
/// 3. Host settings
|
|
|
|
/// 4. Administration directory name
|
|
|
|
/// 5. Save or display the settings
|
|
|
|
/// 6. Redirect to index.php
|
|
|
|
///==========================================================================//
|
|
|
|
|
|
|
|
|
2004-08-17 13:51:41 +00:00
|
|
|
|
2004-08-12 15:53:32 +00:00
|
|
|
/// Begin the session as we are holding all information in a session
|
|
|
|
/// variable until the end.
|
|
|
|
|
|
|
|
session_name('MoodleSession');
|
|
|
|
@session_start();
|
|
|
|
|
|
|
|
if (! isset($_SESSION['INSTALL'])) {
|
|
|
|
$_SESSION['INSTALL'] = array();
|
|
|
|
}
|
|
|
|
|
|
|
|
$INSTALL = &$_SESSION['INSTALL']; // Makes it easier to reference
|
|
|
|
|
2004-08-17 13:51:41 +00:00
|
|
|
|
|
|
|
/// If it's our first time through this script then we need to set some default values
|
|
|
|
|
|
|
|
if ( empty($INSTALL['language']) and empty($_POST['language']) ) {
|
2004-08-12 15:53:32 +00:00
|
|
|
|
|
|
|
/// set defaults
|
|
|
|
$INSTALL['language'] = 'en';
|
|
|
|
|
|
|
|
$INSTALL['dbhost'] = 'localhost';
|
|
|
|
$INSTALL['dbuser'] = '';
|
|
|
|
$INSTALL['dbpass'] = '';
|
|
|
|
$INSTALL['dbtype'] = 'mysql';
|
|
|
|
$INSTALL['dbname'] = 'moodle';
|
|
|
|
$INSTALL['prefix'] = 'mdl_';
|
|
|
|
|
|
|
|
$INSTALL['wwwroot'] = '';
|
|
|
|
$INSTALL['dirroot'] = dirname(__FILE__);
|
|
|
|
$INSTALL['dataroot'] = dirname(dirname(__FILE__)) . '/moodledata';
|
|
|
|
|
|
|
|
$INSTALL['admindirname'] = 'admin';
|
|
|
|
|
2004-08-17 13:51:41 +00:00
|
|
|
$INSTALL['stage'] = 0;
|
2004-08-12 15:53:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//==========================================================================//
|
|
|
|
|
|
|
|
/// Fake some settings so that we can use selected functions from moodlelib.php and weblib.php
|
2004-08-17 13:51:41 +00:00
|
|
|
|
2004-08-12 15:53:32 +00:00
|
|
|
$SESSION->lang = (!empty($_POST['language'])) ? $_POST['language'] : $INSTALL['language'];
|
|
|
|
$CFG->dirroot = $INSTALL['dirroot'];
|
|
|
|
$CFG->dataroot = $INSTALL['dataroot'];
|
2004-12-26 14:45:39 +00:00
|
|
|
$CFG->directorypermissions = 02777;
|
2004-08-12 15:53:32 +00:00
|
|
|
|
|
|
|
|
2004-08-17 13:51:41 +00:00
|
|
|
/// Include some moodle libraries
|
|
|
|
|
2004-08-12 15:53:32 +00:00
|
|
|
require_once('./lib/moodlelib.php');
|
|
|
|
require_once('./lib/weblib.php');
|
|
|
|
require_once('./lib/adodb/adodb.inc.php');
|
|
|
|
|
|
|
|
|
|
|
|
/// guess the www root
|
|
|
|
if ($INSTALL['wwwroot'] == '') {
|
|
|
|
list($INSTALL['wwwroot'], $xtra) = explode('/install.php', qualified_me());
|
|
|
|
}
|
|
|
|
|
2004-08-17 13:51:41 +00:00
|
|
|
$stagetext = array(0 => get_string('chooselanguage', 'install'),
|
|
|
|
get_string('compatibilitysettings', 'install'),
|
|
|
|
get_string('directorysettings', 'install'),
|
|
|
|
get_string('databasesettings', 'install'),
|
|
|
|
get_string('admindirsetting', 'install'),
|
|
|
|
get_string('configurationcomplete', 'install')
|
2004-08-12 15:53:32 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
|
2004-08-17 13:51:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
//==========================================================================//
|
|
|
|
|
|
|
|
/// Are we in help mode?
|
|
|
|
|
|
|
|
if (isset($_GET['help'])) {
|
|
|
|
$nextstage = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-08-19 08:53:23 +00:00
|
|
|
|
2004-08-19 08:34:21 +00:00
|
|
|
//==========================================================================//
|
|
|
|
|
2004-08-19 08:53:23 +00:00
|
|
|
/// Are we in config download mode?
|
2004-08-19 08:34:21 +00:00
|
|
|
|
2004-08-19 08:53:23 +00:00
|
|
|
if (isset($_GET['download'])) {
|
|
|
|
header("Content-Type: application/download\n");
|
|
|
|
header("Content-Disposition: attachment; filename=\"config.php\"");
|
|
|
|
echo $INSTALL['config'];
|
|
|
|
exit;
|
2004-08-19 08:34:21 +00:00
|
|
|
}
|
2004-08-17 13:51:41 +00:00
|
|
|
|
2004-08-19 08:53:23 +00:00
|
|
|
|
|
|
|
|
2004-08-12 15:53:32 +00:00
|
|
|
//==========================================================================//
|
|
|
|
|
|
|
|
/// Was data submitted?
|
2004-08-17 13:51:41 +00:00
|
|
|
|
|
|
|
if (isset($_POST['stage'])) {
|
2004-08-12 15:53:32 +00:00
|
|
|
|
|
|
|
/// Get the stage for which the form was set and the next stage we are going to
|
|
|
|
|
|
|
|
|
|
|
|
if ( $goforward = (! empty( $_POST['next'] )) ) {
|
|
|
|
$nextstage = $_POST['stage'] + 1;
|
|
|
|
} else {
|
|
|
|
$nextstage = $_POST['stage'] - 1;
|
|
|
|
}
|
2004-08-19 08:53:23 +00:00
|
|
|
|
2004-08-17 13:51:41 +00:00
|
|
|
if ($nextstage < 0) $nextstage = 0;
|
2004-08-19 08:53:23 +00:00
|
|
|
|
2004-08-12 15:53:32 +00:00
|
|
|
|
|
|
|
/// Store any posted data
|
|
|
|
foreach ($_POST as $setting=>$value) {
|
|
|
|
$INSTALL[$setting] = $value;
|
|
|
|
}
|
2004-08-19 08:53:23 +00:00
|
|
|
|
2004-08-12 15:53:32 +00:00
|
|
|
} else {
|
|
|
|
|
|
|
|
$goforward = true;
|
2004-08-17 13:51:41 +00:00
|
|
|
$nextstage = 0;
|
2004-08-19 08:53:23 +00:00
|
|
|
|
2004-08-12 15:53:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//==========================================================================//
|
|
|
|
|
|
|
|
/// Check the directory settings
|
2004-08-17 13:51:41 +00:00
|
|
|
|
2004-08-12 15:53:32 +00:00
|
|
|
if ($INSTALL['stage'] == 2) {
|
|
|
|
|
|
|
|
error_reporting(0);
|
2004-08-19 08:53:23 +00:00
|
|
|
|
|
|
|
|
|
|
|
/// check dirroot
|
|
|
|
if (($fh = @fopen($INSTALL['dirroot'].'/install.php', 'r')) === false ) {
|
|
|
|
$CFG->dirroot = dirname(__FILE__);
|
|
|
|
$INSTALL['dirroot'] = dirname(__FILE__);
|
2004-10-22 10:15:56 +00:00
|
|
|
$errormsg .= get_string('dirrooterror', 'install').'<br />';
|
|
|
|
}
|
|
|
|
if ($fh) fclose($fh);
|
2004-08-19 08:53:23 +00:00
|
|
|
|
2004-10-22 10:15:56 +00:00
|
|
|
$CFG->dirroot = $INSTALL['dirroot'];
|
2004-08-19 08:12:28 +00:00
|
|
|
|
2004-10-22 10:15:56 +00:00
|
|
|
/// check wwwroot
|
|
|
|
if (ini_get('allow_url_fopen')) {
|
2004-08-19 08:53:23 +00:00
|
|
|
if (($fh = @fopen($INSTALL['wwwroot'].'/install.php', 'r')) === false) {
|
2004-10-22 10:15:56 +00:00
|
|
|
$errormsg .= get_string('wwwrooterror', 'install').'<br />';
|
2004-08-12 15:53:32 +00:00
|
|
|
}
|
|
|
|
}
|
2004-10-22 10:15:56 +00:00
|
|
|
if ($fh) fclose($fh);
|
|
|
|
|
|
|
|
/// check dataroot
|
|
|
|
$CFG->dataroot = $INSTALL['dataroot'];
|
|
|
|
if (make_upload_directory('sessions', false) === false ) {
|
|
|
|
$errormsg = get_string('datarooterror', 'install').'<br />';
|
|
|
|
}
|
|
|
|
if ($fh) fclose($fh);
|
2004-08-12 15:53:32 +00:00
|
|
|
|
|
|
|
if (!empty($errormsg)) $nextstage = 2;
|
|
|
|
|
|
|
|
error_reporting(7);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//==========================================================================//
|
|
|
|
|
|
|
|
/// Check database settings if stage 3 data submitted
|
|
|
|
/// Try to connect to the database. If that fails then try to create the database
|
2004-08-17 13:51:41 +00:00
|
|
|
|
2004-08-12 15:53:32 +00:00
|
|
|
if ($INSTALL['stage'] == 3) {
|
|
|
|
|
|
|
|
if (empty($INSTALL['dbname'])) {
|
|
|
|
$INSTALL['dbname'] = 'moodle';
|
|
|
|
}
|
2004-08-19 08:53:23 +00:00
|
|
|
|
2004-08-17 13:51:41 +00:00
|
|
|
/// different format for postgres7 by socket
|
|
|
|
if ($INSTALL['dbtype'] == 'postgres7' and ($INSTALL['dbhost'] == 'localhost' || $INSTALL['dbhost'] == '127.0.0.1')) {
|
2004-08-12 15:53:32 +00:00
|
|
|
$INSTALL['dbhost'] = "user='{$INSTALL['dbuser']}' password='{$INSTALL['dbpass']}' dbname='{$INSTALL['dbname']}'";
|
2004-08-17 13:51:41 +00:00
|
|
|
$INSTALL['dbuser'] = '';
|
|
|
|
$INSTALL['dbpass'] = '';
|
|
|
|
$INSTALL['dbname'] = '';
|
|
|
|
|
2004-08-12 15:53:32 +00:00
|
|
|
if ($INSTALL['prefix'] == '') { /// must have a prefix
|
|
|
|
$INSTALL['prefix'] = 'mdl_';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-09-23 05:40:53 +00:00
|
|
|
if ($INSTALL['dbtype'] == 'mysql') { /// Check MySQL extension is present
|
|
|
|
if (!extension_loaded('mysql')) {
|
|
|
|
$errormsg = get_string('mysqlextensionisnotpresentinphp', 'install');
|
|
|
|
$nextstage = 3;
|
|
|
|
}
|
|
|
|
}
|
2004-08-12 15:53:32 +00:00
|
|
|
|
2004-09-23 05:40:53 +00:00
|
|
|
if (empty($errormsg)) {
|
|
|
|
|
|
|
|
$db = &ADONewConnection($INSTALL['dbtype']);
|
|
|
|
|
|
|
|
error_reporting(0); // Hide errors
|
|
|
|
|
|
|
|
if (! $dbconnected = $db->Connect($INSTALL['dbhost'],$INSTALL['dbuser'],$INSTALL['dbpass'],$INSTALL['dbname'])) {
|
|
|
|
/// The following doesn't seem to work but we're working on it
|
|
|
|
/// If you come up with a solution for creating a database in MySQL
|
|
|
|
/// feel free to put it in and let us know
|
|
|
|
if ($dbconnected = $db->Connect($INSTALL['dbhost'],$INSTALL['dbuser'],$INSTALL['dbpass'])) {
|
|
|
|
switch ($INSTALL['dbtype']) { /// Try to create a database
|
|
|
|
case 'mysql':
|
|
|
|
if ($db->Execute("CREATE DATABASE {$INSTALL['dbname']};")) {
|
|
|
|
$dbconnected = $db->Connect($INSTALL['dbhost'],$INSTALL['dbuser'],$INSTALL['dbpass'],$INSTALL['dbname']);
|
|
|
|
} else {
|
|
|
|
$errormsg = get_string('dbcreationerror', 'install');
|
|
|
|
$nextstage = 3;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2004-08-12 15:53:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
error_reporting(7);
|
|
|
|
|
|
|
|
if (($dbconnected === false) and (empty($errormsg)) ) {
|
|
|
|
$errormsg = get_string('dbconnectionerror', 'install');
|
|
|
|
$nextstage = 3;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//==========================================================================//
|
|
|
|
|
|
|
|
/// If the next stage is admin directory settings OR we have just come from there then
|
|
|
|
/// check the admin directory.
|
|
|
|
/// If we can open a file then we know that the admin name is correct.
|
|
|
|
|
|
|
|
if ($nextstage == 4 or $INSTALL['stage'] == 4) {
|
2004-10-22 10:17:25 +00:00
|
|
|
if (($fh = @fopen($INSTALL['dirroot'].'/'.$INSTALL['admindirname'].'/site.html', 'r')) !== false) {
|
2004-08-12 15:53:32 +00:00
|
|
|
$nextstage = ($goforward) ? 5 : 3;
|
|
|
|
fclose($fh);
|
|
|
|
} else {
|
|
|
|
if ($nextstage != 4) {
|
|
|
|
$errormsg = get_string('admindirerror', 'install');
|
|
|
|
$nextstage = 4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//==========================================================================//
|
|
|
|
|
|
|
|
/// Display or print the data
|
|
|
|
/// Put the data into a string
|
|
|
|
/// Try to open config file for writing.
|
2004-08-17 13:51:41 +00:00
|
|
|
|
2004-08-12 15:53:32 +00:00
|
|
|
if ($nextstage == 5) {
|
2004-08-19 08:53:23 +00:00
|
|
|
|
|
|
|
$str = '<?php /// Moodle Configuration File '."\r\n";
|
|
|
|
$str .= "\r\n";
|
|
|
|
|
|
|
|
$str .= 'unset($CFG);'."\r\n";
|
|
|
|
$str .= "\r\n";
|
|
|
|
|
|
|
|
$str .= '$CFG->dbtype = \''.$INSTALL['dbtype']."';\r\n";
|
2004-09-06 15:50:47 +00:00
|
|
|
$str .= '$CFG->dbhost = \''.addslashes($INSTALL['dbhost'])."';\r\n";
|
2004-08-31 12:53:51 +00:00
|
|
|
if (!empty($INSTALL['dbname'])) {
|
2004-08-19 08:53:23 +00:00
|
|
|
$str .= '$CFG->dbname = \''.$INSTALL['dbname']."';\r\n";
|
|
|
|
$str .= '$CFG->dbuser = \''.$INSTALL['dbuser']."';\r\n";
|
|
|
|
$str .= '$CFG->dbpass = \''.$INSTALL['dbpass']."';\r\n";
|
|
|
|
}
|
|
|
|
$str .= '$CFG->dbpersist = false;'."\r\n";
|
|
|
|
$str .= '$CFG->prefix = \''.$INSTALL['prefix']."';\r\n";
|
|
|
|
$str .= "\r\n";
|
|
|
|
|
|
|
|
$str .= '$CFG->wwwroot = \''.$INSTALL['wwwroot']."';\r\n";
|
|
|
|
$str .= '$CFG->dirroot = \''.$INSTALL['dirroot']."';\r\n";
|
|
|
|
$str .= '$CFG->dataroot = \''.$INSTALL['dataroot']."';\r\n";
|
2004-12-13 07:38:43 +00:00
|
|
|
$str .= '$CFG->admin = \''.$INSTALL['admindirname']."';\r\n";
|
2004-08-19 08:53:23 +00:00
|
|
|
$str .= "\r\n";
|
|
|
|
|
2004-12-26 14:45:39 +00:00
|
|
|
$str .= '$CFG->directorypermissions = 02777;'."\r\n";
|
2004-08-19 08:53:23 +00:00
|
|
|
$str .= "\r\n";
|
|
|
|
|
|
|
|
$str .= 'require_once("$CFG->dirroot/lib/setup.php");'."\r\n";
|
|
|
|
$str .= '// MAKE SURE WHEN YOU EDIT THIS FILE THAT THERE ARE NO SPACES, BLANK LINES,'."\r\n";
|
|
|
|
$str .= '// RETURNS, OR ANYTHING ELSE AFTER THE TWO CHARACTERS ON THE NEXT LINE.'."\r\n";
|
|
|
|
$str .= '?>';
|
|
|
|
|
2004-08-21 13:27:44 +00:00
|
|
|
umask(0137);
|
|
|
|
|
2004-08-12 15:53:32 +00:00
|
|
|
if (( $configsuccess = ($fh = @fopen($configfile, 'w')) ) !== false) {
|
|
|
|
fwrite($fh, $str);
|
|
|
|
fclose($fh);
|
|
|
|
}
|
2004-08-21 13:27:44 +00:00
|
|
|
|
2004-08-19 08:53:23 +00:00
|
|
|
|
|
|
|
$INSTALL['config'] = $str;
|
2004-08-12 15:53:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//==========================================================================//
|
|
|
|
|
|
|
|
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<html dir="<?php echo (get_string('this_direction') == 'rtl') ? 'rtl' : 'ltr' ?>">
|
|
|
|
<head>
|
|
|
|
<link rel="shortcut icon" href="http://moodle.dougiamas.net/theme/standard/favicon.ico" />
|
|
|
|
<title>Moodle Install</title>
|
|
|
|
<meta http-equiv="content-type" content="text/html; charset=<?php print_string('thischarset') ?>" />
|
|
|
|
<?php css_styles() ?>
|
|
|
|
|
|
|
|
</head>
|
|
|
|
|
|
|
|
<body>
|
|
|
|
|
2004-08-17 13:51:41 +00:00
|
|
|
|
|
|
|
<?php
|
|
|
|
if (isset($_GET['help'])) {
|
|
|
|
print_install_help($_GET['help']);
|
2004-08-19 08:53:23 +00:00
|
|
|
close_window_button();
|
2004-08-17 13:51:41 +00:00
|
|
|
} else {
|
|
|
|
?>
|
|
|
|
|
2004-08-12 15:53:32 +00:00
|
|
|
|
|
|
|
<table class="main" align="center" cellpadding="3" cellspacing="0">
|
|
|
|
<tr>
|
2004-08-17 13:51:41 +00:00
|
|
|
<td class="td_mainlogo">
|
2004-09-16 17:13:57 +00:00
|
|
|
<p class="p_mainlogo"><img src="pix/moodlelogo-med.gif" width="240" height="60" alt=\"\"></p>
|
2004-08-17 13:51:41 +00:00
|
|
|
</td>
|
|
|
|
<td class="td_mainlogo" valign="bottom">
|
|
|
|
<p class="p_mainheader"><?php print_string('installation', 'install') ?></p>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
|
|
<td class="td_mainheading" colspan="2">
|
|
|
|
<p class="p_mainheading"><?php echo $stagetext[$nextstage] ?></p>
|
|
|
|
</td>
|
2004-08-12 15:53:32 +00:00
|
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
2004-08-17 13:51:41 +00:00
|
|
|
<td class="td_main" colspan="2">
|
2004-08-19 08:53:23 +00:00
|
|
|
|
2004-08-12 15:53:32 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
if (!empty($errormsg)) echo "<p class=\"errormsg\" align=\"center\">$errormsg</p>\n";
|
|
|
|
|
|
|
|
|
|
|
|
if ($nextstage == 5) {
|
2004-08-19 08:53:23 +00:00
|
|
|
$INSTALL['stage'] = 0;
|
|
|
|
$options = array();
|
|
|
|
$options['lang'] = $INSTALL['language'];
|
2004-08-12 15:53:32 +00:00
|
|
|
if ($configsuccess) {
|
|
|
|
echo "<p>".get_string('configfilewritten', 'install')."</p>\n";
|
2004-08-19 08:53:23 +00:00
|
|
|
|
|
|
|
echo "<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"100%\">\n";
|
|
|
|
echo "<tr>\n";
|
|
|
|
echo "<td width=\"33.3%\"> </td>\n";
|
|
|
|
echo "<td width=\"33.3%\"> </td>\n";
|
|
|
|
echo "<td width=\"33.3%\" align=\"right\">\n";
|
|
|
|
print_single_button("index.php", $options, get_string('continue')." »");
|
|
|
|
echo "</td>\n";
|
|
|
|
echo "</tr>\n";
|
|
|
|
echo "</table>\n";
|
|
|
|
|
2004-08-12 15:53:32 +00:00
|
|
|
} else {
|
2004-08-19 08:53:23 +00:00
|
|
|
echo "<p class=\"errormsg\">".get_string('configfilenotwritten', 'install')."</p>";
|
|
|
|
|
|
|
|
echo "<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"100%\">\n";
|
|
|
|
echo "<tr>\n";
|
|
|
|
echo "<td width=\"33.3%\"> </td>\n";
|
|
|
|
echo "<td width=\"33.3%\" align=\"center\">\n";
|
|
|
|
$installoptions = array();
|
|
|
|
$installoptions['download'] = 1;
|
|
|
|
print_single_button("install.php", $installoptions, get_string('download', 'install'));
|
|
|
|
echo "</td>\n";
|
|
|
|
echo "<td width=\"33.3%\" align=\"right\">\n";
|
|
|
|
print_single_button("index.php", $options, get_string('continue')." »");
|
|
|
|
echo "</td>\n";
|
|
|
|
echo "</tr>\n";
|
|
|
|
echo "</table>\n";
|
|
|
|
|
2004-08-12 15:53:32 +00:00
|
|
|
echo "<hr />\n";
|
2004-08-19 08:53:23 +00:00
|
|
|
echo "<div style=\"text-align: left\">\n";
|
|
|
|
print_object(htmlentities($str));
|
|
|
|
echo "</div>\n";
|
2004-08-12 15:53:32 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$formaction = (isset($_GET['configfile'])) ? "install.php?configfile=".$_GET['configfile'] : "install.php";
|
|
|
|
form_table($nextstage, $formaction);
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|
|
|
|
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</table>
|
|
|
|
|
2004-08-17 13:51:41 +00:00
|
|
|
<?php
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
|
2004-08-12 15:53:32 +00:00
|
|
|
</body>
|
|
|
|
</html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2004-08-19 08:53:23 +00:00
|
|
|
<?php
|
2004-08-12 15:53:32 +00:00
|
|
|
|
|
|
|
//==========================================================================//
|
|
|
|
|
|
|
|
|
|
|
|
function print_object($object) {
|
|
|
|
echo "<pre>\n";
|
|
|
|
print_r($object);
|
|
|
|
echo "</pre>\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//==========================================================================//
|
|
|
|
|
2004-08-17 13:51:41 +00:00
|
|
|
function form_table($nextstage = 0, $formaction = "install.php") {
|
2004-08-12 15:53:32 +00:00
|
|
|
global $INSTALL;
|
|
|
|
|
|
|
|
/// standard lines for all forms
|
|
|
|
?>
|
|
|
|
|
|
|
|
<form name="installform" method="post" action="<?php echo $formaction ?>">
|
|
|
|
<input type="hidden" name="stage" value="<?php echo $nextstage ?>" />
|
|
|
|
<table class="install_table" cellspacing="3" cellpadding="3" align="center">
|
|
|
|
|
|
|
|
<?php
|
|
|
|
/// what we do depends on the stage we're at
|
|
|
|
switch ($nextstage) {
|
2004-08-17 13:51:41 +00:00
|
|
|
case 0: /// Language settings
|
2004-08-12 15:53:32 +00:00
|
|
|
?>
|
|
|
|
<tr>
|
|
|
|
<td class="td_left"><p><?php print_string('language') ?></p></td>
|
|
|
|
<td class="td_right">
|
|
|
|
<?php choose_from_menu (get_list_of_languages(), 'language', $INSTALL['language'], '') ?>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
|
|
|
|
<?php
|
2004-08-17 13:51:41 +00:00
|
|
|
break;
|
|
|
|
case 1: /// Compatibilty check
|
|
|
|
$compatsuccess = true;
|
2004-08-19 08:53:23 +00:00
|
|
|
|
2004-08-17 13:51:41 +00:00
|
|
|
/// Check that PHP is of a sufficient version
|
2004-08-19 08:53:23 +00:00
|
|
|
print_compatibility_row(check_php_version("4.1.0"), get_string('phpversion', 'install'), get_string('phpversionerror', 'install'), 'phpversionhelp');
|
2004-08-17 13:51:41 +00:00
|
|
|
/// Check session auto start
|
|
|
|
print_compatibility_row(!ini_get_bool('session.auto_start'), get_string('sessionautostart', 'install'), get_string('sessionautostarterror', 'install'), 'sessionautostarthelp');
|
|
|
|
/// Check magic quotes
|
|
|
|
print_compatibility_row(!ini_get_bool('magic_quotes_runtime'), get_string('magicquotesruntime', 'install'), get_string('magicquotesruntimeerror', 'install'), 'magicquotesruntimehelp');
|
2004-08-19 08:53:23 +00:00
|
|
|
/// Check safe mode
|
|
|
|
print_compatibility_row(!ini_get_bool('safe_mode'), get_string('safemode', 'install'), get_string('safemodeerror', 'install'), 'safemodehelp', true);
|
2004-08-17 13:51:41 +00:00
|
|
|
/// Check file uploads
|
2004-08-19 08:53:23 +00:00
|
|
|
print_compatibility_row(ini_get_bool('file_uploads'), get_string('fileuploads', 'install'), get_string('fileuploadserror', 'install'), 'fileuploadshelp', true);
|
2004-08-17 13:51:41 +00:00
|
|
|
/// Check GD version
|
2004-08-19 08:53:23 +00:00
|
|
|
print_compatibility_row(check_gd_version(), get_string('gdversion', 'install'), get_string('gdversionerror', 'install'), 'gdversionhelp', true);
|
2004-08-17 13:51:41 +00:00
|
|
|
/// Check memory limit
|
2004-08-19 08:53:23 +00:00
|
|
|
print_compatibility_row(check_memory_limit(), get_string('memorylimit', 'install'), get_string('memorylimiterror', 'install'), 'memorylimithelp', true);
|
2004-08-17 13:51:41 +00:00
|
|
|
|
|
|
|
|
2004-08-12 15:53:32 +00:00
|
|
|
break;
|
|
|
|
case 2: /// Directory settings
|
|
|
|
?>
|
|
|
|
|
|
|
|
<tr>
|
|
|
|
<td class="td_left"><p><?php print_string('wwwroot', 'install') ?></p></td>
|
|
|
|
<td class="td_right">
|
|
|
|
<input type="text" size="40"name="wwwroot" value="<?php echo $INSTALL['wwwroot'] ?>" />
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td class="td_left"><p><?php print_string('dirroot', 'install') ?></p></td>
|
|
|
|
<td class="td_right">
|
|
|
|
<input type="text" size="40" name="dirroot" value="<?php echo $INSTALL['dirroot'] ?>" />
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td class="td_left"><p><?php print_string('dataroot', 'install') ?></p></td>
|
|
|
|
<td class="td_right">
|
|
|
|
<input type="text" size="40" name="dataroot" value="<?php echo $INSTALL['dataroot'] ?>" />
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
|
|
|
|
<?php
|
|
|
|
break;
|
|
|
|
case 3: /// Database settings
|
|
|
|
?>
|
|
|
|
|
|
|
|
<tr>
|
|
|
|
<td class="td_left"><p><?php print_string('dbtype', 'install') ?></p></td>
|
|
|
|
<td class="td_right">
|
|
|
|
<?php choose_from_menu (array("mysql" => "mysql", "postgres7" => "postgres7"), 'dbtype', $INSTALL['dbtype'], '') ?>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td class="td_left"><p><?php print_string('dbhost', 'install') ?></p></td>
|
|
|
|
<td class="td_right">
|
|
|
|
<input type="text" size="40" name="dbhost" value="<?php echo $INSTALL['dbhost'] ?>" />
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td class="td_left"><p><?php print_string('database', 'install') ?></p></td>
|
|
|
|
<td class="td_right">
|
|
|
|
<input type="text" size="40" name="dbname" value="<?php echo $INSTALL['dbname'] ?>" />
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td class="td_left"><p><?php print_string('user') ?></p></td>
|
|
|
|
<td class="td_right">
|
|
|
|
<input type="text" size="40" name="dbuser" value="<?php echo $INSTALL['dbuser'] ?>" />
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td class="td_left"><p><?php print_string('password') ?></p></td>
|
|
|
|
<td class="td_right">
|
2004-10-22 10:15:56 +00:00
|
|
|
<input type="password" size="40" name="dbpass" value="<?php echo $INSTALL['dbpass'] ?>" />
|
2004-08-12 15:53:32 +00:00
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td class="td_left"><p><?php print_string('dbprefix', 'install') ?></p></td>
|
|
|
|
<td class="td_right">
|
|
|
|
<input type="text" size="40" name="prefix" value="<?php echo $INSTALL['prefix'] ?>" />
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
|
|
|
|
<?php
|
|
|
|
break;
|
|
|
|
case 4: /// Administration directory setting
|
|
|
|
?>
|
|
|
|
|
|
|
|
<tr>
|
|
|
|
<td class="td_left"><p><?php print_string('admindirname', 'install') ?></p></td>
|
|
|
|
<td class="td_right">
|
|
|
|
<input type="text" size="40" name="admindirname" value="<?php echo $INSTALL['admindirname'] ?>" />
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
|
|
|
|
|
|
|
|
<?php
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
}
|
|
|
|
?>
|
2004-08-19 08:12:28 +00:00
|
|
|
|
2004-08-19 08:53:23 +00:00
|
|
|
<tr>
|
|
|
|
<td colspan="<?php echo ($nextstage == 1) ? '3' : '2'; ?>">
|
|
|
|
|
|
|
|
<?php echo ($nextstage < 5) ? "<input type=\"submit\" name=\"next\" value=\"".get_string('next')." »\" style=\"float: right\"/>\n" : " \n" ?>
|
|
|
|
<?php echo ($nextstage > 0) ? "<input type=\"submit\" name=\"prev\" value=\"« ".get_string('previous')."\" style=\"float: left\"/>\n" : " \n" ?>
|
2004-08-19 08:12:28 +00:00
|
|
|
|
2004-08-21 13:27:44 +00:00
|
|
|
|
2004-08-19 08:53:23 +00:00
|
|
|
</td>
|
2004-08-19 08:12:28 +00:00
|
|
|
|
2004-08-19 08:53:23 +00:00
|
|
|
</tr>
|
|
|
|
|
|
|
|
</table>
|
2004-08-12 15:53:32 +00:00
|
|
|
</form>
|
|
|
|
|
|
|
|
<?php
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2004-08-17 13:51:41 +00:00
|
|
|
//==========================================================================//
|
|
|
|
|
2004-08-19 08:53:23 +00:00
|
|
|
function print_compatibility_row($success, $testtext, $errormessage, $helpfield='', $caution=false) {
|
2004-08-17 13:51:41 +00:00
|
|
|
echo "<tr>\n";
|
2004-08-19 08:53:23 +00:00
|
|
|
echo "<td class=\"td_left\" valign=\"top\" nowrap width=\"160\"><p>$testtext</p></td>\n";
|
2004-08-17 13:51:41 +00:00
|
|
|
if ($success) {
|
2004-08-19 08:53:23 +00:00
|
|
|
echo "<td valign=\"top\"><p class=\"p_pass\">".get_string('pass', 'install')."</p></td>\n";
|
|
|
|
echo "<td valign=\"top\"> </td>\n";
|
2004-08-17 13:51:41 +00:00
|
|
|
} else {
|
2004-08-19 08:53:23 +00:00
|
|
|
echo "<td valign=\"top\"";
|
|
|
|
echo ($caution) ? "<p class=\"p_caution\">".get_string('caution', 'install') : "<p class=\"p_fail\">".get_string('fail', 'install');
|
|
|
|
echo "</p></td>\n";
|
|
|
|
echo "<td valign=\"top\">";
|
|
|
|
echo "<p>$errormessage ";
|
|
|
|
install_helpbutton("install.php?help=$helpfield");
|
|
|
|
echo "</p></td>\n";
|
2004-08-17 13:51:41 +00:00
|
|
|
}
|
|
|
|
echo "</tr>\n";
|
|
|
|
return $success;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//==========================================================================//
|
|
|
|
|
|
|
|
function install_helpbutton($url, $title='') {
|
|
|
|
if ($title == '') {
|
|
|
|
$title = get_string('help');
|
|
|
|
}
|
|
|
|
echo "<a href=\"javascript: void(0)\">";
|
|
|
|
echo "<img src=\"./pix/help.gif\" height=\"17\" width=\"22\" alt=\"$title\"";
|
2004-09-16 17:13:57 +00:00
|
|
|
echo "border=\"0\" align=\"middle\" title=\"$title\" ";
|
2004-08-17 13:51:41 +00:00
|
|
|
echo "onClick=\"return window.open('$url', 'Help', 'menubar=0,location=0,scrollbars,resizable,width=500,height=400')\">";
|
|
|
|
echo "</a>\n";
|
|
|
|
}
|
2004-08-19 08:53:23 +00:00
|
|
|
|
2004-08-17 13:51:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
//==========================================================================//
|
|
|
|
|
|
|
|
function print_install_help($help) {
|
|
|
|
switch ($help) {
|
|
|
|
case 'phpversionhelp':
|
|
|
|
print_string($help, 'install', phpversion());
|
|
|
|
break;
|
|
|
|
case 'memorylimithelp':
|
2004-08-17 14:12:01 +00:00
|
|
|
print_string($help, 'install', get_memory_limit());
|
2004-08-17 13:51:41 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
print_string($help, 'install');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//==========================================================================//
|
|
|
|
|
|
|
|
function get_memory_limit() {
|
|
|
|
if ($limit = ini_get('memory_limit')) {
|
|
|
|
return $limit;
|
|
|
|
} else {
|
|
|
|
return get_cfg_var('memory_limit');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================//
|
|
|
|
|
|
|
|
function check_memory_limit() {
|
|
|
|
|
|
|
|
/// if limit is already 16M or more then we don't care if we can change it or not
|
|
|
|
if ((int)str_replace('M', '', get_memory_limit()) >= 16) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Otherwise, see if we can change it ourselves
|
|
|
|
@ini_set('memory_limit', '16M');
|
|
|
|
return ((int)str_replace('M', '', get_memory_limit()) >= 16);
|
|
|
|
}
|
|
|
|
|
2004-08-12 15:53:32 +00:00
|
|
|
//==========================================================================//
|
|
|
|
|
|
|
|
function css_styles() {
|
|
|
|
?>
|
|
|
|
|
|
|
|
<style type="text/css">
|
|
|
|
|
|
|
|
body { background-color: #ffeece; }
|
2004-08-19 08:53:23 +00:00
|
|
|
p, li {
|
2004-08-17 13:51:41 +00:00
|
|
|
font-family: helvetica, arial, sans-serif;
|
|
|
|
font-size: 10pt;
|
|
|
|
}
|
2004-08-12 15:53:32 +00:00
|
|
|
a { text-decoration: none; color: blue; }
|
|
|
|
.errormsg {
|
|
|
|
color: red;
|
|
|
|
font-weight: bold;
|
|
|
|
}
|
2004-08-17 13:51:41 +00:00
|
|
|
blockquote {
|
2004-08-19 08:53:23 +00:00
|
|
|
font-family: courier, monospace;
|
2004-08-17 13:51:41 +00:00
|
|
|
font-size: 10pt;
|
|
|
|
}
|
2004-08-12 15:53:32 +00:00
|
|
|
.install_table {
|
|
|
|
width: 500px;
|
|
|
|
}
|
|
|
|
.td_left {
|
|
|
|
text-align: right;
|
|
|
|
font-weight: bold;
|
|
|
|
}
|
|
|
|
.td_right {
|
|
|
|
text-align: left;
|
|
|
|
}
|
|
|
|
.main {
|
|
|
|
width: 500px;
|
|
|
|
border-width: 1px;
|
|
|
|
border-style: solid;
|
|
|
|
border-color: #ffc85f;
|
|
|
|
-moz-border-radius-bottomleft: 15px;
|
|
|
|
-moz-border-radius-bottomright: 15px;
|
|
|
|
}
|
|
|
|
.td_mainheading {
|
|
|
|
background-color: #fee6b9;
|
2004-08-17 13:51:41 +00:00
|
|
|
padding: 10px;
|
2004-08-12 15:53:32 +00:00
|
|
|
}
|
|
|
|
.td_main {
|
|
|
|
text-align: center;
|
|
|
|
}
|
2004-08-17 13:51:41 +00:00
|
|
|
.td_mainlogo {
|
|
|
|
}
|
|
|
|
.p_mainlogo {
|
|
|
|
}
|
2004-08-12 15:53:32 +00:00
|
|
|
.p_mainheading {
|
2004-08-17 13:51:41 +00:00
|
|
|
font-size: 11pt;
|
|
|
|
}
|
|
|
|
.p_mainheader{
|
|
|
|
text-align: right;
|
|
|
|
font-size: 20pt;
|
|
|
|
font-weight: bold;
|
|
|
|
}
|
|
|
|
.p_pass {
|
|
|
|
color: green;
|
|
|
|
font-weight: bold;
|
|
|
|
}
|
|
|
|
.p_fail {
|
|
|
|
color: red;
|
|
|
|
font-weight: bold;
|
|
|
|
}
|
2004-08-19 08:53:23 +00:00
|
|
|
.p_caution {
|
|
|
|
color: #ff6600;
|
|
|
|
font-weight: bold;
|
|
|
|
}
|
2004-08-17 13:51:41 +00:00
|
|
|
.p_help {
|
|
|
|
text-align: center;
|
|
|
|
font-family: helvetica, arial, sans-serif;
|
|
|
|
font-size: 14pt;
|
|
|
|
font-weight: bold;
|
|
|
|
color: #333333;
|
2004-08-12 15:53:32 +00:00
|
|
|
}
|
2004-08-19 08:53:23 +00:00
|
|
|
|
2004-08-12 15:53:32 +00:00
|
|
|
</style>
|
|
|
|
|
|
|
|
<?php
|
|
|
|
}
|
|
|
|
?>
|