
* Preparation for installer and discontinue support of old config style. * Adding installer with step 0 * Fixing travis config, because example config isn't loaded anymore if normal config does not exist. * Adding installer step 1: database connection * Adding installer step 2: database schema * Adding installer step 3: Your first admin user * Minor fix on step 3 * Adding installer step 4: general settings * Adding installer step 5: optional features * Adding final installation step 7: writing config & finish * Display the current installation progress * Fixing installation finish * Disable direct access to installer * Change colors of "notifying" text * Add check and cross marks to requirements page of the installer * Change how config directory is checked, no more writable check but error if writing fails. * Execute post-receice..
125 lines
2.7 KiB
PHP
125 lines
2.7 KiB
PHP
<?php
|
|
|
|
if(strpos($_SERVER['REQUEST_URI'], 'installer/') !== false){
|
|
die('You cannot directly access the installer files.');
|
|
}
|
|
|
|
/*-----------------------------------------------------------------------------*/
|
|
|
|
define('INSTALLER_MAX_STEP', 6);
|
|
|
|
define('INSTALLER_TYPE_CREATE', 0);
|
|
define('INSTALLER_TYPE_MAP', 1);
|
|
|
|
$installerStepTitles = array(
|
|
'Requirements',
|
|
'Database connection',
|
|
'Database schema',
|
|
'Your first admin user',
|
|
'General settings',
|
|
'Optional features',
|
|
'Finish installation',
|
|
);
|
|
|
|
$installerStepMapping = array(
|
|
0 => 0,
|
|
1 => 1,
|
|
2 => 2,
|
|
3 => 2,
|
|
4 => 3,
|
|
5 => 4,
|
|
6 => 5,
|
|
7 => 6,
|
|
);
|
|
|
|
/*-----------------------------------------------------------------------------*/
|
|
|
|
function installer_reset()
|
|
{
|
|
global $_SESSION;
|
|
|
|
$_SESSION['installer'] = array(
|
|
'lastStep' => 0,
|
|
'step' => 0,
|
|
'config' => array(),
|
|
);
|
|
}
|
|
|
|
function installer_message($setMessage = null)
|
|
{
|
|
global $_SESSION;
|
|
|
|
if(!is_null($setMessage)){
|
|
$_SESSION['installer']['message'] = $setMessage;
|
|
}
|
|
elseif(isset($_SESSION['installer']['message'])){
|
|
$m = '<div class="notification notification-success">'.$_SESSION['installer']['message'].'</div>';
|
|
unset($_SESSION['installer']['message']);
|
|
|
|
return $m;
|
|
}
|
|
|
|
return $setMessage;
|
|
}
|
|
|
|
function installer_prev($thisStep, $stepSize = 1)
|
|
{
|
|
$s = ($thisStep < 0) ? 0 : ($thisStep - $stepSize);
|
|
|
|
$_SESSION['installer']['lastStep'] = $thisStep;
|
|
$_SESSION['installer']['step'] = $s;
|
|
|
|
Router::redirect('/?step='.$s);
|
|
}
|
|
|
|
function installer_next($thisStep, $stepSize = 1)
|
|
{
|
|
$s = ($thisStep > 8) ? 8 : ($thisStep + $stepSize);
|
|
|
|
$_SESSION['installer']['lastStep'] = $thisStep;
|
|
$_SESSION['installer']['step'] = $s;
|
|
|
|
Router::redirect('/?step='.$s);
|
|
}
|
|
|
|
if(!isset($_SESSION['installer'])){
|
|
installer_reset();
|
|
}
|
|
|
|
/*-----------------------------------------------------------------------------*/
|
|
|
|
$step = (isset($_GET['step']) && is_numeric($_GET['step'])) ? intval($_GET['step']) : 0;
|
|
|
|
echo '<h1>Installation of WebMUM</h1>';
|
|
|
|
if($step > 0){
|
|
?>
|
|
<ol style="font-size: 1.1em;">
|
|
<?php for($s = 1; $s <= INSTALLER_MAX_STEP; $s++): ?>
|
|
<li>
|
|
<?php if(isset($installerStepMapping[$step]) && $s < $installerStepMapping[$step]): ?>
|
|
<span style="color: #999;"><?php echo $installerStepTitles[$s]; ?></span>
|
|
<?php elseif(isset($installerStepMapping[$step]) && $s === $installerStepMapping[$step]): ?>
|
|
<strong><?php echo $installerStepTitles[$s]; ?></strong>
|
|
<?php else: ?>
|
|
<?php echo $installerStepTitles[$s]; ?>
|
|
<?php endif; ?>
|
|
</li>
|
|
<?php endfor; ?>
|
|
</ol>
|
|
<?php
|
|
}
|
|
|
|
try{
|
|
$stepFile = __DIR__.'/step'.$step.'.php';
|
|
if(file_exists($stepFile)){
|
|
include_once $stepFile;
|
|
}
|
|
else{
|
|
installer_reset();
|
|
echo 'Wizard step '.$step.' is missing.';
|
|
}
|
|
}
|
|
catch(Exception $e){
|
|
echo $e->getMessage();
|
|
}
|