aboutsummaryrefslogtreecommitdiff
path: root/h-source/Application/Models/VendorsModel.php
diff options
context:
space:
mode:
Diffstat (limited to 'h-source/Application/Models/VendorsModel.php')
-rw-r--r--h-source/Application/Models/VendorsModel.php50
1 files changed, 50 insertions, 0 deletions
diff --git a/h-source/Application/Models/VendorsModel.php b/h-source/Application/Models/VendorsModel.php
index c9e8acc..0b06d52 100644
--- a/h-source/Application/Models/VendorsModel.php
+++ b/h-source/Application/Models/VendorsModel.php
@@ -28,5 +28,55 @@ class VendorsModel extends Model_Tree {
parent::__construct();
}
+
+ public function check($id,$interface = 'USB')
+ {
+ if (preg_match('/^[a-zA-Z0-9]{4}(\:)[a-zA-Z0-9]{4}$/',$id))
+ {
+ $clean['bus'] = strcmp($interface,'USB') === 0 ? "USB" : "PCI";
+
+ $temp = explode(':',$id);
+ $clean['vendorId'] = sanitizeAlphanum($temp[0]);
+
+ $number = $this->clear()->where(array("vendorid" => $clean['vendorId'], "bus" => $clean['bus']))->rowNumber();
+
+ if ($number > 0)
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public function getName($id,$interface)
+ {
+ if ($this->check($id,$interface))
+ {
+ $clean['bus'] = strcmp($interface,'USB') === 0 ? "USB" : "PCI";
+
+ $temp = explode(':',$id);
+ $clean['vendorId'] = sanitizeAlphanum($temp[0]);
+
+ $res = $this->clear()->where(array("vendorid" => $clean['vendorId'], "bus" => $clean['bus']))->send();
+
+ if (count($res) > 0)
+ {
+ return $res[0]['vendors']['clean_name'];
+ }
+ }
+ return 'not-known';
+ }
+ public function getFullName($name)
+ {
+ $clean['name'] = sanitizeAll($name);
+
+ $res = $this->clear()->where(array("clean_name" => $clean['name']))->send();
+
+ if (count($res) > 0)
+ {
+ return $res[0]['vendors']['full_name'];
+ }
+ return $clean['name'];
+ }
} \ No newline at end of file