X-Git-Url: https://git.cweiske.de/phorkie.git/blobdiff_plain/825c9662ddc1c534712056c458c8f6d71b81b921..81019df2b6d03e732b00e66913546af75bc4d560:/www/setup.php diff --git a/www/setup.php b/www/setup.php index b042339..909306f 100644 --- a/www/setup.php +++ b/www/setup.php @@ -3,6 +3,8 @@ * Check if all is setup correctly */ namespace phorkie; +header('HTTP/1.0 500 Internal Server Error'); + $reqWritePermissions = false; require_once 'www-header.php'; @@ -13,6 +15,132 @@ if (!$GLOBALS['phorkie']['cfg']['setupcheck']) { exit(1); } -header('Content-type: text/plain'); -echo "All fine\n"; +$messages = SetupCheck::run(); +$errors = 0; +foreach ($messages as $arMessage) { + list($type, $message) = $arMessage; + $type == 'error' && ++$errors; +} +if ($errors == 0) { + header('HTTP/1.0 200 OK'); +} +header('Content-type: text/html'); + +if ($errors == 0) { + $messages[] = array('ok', 'All fine'); +} + +$out = << + + + + phorkie setup check + + + + + + + + + +
+
+
+ + +

Check results

+ +
    +HTM; +$stateMap = array( + 'ok' => 'success', + 'info' => 'info', + 'error' => 'danger' +); +foreach ($messages as $arMessage) { + list($type, $message) = $arMessage; + $out .= '
  • '; + $out .= htmlspecialchars($message); + $out .= '
  • ' . "\n"; +} +$out .= << +HTM; + +if (array_sum($GLOBALS['phorkie']['cfgfiles']) == 0) { + //no config file loaded + reset($GLOBALS['phorkie']['cfgfiles']); + list($cfgFilePath, ) = each($GLOBALS['phorkie']['cfgfiles']); + + $cfgFilePath = Tools::foldPath($cfgFilePath); + $cfgFileTemplate = htmlspecialchars( + file_get_contents(__DIR__ . '/../data/config.php.dist') + ); + $cfgFileLines = count(explode("\n", $cfgFileTemplate)); + + $out .= <<Configuration file +

    + Phorkie did not find a configuration file. + Please create one at +

    +
    $cfgFilePath
    +

    + from the following template: +

    + +

    + Remove the leading // from a line if you want to adjust it. +

    +HTM; +} + +$out .= << + back to the index +

    +
+
+
+ + + + + +HTM; +echo $out; ?>