Current Threads
You are not allowed to delete log entries. (insufficient permissions)
';
}else{
$id=htmlspecialchars($_GET["delete"]);
$conn = new mysqli($DB_SERVERNAME, $DB_USERNAME, $DB_PASSWORD, $DB_DATABASE);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "DELETE FROM vir_notify WHERE id = ?";
$stmt = $conn->prepare($sql);
$stmt->bind_param("i", $id);
// Execute the statement
$stmt->execute();
$stmt->close();
$conn->close();
echo '
Log entry deleted.
';
}
}
if(isset($_GET["delete_all"])){
if($perms[3]!=="1"){
echo '
You are not allowed to delete log entries. (insufficient permissions)
';
}else{
$conn = new mysqli($DB_SERVERNAME, $DB_USERNAME, $DB_PASSWORD, $DB_DATABASE);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "DELETE FROM vir_notify";
$stmt = $conn->prepare($sql);
// Execute the statement
$stmt->execute();
$stmt->close();
$conn->close();
echo '
Log deleted.
';
}
}
// Define page size and current page
$page_size = 50;
$current_page = htmlspecialchars(isset($_GET['page']) ? intval($_GET['page']) : 1);
$offset = ($current_page - 1) * $page_size;
// Get total number of log entries based on filters
$conn = new mysqli($DB_SERVERNAME, $DB_USERNAME, $DB_PASSWORD, $DB_DATABASE);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT count(vir_notify.id) AS log_count FROM machines,vir_notify WHERE machine_name=machine_id AND machine_location LIKE ? AND path LIKE ? AND hash LIKE ? AND machine_id LIKE ? AND action LIKE ?";
$stmt = $conn->prepare($sql);
$path = "%" . $path . "%";
$hash = "%" . $hash . "%";
$machine_id = "%" . $machine_id . "%";
$machine_location = "%" . $machine_location . "%";
$action = "%" . $action . "%";
$stmt->bind_param("sssss",$machine_location, $path, $hash, $machine_id, $action);
$stmt->execute();
$result = $stmt->get_result();
$row = $result->fetch_assoc();
$total_entries = $row["log_count"];
// Calculate total pages
$total_pages = ceil($total_entries / $page_size);
// Query log entries for the current page with filters
$sql = "SELECT * FROM machines,vir_notify WHERE machine_location LIKE ? AND path LIKE ? AND hash LIKE ? AND machine_id LIKE ? AND action LIKE ? AND machine_name=machine_id ORDER BY vir_notify.id DESC LIMIT ?, ?";
$stmt = $conn->prepare($sql);
$path = "%" . $path . "%";
$hash = "%" . $hash . "%";
$machine_id = "%" . $machine_id . "%";
$machine_location = "%" . $machine_location . "%";
$action = "%" . $action . "%";
$stmt->bind_param("sssssii",$machine_location, $path, $hash, $machine_id, $action, $offset, $page_size);
$stmt->execute();
$result = $stmt->get_result();
// Display log entries
echo '
';
echo '';
echo '';
echo 'Entry id Machine id Location File Hash Action taken Delete entry ';
echo ' ';
echo ' ';
echo '';
// Display filter options
echo '';
echo '';
echo ' ';
while($row = $result->fetch_assoc()) {
echo '';
echo '' . $row["id"] . ' ';
echo '' . $row["machine_id"] . ' ';
echo '' . $row["machine_location"] . ' ';
echo '' . $row["path"] . ' ';
echo '' . $row["hash"] . ' ';
echo '' . $row["action"] . ' ';
echo 'delete ';
echo ' ';
}
echo ' ';
echo '
';
$conn->close();
// Display pagination links with filter query
echo '
';
echo '';
echo ' ';
?>