-
Notifications
You must be signed in to change notification settings - Fork 1
/
routes.php
144 lines (102 loc) · 3.35 KB
/
routes.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<?php
/*
* Routings, on Error
*/
// 404 - File Not Found
$app->notFound(function () use ($app) {
$app->render("404.html");
});
// Any Error ...
$app->error(function (\Exception $e) use ($app) {
include("views/error.php");
});
/*
* Default routings
*/
// Homepage
$app->get('/(page/:currentPage)', function ($currentPage = 0) use ($app, $db) {
if (empty($currentPage) || !is_numeric($currentPage)) {
$currentPage = 1;
} else {
$currentPage = intval($currentPage);
}
include("views/index.php");
});
// Show certain battle report
$app->get('/show/:battleReportID(/:battleReportDetail)', function($battleReportID, $battleReportDetail = "") use ($app) {
include("views/show.php");
});
// Creating new battle reports
$app->map('/create', function () use ($app) {
include("views/create.php");
})->via('GET', 'POST');
// Editing existing (and newly created) battle reports
$app->map('/edit/:battleReportID(/:editAction)', function ($battleReportID, $battleReportEditAction = "") use ($app, $basePath) {
include("views/edit.php");
})->via('GET', 'POST');
// Log in
$app->map('/login', function () use ($app) {
include("views/login.php");
})->via('GET', 'POST');
if (BR_LOGINMETHOD_EVE_SSO === true) {
$app->get('/login/eve-sso', function () use ($app) {
include("views/login-methods/eve-sso.php");
});
$app->get('/login/eve-sso-auth', function () use ($app) {
include("views/login-methods/eve-sso-auth.php");
});
}
// Log out
$app->get('/logout', function () use ($app, $basePath, $theme, $BR_DEBUGMODE) {
include("views/logout.php");
});
// Info pages
$app->get('/info(/:page)', function ($page = "about") use ($app, $basePath, $theme) {
include("views/info.php");
});
// Autocomplete Suggestions:
$app->group('/autocomplete', function () use ($app, $db) {
// Fetching solar systems for input suggestions
$app->post('/solarSystems', function () use ($app, $db) {
include("views/autocomplete/solarSystems.php");
});
// Fetching ship names for input suggestions
$app->post('/shipNames', function () use ($app, $db) {
include("views/autocomplete/shipNames.php");
});
// Fetching known corporation and alliance names
$app->post('/corpNames', function () use ($app, $db) {
include("views/autocomplete/corpNames.php");
});
$app->post('/alliNames', function () use ($app, $db) {
include("views/autocomplete/alliNames.php");
});
// For associating a battle report's combatant
// to anything, e.g. pov-footage
$app->post('/combatants/:battleReportID', function ($battleReportID) use ($app, $db) {
include("views/autocomplete/combatants.php");
});
});
// Pages only for logged in users
if (User::isLoggedIn() && BR_COMMENTS_ENABLED === true) {
$app->post('/comment/:battleReportID', function ($battleReportID) use ($app, $db) {
include("views/comment.php");
});
if (User::isAdmin()) {
$app->get('/comment/delete/:commentID', function ($commentID) use ($app, $db) {
include("views/admin/deleteComment.php");
});
}
}
// Admin only pages
if (User::isAdmin()) {
$app->get('/admin(/:adminAction)', function ($adminAction = "") use ($app, $db, $basePath) {
include("views/admin/admin.php");
});
}
// Slack.com Integration
if (BR_API_SLACK_ENABLED === true && BR_API_SLACK_TOKEN !== '') {
$app->map('/api/slack', function () use ($app, $basePath) {
include("api/slack.php");
})->via('GET', 'POST');
}