From 1de1488e496bcf1555be1b5fc0d6cbfc3a972546 Mon Sep 17 00:00:00 2001 From: jakani24 Date: Sun, 21 Jan 2024 16:54:58 +0100 Subject: [PATCH] Update add_entry.php --- .../cyberhex-code/api/php/log/add_entry.php | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/server/cyberhex-code/api/php/log/add_entry.php b/src/server/cyberhex-code/api/php/log/add_entry.php index cb2bd6b..521e98b 100644 --- a/src/server/cyberhex-code/api/php/log/add_entry.php +++ b/src/server/cyberhex-code/api/php/log/add_entry.php @@ -1,3 +1,25 @@ apikey +//put auth code here afterwards + +//add the entry to the log db +//this page has no gui, it may return ok or error +$loglevel=htmlspecialchars($_GET["loglevel"]); +$logtext=htmlspecialchars($_GET["logtext"]); +$machine_id=htmlspecialchars($_GET["machine_id"]); +//include db pw +include "../../../config.php"; +$conn = new mysqli($DB_SERVERNAME, $DB_USERNAME, $DB_PASSWORD, $DB_DATABASE); +if ($conn->connect_error) { + die("conn_err"); +} +$sql = "INSERT INTO log loglevel,machine_id,logtext VALUES (?,?,?);"; +$stmt = $conn->prepare($sql); +$stmt->bind_param("sss", $$loglevel,$machine_id,$logtext); +// Execute the statement +if(!$stmt->execute()) + echo("wrt_err"); +$stmt->close(); +$conn->close(); + ?> \ No newline at end of file