forked from flx5/InMaFSS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathglobal.php
165 lines (130 loc) · 5.07 KB
/
global.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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
<?php
/* =================================================================================*\
|* This file is part of InMaFSS *|
|* InMaFSS - INformation MAnagement for School Systems - Keep yourself up to date! *|
|* ############################################################################### *|
|* Copyright (C) flx5 *|
|* E-Mail: [email protected] *|
|* ############################################################################### *|
|* InMaFSS is free software; you can redistribute it and/or modify *|
|* it under the terms of the GNU Affero General Public License as published by *|
|* the Free Software Foundation; either version 3 of the License, *|
|* or (at your option) any later version. *|
|* ############################################################################### *|
|* InMaFSS 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 Affero General Public License for more details. *|
|* ############################################################################### *|
|* You should have received a copy of the GNU Affero General Public License *|
|* along with InMaFSS; if not, see http://www.gnu.org/licenses/. *|
\*================================================================================= */
define('DS', DIRECTORY_SEPARATOR);
define('CWD', dirname(__FILE__) . DS);
define('INC', CWD . "inc" . DS);
define('PLUGIN_DIR', CWD . DS . "plugins" . DS);
$www = $_SERVER['REQUEST_URI'];
$www = substr($www, 0, strrpos($www, basename(dirname(__FILE__)))).basename(dirname(__FILE__));
define('WWW', $www);
#register_shutdown_function('Shutdown');
set_error_handler('error_handler');
date_default_timezone_set('Europe/Berlin');
header('Content-Type: text/html');
if (file_exists(CWD . "install.php") && file_exists(CWD . "inc/config.php")) {
# die("ERROR: YOU HAVE TO REMOVE THE install.php BEFORE YOU WILL BE ABLE TO USE THIS!");
}
if (!file_exists(CWD . "inc/config.php") && !file_exists(CWD . "install.php")) {
die("ERROR: CONFIG AND INSTALLER NOT FOUND!");
}
if (!file_exists(CWD . "inc/config.php") && file_exists(CWD . "install.php")) {
header("Location: " . WWW . "/install.php");
exit;
}
require_once("inc/variables.php");
require_once("inc/class.config.php");
require_once("inc/core.php");
require_once("inc/sql.php");
require_once("inc/lang.php");
require_once("inc/tpl.php");
require_once("inc/update.php");
require_once("inc/plugin.php");
require_once("inc/parse.php");
core::MagicQuotesCompability();
$config = new config();
$vars = new variables(new core(), null, null, new tpl(), new Update(), new pluginManager(), false);
$vars->set("sql", SQL::GenerateInstance($config->Get("dbtype"), $config->Get("dbhost"), $config->Get("dbusr"), $config->Get("dbpass"), $config->Get("dbname")));
vars::Init($vars);
getVar("sql")->connect();
$config->LoadFromDB();
$vars->Set("lang", new lang($config->Get("lang")));
getVar("pluginManager")->Init();
getVar("update")->Init();
session_start();
if (isset($_SESSION['user']) && isset($_SESSION['timestamp'])) {
define('LOGGED_IN', true);
define('USERNAME', $_SESSION['user']);
} else {
define('LOGGED_IN', false);
define('USERNAME', 'GUEST');
}
function lang() {
return getVar("lang");
}
function filter($input) {
return getVar("core")->filter($input);
}
function dbquery($input) {
if (getVar("PLUGIN") || !getVar("sql")->IsConnected()) {
return null;
}
return getVar("sql")->DoQuery($input);
}
function config($var) {
if (getVar("PLUGIN")) {
return null;
}
global $config;
return $config->Get($var);
}
class vars {
private static $vars;
public static function Init($vars) {
self::$vars = $vars;
}
public static function getVar($var) {
return self::$vars->Get($var);
}
public static function setVar($var, $val) {
self::$vars->Set($var, $val);
}
public static function get() {
return self::$vars;
}
}
function getVar($var) {
return vars::getVar($var);
}
function setVar($var, $val) {
vars::setVar($var, $val);
}
function setPlugin($val, $actor) {
global $vars;
vars::get()->setPlugin($val, $actor);
}
function getVersion() {
include("inc/version.php");
return $version;
}
function error_handler($errno, $errstr, $errfile, $errline) {
if (error_reporting() == 0)
return true; // Ignore Messages with an @ before!
return false;
}
function Shutdown() {
$error = error_get_last();
if ($error != null) {
ob_end_clean();
core::SystemError($error['message'], ' in ' . $error['file'] . ' on line ' . $error['line']);
}
}
?>