Location: PHPKode > projects > Php-Logging-System > phplogsys-1.1.4/includes/iptablesdetail.php
<?php
//========================================================================
// BEGIN: GET THE INPUT VARIABLES
//========================================================================
$seq = get_input('seq');
$table = get_input('table');
//========================================================================
// END: GET THE INPUT VARIABLES
//========================================================================
function iptables_port_references($name, $port, $prot){
	global $iptables_port_references;
	return '<tr><th>' . $name . ':</th><td>' . str_replace(array('[PORT]', '[PROTO]', '[proto]'), array($port, strtoupper($prot), $prot), implode(' ', $iptables_port_references)) . '</td></tr>';
}

function iptables_ip_references($name, $ip){
	global $iptables_ip_references;
	return '<tr><th>' . $name . ':</th><td>' . str_replace('[IP]', $ip, implode(' ', $iptables_ip_references)) . '</td></tr>';
}
//========================================================================
// BEGIN: BUILD AND EXECUTE SQL STATEMENT
// AND BUILD PARAMETER LIST FOR HTML GETS
//========================================================================
if($table){
	$srcTable = $table;
} else{
	$srcTable = DEFAULTSYSLOGTABLE;
}

$query = 'SELECT * FROM ' . $srcTable . ' WHERE seq = ' . $seq;

//------------------------------------------------------------------------
// Execute the query
// The FOUND_ROWS function returns the value from the SQL_CALC_FOUND_ROWS
// count.
//------------------------------------------------------------------------
$results = perform_query($query, $dbLink);
//========================================================================
// END: BUILD AND EXECUTE SQL STATEMENT
// AND BUILD PARAMETER LIST FOR HTML GETS
//========================================================================

//========================================================================
// BEGIN: PREPARE RESULT ARRAY
//========================================================================
if($row = fetch_array($results)){
	$result_array = $row;
}else{
	echo 'No results found, <br><a href="', $_SERVER["PHP_SELF"], '?pageId=iptablesform">BACK TO SEARCH</a>';
	require_once(BASE_PATH . '/html_footer.php');
	exit;
}
//========================================================================
// END: PREPARE RESULT ARRAY
//========================================================================

//========================================================================
// BEGIN: BUILDING THE HTML PAGE
//========================================================================
// Print result sub-header
unset($query);
require_once(BASE_PATH . '/iptables_result_subheader.php');

// If there is a result list then print it
//------------------------------------------------------------------------
// If the query returned some results then start the table with the
// results
//------------------------------------------------------------------------
?>
<style>
table.iptablesdetail {
	width: auto;
	border: thin solid grey;
	border-collapse: collapse;
	padding: 0px;
	margin: 0px;
}
table.iptablesdetail tr td {
	vertical-align: top;
	padding: 0px;
	margin: 0px;
}
table.iptablesdetail tr td table {
	border-collapse: collapse;
	border: thin solid grey;
}
table.iptablesdetail tr td table tr td table tr th {
	text-align: left;
}
table.iptablesdetail tr td table tr td table.numeric tr td {
	text-align: right;
}
</style>
<table class="iptablesdetail">
<tr><td><table>
		<tr class="resultsheader">
			<td>META DATA</td>
		</tr>
		<tr><td><table>
				<tr><th>SEQ#</th><td><?=$seq?></td></tr>
				<tr><th>DATE TIME</th><td><?=date('m/d/Y H:i:s', $result_array['timestamp'])?></td></tr>
				<tr><th>HOST</th><td><?=$result_array['host']?></td></tr>
				<tr><th>PREFIX</th><td><?=$result_array['prefix']?></td></tr>
				<tr><th>INCOMMING INTERFACE</th><td><?=$result_array['in']?></td></tr>
				<tr><th>OUTGOING INTERFACE</th><td><?=$result_array['out']?></td></tr>
				<tr><th>MAC ADDRESS</th><td><?=$result_array['mac']?></td></tr>
				</table>
			</td>
		</tr>
		<tr class="resultsheader">
			<td>REFERENCE DATA</td>
		</tr>
		<tr><td><table>
		<?
			if(isset($result_array['src'])) echo iptables_ip_references('Source IP', $result_array['src']);
			if(isset($result_array['dst'])) echo iptables_ip_references('Destination IP', $result_array['dst']);
			if(isset($result_array['spt'])) echo iptables_port_references('Source Port', $result_array['spt'], $result_array['proto']);
			if(isset($result_array['dpt'])) echo iptables_port_references('Destination Port', $result_array['dpt'], $result_array['proto']);
		?>
			</td></table>
		</tr>
		</table>
	</td>
</tr>
<tr><td><table>
		<tr class="resultsheader">
			<td>IP DATA</td>
			<td>TCP/UDP DATA</td>
		</tr>
		<tr><td><table class="numeric">
				<tr><th>SOURCE ADDRESS</th><td><?=$result_array['src']?></td></tr>
				<tr><th>DESTINATION ADDRESS</th><td><?=$result_array['dst']?></td></tr>
				<tr><th>TYPE OF SERVICE</th><td><?=$result_array['tos']?></td></tr>
				<tr><th>ID NUMBER</th><td><?=$result_array['id']?></td></tr>
				<tr><th>TIME TO LIVE</th><td><?=$result_array['ttl']?></td></tr>
				<tr><th>PROTOCOL</th><td><?=$result_array['proto']?></td></tr>
				<tr><th>FLAGS</th><td><?=$result_array['flags']?></td></tr>
				</table>
			</td>
			<td><table class="numeric">
				<tr><th>SOURCE PORT</th><td><?=$result_array['spt']?></td></tr>
				<tr><th>DESTINATION PORT</th><td><?=$result_array['dpt']?></td></tr>
				<tr><th>WINDOW</th><td><?=$result_array['window']?></td></tr>
				<tr><th>RESERVED</th><td><?=$result_array['res']?></td></tr>
				<tr><th>URGENT POINTER</th><td><?=$result_array['urgp']?></td></tr>
				</table>
			</td>
		</tr>
		</table>
	</td>
</tr>
</table>
Return current item: Php-Logging-System