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);
85 if (!function_exists('idn_to_ascii')) {
86 $messages[][] = array(
87 'err', 'Function "idn_to_ascii" is not available'
90 if (\System::which('exiftool') === false) {
91 $messages[][] = array(
92 'err', '"exiftool" is not installed'
98 <html xmlns="http://www.w3.org/1999/xhtml" lang="en">
100 <title>phancap setup check</title>
101 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
102 <link rel="stylesheet" href="css/bootstrap.min.css"/>
103 <link rel="stylesheet" href="css/bootstrap-theme.min.css"/>
104 <link rel="stylesheet" href="css/phancap.css"/>
105 <meta name="viewport" content="width=device-width, initial-scale=1"/>
106 <style type="text/css">
110 display: inline-block;
122 background-color: red;
133 <div class="container">
135 <div class="col-md-2"></div>
136 <div class="col-md-8">
138 <div class="page-header">
139 <h1>phancap setup check</h1>
142 <ul class="list-group">
149 foreach ($messages as $key => $messages) {
150 if (!is_numeric($key)) {
151 $out .= '<li class="list-group-item">' . htmlspecialchars($key)
152 . '<ul class="list-group">';
154 foreach ($messages as $data) {
155 list($state, $message) = $data;
156 $out .= '<li class="list-group-item list-group-item-'
157 . $stateMap[$state] . '">';
158 $out .= htmlspecialchars($message);
159 $out .= '</li>' . "\n";
161 if (!is_numeric($key)) {
162 $out .= '</ul></li>' . "\n";
168 <a href="./">back</a> to the index
174 <div class="container footer">
175 <a href="http://cweiske.de/phancap.htm">phancap</a>,
176 the self-hosted website screenshot service is available under the
177 <a href="http://www.gnu.org/licenses/agpl-3.0.html">
178 <abbr title="GNU Affero General Public License">AGPL</abbr></a>.
185 header('HTTP/1.0 200 OK');