blob: 7d9abc2f15c1841631c139dab60b94fc33596aa9 (
plain)
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
|
<?php
require_once('tdd-bootstrap.php');
// parsing URI parts from full request string
$uri = explode('b-', basename($_SERVER['REQUEST_URI']));
if (count($uri) < 2) {
die('This script cannot be called directly!');
}
$board = (int)(array_pop($uri));
$roundPrefix = implode('b-', $uri);
try {
$database = new BoardDB();
// GET parameters pre-parsed by mod_rewrite are used for HTML fallback
// in case {$prefix}{$round} combo is not matched against board DB
$protocol = new Protocol($_GET['prefix'], $_GET['round'], $board);
$html_filename = $protocol->get_filename();
foreach ($database->getDB() as $prefix => $rounds) {
foreach ($rounds as $round => $boards) {
if ($prefix . $round === $roundPrefix) {
if (isset($boards[$board])) {
foreach($boards[$board] as $table => $deal) {
$protocol->set_deal($table, $deal);
}
echo $protocol->output();
exit(0);
}
}
}
}
readfile($html_filename);
} catch (Exception $e) {
header('HTTP/1.0 404 Not Found');
die();
}
|