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' => '