Store in GIT
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
header('Content-Type: application/json');
|
||||
require('../inc/connect.php');
|
||||
|
||||
$device_id = $_GET["id"];
|
||||
$key = $_GET["key"];
|
||||
|
||||
if($device_id == "")
|
||||
{
|
||||
echo '{"error":"device-id not set"}';
|
||||
exit;
|
||||
}
|
||||
|
||||
if($key== "")
|
||||
{
|
||||
echo '{"error":"key not set"}';
|
||||
exit;
|
||||
}
|
||||
|
||||
if($key != "boef1239")
|
||||
{
|
||||
echo '{"error":"invalid key"}';
|
||||
exit;
|
||||
}
|
||||
|
||||
// Check if ID actually exists
|
||||
$sql = "SELECT `id` FROM device WHERE dev_id='" . $device_id . "'";
|
||||
$query = ExecQuery($mysqli, $sql);
|
||||
|
||||
if($query->num_rows < 1){
|
||||
echo '{"error":"device-id does not exist", "device-id": "' . $device_id . '"}';
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = $query->fetch_assoc();
|
||||
|
||||
$id = $result['id'];
|
||||
|
||||
//Delete all related data
|
||||
$sql = "DELETE FROM device WHERE id=$id";
|
||||
ExecQuery($mysqli, $sql);
|
||||
$sql = "DELETE FROM alarm WHERE dev_id=$id";
|
||||
ExecQuery($mysqli, $sql);
|
||||
$sql = "DELETE FROM stream WHERE dev_id=$id";
|
||||
ExecQuery($mysqli, $sql);
|
||||
|
||||
echo '{"success":"true"}';
|
||||
?>
|
||||
Reference in New Issue
Block a user