summaryrefslogtreecommitdiffstats
path: root/modules-available
diff options
context:
space:
mode:
authorJannik Schönartz2017-12-28 18:01:28 +0100
committerJannik Schönartz2017-12-28 18:01:28 +0100
commitddb431fa8b017790ba86e2ee86475468c848ea81 (patch)
treea1b75e89672afc8f52f292d6dd1e3b11e68b8b20 /modules-available
parent[usb-lock-off] API device delete function now works with the new db struct. (diff)
downloadslx-admin-ddb431fa8b017790ba86e2ee86475468c848ea81.tar.gz
slx-admin-ddb431fa8b017790ba86e2ee86475468c848ea81.tar.xz
slx-admin-ddb431fa8b017790ba86e2ee86475468c848ea81.zip
[usb-lock-off] Code cleanup and removed code for the old db struct.
Diffstat (limited to 'modules-available')
-rw-r--r--modules-available/usblockoff/api.inc.php54
-rw-r--r--modules-available/usblockoff/page.inc.php39
-rw-r--r--modules-available/usblockoff/templates/usb-device-list.html8
3 files changed, 1 insertions, 100 deletions
diff --git a/modules-available/usblockoff/api.inc.php b/modules-available/usblockoff/api.inc.php
index 9467d67b..298dd948 100644
--- a/modules-available/usblockoff/api.inc.php
+++ b/modules-available/usblockoff/api.inc.php
@@ -12,12 +12,6 @@ function HandleParameters()
$ip = Request::get('ip', 0, 'string');
$client = Database::queryFirst("SELECT m.machineuuid AS 'muid', m.currentuser AS 'user' FROM machine AS m WHERE m.clientip=:ip", array('ip' => $ip));
- // $ruleInformation['hash'] = Request::get('hash', '', 'string');
- // $ruleInformation['parent-hash'] = Request::get('parent-hash', '', 'string');
- // $ruleInformation['via-port'] = Request::get('via-port', '', 'string');
- // $ruleInformation['with-interface'] = Request::get('with-interface', '', 'string');
- // $ruleInformation['interface-policy'] = Request::get('interface-policy', '', 'string');
- // newDevice($id, $serial, $name, $ip, $ruleInformation);
// TODO: product and vendor id necessary? It's already in the hwname part.
list($vid, $pid) = explode(':', $id);
$hwProps = array(
@@ -44,7 +38,6 @@ function HandleParameters()
}
}
-
/**
* Adds a new USB-Device to the db.
*
@@ -118,58 +111,12 @@ function addUSBHwProps($table, $hwid, $serial, $propArray) {
}
/**
- * Adds a new USB-Device to the db.
- *
- * @param string $id USB-Device id.
- * @param string $serial USB-Device serial number.
- * @param string $name USB-Device name.
- */
-/* VERSION WITH OLD DB ---------------------------------------------------------------------------------------
-function newDevice($id, $serial, $name, $ip, $ruleInformation)
-{
- $NOW = time();
- //$machineuuid = Database::queryFirst("SELECT machineuuid, currentuser FROM machine AS m WHERE m.clientip = :ip", array('ip' => $ip));
- $client = Database::queryFirst("SELECT m.machineuuid AS 'muid', m.currentuser AS 'user' FROM machine AS m WHERE m.clientip=:ip", array('ip' => $ip));
-
- // TODO: Same device when ID/Serial/Name are the same? Maybe hash value but the hash value can be different on multiple unix.
- $dbresult = Database::queryFirst("SELECT uid FROM `usb_devices` WHERE id=:id AND serial=:serialnr AND name=:name", array(
- 'id' => $id,
- 'serialnr' => $serial,
- 'name' => $name));
- if (empty($dbresult)) {
- $dbquery = Database::exec("INSERT INTO `usb_devices` (id, serial, name, machineuuid, time, user, ruleInformation) VALUES (:id, :serialnr,
- :name, :machineuuid, :now, :user, :ruleInformation)", array('id' => $id,
- 'serialnr' => $serial,
- 'name' => $name,
- 'machineuuid' => $client['muid'],
- 'now' => $NOW,
- 'user' => $client['user'],
- 'ruleInformation' => json_encode($ruleInformation)));
- echo "Successfully added";
- } else {
- $dbquery = Database::exec("UPDATE `usb_devices` SET machineuuid=:machineuuid, time=:now, user=:user, ruleInformation=:ruleInformation WHERE id=:id AND serial=:serialnr AND name=:name",
- array('id' => $id,
- 'serialnr' => $serial,
- 'name' => $name,
- 'machineuuid' => $client['muid'],
- 'now' => $NOW,
- 'user' => $client['user'],
- 'ruleInformation' => json_encode($ruleInformation)));
- echo "Successfully updated";
- }
-
-}
-*/
-/**
* Deletes a device from the db given a serial number.
*
* @param string $serial USB-Device serial number.
*/
function deleteDevice($id, $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(
@@ -179,5 +126,4 @@ function deleteDevice($id, $serial)
} else {
echo "Type is not a USB device";
}
-
}
diff --git a/modules-available/usblockoff/page.inc.php b/modules-available/usblockoff/page.inc.php
index fc805fe0..f582cf92 100644
--- a/modules-available/usblockoff/page.inc.php
+++ b/modules-available/usblockoff/page.inc.php
@@ -19,16 +19,12 @@ class Page_usblockoff extends Page
}
$this->action = Request::post('action');
- error_log($this->action);
if ($this->action === 'updateConfig') {
$this->updateConfig();
} elseif ($this->action === 'deleteConfig') {
$this->deleteConfig();
}
- // elseif ($this->action === 'addDevices') {
- // $this->addDevices();
- //}
}
/**
@@ -39,7 +35,6 @@ class Page_usblockoff extends Page
$this->loadConfigChooser();
}
-
protected function loadConfigChooser()
{
$dbquery = Database::simpleQuery("SELECT configid, configname FROM `usb_configs`");
@@ -187,32 +182,7 @@ class Page_usblockoff extends Page
private function ajaxDeviceList()
{
-
- //$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
- WHERE m.machineuuid=:machineuuid", array('machineuuid' => $entry['machineuuid']));
-
- $device['uid'] = $entry['uid'];
- $device['id'] = $entry['id'];
- $device['name'] = $entry['name'];
- $device['serial'] = $entry['serial'];
- $device['machineuuid'] = $entry['machineuuid'];
- $device['user'] = $entry['user'];
- $device['clientip'] = $locationquery['ip'];
- $device['date'] = date('d.m.Y', $entry['time']);
- $device['time'] = date('G:i', $entry['time']);
- $device['location'] = $locationquery['name'];
- $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;
- }*/
$settings = array();
$setting = array();
@@ -292,19 +262,10 @@ class Page_usblockoff extends Page
$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;
}
diff --git a/modules-available/usblockoff/templates/usb-device-list.html b/modules-available/usblockoff/templates/usb-device-list.html
index a6cd96b0..a2964987 100644
--- a/modules-available/usblockoff/templates/usb-device-list.html
+++ b/modules-available/usblockoff/templates/usb-device-list.html
@@ -75,13 +75,6 @@
function clickRow(tbody, uid) {
$(tbody).toggleClass('selected');
countSelected();
-
- // OLD SEND TO PHP STUFF
- //if ($(tbody).find('#uid').length == 1) {
- // $(tbody).find('#uid').remove();
- //} else {
- // $(tbody).append('<input type="hidden" name="uids[]" value="' + uid + '" id="uid">');
- //}
}
function countSelected() {
@@ -120,6 +113,7 @@
}
}
+ // This function is used in the usb-configuration.html. (myModalAddButton)
function addDevices() {
$('.selected').each(function () {
var rule = $('#prop-action').val();