talk about features
[phancap.git] / www / setup.php
index cbba4dd384bdac94895aa83ff6041015d48ac85e..3107769fef44b5b85bece1e5b374675c4a77cf87 100644 (file)
@@ -1,8 +1,17 @@
 <?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')) {
@@ -17,6 +26,12 @@ $messages = array();
 $config = new Config();
 try {
     $config->load();
+    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) {
@@ -29,6 +44,21 @@ try {
             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());
 }
@@ -54,37 +84,66 @@ foreach ($adapter as $classpart) {
 
 $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: 0.5ex;
     }
     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";
     }
@@ -93,10 +152,13 @@ foreach ($messages as $key => $messages) {
     }
 }
 $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>
  </body>
 </html>
 HTM;