Exemplo n.º 1
0
function ProfileDialog()
{
    global $self;
    global $desc_expire;
    $is_shadow = ($_SESSION['profileinfo']['type'] & 4) > 0;
    $can_edit = $_SESSION['profileinfo']['type'] == 0 || $_SESSION['profileinfo']['type'] == 2;
    if ($_SESSION['profileinfo']['type'] == 0) {
        $type = 'live';
    } else {
        $type = ($_SESSION['profileinfo']['type'] & 3) == 2 ? "Continous" : "History";
        $type .= ($_SESSION['profileinfo']['type'] & 4) > 0 ? ' / shadow' : '';
    }
    $tstart = UNIX2ISO($_SESSION['profileinfo']['tstart']);
    $tend = UNIX2ISO($_SESSION['profileinfo']['tend']);
    $tupdate = UNIX2ISO($_SESSION['profileinfo']['updated']);
    $pattern = "/(\\d{4})(\\d{2})(\\d{2})(\\d{2})(\\d{2})/";
    $replacement = "\$1-\$2-\$3-\$4-\$5";
    $tstart = preg_replace($pattern, $replacement, $tstart);
    $tend = preg_replace($pattern, $replacement, $tend);
    $tupdate = preg_replace($pattern, $replacement, $tupdate);
    $size = ScaleBytes($_SESSION['profileinfo']['size'], 1, 1024.0);
    $maxsize = $_SESSION['profileinfo']['maxsize'] ? ScaleBytes($_SESSION['profileinfo']['maxsize'], 1, 1024.0) : 'unlimited';
    $description = Util::htmlentities(implode("\n", $_SESSION['profileinfo']['description']));
    $status = $_SESSION['profileinfo']['status'];
    $locked = $_SESSION['profileinfo']['locked'] == 1 ? " - locked" : "";
    $opt_delete = $status == 'OK' && $_SESSION['profile'] != 'live';
    $is_live = $_SESSION['profile'] == 'live';
    $can_commit = ($status == 'new' || $status == 'stalled') && count($_SESSION['profileinfo']['channel']) > 0;
    $can_add_channel = $status == 'new' || $status == 'stalled' || $status == 'OK' && ($_SESSION['profileinfo']['type'] & 2) > 0;
    if (preg_match("/built (\\d+\\.{0,1}\\d*)/", $status, $matches)) {
        $progress = $matches[1];
        $opt_cancel = array_key_exists('cancel-inprogress', $_SESSION) ? 0 : 1;
    } else {
        $progress = NULL;
        $opt_cancel = 0;
        if (array_key_exists('cancel-inprogress', $_SESSION)) {
            unset($_SESSION['cancel-inprogress']);
        }
    }
    $expire = ExpireString($_SESSION['profileinfo']['expire']);
    $cmd_out = nfsend_query("get-profilegroups", array(), 0);
    if (is_array($cmd_out)) {
        $profilegroups = $cmd_out['profilegroups'];
    } else {
        $profilegroups = array();
        $profilegroups[] = '.';
    }
    $profilegroups[] = 'New group ...';
    if ($_COOKIE['extended_channellist'] == 1) {
        $style_arrow_down = '';
        $style_arrow_right = 'style="display:none"';
    } else {
        $style_arrow_down = 'style="display:none"';
        $style_arrow_right = '';
    }
    ?>
<div style="margin-top:20px; margin-left:20px;">
<table class="STATTABLE" cellspacing="4"  cellpadding="4">
<tr class="STATTABLE">
    <th class="STATTABLE" colspan='2'>
<?php 
    if ($opt_delete) {
        ?>
	<form style="display:inline;" name="profileform" id="profileform" action="<?php 
        echo $self;
        ?>
" method="POST" onSubmit="return ConfirmDeleteProfile(<?php 
        print '\'' . Util::htmlentities($_SESSION['profile']) . '\', \'' . Util::htmlentities($_SESSION['profilegroup']) . '\'';
        ?>
);">
    	<input type="image" name="deleteprofile" value="<?php 
        echo Util::htmlentities($_SESSION['profileswitch']);
        ?>
" title="Delete this profile" src="icons/trash.png" align="right" >
		<input type="hidden" name="switch" value="<?php 
        echo Util::htmlentities($_SESSION['profileswitch']);
        ?>
" >
	</form>
<?php 
    }
    if ($opt_cancel) {
        ?>
	<form style="display:inline;" name="profileform" id="profileform" action="<?php 
        echo $self;
        ?>
" method="POST" onSubmit="return ConfirmCancelBuild(<?php 
        print '\'' . Util::htmlentities($_SESSION['profile']) . '\', \'' . Util::htmlentities($_SESSION['profilegroup']) . '\'';
        ?>
);">
    	<input type="image" name="cancelbuild" value="<?php 
        echo Util::htmlentities($_SESSION['profileswitch']);
        ?>
" title="Cancel building profile" src="icons/cancel.png" align="right" >
		<input type="hidden" name="switch" value="<?php 
        echo Util::htmlentities($_SESSION['profileswitch']);
        ?>
" >
	</form>
<?php 
    }
    if (!is_null($progress)) {
        print "Building ";
    }
    ?>
		Profile: &nbsp;<?php 
    echo Util::htmlentities($_SESSION['profile']);
    ?>
	</th>
</tr>
<?php 
    if (!is_null($progress)) {
        ProgressBar($progress);
    }
    ?>
<tr class="STATTABLE" id="ed_group_ro" >
    <td class="STATTABLE" >Group:</td> 
    <td class="MYVALUE">
<?php 
    if (!$is_live) {
        ?>
    	<a href="#null" onclick="EnableEdit('ed_group');" title="Change group" ><IMG SRC="icons/edit.png" name="edit_group" border="0" align="right" alt="edit icon"></a>
<?php 
    }
    print $_SESSION['profilegroup'] == '.' ? "(nogroup)" : Util::htmlentities($_SESSION['profilegroup']);
    ?>
	</td>
</tr>
<tr class="STATTABLE" id="ed_group_rw" style="display:none">
    <td class="STATTABLE" style="color:red"> Group: </td>
    <td class="MYVALUE">
	<form style="display: inline;" name="profileform" id="profileform" action="<?php 
    echo $self;
    ?>
" method="POST" >
    	<select name="groupselect" id="groupselect" onChange="HandleGroupSelect()" style="width:100%">
<?php 
    foreach ($profilegroups as $group) {
        $selected = $_SESSION['profilegroup'] == $group ? "selected" : '';
        if ($group == '.') {
            $group = '(nogroup)';
        }
        print "<option value='{$group}' {$selected}>{$group}</option>\n";
    }
    ?>
    	</select><br>
		<input type="text" name="profilegroup" id="profilegroup" value=""
			SIZE="32" MAXLENGTH="32" style="width:100%;display:none"><br>
		<hr class="hrule">
		<span style="color:red"><input name="regroup" value="Enter new group" type="submit" onclick=""></span>
		<a href="#null" onMouseover="showhint('Select an existing or create a new group', 
this, event, '200px')"><IMG SRC="icons/help.png" border="0" alt="help icon"></a>
	</form>
	</td >
</tr>
<tr class="STATTABLE" id="ed_description_ro">
    <td class="STATTABLE">Description:</td> 
    <td class="MYVALUE">
    	<table style="width: 100%; text-align: left;" cellpadding='0' cellspacing='0'>
		<tr>
			<td>
				<textarea name="description" rows="4" cols="40" style="width:100%" readonly ><?php 
    echo Util::htmlentities($description);
    ?>
</textarea>
			</td>
			<td style="vertical-align:top;">
			<a href="#null" onclick="EnableEdit('ed_description');" title="Change Description" ><IMG SRC="icons/edit.png" name="edit_description" border="0" align="right" alt="edit icon" ></a>
			</td>
		</tr>
		</table>
    </td>
</tr>
<tr class="STATTABLE" id="ed_description_rw" style="display: none">
    <td class="STATTABLE" style="color:red"> Description:</td> 
    <td class="MYVALUE">
	<form style="display: inline;" name="profileform" id="profileform" action="<?php 
    echo $self;
    ?>
" method="POST" >
		<textarea name="description" cols="25" rows="3" style="width:100%"><?php 
    echo Util::htmlentities($description);
    ?>
</textarea>
		<span style="color:red"><input name="edit" value="Enter new description" type="submit" onclick=""></span>
	</form>
    </td>
</tr>


<tr class="STATTABLE" id="ed_type_ro">
    <td class="STATTABLE" >Type:</td> 
    <td class="MYVALUE">
<?php 
    $current_type = $_SESSION['profileinfo']['type'];
    if ($current_type != 0) {
        ?>
    	<a href="#null" onclick="EnableEdit('ed_type');" title="Change profile type" ><IMG SRC="icons/edit.png" name="edit_profile_type" border="0" align="right" alt="edit icon"></a>
<?php 
    }
    print $type;
    ?>
	</td>
</tr>
</tr>
<tr class="STATTABLE" id="ed_type_rw" style="display:none">
    <td class="STATTABLE" style="color:red"> Type: </td>
    <td class="MYVALUE">
	<form style="display: inline;" name="profiletypeform" action="<?php 
    echo $self;
    ?>
"
		onSubmit="return ConfirmNewType(<?php 
    echo Util::htmlentities($current_type);
    ?>
)" method="POST" >
		<input type="radio" name="profile_type" value="2" <?php 
    echo $current_type == 2 ? 'checked' : '';
    ?>
> 
		Continous Profile<br>
<?php 
    $disable_mode = $current_type == 5 || $current_type == 6 ? 'disabled ' : '';
    ?>

		<input type="radio" name="profile_type" value="1" <?php 
    echo $disable_mode;
    echo $current_type == 1 ? 'checked' : '';
    ?>
> 
		History Profile<br>
		<hr class="hrule">
		<input type="radio" name="profile_type" value="6" <?php 
    echo $current_type == 6 ? 'checked' : '';
    ?>
> 
		Continous Profile&nbsp;/&nbsp;shadow<br>
		<input type="radio" name="profile_type" value="5" <?php 
    echo $current_type == 5 ? 'checked' : '';
    ?>
> 
		History Profile&nbsp;/&nbsp;shadow<br>
		<hr class="hrule">
		<input name="edit" value="Commit new type" type="submit" >
		<a href="#null" onMouseover="showhint('<b>Continous Profile</b><br>\
Switching to a continuous profile starts profiling.<br>\
<b>History Profile</b><br>Switching to a history profile stops profiling.<br> \
<b>Shadow Profile</b><br>Switching to a shadow profile deletes all profiled netflow data to free disk space. \
All graphics data remains available. Processing netflow is done by applying the appropriate channel filters \
to \'live\' netflow data first.<br>When switching back from shadow to a real profile, data collecting starts \
again.', this, event, '200px')"><IMG SRC="icons/help.png" border="0" alt="help icon"></a>
	</form>
	</td >
</tr>
<tr class="STATTABLE">
    <td class="STATTABLE">Start:</td> 
    <td class="MYVALUE">
		<input type="text" name="ro_tstart" value="<?php 
    echo $tstart;
    ?>
" SIZE="17" MAXLENGTH="16" 
			style="font-size:12px;" readonly>
	</td>
</tr>
<tr class="STATTABLE">
    <td class="STATTABLE">End:</td> 
    <td class="MYVALUE">
		<input type="text" name="ro_tend" value="<?php 
    echo $tend;
    ?>
" SIZE="17" MAXLENGTH="16" 
			style="font-size:12px;" readonly>
	</td>
</tr>
<tr class="STATTABLE">
    <td class="STATTABLE">Last Update:</td> 
    <td class="MYVALUE">
		<input type="text" name="ro_tupdate" value="<?php 
    echo $tupdate;
    ?>
" SIZE="17" MAXLENGTH="16" 
			style="font-size:12px;" readonly>
	</td>
</tr>



<tr class="STATTABLE">
    <td class="STATTABLE">Size:</td> 
    <td class="MYVALUE"> <?php 
    echo Util::htmlentities($size);
    ?>
 </td>
</tr>

<tr class="STATTABLE" id="ed_max_ro">
    <td class="STATTABLE">Max. Size:</td> 
    <td class="MYVALUE">
<?php 
    if ($can_edit) {
        ?>
    	<a href="#null" onclick="EnableEdit('ed_max');" title="Change max. size" ><IMG SRC="icons/edit.png" name="edit_maxsize" border="0" align="right" alt="edit icon"></a>
<?php 
    }
    ?>
		<input type="text" name="profile_maxsize" value="<?php 
    echo Util::htmlentities($maxsize);
    ?>
" SIZE="16" MAXLENGTH="16" 
			style="font-size:12px;" readonly>
    </td>
</tr>

<tr class="STATTABLE" id="ed_max_rw" style="display: none">
    <td class="STATTABLE" style="color:red">Max. Size:</td> 
    <td class="MYVALUE">
	<form style="display: inline;" name="profileform" id="profileform" action="<?php 
    echo $self;
    ?>
" method="POST" >
		<input type='text' name='profile_maxsize' value='<?php 
    echo Util::htmlentities($maxsize);
    ?>
'  SIZE="16" MAXLENGTH="16" style="font-size:12px;">
		<hr class="hrule">
		<span style="color:red"><input name="edit" value="Enter new value" type="submit" onclick=""></span>
		<a href="#null" onMouseover="showhint('Maximum size, this profile may grow.\
Any number is taken as <b>MB</b>, unless another scale is specified such as <b>K, M, G, T</b>\
 or <b>KB, MB, GB, TB</b>. If set to <b>0</b>, no size limit applies.<br>\
Ex. 300, 300M, 2G etc.', this, event, '200px')"><IMG SRC="icons/help.png" border="0" alt="help icon"></a>
	</form>
    </td>
</tr>


<tr class="STATTABLE" id="ed_exp_ro" >
    <td class="STATTABLE">Expire:</td> 
    <td class="MYVALUE">
<?php 
    if ($can_edit) {
        ?>
		<a href="#null" onclick="EnableEdit('ed_exp');" title="Change expire size" ><IMG SRC="icons/edit.png" name="edit_expire" border="0" align="right" alt="edit icon"></a>
<?php 
    }
    ?>
		<input type="text" name="profile_expire" value="<?php 
    echo Util::htmlentities($expire);
    ?>
" SIZE="16" MAXLENGTH="16" style="font-size:12px;" readonly >
    </td>
</tr>

<tr class="STATTABLE" id="ed_exp_rw" style="display: none">
    <td class="STATTABLE" style="color:red">Expire:</td> 
    <td class="MYVALUE">
	<form style="display: inline;" name="profileform" id="profileform" action="<?php 
    echo $self;
    ?>
" method="POST" >
		<input type='text' name='profile_expire' value='<?php 
    echo Util::htmlentities($expire);
    ?>
' SIZE='16' MAXLENGTH='16' style="font-size:12px;" >
		<hr class="hrule">
		<span style="color:red"><input name="edit" value="Enter new value" type="submit"></span>
		<a href="#null" onMouseover="showhint('Expire time. This specifies the maximum lifetime for this profile. \
Data files older than this, will be deleted. Any number is taken as <b>hours</b> unless another scale is specified \
such as <b>d, day, days</b> and/or <b>h, hour, hours</b>. If set to <b>0</b> or <b>never</b>, no time limit applies.<br>\
Ex. 72, 72h, 4d 12h, 14days etc.', this, event, '200px')"><IMG SRC="icons/help.png" border="0" alt="help icon"></a>
	</form>
    </td>
</tr>


<tr class="STATTABLE">
    <td class="STATTABLE">Status:</td> 
    <td class="MYVALUE">
<?php 
    if ($can_commit) {
        ?>
		<form style="display: inline;" name="profileform" id="profileform" action="<?php 
        echo $self;
        ?>
" method="POST" >
		<input type="image" name="commit_profile" value="commit_profile" title="Commit new profile" src="icons/ok.png" align="right">
		</form>
<?php 
    }
    ?>
		<?php 
    echo Util::htmlentities($status) . " " . Util::htmlentities($locked);
    ?>
	</td>
</tr>
<tr class="STATTABLE">
	<td class="CHANNELTITLE" colspan="2">
<?php 
    if ($can_add_channel) {
        ?>
		<form style="display: inline;" name="profileform" id="profileform" action="<?php 
        echo $self;
        ?>
" method="POST" >
		<input type="image" name="add_channel" value="add_channel" title="Add new channel" src="icons/plus.png" align="right">
		</form>
<?php 
    }
    ?>
		<a href="#null" onclick="ToggleAll('show')" id="all_r" title="expand channel list" <?php 
    echo $style_arrow_right;
    ?>
><IMG SRC="icons/arrow.yellow.right.png" name="<?php 
    echo $chan_id;
    ?>
 right" border="0" alt="arrow right"></a>
		<a href="#null" onclick="ToggleAll('hide')" id="all_d" title="collaps channel list"<?php 
    echo $style_arrow_down;
    ?>
><IMG SRC="icons/arrow.yellow.down.png" name="<?php 
    echo $chan_id;
    ?>
 down" border="0" alt="arrow down"></a>	
		Channel List:
	</td>
</tr>
	<?php 
    $i = 1;
    $is_live_profile = $_SESSION['profileinfo']['name'] == 'live';
    foreach ($_SESSION['profileinfo']['channel'] as $channel) {
        $_opts['profile'] = $_SESSION['profileswitch'];
        $_opts['channel'] = $channel['name'];
        $_filter = nfsend_query("get-channelfilter", $_opts, 0);
        if (!is_array($_filter)) {
            $channel['filter'] = array('Unable to get channel filter');
        }
        $channel['filter'] = $_filter['filter'];
        print "<tr class='STATTABLE'>\n";
        print "<td style='padding: 0px' colspan='2'>\n";
        PrintChannelStat($i, $channel, $_COOKIE['extended_channellist']);
        print "</td>\n";
        print "</tr>\n";
        $i++;
    }
    ?>

</table>
</div>
<script type="text/javascript">Init_ShowHide_profile();</script>
<?php 
}
Exemplo n.º 2
0
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 ? '&nbsp;/&nbsp;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");
    ?>
&nbsp;
			<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");
    ?>
:&nbsp;
			<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;
    ?>
">&nbsp;
			<input class="lbutton" name="adjust" value=" < " type="submit" title="<?php 
    echo _("Previous time slot");
    ?>
">&nbsp;
			<input class="lbutton" name="adjust" value=" | " type="submit" title="<?php 
    echo _("Center cursor");
    ?>
">&nbsp;
			<input class="lbutton" name="adjust" value=" ^ " type="submit" <?php 
    echo $status;
    ?>
 title="<?php 
    echo $peak_search_label;
    ?>
">&nbsp;
			<input class="lbutton" name="adjust" value=" > " type="submit" title="<?php 
    echo _("Next time slot");
    ?>
">&nbsp;
			<input class="lbutton" name="adjust" value=" >> " type="submit" title="<?php 
    echo _("Forward");
    ?>
 <?php 
    echo $size_label;
    ?>
">&nbsp;
			<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">&nbsp;</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> &nbsp</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} &nbsp</td>\n";
            $cellcolour = "bgcolor='#f2f2f2'";
        } else {
            print "<td align=left><input type='checkbox' name='{$channel}' value='{$channel}' onClick='this.form.submit();'>{$channel} &nbsp</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}&nbsp;</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}&nbsp;</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}&nbsp;</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");
    ?>
 &nbsp;
<?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 
}
Exemplo n.º 3
0
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 ? '&nbsp;/&nbsp;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) : "&nbsp;") . "</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");
    ?>
&nbsp;
			<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");
    ?>
:&nbsp;
			<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;
    ?>
">&nbsp;
			<input class="small av_b_secondary" name="adjust" value=" < " type="submit" title="<?php 
    echo _("Previous time slot");
    ?>
">&nbsp;
			<input class="small av_b_secondary" name="adjust" value=" | " type="submit" title="<?php 
    echo _("Center cursor");
    ?>
">&nbsp;
			<input class="small av_b_secondary" name="adjust" value=" ^ " type="submit" <?php 
    echo $status;
    ?>
 title="<?php 
    echo $peak_search_label;
    ?>
">&nbsp;
			<input class="small av_b_secondary" name="adjust" value=" > " type="submit" title="<?php 
    echo _("Next time slot");
    ?>
">&nbsp;
			<input class="small av_b_secondary" name="adjust" value=" >> " type="submit" title="<?php 
    echo _("Forward");
    ?>
 <?php 
    echo $size_label;
    ?>
">&nbsp;
			<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">&nbsp;</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}&nbsp;</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}&nbsp;</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}&nbsp;</td>";
            $col++;
        }
        print "</tr>\n";
        $row++;
    }
    ?>
		
	<tr bgcolor='#dee7ec'>
	<td colspan="2">&nbsp;</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}&nbsp;</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}&nbsp;</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}&nbsp;</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");
    ?>
 &nbsp;
<?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);
}
Exemplo n.º 4
0
function DisplayEventTable($alert, $readonly)
{
    global $self;
    global $num_ConditionList;
    $controls_display_style = $readonly ? "" : "style='display:none'";
    $updated = $alert['updated_str'];
    ?>

<table class="ALERTTABLE" id="EventTable" width="100%" <?php 
    echo $controls_display_style;
    ?>
>
<tbody>
	<tr class="ALERTTABLE">
		<th class="ALERTTABLE">
			Alert Infos:
		</th>
	</tr>
	<tr>
		<td>Last cycle: <?php 
    echo $updated;
    ?>
</td>
	</tr>
	<tr>
		<td class="MYVALUE">
<?php 
    $arg = implode(' ', array($_SESSION['alert_display']['avg_type'], $alert['updated'] - 86400, $alert['updated']));
    $arg = urlencode($arg);
    $js_arg = implode(' ', array($alert['updated'] - 86400, $alert['updated']));
    $js_arg = urlencode($js_arg);
    $js_arg = "'" . $alert['name'] . "', '{$js_arg}'";
    ?>
			<iframe id="avg_frame" src="rrdgraph.php?cmd=get-alertgraph&amp;alert=<?php 
    echo $alert['name'];
    ?>
&amp;arg=<?php 
    echo $arg;
    ?>
" 
				align="left" scrolling="no" frameborder="0" marginwidth="0" marginheight="0" width="680" height="280"></iframe>
		</td>
	</tr>
	<tr>
		<td class="MYVALUE">
			<table class="ALERTDETAILS">
			<thead>
			<tr>
				<th></th>
				<th></th>
				<th><b>Last</b></th>
				<th><b>Avg 10m</b></th>
				<th><b>Avg 30m</b></th>
				<th><b>Avg 1h</b></th>
				<th><b>Avg 6h</b></th>
				<th><b>Avg 12h</b></th>
				<th><b>Avg 24h</b></th>
			</tr>
			</thead>
			<tbody>
			<tr>
				<td rowspan="2">
<?php 
    $checked = $_SESSION['alert_display']['avg_type'] == 0 ? 'checked' : '';
    ?>
				<input type="radio" name="avg_type" value="0" onChange="SetAlertStatus(0, <?php 
    echo $js_arg;
    ?>
);" <?php 
    echo $checked;
    ?>
> 
				</td>
				<td rowspan="2"><b>Flows</b></td>
<?php 
    $vec = explode(':', $alert['last_flows']);
    foreach ($vec as $val) {
        $val = ScaleValue($val, 1);
        print "<td style='text-align:right'>{$val}</td>\n";
    }
    ?>
			</tr>
			<tr>
<?php 
    foreach ($vec as $val) {
        $val = ScaleValue($val, 300);
        print "<td style='text-align:right'>{$val}</td>\n";
    }
    ?>
			</tr>
			<tr>
				<td rowspan="2">
<?php 
    $checked = $_SESSION['alert_display']['avg_type'] == 1 ? 'checked' : '';
    ?>
				<input type="radio" name="avg_type" value="1" onChange="SetAlertStatus(1, <?php 
    echo $js_arg;
    ?>
);" <?php 
    echo $checked;
    ?>
> 
				</td>
				<td rowspan="2"><b>Packets</b></td>
<?php 
    $vec = explode(':', $alert['last_packets']);
    foreach ($vec as $val) {
        $val = ScaleValue($val, 1);
        print "<td style='text-align:right'>{$val}</td>\n";
    }
    ?>
			</tr>
			<tr>
<?php 
    foreach ($vec as $val) {
        $val = ScaleValue($val, 300);
        print "<td style='text-align:right'>{$val}</td>\n";
    }
    ?>
			</tr>
			<tr>
				<td rowspan="2">
<?php 
    $checked = $_SESSION['alert_display']['avg_type'] == 2 ? 'checked' : '';
    ?>
				<input type="radio" name="avg_type" value="2" onChange="SetAlertStatus(2, <?php 
    echo $js_arg;
    ?>
);" <?php 
    echo $checked;
    ?>
> 
				</td>
				<td rowspan="2"><b>Bytes</b></td>
<?php 
    $vec = explode(':', $alert['last_bytes']);
    foreach ($vec as $val) {
        $val = ScaleBytes($val, 1, 1000.0);
        print "<td style='text-align:right'>{$val}</td>\n";
    }
    ?>
			</tr>
			<tr>
<?php 
    foreach ($vec as $val) {
        $val = ScaleBytes($val, 300, 1000.0);
        print "<td style='text-align:right'>{$val}</td>\n";
    }
    ?>
			</tr>
			</tbody>
			</table>
		</td>
	</tr>
	<tr>
<?php 
    if (array_key_exists('last_condition', $alert)) {
        $vec = explode(':', $alert['last_condition']);
        $num = count($vec);
        print "<td><p></td>\n";
    } else {
        $num = 0;
        print "<td><p><b>Last conditions not available</b></td>\n";
    }
    ?>
	</tr>
	<tr>
		<td>
<?php 
    if ($num) {
        print "<table class='ALERTDETAILS'>\n";
        print "<tr>\n";
        $offset = $alert['type'] == 1 ? $num_ConditionList : 0;
        print "<td><b>Conditions:</b></td>\n";
        for ($i = 0; $i < $num; $i++) {
            print "<td><b>";
            print $i + $offset;
            print "</b></td>\n";
        }
        print "<td><b>Final:</b></td>";
        print "</tr>\n";
        print "<tr>\n";
        print "<td><b>State:</b></td>\n";
        for ($i = 0; $i < $num; $i++) {
            print "<td>";
            print $vec[$i] ? "True" : "False";
            print "</td>\n";
        }
        print "<td><b>";
        print $alert['final_condition'] ? "True" : "False";
        print "</b></td>";
        print "</tr>\n";
        print "</table>\n";
    }
    ?>
		</td>
	</tr>
</tbody>
</table>

<?php 
}