/
index.php
executable file
·300 lines (266 loc) · 8.44 KB
/
index.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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage webinterface
* @author Adam Armstrong <adama@memetic.org>
* @copyright (C) 2006 - 2012 Adam Armstrong
*
*/
include("../includes/defaults.inc.php");
include("../config.php");
include_once("../includes/definitions.inc.php");
include("../includes/functions.php");
include("includes/functions.inc.php");
include('includes/plugins.inc.php');
Plugins::start();
// Check for install.inc.php
if (!file_exists('../config.php') && $_SERVER['PATH_INFO'] != '/install.php')
{
// no config.php does so let's redirect to the install
header('Location: /install.php');
exit;
}
$runtime_start = utime();
ob_start();
ini_set('allow_url_fopen', 0);
ini_set('display_errors', 0);
$_SERVER['PATH_INFO'] = (isset($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : $_SERVER['ORIG_PATH_INFO']);
if (strpos($_SERVER['PATH_INFO'], "debug"))
{
$debug = "1";
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
ini_set('log_errors', 1);
ini_set('error_reporting', E_ALL);
} else {
$debug = FALSE;
ini_set('display_errors', 0);
ini_set('display_startup_errors', 0);
ini_set('log_errors', 0);
ini_set('error_reporting', 0);
}
foreach ($_GET as $key=>$get_var)
{
if (strstr($key, "opt"))
{
list($name, $value) = explode("|", $get_var);
if (!isset($value)) { $value = "yes"; }
$vars[$name] = $value;
}
}
$segments = explode('/', trim($_SERVER['REQUEST_URI'], '/'));
foreach ($segments as $pos => $segment)
{
$segment = urldecode($segment);
if ($pos == "0")
{
$vars['page'] = $segment;
} else {
list($name, $value) = explode("=", $segment);
if ($value == "" || !isset($value))
{
$vars[$name] = yes;
} else {
$vars[$name] = $value;
}
}
}
foreach ($_GET as $name => $value)
{
$vars[$name] = $value;
}
foreach ($_POST as $name => $value)
{
$vars[$name] = $value;
}
include("includes/authenticate.inc.php");
if (strstr($_SERVER['REQUEST_URI'], 'widescreen=yes')) { $_SESSION['widescreen'] = 1; }
if (strstr($_SERVER['REQUEST_URI'], 'widescreen=no')) { unset($_SESSION['widescreen']); }
# Load the settings for Multi-Tenancy.
if (isset($config['branding']) && is_array($config['branding']))
{
if ($config['branding'][$_SERVER['SERVER_NAME']])
{
foreach ($config['branding'][$_SERVER['SERVER_NAME']] as $confitem => $confval)
{
eval("\$config['" . $confitem . "'] = \$confval;");
}
} else {
foreach ($config['branding']['default'] as $confitem => $confval)
{
eval("\$config['" . $confitem . "'] = \$confval;");
}
}
}
# page_title_prefix is displayed, unless page_title is set
if ($config['page_title']) { $config['page_title_prefix'] = $config['page_title']; }
?>
<!DOCTYPE HTML>
<html>
<head>
<title><?php echo($config['page_title_suffix']); ?></title>
<base href="<?php echo($config['base_url']); ?>" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<?php
if ($config['page_refresh']) { echo(' <meta http-equiv="refresh" content="'.$config['page_refresh'].'" />' . "\n"); }
?>
<link href="css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<link href="css/typeahead.js-bootstrap.css" rel="stylesheet" type="text/css" />
<link href="css/bootstrap-switch.min.css" rel="stylesheet" type="text/css" />
<link href="<?php echo($config['stylesheet']); ?>" rel="stylesheet" type="text/css" />
<script src="js/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/bootstrap-hover-dropdown.min.js"></script>
<script src="js/bootstrap-switch.min.js"></script>
<script src="js/typeahead.min.js"></script>
<script src="js/hogan-2.0.0.js"></script>
<script src="js/jquery.cycle2.min.js"></script>
<?php
if ($config['favicon']) { echo(' <link rel="shortcut icon" href="'.$config['favicon'].'" />' . "\n"); }
?>
<script type="text/javascript">
<!-- Begin
function popUp(URL)
{
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=550,height=600');");
}
// End -->
</script>
<script type="text/javascript" src="js/overlib_mini.js"></script>
</head>
<body>
<?php
if (!$vars['bare'] == "yes") {
if ($_SESSION['authenticated'])
{
include("includes/print-menubar.php");
}
}
?>
<br />
<div class="container-fluid">
<?php
if ($_SESSION['authenticated'])
{
?>
<div class="row">
<div class="col-md-12">
<br /><br />
</div>
</div>
<?php
}
?>
<div class="row">
<div class="col-md-12">
<?php
// To help debug the new URLs :)
if ($devel || $vars['devel'])
{
echo("<pre>");
print_r($_GET);
print_r($vars);
echo("</pre>");
}
if ($_SESSION['authenticated'])
{
// Authenticated. Print a page.
if (isset($vars['page']) && !strstr("..", $vars['page']) && is_file("pages/" . $vars['page'] . ".inc.php"))
{
include("pages/" . $vars['page'] . ".inc.php");
} else {
if (isset($config['front_page']) && is_file($config['front_page']))
{
include($config['front_page']);
} else {
include("pages/front/default.php");
}
}
} else {
// Not Authenticated. Show status page if enabled
if ( $config['public_status'] === true )
{
if (isset($vars['page']) && strstr("login", $vars['page']))
{
include("pages/logon.inc.php");
} else {
echo '<div id="public-status">';
include("pages/public.inc.php");
echo '</div>';
echo '<div id="public-logon" style="display:none;">';
echo '<div class="well"><h3>Logon<button class="btn btn-default" type="submit" style="float:right;" id="ToggleStatus">Status</button></h3></div>';
include ("pages/logon.inc.php");
echo '</div>';
}
}
else
{
include("pages/logon.inc.php");
}
}
?>
</div>
</div>
</div>
<?php
$runtime_end = utime(); $runtime = $runtime_end - $runtime_start;
$gentime = substr($runtime, 0, 5);
# FIXME - move this
if ($config['page_gen'])
{
echo(' <br />MySQL: Cell '.($db_stats['fetchcell']+0).'/'.round($db_stats['fetchcell_sec']+0,3).'s'.
' Row '.($db_stats['fetchrow']+0). '/'.round($db_stats['fetchrow_sec']+0,3).'s'.
' Rows '.($db_stats['fetchrows']+0).'/'.round($db_stats['fetchrows_sec']+0,3).'s'.
' Column '.($db_stats['fetchcol']+0). '/'.round($db_stats['fetchcol_sec']+0,3).'s');
$fullsize = memory_get_usage();
unset($cache);
$cachesize = $fullsize - memory_get_usage();
if ($cachesize < 0) { $cachesize = 0; } // Silly PHP!
echo(' <br />Cached data in memory is '.formatStorage($cachesize).'. Page memory usage is '.formatStorage($fullsize).', peaked at '. formatStorage(memory_get_peak_usage()) .'.');
echo(' <br />Generated in ' . $gentime . ' seconds.');
}
?>
<script class="content_tooltips" type="text/javascript">
$(document).ready(function() { $('#content a[title]').qtip({ content: { text: false }, style: 'light' }); });
$('INPUT.auto-hint, TEXTAREA.auto-hint').focus(function() {
if ($(this).val() == $(this).attr('title')) {
$(this).val('');
$(this).removeClass('auto-hint');
}
});
</script>
<?php
if (is_array($pagetitle))
{
# if prefix is set, put it in front
if ($config['page_title_prefix']) { array_unshift($pagetitle,$config['page_title_prefix']); }
# if suffix is set, put it in the back
if ($config['page_title_suffix']) { $pagetitle[] = $config['page_title_suffix']; }
# create and set the title
$title = join(" - ",$pagetitle);
echo("<script type=\"text/javascript\">\ndocument.title = '$title';\n</script>");
}
?>
<footer>
<div class="container">
<div class="row">
<div class="col-md-12 text-center">
<?php
echo(' <br /> <br /> ' . (isset($config['footer']) ? $config['footer'] : ''));
echo(' <br />Powered by <a href="' . $config['project_url'] . '" target="_blank">' . $config['project_name_version'].'</a>. ');
echo( $config['project_name'].' is <a href="http://www.gnu.org/philosophy/free-sw.html">Free Software</a>, released under the <a href="http://www.gnu.org/copyleft/gpl.html">GNU GPLv3</a>.<br/>');
echo(' Copyright © 2006-2012 by Adam Armstrong. Copyright © 2013-'.date("Y").' by the '.$config['project_name'].' Contributors.');
?>
</div>
</div>
</div>
</footer>
</body>
</html>