中文版 review/search 中增加了关键词的过滤

This commit is contained in:
Li Jianxuan 2011-12-29 09:39:07 +00:00
parent 0d608ca06c
commit 71ef7b0cd3
1 changed files with 31 additions and 9 deletions

View File

@ -386,6 +386,28 @@ class ReviewController extends Zend_Controller_Action
function searchAction() function searchAction()
{ {
$key=$this->_request->getParam('q'); $key=$this->_request->getParam('q');
if(preg_match("/\"|'|<|>/",$key))
{
$data=array(
'<'=>'&lt;',
'>'=>'&gt;',
"\'"=>'',
"\""=>'”',
);
$patterns = array();
$replacements = array();
foreach($data as $k=>$v)
{
$patterns[]='/'.$k.'/i';
$replacements[]=$v;
}
ksort($patterns);
ksort($replacements);
$key=preg_replace($patterns, $replacements, $key);
}
if (!empty($key)) { if (!empty($key)) {
$search=new Search($key); $search=new Search($key);
$where=$search->sql_expr(array("m.title","m.description")); $where=$search->sql_expr(array("m.title","m.description"));