From 125d2d97ceea0b2ef603bbbeacdeb5e2ac8e6379 Mon Sep 17 00:00:00 2001 From: wlx Date: Fri, 25 Dec 2009 09:33:09 +0000 Subject: [PATCH] =?UTF-8?q?fix=20bug=20#81.=20=E4=BF=AE=E5=A4=8D=E7=99=BB?= =?UTF-8?q?=E5=BD=95=E7=94=A8=E6=88=B7=E4=B8=8D=E8=83=BD=E7=95=99=E8=A8=80?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/default/controllers/DataController.php | 14 ++++---------- application/models/CommentForm.php | 5 ++--- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/application/default/controllers/DataController.php b/application/default/controllers/DataController.php index 51291b99..5a8c24e4 100755 --- a/application/default/controllers/DataController.php +++ b/application/default/controllers/DataController.php @@ -557,16 +557,11 @@ class DataController extends Zend_Controller_Action $user=Zend_Auth::getInstance()->getIdentity(); $commentForm=new CommentForm(); $formdata['uuid']=$uuid; - $formdata['id']=0;//用户ID,默认为0,即未登录用户 + $formdata['uid']=0;//用户ID,默认为0,即未登录用户 $this->view->addHelperPath('helper','Zend_View_Helper_'); if ($this->_request->isPost()) { include_once("bcspamblock.php"); $formdata=$this->_request->getPost(); - if ($user) { - $formdata['id']=$user->id; - $formdata['author']=$user->username; - $formdata['email']=$user->email; - } if (bcspamblock_verify() && $commentForm->isValid($formdata)) { $sql="insert into comments (userid,uuid,author,email,url,ip,content,agent,type) values(?,?,?,?,?,?,?,?,?)"; $agent=$this->_request->getHeader('User-Agent'); @@ -575,12 +570,11 @@ class DataController extends Zend_Controller_Action $stripper = new Zend_Filter_StripTags('strong');//剔除特殊字符HTML $content=$stripper->filter($formdata['content']); $author=$stripper->filter($formdata['author']); - $this->db->query($sql,array($formdata['id'],$formdata['uuid'],$author,$formdata['email'],$formdata['url'],$ip,$content,$agent,$type)); + $this->db->query($sql,array($formdata['uid'],$formdata['uuid'],$author,$formdata['email'],$formdata['url'],$ip,$content,$agent,$type)); $formdata['content']=''; } - } - if ($user) { - $formdata['id']=$user->id; + } elseif ($user) { + $formdata['uid']=$user->id; $formdata['author']=$user->username; $formdata['email']=$user->email; } diff --git a/application/models/CommentForm.php b/application/models/CommentForm.php index c1fa4a4c..67df79d2 100644 --- a/application/models/CommentForm.php +++ b/application/models/CommentForm.php @@ -27,7 +27,7 @@ class CommentForm extends Zend_Form $spam->addPrefixPath('Validator','validator/','validate') ->addValidator('SpamBlock'); - $id = new Zend_Form_Element_Hidden('id'); + $uid = new Zend_Form_Element_Hidden('uid'); $uuid = new Zend_Form_Element_Hidden('uuid'); $redirect=new Zend_Form_Element_Hidden('redirect'); @@ -35,8 +35,7 @@ class CommentForm extends Zend_Form $submit = new Zend_Form_Element_Submit('submit'); $submit->setLabel('评论'); $submit->setAttrib('id', 'commentbutton'); - $this->addElements(array($author,$email, $url, $spam, $content, $submit,$id, $uuid)); - + $this->addElements(array($author,$email, $url, $spam, $content, $submit,$uid, $uuid)); $this->clearDecorators(); $this->addDecorator('FormElements') ->addDecorator('HtmlTag', array('tag' => '