-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
48 lines (39 loc) · 1.43 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
declare(strict_types = 1);
use Attogram\Router\Router;
require '../../vendor/autoload.php';
$router = new Router();
$title = 'Timezone String Control - Attogram Router Examples';
$homeLink = '<a href="' . $router->getHome() . '../">Attogram Router</a>'
. ' - <a href="' . $router->getHome() . '">' . $title . '</a>';
$header = '<html lang="en"><head><title>' . $title . '</title>'
. '<style>a { text-decoration:none; }</style>'
. '</head><body>' . $homeLink . '<hr />';
$footer = '<footer><hr />' . $homeLink . '</footer></body></html>';
$router->allow('/', 'timezones');
$router->allow('?', 'timezones');
$router->allow('?/?', 'timezones');
$router->allow('?/?/?', 'timezones');
if ($router->match() !== 'timezones') {
header('HTTP/1.0 404 Not Found');
die("$header <h1>Page Not Found</h1> $footer");
}
$timeZone = 'UTC';
if (!empty($router->getVar(0))) {
$timeZone = $router->getVar(0);
}
if (!empty($router->getVar(1))) {
$timeZone .= '/' . $router->getVar(1);
}
if (!empty($router->getVar(2))) {
$timeZone .= '/' . $router->getVar(2);
}
if (!@date_default_timezone_set($timeZone)) {
header('HTTP/1.0 404 Not Found');
die("$header <h1>Timezone Not Found</h1> $footer");
}
print $header . '<h1>' . $timeZone . '<br />' . date('r') . '</h1><p>Timezones ';
foreach (timezone_identifiers_list() as $id) {
print ' - <a href="' . $router->getHome() . $id . '">' . $id . '</a>';
}
print '</p>' . $footer;