-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.php
53 lines (44 loc) · 1.33 KB
/
setup.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
<?php
// Define constants
define('NLM_DIR', dirname(__FILE__));
define('NLM_CONDIF_DIR', NLM_DIR . '/config');
// Load required vendors
$vendors = NLM_DIR . '/vendor/autoload.php';
if (!file_exists($vendors)) {
echo "Missing required dependencies: Install composer, and run the command below\n";
echo "Command: cd ".NLM_DIR."; composer install\n";
exit(1);
}
require_once $vendors;
// Include Config
/* @var $config array */
$config = array();
$config['database'] = array();
$config_file = NLM_CONDIF_DIR . '/config.php';
if (!file_exists($config_file)) {
$config_dist = NLM_CONDIF_DIR . '/config.dist.php';
echo "Config is missing: Create $config_file file from $config_dist and set the required parameters.\n";
echo "Command: cp $config_dist $config_file \n";
exit(1);
}
require_once $config_file;
// Include classes
foreach (($classes = glob(NLM_DIR . '/classes/*.php')) as $file) {
require_once $file;
}
// Initialize config
Config::initialize($config);
// Touch log files
foreach ($config['logs'] as $type => $logfile) {
if (!file_exists($logfile)) {
file_put_contents($logfile, date('r'));
}
}
if (($file = Config::get('logs.errors')) && is_file($file)) {
ini_set('log_errors', 1);
ini_set('error_log', $file);
}
if ($timezone = Config::get('timezone')) {
date_default_timezone_set($timezone);
}
mb_internal_encoding('UTF-8');