-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
121 lines (101 loc) · 4.58 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
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
<?php
/**
* @package KX
**/
declare(strict_types=1);
require __DIR__ . '/vendor/autoload.php';
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
ini_set('log_errors', 'On');
ini_set('error_log', KX\Core\Helper::path('app/Storage'));
error_reporting(E_ALL);
use KX\Core\Request;
use KX\Core\Response;
define('KX_VERSION', 'v1.2.0');
try {
$app = (new KX\Core\Factory)->setup();
// $app->response->setLayout('layout'); // set global layout
// $app->setLayout('layout');
/**
* Custom error handler
**/
$app->setCustomErrorHandler(function (Request $request, Response $response, $errNo, string $errMsg, string $file, int $line) {
$response->setStatus(500);
$response->setBody('<pre>Error: ' . $errMsg . ' in ' . $file . ' on line ' . $line . '</pre>');
$response->send();
});
/**
* Set defaults
**/
$app->setDefaultViewFolder('basic');
// $app->setDefaultViewLayout('layout');
/*
$app->setErrorPageContents([
'404' => ['']
]);*/
$app->setMaintenanceMode([
'/auth/login',
], 'dashboard.settings');
/**
* Single route
**/
$app->route(['GET'], '/', 'App@index', ['Test@run']);
/**
* Route group
**/
$app->routeGroup([['POST', 'GET'], '/auth', 'User@account', 'Auth@isLogged'], [
[['POST', 'GET'], '/register', 'User@register', 'Auth@isNotLogged'],
[['POST', 'GET'], '/verify-account', 'User@verifyAccount'],
[['POST', 'GET'], '/login', 'User@login', 'Auth@isNotLogged'],
[['POST', 'GET'], '/recovery', 'User@recovery', 'Auth@isNotLogged'],
[['POST', 'GET'], '/notifications', 'User@notifications', 'Auth@isLogged'],
[['POST', 'GET'], '/sessions', 'User@sessions', 'Auth@isLogged'],
[['POST', 'GET'], '/logout', 'User@logout', 'Auth@isLogged'],
[['POST', 'GET'], '/logout/:type', 'User@logout', 'Auth@isLogged'],
[['POST'], '/heartbeat', 'User@heartbeat', 'Auth@isLogged'],
[['POST'], '/notifications/:action/:id', 'User@notificationAction', 'Auth@isLogged'],
]);
$app->routeGroup(['GET', '/dashboard', 'Panel@dashboard', 'Auth@isAuthorized'], [
[['POST'], '/data/:table', 'Panel@tableData', 'Auth@isAuthorized'],
[['POST', 'GET'], '/settings', 'Panel@settings', 'Auth@isAuthorized'],
// Users
[['POST', 'GET'], '/users', 'Panel@users', 'Auth@isAuthorized'],
[['POST'], '/users/add', 'Panel@userAdd', 'Auth@isAuthorized'],
[['POST', 'GET'], '/users/edit/:id', 'Panel@userEdit', 'Auth@isAuthorized'],
[['POST'], '/users/delete/:id', 'Panel@userDelete', 'Auth@isAuthorized'],
// User Roles
[['POST', 'GET'], '/user-roles', 'Panel@userRoles', 'Auth@isAuthorized'],
[['POST'], '/user-roles/add', 'Panel@userRoleAdd', 'Auth@isAuthorized'],
[['POST', 'GET'], '/user-roles/edit/:id', 'Panel@userRoleEdit', 'Auth@isAuthorized'],
[['POST'], '/user-roles/delete/:id', 'Panel@userRoleDelete', 'Auth@isAuthorized'],
// Sessions
[['POST', 'GET'], '/sessions', 'Panel@sessions', 'Auth@isAuthorized'],
[['POST'], '/sessions/delete/:id', 'Panel@sessionDelete', 'Auth@isAuthorized'],
// Modules
[['POST', 'GET'], '/modules', 'Panel@modules', 'Auth@isAuthorized'],
[['POST'], '/modules/add', 'Panel@moduleAdd', 'Auth@isAuthorized'],
[['POST', 'GET'], '/modules/edit/:id', 'Panel@moduleEdit', 'Auth@isAuthorized'],
[['POST'], '/modules/delete/:id', 'Panel@moduleDelete', 'Auth@isAuthorized'],
// Widgets
[['POST', 'GET'], '/widgets', 'Panel@widgets', 'Auth@isAuthorized'],
[['POST'], '/widgets/add', 'Panel@widgetAdd', 'Auth@isAuthorized'],
[['POST', 'GET'], '/widgets/edit/:id', 'Panel@widgetEdit', 'Auth@isAuthorized'],
[['POST'], '/widgets/delete/:id', 'Panel@widgetDelete', 'Auth@isAuthorized'],
// Languages
[['POST', 'GET'], '/languages', 'Panel@languages', 'Auth@isAuthorized'],
[['POST'], '/languages/save', 'Panel@languagesSave', 'Auth@isAuthorized'],
// Logs
[['POST', 'GET'], '/logs', 'Panel@logs', 'Auth@isAuthorized'],
]);
// inital setup and app routes
$app->routeGroup(['GET', '/kalipso', 'App@setup'], [
['GET', '/setup-models', 'App@setupModels'],
['GET', '/setup-models-with-seed', 'App@setupModelsWithSeed'],
['GET', '/sync-models', 'App@syncModels'],
['GET', '/clear-storage', 'App@clearStorage'],
['GET', '/cron', 'App@cronJobs'],
]);
$app->run();
} catch (Exception $e) {
KX\Core\Exception::exceptionHandler($e);
}