Use HTML5 doctype
[phancap.git] / www / index.php
1 <?php
2 /**
3  * Give information about phancap 
4  *
5  * PHP version 5
6  *
7  * @category  Tools
8  * @package   Phancap
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
13  */
14 namespace phancap;
15 header('HTTP/1.0 500 Internal Server Error');
16
17 if (file_exists(__DIR__ . '/../src/phancap/Autoloader.php')) {
18     include_once __DIR__ . '/../src/phancap/Autoloader.php';
19     Autoloader::register();
20 } else {
21     include_once 'phancap/Autoloader.php';
22 }
23 header('HTTP/1.0 200 OK');
24
25 $options = new Options();
26 $config = new Config();
27 try {
28     $config->load();
29     $options->setConfig($config);
30 } catch (\Exception $e) {
31 }
32 ?>
33 <!DOCTYPE html>
34 <html xmlns="http://www.w3.org/1999/xhtml" lang="en">
35  <head>
36   <title>phancap</title>
37
38   <link rel="stylesheet" href="css/bootstrap.min.css"/>
39   <link rel="stylesheet" href="css/bootstrap-theme.min.css"/>
40   <link rel="stylesheet" href="css/phancap.css"/>
41   <meta name="viewport" content="width=device-width, initial-scale=1"/>
42  </head>
43  <body>
44   <div class="container">
45    <div class="row">
46     <div class="col-md-2"></div>
47     <div class="col-md-8">
48
49      <div class="page-header">
50       <h1>phancap</h1>
51      </div>
52
53      <div class="row">
54       <div class="col-md-6">
55        <p>
56         Web service to create website screenshots.
57        </p>
58
59       </div>
60       <div class="col-md-6">
61
62        <div class="panel panel-default">
63         <div class="panel-heading">Create screenshot</div>
64         <div class="panel-body">
65          <?php if ($config->access === false) { ?>
66           <div class="alert alert-danger">API is disabled</div>
67          <?php } else if ($config->access !== true) { ?>
68           <div class="alert alert-warning">API requires authentication</div>
69          <?php } ?>
70          <form method="get" action="./get.php" class="form-inline">
71           <div class="form-group">
72            <label for="url">URL:</label>
73            <input type="text" name="url" id="url" class="form-control"
74                   placeholder="http://example.org/" />
75           </div>
76           <button type="submit" class="btn btn-default">Go</button>
77          </form>
78         </div>
79        </div>
80
81       </div>
82      </div>
83
84
85      <h2 id="tools">Tools</h2>
86      <ul class="list-group">
87       <li class="list-group-item">
88        <a href="setup.php">Setup check</a> to test if everything is ok
89       </li>
90       <li class="list-group-item">
91        <a href="README.html">README</a>
92       </li>
93      </ul>
94
95
96      <h2 id="api">API</h2>
97      <p>
98       The API is accessible at <a href="get.php">get.php</a>.
99      </p>
100
101      <div class="panel panel-default">
102       <div class="panel-heading" style="text-align: center">
103        Available URL parameters
104       </div>
105       <table class="table table-striped table-bordered table-condensed">
106        <thead>
107         <tr>
108          <th>Name</th>
109          <th>Description</th>
110          <th>Type</th>
111          <th>Default</th>
112         </tr>
113        </thead>
114        <tbody>
115 <?php
116 foreach ($options->options as $name => $option) {
117     echo '<tr>'
118         . '<td><var>' . $name . '</var></td>'
119         . '<td>' . htmlspecialchars($option['title']) . '</td>'
120         . '<td>'
121         . (
122             is_array($option['type'])
123             ? ('One of: <kbd>' . implode('</kbd>, <kbd>', $option['type']) . '</kbd>')
124             : str_replace('skip', '&#160;', $option['type'])
125         )
126         . '</td>'
127         . '<td>&#160;<kbd>' . $option['default'] . '</kbd></td>'
128         . '</tr>';
129 }
130 ?>
131        </tbody>
132       </table>
133      </div>
134      <p>
135       Ages can be given as ISO 8601 duration specification, for example:
136      </p>
137      <dl class="dl-horizontal">
138       <dt><kbd>P1Y</kbd></dt><dd>1 year</dd>
139       <dt><kbd>P2W</kbd></dt><dd>2 weeks</dd>
140       <dt><kbd>P1D</kbd></dt><dd>1 day</dd>
141       <dt><kbd>PT4H</kbd></dt><dd>4 hours</dd>
142      </dl>
143
144     </div>
145    </div>
146   </div>
147
148   <div class="container footer">
149    <a href="http://cweiske.de/phancap.htm">phancap</a>,
150    the self-hosted website screenshot service is available under the
151    <a href="http://www.gnu.org/licenses/agpl-3.0.html">
152     <abbr title="GNU Affero General Public License">AGPL</abbr></a>.
153   </div>
154
155  </body>
156 </html>