aboutsummaryrefslogtreecommitdiff
path: root/h-source/Application/Models/VendorsModel.php
diff options
context:
space:
mode:
authorAntonio Gallo <tonicucoz@gmail.com>2012-05-24 09:23:37 +0000
committerAntonio Gallo <tonicucoz@gmail.com>2012-05-24 09:23:37 +0000
commit7097598d5576ba5e9391b43f26bfc037c08d61c3 (patch)
treebbf29889dec96383b580b9a24faf5043a3ab5058 /h-source/Application/Models/VendorsModel.php
parent7fb84c6c0e482ae6d2f241b7fb6d75549fa7529d (diff)
all the names of the vendors are now stored inside the db and are taken from the db
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