Exemple #1
0
function flowview_display_report()
{
    global $config, $colors;
    if (isset($_REQUEST['tab']) && strlen($_REQUEST['tab']) > 10) {
        $flowdata = unserialize(base64_decode($_REQUEST['tab']));
        $sessionid = $_REQUEST['tab'];
        foreach ($flowdata['post'] as $item => $value) {
            switch ($item) {
                case 'bytes':
                case 'flows':
                case 'packets':
                    break;
                default:
                    $_POST[$item] = $value;
            }
        }
        $_REQUEST['query'] = $_POST['query'];
        $_REQUEST['action'] = 'view';
    } else {
        $sessionid = '';
    }
    include $config['base_path'] . '/plugins/flowview/variables.php';
    include $config['base_path'] . '/plugins/flowview/arrays.php';
    $rname = '';
    if ($stat_report > 0) {
        $rname = $stat_report_array[$stat_report];
    }
    if ($print_report > 0) {
        $rname = $print_report_array[$print_report];
    }
    $current = '';
    $error = flowview_check_fields();
    if ($error != '') {
        display_tabs();
        print "<font color=red><strong>{$error}</strong></font>";
        html_end_box();
        return;
    }
    /* if the user pushed the 'clear' button */
    if (isset($_REQUEST["clear"])) {
        kill_session_var("sess_flows_exclude");
        kill_session_var("sess_flows_table");
        kill_session_var("sess_flows_bytes");
        kill_session_var("sess_flows_packets");
        kill_session_var("sess_flows_flows");
        unset($_REQUEST["exclude"]);
        unset($_REQUEST["table"]);
        unset($_REQUEST["bytes"]);
        unset($_REQUEST["packets"]);
        unset($_REQUEST["flows"]);
    }
    /* remember these search fields in session vars so we don't have to keep passing them around */
    load_current_session_value("exclude", "sess_flows_exclude", "0");
    load_current_session_value("table", "sess_flows_table", "on");
    load_current_session_value("bytes", "sess_flows_bytes", "");
    load_current_session_value("packets", "sess_flows_packets", "");
    load_current_session_value("flows", "sess_flows_flows", "");
    $filter = createfilter($sessionid);
    display_tabs();
    if (isset($_POST['stat_report']) && $_POST['stat_report'] != 99) {
        html_start_box("<strong>Report: {$rname}</strong>", "100%", $colors["header"], "3", "center", "");
        ?>
		<tr bgcolor="#<?php 
        print $colors["panel"];
        ?>
">
			<td>
			<form id="view" name="view" action="flowview.php" method="post">
				<table cellpadding="2" cellspacing="0">
					<tr>
						<td nowrap style='white-space: nowrap;'>
							<strong>Exclude:</strong>&nbsp;
						</td>
						<td nowrap style='white-space: nowrap;'>
							<select name='exclude' id='exclude'>
								<option value='0'<?php 
        echo $_REQUEST["exclude"] == 0 ? " selected" : "";
        ?>
>None</option>
								<option value='1'<?php 
        echo $_REQUEST["exclude"] == 1 ? " selected" : "";
        ?>
>Top Sample</option>
								<option value='2'<?php 
        echo $_REQUEST["exclude"] == 2 ? " selected" : "";
        ?>
>Top 2 Samples</option>
								<option value='3'<?php 
        echo $_REQUEST["exclude"] == 3 ? " selected" : "";
        ?>
>Top 3 Samples</option>
								<option value='4'<?php 
        echo $_REQUEST["exclude"] == 4 ? " selected" : "";
        ?>
>Top 4 Samples</option>
								<option value='5'<?php 
        echo $_REQUEST["exclude"] == 5 ? " selected" : "";
        ?>
>Top 5 Samples</option>
						</td>
						<td nowrap style='white-space: nowrap;'>
							<strong>Show/Hide:</strong>&nbsp;
						</td>
						<td width="1">
							<input type="checkbox" name="table" id="table" <?php 
        print $_REQUEST["table"] == "true" || $_REQUEST["table"] == "on" ? "checked" : "";
        ?>
>
						</td>
						<td nowrap style='white-space: nowrap;'>
							<label for="table">Table</label>
						</td>
						<td width="1">
							<input type="checkbox" name="bytes" id="bytes" <?php 
        print $_REQUEST["bytes"] == "true" || $_REQUEST["bytes"] == "on" ? "checked" : "";
        ?>
>
						</td>
						<td nowrap style='white-space: nowrap;'>
							<label for="bytes">Bytes Bar</label>
						</td>
						<td width="1">
							<input type="checkbox" name="packets" id="packets" <?php 
        print $_REQUEST["packets"] == "true" || $_REQUEST["packets"] == "on" ? "checked" : "";
        ?>
>
						</td>
						<td nowrap style='white-space: nowrap;'>
							<label for="packets">Packets Bar</label>
						</td>
						<td width="1">
							<input type="checkbox" name="flows" id="flows" <?php 
        print $_REQUEST["flows"] == "true" || $_REQUEST["flows"] == "on" ? "checked" : "";
        ?>
>
						</td>
						<td nowrap style='white-space: nowrap;'>
							<label for="flows">Flows Bar</label>
						</td>
						<td nowrap style='white-space: nowrap;'>
							<input type="submit" name="clear" value="Clear" title="Clear Filters">
						</td>
					</tr>
				</table>
				<input type='hidden' name='page' value='1'>
				<input type='hidden' name='tab'  id='tab' value='<?php 
        print $sessionid;
        ?>
'>
			</form>
			</td>
		</tr>
		<?php 
        html_end_box();
        flowview_draw_chart('bytes', $rname);
        flowview_draw_chart('packets', $rname);
        flowview_draw_chart('flows', $rname);
    } elseif (isset($_POST['print_report']) && $_POST['print_report'] > 0) {
        html_start_box("<strong>Report: {$rname}</strong>", "100%", $colors["header"], "3", "center", "");
    }
    echo "<div id='flowcontent'>";
    echo $filter;
    html_end_box();
    echo "</div>";
    ?>
	<script type='text/javascript'>

	swfobject.embedSWF('open-flash-chart.swf', 'chartbytes', '98%', '275', '9.0.0', 'expressInstall.swf', {'data-file':'<?php 
    print urlencode($config["url_path"] . "plugins/flowview/flowview.php?session=" . $sessionid . "&action=chartdata&exclude=" . $_REQUEST['exclude'] . "&type=bytes&title={$rname}");
    ?>
', 'id':'chartbytes'});
	swfobject.embedSWF('open-flash-chart.swf', 'chartpackets', '98%', '275', '9.0.0', 'expressInstall.swf', {'data-file':'<?php 
    print urlencode($config["url_path"] . "plugins/flowview/flowview.php?session=" . $sessionid . "&action=chartdata&exclude=" . $_REQUEST['exclude'] . "&type=packets&title={$rname}");
    ?>
', 'id':'chartpackets'});
	swfobject.embedSWF('open-flash-chart.swf', 'chartflows', '98%', '275', '9.0.0', 'expressInstall.swf', {'data-file':'<?php 
    print urlencode($config["url_path"] . "plugins/flowview/flowview.php?session=" . $sessionid . "&action=chartdata&exclude=" . $_REQUEST['exclude'] . "&type=flows&title={$rname}");
    ?>
', 'id':'chartflows'});

	$('#bytes').click(function() {
		if (!$('#bytes').is(':checked')) {
			$('#wrapperbytes').hide();
			$.get('flowview.php?action=updatesess&type=bytes&value=');
		}else{
			$('#wrapperbytes').show();
		}
	});

	$('#packets').click(function() {
		if (!$('#packets').is(':checked')) {
			$('#wrapperpackets').hide();
			$.get('flowview.php?action=updatesess&type=packets&value=');
		}else{
			$('#wrapperpackets').show();
		}
	});

	$('#flows').click(function() {
		if (!$('#flows').is(':checked')) {
			$('#wrapperflows').hide();
			$.get('flowview.php?action=updatesess&type=flows&value=');
		}else{
			$('#wrapperflows').show();
		}
	});

	$('#table').click(function() {
		if (!$('#table').is(':checked')) {
			$('#flowcontent').hide();
			$.get('flowview.php?action=updatesess&type=table&value=');
		}else{
			$.get('flowview.php?action=updatesess&type=table&value=on');
			$('#flowcontent').show();
		}
	});

	$('#exclude').change(function() {
		document.view.submit();
	});
			
	if ($('#table').is(':checked') || <?php 
    print $_POST['stat_report'];
    ?>
 == 99) {
		$('#flowcontent').show();
	}else{
		$('#flowcontent').hide();
	}

	if ($('#bytes').is(':checked')) {
		$('#wrapperbytes').show();
	}

	if ($('#packets').is(':checked')) {
		$('#wrapperpackets').show();
	}

	if ($('#flows').is(':checked')) {
		$('#wrapperflows').show();
	}

    $.tablesorter.addParser({ 
        id: 'bytes', 
        is: function(s) { 
            return false; 
        }, 
        format: function(s) { 
			if (s.indexOf('MB') > 0) {
				loc=s.indexOf('MB');
				return s.substring(0,loc) * 1024 * 1024;
			}else if (s.indexOf('KB') > 0) {
				loc=s.indexOf('KB');
				return s.substring(0,loc) * 1024;
			}else if (s.indexOf('Bytes') > 0) {
				loc=s.indexOf('Bytes');
				return s.substring(0,loc);
			}else if (s.indexOf('GB') > 0) {
				loc=s.indexOf('GB');
				return s.substring(0,loc) * 1024 * 1024 * 1024;
			}else if (s.indexOf('TB') > 0) {
				loc=s.indexOf('TB');
				return s.substring(0,loc) * 1024 * 1024 * 1024 * 1024;
			}else{
				return s;
			}
        }, 
        type: 'numeric' 
    }); 

	$().ready(function() {
		$('#sorttable').tablesorter();
	});
	</script>
	<?php 
}
Exemple #2
0
function flowview_display_report()
{
    global $config, $colors;
    general_header();
    if (isset_request_var('tab') && strlen(get_nfilter_request_var('tab')) > 10) {
        $flowdata = unserialize(base64_decode(get_nfilter_request_var('tab')));
        $sessionid = get_nfilter_request_var('tab');
        foreach ($flowdata['post'] as $item => $value) {
            switch ($item) {
                case 'bytes':
                case 'flows':
                case 'packets':
                    break;
                case 'exclude':
                    if (isset_request_var('exclude')) {
                        get_filter_request_var('exclude');
                        break;
                    } else {
                        set_request_var($item, $value);
                        break;
                    }
                default:
                    set_request_var($item, $value);
                    break;
            }
        }
        set_request_var('action', 'view');
    } else {
        $sessionid = '';
    }
    include $config['base_path'] . '/plugins/flowview/variables.php';
    include $config['base_path'] . '/plugins/flowview/arrays.php';
    $rname = '';
    if ($stat_report > 0) {
        $rname = $stat_report_array[$stat_report];
    }
    if ($print_report > 0) {
        $rname = $print_report_array[$print_report];
    }
    $current = '';
    $error = flowview_check_fields();
    if ($error != '') {
        display_tabs();
        print "<font class='textError'>{$error}</font>";
        html_end_box();
        return;
    }
    /* if the user pushed the 'clear' button */
    if (isset_request_var('clear')) {
        kill_session_var('sess_flows_exclude');
        kill_session_var('sess_flows_table');
        kill_session_var('sess_flows_bytes');
        kill_session_var('sess_flows_packets');
        kill_session_var('sess_flows_flows');
        unset_request_var('exclude');
        unset_request_var('table');
        unset_request_var('bytes');
        unset_request_var('packets');
        unset_request_var('flows');
    }
    /* remember these search fields in session vars so we don't have to keep passing them around */
    load_current_session_value('exclude', 'sess_flows_exclude', '0');
    load_current_session_value('table', 'sess_flows_table', 'on');
    load_current_session_value('bytes', 'sess_flows_bytes', '');
    load_current_session_value('packets', 'sess_flows_packets', '');
    load_current_session_value('flows', 'sess_flows_flows', '');
    $filter = createfilter($sessionid);
    display_tabs();
    if (isset_request_var('stat_report') && get_nfilter_request_var('stat_report') != 99) {
        html_start_box("Report: {$rname}", '100%', '', '3', 'center', '');
        ?>
		<tr class='even'>
			<td>
			<form id='view' name='view' action='flowview.php' method='post'>
				<table class='filterTable'>
					<tr>
						<td>
							Exclude
						</td>
						<td>
							<select name='exclude' id='exclude'>
								<option value='0'<?php 
        echo get_request_var('exclude') == 0 ? ' selected' : '';
        ?>
>None</option>
								<option value='1'<?php 
        echo get_request_var('exclude') == 1 ? ' selected' : '';
        ?>
>Top Sample</option>
								<option value='2'<?php 
        echo get_request_var('exclude') == 2 ? ' selected' : '';
        ?>
>Top 2 Samples</option>
								<option value='3'<?php 
        echo get_request_var('exclude') == 3 ? ' selected' : '';
        ?>
>Top 3 Samples</option>
								<option value='4'<?php 
        echo get_request_var('exclude') == 4 ? ' selected' : '';
        ?>
>Top 4 Samples</option>
								<option value='5'<?php 
        echo get_request_var('exclude') == 5 ? ' selected' : '';
        ?>
>Top 5 Samples</option>
							</select>
						</td>
						<td>
							Show/Hide
						</td>
						<td>
							<input type='checkbox' name='table' id='table' <?php 
        print get_request_var('table') == 'true' || get_request_var('table') == 'on' ? 'checked' : '';
        ?>
>
						</td>
						<td>
							<label for='table'>Table</label>
						</td>
						<td>
							<input type='checkbox' name='bytes' id='bytes' <?php 
        print get_request_var('bytes') == 'true' || get_request_var('bytes') == 'on' ? 'checked' : '';
        ?>
>
						</td>
						<td>
							<label for='bytes'>Bytes Bar</label>
						</td>
						<td>
							<input type='checkbox' name='packets' id='packets' <?php 
        print get_request_var('packets') == 'true' || get_request_var('packets') == 'on' ? 'checked' : '';
        ?>
>
						</td>
						<td>
							<label for='packets'>Packets Bar</label>
						</td>
						<td>
							<input type='checkbox' name='flows' id='flows' <?php 
        print get_request_var('flows') == 'true' || get_request_var('flows') == 'on' ? 'checked' : '';
        ?>
>
						</td>
						<td>
							<label for='flows'>Flows Bar</label>
						</td>
						<td>
							<input type='button' id='clear' value='Clear' title='Clear Filters'>
						</td>
					</tr>
				</table>
				<input type='hidden' name='page' value='1'>
				<input type='hidden' name='tab'  id='tab' value='<?php 
        print $sessionid;
        ?>
'>
			</form>
			</td>
		</tr>
		<?php 
        html_end_box();
        flowview_draw_chart('bytes', $rname);
        flowview_draw_chart('packets', $rname);
        flowview_draw_chart('flows', $rname);
    } elseif (isset_request_var('print_report') && get_nfilter_request_var('print_report') > 0) {
        html_start_box("Report: {$rname}", '100%', '', '3', 'center', '');
    }
    echo "<div id='flowcontent'>";
    echo $filter;
    html_end_box();
    echo "</div>";
    ?>
	<script type='text/javascript'>

	swfobject.embedSWF('open-flash-chart.swf', 'chartbytes', '98%', '275', '9.0.0', 'expressInstall.swf', {'data-file':'<?php 
    print urlencode($config["url_path"] . "plugins/flowview/flowview.php?session=" . $sessionid . "&action=chartdata&exclude=" . get_request_var('exclude') . "&type=bytes&title={$rname}");
    ?>
', 'id':'chartbytes'});
	swfobject.embedSWF('open-flash-chart.swf', 'chartpackets', '98%', '275', '9.0.0', 'expressInstall.swf', {'data-file':'<?php 
    print urlencode($config["url_path"] . "plugins/flowview/flowview.php?session=" . $sessionid . "&action=chartdata&exclude=" . get_request_var('exclude') . "&type=packets&title={$rname}");
    ?>
', 'id':'chartpackets'});
	swfobject.embedSWF('open-flash-chart.swf', 'chartflows', '98%', '275', '9.0.0', 'expressInstall.swf', {'data-file':'<?php 
    print urlencode($config["url_path"] . "plugins/flowview/flowview.php?session=" . $sessionid . "&action=chartdata&exclude=" . get_request_var('exclude') . "&type=flows&title={$rname}");
    ?>
', 'id':'chartflows'});

	$('#bytes').click(function() {
		if (!$('#bytes').is(':checked')) {
			$('#wrapperbytes').hide();
			$.get('flowview.php?action=updatesess&type=bytes&value=');
		}else{
			$('#wrapperbytes').show();
		}
	});

	$('#packets').click(function() {
		if (!$('#packets').is(':checked')) {
			$('#wrapperpackets').hide();
			$.get('flowview.php?action=updatesess&type=packets&value=');
		}else{
			$('#wrapperpackets').show();
		}
	});

	$('#flows').click(function() {
		if (!$('#flows').is(':checked')) {
			$('#wrapperflows').hide();
			$.get('flowview.php?action=updatesess&type=flows&value=');
		}else{
			$('#wrapperflows').show();
		}
	});

	$('#table').click(function() {
		if (!$('#table').is(':checked')) {
			$('#flowcontent').hide();
			$.get('flowview.php?action=updatesess&type=table&value=');
		}else{
			$.get('flowview.php?action=updatesess&type=table&value=on');
			$('#flowcontent').show();
		}
	});

	$('#clear').click(function() {
		loadPageNoHeader('flowview.php?header=false&action=view&clear=true&tab='+$('#tab').val());
	});

	$('#exclude').change(function() {
		loadPageNoHeader('flowview.php?header=false&action=view&exclude='+$('#exclude').val()+'&tab='+$('#tab').val());
	});
			
	if ($('#table').is(':checked') || <?php 
    print isset_request_var('stat_report') ? get_nfilter_request_var('stat_report') == 99 ? 'true' : 'false' : 'true';
    ?>
) {
		$('#flowcontent').show();
	}else{
		$('#flowcontent').hide();
	}

	if ($('#bytes').is(':checked')) {
		$('#wrapperbytes').show();
	}

	if ($('#packets').is(':checked')) {
		$('#wrapperpackets').show();
	}

	if ($('#flows').is(':checked')) {
		$('#wrapperflows').show();
	}

    $.tablesorter.addParser({ 
        id: 'bytes', 
        is: function(s) { 
            return false; 
        }, 
        format: function(s) { 
			if (s.indexOf('MB') > 0) {
				loc=s.indexOf('MB');
				return s.substring(0,loc) * 1024 * 1024;
			}else if (s.indexOf('KB') > 0) {
				loc=s.indexOf('KB');
				return s.substring(0,loc) * 1024;
			}else if (s.indexOf('Bytes') > 0) {
				loc=s.indexOf('Bytes');
				return s.substring(0,loc);
			}else if (s.indexOf('GB') > 0) {
				loc=s.indexOf('GB');
				return s.substring(0,loc) * 1024 * 1024 * 1024;
			}else if (s.indexOf('TB') > 0) {
				loc=s.indexOf('TB');
				return s.substring(0,loc) * 1024 * 1024 * 1024 * 1024;
			}else{
				return s;
			}
        }, 
        type: 'numeric' 
    }); 

	$(function() {
		$('#sorttable').tablesorter({
			widgets: ['zebra'],
			widgetZebra: { css: ['even', 'odd'] },
			headerTemplate: '<div class="textSubHeaderDark">{content} {icon}</div>',
			cssIconAsc: 'fa-sort-asc',
			cssIconDesc: 'fa-sort-desc',
			cssIconNone: 'fa-sort',
			cssIcon: 'fa'
		});
		$('#sorttable').resizable();
	});
	</script>
	<?php 
    bottom_footer();
}