中文版 review/search 中增加了关键词的过滤
This commit is contained in:
parent
0d608ca06c
commit
71ef7b0cd3
|
@ -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(
|
||||||
|
'<'=>'<',
|
||||||
|
'>'=>'>',
|
||||||
|
"\'"=>'’',
|
||||||
|
"\""=>'”',
|
||||||
|
);
|
||||||
|
|
||||||
|
$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"));
|
||||||
|
|
Loading…
Reference in New Issue