Quellcode durchsuchen

Adding installer with step 0

ohartl vor 9 Jahren
Ursprung
Commit
651ce7def7
3 geänderte Dateien mit 192 neuen und 0 gelöschten Zeilen
  1. 26 0
      include/css/style.css
  2. 73 0
      installer/index.php
  3. 93 0
      installer/step0.php

+ 26 - 0
include/css/style.css

@@ -5,6 +5,28 @@ body {
 	background-color: white;
 }
 
+hr {
+	border: none;
+	border-bottom: 1px solid #ccc;
+	margin: 20px 0;
+}
+
+hr.invisible {
+	border: none;
+}
+
+.text-fail {
+	color: #d90000;
+}
+
+.text-warning {
+	color: #cbc600;
+}
+
+.text-success {
+	color: #69d169;
+}
+
 
 #header {
 	position: relative;
@@ -80,6 +102,10 @@ body {
 		margin: 25px 0;
 	}
 
+		#content .form hr {
+			margin: 5px 0 15px;
+		}
+
 		#content .form .input-group, #content .form .buttons {
 			padding-bottom: 10px;
 		}

+ 73 - 0
installer/index.php

@@ -0,0 +1,73 @@
+<?php
+
+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)
+{
+	$s = ($thisStep < 0) ? 0 : ($thisStep - 1);
+
+	$_SESSION['installer']['lastStep'] = $thisStep;
+	$_SESSION['installer']['step'] = $s;
+
+	Router::redirect('/?step='.$s);
+}
+
+function installer_next($thisStep)
+{
+	$s = ($thisStep > 8) ? 8 : ($thisStep + 1);
+
+	$_SESSION['installer']['lastStep'] = $thisStep;
+	$_SESSION['installer']['step'] = $s;
+
+	Router::redirect('/?step='.$s);
+}
+
+if(!isset($_SESSION['installer'])){
+	installer_reset();
+}
+
+?>
+<h1>Installation of WebMUM</h1>
+<?php
+
+try{
+	$step = (isset($_GET['step']) && is_numeric($_GET['step'])) ? intval($_GET['step']) : 0;
+
+	$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();
+}

+ 93 - 0
installer/step0.php

@@ -0,0 +1,93 @@
+<?php
+
+$thisStep = 0;
+
+
+$requirements = array();
+$numberOfRequirements = 5;
+if(version_compare(phpversion(), '5.4.0', '>=')){
+	$requirements[] = 'php_version';
+}
+if(function_exists('mysqli_connect')){
+	$requirements[] = 'php_extension_mysqli';
+}
+if(session_status() != PHP_SESSION_DISABLED){
+	$requirements[] = 'php_session_enabled';
+}
+if(file_exists('config') && is_writable('config') && !file_exists('config/config.php')){
+	$requirements[] = 'config_path_writable';
+}
+if(file_exists('config') && file_exists('config/config.php.example')){
+	$requirements[] = 'config_example';
+}
+
+
+if(isset($_GET['go']) && $_GET['go'] == 'next'){
+	if(count($requirements) === $numberOfRequirements){
+		installer_next($thisStep);
+	}
+}
+?>
+<?php echo installer_message(); ?>
+
+<h2>Getting started</h2>
+
+<p>By following this wizard you will install and configure your new WebMUM installation.</p>
+
+<hr>
+
+<strong>System Info:</strong>
+<ul>
+	<li>System: <strong><?php echo php_uname(); ?></strong></li>
+	<li>Hostname: <strong><?php echo $_SERVER['SERVER_NAME']; ?></strong></li>
+	<li>IP: <strong><?php echo $_SERVER['SERVER_ADDR']; ?></strong></li>
+	<li>PHP version: <strong><?php echo phpversion(); ?></strong></li>
+	<li>Server API: <strong><?php echo php_sapi_name(); ?></strong></li>
+	<li>WebMUM directory: <strong><?php echo dirname($_SERVER['SCRIPT_FILENAME']); ?></strong></li>
+</ul>
+
+<strong>Server requirements</strong>
+<ul>
+<?php if(in_array('php_version', $requirements)): ?>
+	<li class="text-success">PHP version: <strong><?php echo phpversion(); ?></strong> (>=5.4.0 or >=7.0.0)</li>
+<?php else: ?>
+	<li class="text-fail">PHP version: <strong><?php echo phpversion(); ?></strong> (>=5.4.0 or >=7.0.0)</li>
+<?php endif; ?>
+</ul>
+
+<strong>Required PHP settings</strong>
+<ul>
+<?php if(in_array('php_extension_mysqli', $requirements)): ?>
+	<li class="text-success">Database extension (mysqli): enabled</li>
+<?php else: ?>
+	<li class="text-fail">Database extension (mysqli): disabled</li>
+<?php endif; ?>
+<?php if(in_array('php_session_enabled', $requirements)): ?>
+	<li class="text-success">Session support: enabled</li>
+<?php else: ?>
+	<li class="text-fail">Session support: disabled</li>
+<?php endif; ?>
+</ul>
+
+<strong>Directories and files</strong>
+<ul>
+<?php if(in_array('config_path_writable', $requirements)): ?>
+	<li class="text-success">"config/": writable</li>
+<?php else: ?>
+	<li class="text-fail">"config/": not writable</li>
+<?php endif; ?>
+<?php if(in_array('config_example', $requirements)): ?>
+	<li class="text-success">"config/config.php.example": exists</li>
+<?php else: ?>
+	<li class="text-fail">"config/config.php.example": is missing</li>
+<?php endif; ?>
+</ul>
+
+<hr>
+
+<?php if(count($requirements) === $numberOfRequirements):?>
+	<p>Click on Start button to continue.</p>
+	<a class="button button-primary" href="/?step=<?php echo $thisStep; ?>&go=next">Start</a>
+<?php else:?>
+	<p class="notification notification-fail">Some requirements aren't fulfilled.</p>
+<?php endif; ?>