summaryrefslogtreecommitdiffstats
path: root/modules-available
diff options
context:
space:
mode:
Diffstat (limited to 'modules-available')
-rw-r--r--modules-available/usblockoff/api.inc.php23
1 files changed, 18 insertions, 5 deletions
diff --git a/modules-available/usblockoff/api.inc.php b/modules-available/usblockoff/api.inc.php
index 708303a8..9467d67b 100644
--- a/modules-available/usblockoff/api.inc.php
+++ b/modules-available/usblockoff/api.inc.php
@@ -38,8 +38,9 @@ function HandleParameters()
);
newDevice($id, $serial, $hwProps, $deviceProps);
} elseif ($getAction == "deletedevice") {
+ $id = Request::get('id', '', 'string');
$serial = Request::get('serial', '', 'string');
- deleteDevice($serial);
+ deleteDevice($id, $serial);
}
}
@@ -70,7 +71,8 @@ function newDevice($id, $serial, $hwProps, $deviceProps)
// Add the hwid -> serial in the usblockoff_hw table if not already existent.
$dbquery2 = Database::queryFirst("Select * FROM `usblockoff_hw` WHERE hwid=:hwid AND serial=:serial", array(
'hwid' => $hwid,
- 'serial' => $serial));
+ 'serial' => $serial
+ ));
if (empty($dbquery2)) {
Database::exec("INSERT INTO `usblockoff_hw` (hwid, serial) VALUES (:hwid, :serial)", array(
@@ -163,8 +165,19 @@ function newDevice($id, $serial, $name, $ip, $ruleInformation)
*
* @param string $serial USB-Device serial number.
*/
-// TODO: Edit for the new db struct.
-function deleteDevice($serial)
+function deleteDevice($id, $serial)
{
- $dbquery = Database::exec("DELETE FROM `usb_devices` WHERE serial=:serial", array('serial' => $serial));
+ // For the Old db struct
+ //Database::exec("DELETE FROM `usb_devices` WHERE serial=:serial", array('serial' => $serial));
+
+ $hw = Database::queryFirst("SELECT * FROM `statistic_hw` WHERE hwname=:id", array('id' => $id));
+ if($hw['hwtype'] === DeviceType::USB) {
+ Database::exec("DELETE FROM `usblockoff_hw` WHERE hwid=:hwid AND serial=:serial", array(
+ 'hwid' => $hw['hwid'],
+ 'serial' => $serial));
+ echo "Successfully deleted.";
+ } else {
+ echo "Type is not a USB device";
+ }
+
}