index that shows options and setup check
[phancap.git] / www / index.php
1 <?php
2 namespace phancap;
3 /**
4  * Check if everything is setup
5  */
6 header('HTTP/1.0 500 Internal Server Error');
7
8 if (file_exists(__DIR__ . '/../src/phancap/Autoloader.php')) {
9     include_once __DIR__ . '/../src/phancap/Autoloader.php';
10     Autoloader::register();
11 } else {
12     include_once 'phancap/Autoloader.php';
13 }
14 header('HTTP/1.0 200 OK');
15 ?>
16 <?xml version="1.0" encoding="utf-8"?>
17 <html>
18  <head>
19   <title>phancap</title>
20  </head>
21  <body>
22   <h1>phancap</h1>
23   <p>
24    Web service to create website screenshots.
25   </p>
26
27   <h2>API</h2>
28   <p>
29    The API is accessible at <a href="get.php">get.php</a>.
30   </p>
31   <table border="1">
32    <caption>Available URL parameters</caption>
33    <thead>
34     <tr>
35      <th>Name</th>
36      <th>Description</th>
37      <th>Type</th>
38      <th>Default</th>
39     </tr>
40    </thead>
41    <tbody>
42 <?php
43 $options = new Options();
44 $config = new Config();
45 try {
46     $config->load();
47     $options->setConfig($config);
48 } catch (\Exception $e) {}
49
50 foreach ($options->options as $name => $option) {
51     echo '<tr>'
52         . '<td><tt>' . $name . '</tt></td>'
53         . '<td>' . htmlspecialchars($option['title']) . '</td>'
54         . '<td>'
55         . (
56             is_array($option['type'])
57             ? ('One of: <tt>' . implode('</tt>, <tt>', $option['type']) . '</tt>')
58             : str_replace('skip', '&#160;', $option['type'])
59         )
60         . '</td>'
61         . '<td>&#160;<tt>' . $option['default'] . '</tt></td>'
62         . '</tr>';
63 }
64 ?>
65    </tbody>
66   </table>
67
68
69   <h2>Tools</h2>
70   <ul>
71    <li>
72     <a href="setup.php">Setup check</a> to test if everything is ok
73    </li>
74   </ul>
75  </body>
76 </html>