Skip to content

Commit

Permalink
Now the installation process perform then environment check.
Browse files Browse the repository at this point in the history
  • Loading branch information
stronk7 committed Jan 21, 2006
1 parent 0e101fe commit 3b3b802
Showing 1 changed file with 115 additions and 41 deletions.
156 changes: 115 additions & 41 deletions install.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
define ('DIRECTORY', 2); /// 2. Directory settings
define ('DATABASE', 3); /// 2. Database settings
define ('ADMIN', 4); /// 4. Administration directory name
define ('SAVE', 5); /// 5. Save or display the settings
define ('REDIRECT', 6); /// 6. Redirect to index.php
define ('ENVIRONMENT', 5); /// 5. Administration directory name
define ('SAVE', 6); /// 6. Save or display the settings
define ('REDIRECT', 7); /// 7. Redirect to index.php
///==========================================================================//


Expand Down Expand Up @@ -59,7 +60,36 @@
$INSTALL['stage'] = WELCOME;
}

//==========================================================================//

/// Was data submitted?
if (isset($_POST['stage'])) {

/// 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;
}


if ($nextstage < 0) $nextstage = WELCOME;


/// Store any posted data
foreach ($_POST as $setting=>$value) {
$INSTALL[$setting] = $value;
}

} else {

$goforward = true;
$nextstage = WELCOME;

}

//==========================================================================//

Expand All @@ -69,16 +99,25 @@
$CFG->dirroot = $INSTALL['dirroot'];
$CFG->libdir = $INSTALL['dirroot'].'/lib';
$CFG->dataroot = $INSTALL['dataroot'];
$CFG->admin = $INSTALL['admindirname'];
$CFG->directorypermissions = 00777;


/// Include some moodle libraries

require_once('./lib/setuplib.php');
require_once('./lib/moodlelib.php');
require_once('./lib/weblib.php');
require_once('./lib/adodb/adodb.inc.php');
require_once('./lib/environmentlib.php');
require_once('./lib/xmlize.php');
require_once('./version.php');

/// Set version and release
$INSTALL['version'] = $version;
$INSTALL['release'] = $release;

/// Have the $db object ready because we are going to use it often
$db = &ADONewConnection($INSTALL['dbtype']);

/// guess the www root
if ($INSTALL['wwwroot'] == '') {
Expand All @@ -90,6 +129,7 @@
DIRECTORY => get_string('directorysettingshead', 'install'),
DATABASE => get_string('databasesettingshead', 'install'),
ADMIN => get_string('admindirsettinghead', 'install'),
ENVIRONMENT => get_string('environmenthead', 'install'),
SAVE => get_string('configurationcompletehead', 'install')
);

Expand All @@ -98,6 +138,7 @@
DIRECTORY => get_string('directorysettingssub', 'install'),
DATABASE => get_string('databasesettingssub', 'install'),
ADMIN => get_string('admindirsettingsub', 'install'),
ENVIRONMENT => get_string('environmentsub', 'install'),
SAVE => get_string('configurationcompletesub', 'install')
);

Expand Down Expand Up @@ -126,37 +167,6 @@



//==========================================================================//

/// Was data submitted?
if (isset($_POST['stage'])) {

/// 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;
}


if ($nextstage < 0) $nextstage = WELCOME;


/// Store any posted data
foreach ($_POST as $setting=>$value) {
$INSTALL[$setting] = $value;
}

} else {

$goforward = true;
$nextstage = WELCOME;

}



//==========================================================================//
Expand Down Expand Up @@ -232,8 +242,6 @@

if (empty($errormsg)) {

$db = &ADONewConnection($INSTALL['dbtype']);

error_reporting(0); // Hide errors

if (! $dbconnected = $db->Connect($INSTALL['dbhost'],$INSTALL['dbuser'],$INSTALL['dbpass'],$INSTALL['dbname'])) {
Expand Down Expand Up @@ -273,9 +281,9 @@

if ($nextstage == ADMIN or $INSTALL['stage'] == ADMIN) {
if (!ini_get('allow_url_fopen')) {
$nextstage = ($goforward) ? SAVE : DATABASE;
$nextstage = ($goforward) ? ENVIRONMENT : DATABASE;
} else if (($fh = @fopen($INSTALL['wwwroot'].'/'.$INSTALL['admindirname'].'/site.html', 'r')) !== false) {
$nextstage = ($goforward) ? SAVE : DATABASE;
$nextstage = ($goforward) ? ENVIRONMENT : DATABASE;
fclose($fh);
} else {
if ($nextstage != ADMIN) {
Expand All @@ -285,6 +293,25 @@
}
}

//==========================================================================//

// Check if we can navigate from the environemt page (because it's ok)

if ($INSTALL['stage'] == ENVIRONMENT) {
error_reporting(0); // Hide errors
$dbconnected = $db->Connect($INSTALL['dbhost'],$INSTALL['dbuser'],$INSTALL['dbpass'],$INSTALL['dbname']);
error_reporting(7); // Show errors
if ($dbconnected) {
/// Execute environment check, printing results
if (!check_moodle_environment($INSTALL['release'], $environment_results, false)) {
$nextstage = ENVIRONMENT;
}
} else {
/// We never should reach this because DB has been tested before arriving here
$errormsg = get_string('dbconnectionerror', 'install');
$nextstage = DATABASE;
}
}


//==========================================================================//
Expand Down Expand Up @@ -474,7 +501,7 @@ function print_object($object) {
//==========================================================================//

function form_table($nextstage = WELCOME, $formaction = "install.php") {
global $INSTALL;
global $INSTALL, $db;

/// standard lines for all forms
?>
Expand Down Expand Up @@ -596,6 +623,32 @@ function form_table($nextstage = WELCOME, $formaction = "install.php") {
</tr>


<?php
break;
case ENVIRONMENT: /// Environment checks
?>

<tr>
<td colspan="2">
<?php
error_reporting(0); // Hide errors
$dbconnected = $db->Connect($INSTALL['dbhost'],$INSTALL['dbuser'],$INSTALL['dbpass'],$INSTALL['dbname']);
error_reporting(7); // Show errors
if ($dbconnected) {
/// Execute environment check, printing results
check_moodle_environment($INSTALL['release'], $environment_results, true);
} else {
/// We never should reach this because DB has been tested before arriving here
$errormsg = get_string('dbconnectionerror', 'install');
$nextstage = DATABASE;
echo '<p class="errormsg" align="center">'.get_string('dbconnectionerror', 'install').'</p>';
}
?>
</td>
</tr>



<?php
break;
default:
Expand Down Expand Up @@ -706,7 +759,7 @@ function css_styles() {
<style type="text/css">

body { background-color: #ffeece; }
p, li {
p, li, td {
font-family: helvetica, arial, sans-serif;
font-size: 10pt;
}
Expand Down Expand Up @@ -779,7 +832,28 @@ function css_styles() {
font-weight: bold;
color: #333333;
}

.environmenttable {
font-size: 10pt;
border-color: #ffc85f;
}
.header {
background-color: #fee6b9;
font-size: 10pt;
}
.cell {
background-color: #ffeece;
font-size: 10pt;
}
.error {
color: #ff0000;
}
.errorboxcontent {
text-align: center;
font-weight: bold;
padding: 20px;
color: #ff0000;
}

</style>

<?php
Expand Down

0 comments on commit 3b3b802

Please sign in to comment.