From d6fc4f494bf9ceb326fc37679f16224b91a0fc26 Mon Sep 17 00:00:00 2001 From: Antonio Gallo Date: Thu, 3 Mar 2011 16:48:20 +0000 Subject: improved the vendor selection --- h-source/Application/Include/vendors.php | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'h-source/Application/Include/vendors.php') diff --git a/h-source/Application/Include/vendors.php b/h-source/Application/Include/vendors.php index 79fcefb..8dcc312 100644 --- a/h-source/Application/Include/vendors.php +++ b/h-source/Application/Include/vendors.php @@ -3,24 +3,28 @@ class Vendors { - public static function getName($id) + public static function getName($id,$interface) { - if (self::check($id)) + if (self::check($id,$interface)) { + $idArray = strcmp($interface,'USB') === 0 ? self::$usbId : self::$pciId; + $temp = explode(':',$id); $vendorId = $temp[0]; - return self::$id[$vendorId]; + return $idArray[$vendorId]; } return 'not-known'; } - public static function check($id) + public static function check($id,$interface = 'USB') { if (preg_match('/^[a-zA-Z0-9]{4}(\:)[a-zA-Z0-9]{4}$/',$id)) { + $idArray = strcmp($interface,'USB') === 0 ? self::$usbId : self::$pciId; + $temp = explode(':',$id); $vendorId = $temp[0]; - if (array_key_exists($vendorId,self::$id)) + if (array_key_exists($vendorId,$idArray)) { return true; } @@ -28,7 +32,7 @@ class Vendors return false; } - public static $id = array( + public static $pciId = array( '0010' => 'Allied-Telesis-Inc', '001a' => 'Ascend-Communications-Inc.', '001c' => 'PEAK-System-Technik-GmbH', @@ -1802,6 +1806,9 @@ class Vendors 'feda' => 'Broadcom', 'fede' => 'Fedetec-Inc.', 'fffd' => 'XenSource-Inc.', + ); + + public static $usbId = array( '0001' => 'Frys-Electronics', '0002' => 'Ingram', '0003' => 'Club-Mac', -- cgit v1.2.3