我正在尝试使用Log Parser Studio查看IIS日志,以确定某些IP地址最近访问过一个网站的时间。我使用以下查询至少可以让我对日志的使用寿命有所了解:
select c-ip, count(c-ip) as requestcount from '[LogFilePath]' group by c-ip order by count(c-ip) desc
我在修改它以获取具有“最后访问”日期的IP地址信息时遇到麻烦。这样的事情可能吗?还是有更好的方法去实现我想要的?
理想情况下,我想利用此查询来审核日志,并在IP地址经过X天的闲置时间后....基于IP地址撤消访问权限(在防火墙处删除访问权限,IP地址位于白名单)。
由于网站/应用程序的性质,有时候IP在90-120天内无法访问,因此使用简单的“点击计数”是行不通的。错误地删除仍然有效的IP地址的访问可能很容易,重启防火墙后,命中计数将被重置。
谢谢。
答案 0 :(得分:0)
在查询中添加MAX(DATE)。
<?php
session_start();
session_regenerate_id(true);
if (isset($_POST["LogoutBtn"])) {
$_SESSION = array();
if (ini_get("session.use cookies")) {
$yesterday = time() - (24 * 60 * 60);
$params = session_get_cookie_params();
setcookie(session_name(), "", $yesterday, $params["path"], $params["domain"], $params["secure"], $params["httponly"]);
}
session_destroy();
}
$dataFiles = array("/amacmi01_p1fma/data/DTresults.php",
"/amacmi01_p1fma/data/P1results.php",
"/amacmi01_p1fma/data/PfPresults.php");
$page = $_SERVER["PHP_SELF"];
?>
<!DOCTYPE html>
<html>
<head>
<meta author="Andrew Macmillan">
<meta charset="UTF-8">
<?php
$title = "";
switch ($page) {
case "/amacmi01_p1fma/index.php":
$title = "BBK DCS Home Page";
break;
case "/amacmi01_p1fma/admin-login.php":
$title = "DCS Admin Login";
break;
case "/amacmi01_p1fma/staff-login.php":
$title = "DCS Staff Login";
break;
case "/amacmi01_p1fma/register-staff.php":
$title = "Register New Staff";
break;
case "/amacmi01_p1fma/admin-options.php":
$title = "Admin Options";
break;
case "/amacmi01_p1fma/intranet.php":
$title = "BBK DCS Intranet Page";
break;
case "/amacmi01_p1fma/error.php":
$title = "Error Viewing Modules";
break;
case "/amacmi01_p1fma/logged-out.php":
$title = "Logging Out";
break;
case "/amacmi01_p1fma/data/DTresults.php":
$title = "Introduction to Database Technology - DT Results";
break;
case "/amacmi01_p1fma/data/P1results.php":
$title = "Web Programming using PHP - P1 Results";
break;
case "/amacmi01_p1fma/data/PfPresults.php":
$title = "Problem Solving for Programming – PfP Results";
break;
}
echo "<title>$title</title>";
if (in_array($page, $dataFiles)) {
echo '<link rel="stylesheet" type="text/css" href="../styles/style.css"/>';
} else {
echo '<link rel="stylesheet" type="text/css" href="styles/style.css"/>';
}
?>
</head>
<body>
<header>
<?php
if ($page !== "/amacmi01_p1fma/index.php" && $page !== "/amacmi01_p1fma/logged-out.php") {
if (in_array($page, $dataFiles)) {
echo '<div class="home-link">
<a href="../index.php">Return to Home Page</a>
</div>';
} else {
echo '<div class="home-link">
<a href="index.php">Return to Home Page</a>
</div>';
}
}
if (isset($_SESSION["LoggedIn"]) && $page !== "/amacmi01_p1fma/logged-out.php") {
$homeLink = "";
if (in_array($page, $dataFiles)) {
$homeLink = "../logged-out.php";
} else{
$homeLink = "logged-out.php";
}
echo '<div id="logout-form">
<form action="'.$homeLink.'" method="post">
<label for="logout-btn">You are logged in as '.$_SESSION["UserName"].'</label>
<input type="submit" name="LogoutBtn" id="logout-btn" value="Logout"/>
</form>
</div>';
}
?>
</header>