中文版 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

@ -332,7 +332,7 @@ class ReviewController extends Zend_Controller_Action
$this->db->exec($sql); $this->db->exec($sql);
} }
echo '<div class="box box-success">保存成功!'; echo '<div class="box box-success">保存成功!';
echo "</div>"; echo "</div>";
} }
if($data['status']>=0) if($data['status']>=0)
{ {
@ -345,14 +345,14 @@ class ReviewController extends Zend_Controller_Action
$mail=new WestdcMailer($this->view->config->smtp); $mail=new WestdcMailer($this->view->config->smtp);
$mail->setFrom($this->view->config->service->email,'西部数据中心服务组'); $mail->setFrom($this->view->config->service->email,'西部数据中心服务组');
if(@$data['is_expert']=='true') if(@$data['is_expert']=='true')
{ {
$mailtp=new EmailText($this->db,"review-expert-comment",array( $mailtp=new EmailText($this->db,"review-expert-comment",array(
'user' => $user->username, 'user' => $user->username,
'uuid' => $uuid, 'uuid' => $uuid,
'title'=> $md['title'], 'title'=> $md['title'],
'content' => $mdcomment 'content' => $mdcomment
)); ));
$mail->setBodyText($mailtp->getBody()); $mail->setBodyText($mailtp->getBody());
$mail->setSubject($mailtp->getSubject()); $mail->setSubject($mailtp->getSubject());
$mail->addTo($this->view->config->service->email); //管理员邮箱 $mail->addTo($this->view->config->service->email); //管理员邮箱
}else{ }else{
@ -361,11 +361,11 @@ class ReviewController extends Zend_Controller_Action
'uuid' => $uuid, 'uuid' => $uuid,
'title'=> $md['title'], 'title'=> $md['title'],
'content' => $mdcomment 'content' => $mdcomment
)); ));
$mail->setBodyText($mailtp->getBody()); $mail->setBodyText($mailtp->getBody());
$mail->setSubject($mailtp->getSubject()); $mail->setSubject($mailtp->getSubject());
$sql="select distinct(res.email) from responsible res left join role r on res.id=r.resid where r.role in ('author','resourceProvider') and r.uuid=?"; $sql="select distinct(res.email) from responsible res left join role r on res.id=r.resid where r.role in ('author','resourceProvider') and r.uuid=?";
$rows=$this->db->fetchAll($this->db->quoteInto($sql,$uuid)); $rows=$this->db->fetchAll($this->db->quoteInto($sql,$uuid));
foreach($rows as $row) foreach($rows as $row)
$mail->addTo($row['email']); //元数据作者 $mail->addTo($row['email']); //元数据作者
$mail->addCc($this->view->config->service->email); //管理员 $mail->addCc($this->view->config->service->email); //管理员
@ -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"));