This repository has been archived by the owner on Dec 6, 2019. It is now read-only.
/
bootstrap.inc.php
131 lines (100 loc) · 3.62 KB
/
bootstrap.inc.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<?php
/**
* phpVMS - Virtual Airline Administration Software
* Copyright (c) 2008 Nabeel Shahzad
* For more information, visit www.phpvms.net
* Forums: http://www.phpvms.net/forum
* Documentation: http://www.phpvms.net/docs
*
* phpVMS is licenced under the following license:
* Creative Commons Attribution Non-commercial Share Alike (by-nc-sa)
* View license.txt in the root, or visit http://creativecommons.org/licenses/by-nc-sa/3.0/
*
* @author Nabeel Shahzad
* @copyright Copyright (c) 2008, Nabeel Shahzad
* @link http://www.phpvms.net
* @license http://creativecommons.org/licenses/by-nc-sa/3.0/
*/
function pre_module_load() {
if (is_dir(CORE_PATH . '/local.config.php')) {
Debug::showCritical('core/local.config.php is a folder, not a file. Please delete and create as a file');
die();
}
if (!file_exists(CORE_PATH . '/local.config.php') || filesize(CORE_PATH .
'/local.config.php') == 0) {
Debug::showCritical('phpVMS has not been installed yet! Goto <a href="install/install.php">install/install.php</a> to start!');
exit;
}
SiteData::loadSiteSettings();
Auth::StartAuth();
}
function post_module_load() {
/* Misc tasks which need to get done */
/* If the setting to auto-retired pilots is on, then do that
and only check every 24 hours
*/
if (Config::Get('USE_CRON') == false) {
if (Config::Get('PILOT_AUTO_RETIRE') == true) {
$within_timelimit = CronData::check_hoursdiff('find_retired_pilots', '24');
if ($within_timelimit == false) {
PilotData::findRetiredPilots();
CronData::set_lastupdate('find_retired_pilots');
}
}
if (Config::Get('CLOSE_BIDS_AFTER_EXPIRE') === false) {
$within_timelimit = CronData::check_hoursdiff('check_expired_bids', '24');
if ($within_timelimit == false) {
SchedulesData::deleteExpiredBids();
CronData::set_lastupdate('check_expired_bids');
}
}
/* Expenses, make sure they're all populated */
$within_timelimit = CronData::check_hoursdiff('populate_expenses', 18);
if ($within_timelimit === false) {
FinanceData::updateAllExpenses();
CronData::set_lastupdate('populate_expenses');
}
/* And finally, clear expired sessions */
Auth::clearExpiredSessions();
}
// @TODO: Clean ACARS records older than one month
if (Config::Get('MAINTENANCE_MODE') == true && !Auth::LoggedIn() && !
PilotGroups::group_has_perm(Auth::$usergroups, FULL_ADMIN)) {
Template::Show('maintenance.tpl');
die();
}
return true;
}
function adminurl($path) {
if ($path[0] != '/') $path = '/' . $path;
return SITE_URL . '/admin/index.php' . $path;
}
function url($path) {
if ($path[0] != '/') $path = '/' . $path;
if (Config::Get('URL_REWRITE') == true) {
return SITE_URL . $path;
}
return SITE_URL . '/index.php' . $path;
}
function cndebug($txt) {
Debug::log($txt);
}
function adminaction($path) {
if ($path[0] != '/') $path = '/' . $path;
return SITE_URL . '/admin/action.php' . $path;
}
function actionurl($path) {
if ($path[0] != '/') $path = '/' . $path;
if (Config::Get('URL_REWRITE') == true) {
return SITE_URL . $path;
}
return SITE_URL . '/action.php' . $path;
}
function fileurl($path) {
$url = SITE_URL;
if ($path[0] != '/') $path = '/' . $path;
return $url . $path;
}
function html_url($title, $url) {
return '<a href="' . url($url) . '" >' . $title . '</a>';
}