From 7097598d5576ba5e9391b43f26bfc037c08d61c3 Mon Sep 17 00:00:00 2001 From: Antonio Gallo Date: Thu, 24 May 2012 09:23:37 +0000 Subject: all the names of the vendors are now stored inside the db and are taken from the db --- h-source/Application/Models/VendorsModel.php | 50 ++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) (limited to 'h-source/Application/Models') 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 -- cgit v1.2.3