function ham() { if (!Permission::check('ADMIN')) { return false; } $this->methodName = "ham"; $childId = Convert::raw2sql($_REQUEST['ctf']['childID']); if (is_numeric($childId)) { $comment = DataObject::get_by_id($this->sourceClass, $childId); if ($comment) { $comment->IsSpam = false; $comment->NeedsModeration = false; $comment->write(); 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. } } } } }
function postcomment($data) { // Spam filtering if (SSAkismet::isEnabled()) { try { $akismet = new SSAkismet(); $akismet->setCommentAuthor($data['Name']); $akismet->setCommentContent($data['Comment']); if ($akismet->isCommentSpam()) { if (SSAkismet::getSaveSpam()) { $comment = Object::create('PageComment'); $this->saveInto($comment); $comment->setField("IsSpam", true); $comment->write(); } echo "<b>" . _t('PageCommentInterface_Form.SPAMDETECTED', 'Spam detected!!') . "</b><br /><br />"; printf("If you believe this was in error, please email %s.", ereg_replace("@", " _(at)_", Email::getAdminEmail())); echo "<br /><br />" . _t('PageCommentInterface_Form.MSGYOUPOSTED', 'The message you posted was:') . "<br /><br />"; echo $data['Comment']; return; } } catch (Exception $e) { // Akismet didn't work, continue without spam check } } //check if spam question was right. if (MathSpamProtection::isEnabled()) { if (!MathSpamProtection::correctAnswer($data['Math'])) { if (!Director::is_ajax()) { Director::redirectBack(); } return "spamprotectionfalied"; //used by javascript for checking if the spam question was wrong } } Cookie::set("PageCommentInterface_Name", $data['Name']); $comment = Object::create('PageComment'); $this->saveInto($comment); $comment->IsSpam = false; $comment->NeedsModeration = PageComment::moderationEnabled(); $comment->write(); if (Director::is_ajax()) { if ($comment->NeedsModeration) { echo _t('PageCommentInterface_Form.AWAITINGMODERATION', "Your comment has been submitted and is now awating moderation."); } else { echo $comment->renderWith('PageCommentInterface_singlecomment'); } } else { Director::redirectBack(); } }
function hammarked() { $numComments = 0; $folderID = 0; $deleteList = ''; if ($_REQUEST['Comments']) { foreach ($_REQUEST['Comments'] as $commentid) { $comment = DataObject::get_by_id('PageComment', $commentid); if ($comment) { $comment->IsSpam = false; $comment->NeedsModeration = false; $comment->write(); if (SSAkismet::isEnabled()) { try { $akismet = new SSAkismet(); $akismet->setCommentAuthor($comment->getField('Name')); $akismet->setCommentContent($comment->getField('Comment')); $akismet->submitSpam(); } catch (Exception $e) { // Akismet didn't work, most likely the service is down. } } $numComments++; } } } else { user_error("No comments in {$commentList} could be found!", E_USER_ERROR); } $msg = sprintf(_t('CommentAdmin.MARKEDNOTSPAM', 'Marked %s comments as not spam.'), $numComments); echo <<<JS \t\t\t\t{$deleteList} \t\t\t\t\$('Form_EditForm').getPageFromServer(\$('Form_EditForm_ID').value); \t\t\t\tstatusMessage("{$msg}"); JS; }
function postcomment($data) { // Spam filtering Cookie::set("PageCommentInterface_Name", $data['Name']); Cookie::set("PageCommentInterface_CommenterURL", $data['CommenterURL']); Cookie::set("PageCommentInterface_Comment", $data['Comment']); if (SSAkismet::isEnabled()) { try { $akismet = new SSAkismet(); $akismet->setCommentAuthor($data['Name']); $akismet->setCommentContent($data['Comment']); if ($akismet->isCommentSpam()) { if (SSAkismet::getSaveSpam()) { $comment = Object::create('PageComment'); $this->saveInto($comment); $comment->setField("IsSpam", true); $comment->write(); } echo "<b>" . _t('PageCommentInterface_Form.SPAMDETECTED', 'Spam detected!!') . "</b><br /><br />"; printf("If you believe this was in error, please email %s.", ereg_replace("@", " _(at)_", Email::getAdminEmail())); echo "<br /><br />" . _t('PageCommentInterface_Form.MSGYOUPOSTED', 'The message you posted was:') . "<br /><br />"; echo $data['Comment']; return; } } catch (Exception $e) { // Akismet didn't work, continue without spam check } } //check if spam question was right. if (MathSpamProtection::isEnabled()) { if (!MathSpamProtection::correctAnswer($data['Math'])) { if (!Director::is_ajax()) { Director::redirectBack(); } return "spamprotectionfailed"; //used by javascript for checking if the spam question was wrong } } // If commenting can only be done by logged in users, make sure the user is logged in $member = Member::currentUser(); if (PageCommentInterface::CanPostComment() && $member) { $this->Fields()->push(new HiddenField("AuthorID", "Author ID", $member->ID)); } elseif (!PageCommentInterface::CanPostComment()) { echo "You're not able to post comments to this page. Please ensure you are logged in and have an appropriate permission level."; return; } $comment = Object::create('PageComment'); $this->saveInto($comment); // Store the Session ID if needed for Spamprotection if ($session = Session::get('mollom_user_session_id')) { $comment->SessionID = $session; Session::clear('mollom_user_session_id'); } $comment->IsSpam = false; $comment->NeedsModeration = PageComment::moderationEnabled(); $comment->write(); Cookie::set("PageCommentInterface_Comment", ''); if (Director::is_ajax()) { if ($comment->NeedsModeration) { echo _t('PageCommentInterface_Form.AWAITINGMODERATION', "Your comment has been submitted and is now awaiting moderation."); } else { echo $comment->renderWith('PageCommentInterface_singlecomment'); } } else { // since it is not ajax redirect user down to their comment since it has been posted // get the pages url off the comments parent ID. if ($comment->ParentID) { $page = DataObject::get_by_id("Page", $comment->ParentID); if ($page) { // Redirect to the actual post on the page. return Director::redirect(Director::baseURL() . $page->URLSegment . '#PageComment_' . $comment->ID); } } return Director::redirectBack(); // worst case, just go back to the page } }
/** * 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(); } }
function reportham() { if(SSAkismet::isEnabled()) { if(Permission::check('CMS_ACCESS_CMSMain')) { $comment = DataObject::get_by_id("PageComment", $this->urlParams['ID']); if($comment) { 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(); } } }
/** * 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(); } }