From 3a60b2a5bf93cdff491a0840606f3cf2c4cff151 Mon Sep 17 00:00:00 2001 From: Antonio Gallo Date: Fri, 28 Jan 2011 17:55:49 +0000 Subject: improved search page --- .../Application/Controllers/SearchController.php | 113 +++++++++++++++++++++ h-source/Application/Views/right.php | 2 +- h-source/Public/Css/website.css | 2 +- 3 files changed, 115 insertions(+), 2 deletions(-) diff --git a/h-source/Application/Controllers/SearchController.php b/h-source/Application/Controllers/SearchController.php index 6f96595..b35ee45 100644 --- a/h-source/Application/Controllers/SearchController.php +++ b/h-source/Application/Controllers/SearchController.php @@ -107,6 +107,119 @@ class SearchController extends BaseController { if (isset($_POST['lspci'])) { + $data['notice'] = null; + + $lspci = $this->request->post('lspci','','sanitizeHtml'); + if (strlen($lspci)<10000) + { + $flag = false; + + $lspci = nl2br($lspci); + $lspciArray = explode('
',$lspci); + $lspciResult = array(); + reset($lspciArray); + while(current($lspciArray) !== false) + { + $item = current($lspciArray); + if (stristr($item,'Slot')) + { + $temp = array(); + +// class + if (next($lspciArray) !== false) + { + $item = trim(current($lspciArray)); + if( !preg_match( '/^[a-zA-Z0-9\-\_\.\:\+\s\(\)\/\[\]]+$/i', $item ) ) + { + $flag = false; + break; + } + if( preg_match( '/Class\:(.*)\[(.*)\]/i', $item, $matches ) ) + { + $temp['className'] = $matches[1]; + $temp['classId'] = $matches[2]; + } + else + { + $temp['className'] = "unknown"; + $temp['classId'] = "unknown"; + } + } + else + { + $flag = false; + break; + } + +// vendor + if (next($lspciArray) !== false) + { + $item = trim(current($lspciArray)); + if( !preg_match( '/^[a-zA-Z0-9\-\_\.\:\+\s\(\)\/\[\]]+$/i', $item ) ) + { + $flag = false; + break; + } + if( preg_match( '/Vendor\:(.*)\[(.*)\]/i', $item, $matches ) ) + { + $temp['vendorName'] = $matches[1]; + $temp['vendorId'] = $matches[2]; + } + else + { + $temp['vendorName'] = "unknown"; + $temp['vendorId'] = "unknown"; + } + } + else + { + $flag = false; + break; + } + +// device + if (next($lspciArray) !== false) + { + $item = trim(current($lspciArray)); + if( !preg_match( '/^[a-zA-Z0-9\-\_\.\:\+\s\(\)\/\[\]]+$/i', $item ) ) + { + $flag = false; + break; + } + if( preg_match( '/Device\:(.*)\[(.*)\]/i', $item, $matches ) ) + { + $temp['deviceName'] = $matches[1]; + $temp['deviceId'] = $matches[2]; + } + else + { + $temp['deviceName'] = "unknown"; + $temp['deviceId'] = "unknown"; + } + } + else + { + $flag = false; + break; + } + + $lspciResult[] = $temp; + $flag = true; + } + next($lspciArray); + } + } + else + { + $data['notice'] = "
the lspci output is too long
\n"; + } + + if ($flag) + { + echo "
";
+				print_r($lspciResult);
+				echo "
"; + } // $clean['pciid'] = $this->request->post('lspci','','sanitizePciid'); // $data['table'] = $this->m['HardwareModel']->clear()->select()->where(array('pci_id'=>$clean['pciid']))->send(); // $data['recordNumber'] = 0; diff --git a/h-source/Application/Views/right.php b/h-source/Application/Views/right.php index f81ca1d..a37e0a2 100644 --- a/h-source/Application/Views/right.php +++ b/h-source/Application/Views/right.php @@ -22,7 +22,7 @@