<?
function fn_Login($QUERY_START_DATETIME,$QUERY_END_DATETIME,$QUERY_IP,$QUERY_USER,$QUERY_STATUS){
	require("../_read_source/_loginlog.php");

	if ($QUERY_START_DATETIME == '') $QUERY_START_DATETIME = "1900-01-01 00:00:00";
	if ($QUERY_END_DATETIME == '') $QUERY_END_DATETIME = "2037-12-31 23:59:59";
	

	$strSQL = " where DATE_FORMAT(".$DB_LOGINLOG_LOGIN_TIME.",'%Y-%m-%d %T') between '".$QUERY_START_DATETIME."' and '".$QUERY_END_DATETIME."'";

	if ($QUERY_IP != '') $strSQL = $strSQL." and ".$DB_LOGINLOG_LOGIN_IP."='".$QUERY_IP."'";
	if ($QUERY_USER != '') $strSQL = $strSQL." and ".$DB_LOGINLOG_LOGINID."='".$QUERY_USER."'";
	if ($QUERY_STATUS != '') $strSQL = $strSQL." and ".$DB_LOGINLOG_STATUS."='".$QUERY_STATUS."'";

	return $strSQL;
}

function fn_Online($QUERY_START_DATETIME,$QUERY_END_DATETIME,$QUERY_IP,$QUERY_USER,$QUERY_GROUP,$QUERY_REMARK,$QUERY_ISP){
	require("../_read_source/_ipcontrol.php");

	if ($QUERY_START_DATETIME == '') $QUERY_START_DATETIME = "0000-00-00 00:00:00";
	if ($QUERY_END_DATETIME == '') $QUERY_END_DATETIME = "2037-12-31 23:59:59";
	

	$strSQL = " and DATE_FORMAT(".$DB_IPCONTROL_EXIST_TIME.",'%Y-%m-%d %T') between '".$QUERY_START_DATETIME."' and '".$QUERY_END_DATETIME."'";

	if ($QUERY_IP != '') $strSQL = $strSQL." and ".$DB_IPCONTROL_IP."='".$QUERY_IP."'";
	if ($QUERY_USER != '') $strSQL = $strSQL." and ".$DB_IPCONTROL_USERNAME."='".$QUERY_USER."'";
	if ($QUERY_GROUP != '') $strSQL = $strSQL." and I.".$DB_IPCONTROL_GROUPNO."='".$QUERY_GROUP."'";
	if ($QUERY_REMARK != '') $strSQL = $strSQL." and ".$DB_IPCONTROL_REMARK."='".$QUERY_REMARK."'";
	if ($QUERY_ISP != '') $strSQL = $strSQL." and _ISP='".$QUERY_ISP."'";

	return $strSQL;
}
?>