-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
80 lines (58 loc) · 1.88 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
<?php
define('DEBUG', false);
define('READONLY', true);
define('VERSION', '0.1.2');
if (DEBUG) {
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
} else {
ini_set('display_errors', 0);
ini_set('display_startup_errors', 0);
}
include_once('dependencies/dependencies.php');
Config::init();
Router::init();
Auth::init();
Router::setMethodNotAllowed( function() {
HomeController::home();
// Response::error(405, 'method-not-allowed', 'method not allowed');
});
Router::setPathNotFound( function() {
HomeController::home();
// Response::error(404, 'not-found', 'not found');
});
Router::setSpamProtection( function($function, $matches, $path) {
call_user_func_array($function, $matches);
} );
Router::setAllowedUsers( Config::getUsers() );
Router::setBaseUrl( '' );
Router::setAuthRequired( function() {
Router::json();
Response::error(401, 'wrong-credentials', 'wrong credentials supplied');
});
Router::setAuthDisabled( function() {
Router::json();
Response::error(400, 'readonly-mode', 'readonly mode is active');
});
Router::addMulti(['/'], function() {
HomeController::home();
}, 'get', 'none', false);
Router::addMulti(['\/(.*)\/(j|s|p|g)\/(.*)', '\/(.*)\/(j|s|p|g)\/(.*)\/'], function($user, $type, $name) {
ViewerController::findImage($user, $type, $name);
}, 'get', 'none', false);
Router::addMulti(['/login', '/login/'], function() {
AuthController::login();
}, 'get,post', 'none', false);
Router::addMulti(['/logout', '/logout/'], function() {
AuthController::logout();
}, 'get', 'none', false);
Router::addMulti(['/admin', '/admin/'], function() {
AdminController::viewImages();
}, 'get', 'session', false);
Router::addMulti(['/upload', '/upload/'], function($user) {
Router::json();
UploadController::uploadImage($user);
}, 'post', 'apiKey', false);
Router::run();
?>