forked from devsnippet/ossimTest
/
top.php
414 lines (369 loc) · 14.7 KB
/
top.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
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
<?php
/*****************************************************************************
*
* License:
*
* Copyright (c) 2003-2006 ossim.net
* Copyright (c) 2007-2009 AlienVault
* All rights reserved.
*
* This package is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 dated June, 1991.
* You may not use, modify or distribute this program under any other version
* of the GNU General Public License.
*
* This package 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this package; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
* MA 02110-1301 USA
*
*
* On Debian GNU/Linux systems, the complete text of the GNU General
* Public License can be found in `/usr/share/common-licenses/GPL-2'.
*
* Otherwise you can read it here: http://www.gnu.org/licenses/gpl-2.0.txt
****************************************************************************/
require_once 'classes/Security.inc';
require_once 'classes/Session.inc';
require_once 'classes/WebIndicator.inc';
require_once 'classes/Util.inc';
Session::useractive("session/login.php");
// refresh hour
$tz = Util::get_timezone();
$timetz = gmdate("U")+(3600*$tz);
if (GET("lasthour")=="1") {
echo gmdate("H:i",$timetz);
exit();
}
require_once ('ossim_conf.inc');
$conf = $GLOBALS["CONF"];
//$ntop_link = $conf->get_conf("ntop_link", FALSE);
ossim_set_lang();
$uc_languages = array(
"de_DE.UTF-8",
"de_DE.UTF8",
"de_DE",
"en_GB",
"es_ES",
"fr_FR",
"pt_BR"
);
//$sensor_ntop = parse_url($ntop_link);
$ocs_link = $conf->get_conf("ocs_link", FALSE);
$glpi_link = $conf->get_conf("glpi_link", FALSE);
$ovcp_link = $conf->get_conf("ovcp_link", FALSE);
$nagios_link = $conf->get_conf("nagios_link", FALSE);
$sensor_nagios = parse_url($nagios_link);
if (!isset($sensor_nagios['host'])) {
$sensor_nagios['host'] = $_SERVER['SERVER_NAME'];
}
$menu = array();
$hmenu = array();
/*
$placeholder = gettext("Dashboard");
$placeholder = gettext("Events");
$placeholder = gettext("Monitors");
$placeholder = gettext("Incidents");
$placeholder = gettext("Reports");
$placeholder = gettext("Policy");
$placeholder = gettext("Correlation");
$placeholder = gettext("Configuration");
$placeholder = gettext("Tools");
*/
$placeholder = gettext("Logout");
// Passthrough Vars
$status = "Open";
if (GET('status') != null) $status = GET('status');
/* Menu options */
include ("menu_options.php");
/* Generate reporting server url */
switch ($conf->get_conf("bi_type", FALSE)) {
case "jasperserver":
default:
if ($conf->get_conf("bi_host", FALSE) == "localhost") {
$bi_host = $_SERVER["SERVER_NAME"];
} else {
$bi_host = $conf->get_conf("bi_host", FALSE);
}
if (!strstr($bi_host, "http")) {
$reporting_link = "http://";
}
$bi_link = $conf->get_conf("bi_link", FALSE);
$bi_link = str_replace("USER", $conf->get_conf("bi_user", FALSE) , $bi_link);
$bi_link = str_replace("PASSWORD", $conf->get_conf("bi_pass", FALSE) , $bi_link);
$reporting_link.= $bi_host;
$reporting_link.= ":";
$reporting_link.= $conf->get_conf("bi_port", FALSE);
$reporting_link.= $bi_link;
}
$option = intval(GET('option'));
$soption = intval(GET('soption'));
$url = addslashes(GET('url'));
if ($url != "") {
$url_check = preg_replace("/\.php.*/",".php",$url);
if (!file_exists($url_check)) {
echo _("Can't access to $url_check for security reasons");
exit;
}
}
if (empty($option))
$option = 0;
if (!isset($soption))
{
if ( isset($_SESSION["_TopMenu_" . $option]) )
$soption = $_SESSION["_TopMenu_" . $option];
else
$soption = 0;
}
else
{
$_SESSION["_TopMenu_" . $option] = $soption;
}
$keys = array_keys($menu);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>Ossim Menu</title>
<link rel="stylesheet" type="text/css" href="style/top.css">
<style type='text/css'>
html, body {height:100%;overflow-y:auto;overflow-x:hidden}
/*#side-bar ul, #side-bar span {visibility: hidden;}*/
#side-bar, #side-bar2 {visibility: hidden;}
</style>
<link type="text/css" href="style/default/jx.stylesheet.css" rel="stylesheet" />
<script type="text/javascript" src="js/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="js/jquery.jixedbar.js"></script>
<script type="text/javascript" src="js/accordian.js" ></script>
<script type="text/javascript">
var newwindow;
function new_wind(url,name)
{
newwindow=window.open(url,name,'height=768,width=1024,scrollbars=yes');
if (window.focus) {newwindow.focus()}
}
function fullwin(){
window.open("index.php","main_window","fullscreen,scrollbars")
}
$(document).ready(function() {
new Accordian('basic-accordian',5,'header_highlight');
$("#side-bar").jixedbar();
$("#side-bar").css('visibility', 'visible');
$("#side-bar2").css('visibility', 'visible');
});
</script>
<body leftmargin='0' topmargin='0' marginwidth='0' marginheight='0' bgcolor="#D2D2D2">
<table width="100%" height="100%" border='0' cellpadding='0' cellspacing='0' style="border:1px solid #AAAAAA">
<tr>
<td valign="top">
<table width="100%" border='0' cellpadding='0' cellspacing='0'>
<!--<tr><td style="background:#678297 url(pixmaps/top/blueshadow.gif) top left" align="center" height="40" class="white"> :: Operation :: </td></tr> -->
<tr>
<td>
<div id="basic-accordian" ><!--Parent of the Accordion-->
<?php
$i = 0;
$moption = $hoption = "";
foreach($menu as $name => $opc) if ($name != "Logout")
{
if (!isset($language)) $language = "";
$open = ($option == $i) ? "header_highlight" : "";
$txtopc = (in_array($language, $uc_languages)) ? Util::htmlentities(strtoupper(html_entity_decode(gettext($name)))) : gettext($name);
?>
<!--Start of each accordion item-->
<div id="test<?php if ($i > 0) echo $i ?>-header" class="accordion_headings <?php echo $open ?>">
<img src="pixmaps/menu/<?php echo str_replace(" ","",strtolower($name)) ?>.gif" border=0 align="absmiddle"> <?php echo $txtopc ?>
</div>
<!--Prefix of heading (the DIV above this) and content (the DIV below this) to be same... eg. foo-header & foo-content-->
<?php $default_url = (count($menu[$keys[$i]])==1) ? $menu[$keys[$i]][0]["url"] : ""; ?>
<div id="test<?php if ($i > 0) echo $i ?>-content"<?=($default_url!="") ? " url=\"$default_url\"" : ""?>><!--DIV which show/hide on click of header-->
<!--This DIV is for inline styling like padding...-->
<div class="accordion_child">
<table cellpadding='0' cellspacing='0' border='0' width="100%">
<?php
if (is_array($menu[$keys[$i]]))
{
foreach($menu[$keys[$i]] as $j => $op)
{
if ($option == $i && $soption == $j && $url == "") {
$url = $op["url"];
$hoption = $keys[$i];
$moption = $op["id"];
}
$txtsopc = (in_array($language, $uc_languages)) ? Util::htmlentities(strtoupper(html_entity_decode($op["name"]))) : $op["name"];
$lnk = (count($menu[$keys[$i]])==1 || ($option == $i && $soption == $j)) ? "on" : "";
if ($op["id"] != "Help")
{
?>
<tr>
<td>
<div class="opc<?php echo $lnk ?>" onclick="document.location.href='<?php echo $SCRIPT_NAME ?>?option=<?php echo $i ?>&soption=<?php echo $j ?>'">
<table cellpadding='0' cellspacing='0' border='0' width="100%">
<tr>
<td class="cell right"><img src="pixmaps/menu/icon0.gif"/></td>
<td class="cell" nowrap='nowrap'>
<span class="lnk<?php echo $lnk ?>"><?php echo $txtsopc ?></span>
</td>
</tr>
</table>
</div>
</td>
</tr>
<?php
}
else
{
?>
<tr>
<td>
<table cellpadding='0' cellspacing='0' border='0' width="100%">
<tr>
<td class="opc right"><a href="<?php echo $op["url"] ?>"><img src="pixmaps/menu/help.gif" border="0"></a></td>
<td class="opc" nowrap><a href="<?php echo $op["url"] ?>" class="help">Help</a></td>
</tr>
</table>
</td>
</tr>
<?php
}
}
echo "<tr><td height='2' bgcolor='#575757'></td></tr>";
echo "<tr><td height='1' bgcolor='#FFFFFF'></td></tr>";
}
?>
</table>
</div>
</div>
<?php
$i++;
}
?>
</div>
</td>
</tr>
<!--
<tr><td height="26" class="outmenu">
<img src="pixmaps/user-green.png" width="12" border=0 align="absmiddle"> <a href="<?=($opensource) ? "session/modifyuserform.php?user=".Session::get_session_user()."&frommenu=1&hmenu=Userprofile&smenu=Userprofile" : "acl/users_edit.php?login=".Session::get_session_user()."&frommenu=1&hmenu=Userprofile&smenu=Userprofile";?>" target="main"><font color="black"><?php echo _("My Profile")?></font></a>
</td></tr>
<tr><td height="26" class="outmenu">
<img src="pixmaps/users.png" width="12" border='0' align="absmiddle"> <a href="userlog/opened_sessions.php?hmenu=Sessions&smenu=Sessions" target="main"><span style='color:black'><?php echo _("Current Sessions")?></span></a>
</td></tr>
<tr><td height="26" class="outmenu">
<img src="pixmaps/menu/logout.png" border=0 align="absmiddle"> <a href="session/login.php?action=logout"><font color="black"><?php echo _("Logout")?></font></a> [<font color="gray"><?php
echo $_SESSION["_user"] ?></font>]
</td></tr>
<tr><td height='1' bgcolor='#EEEEEE'></td></tr>
<tr><td height="26" class="outmenu">
<img src="pixmaps/menu/maximizep.png" border=0 align="absmiddle"> <a href="#" onClick="fullwin()"><font color="black"><?php echo _("Maximize")?></font></a>
</td></tr>
<?php
if(Session::am_i_admin()) {
?>
<tr><td height="26" class="outmenu">
<img src="pixmaps/menu/gear.png" border=0 align="absmiddle"> <a href="sysinfo/index.php" target="main"><font color="black"><?php echo _("System Status")?></font></a>
</td></tr>
<?php
}
?>
-->
</table>
<div id="side-bar">
<ul>
<li title="<?php echo _("User options")?>"><a href="#"><img src="pixmaps/myprofile.png" alt="<?php echo Session::get_session_user()?>" /></a>
<ul>
<li title="<?php echo _("Maximize")?>"><a href="#" onClick="fullwin()"><img src="pixmaps/maximize.png" align="absmiddle"> <?php echo _("Maximize")?></a></li>
<li title="<?php echo _("Logout")?>"><a href="session/login.php?action=logout"><img src="pixmaps/logout.png" align="absmiddle"> <?php echo _("Logout")?></a></li>
<li title="<?php echo _("My Profile")?>"><a href="<?=($opensource) ? "session/modifyuserform.php?user=".Session::get_session_user()."&frommenu=1&hmenu=Userprofile&smenu=Userprofile" : "acl/users_edit.php?login=".Session::get_session_user()."&frommenu=1&hmenu=Userprofile&smenu=Userprofile";?>" target="main"><img src="pixmaps/myprofile.png" align="absmiddle"> <?php echo _("My Profile")?></a></li>
</ul>
</li>
</ul>
<span class="jx-separator-right"></span>
<ul class="jx-bar-button-right">
<?php if(Session::am_i_admin()) { ?>
<li title="<?php echo _("System<br>Status")?>"><a href="sysinfo/index.php?hmenu=Sysinfo&smenu=Hardware+Info" target="main"><img src="pixmaps/status.png"></a> </li>
<?php } else { ?>
<li title="<?php echo _("System<br>Status")?>"><img src="pixmaps/status_gray.png"></li>
</ul>
<?php } ?>
<ul class="jx-bar-button-right">
<?php if(Session::menu_perms("MenuReports", "ReportsHostReport") || Session::am_i_admin()) { ?>
<li title="<?php echo _("Data Snapshot")?>"><a href="<?php echo "report/host_report.php?hmenu=Sysinfo&smenu=Sysinfo&host=any&star_date=".gmdate("Y-m-d",$timetz-604800)."&end_date=".gmdate("Y-m-d",$timetz) ?>" target="main"><img src="pixmaps/compass.png"></a></li>
<?php } else { ?>
<li title="<?php echo _("Data Snapshot")?>"><img src="pixmaps/status_gray.png"></li>
<?php } ?>
</ul>
</div>
<?php
require_once ('classes/DateDiff.inc');
require_once ('ossim_db.inc');
require_once ('ossim_conf.inc');
$db = new ossim_db();
$conn = $db->connect();
$all_sessions = Session_activity::get_list($conn," ORDER BY activity desc");
$users = 0;
foreach ($all_sessions as $sess)
{
if ($sess->get_id() == session_id())
{
$ago = str_replace(" ago","",TimeAgo(Util::get_utc_unixtime($conn,$sess->get_logon_date()),gmdate("U")));
}
if (!Session_activity::is_expired(Util::get_utc_unixtime($conn,$sess->get_activity()))) $users++;
}
$db->close($conn);
// TIME DEBUG
//var_dump($tz);
//var_dump(gmdate("U"));
//var_dump($timetz);
//var_dump($sess->get_activity());
//var_dump(Util::get_utc_unixtime($conn,$sess->get_activity()));
?>
<div id="side-bar2" class="jx-bottom-bar jx-bar-rounded-bl jx-bar-rounded-br">
<table style="width:100%">
<tr>
<td class="jx-gray">
<?php echo _("User session").": <a href='userlog/opened_sessions.php?hmenu=Sysinfo&smenu=Sessions' target='main' class='jx-gray-b'>$ago</a>" ?>
<br/>
<span style="float:left"><?= "<a href='userlog/opened_sessions.php?hmenu=Sysinfo&smenu=Sessions' target='main' class='jx-gray-b'>$users</a> "._("active users") ?></span><span style="float:right" id="hour"><?= gmdate("H:i",$timetz)?></span>
</td>
</tr>
</table>
</div>
</td><!-- <td style="background:url('pixmaps/menu/dg_gray.gif') repeat-y top left;width:6"><img src="pixmaps/menu/dg_gray.gif"></td> -->
</tr>
</table>
<?php
if ($url != "")
{
if (preg_match("/hmenu\=/",$url))
{
?>
<script type='text/javascript'> window.open('<?php echo $url ?>', 'main') </script>
<?php
}
else
{
?>
<script type='text/javascript'> window.open('<?php echo $url . (preg_match("/\?/", $url) ? "&" : "?") . "hmenu=" . urlencode(($hoption=="Policy" && $moption!="Actions") ? $hoption : $moption) . "&smenu=" . urlencode($moption) ?>', 'main') </script>
<?
}
}
?>
<script type='text/javascript'>
function refresh_hour() {
$.ajax({
type: "GET",
url: "top.php?lasthour=1&bypassexpirationupdate=1",
success: function(msg) {
$("#hour").html(msg);
}
});
}
setInterval('refresh_hour()',60000);
</script>
</body>
</html>