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);
86 <?xml version="1.0" encoding="utf-8"?>
87 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
88 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
90 <title>phancap setup check</title>
91 <link rel="stylesheet" href="css/bootstrap.min.css"/>
92 <link rel="stylesheet" href="css/bootstrap-theme.min.css"/>
93 <link rel="stylesheet" href="css/phancap.css"/>
94 <meta name="viewport" content="width=device-width, initial-scale=1"/>
95 <style type="text/css">
99 display: inline-block;
111 background-color: red;
122 <div class="container">
124 <div class="col-md-2"></div>
125 <div class="col-md-8">
127 <div class="page-header">
128 <h1>phancap setup check</h1>
131 <ul class="list-group">
138 foreach ($messages as $key => $messages) {
139 if (!is_numeric($key)) {
140 $out .= '<li class="list-group-item">' . htmlspecialchars($key)
141 . '<ul class="list-group">';
143 foreach ($messages as $data) {
144 list($state, $message) = $data;
145 $out .= '<li class="list-group-item list-group-item-'
146 . $stateMap[$state] . '">';
147 $out .= htmlspecialchars($message);
148 $out .= '</li>' . "\n";
150 if (!is_numeric($key)) {
151 $out .= '</ul></li>' . "\n";
157 <a href="./">back</a> to the index
163 <div class="container footer">
164 <a href="http://cweiske.de/phancap.htm">phancap</a>,
165 the self-hosted website screenshot service is available under the
166 <a href="http://www.gnu.org/licenses/agpl-3.0.html">
167 <abbr title="GNU Affero General Public License">AGPL</abbr></a>.
174 header('HTTP/1.0 200 OK');