-
Notifications
You must be signed in to change notification settings - Fork 34
/
init.php
64 lines (56 loc) · 2.16 KB
/
init.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
<?php
/**
* dmarc-srg - A php parser, viewer and summary report generator for incoming DMARC reports.
* Copyright (C) 2020 Aleksey Andreev (liuch)
*
* Available at:
* https://github.com/liuch/dmarc-srg
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation, either version 3 of the License.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
$va = __DIR__ . '/vendor/autoload.php';
if (is_readable($va)) {
require_once($va);
}
spl_autoload_register(function ($class) {
$prefix = 'Liuch\\DmarcSrg\\';
$prefix_len = 15;
$base_dir = __DIR__ . '/classes/';
if (strncmp($prefix, $class, $prefix_len) === 0) {
$relative_class = substr($class, $prefix_len);
$file = $base_dir . str_replace('\\', '/', $relative_class) . '.php';
if (file_exists($file)) {
require_once($file);
}
}
});
date_default_timezone_set('GMT');
$core = new Liuch\DmarcSrg\Core([
'auth' => [ 'Liuch\DmarcSrg\Auth' ],
'admin' => [ 'Liuch\DmarcSrg\Admin' ],
'ehandler' => [ 'Liuch\DmarcSrg\ErrorHandler' ],
'config' => [ 'Liuch\DmarcSrg\Config', [ __DIR__ . '/config/conf.php' ] ],
'status' => [ 'Liuch\DmarcSrg\Status' ],
'database' => [ 'Liuch\DmarcSrg\Database\DatabaseController' ],
'template' => __DIR__ . '/template.html'
]);
$core->errorHandler()->setLogger(new Liuch\DmarcSrg\Log\PhpSystemLogger());
set_exception_handler(function ($e) {
Liuch\DmarcSrg\Core::instance()->errorHandler()->handleException($e);
});
set_error_handler(function (int $severity, string $message, string $file, int $line) {
if (error_reporting() === 0) {
return false;
}
throw new \ErrorException($message, -1, $severity, $file, $line);
});