This repository was archived by the owner on Jun 24, 2021. It is now read-only.
generated from shgysk8zer0/blank-repo
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathautoloader.php
More file actions
52 lines (42 loc) · 1.25 KB
/
autoloader.php
File metadata and controls
52 lines (42 loc) · 1.25 KB
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
<?php
namespace autoloader;
require 'vendor/autoload.php';
use const \Consts\{
AUTOLOADER,
AUTOLOAD_EXTS,
TIMEZONE,
INCLUDE_PATH,
ERROR_HANDLER,
EXCEPTION_HANDLER,
HMAC_FILE,
CREDS_FILE,
CSP_ALLOWED_HEADERS,
HOST,
TOKEN_EXPIRES,
};
use \shgysk8zer0\PHPAPI\{API, User, PDO, UploadFile};
use \shgysk8zer0\PHPAPI\Schema\{Thing};
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'shims.php');
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'consts.php');
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'functions.php');
try {
set_include_path(join(INCLUDE_PATH, PATH_SEPARATOR) . PATH_SEPARATOR . get_include_path());
spl_autoload_register(AUTOLOADER);
spl_autoload_extensions(join(AUTOLOAD_EXTS, ','));
set_error_handler(ERROR_HANDLER);
set_exception_handler(EXCEPTION_HANDLER);
date_default_timezone_set(TIMEZONE);
if (! file_exists(HMAC_FILE)) {
(new \shgysk8zer0\PHPAPI\RandomString(30, true, true, true, true))->saveAs(HMAC_FILE);
}
User::setKey(file_get_contents(HMAC_FILE));
User::setExpires(TOKEN_EXPIRES['value'], TOKEN_EXPIRES['units']);
UploadFile::setHost(HOST);
if (FILE_EXISTS(CREDS_FILE)) {
PDO::setCredsFile(CREDS_FILE);
}
// Thing::setPDO(PDO::load());
API::allowHeaders(...CSP_ALLOWED_HEADERS);
} catch (\Throwable $e) {
print_r($e);
}