<?
function
fn_searchP2P($QUERY_ID,$QUERY_START_DATETIME,$QUERY_END_DATETIME,$QUERY_MAC,$QUERY_PMAC,$QUERY_IP,$QUERY_IP_1,$QUERY_PIP,$QUERY_PORT,$QUERY_PPORT,$QUERY_TYPE,$QUERY_TOOL,$QUERY_NAME,$QUERY_DIR){
    if ($QUERY_ID != '') {
		$conSQL = $conSQL." and _AUTO = '".$QUERY_ID."'";
	}else{

		//if (($QUERY_START_DATETIME != '')||($QUERY_END_DATETIME != ''))$conSQL = " and _START between '".$QUERY_START_DATETIME."' and '".$QUERY_END_DATETIME."'";

		if (($QUERY_START_DATETIME != '')||($QUERY_END_DATETIME != ''))$conSQL = " and _TIMESTAMP  between '".$QUERY_START_DATETIME."' and '".$QUERY_END_DATETIME."'";

		if ($QUERY_PIP != '') $conSQL.=" and _SRC_IP  =  '".$QUERY_PIP."'";	
		if ($QUERY_IP_1 != '') { 
			if ($QUERY_IP != '') $conSQL.=" and _IP =  '".$QUERY_IP."'";	
        }
		else{
			if ($QUERY_IP != '') $conSQL.=" and  _IP like '".$QUERY_IP."%'";
		}

		if ($QUERY_PMAC != '') $conSQL.=" and _SRC_MAC  like '%".$QUERY_PMAC."%'";	
		if ($QUERY_MAC != '') $conSQL .=" and _MAC  like '%".$QUERY_SMAC."%'";	
		if ($QUERY_PPORT != '') $conSQL.=" and _SRC_PORT =  '".$QUERY_PPORT."'";	
		if ($QUERY_PORT != '') $conSQL.=" and _PORT=  '".$QUERY_PORT."'";	
		if ($QUERY_TOOL != '') $conSQL.=" and _TOOLS  like '%".$QUERY_TOOL."%'";	
		if ($QUERY_NAME != '') $conSQL.=" and _FILENAME  like '%".$QUERY_NAME."%'";	
		if ($QUERY_DIR != '') $conSQL .=" and _DIR='".$QUERY_DIR."'";
	}
	return $conSQL;
}
?>