function DisplayDetails() { global $self; global $DisplayOrder; global $TypeOrder; global $WinSizeLabels; global $RRDoffset; global $GMToffset; global $TZname; require_once 'av_init.php'; $db_aux = new ossim_db(); $conn_aux = $db_aux->connect(); ?> <script language="Javascript" src="js/detail.js" type="text/javascript"> </script> <?php $tright = UNIX2DISPLAY($_SESSION['tright']); $tleft = UNIX2DISPLAY($_SESSION['tleft']); $profile = $_SESSION['profile']; $profilegroup = $_SESSION['profilegroup']; $detail_opts = $_SESSION['detail_opts']; $is_shadow = ($_SESSION['profileinfo']['type'] & 4) > 0; print "<h3>Profile: " . Util::htmlentities($profile) . "</h3>\n"; if ($detail_opts['channellist'] != '') { $_tmp = explode('!', $detail_opts['channellist']); } else { $_tmp = array(); } if (count($_tmp) == 0) { $graph_channels = '@EMPTY'; } else { $graph_channels = ''; foreach ($_tmp as $_t) { $graph_channels .= $_t . ';' . Av_sensor::get_nfsen_channel_name($conn_aux, $_t) . ':'; } $graph_channels = preg_replace('/:$/', '', $graph_channels); } ?> <table style='font-size:14px;font-weight:bold;width:100%' class='transparent'> <tr> <?php for ($i = 1; $i < count($DisplayOrder); $i++) { $label = $DisplayOrder[$i]; if ($label == $detail_opts['proto']) { $label = 'any'; } print "<td>"; print $label; print "</td>\n"; } print "<td style='font-size:14px;font-weight:bold'>" . gettext("Profile info:") . "</td>\n"; // Empty right element print "</tr><tr>\n"; for ($i = 1; $i < count($DisplayOrder); $i++) { $label = $DisplayOrder[$i]; if ($label == $detail_opts['proto']) { $label = 'any'; } print "<td>\n"; if ($graph_channels != '@EMPTY') { $arg = implode(" ", array($graph_channels, $label, $detail_opts['type'], $_SESSION['profileinfo']['tstart'], $_SESSION['tstart'], $_SESSION['tend'], $_SESSION['tleft'], $_SESSION['tright'], 288, 100, 1, $detail_opts['logscale'], $detail_opts['linegraph'])); $arg = urlencode($arg); } else { $arg = ''; } print "<a href='{$self}&proto={$label}'> " . "<img src=rrdgraph.php?cmd=get-detailsgraph&profile=" . Util::htmlentities($_SESSION['profileswitch']) . "&arg={$arg} border='0' width='165' height='81' alt='{$label}'></a>\n"; print "</td>\n"; } print "<td style='vertical-align: bottom;'>\n"; $str = strftime("%b %d %Y - %H:%M", $_SESSION['profileinfo']['tstart']); $expire = $_SESSION['profileinfo']['expire']; if ($expire == 0) { $expire = 'never'; } else { $d = (int) ($expire / 24); $h = $expire % 24; $d_ext = $d == 1 ? '' : 's'; $h_ext = $h == 1 ? '' : 's'; if ($d) { $expire = "{$d} day{$d_ext} {$h} hour{$h_ext}"; } else { $expire = "{$h} hour{$h_ext}"; } } $maxsize = ScaleBytes($_SESSION['profileinfo']['maxsize'], 1, 1024.0); if ($maxsize == 0) { $maxsize = 'unlimited'; } print "<table style='font-size:12px;font-weight:bold;border:none;width:100%'>\n"; switch ($_SESSION['profileinfo']['type'] & 3) { case 0: $type = 'live'; break; case 1: $type = 'history'; break; case 2: $type = 'continuous'; break; default: $type = 'unknown'; } $type .= $is_shadow ? ' / shadow' : ''; print "<tr><td>Type:</td><td>{$type}</td></tr>"; print "<tr><td>Max:</td><td>" . Util::htmlentities($maxsize) . "</td></tr>"; print "<tr><td>Exp:</td><td>{$expire}</td></tr>"; print "<tr><td>Start:</td><td>{$str} {$TZname}</td></tr>\n"; $str = strftime("%b %d %Y - %H:%M", $_SESSION['profileinfo']['tend']); print "<tr><td style='border:none'>End:</td><td style='border:none'>{$str} {$TZname}</td></tr>\n"; print "</table>\n"; print "</td>\n"; if ($graph_channels != '@EMPTY') { $arg = implode(" ", array($graph_channels, $detail_opts['proto'], $detail_opts['type'], $_SESSION['profileinfo']['tstart'], $_SESSION['tstart'], $_SESSION['tend'], $_SESSION['tleft'], $_SESSION['tright'], 576, 200, 0, $detail_opts['logscale'], $detail_opts['linegraph'])); $arg = urlencode($arg); } else { $arg = ''; } ?> </tr> <tr> <td colspan='4' align="center" valign="top" style='padding:0;'> <br> <img id='MainGraph' style='position:relative; top:0px; left:0px;' onclick="DragCursor.set(event);" src=rrdgraph.php?cmd=get-detailsgraph&profile=<?php echo Util::htmlentities($_SESSION['profileswitch']); ?> &arg=<?php echo $arg; ?> border='0' alt='main-graph'> <img id="CursorDragHandle" style="position:absolute;display:none; " src="icons/cursor-line.png" alt="Line Cursor"> <img id="StartDragHandle" style="position:absolute;display:none" src="icons/cursor-start.png" alt="Start Cursor"> <div id="StartLine" style="position: absolute;display:none; width: 1px; height: 200px; background-color: black;"></div> <div id="SpanBox" style="position:absolute;display:none; height: 200px; background-color: #B1FFA1; filter:alpha(opacity=40); opacity:.40;"></div> <div id="StopLine" style="position: absolute;display:none; width: 1px; height: 200px; background-color: black;"></div> <img id="StopDragHandle" style="position:absolute;display:none" src="icons/cursor-stop.png" alt="Stop Cursor"> <form style="display:inline;" name="slotselectform" id="slotselectform" action="<?php echo $self; ?> " method="POST"> <input type="hidden" name="cursor_mode" id="cursor_mode" value=""> <input type="hidden" name="tleft" id="tleft" value=""> <input type="hidden" name="tright" id="tright" value=""> </form> </td> <td style="vertical-align:bottom;padding:0;"> <table style="margin-bottom:1pt;border:none;width:100%"> <tr> <td><span style='font-size:14px;font-weight:bold;margin-bottom:1pt'> t<SUB><?php echo _("start"); ?> </SUB> </span> </td> <td style="font-size:16px;color:#555555;"> <!-- input type="text" name="box_tleft" id="box_tleft" value="" SIZE="16" MAXLENGTH="16" style='font-size:10px;' readonly --> <b id='box_tleft'>- <?php echo _("update"); ?> -</b> </td> </tr><tr> <td><span style='font-size:14px;font-weight:bold;margin-bottom:1pt'> t<SUB><?php echo _("end"); ?> </SUB> </span> </td> <td style="font-size:16px;color:#555555;"> <!-- input type="text" name="box_tright" id="box_tright" value="" SIZE="16" MAXLENGTH="16" style='font-size:10px;' readonly --> <b id='box_tright'>- <?php echo _("update"); ?> -</b> </td> </tr> </table> <table style='font-size:14px;font-weight:bold;border:none;width:100%'> <?php for ($i = 1; $i < count($TypeOrder); $i++) { $label = $TypeOrder[$i]; if ($label == $detail_opts['type']) { $label = 'flows'; } // Make first letter uppercase of label to print $printlabel = strtoupper($label[0]) . substr($label, 1); print "<tr><td>" . ($printlabel != "" ? gettext($printlabel) : " ") . "</td></tr>\n"; print "<tr><td style='border:none'>\n"; if ($graph_channels != '@EMPTY') { $arg = implode(" ", array($graph_channels, $detail_opts['proto'], $label, $_SESSION['profileinfo']['tstart'], $_SESSION['tstart'], $_SESSION['tend'], $_SESSION['tleft'], $_SESSION['tright'], 288, 100, 1, $detail_opts['logscale'], $detail_opts['linegraph'])); $arg = urlencode($arg); } else { $arg = ''; } print "<a href='{$self}&type={$label}'> " . "<img src=rrdgraph.php?cmd=get-detailsgraph&profile=" . Util::htmlentities($_SESSION['profileswitch']) . "&arg={$arg} border='0' width='165' height='81' alt='{$label}'></a>"; print "</td></tr>\n"; } ?> </table> </td> </tr> <tr> <td colspan='4' style="border:none"> <table border="0" style='width:100%;margin:0pt;border:none'> <tr> <td style="border:none"> <?php echo _("Select"); ?> <select name="CursorMode" id="ModeSelector" onchange="SetCursorMode(<?php echo Util::htmlentities($_SESSION['tstart']) . ", " . Util::htmlentities($_SESSION['tend']) . ", " . Util::htmlentities($_SESSION['profileinfo']['tstart']) . ", " . Util::htmlentities($_SESSION['tleft']) . ", " . Util::htmlentities($_SESSION['tright']) . ",576, {$RRDoffset}"; ?> )" size=1> <?php if ($detail_opts['cursor_mode'] == 1) { print "<option value='0'>" . _("Single Timeslot") . "\n"; print "<option value='1' selected>" . _("Time Window") . "\n"; } else { print "<option value='0' selected>" . _("Single Timeslot") . "\n"; print "<option value='1'>" . _("Time Window") . "\n"; } ?> </select> </td> <td style="text-align: right;border:none"> <?php echo _("Display"); ?> : <form action="<?php echo $self; ?> " style="display:inline;" method="POST"> <select name='wsize' onchange='this.form.submit();' size=1> <?php $size_label = 'unknown'; for ($i = 0; $i < count($WinSizeLabels); $i++) { if ($i == $detail_opts['wsize']) { print "<option value='{$i}' selected>" . $WinSizeLabels[$i] . "\n"; $size_label = $WinSizeLabels[$i]; } else { print "<option value='{$i}'>" . $WinSizeLabels[$i] . "\n"; } } $status = $detail_opts['cursor_mode'] == 0 && !$is_shadow ? '' : 'disabled'; $peak_search_label = $status == '' ? _("Search Peak") : _("Peak search not available"); ?> </select> <input class="small av_b_secondary" name="adjust" value=" << " type="submit" title="<?php echo _("Back"); ?> <?php echo $size_label; ?> "> <input class="small av_b_secondary" name="adjust" value=" < " type="submit" title="<?php echo _("Previous time slot"); ?> "> <input class="small av_b_secondary" name="adjust" value=" | " type="submit" title="<?php echo _("Center cursor"); ?> "> <input class="small av_b_secondary" name="adjust" value=" ^ " type="submit" <?php echo $status; ?> title="<?php echo $peak_search_label; ?> "> <input class="small av_b_secondary" name="adjust" value=" > " type="submit" title="<?php echo _("Next time slot"); ?> "> <input class="small av_b_secondary" name="adjust" value=" >> " type="submit" title="<?php echo _("Forward"); ?> <?php echo $size_label; ?> "> <input class="small av_b_secondary" name="adjust" value=" >| " type="submit" title="<?php echo _("Goto last slot"); ?> "> </form> </td> </tr> </table> </td> <td style="border:none"> <form action="<?php echo $self; ?> " method="POST"> <table style="border:none;width:100%"> <tr> <td style="border:none"> <input type="radio" onClick='this.form.submit();' name="logscale" value="0" <?php if ($detail_opts['logscale'] == 0) { print "checked"; } ?> ><?php echo _("Lin Scale"); ?> </td> <td style="border:none"> <input type="radio" onClick='this.form.submit();' name="linegraph" value="0" <?php if ($detail_opts['linegraph'] == 0) { print "checked"; } ?> ><?php echo _("Stacked Graph"); ?> </td> </tr> <tr> <td style="border:none"> <input type="radio" onClick='this.form.submit();' name="logscale" value="1" <?php if ($detail_opts['logscale'] == 1) { print "checked"; } ?> ><?php echo _("Log Scale"); ?> </td> <td style="border:none"> <input type="radio" onClick='this.form.submit();' name="linegraph" value="1" <?php if ($detail_opts['linegraph'] == 1) { print "checked"; } ?> ><?php echo _("Line Graph"); ?> </td> </tr> </table> </form> </td> </tr><tr> <td colspan='4' style="border:none"></td> <td style="border:none"></td> </tr> </table> <?php if ($_SESSION['tleft'] == $_SESSION['tright']) { $tslot = "timeslot " . strftime("%b %d %Y - %H:%M", $_SESSION['tleft']); } else { $tslot = "timeslot " . strftime("%b %d %Y - %H:%M", $_SESSION['tleft']) . " - " . strftime("%b %d %Y - %H:%M", $_SESSION['tright']); } $num_channels = count(array_keys($_SESSION['profileinfo']['channel'])); $proto_index = 1; foreach ($DisplayOrder as $p) { if ($detail_opts['proto'] == $p) { break; } $proto_index++; } $statpref = explode(':', $detail_opts['statpref']); $max_colspan = 0; for ($i = 0; $i < count($statpref); $i++) { $pref = $statpref[$i]; if ($pref == 0) { $arrow_style[] = ''; $arrow_style[] = 'style="display:none;"'; $colspan[] = 5; $max_colspan += 5; } else { $arrow_style[] = 'style="display:none;"'; $arrow_style[] = ''; $statpref[$i] = $proto_index; $colspan[] = 1; $max_colspan += 1; } } $_i = 0; if ($detail_opts['statvisible'] == 1) { $stattable_style = ''; $down_arrow_style = ''; $right_arrow_style = 'style="display:none"'; } else { $stattable_style = 'display:none;'; $down_arrow_style = 'style="display:none"'; $right_arrow_style = ''; } ?> <br><br><b> <table style="width:100%" cellspacing='0' cellpadding='0'> <tr> <th class='thold'> <a href="#null" onClick="ShowHideStat();" title="<?php echo _("Hide Statistic"); ?> " ><IMG SRC="icons/arrow.yellow.down.png" name="flows" id="stat_arrow_down" border="0" <?php echo $down_arrow_style; ?> align="left" alt="<?php echo _("Hide stat table"); ?> "></a> <a href="#null" onClick="ShowHideStat();" title="<?php echo _("Show Statistic"); ?> " ><IMG SRC="icons/arrow.yellow.right.png" name="flows" id="stat_arrow_right" border="0" <?php echo $right_arrow_style; ?> align="left" alt="<?php echo _("Show stat table"); ?> "></a> Statistics <?php echo $tslot; ?> </b> </th> </tr> </table> <form action="<?php echo $self; ?> " method="POST" id="statsform"> <input type="hidden" name="srctrigger" value="src"> <table id="stattable" style='font-size:14px;font-weight:bold;<?php echo $stattable_style; ?> ;border:none;width:100%' cellspacing='0' cellpadding='3'> <tr align='center'> <th class='theader' colspan="2"><?php echo _("Channel"); ?> </th> <th class='theader' id="label0" colspan='<?php echo $colspan[0]; ?> '> <a href="#null" onClick="CollapseExpandStat(<?php echo $num_channels; ?> , 0, <?php echo $proto_index; ?> );" title="<?php echo _("Collapse"); ?> " ><IMG SRC="icons/arrow.blue.down.png" name="flows" id="arrow0_down" border="0" <?php echo $arrow_style[$_i++]; ?> align="left" alt="<?php echo _("collapse"); ?> "></a> <a href="#null" onClick="CollapseExpandStat(<?php echo $num_channels; ?> , 0, <?php echo $proto_index; ?> );" title="<?php echo _("Expand"); ?> " ><IMG SRC="icons/arrow.blue.right.png" name="flows" id="arrow0_right" border="0" <?php echo $arrow_style[$_i++]; ?> align="left" alt="<?php echo _("collapse"); ?> "></a><?php echo _("Flows"); ?> </th> <th class='theader' id="label1" colspan='<?php echo $colspan[1]; ?> '> <a href="#null" onClick="CollapseExpandStat(<?php echo $num_channels; ?> , 1, <?php echo $proto_index; ?> );" title="<?php echo _("Collapse"); ?> " ><IMG SRC="icons/arrow.blue.down.png" name="flows" id="arrow1_down" border="0" <?php echo $arrow_style[$_i++]; ?> align="left" alt="<?php echo _("collapse"); ?> "></a> <a href="#null" onClick="CollapseExpandStat(<?php echo $num_channels; ?> , 1, <?php echo $proto_index; ?> );" title="<?php echo _("Expand"); ?> " ><IMG SRC="icons/arrow.blue.right.png" name="flows" id="arrow1_right" border="0" <?php echo $arrow_style[$_i++]; ?> align="left" alt="<?php echo _("collapse"); ?> "></a><?php echo _("Packets"); ?> </th> <th class='theader' id="label2" colspan='<?php echo $colspan[2]; ?> '> <a href="#null" onClick="CollapseExpandStat(<?php echo $num_channels; ?> , 2, <?php echo $proto_index; ?> );" title="<?php echo _("Collapse"); ?> " ><IMG SRC="icons/arrow.blue.down.png" name="flows" id="arrow2_down" border="0" <?php echo $arrow_style[$_i++]; ?> align="left" alt="<?php echo _("collapse"); ?> "></a> <a href="#null" onClick="CollapseExpandStat(<?php echo $num_channels; ?> , 2, <?php echo $proto_index; ?> );" title="<?php echo _("Expand"); ?> " ><IMG SRC="icons/arrow.blue.right.png" name="flows" id="arrow2_right" border="0" <?php echo $arrow_style[$_i++]; ?> align="left" alt="<?php echo _("collapse"); ?> "></a><?php echo _("Traffic"); ?> </th> </tr> <tr> <td colspan="2"> </td> <?php for ($i = 0; $i < 3; $i++) { $col = 1; foreach (array(gettext("all:"), 'tcp:', 'udp:', 'icmp:', gettext("other:")) as $_type) { if ($statpref[$i] == 0) { $_style = ''; } else { if ($statpref[$i] == $col) { $_style = ''; } else { $_style = 'style="display:none;"'; } } print "<td id='id.0.{$i}.{$col}' {$_style}>{$_type}</td>"; $col++; } } print "</tr>\n"; // for simplified testing foreach (explode('!', $detail_opts['channellist']) as $channel) { $_SelectedChannels[$channel] = 1; } foreach (array('', '_tcp', '_udp', '_icmp', '_other') as $_type) { $flows_sum[$_type] = 0; $packets_sum[$_type] = 0; $bits_sum[$_type] = 0; } $row = 1; $rateval = 1; foreach ($_SESSION['profileinfo']['channel'] as $channel) { $ch_name = $channel['name']; $ch_id = $channel['id']; if (Session::am_i_admin()) { $del_incon = "<img src='/ossim/vulnmeter/images/delete.gif' align='sub' onclick='remove_source(\"{$ch_id}\")' style='cursor:pointer;' border='0'>"; } else { $del_incon = ''; } print "<tr>\n"; # channel exists in profile $statinfo = ReadStat($profile, $profilegroup, $ch_id); $rateval = 1; if ($detail_opts['ratescale'] == 1) { $rateval = $_SESSION['tright'] - $_SESSION['tleft'] + 300; } $bgcolour = "bgcolor='" . Util::htmlentities($channel['colour']) . "'"; print "<td {$bgcolour} style='width:10px'></td>\n"; if (array_key_exists($ch_id, $_SelectedChannels)) { print "<td align=left><input type='checkbox' name='" . Util::htmlentities($ch_id) . "' value='" . Util::htmlentities($ch_id) . "' onClick='this.form.submit();' checked>{$ch_name} {$del_incon}</td>\n"; $cellcolour = "bgcolor='#f2f2f2'"; } else { print "<td align=left><input type='checkbox' name='" . Util::htmlentities($ch_id) . "' value='" . Util::htmlentities($ch_id) . "' onClick='this.form.submit();'>{$ch_name} {$del_incon}</td>\n"; $cellcolour = ''; } # print flows $i = 0; $col = 1; $mark_char = ($_SESSION['profileinfo']['type'] & 4) > 0 ? 'S' : 'x'; foreach (array('', '_tcp', '_udp', '_icmp', '_other') as $_type) { if ($statinfo) { $_val = ScaleValue($statinfo['flows' . $_type], $rateval); $flows_sum[$_type] += $statinfo['flows' . $_type]; } else { $_val = $mark_char; } if ($statpref[$i] == 0) { $_style = ''; } else { if ($statpref[$i] == $col) { $_style = ''; } else { $_style = 'style="display:none;"'; } } print "<td {$cellcolour} id='id.{$row}.{$i}.{$col}' {$_style} align=right>{$_val} </td>"; $col++; } # print packets $i = 1; $col = 1; foreach (array('', '_tcp', '_udp', '_icmp', '_other') as $_type) { if ($statinfo) { $_val = ScaleValue($statinfo['packets' . $_type], $rateval); $packets_sum[$_type] += $statinfo['packets' . $_type]; } else { $_val = $mark_char; } if ($statpref[$i] == 0) { $_style = ''; } else { if ($statpref[$i] == $col) { $_style = ''; } else { $_style = 'style="display:none;"'; } } print "<td {$cellcolour} id='id.{$row}.{$i}.{$col}' {$_style} align=right>{$_val} </td>"; $col++; } # prints bits $i = 2; $col = 1; foreach (array('', '_tcp', '_udp', '_icmp', '_other') as $_type) { if ($statinfo) { $_val = ScaleBytes($statinfo['traffic' . $_type], $rateval, 1000.0); $bits_sum[$_type] += $statinfo['traffic' . $_type]; } else { $_val = $mark_char; } if ($statpref[$i] == 0) { $_style = ''; } else { if ($statpref[$i] == $col) { $_style = ''; } else { $_style = 'style="display:none;"'; } } print "<td {$cellcolour} id='id.{$row}.{$i}.{$col}' {$_style} align=right>{$_val} </td>"; $col++; } print "</tr>\n"; $row++; } ?> <tr bgcolor='#dee7ec'> <td colspan="2"> </td> <?php # reprint the header as a footer for ($i = 0; $i < 3; $i++) { $col = 1; foreach (array('all:', 'tcp:', 'udp:', 'icmp:', 'other:') as $_type) { if ($statpref[$i] == 0) { $_style = ''; } else { if ($statpref[$i] == $col) { $_style = ''; } else { $_style = 'style="display:none;"'; } } print "<td id='id.{$row}.{$i}.{$col}' {$_style}>{$_type}</td>"; $col++; } } print "</tr>\n"; $row++; ?> <tr> <td colspan="2">TOTAL</td> <?php # print flows $i = 0; $col = 1; $mark_char = ($_SESSION['profileinfo']['type'] & 4) > 0 ? 'S' : 'x'; foreach (array('', '_tcp', '_udp', '_icmp', '_other') as $_type) { $_val = ScaleValue($flows_sum[$_type], $rateval); if ($statpref[$i] == 0) { $_style = ''; } else { if ($statpref[$i] == $col) { $_style = ''; } else { $_style = 'style="display:none;"'; } } print "<td {$cellcolour} id='id.{$row}.{$i}.{$col}' {$_style} align=right>{$_val} </td>"; $col++; } # print packets $i = 1; $col = 1; foreach (array('', '_tcp', '_udp', '_icmp', '_other') as $_type) { $_val = ScaleValue($packets_sum[$_type], $rateval); if ($statpref[$i] == 0) { $_style = ''; } else { if ($statpref[$i] == $col) { $_style = ''; } else { $_style = 'style="display:none;"'; } } print "<td {$cellcolour} id='id.{$row}.{$i}.{$col}' {$_style} align=right>{$_val} </td>"; $col++; } # prints bits $i = 2; $col = 1; foreach (array('', '_tcp', '_udp', '_icmp', '_other') as $_type) { $_val = ScaleBytes($bits_sum[$_type], $rateval, 1000.0); if ($statpref[$i] == 0) { $_style = ''; } else { if ($statpref[$i] == $col) { $_style = ''; } else { $_style = 'style="display:none;"'; } } print "<td {$cellcolour} id='id.{$row}.{$i}.{$col}' {$_style} align=right>{$_val} </td>"; $col++; } print "</tr>\n"; $row++; ?> <tr><td colspan="2"> <INPUT class="small av_b_secondary" TYPE="submit" NAME="MultipleSources" Value="<?php echo _("All"); ?> "> <INPUT class="small av_b_secondary" TYPE="submit" NAME="MultipleSources" Value="<?php echo _("None"); ?> "> </td> <td colspan='15' style='text-align: left;'> <?php echo _("Display"); ?> : <input type="radio" onClick='this.form.submit();' name="ratescale" value="0" <?php if ($detail_opts['ratescale'] == 0) { print "checked"; } ?> ><?php echo _("Sum"); ?> <input type="radio" onClick='this.form.submit();' name="ratescale" value="1" <?php if ($detail_opts['ratescale'] == 1) { print "checked"; } ?> ><?php echo _("Rate"); ?> <?php if (!$statinfo) { print "x: " . _("No Data available"); } ?> </td></tr> </table> </form> <style type="text/css"> #av_msg_container { width: 60% !important; } .flowlist .tr_flow_data{ font-family: Courier, "Courier New", monospace !important; } </style> <script language="Javascript" type="text/javascript"> function remove_source(id) { if( confirm("<?php echo Util::js_entities(_('This Netflow source is going to be deleted. This action cannot be undone. Are you soure?')); ?> ") ) { $.ajax({ data: {"action": 1, "data": {"sensor": id}}, type: "POST", url: "nfsen_ajax.php", dataType: "json", beforeSend: function () { window.scrollTo(0, 0); var layer = "<div id='loading_container' style='width:100%;height:100%;position:absolute;top:0px;left:0px;'></div>"; $('body').append(layer); show_loading_box('loading_container', '<?php echo Util::js_entities(_("Deleting Netflow source...")); ?> ', ''); }, success: function(data) { hide_loading_box(); $('#loading_container').remove(); if(data.error) { notify(data.msg, 'nf_error'); } else { notify(data.msg, 'nf_success'); setTimeout("document.location.reload();", 1500); } }, error: function(XMLHttpRequest, textStatus, errorThrown) { hide_loading_box(); $('#loading_container').remove(); notify(textStatus, 'nf_error'); } }); } } window.onload=function() { SetCookieValue("statvisible", <?php echo $detail_opts['statvisible'] ? 1 : 0; ?> ); var curdate = new Date(); GMToffset = <?php echo $GMToffset; ?> + curdate.getTimezoneOffset() * 60; CursorMode = <?php echo intval($detail_opts['cursor_mode']); ?> ; if ( CursorMode == 0 ) SlotSelectInit(<?php echo preg_replace('/[,\\)]/', '', Util::htmlentities($_SESSION['tstart'])) . ", " . preg_replace('/[,\\)]/', '', Util::htmlentities($_SESSION['tend'])) . ", " . preg_replace('/[,\\)]/', '', Util::htmlentities($_SESSION['profileinfo']['tstart'])) . ", " . preg_replace('/[,\\)]/', '', Util::htmlentities($_SESSION['tleft'])) . ",576, {$RRDoffset}"; ?> ); else WSelectInit(<?php echo preg_replace('/[,\\)]/', '', Util::htmlentities($_SESSION['tstart'])) . ", " . preg_replace('/[,\\)]/', '', Util::htmlentities($_SESSION['tend'])) . ", " . preg_replace('/[,\\)]/', '', Util::htmlentities($_SESSION['profileinfo']['tstart'])) . ", " . preg_replace('/[,\\)]/', '', Util::htmlentities($_SESSION['tleft'])) . ", " . preg_replace('/[,\\)]/', '', Util::htmlentities($_SESSION['tright'])) . ",576, {$RRDoffset}"; ?> ); <?php if (array_key_exists('anchor', $_SESSION)) { print "location.hash='" . Util::htmlentities($_SESSION['anchor']) . "';"; unset($_SESSION['anchor']); } ?> } </script> <?php $db_aux->close($conn_aux); }
function Process_stat_tab($tab_changed, $profile_changed) { // the default display page - the profile stats $_SESSION['display'] = 'default'; // if it's a new profile, only admin tasks make sense // no refresh if ($_SESSION['profileinfo']['status'] == 'new') { $_SESSION['tablock'] = "A new profile needs to be completed first."; } else { unset($_SESSION['tablock']); } if (isset($_COOKIE['extended_channellist'])) { $_POST['extended_channellist'] = $_COOKIE['extended_channellist']; } $parse_opts = array("extended_channellist" => array("required" => 0, "default" => 1, "allow_null" => 0, "match" => array(0, 1), "validate" => NULL)); list($form_data, $has_errors) = ParseForm($parse_opts); $_COOKIE['extended_channellist'] = $form_data['extended_channellist']; // just display profile status if ($tab_changed || $profile_changed) { unset($_SESSION['form_data']); return; } // Delete this profile - process confirmed action if (array_key_exists('deleteprofile_x', $_POST)) { $parse_opts = array("switch" => array("required" => 1, "default" => NULL, "allow_null" => 0, "match" => "/^[A-Za-z0-9\\.][A-Za-z0-9\\-+_\\/]+\$/", "validate" => "profile_exists_validate", "must_exist" => 1)); list($form_data, $has_errors) = ParseForm($parse_opts); if ($has_errors > 0) { return; } if ($form_data['switch'] != $_SESSION['profileswitch']) { SetMessage('error', "Profile to delete is not current profile"); return; } // Do the work $cmd_opts['profile'] = $_SESSION['profileswitch']; if (array_key_exists('pid', $_SESSION)) { $cmd_opts['pid'] = $_SESSION['pid']; } $cmd_out = nfsend_query("delete-profile", $cmd_opts, 0); if (is_array($cmd_out)) { SetMessage('info', "Profile '" . $cmd_opts['profile'] . "' deleted"); unset($_SESSION['ProfileList']); $profiles = GetProfiles(); // as current profile no longer exists, switch to 'live' $_SESSION['profile'] = 'live'; $_SESSION['profilegroup'] = '.'; $_SESSION['profileswitch'] = './live'; $profileinfo = ReadProfile($_SESSION['profileswitch']); $_SESSION['profileinfo'] = $profileinfo; } // else errors are displayed anyway - nothing to do return; } // Cancel building the profile if (array_key_exists('cancelbuild_x', $_POST)) { $parse_opts = array("switch" => array("required" => 1, "default" => NULL, "allow_null" => 0, "match" => "/^[A-Za-z0-9\\.][A-Za-z0-9\\-+_\\/]+\$/", "validate" => "profile_exists_validate", "must_exist" => 1)); list($form_data, $has_errors) = ParseForm($parse_opts); if ($has_errors > 0) { return; } if ($form_data['switch'] != $_SESSION['profileswitch']) { SetMessage('error', "Profile to delete is not current profile"); return; } // Do the work $cmd_opts['profile'] = $_SESSION['profileswitch']; $cmd_out = nfsend_query("cancel-profile", $cmd_opts, 0); if (is_array($cmd_out)) { SetMessage('info', "Building profile '" . $cmd_opts['profile'] . "' canceled"); $profiles = GetProfiles(); $_SESSION['cancel-inprogress'] = 1; } // else errors are displayed anyway - nothing to do $_SESSION['refresh'] = 5; return; } // put profile into another group? if (array_key_exists('regroup', $_POST)) { if (!array_key_exists('groupselect', $_POST) || !array_key_exists('profilegroup', $_POST)) { SetMessage('error', "Missing parameters"); return; } $_group = Util::htmlentities($_POST['groupselect']); if ($_group == '(nogroup)') { $_group = '.'; } else { if ($_group == 'New group ...') { $_group = Util::htmlentities($_POST['profilegroup']); } } if ($_group != '.' && !preg_match("/^[A-Za-z0-9][A-Za-z0-9\\-+_]+\$/", $_group)) { SetMessage('error', "Illegal characters in group name '{$_group}'"); return; } else { $cmd_opts['profile'] = $_SESSION['profile']; $cmd_opts['profilegroup'] = $_SESSION['profilegroup']; $cmd_opts['newgroup'] = $_group; } if ($cmd_opts['profilegroup'] == $cmd_opts['newgroup']) { // nothing changed return; } // Do the work $cmd_out = nfsend_query("modify-profile", $cmd_opts, 0); if (is_array($cmd_out)) { // update new info in SESSION $_SESSION['profilegroup'] = $cmd_opts['newgroup']; $_SESSION['profileswitch'] = $cmd_opts['newgroup'] . '/' . $_SESSION['profile']; $profileinfo = ReadProfile($_SESSION['profileswitch']); $_SESSION['profileinfo'] = $profileinfo; unset($_SESSION['ProfileList']); $profiles = GetProfiles(); } // else errors are displayed anyway - nothing to do return; } // Edit a profile if (array_key_exists('edit', $_POST)) { $cmd_opts = array(); if (array_key_exists('profile_maxsize', $_POST)) { $_tmp = ParseMaxSize($_POST['profile_maxsize']); if (strlen($_tmp) > 0) { $cmd_opts['maxsize'] = $_tmp; } else { SetMessage('warning', "Invalid value for maxsize"); } } if (array_key_exists('profile_expire', $_POST)) { $_tmp = ParseExpire($_POST['profile_expire']); if ($_tmp >= 0) { $cmd_opts['expire'] = $_tmp; } else { SetMessage('warning', "Invalid value for expire"); } } if (array_key_exists('description', $_POST)) { $_tmp = preg_replace("/\r/", '', $_POST['description']); if (!get_magic_quotes_gpc()) { $description = addslashes($_tmp); } else { $description = $_tmp; } $cmd_opts['description'] = explode("\n", $description); } if (array_key_exists('profile_type', $_POST)) { $_tmp = $_POST['profile_type']; if (!is_numeric($_tmp) || $_tmp > 6) { SetMessage('warning', "Invalid value for profile_type"); } else { if ($_SESSION['profileinfo']['type'] != $_tmp) { $cmd_opts['profile_type'] = $_tmp; } } } if (count(array_keys($cmd_opts)) > 0) { $cmd_opts['profile'] = $_SESSION['profileswitch']; // Do the work $cmd_out = nfsend_query("modify-profile", $cmd_opts, 0); if (is_array($cmd_out)) { $profileinfo = ReadProfile($_SESSION['profileswitch']); $_SESSION['profileinfo'] = $profileinfo; } } return; } // Cancel an edit or add a channel dialog if (array_key_exists('edit_channel_cancel', $_POST) || array_key_exists('add_channel_cancel', $_POST)) { // nothing to do - default will do return; } // Add a new channel - provide add dialog if (array_key_exists('add_channel_x', $_POST)) { $_POST['add_channel'] = $_POST['add_channel_x']; } if (array_key_exists('add_channel', $_POST)) { $_SESSION['display'] = 'add_channel'; $_SESSION['refresh'] = 0; return; } // edit a channel - provide edit dialog if (array_key_exists('edit_channel', $_POST)) { $parse_opts = array("edit_channel" => array("required" => 1, "default" => NULL, "allow_null" => 0, "match" => "/^[A-Za-z0-9][A-Za-z0-9\\-+_]+\$/", "validate" => NULL)); list($form_data, $has_errors) = ParseForm($parse_opts); $form_data['profileswitch'] = $_SESSION['profileswitch']; if ($has_errors > 0) { return; } $_channel = $form_data['edit_channel']; if (!array_key_exists($_channel, $_SESSION['profileinfo']['channel'])) { SetMessage('error', "Channel '{$_channel}' does not exists in profile '" . $form_data['profile'] . "'"); return; } $_SESSION['form_data'] = $form_data; $_SESSION['refresh'] = 0; $_SESSION['display'] = 'edit_channel'; return; } // edit or add a channel? - process commited form entries if (array_key_exists('edit_channel_commit', $_POST) || array_key_exists('add_channel_commit', $_POST)) { if (array_key_exists('edit_channel_commit', $_POST)) { $_display = "edit_channel"; } else { $_display = "add_channel"; } $_SESSION['refresh'] = 0; $parse_opts = array("name" => array("required" => 1, "default" => NULL, "allow_null" => 0, "match" => "/^[A-Za-z0-9][A-Za-z0-9\\-+_]*\$/", "validate" => NULL), "colour" => array("required" => 1, "default" => NULL, "allow_null" => 0, "match" => "/^#[0-9a-f]{6}/i", "validate" => NULL), "sign" => array("required" => 1, "default" => '+', "allow_null" => 0, "match" => array('+', '-'), "validate" => NULL), "order" => array("required" => 1, "default" => 1, "allow_null" => 0, "match" => "/^[0-9]{1,2}/", "validate" => NULL), "filter" => array("required" => 1, "default" => NULL, "allow_null" => 0, "match" => "/^[\\s!-~]+\$/", "validate" => 'filter_validate'), "configured" => array("required" => 1, "default" => array(), "allow_null" => 0, "match" => NULL, "validate" => 'channel_validate')); list($form_data, $has_errors) = ParseForm($parse_opts); $form_data['profile'] = $_SESSION['profile']; $form_data['profilegroup'] = $_SESSION['profilegroup']; // additional checks if (!is_null($form_data['name'])) { $_channel = $form_data['name']; if ($_display == "edit_channel") { // verify channel in existing profile if (!array_key_exists($_channel, $_SESSION['profileinfo']['channel'])) { SetMessage('error', "Channel '{$_channel}' does not exist in profile '{$profile}'"); $has_errors = 1; } } else { // verify channel name for new channel if (array_key_exists($_channel, $_SESSION['profileinfo']['channel'])) { SetMessage('error', "Channel '{$_channel}' already exist in profile '" . $_SESSION['profile'] . "'"); $has_errors = 1; } } } // else error already reported by ParseForm // must not change the sourcelist or the filter of a channel in profile 'live' if ($form_data['profile'] == 'live') { unset($form_data['sourcelist']); unset($form_data['filter']); } else { $form_data['sourcelist'] = implode('|', $form_data['configured']); } unset($form_data['configured']); $_SESSION['form_data'] = $form_data; if ($has_errors > 0) { $_SESSION['display'] = $_display; return; } // Do the work $command = $_display == 'add_channel' ? 'add-channel' : 'modify-channel'; // make sure parameters match for nfsend $form_data['channel'] = $form_data['name']; unset($form_data['name']); $cmd_out = nfsend_query($command, $form_data, 0); if (is_array($cmd_out)) { $profileinfo = ReadProfile($_SESSION['profileswitch']); $_SESSION['profileinfo'] = $profileinfo; unset($_SESSION['form_data']); } else { // fishy something went wrong $_SESSION['display'] = $_display; } return; } // delete a channel if (array_key_exists('delete_channel_commit_x', $_POST)) { if (!array_key_exists('name', $_POST)) { SetMessage('error', "Missing channel name"); return; } $profile = $_SESSION['profile']; $_channelname = $_POST['name']; if (!array_key_exists($_channelname, $_SESSION['profileinfo']['channel'])) { SetMessage('error', "Channel '{$_tmp}' does not exist in profile '{$profile}'"); return; } // do the work $cmd_opts['profile'] = $_SESSION['profileswitch']; $cmd_opts['channel'] = $_channelname; $cmd_out = nfsend_query("delete-channel", $cmd_opts, 0); if (is_array($cmd_out)) { $profileinfo = ReadProfile($_SESSION['profileswitch']); $_SESSION['profileinfo'] = $profileinfo; } return; } // Cancel a new profile dialog if (array_key_exists('new_profile_cancel', $_POST)) { if (array_key_exists("new_profile", $_SESSION)) { unset($_SESSION['new_profile']); } // default will do return; } // create a new profile - provide the new profile dialog // this input comes directly from the profile select menu if (array_key_exists('new_profile', $_SESSION)) { unset($_SESSION['new_profile']); $_SESSION['display'] = 'new_profile'; return; } // create a new profile - process commited form if (array_key_exists('new_profile_commit', $_POST)) { $parse_opts = array("newprofileswitch" => array("required" => 1, "default" => NULL, "allow_null" => 0, "match" => "/^[A-Za-z0-9\\.][A-Za-z0-9\\-+_\\/]+\$/", "validate" => "profile_exists_validate", "must_exist" => 0), "tstart" => array("required" => 1, "default" => NULL, "allow_null" => 1, "match" => "/^[0-9]+[0-9\\-]+[0-9]+\$/", "validate" => "date_time_validate"), "tend" => array("required" => 1, "default" => NULL, "allow_null" => 1, "match" => "/^[0-9]+[0-9\\-]+[0-9]+\$/", "validate" => "date_time_validate"), "channel_wizard" => array("required" => 1, "default" => NULL, "allow_null" => 0, "match" => array('classic', 'individual'), "validate" => NULL), "expire" => array("required" => 0, "default" => 0, "allow_null" => 0, "match" => "/^[\\s!-~]+\$/", "validate" => 'expire_validate'), "maxsize" => array("required" => 0, "default" => 0, "allow_null" => 0, "match" => "/^[\\s!-~]+\$/", "validate" => 'maxsize_validate'), "description" => array("required" => 0, "default" => NULL, "allow_null" => 1, "match" => "/^[\\s!-~]+\$/", "validate" => 'description_validate'), "filter" => array("required" => 0, "default" => NULL, "allow_null" => 1, "match" => "/^[\\s!-~]+\$/", "validate" => 'filter_validate'), "channel" => array("required" => 0, "default" => array(), "allow_null" => 1, "match" => NULL, "validate" => 'channel_validate'), "shadow" => array("required" => 1, "default" => 1, "allow_null" => 1, "match" => array(0, 1), "validate" => NULL), "num_channels" => array("required" => 0, "default" => 0, "allow_null" => 1, "match" => "/^[0-9]{1,3}\$/", "validate" => NULL)); list($form_data, $has_errors) = ParseForm($parse_opts); if (preg_match("/^(.+)\\/(.+)/", $form_data['newprofileswitch'], $matches)) { $_profilegroup = $matches[1]; $_profilename = $matches[2]; $form_data['profileswitch'] = $form_data['newprofileswitch']; $form_data['profile'] = $_profilename; $form_data['profilegroup'] = $_profilegroup; unset($form_data['newprofileswitch']); } else { $has_errors = 1; } // additional checks if (!is_null($form_data['tend']) && !is_null($form_data['tstart']) && $form_data['tend'] < $form_data['tstart']) { $ts = UNIX2DISPLAY($form_data['tstart']); $te = UNIX2DISPLAY($form_data['tend']); $form_data['tstart'] = NULL; $form_data['tend'] = NULL; SetMessage('error', "Profile end time '{$te}' earlier then Start time '{$ts}'"); $has_errors = 1; } if (!is_null($form_data['tend']) && is_null($form_data['tstart'])) { $te = UNIX2DISPLAY($form_data['tend']); SetMessage('error', "Profile has end time '{$te}', but no start time set"); $has_errors = 1; } if ($form_data['channel_wizard'] == 'classic') { if (is_null($form_data['filter']) || count($form_data['channel']) == 0) { SetMessage('error', "A classic profile needs a valid filter and at least one selected channel"); $has_errors = 1; } } if ($has_errors > 0) { $_SESSION['form_data'] = $form_data; $_SESSION['display'] = 'new_profile'; $_SESSION['refresh'] = 0; return; } // do the work if (array_key_exists('channel_wizard', $form_data)) { $type = $form_data['channel_wizard']; if (NewProfileCreate($form_data, $type) == TRUE) { // update NfSen to include the new profile unset($_SESSION['ProfileList']); $profiles = GetProfiles(); // switch to new profile $_SESSION['profileswitch'] = $form_data['profileswitch']; $_SESSION['profile'] = $form_data['profile']; $_SESSION['profilegroup'] = $form_data['profilegroup']; $_SESSION['profileinfo'] = ReadProfile($_SESSION['profileswitch']); SetMessage('info', "Profile '" . $form_data['profile'] . "' created"); // if ( $_SESSION['profileinfo']['type'] == 1 && $_SESSION['profileinfo']['status'] != 'new' ) if ($_SESSION['profileinfo']['tstart'] < $_SESSION['profileinfo']['tend']) { $_SESSION['refresh'] = 5; } } else { $_SESSION['form_data'] = $form_data; $_SESSION['display'] = 'new_profile'; } } return; } if (array_key_exists('commit_profile_x', $_POST)) { if ($_SESSION['profileinfo']['status'] != 'new' && $_SESSION['profileinfo']['status'] != 'stalled') { SetMessage('error', "Can not commit a profile, not in status 'new or stalled'"); return; } // Do the work // if it fails, the default will do if (NewProfileCommit($_SESSION['profileswitch'])) { $profileinfo = ReadProfile($_SESSION['profileswitch']); $_SESSION['profileinfo'] = $profileinfo; unset($_SESSION['tablock']); if ($_SESSION['profileinfo']['tstart'] < $_SESSION['profileinfo']['tend']) { $_SESSION['refresh'] = 5; } } return; } // refresh time if profile building in progress if (preg_match("/built/", $_SESSION['profileinfo']['status'])) { $_SESSION['refresh'] = 5; } }
function DisplayDetails() { global $self; global $DisplayOrder; global $TypeOrder; global $WinSizeLabels; global $RRDoffset; global $GMToffset; global $TZname; require_once 'classes/Session.inc'; require_once 'classes/Sensor.inc'; require_once 'ossim_db.inc'; $db_aux = new ossim_db(); $conn_aux = $db_aux->connect(); $sensors_list = Sensor::get_list($conn_aux); $db_aux->close($conn_aux); ?> <script language="Javascript" src="js/detail.js" type="text/javascript"> </script> <?php $tright = UNIX2DISPLAY($_SESSION['tright']); $tleft = UNIX2DISPLAY($_SESSION['tleft']); $profile = $_SESSION['profile']; $profilegroup = $_SESSION['profilegroup']; $detail_opts = $_SESSION['detail_opts']; $channels = array_keys($_SESSION['profileinfo']['channel']); $is_shadow = ($_SESSION['profileinfo']['type'] & 4) > 0; print "<h3>" . _("Profile") . ": <font size='+1'>{$profile}</font></h3>\n"; $_tmp = explode('!', $detail_opts['channellist']); $graph_channels = count($_tmp) == 0 ? '@EMPTY' : implode(":", $_tmp); ?> <table style='font-size:14px;font-weight:bold;width:100%'> <tr> <?php for ($i = 1; $i < count($DisplayOrder); $i++) { $label = $DisplayOrder[$i]; if ($label == $detail_opts['proto']) { $label = 'any'; } print "<td>"; print $label; print "</td>\n"; } print "<td style='font-size:14px;font-weight:bold'>" . gettext("Profile info:") . "</td>\n"; // Empty right element print "</tr><tr>\n"; for ($i = 1; $i < count($DisplayOrder); $i++) { $label = $DisplayOrder[$i]; if ($label == $detail_opts['proto']) { $label = 'any'; } print "<td>\n"; $arg = implode(" ", array($graph_channels, $label, $detail_opts['type'], $_SESSION['profileinfo']['tstart'], $_SESSION['tstart'], $_SESSION['tend'], $_SESSION['tleft'], $_SESSION['tright'], 288, 100, 1, $detail_opts['logscale'], $detail_opts['linegraph'])); $arg = urlencode($arg); print "<a href='{$self}?proto={$label}'> " . "<img src=rrdgraph.php?cmd=get-detailsgraph&profile=" . $_SESSION['profileswitch'] . "&arg={$arg} border='0' width='165' height='81' alt='{$label}'></a>\n"; print "</td>\n"; } print "<td style='vertical-align: bottom;'>\n"; $str = strftime("%b %d %Y - %H:%M", $_SESSION['profileinfo']['tstart']); $expire = $_SESSION['profileinfo']['expire']; if ($expire == 0) { $expire = 'never'; } else { $d = (int) ($expire / 24); $h = $expire % 24; $d_ext = $d == 1 ? '' : 's'; $h_ext = $h == 1 ? '' : 's'; if ($d) { $expire = "{$d} day{$d_ext} {$h} hour{$h_ext}"; } else { $expire = "{$h} hour{$h_ext}"; } } $maxsize = ScaleBytes($_SESSION['profileinfo']['maxsize'], 1, 1024.0); if ($maxsize == 0) { $maxsize = 'unlimited'; } print "<table style='font-size:12px;font-weight:bold;border:none;width:100%'>\n"; switch ($_SESSION['profileinfo']['type'] & 3) { case 0: $type = 'live'; break; case 1: $type = 'history'; break; case 2: $type = 'continuous'; break; default: $type = 'unknown'; } $type .= $is_shadow ? ' / shadow' : ''; print "<tr><td>" . _("Type") . ":</td><td>{$type}</td></tr>"; print "<tr><td>" . _("Max") . ":</td><td>{$maxsize}</td></tr>"; print "<tr><td>" . _("Exp") . ":</td><td>{$expire}</td></tr>"; print "<tr><td>" . _("Start") . ":</td><td>{$str} {$TZname}</td></tr>\n"; $str = strftime("%b %d %Y - %H:%M", $_SESSION['profileinfo']['tend']); print "<tr><td style='border:none'>" . _("End") . ":</td><td style='border:none'>{$str} {$TZname}</td></tr>\n"; print "</table>\n"; print "</td>\n"; $arg = implode(" ", array($graph_channels, $detail_opts['proto'], $detail_opts['type'], $_SESSION['profileinfo']['tstart'], $_SESSION['tstart'], $_SESSION['tend'], $_SESSION['tleft'], $_SESSION['tright'], 576, 200, 0, $detail_opts['logscale'], $detail_opts['linegraph'])); $arg = urlencode($arg); ?> </tr> <tr> <td colspan='4' align="left" valign="top"> <img id='MainGraph' style='position:relative; top:0px; left:0px;' onclick="DragCursor.set(event);" src=rrdgraph.php?cmd=get-detailsgraph&profile=<?php echo $_SESSION['profileswitch']; ?> &arg=<?php echo $arg; ?> border='0' alt='<?php echo _("main-graph"); ?> '> <img id="CursorDragHandle" style="position:absolute;display:none; " src="icons/cursor-line.png" alt="<?php echo _("Line Cursor"); ?> "> <img id="StartDragHandle" style="position:absolute;display:none" src="icons/cursor-start.png" alt="<?php echo _("Start Cursor"); ?> "> <div id="StartLine" style="position: absolute;display:none; width: 1px; height: 200px; background-color: black;"></div> <div id="SpanBox" style="position:absolute;display:none; height: 200px; background-color: #B1FFA1; filter:alpha(opacity=40); opacity:.40;"></div> <div id="StopLine" style="position: absolute;display:none; width: 1px; height: 200px; background-color: black;"></div> <img id="StopDragHandle" style="position:absolute;display:none" src="icons/cursor-stop.png" alt="<?php echo _("Stop Cursor"); ?> "> <form style="display:inline;" name="slotselectform" id="slotselectform" action="<?php echo $self; ?> " method="POST"> <input type="hidden" name="cursor_mode" id="cursor_mode" value=""> <input type="hidden" name="tleft" id="tleft" value=""> <input type="hidden" name="tright" id="tright" value=""> </form> </td> <td style="vertical-align: bottom;"> <table style="margin-bottom:1pt;border:none;width:100%"> <tr> <td><span style='font-size:14px;font-weight:bold;margin-bottom:1pt'> t<SUB><?php echo _("start"); ?> </SUB> </span> </td> <td style="font-size:16px;color:#555555;"> <!-- input type="text" name="box_tleft" id="box_tleft" value="" SIZE="16" MAXLENGTH="16" style='font-size:10px;' readonly --> <b id='box_tleft'>- <?php echo _("update"); ?> -</b> </td> </tr><tr> <td><span style='font-size:14px;font-weight:bold;margin-bottom:1pt'> t<SUB><?php echo _("end"); ?> </SUB> </span> </td> <td style="font-size:16px;color:#555555;"> <!-- input type="text" name="box_tright" id="box_tright" value="" SIZE="16" MAXLENGTH="16" style='font-size:10px;' readonly --> <b id='box_tright'>- <?php echo _("update"); ?> -</b> </td> </tr> </table> <table style='font-size:14px;font-weight:bold;border:none;width:100%'> <?php for ($i = 1; $i < count($TypeOrder); $i++) { $label = $TypeOrder[$i]; if ($label == $detail_opts['type']) { $label = 'flows'; } // Make first letter uppercase of label to print $printlabel = strtoupper($label[0]) . substr($label, 1); print "<tr><td>" . gettext($printlabel) . "</td></tr>\n"; print "<tr><td style='border:none'>\n"; $arg = implode(" ", array($graph_channels, $detail_opts['proto'], $label, $_SESSION['profileinfo']['tstart'], $_SESSION['tstart'], $_SESSION['tend'], $_SESSION['tleft'], $_SESSION['tright'], 288, 100, 1, $detail_opts['logscale'], $detail_opts['linegraph'])); $arg = urlencode($arg); print "<a href='{$self}?type={$label}'> " . "<img src=rrdgraph.php?cmd=get-detailsgraph&profile=" . $_SESSION['profileswitch'] . "&arg={$arg} border='0' width='165' height='81' alt='{$label}'></a>"; print "</td></tr>\n"; } ?> </table> </td> </tr> <tr> <td colspan='4' style="border:none"> <table border="0" style='width: 100%;margin:0pt;;border:none;width:100%'> <tr> <td style="border:none"> <?php echo _("Select"); ?> <select name="CursorMode" id="ModeSelector" onchange="SetCursorMode(<?php echo $_SESSION['tstart'] . ", " . $_SESSION['tend'] . ", " . $_SESSION['profileinfo']['tstart'] . ", " . $_SESSION['tleft'] . ", " . $_SESSION['tright'] . ",576, {$RRDoffset}"; ?> )" size=1> <?php if ($detail_opts['cursor_mode'] == 1) { print "<option value='0'>" . _("Single Timeslot") . "\n"; print "<option value='1' selected>" . _("Time Window") . "\n"; } else { print "<option value='0' selected>" . _("Single Timeslot") . "\n"; print "<option value='1'>" . _("Time Window") . "\n"; } ?> </select> </td> <td style="text-align: right;border:none"> <?php echo _("Display"); ?> : <form action="<?php echo $self; ?> " style="display:inline;" method="POST"> <select name='wsize' onchange='this.form.submit();' size=1> <?php $size_label = 'unknown'; for ($i = 0; $i < count($WinSizeLabels); $i++) { if ($i == $detail_opts['wsize']) { print "<option value='{$i}' selected>" . $WinSizeLabels[$i] . "\n"; $size_label = $WinSizeLabels[$i]; } else { print "<option value='{$i}'>" . $WinSizeLabels[$i] . "\n"; } } $status = $detail_opts['cursor_mode'] == 0 && !$is_shadow ? '' : 'disabled'; $peak_search_label = $status == '' ? _("Search Peak") : _("Peak search not available"); ?> </select> <input class="lbutton" name="adjust" value=" << " type="submit" title="<?php echo _("Back"); ?> <?php echo $size_label; ?> "> <input class="lbutton" name="adjust" value=" < " type="submit" title="<?php echo _("Previous time slot"); ?> "> <input class="lbutton" name="adjust" value=" | " type="submit" title="<?php echo _("Center cursor"); ?> "> <input class="lbutton" name="adjust" value=" ^ " type="submit" <?php echo $status; ?> title="<?php echo $peak_search_label; ?> "> <input class="lbutton" name="adjust" value=" > " type="submit" title="<?php echo _("Next time slot"); ?> "> <input class="lbutton" name="adjust" value=" >> " type="submit" title="<?php echo _("Forward"); ?> <?php echo $size_label; ?> "> <input class="lbutton" name="adjust" value=" >| " type="submit" title="<?php echo _("Goto last slot"); ?> "> </form> </td> </tr> </table> </td> <td style="border:none"> <form action="<?php echo $self; ?> " method="POST"> <table style="border:none;width:100%"> <tr> <td style="border:none"> <input type="radio" onClick='this.form.submit();' name="logscale" value="0" <?php if ($detail_opts['logscale'] == 0) { print "checked"; } ?> ><?php echo _("Lin Scale"); ?> </td> <td style="border:none"> <input type="radio" onClick='this.form.submit();' name="linegraph" value="0" <?php if ($detail_opts['linegraph'] == 0) { print "checked"; } ?> ><?php echo _("Stacked Graph"); ?> </td> </tr> <tr> <td style="border:none"> <input type="radio" onClick='this.form.submit();' name="logscale" value="1" <?php if ($detail_opts['logscale'] == 1) { print "checked"; } ?> ><?php echo _("Log Scale"); ?> </td> <td style="border:none"> <input type="radio" onClick='this.form.submit();' name="linegraph" value="1" <?php if ($detail_opts['linegraph'] == 1) { print "checked"; } ?> ><?php echo _("Line Graph"); ?> </td> </tr> </table> </form> </td> </tr><tr> <td colspan='4'></td> <td></td> </tr> </table> <?php if ($_SESSION['tleft'] == $_SESSION['tright']) { $tslot = "timeslot " . strftime("%b %d %Y - %H:%M", $_SESSION['tleft']); } else { $tslot = "timeslot " . strftime("%b %d %Y - %H:%M", $_SESSION['tleft']) . " - " . strftime("%b %d %Y - %H:%M", $_SESSION['tright']); } $num_channels = count(array_keys($_SESSION['profileinfo']['channel'])); $proto_index = 1; foreach ($DisplayOrder as $p) { if ($detail_opts['proto'] == $p) { break; } $proto_index++; } $statpref = explode(':', $detail_opts['statpref']); $max_colspan = 0; for ($i = 0; $i < count($statpref); $i++) { $pref = $statpref[$i]; if ($pref == 0) { $arrow_style[] = ''; $arrow_style[] = 'style="display:none;"'; $colspan[] = 5; $max_colspan += 5; } else { $arrow_style[] = 'style="display:none;"'; $arrow_style[] = ''; $statpref[$i] = $proto_index; $colspan[] = 1; $max_colspan += 1; } } $_i = 0; if ($detail_opts['statvisible'] == 1) { $stattable_style = ''; $down_arrow_style = ''; $right_arrow_style = 'style="display:none"'; } else { $stattable_style = 'display:none;'; $down_arrow_style = 'style="display:none"'; $right_arrow_style = ''; } ?> <br><br><b> <a href="#null" onClick="ShowHideStat();" title="<?php echo _("Hide Statistic"); ?> " ><IMG SRC="icons/arrow.yellow.down.png" name="flows" id="stat_arrow_down" border="0" <?php echo $down_arrow_style; ?> align="left" alt="<?php echo _("Hide stat table"); ?> "></a> <a href="#null" onClick="ShowHideStat();" title="<?php echo _("Show Statistic"); ?> " ><IMG SRC="icons/arrow.yellow.right.png" name="flows" id="stat_arrow_right" border="0" <?php echo $right_arrow_style; ?> align="left" alt="<?php echo _("Show stat table"); ?> "></a> Statistics <?php echo $tslot; ?> </b> <form action="<?php echo $self; ?> " method="POST" id="statsform"> <input type="hidden" name="srctrigger" value="src"> <table id="stattable" style='font-size:14px;font-weight:bold;<?php echo $stattable_style; ?> ;border:none;width:100%'> <tr align='center'> <td class='theader' colspan="2"><?php echo _("Channel"); ?> :</td> <td class='theader' id="label0" colspan='<?php echo $colspan[0]; ?> '> <a href="#null" onClick="CollapseExpandStat(<?php echo $num_channels; ?> , 0, <?php echo $proto_index; ?> );" title="<?php echo _("Collapse"); ?> " ><IMG SRC="icons/arrow.blue.down.png" name="flows" id="arrow0_down" border="0" <?php echo $arrow_style[$_i++]; ?> align="left" alt="<?php echo _("collapse"); ?> "></a> <a href="#null" onClick="CollapseExpandStat(<?php echo $num_channels; ?> , 0, <?php echo $proto_index; ?> );" title="<?php echo _("Expand"); ?> " ><IMG SRC="icons/arrow.blue.right.png" name="flows" id="arrow0_right" border="0" <?php echo $arrow_style[$_i++]; ?> align="left" alt="<?php echo _("collapse"); ?> "></a><?php echo _("Flows"); ?> : </td> <td class='theader' id="label1" colspan='<?php echo $colspan[1]; ?> '> <a href="#null" onClick="CollapseExpandStat(<?php echo $num_channels; ?> , 1, <?php echo $proto_index; ?> );" title="<?php echo _("Collapse"); ?> " ><IMG SRC="icons/arrow.blue.down.png" name="flows" id="arrow1_down" border="0" <?php echo $arrow_style[$_i++]; ?> align="left" alt="<?php echo _("collapse"); ?> "></a> <a href="#null" onClick="CollapseExpandStat(<?php echo $num_channels; ?> , 1, <?php echo $proto_index; ?> );" title="<?php echo _("Expand"); ?> " ><IMG SRC="icons/arrow.blue.right.png" name="flows" id="arrow1_right" border="0" <?php echo $arrow_style[$_i++]; ?> align="left" alt="<?php echo _("collapse"); ?> "></a><?php echo _("Packets"); ?> : </td> <td class='theader' id="label2" colspan='<?php echo $colspan[2]; ?> '> <a href="#null" onClick="CollapseExpandStat(<?php echo $num_channels; ?> , 2, <?php echo $proto_index; ?> );" title="<?php echo _("Collapse"); ?> " ><IMG SRC="icons/arrow.blue.down.png" name="flows" id="arrow2_down" border="0" <?php echo $arrow_style[$_i++]; ?> align="left" alt="<?php echo _("collapse"); ?> "></a> <a href="#null" onClick="CollapseExpandStat(<?php echo $num_channels; ?> , 2, <?php echo $proto_index; ?> );" title="<?php echo _("Expand"); ?> " ><IMG SRC="icons/arrow.blue.right.png" name="flows" id="arrow2_right" border="0" <?php echo $arrow_style[$_i++]; ?> align="left" alt="<?php echo _("collapse"); ?> "></a><?php echo _("Traffic"); ?> : </td> </tr> <tr> <th colspan="2"> </td> <?php for ($i = 0; $i < 3; $i++) { $col = 1; foreach (array(gettext("all:"), 'tcp:', 'udp:', 'icmp:', gettext("other:")) as $_type) { if ($statpref[$i] == 0) { $_style = ''; } else { if ($statpref[$i] == $col) { $_style = ''; } else { $_style = 'style="display:none;"'; } } print "<th id='id.0.{$i}.{$col}' {$_style}>{$_type}</td>"; $col++; } } print "</tr>\n"; // for simplified testing foreach (explode('!', $detail_opts['channellist']) as $channel) { $_SelectedChannels[$channel] = 1; } $row = 1; foreach (array_keys($_SESSION['profileinfo']['channel']) as $channel) { $has_perm = 0; foreach ($sensors_list as $s) { if ($channel == $s->get_name()) { $has_perm = 1; } } if (Session::am_i_admin()) { $has_perm = 1; } print "<tr>\n"; # channel exists in profile $statinfo = ReadStat($profile, $profilegroup, $channel); $rateval = 1; if ($detail_opts['ratescale'] == 1) { $rateval = $_SESSION['tright'] - $_SESSION['tleft'] + 300; } $bgcolour = "bgcolor='" . $_SESSION['profileinfo']['channel'][$channel]['colour'] . "'"; print "<td {$bgcolour} style='width:10px'></td>\n"; if (!$has_perm) { print "<td align=left><input type='checkbox' name='{$channel}' value='{$channel}' onClick='this.form.submit();' disabled><font style='color:gray'>{$channel}</font>  </td>\n"; $cellcolour = ''; } elseif (array_key_exists($channel, $_SelectedChannels)) { print "<td align=left><input type='checkbox' name='{$channel}' value='{$channel}' onClick='this.form.submit();' checked>{$channel}  </td>\n"; $cellcolour = "bgcolor='#f2f2f2'"; } else { print "<td align=left><input type='checkbox' name='{$channel}' value='{$channel}' onClick='this.form.submit();'>{$channel}  </td>\n"; $cellcolour = ''; } # print flows $i = 0; $col = 1; $mark_char = ($_SESSION['profileinfo']['type'] & 4) > 0 ? 'S' : 'x'; foreach (array('', '_tcp', '_udp', '_icmp', '_other') as $_type) { if ($statinfo) { $_val = ScaleValue($statinfo['flows' . $_type], $rateval); } else { $_val = $mark_char; } if ($statpref[$i] == 0) { $_style = ''; } else { if ($statpref[$i] == $col) { $_style = ''; } else { $_style = 'style="display:none;"'; } } print "<td {$cellcolour} id='id.{$row}.{$i}.{$col}' {$_style} align=right>{$_val} </td>"; $col++; } # print packets $i = 1; $col = 1; foreach (array('', '_tcp', '_udp', '_icmp', '_other') as $_type) { if ($statinfo) { $_val = ScaleValue($statinfo['packets' . $_type], $rateval); } else { $_val = $mark_char; } if ($statpref[$i] == 0) { $_style = ''; } else { if ($statpref[$i] == $col) { $_style = ''; } else { $_style = 'style="display:none;"'; } } print "<td {$cellcolour} id='id.{$row}.{$i}.{$col}' {$_style} align=right>{$_val} </td>"; $col++; } # prints bits $i = 2; $col = 1; foreach (array('', '_tcp', '_udp', '_icmp', '_other') as $_type) { if ($statinfo) { $_val = ScaleBytes($statinfo['traffic' . $_type], $rateval, 1000.0); } else { $_val = $mark_char; } if ($statpref[$i] == 0) { $_style = ''; } else { if ($statpref[$i] == $col) { $_style = ''; } else { $_style = 'style="display:none;"'; } } print "<td {$cellcolour} id='id.{$row}.{$i}.{$col}' {$_style} align=right>{$_val} </td>"; $col++; } print "</tr>\n"; $row++; } ?> <tr><td colspan="2"> <INPUT class="lbutton" TYPE="submit" NAME="MultipleSources" Value="<?php echo _("All"); ?> "> <INPUT class="lbutton" TYPE="submit" NAME="MultipleSources" Value="<?php echo _("None"); ?> "> </td> <td colspan='15' style='text-align: left;'> <?php echo _("Display"); ?> : <input type="radio" onClick='this.form.submit();' name="ratescale" value="0" <?php if ($detail_opts['ratescale'] == 0) { print "checked"; } ?> ><?php echo _("Sum"); ?> <input type="radio" onClick='this.form.submit();' name="ratescale" value="1" <?php if ($detail_opts['ratescale'] == 1) { print "checked"; } ?> ><?php echo _("Rate"); ?> <?php if (!$statinfo) { print "x: " . _("No Data available"); } ?> </td></tr> </table> </form> <script language="Javascript" type="text/javascript"> window.onload=function() { SetCookieValue("statvisible", <?php echo $detail_opts['statvisible'] ? 1 : 0; ?> ); var curdate = new Date(); GMToffset = <?php echo $GMToffset; ?> + curdate.getTimezoneOffset() * 60; CursorMode = <?php echo $detail_opts['cursor_mode']; ?> ; if ( CursorMode == 0 ) SlotSelectInit(<?php echo $_SESSION['tstart'] . ", " . $_SESSION['tend'] . ", " . $_SESSION['profileinfo']['tstart'] . ", " . $_SESSION['tleft'] . ",576, {$RRDoffset}"; ?> ); else WSelectInit(<?php echo $_SESSION['tstart'] . ", " . $_SESSION['tend'] . ", " . $_SESSION['profileinfo']['tstart'] . ", " . $_SESSION['tleft'] . ", " . $_SESSION['tright'] . ",576, {$RRDoffset}"; ?> ); <?php if (array_key_exists('anchor', $_SESSION)) { print "location.hash='" . $_SESSION['anchor'] . "';"; unset($_SESSION['anchor']); } ?> } </script> <?php }