diff options
Diffstat (limited to 'h-source/Application/Controllers')
-rw-r--r-- | h-source/Application/Controllers/BluetoothController.php | 6 | ||||
-rw-r--r-- | h-source/Application/Controllers/GenericController.php | 24 |
2 files changed, 16 insertions, 14 deletions
diff --git a/h-source/Application/Controllers/BluetoothController.php b/h-source/Application/Controllers/BluetoothController.php index 4730081..58269bf 100644 --- a/h-source/Application/Controllers/BluetoothController.php +++ b/h-source/Application/Controllers/BluetoothController.php @@ -45,6 +45,7 @@ class BluetoothController extends GenericController $this->m['HardwareModel']->strongConditions['update'] = array( "checkNotEmpty" => "model|you have to fill the <i>model name</i> entry", "checkMatch|/^[a-zA-Z0-9\-\_\.\+\s\(\)\@\[\]\/]+$/" => "model|characters not allowed in the <i>model name</i> entry", + "+checkMatch|/^[a-zA-Z0-9]{4}(\:)[a-zA-Z0-9]{4}$/" => "pci_id|<i>VendorID:ProductID</i> has to have the following format: [a-zA-Z0-9]{4}(\:)[a-zA-Z0-9]{4}", "checkLength|99" => "model", "+checkLength|299" => "distribution", "++checkIsStrings|".Wifi::$commYear => "comm_year", @@ -55,6 +56,7 @@ class BluetoothController extends GenericController $this->m['HardwareModel']->strongConditions['insert'] = array( "checkNotEmpty" => "model|you have to fill the <i>model name</i> entry", "checkMatch|/^[a-zA-Z0-9\-\_\.\+\s\(\)\@\[\]\/]+$/" => "model|characters not allowed in the <i>model name</i> entry", + "+checkMatch|/^[a-zA-Z0-9]{4}(\:)[a-zA-Z0-9]{4}$/" => "pci_id|<i>VendorID:ProductID</i> has to have the following format: [a-zA-Z0-9]{4}(\:)[a-zA-Z0-9]{4}", "checkLength|99" => "model", "+checkLength|299" => "distribution", "++checkIsStrings|".Wifi::$commYear => "comm_year", @@ -67,7 +69,6 @@ class BluetoothController extends GenericController "checkLength|20000" => "description", "+checkLength|49" => "kernel", "++checkLength|49" => "driver", - "+checkMatch|/^[a-zA-Z0-9]{4}(\:)[a-zA-Z0-9]{4}$/" => "pci_id|<i>VendorID:ProductID</i> has to have the following format: [a-zA-Z0-9]{4}(\:)[a-zA-Z0-9]{4}", "++checkMatch|/^[a-zA-Z0-9\-\_\.\+\s\/\,\:\;\(\)\[\]]+$/" => "driver|only the following characters are allowed for the <i>driver</i> entry: a-z A-Z 0-9 - _ . + s / , : ; ( ) [ ]", ); @@ -76,7 +77,6 @@ class BluetoothController extends GenericController "checkLength|20000" => "description", "+checkLength|49" => "kernel", "++checkLength|49" => "driver", - "+checkMatch|/^[a-zA-Z0-9]{4}(\:)[a-zA-Z0-9]{4}$/" => "pci_id|<i>VendorID:ProductID</i> has to have the following format: [a-zA-Z0-9]{4}(\:)[a-zA-Z0-9]{4}", "++checkMatch|/^[a-zA-Z0-9\-\_\.\+\s\/\,\:\;\(\)\[\]]+$/" => "driver|only the following characters are allowed for the <i>driver</i> entry: a-z A-Z 0-9 - _ . + s / , : ; ( ) [ ]", ); @@ -94,7 +94,7 @@ class BluetoothController extends GenericController $this->setArgKeys($argKeys); - $data['title'] = 'Soundcard'; + $data['title'] = 'Bluetooth'; $this->append($data); } diff --git a/h-source/Application/Controllers/GenericController.php b/h-source/Application/Controllers/GenericController.php index f58fa24..0bc3705 100644 --- a/h-source/Application/Controllers/GenericController.php +++ b/h-source/Application/Controllers/GenericController.php @@ -79,13 +79,14 @@ class GenericController extends BaseController { if ($this->checkDist()) { - if ($this->checkVendorId()) + $pci_id = $this->request->post('pci_id','','sanitizeAll'); + $interface = $this->request->post('interface','not-defined','sanitizeAll'); + + if ($this->checkVendorId($interface)) { - $pci_id = $this->request->post('pci_id','','sanitizeAll'); - if (strcmp($this->m['HardwareModel']->type,'notebook') !== 0) { - $this->m['HardwareModel']->values['vendor'] = sanitizeAll(Vendors::getName($pci_id)); + $this->m['HardwareModel']->values['vendor'] = sanitizeAll(Vendors::getName($pci_id,$interface)); $this->m['HardwareModel']->databaseConditions['insert']['+checkUnique'] = 'pci_id|<i>VendorID:ProductID</i> is already present in the database. This means that the device you are trying to insert is already in the database'; } @@ -222,13 +223,14 @@ class GenericController extends BaseController { if ($this->checkDist()) { - if ($this->checkVendorId()) + $pci_id = $this->request->post('pci_id','','sanitizeAll'); + $interface = $this->request->post('interface','not-defined','sanitizeAll'); + + if ($this->checkVendorId($interface)) { - $pci_id = $this->request->post('pci_id','','sanitizeAll'); - if (strcmp($this->m['HardwareModel']->type,'notebook') !== 0) { - $this->m['HardwareModel']->values['vendor'] = sanitizeAll(Vendors::getName($pci_id)); + $this->m['HardwareModel']->values['vendor'] = sanitizeAll(Vendors::getName($pci_id,$interface)); $this->m['HardwareModel']->databaseConditions['update']['+checkUniqueCompl'] = 'pci_id|<i>VendorID:ProductID</i> is already present in the database. This means that the device you are trying to insert is already in the database'; } @@ -273,7 +275,7 @@ class GenericController extends BaseController } } - protected function checkVendorId() + protected function checkVendorId($interface) { if (strcmp($this->m['HardwareModel']->type,'notebook') === 0) return true; @@ -283,14 +285,14 @@ class GenericController extends BaseController { if (preg_match('/^[a-zA-Z0-9]{4}(\:)[a-zA-Z0-9]{4}$/',$_POST['pci_id'])) { - if (Vendors::check($_POST['pci_id'])) + if (Vendors::check($_POST['pci_id'],$interface)) { return true; } else { $this->m['HardwareModel']->result = false; - $this->m['HardwareModel']->notice = "<div class='alert'>Vendorid code non present in the list, please open an issue <a href='".$this->baseUrl."/issues/viewall/".Lang::$current."'>here</a> in order to ask the insertion of your vendor</div>\n"; + $this->m['HardwareModel']->notice = "<div class='alert'>Vendorid code non present in the list, please open an issue <a href='".$this->baseUrl."/issues/viewall/".Lang::$current."'>here</a> in order to ask the insertion of your vendor. NB: if it is a USB device, please choose the right interface. If it is not a USB device, and you are not sure about the right interface, choose not-defined, and it should work fine</div>\n"; return false; } } |