forked from PeeHaa/OpCacheGUI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
routes.php
75 lines (65 loc) · 2.72 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
<?php
if ($user->requiresLogin()) {
$router->get('', function() use ($htmlTemplate, $csrfToken) {
return $htmlTemplate->render('login.phtml', [
'csrfToken' => $csrfToken,
'username' => null,
'login' => true,
'title' => 'Login',
]);
});
$router->post('', function() use ($htmlTemplate, $csrfToken, $request, $user) {
if ($csrfToken->validate($request->post('csrfToken')) && $user->login($request->post('username'), $request->post('password'), $request->getIp())) {
header('Location: ' . $request->getUrl());
exit;
}
return $htmlTemplate->render('login.phtml', [
'csrfToken' => $csrfToken,
'username' => $request->post('username'),
'login' => true,
]);
});
return;
}
$router->get('', function() use ($htmlTemplate, $byteFormatter, $csrfToken, $translator) {
return $htmlTemplate->render('status.phtml', [
'byteFormatter' => $byteFormatter,
'csrfToken' => $csrfToken,
'active' => 'status',
'title' => $translator->translate('stats.title'),
]);
});
$router->get('configuration', function() use ($htmlTemplate, $byteFormatter, $translator) {
return $htmlTemplate->render('configuration.phtml', [
'byteFormatter' => $byteFormatter,
'active' => 'config',
'title' => $translator->translate('config.title'),
]);
});
$router->get('cached-scripts', function() use ($htmlTemplate, $byteFormatter, $csrfToken, $translator) {
return $htmlTemplate->render('cached.phtml', [
'byteFormatter' => $byteFormatter,
'csrfToken' => $csrfToken,
'active' => 'cached',
'title' => $translator->translate('scripts.title'),
]);
});
$router->get('graphs', function() use ($htmlTemplate, $byteFormatter, $translator) {
return $htmlTemplate->render('graphs.phtml', [
'byteFormatter' => $byteFormatter,
'active' => 'graphs',
'title' => $translator->translate('graph.title'),
]);
});
$router->post('reset', function() use ($jsonTemplate, $csrfToken, $request) {
return $jsonTemplate->render('reset.pjson', [
'csrfToken' => $csrfToken,
'result' => ($csrfToken->validate($request->post('csrfToken')) && opcache_reset()) ? 'success' : 'failed',
]);
});
$router->post('invalidate', function() use ($jsonTemplate, $csrfToken, $request) {
return $jsonTemplate->render('invalidate.pjson', [
'csrfToken' => $csrfToken,
'result' => ($csrfToken->validate($request->post('csrfToken')) && opcache_invalidate($request->post('key'), true)) ? 'success' : 'failed',
]);
});