/** Check the data for spam or not * @access public * @param array $data * @return array */ public function direct(array $data) { $cleanData = $this->_checkFields($data); if ($this->_akismet->isSpam($cleanData)) { $cleanData['commentStatus'] = self::SPAM; } else { $cleanData['commentStatus'] = self::NOTSPAM; } return $cleanData; }
public function isSpam($params) { if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; } elseif (isset($_SERVER['REMOTE_ADDR'])) { $ip = $_SERVER['REMOTE_ADDR']; } else { $ip = ''; } if (isset($_SERVER['HTTP_USER_AGENT'])) { $userAgent = (string) $_SERVER['HTTP_USER_AGENT']; } else { $userAgent = ''; } if (isset($_SERVER['HTTP_REFERER'])) { $referrer = (string) $_SERVER['HTTP_REFERER']; } else { $referrer = ''; } $params['user_ip'] = $ip; $params['user_agent'] = $userAgent; if ($referrer != '') { $params['referrer'] = $referrer; } return parent::isSpam($params); }
/** Add the complaint * @access public * @param array $data * @return integer */ public function addComplaint(array $data) { if (!empty($data['csrf'])) { unset($data['csrf']); } if (empty($data['comment_date'])) { $data['comment_date'] = $this->timeCreation(); $data['created'] = $this->timeCreation(); } if (empty($data['createdBy'])) { $data['createdBy'] = $this->getUserNumber(); } if (empty($data['updatedBy'])) { $data['updatedBy'] = $this->getUserNumber(); } if (empty($data['user_ip'])) { $data['user_ip'] = Zend_Controller_Front::getInstance()->getRequest()->getClientIp(); } if (empty($data['user_agent'])) { $useragent = new Zend_Http_UserAgent(); $data['user_agent'] = $useragent->getUserAgent(); } if ($this->_akismet->isSpam($data)) { $data['comment_approved'] = self::SPAM; } else { $data['comment_approved'] = self::NOTSPAM; } return parent::insert($data); }
function actionSpam($id, $action) { $where = 'id = ' . intval($id); $row = $this->fetchRow($where); if ($row == null) { return 'Id invalid : ' . $id; } $data = Zend_Json::decode($row['fields']); Zend_Debug::dump($data); $akismet = new Zend_Service_Akismet($this->akismet_api, $this->akismet_blog); switch ($action) { case "spam": /* C'est un spam */ $akismet->submitSpam($data); $data['spam'] = true; break; case 'ham': $akismet->submitHam($data); $data['spam'] = false; break; case 'isspam': $data['spam'] = $akismet->isSpam($data); break; } $maj = array('spam' => $data['spam'], 'fields' => Zend_Json::encode($data)); $ret = $this->update($maj, $where); if ($ret == 1) { return true; } else { return false; } }
public static function isSpam($name, $url, $message) { if ($this->chkTrigger($message)) { return true; } else { // Verifica se é SPAM $akismet = new Zend_Service_Akismet(self::API_KEY, self::BLOG); $data = array('user_ip' => $_SERVER["REMOTE_ADDR"], 'user_agent' => $_SERVER["HTTP_USER_AGENT"], 'comment_type' => 'comment', 'comment_author' => $name, 'comment_author_url' => $url, 'comment_content' => $message); return $akismet->isSpam($data); } }
public function checkSpam() { $wordPressAPIKey = get_option('commenting_wpapi_key'); if (!empty($wordPressAPIKey)) { $ak = new Zend_Service_Akismet($wordPressAPIKey, WEB_ROOT); $data = $this->getAkismetData(); try { $this->is_spam = $ak->isSpam($data); } catch (Exception $e) { $this->is_spam = 1; } } else { //if not using Akismet, assume only registered users are commenting $this->is_spam = 0; } }
public function articleAction() { if ($this->_getParam('id', false)) { $news = new News(); $this->view->news = $news->getStory($this->_getParam('id')); $comments = new Comments(); $this->view->comments = $comments->getCommentsNews($this->_getParam('id')); $form = new CommentFindForm(); $form->submit->setLabel('Add a new comment'); $this->view->form = $form; if ($this->_request->isPost()) { $formData = $this->_request->getPost(); if ($form->isValid($formData)) { $data = array(); $data['comment_findID'] = $this->_getParam('id'); $data['user_ip'] = $form->getValue('comment_author_IP'); $data['user_agent'] = $form->getValue('comment_agent'); $data['comment_type'] = 'newscomment'; $data['comment_author'] = $form->getValue('comment_author'); $data['comment_author_email'] = $form->getValue('comment_author_email'); $data['comment_content'] = $form->getValue('comment_content'); $data['comment_date'] = $this->getTimeForForms(); $data['user_id'] = $this->getIdentityForForms(); $config = Zend_Registry::get('config'); $akismetkey = $config->webservice->akismetkey; $akismet = new Zend_Service_Akismet($akismetkey, 'http://www.finds.org.uk'); if ($akismet->isSpam($data)) { $data['comment_approved'] = 'spam'; } else { $data['comment_approved'] = 'moderation'; } $comments = new Comments(); $insert = $comments->insert($data); $this->_flashMessenger->addMessage('Your comment has been entered and will appear shortly!'); $this->_redirect('/news/stories/article/id/' . $this->_getParam('id')); $this->_request->setMethod('GET'); } else { $this->_flashMessenger->addMessage('There are problems with your comment submission'); $form->populate($formData); } } } else { throw new Exception('No parameter on the url string'); } }
public function commentAction() { $label = $this->_getParam('label'); if ($label === null) { throw new Zend_Exception('No label specified in PostsController::commentAction()'); } $postManager = new Post(); $post = $postManager->fetchRow(array('label = ?' => $label, 'is_active = ?' => 1)); if ($post === null) { throw new Zend_Exception('No post found with that label in PostsController::commentAction()'); } $this->view->post = $post; // form $form = new Zend_Form($this->_commentForm); $form->setAction('/posts/' . $post->label . '/comment'); $this->view->form = $form; if ($this->getRequest()->isPost()) { if ($form->isValid($_POST)) { $config = Zend_Registry::get('config'); $akismet = new Zend_Service_Akismet($config->akismet->key, 'http://codecaine.co.za'); $akismetData = array('user_ip' => $_SERVER['REMOTE_ADDR'], 'user_agent' => $_SERVER['HTTP_USER_AGENT'], 'referrer' => $_SERVER['HTTP_REFERER'], 'permalink' => 'http://codecaine.co.za/posts/' . $post->label, 'comment_type' => 'comment', 'comment_author' => $_POST['name'], 'comment_author_email' => $_POST['email'], 'comment_author_url' => $_POST['website'], 'comment_content' => $_POST['text']); if ($akismet->isSpam($akismetData)) { $this->_redirect('/spam'); } $commentManager = new Comment(); $data = $_POST; unset($data['submit']); $data['post_id'] = $post->id; $data['posted_at'] = new Zend_Db_Expr('NOW()'); $id = $commentManager->insert($data); $this->_redirect('/posts/' . $post->label . '#comment-' . $id); } } // description $this->view->metaDescription = 'Post your comments on ' . $post->title; // set title $this->_title($post->title); }
private function check_is_spam(array $info) { global $prefs, $user; if ($prefs['comments_akismet_filter'] != 'y') { return false; } if ($user && $prefs['comments_akismet_check_users'] != 'y') { return false; } try { $tikilib = TikiLib::lib('tiki'); $url = $tikilib->tikiUrl(); $akismet = new Zend_Service_Akismet($prefs['comments_akismet_apikey'], $url); return $akismet->isSpam(array('user_ip' => $tikilib->get_ip_address(), 'user_agent' => $_SERVER['HTTP_USER_AGENT'], 'referrer' => $_SERVER['HTTP_REFERER'], 'comment_type' => 'comment', 'comment_author' => $info['author'], 'comment_author_email' => $info['email'], 'comment_author_url' => $info['website'], 'comment_content' => $info['content'])); } catch (Exception $e) { TikiLib::lib('errorreport')->report(tr('Cannot perform spam check: %0', $e->getMessage())); return false; } }
protected function _checkAkismet($content, array $extraParams, Zend_Controller_Request_Http $request) { $options = XenForo_Application::getOptions(); $visitor = XenForo_Visitor::getInstance(); $result = self::RESULT_ALLOWED; if ($options->akismetKey) { $akismetParams = array('user_ip' => $request->getClientIp(false), 'user_agent' => $request->getServer('HTTP_USER_AGENT', 'Unknown'), 'referrer' => $request->getServer('HTTP_REFERER'), 'comment_type' => 'comment', 'comment_author' => $visitor['username'], 'comment_author_email' => $visitor['email'], 'comment_author_url' => $visitor['homepage'], 'comment_content' => $content); if (isset($extraParams['permalink'])) { $akismetParams['permalink'] = $extraParams['permalink']; } $akismet = new Zend_Service_Akismet($options->akismetKey, $options->boardUrl); try { $this->_checkParams['akismetIsSpam'] = $akismet->isSpam($akismetParams); $this->_checkParams['akismet'] = $akismetParams; if ($this->_checkParams['akismetIsSpam']) { $result = self::RESULT_MODERATED; $this->_resultDetails[] = array('phrase' => 'akismet_matched'); } } catch (Zend_Http_Exception $e) { } catch (Zend_Service_Exception $e) { } } return $result; }
public function indexAction() { if ($this->_request->isPost()) { if ($this->input->hasInvalid()) { $missing = ""; $notalnum = ""; $message = ""; foreach ($this->input->getInvalid() as $key => $value) { if (isset($value["isEmpty"])) { $missing .= $key . ","; } if (isset($value["notAlnum"])) { $notalnum .= $key . ","; } } if ($missing) { $message .= "Following are required {$missing} \n"; } if ($notalnum) { $message .= "Following are alpha numeric only {$notalnum}"; } throw new Zend_Service_Exception(Zend_Json::encode(array("error" => $message))); } if (!$this->_helper->csrf->isValidToken($this->token)) { throw new Zend_Service_Exception(Zend_Json::encode(array("error" => 'Token validation failed'))); } if ($this->config->antispam) { switch ($this->config->antispam) { case "typepad": $spam = new Zend_Service_TypePadAntiSpam($this->config->typepad->key, "http://" . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]); break; case "akismet": $spam = new Zend_Service_Akismet($this->config->akismet->key, "http://" . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]); break; } if (isset($spam)) { if ($spam->verifyKey()) { $params = array(); $params["user_ip"] = $_SERVER['REMOTE_ADDR']; $params["user_agent"] = $_SERVER['HTTP_USER_AGENT']; $params["referrer"] = $_SERVER['HTTP_REFERER']; $params["comment_type"] = "email"; $params["comment_author"] = $this->name; $params["comment_author_email"] = $this->email; $params["comment_content"] = $this->message; if ($spam->isSpam($params)) { throw new Zend_Service_Exception(Zend_Json::encode(array("error" => 'Message failed due to spam'))); } } } } $mail = new Zend_Mail(); $mail->setHeaderEncoding(Zend_Mime::ENCODING_BASE64); $mail->setBodyText($this->subject); $mail->setFrom($this->email, $this->name); $emails = explode(",", $this->to); $validator = new Zend_Validate_EmailAddress(); foreach ($emails as $value) { if ($validator->isValid($value)) { $mail->addTo($value); } } $mail->setSubject($this->subject); $mail->setBodyText($this->message); $mail->setBodyHtml($this->message); try { $mail->send(); } catch (Exception $e) { throw new Zend_Service_Exception(Zend_Json::encode(array("error" => 'Mail send was not successful'))); } $this->getResponse()->setBody(Zend_Json::encode(array("success" => "Message succesfully sent"))); } }
public function responseAction() { $id = $this->_request->getParam('id', 0); if (!$id) { $this->_redirect('/ads/categories-list/'); } $ads = new Ads(); $ad = $ads->find($id)->current(); if (!$ad) { $this->_redirect('/ads/categories-list/'); } $form = new AdsResponseForm(); $form->getSubForm('ads_responses')->getElement('ad_id')->setValue($id); if (Standart_Main::buttonPressed('doResponse')) { if ($form->isValid($_POST)) { $values = $form->getValues(); $akismetData = array('user_ip' => $_SERVER['REMOTE_ADDR'], 'user_agent' => $_SERVER['HTTP_USER_AGENT'], 'comment_type' => 'comment', 'comment_author' => $values['ads_responses']['name'], 'comment_author_email' => $values['ads_responses']['email'], 'comment_content' => $values['ads_responses']['content']); $akismet = new Zend_Service_Akismet(Zend_Registry::get('config')->akismet->apiKey, Zend_Registry::get('config')->host->default); if ($akismet->isSpam($akismetData)) { $values['ads_responses']['is_spam'] = 1; $this->view->message(Standart_Main::translate('adsResponseIsSpam'), 'error'); } $adsResponses = new Ads_Responses(); $adsResponses->insert($values['ads_responses']); $this->_redirect('/ads/response/id/' . $id . '/'); } else { $this->view->message(Standart_Main::translate('invalidFormData'), 'error'); } } $this->view->form = $form; }