Update create_log_backup.php

This commit is contained in:
jakani24
2024-06-09 19:20:07 +02:00
parent 904a8e0c5f
commit 4cd6a1bfea

View File

@@ -67,22 +67,22 @@ function create_server_log_backup($conn){
$fp=fopen("/var/www/html/backup/$filename","w"); $fp=fopen("/var/www/html/backup/$filename","w");
//do all the logic here and write into file //do all the logic here and write into file
// Query log entries for the export file // Query log entries for the export file
$sql = "SELECT * FROM machines,vir_notify WHERE machine_name=machine_id ORDER BY vir_notify.id DESC"; $sql = "SELECT * FROM users,server_log WHERE (userid=users.id OR userid=-1) ORDER BY server_log.id DESC";
$stmt = $conn->prepare($sql); $stmt = $conn->prepare($sql);
$stmt->execute(); $stmt->execute();
$result = $stmt->get_result(); $result = $stmt->get_result();
fwrite ($fp,"Entry id;Machine id;Machine Location;Path;Hash;Action taken\n"); fwrite ($fp,"Entry id;Loglevel;Logtext;Username;Time\n");
//now add entrys //now add entrys
while ($row = $result->fetch_assoc()) { while ($row = $result->fetch_assoc()) {
fwrite($fp,$row["id"] . ';'); fwrite($fp,$row["id"] . ';');
fwrite($fp,$row["machine_id"] . ';'); fwrite($fp,$row["loglevel"] . ';');
fwrite($fp,$row["machine_location"] . ';'); fwrite($fp,$row["logtext"] . ';');
fwrite($fp,$row["path"] . ';'); fwrite($fp,$row["username"] . ';');
fwrite($fp,$row["hash"] . ';'); fwrite($fp,$row["time"] . ';\n');
fwrite($fp,$row["action"] . ";\n");
} }
fclose($fp); fclose($fp);
$stmt->close(); $stmt->close();