summaryrefslogtreecommitdiff
path: root/tdd/tdd-protocol.php
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2018-11-15 01:30:14 +0100
committeremkael <emkael@tlen.pl>2018-11-15 01:30:14 +0100
commitd1a50c119db7356671af310cf04a046e2be2fc90 (patch)
tree9c8e86b5d0cbed4bce1f0214d17def5685ae20a3 /tdd/tdd-protocol.php
parent4d2495bc8add202c39b8dbf8a4ea059120984999 (diff)
Documentation updated
Diffstat (limited to 'tdd/tdd-protocol.php')
-rw-r--r--tdd/tdd-protocol.php6
1 files changed, 5 insertions, 1 deletions
diff --git a/tdd/tdd-protocol.php b/tdd/tdd-protocol.php
index 7d9abc2..a7ab513 100644
--- a/tdd/tdd-protocol.php
+++ b/tdd/tdd-protocol.php
@@ -4,11 +4,13 @@ require_once('tdd-bootstrap.php');
// parsing URI parts from full request string
$uri = explode('b-', basename($_SERVER['REQUEST_URI']));
+// if "b-" is not found in the string, it's a direct call, all mod_rewrite requests do have it
if (count($uri) < 2) {
die('This script cannot be called directly!');
}
-
+// last part of URI is board number
$board = (int)(array_pop($uri));
+// the rest is compiled back to separate prefix from round later on
$roundPrefix = implode('b-', $uri);
try {
@@ -19,6 +21,7 @@ try {
$html_filename = $protocol->get_filename();
foreach ($database->getDB() as $prefix => $rounds) {
foreach ($rounds as $round => $boards) {
+ // matching each prefix and round in DB to URI
if ($prefix . $round === $roundPrefix) {
if (isset($boards[$board])) {
foreach($boards[$board] as $table => $deal) {
@@ -30,6 +33,7 @@ try {
}
}
}
+ // here's the fallback
readfile($html_filename);
} catch (Exception $e) {
header('HTTP/1.0 404 Not Found');