diff options
Diffstat (limited to 'modules-available/usblockoff/page.inc.php')
-rw-r--r-- | modules-available/usblockoff/page.inc.php | 63 |
1 files changed, 59 insertions, 4 deletions
diff --git a/modules-available/usblockoff/page.inc.php b/modules-available/usblockoff/page.inc.php index efb85fb1..fc805fe0 100644 --- a/modules-available/usblockoff/page.inc.php +++ b/modules-available/usblockoff/page.inc.php @@ -145,7 +145,7 @@ class Page_usblockoff extends Page { $form = array(); - $rulesConf; + $rulesConf = null; if ($id == 0) { $currentdir = getcwd(); @@ -188,8 +188,9 @@ class Page_usblockoff extends Page private function ajaxDeviceList() { - $usbdevices = array(); - + //$usbdevices = array(); + $usbdevices = $this->getUsbDeviceList(); +/* $dbquery = Database::simpleQuery("SELECT * FROM `usb_devices`"); while ($entry = $dbquery->fetch(PDO::FETCH_ASSOC)) { $locationquery = Database::queryFirst("SELECT l.locationname AS 'name', m.clientip AS 'ip' FROM machine AS m JOIN location AS l ON l.locationid=m.locationid @@ -211,7 +212,7 @@ class Page_usblockoff extends Page $device['via-port'] = $ruleInformation['via-port']; $device['with-interface'] = $ruleInformation['with-interface']; $usbdevices[] = $device; - } + }*/ $settings = array(); $setting = array(); @@ -255,4 +256,58 @@ class Page_usblockoff extends Page 'settings' => array_values($settings) )); } + + private function getUsbDeviceList() { + $usbdevices = array(); + + // TODO: Per USB Device 3 querys are executed.. better build a more complex sql query? + + $dbquery = Database::simpleQuery("SELECT * FROM `usblockoff_hw`"); + while ($entry = $dbquery->fetch(PDO::FETCH_ASSOC)) { + + $device = array(); + + // Get all props from the hw table. + $dbquery2 = Database::simpleQuery("SELECT * FROM `statistic_hw_prop` WHERE hwid=:hwid", array( + 'hwid' => $entry['hwid'] + )); + + while ($prop = $dbquery2->fetch(PDO::FETCH_ASSOC)) { + $device[$prop['prop']] = $prop['value']; + } + + // Get all props from the device table. + $dbquery3 = Database::simpleQuery("SELECT * FROM `usblockoff_hw_prop` WHERE hwid=:hwid AND serial=:serial", array( + 'hwid' => $entry['hwid'], + 'serial' => $entry['serial'] + )); + + while ($prop = $dbquery3->fetch(PDO::FETCH_ASSOC)) { + $device[$prop['prop']] = $prop['value']; + } + if (!empty($device['machineuuid'])) { + $locationquery = Database::queryFirst("SELECT l.locationname AS 'name', m.clientip AS 'ip' FROM machine AS m JOIN location AS l ON l.locationid=m.locationid + WHERE m.machineuuid=:machineuuid", array('machineuuid' => $entry['machineuuid'])); + $device['clientip'] = $locationquery['ip']; + $device['location'] = $locationquery['name']; + } + + //$device['uid'] = $entry['uid']; + $device['id'] = $device['vendorid'] . ":" . $device['productid']; + //$device['name'] = $entry['name']; + $device['serial'] = $entry['serial']; + //$device['machineuuid'] = $entry['machineuuid']; + //$device['user'] = $entry['user']; + $device['date'] = date('d.m.Y', $device['lastseen']); + $device['time'] = date('G:i', $device['lastseen']); + //$ruleInformation = json_decode($entry['ruleInformation'], true); + //$device['hash'] = $ruleInformation['hash']; + //$device['parent-hash'] = $ruleInformation['parent-hash']; + //$device['via-port'] = $ruleInformation['via-port']; + //$device['with-interface'] = $ruleInformation['with-interface']; + $usbdevices[] = $device; + } + + return $usbdevices; + } } |