-
Notifications
You must be signed in to change notification settings - Fork 16
/
index.php
43 lines (36 loc) · 1.56 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
<?php
require_once __DIR__ . '/cfg.php';
$router = new Phroute\Phroute\RouteCollector();
/* Game Routing
catch http://phparcade.dev/game/2741/Sample.html */
$router->any(['/game/{id:i}/{gameName:.*}', 'game'], function ($id, $gameName) use (&$foundMatch) {
$game = PHPArcade\Games::getGame($id);
$cleanGameName = PHPArcade\Core::getCleanURL($game['name']) . '.html';
if ($cleanGameName != urldecode($gameName)) {
header('Location: /game/'.$id.'/'.urlencode($cleanGameName));
return false;
} else {
$_GET['params'] = 'game/'.$id.'/'. PHPArcade\Core::getCleanURL($game['name']);
}
});
/* User Profile Routing
catch http://phparcade.dev/profile/view/1/Username.html */
$router->any(['/profile/view/{id:i}/{userProfile:.*}', 'user'], function ($id, $userProfile) use (&$foundMatch) {
$user = PHPArcade\Users::getUserbyID($id);
$cleanUserName = PHPArcade\Core::getCleanURL($user['username']) . '.html';
if ($cleanUserName != urldecode($userProfile))
{
header('Location: /profile/view/' . $id . '/' . urlencode($cleanUserName));
return false;
} else
{
$_GET['params'] = 'profile/view/' . $id . '/' . PHPArcade\Core::getCleanURL($user['username']);
}
});
/* catch all routes not caught earlier */
$router->any('{route:.*}', function () {
});
$response = (new Phroute\Phroute\Dispatcher($router->getData()))->dispatch($_SERVER['REQUEST_METHOD'], $_SERVER['REQUEST_URI']);
require_once(INST_DIR . 'includes/first.php');
/** @noinspection PhpIncludeInspection */
require_once(SITE_THEME_PATH);