Location: PHPKode > projects > YASeMI > yasemi_0.1/gs/various_functions.php
<?php

function lasthours($report) {

	if (!empty($_POST["lasthours"])) {
		header( 'refresh: 600; url=/reports/'.$report.'.php?howmany='.$_POST["lasthours"].'' );
		$before = time() - ($_POST["lasthours"] * 3600);
		$_POST["intrv1"] = date('j-n-Y H:i:s', $before);
		$now = time();
		$_POST["intrv2"] = date('j-n-Y H:i:s', $now);
	}
	elseif (!empty($_GET["howmany"])) {
		header( 'refresh: 600; url=/reports/'.$report.'.php?howmany='.$_GET["howmany"].'' );
		$before = time() - ($_GET["howmany"] * 3600);
		$_POST["intrv1"] = date('j-n-Y H:i:s', $before);
		$now = time();
		$_POST["intrv2"] = date('j-n-Y H:i:s', $now);
	}

}

function fix_date($datetime) {

	// MAKE THE DATES SUITABLE FOR THE UNIX_TIMESTAMP MYSQL COMMAND
	$date = explode(" ",$datetime);
	$date_array = explode("-",$date[0]);	
	$time_array = explode(":",$date[1]);
	
	if ($date_array[0] < 10) $date_array[0] = '0'.$date_array[0];
	if ($date_array[1] < 10) $date_array[1] = '0'.$date_array[1];
	
	$real_datetime = $date_array[2].$date_array[1].$date_array[0].$time_array[0].$time_array[1].$time_array[2];
	
	return $real_datetime;

}

function date_dif($starttime, $endtime) {
	
	
	// MAKE THE DATES SUITABLE FOR THE UNIX_TIMESTAMP MYSQL COMMAND
	$real_starttime = fix_date($starttime);
	$real_endtime = fix_date($endtime);

	$query = "SELECT unix_timestamp('".$real_endtime."') - unix_timestamp('".$real_starttime."')";
	
	// EXECUTES THE QUERY
	$result = mysql_query($query) or die(mysql_error().'<br> SQL:'.$query);

	$row = mysql_fetch_row($result);
	
	return $row[0];
	
}

function dropdown($array, $starttime, $endtime, $posttime1, $posttime2) {

	sort($array);
	
	// THE DROP DOWN WITH THE SUSPICIOUS IP'S
	echo '
	<form name="suspicious" method="post" action="drop_checks.php" target="_blank">
	
	<input type="hidden" name="starttime" value="'.$starttime.'">
	<input type="hidden" name="endtime" value="'.$endtime.'">
	<input type="hidden" name="intrv1" value="'.$posttime1.'">
	<input type="hidden" name="intrv2" value="'.$posttime2.'">
	
	<div style="position:absolute;top: 135px;left: 848px;">
	<select name="drop_reports" style="width:120px;">
		<option value="" onClick="switchDiv(\'blank\');" selected>Choose Report</option>
		<option value="traffic" onClick="switchDiv(\'blank\');">Traffic</option>
		<option value="portscan" onClick="switchDiv(\'blank\');">Portscan</option>
		<option value="flags" onClick="switchDiv(\'flags\');">by Flags</option>
		<option value="flows" onClick="switchDiv(\'blank\');">Flows</option>
	</select><br>
	<select name="suspicious_ip" style="width:120px;">
	<option value="" selected>Choose IP</option>
	';
	foreach($array as $value)
			echo '<option value="'.$value.'">'.$value.'</option>';
	
	echo '</select><br>
		  <input type="submit" name="Submit" value="New Report" style="width:120px;">
		  </div>
		  <div id="flags" style="position:absolute;visibility:hidden;top:135px;left:968px;background:#BFC3FF;padding: 2px;border:1px dotted #000000;">
		  	<input name="urg" type="checkbox" value="urg">URG<br>
			<input name="ack" type="checkbox" value="ack">ACK<br>
			<input name="psh" type="checkbox" value="psh">PSH<br>
			<input name="rst" type="checkbox" value="rst">RST<br>
			<input name="syn" type="checkbox" value="syn">SYN<br>
			<input name="fin" type="checkbox" value="fin">FIN
		  </div>
  		  <div id="blank" style="position:absolute;visibility:hidden;"></div>
 		  </form>
		  ';

}

?>
Return current item: YASeMI