public function addlikeAction() { if ($data = Zend_Json::decode($this->getRequest()->getRawBody())) { try { $customer_id = $this->getSession()->getCustomerId(); $ip = md5($_SERVER['REMOTE_ADDR']); $ua = md5($_SERVER['HTTP_USER_AGENT']); $like = new Comment_Model_Like(); if (!$like->findByIp($data['comment_id'], $customer_id, $ip, $ua)) { $like->setCommentId($data['comment_id'])->setCustomerId($customer_id)->setCustomerIp($ip)->setAdminAgent($ua); $like->save(); $message = $this->_('Your like has been successfully added'); $html = array('success' => 1, 'message' => $message); } else { throw new Exception($this->_("You can't like more than once the same news")); } } catch (Exception $e) { $html = array('error' => 1, 'message' => $e->getMessage()); } $this->_sendHtml($html); } }