Update add_client.php

This commit is contained in:
jakani24
2024-03-09 16:04:50 +01:00
parent 4dbc6495d6
commit 3d5e511bde

View File

@@ -65,6 +65,7 @@ include "../../../config.php";
* setup_script => server location, to download settings, databases etc
* add installer.exe to download list => downloads the app and all the files
*/
$location=htmlspecialchars($_POST["location"]);
//create machineid:
$random_bytes = random_bytes(6);
@@ -72,7 +73,21 @@ include "../../../config.php";
$machineid = bin2hex($random_bytes);
if($_POST["ip"]=="")
$ip="nan";
$location=htmlspecialchars($_POST["location"]);
//check if there isn't a machine with the same name allready
$sql = "SELECT * FROM machined WHERE machine_location = ?";
$stmt->bind_param("s", $location);
$stmt->execute();
// Get the result
$result = $stmt->get_result();
$stmt->close();
if($result->num_rows > 0){
//theres allready a machine with this location
echo '<div class="alert alert-danger" role="alert">
There is allready a machine with the exact same location<br>Please change the location.
</div>';
}
else{
$stmt = $conn->prepare("INSERT INTO machines (machine_name, machine_location,machine_ip) VALUES (?, ?, ?)");
$stmt->bind_param("sss", $machineid, $location, $ip);
@@ -125,6 +140,7 @@ include "../../../config.php";
echo("<a href='/export/setup.txt' download>Download config file2</a>");
echo("<a href='/install.bat' download>Download installer</a>");
}
}
?>
</div>
</div>