diff options
Diffstat (limited to 'modules-available/usblockoff')
-rw-r--r-- | modules-available/usblockoff/api.inc.php | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/modules-available/usblockoff/api.inc.php b/modules-available/usblockoff/api.inc.php index 318f21a1..708303a8 100644 --- a/modules-available/usblockoff/api.inc.php +++ b/modules-available/usblockoff/api.inc.php @@ -64,23 +64,28 @@ function newDevice($id, $serial, $hwProps, $deviceProps) // TODO: addHwProps('statistic_hw_prop', $hwid, $hwProps); - // 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)); - - if (empty($dbquery2)) { - Database::exec("INSERT INTO `usblockoff_hw` (hwid, serial) VALUES (:hwid, :serial)", array( + // Only when the device has a serial number add the specific hw props. + // TODO: !!! Are there data transfer devices without a serial number? !!! + if (!empty($serial)) { + // 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)); - // Add all the prop values to the usblockoff_hw_prop table. - // PROP: serial, machineuuid, time, user, ruleInformation, Port, hash, interface-policy - addUSBHwProps('usblockoff_hw_prop', $hwid, $serial, $deviceProps); + if (empty($dbquery2)) { + Database::exec("INSERT INTO `usblockoff_hw` (hwid, serial) VALUES (:hwid, :serial)", array( + 'hwid' => $hwid, + 'serial' => $serial + )); + } - echo "Successfully added"; + // Add all the prop values to the usblockoff_hw_prop table. + // PROP: serial, machineuuid, time, user, ruleInformation, Port, hash, interface-policy + addUSBHwProps('usblockoff_hw_prop', $hwid, $serial, $deviceProps); + echo "Successfully added"; + } else { + echo "No specific props were added. Device has no serial number"; + } } function addHwProps($table, $hwid, $propArray) { |