3 * Check if everything is setup correctly
9 * @author Christian Weiske <cweiske@cweiske.de>
10 * @copyright 2014 Christian Weiske
11 * @license http://www.gnu.org/licenses/agpl.html GNU AGPL v3
12 * @link http://cweiske.de/phancap.htm
15 header('HTTP/1.0 500 Internal Server Error');
17 if (file_exists(__DIR__ . '/../src/phancap/Autoloader.php')) {
18 include_once __DIR__ . '/../src/phancap/Autoloader.php';
19 Autoloader::register();
21 include_once 'phancap/Autoloader.php';
26 $config = new Config();
29 if ($config->disableSetup) {
30 header('HTTP/1.0 403 Forbidden');
31 header('Content-type: text/plain');
32 echo "Setup check is disabled.\n";
35 $messages[][] = array('ok', 'Base configuration is ok');
37 if ($config->access === true) {
38 $messages[][] = array('ok', 'Everyone may access the API');
39 } else if ($config->access === false) {
40 $messages[][] = array('err', 'API access is disabled');
42 $messages[][] = array(
44 count($config->access) . ' users may access the API'
48 foreach ($config->cfgFiles as $cfgFile) {
49 $messages[][] = array(
50 'info', 'Possible config file: ' . $cfgFile
53 if ($config->cfgFileExists) {
54 $messages[][] = array(
55 'ok', 'Configuration file loaded'
58 $messages[][] = array(
59 'info', 'No configuration file found'
62 } catch (\Exception $e) {
63 $messages[][] = array('err', $e->getMessage());
69 foreach ($adapter as $classpart) {
70 $class = '\\phancap\\Adapter_' . $classpart;
71 $adapter = new $class();
72 $adapter->setConfig($config);
73 $errors = $adapter->isAvailable();
74 if ($errors === true) {
75 $messages[][] = array(
76 'ok', 'Adapter ' . $classpart . ' is available'
79 foreach ($errors as $msg) {
80 $messages['Adapter: '. $classpart][] = array('err', $msg);
87 <html xmlns="http://www.w3.org/1999/xhtml" lang="en">
89 <title>phancap setup check</title>
90 <link rel="stylesheet" href="css/bootstrap.min.css"/>
91 <link rel="stylesheet" href="css/bootstrap-theme.min.css"/>
92 <link rel="stylesheet" href="css/phancap.css"/>
93 <meta name="viewport" content="width=device-width, initial-scale=1"/>
94 <style type="text/css">
98 display: inline-block;
110 background-color: red;
121 <div class="container">
123 <div class="col-md-2"></div>
124 <div class="col-md-8">
126 <div class="page-header">
127 <h1>phancap setup check</h1>
130 <ul class="list-group">
137 foreach ($messages as $key => $messages) {
138 if (!is_numeric($key)) {
139 $out .= '<li class="list-group-item">' . htmlspecialchars($key)
140 . '<ul class="list-group">';
142 foreach ($messages as $data) {
143 list($state, $message) = $data;
144 $out .= '<li class="list-group-item list-group-item-'
145 . $stateMap[$state] . '">';
146 $out .= htmlspecialchars($message);
147 $out .= '</li>' . "\n";
149 if (!is_numeric($key)) {
150 $out .= '</ul></li>' . "\n";
156 <a href="./">back</a> to the index
162 <div class="container footer">
163 <a href="http://cweiske.de/phancap.htm">phancap</a>,
164 the self-hosted website screenshot service is available under the
165 <a href="http://www.gnu.org/licenses/agpl-3.0.html">
166 <abbr title="GNU Affero General Public License">AGPL</abbr></a>.
173 header('HTTP/1.0 200 OK');