Error creating table machines: ' . $conn->error .'
';
}
+
+ // Attempt to create the directory where export files will be stored later on
+ if (mkdir("/var/www/html/export", 0777, true)) {
+ echo '
';
+ }
+ // Attempt to create the directory where import files will be stored later on
+ if (mkdir("/var/www/html/import", 0777, true)) {
+ echo '
diff --git a/src/server/cyberhex-code/system/secure_zone/php/export_log.php b/src/server/cyberhex-code/system/secure_zone/php/export_log.php
index b4db339..1b94c13 100644
--- a/src/server/cyberhex-code/system/secure_zone/php/export_log.php
+++ b/src/server/cyberhex-code/system/secure_zone/php/export_log.php
@@ -38,27 +38,79 @@ if($perms[2]!=="1"){
You can use filters before you export the log. The filter preview is below.
+
Export log
connect_error) {
die("Connection failed: " . $conn->connect_error);
}
- $sql = "DELETE FROM log WHERE id = ?";
+ //list out the log entrys and add them to a .csv file.
+ //get num of entrys
+ $sql = "SELECT count(*) AS log_count FROM log";
$stmt = $conn->prepare($sql);
- $stmt->bind_param("i", $id);
// Execute the statement
$stmt->execute();
+ // Get the result
+ $result = $stmt->get_result();
+ $row = $result->fetch_assoc();
+ $num_of_log_entrys=$row["log_count"];
$stmt->close();
$conn->close();
- echo '
- Log entry deleted.
-
';
+ //now we got the ammount of netrys, write them to file
+ $conn = new mysqli($DB_SERVERNAME, $DB_USERNAME, $DB_PASSWORD, $DB_DATABASE);
+ if ($conn->connect_error) {
+ die("Connection failed: " . $conn->connect_error);
+ }
+ while($num_of_log_entrys!=0){
+ $sql = "SELECT * FROM log where id > $last_id";
+ $stmt = $conn->prepare($sql);
+ // Execute the statement
+ $stmt->execute();
+ // Get the result
+ $result = $stmt->get_result();
+ $row = $result->fetch_assoc();
+ $last_id=$row["id"];
+ $loglevel=$row["loglevel"];
+ $logtext=$row["logtext"];
+ $machine_id=$row["machine_id"];
+ $time=$row["time"];
+ $show=true;
+ //evaluate filter, decide if entry should be shown or not
+ if(isset($_GET["loglevel"]) && $_GET["loglevel"]!==""){
+ if(stripos($loglevel,$_GET["loglevel"])===false){
+ $show=false;
+ }
+ }if(isset($_GET["logtext"]) && $_GET["logtext"]!==""){
+ if(stripos($logtext,$_GET["logtext"])===false){
+ $show=false;
+ }
+ }if(isset($_GET["machine_id"]) && $_GET["machine_id"]!==""){
+ if(stripos($machine_id,$_GET["machine_id"])===false){
+ $show=false;
+ }
+ }if(isset($_GET["time"]) && $_GET["time"]!==""){
+ if(stripos($time,$_GET["time"])===false){
+ $show=false;
+ }
+ }
+ if($show==true){
+ echo('
');
+ echo('| '.$last_id.' | ');
+ echo(''.$loglevel.' | ');
+ echo(''.$logtext.' | ');
+ echo(''.$machine_id.' | ');
+ echo(''.$time.' | ');
+ echo('
');
+ }
+ $stmt->close();
+ $num_of_log_entrys--;
+ }
+ $conn->close();
}
//get count of log entrys
@@ -93,12 +145,12 @@ if($perms[2]!=="1"){
echo('