/** * Report a Spam Comment as valid comment (not spam) */ function reportham() { $comment = DataObject::get_by_id("PageComment", $this->urlParams['ID']); if ($comment && $comment->canEdit()) { // if spam protection module exists if (class_exists('SpamProtectorManager')) { SpamProtectorManager::send_feedback($comment, 'ham'); } if (SSAkismet::isEnabled()) { try { $akismet = new SSAkismet(); $akismet->setCommentAuthor($comment->getField('Name')); $akismet->setCommentContent($comment->getField('Comment')); $akismet->submitHam(); } catch (Exception $e) { // Akismet didn't work, most likely the service is down. } } $comment->setField('IsSpam', false); $comment->write(); } if (Director::is_ajax()) { echo $comment->renderWith('PageCommentInterface_singlecomment'); } else { Director::redirectBack(); } }
/** * Mark a post as spam. Deletes any posts or threads created by that user * and removes their user account from the site * * Must be logged in and have the correct permissions to do marking */ function markasspam() { $currentUser = Member::currentUser(); if (!isset($this->urlParams['ID'])) { return $this->httpError(400); } if (!$this->canModerate()) { return $this->httpError(403); } $post = DataObject::get_by_id('Post', $this->urlParams['ID']); if ($post) { // send spam feedback if needed if (class_exists('SpamProtectorManager')) { SpamProtectorManager::send_feedback($post, 'spam'); } $postID = $post->ID; // post was the start of a thread, Delete the whole thing if ($post->isFirstPost()) { $post->Thread()->delete(); } // Delete the current post $post->delete(); // Log deletion event SS_Log::log(sprintf('Marked post #%d as spam, by moderator %s (#%d)', $postID, $currentUser->Email, $currentUser->ID), SS_Log::NOTICE); // Suspend the member (rather than deleting him), // which gives him or a moderator the chance to revoke a decision. if ($author = $post->Author()) { $author->SuspendedUntil = date('Y-m-d', strtotime('+99 years', SS_Datetime::now()->Format('U'))); $author->write(); } SS_Log::log(sprintf('Suspended member %s (#%d) for spam activity, by moderator %s (#%d)', $author->Email, $author->ID, $currentUser->Email, $currentUser->ID), SS_Log::NOTICE); } return Director::is_ajax() ? true : $this->redirect($this->Link()); }
/** * Report a Spam Comment as valid comment (not spam) */ function reportham($request) { // Protect against CSRF on destructive action $token = SecurityToken::inst(); if (!$token->checkRequest($request)) { return $this->httpError(400); } $comment = DataObject::get_by_id("PageComment", $request->param('ID')); if ($comment && $comment->canEdit()) { // if spam protection module exists if (class_exists('SpamProtectorManager')) { SpamProtectorManager::send_feedback($comment, 'ham'); } if (SSAkismet::isEnabled()) { try { $akismet = new SSAkismet(); $akismet->setCommentAuthor($comment->getField('Name')); $akismet->setCommentContent($comment->getField('Comment')); $akismet->submitHam(); } catch (Exception $e) { // Akismet didn't work, most likely the service is down. } } $comment->setField('IsSpam', false); $comment->write(); } if (Director::is_ajax()) { echo $comment->renderWith('PageCommentInterface_singlecomment'); } else { Director::redirectBack(); } }
/** * Mark a post as spam. Deletes any posts or threads created by that user * and removes their user account from the site * * Must be logged in and have the correct permissions to do marking */ function markasspam() { if ($this->isAdmin() && isset($this->urlParams['ID'])) { $post = DataObject::get_by_id('Post', $this->urlParams['ID']); if ($post) { // send spam feedback if needed if (class_exists('SpamProtectorManager')) { SpamProtectorManager::send_feedback($post, 'spam'); } // some posts do not have authors if ($author = $post->Author()) { $SQL_id = Convert::raw2sql($author->ID); // delete all threads and posts from that user $posts = DataObject::get('Post', "\"AuthorID\" = '{$SQL_id}'"); if ($posts) { foreach ($posts as $post) { if ($post->isFirstPost()) { // post was the start of a thread, Delete the whole thing $post->Thread()->delete(); } else { if ($post->ID) { $post->delete(); } } } } // delete the authors account $author->delete(); } else { $post->delete(); } } } return Director::is_ajax() ? true : $this->redirect($this->Link()); }