Hacks

Xoops Comments - Prevent Anonymous User Spam

attock  21-Sep-2007 13:20 10094 Reads   3 Comment(s) 
Although there is option in every module that would let you choose who can post a comment. But what if you want anonymous users to post comments as well. There isn't any option (at least I couldn't find any) that will prevent anonymous users from spamming. So this hack will prevent spam if a url\link is found in anonymous users' post.

As always recommended while playing with hacks, make sure you backup the file you will be editing. In this case its: XOOPS_ROOT_DIR\Include\comment_post.php

Note: I have tested it only on Xoops 2.0.16


Start...

1) Open XOOPS_ROOT_DIR\Include\comment_post.php


2) Look for the following on line 138

Original Code
break;
case 
"post":

   
$doimage 1;
    
$comment_handler =& xoops_gethandler('comment');
    
$add_userpost false;
    
$call_approvefunc false;
    
$call_updatefunc false;





3) Change it to ...
break;
case 
"post":

    
//myhack - Prevent Anonymous User Spam
    //if a URLLINK is found in link, then dont let annonymous user post.
    
$myhack_comment $_POST['com_text'];
    
$myhack_title $_POST['com_title'];
    
//checking if poster is anonymous
    
if (!is_object($xoopsUser)) {
        if (
preg_match("/http/",$myhack_comment) || preg_match("/www/",$myhack_comment) || preg_match("/href/",$myhack_comment) || preg_match("/http/",$myhack_title) || preg_match("/www/",$myhack_title)) {
            echo 
"Dont Spam Bitch!!!!!";
            exit();    
        }
        else {
        }
    }
    
//end of myhack


    
$doimage 1;
    
$comment_handler =& xoops_gethandler('comment');
    
$add_userpost false;
    
$call_approvefunc false;
    
$call_updatefunc false;





Rating 0/5
Rating: 0/5 (0 votes)
Voting is disabled!


Login

Who's Online

174 user(s) are online (4 user(s) are browsing Publisher)


Members: 0


Guests: 174


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Apr 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits

Categories