function spam() {
		if(!Permission::check('ADMIN')) {
			return false;
		}

		$this->methodName = "spam";
		
		$childId = Convert::raw2sql($_REQUEST['ctf']['childID']);

		if (is_numeric($childId)) {
			$comment = DataObject::get_by_id($this->sourceClass, $childId);
			if($comment) {
				$comment->IsSpam = true;
				$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.
					}
				}
			}
		}
	}
Beispiel #2
0
    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;
    }
Beispiel #3
0
 function reportspam()
 {
     $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, 'spam');
         } else {
             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.
                 }
             }
         }
         $comment->IsSpam = true;
         $comment->NeedsModeration = false;
         $comment->write();
     }
     if (Director::is_ajax()) {
         if (SSAkismet::isEnabled() && SSAkismet::getSaveSpam()) {
             echo $comment->renderWith('PageCommentInterface_singlecomment');
         } else {
             echo '';
         }
     } else {
         Director::redirectBack();
     }
 }
	function reportspam() {
		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->submitSpam();
					} catch (Exception $e) {
						// Akismet didn't work, most likely the service is down.
					}
					
					if(SSAkismet::getSaveSpam()) {
						$comment->setField('IsSpam', true);
						$comment->write();
					} else {
						$comment->delete();
					}
				}
			}
				
			if(Director::is_ajax()) {
				if(SSAkismet::getSaveSpam()) {
					echo $comment->renderWith('PageCommentInterface_singlecomment');
				} else {
					echo '';
				}
			} else {
				Director::redirectBack();
			}
		}
	}
 function reportspam($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, 'spam');
         } else {
             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.
                 }
             }
         }
         $comment->IsSpam = true;
         $comment->NeedsModeration = false;
         $comment->write();
     }
     if (Director::is_ajax()) {
         if (SSAkismet::isEnabled() && SSAkismet::getSaveSpam()) {
             echo $comment->renderWith('PageCommentInterface_singlecomment');
         } else {
             echo '';
         }
     } else {
         Director::redirectBack();
     }
 }