-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootstrap.php
More file actions
65 lines (54 loc) · 1.47 KB
/
bootstrap.php
File metadata and controls
65 lines (54 loc) · 1.47 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
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
use SphereCube\DB;
use SphereCube\Cache;
use SphereCube\Plugins;
// Define COREPATH
define('COREPATH', __DIR__);
/**
* Build path to folder
* @param string $_
* @return string
*/
function buildpath(): string
{
return implode(DIRECTORY_SEPARATOR, func_get_args());
}
/**
* Generate UUID
* @return string
*/
function gen_uuid()
{
return sprintf(
'%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
mt_rand(0, 0xffff),
mt_rand(0, 0xffff),
mt_rand(0, 0xffff),
mt_rand(0, 0x0fff) | 0x4000,
mt_rand(0, 0x3fff) | 0x8000,
mt_rand(0, 0xffff),
mt_rand(0, 0xffff),
mt_rand(0, 0xffff)
);
}
// check autoload.php and config.php
if (!file_exists(buildpath(COREPATH, 'vendor', 'autoload.php'))) {
die('run <code>composer install</code>');
}
if (!file_exists(buildpath(COREPATH, 'config.php'))) {
die('<code>config.php</code> not exist');
}
// Require Composer autoload
require buildpath(COREPATH, 'vendor', 'autoload.php');
// Require config
require buildpath(COREPATH, 'config.php');
if (!file_exists(buildpath(COREPATH, 'version'))) {
file_put_contents(buildpath(COREPATH, 'version'), strval(time()));
}
define('STATICVERSION', file_get_contents(buildpath(COREPATH, 'version')));
// Initilize DB
new DB(DB_CONNECT['base'], DB_CONNECT['host'], DB_CONNECT['user'], DB_CONNECT['pass'], DB_CONNECT['port'], DB_CONNECT['scheme']);
// Initilize Cache
new Cache();
// Initilize Plugins
new Plugins(PLUGIN_CACHE_TTL);