.
if (!defined('EG')) die('Direct access not allowed!');
class SearchController extends BaseController
{
public function __construct($model, $controller, $queryString)
{
$this->_topMenuClasses['search'] = " class='currentitem'";
parent::__construct($model, $controller, $queryString);
$this->model('HardwareModel');
$data['title'] = 'search - '.Website::$generalName;
$this->append($data);
}
public function form($lang = 'en')
{
$this->cleverLoad('form');
$this->right();
}
public function results($lang = 'en')
{
Params::$nullQueryValue = 'undef';
$argKeys = array(
'page:forceNat' => 1,
'action:sanitizeAlphanum' => 'search',
'type:sanitizeString' => 'notebook',
'model:sanitizeString' => 'undef',
);
$this->setArgKeys($argKeys);
$this->shift(1);
if (strcmp($this->viewArgs['action'],'search') === 0)
{
Params::$whereClauseSymbolArray = array('like');
$whereClause = array(
'type' => $this->viewArgs['type'],
'model' => "like '%".$this->viewArgs['model']."%'",
'-deleted' => "no",
);
$recordNumber = $this->m['HardwareModel']->clear()->where($whereClause)->orderBy("id_hard desc")->rowNumber();
$data['recordNumber'] = $recordNumber;
//load the Pages helper
$this->helper('Pages',$this->controller.'/results/'.$this->lang,'page');
$page = $this->viewArgs['page'];
//set the limit clause
$limit = $this->h['Pages']->getLimit($page,$recordNumber,10);
$data['table'] = $this->m['HardwareModel']->clear()->select('id_hard,model,type,comm_year')->where($whereClause)->limit($limit)->orderBy("id_hard desc")->send();
// echo $this->m['HardwareModel']->getQuery();
$data['pageList'] = $this->h['Pages']->render($page-3,7);
$this->append($data);
$this->cleverLoad('results');
$this->right();
}
}
public function pciid($lang = 'en')
{
if (isset($_POST['pciid']))
{
$clean['pciid'] = $this->request->post('pciid','','sanitizePciid');
$data['table'] = $this->m['HardwareModel']->clear()->select()->where(array('pci_id'=>$clean['pciid']))->send();
$data['recordNumber'] = 0;
$this->append($data);
$this->cleverLoad('results');
$this->right();
}
}
public function lspci($lang = 'en')
{
if (isset($_POST['lspci']))
{
$data['notice'] = null;
$lspci = $this->request->post('lspci','','sanitizeHtml');
$lspciResult = array();
$flag = true;
if (strlen($lspci)<50000)
{
$lspci = nl2br($lspci);
$lspciArray = explode('
',$lspci);
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'] = sanitizeAll($matches[1]);
$temp['classId'] = sanitizeAll($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'] = sanitizeAll($matches[1]);
$temp['vendorId'] = sanitizeAll($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'] = sanitizeAll($matches[1]);
$temp['deviceId'] = sanitizeAll($matches[2]);
}
else
{
$temp['deviceName'] = "unknown";
$temp['deviceId'] = "unknown";
}
}
else
{
$flag = false;
break;
}
$lspciResult[] = $temp;
}
next($lspciArray);
}
if (count($lspciResult) === 0 or $flag === false)
{
$data['notice'] = "