<?php
-namespace phancap;
/**
- * Check if everything is setup
+ * Check if everything is setup correctly
+ *
+ * PHP version 5
+ *
+ * @category Tools
+ * @package Phancap
+ * @author Christian Weiske <cweiske@cweiske.de>
+ * @copyright 2014 Christian Weiske
+ * @license http://www.gnu.org/licenses/agpl.html GNU AGPL v3
+ * @link http://cweiske.de/phancap.htm
*/
+namespace phancap;
header('HTTP/1.0 500 Internal Server Error');
if (file_exists(__DIR__ . '/../src/phancap/Autoloader.php')) {
$config = new Config();
try {
$config->load();
- $messages[][] = array('ok', 'Configuration check ok');
+ if ($config->disableSetup) {
+ header('HTTP/1.0 403 Forbidden');
+ header('Content-type: text/plain');
+ echo "Setup check is disabled.\n";
+ exit(1);
+ }
+ $messages[][] = array('ok', 'Base configuration is ok');
+
+ if ($config->access === true) {
+ $messages[][] = array('ok', 'Everyone may access the API');
+ } else if ($config->access === false) {
+ $messages[][] = array('err', 'API access is disabled');
+ } else {
+ $messages[][] = array(
+ 'ok',
+ count($config->access) . ' users may access the API'
+ );
+ }
+
+ foreach ($config->cfgFiles as $cfgFile) {
+ $messages[][] = array(
+ 'info', 'Possible config file: ' . $cfgFile
+ );
+ }
+ if ($config->cfgFileExists) {
+ $messages[][] = array(
+ 'ok', 'Configuration file loaded'
+ );
+ } else {
+ $messages[][] = array(
+ 'info', 'No configuration file found'
+ );
+ }
} catch (\Exception $e) {
$messages[][] = array('err', $e->getMessage());
}
}
}
-header('HTTP/1.0 200 OK');
-
$out = <<<HTM
<?xml version="1.0" encoding="utf-8"?>
-<html>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>phancap setup check</title>
+ <link rel="stylesheet" href="css/bootstrap.min.css"/>
+ <link rel="stylesheet" href="css/bootstrap-theme.min.css"/>
+ <link rel="stylesheet" href="css/phancap.css"/>
+ <meta name="viewport" content="width=device-width, initial-scale=1"/>
<style type="text/css">
+ /*
+ li:before {
+ text-align: center;
+ display: inline-block;
+ width: 1em;
+ padding: 0 0.5ex;
+ margin-right: 0.5ex;
+ }
li.ok:before {
content: '✔';
color: green;
- padding: 0 0.5ex;
- margin-right: 1ex;
}
li.err:before {
content: "✘";
color: white;
background-color: red;
- padding: 0 0.5ex;
- margin-right: 0.5ex;
}
+ li.info:before {
+ content: "i";
+ font-weight: bold;
+ color: blue;
+ }
+ */
</style>
</head>
<body>
- <h1>phancap setup check</h1>
-<ul>
+ <div class="container">
+ <div class="row">
+ <div class="col-md-2"></div>
+ <div class="col-md-8">
+
+ <div class="page-header">
+ <h1>phancap setup check</h1>
+ </div>
+
+ <ul class="list-group">
HTM;
+$stateMap = array(
+ 'ok' => 'success',
+ 'info' => 'info',
+ 'err' => 'danger'
+);
foreach ($messages as $key => $messages) {
if (!is_numeric($key)) {
- $out .= '<li>' . htmlspecialchars($key)
- . '<ul>';
+ $out .= '<li class="list-group-item">' . htmlspecialchars($key)
+ . '<ul class="list-group">';
}
foreach ($messages as $data) {
list($state, $message) = $data;
- $out .= '<li class="' . $state . '">';
+ $out .= '<li class="list-group-item list-group-item-'
+ . $stateMap[$state] . '">';
$out .= htmlspecialchars($message);
$out .= '</li>' . "\n";
}
}
}
$out .= <<<HTM
- </ul>
- <p>
- <a href="./">back</a> to the index
- </p>
+ </ul>
+ <p>
+ <a href="./">back</a> to the index
+ </p>
+ </div>
+ </div>
+ </div>
+
+ <div class="container footer">
+ <a href="http://cweiske.de/phancap.htm">phancap</a>,
+ the self-hosted website screenshot service is available under the
+ <a href="http://www.gnu.org/licenses/agpl-3.0.html">
+ <abbr title="GNU Affero General Public License">AGPL</abbr></a>.
+ </div>
+
</body>
</html>
HTM;
+
+header('HTTP/1.0 200 OK');
echo $out;
?>