Update add_client.php
This commit is contained in:
@@ -65,6 +65,7 @@ include "../../../config.php";
|
|||||||
* setup_script => server location, to download settings, databases etc
|
* setup_script => server location, to download settings, databases etc
|
||||||
* add installer.exe to download list => downloads the app and all the files
|
* add installer.exe to download list => downloads the app and all the files
|
||||||
*/
|
*/
|
||||||
|
$location=htmlspecialchars($_POST["location"]);
|
||||||
//create machineid:
|
//create machineid:
|
||||||
$random_bytes = random_bytes(6);
|
$random_bytes = random_bytes(6);
|
||||||
|
|
||||||
@@ -72,7 +73,21 @@ include "../../../config.php";
|
|||||||
$machineid = bin2hex($random_bytes);
|
$machineid = bin2hex($random_bytes);
|
||||||
if($_POST["ip"]=="")
|
if($_POST["ip"]=="")
|
||||||
$ip="nan";
|
$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 = $conn->prepare("INSERT INTO machines (machine_name, machine_location,machine_ip) VALUES (?, ?, ?)");
|
||||||
$stmt->bind_param("sss", $machineid, $location, $ip);
|
$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='/export/setup.txt' download>Download config file2</a>");
|
||||||
echo("<a href='/install.bat' download>Download installer</a>");
|
echo("<a href='/install.bat' download>Download installer</a>");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user