4 * Get a screenshot for a website.
6 header('HTTP/1.0 500 Internal Server Error');
8 if (file_exists(__DIR__ . '/../src/phancap/Autoloader.php')) {
9 include_once __DIR__ . '/../src/phancap/Autoloader.php';
10 Autoloader::register();
12 include_once 'phancap/Autoloader.php';
15 $config = new Config();
18 $options = new Options();
20 $options->parse($_GET);
21 } catch (\InvalidArgumentException $e) {
22 header('HTTP/1.0 400 Bad Request');
23 header('Content-type: text/plain');
24 echo $e->getMessage() . "\n";
28 $auth = new Authenticator();
30 $auth->authenticate($config);
31 } catch (\Exception $e) {
32 header('HTTP/1.0 401 Unauthorized');
33 header('Content-type: text/plain');
34 echo $e->getMessage() . "\n";
38 $rep = new Repository();
39 $rep->setConfig($config);
41 $img = $rep->getImage($options);
42 header('HTTP/1.0 302 Found');
43 header('Location: ' . $img->getUrl());
44 } catch (\Exception $e) {
45 //FIXME: handle 404s and so properly
46 header('HTTP/1.0 500 Internal Server error');
47 header('Content-type: text/plain');
48 echo $e->getMessage() . "\n";