check_spammers_plain.php returning incorrect TRUE's

Need help with fSpamList? Post here! (DO NOT post removal requests here)

Moderator: fspamlist

strickly
Posts: 17
Joined: Wed Sep 02, 2009 4:57 pm
Contact:

check_spammers_plain.php returning incorrect TRUE's

Postby strickly » Wed Sep 02, 2009 11:29 pm

Hello,

I got at the moment Check_Spammers integrated with PHPBB 3.0.1.

The issue I'm experiencing is that it's getting sign-ups marked as being spammers and not passing thru when it's not really the case. After messing with the code that goes in includes/functions_user.php I realized is that the problem resides in file_get_contents() function.
Even when checked on the script manually, it confirms the username/email/IP is not a spammer.

The problem happens with a username with space in between (ex. Tony Mack). When the script is executed manually in the address bar of the browser it comes back as FALSE, but when the sign-up goes thru functions_user.php a "StopForumSpam TRUE" message is returned which is causing some sign-ups to be rejected.

The problem may be other and I haven't tested with that many username types but at least with this one I did a good troubleshooting and when the script is executed from within the file an incorrect result is given.

I have no idea what may be causing this so I come to you, but the code is implemented fine in the server files and I've tested it in two different hosting accounts and the same occurs so it doesn't seem to be related to specific environment settings.

I appreciate your help as at the moment registering at the site had to be disabled until the spam filter works ok.

Thanks.

User avatar
MysteryFCM
Site Admin
Site Admin
Posts: 3721
Joined: Sun May 15, 2005 12:42 pm
Location: Newcastle, UK
Contact:

Re: check_spammers_plain.php returning incorrect TRUE's

Postby MysteryFCM » Thu Sep 03, 2009 3:53 am

Apologies for taking so long. Could you try modifying the following line in the mod;

Code: Select all

$fspamcheck = file_get_contents('http://temerc.com/Check_Spammers/check_spammers_plain.php?name='.$username.'&email='.$email.'&ip='.$ip);


To;

Code: Select all

$curl = @curl_init();
curl_setopt($curl, CURLOPT_URL, 'http://temerc.com/Check_Spammers/check_spammers_plain.php?name='.$username.'&email='.$email.'&ip='.$ip);
curl_setopt($curl, CURLOPT_VERBOSE, 1);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
$fspamcheck = @curl_exec($curl);
curl_close($curl);


Remember to delete EVERYTHING in the cache folder, after uploading the new functions_user.php file
Regards

Steven Burn
I.T. Mate / hpHosts
it-mate.co.uk / hosts-file.net

Keeping it FREE!

strickly
Posts: 17
Joined: Wed Sep 02, 2009 4:57 pm
Contact:

Re: check_spammers_plain.php returning incorrect TRUE's

Postby strickly » Thu Sep 03, 2009 9:48 am

Unfortunately, no changes.

Both the following codes, return "StopForumSpam TRUE".

$fspamcheck1 = file_get_contents('http://<mydomain>/Check_Spammers/check_spammers_plain.php?name=Tony Mack');

$curl = @curl_init();
curl_setopt($curl, CURLOPT_URL, 'http://<mydomain>/Check_Spammers/check_spammers_plain.php?name=Tony Mack');
curl_setopt($curl, CURLOPT_VERBOSE, 1);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
$fspamcheck2 = @curl_exec($curl);
curl_close($curl);

Thanks for the help.

User avatar
MysteryFCM
Site Admin
Site Admin
Posts: 3721
Joined: Sun May 15, 2005 12:42 pm
Location: Newcastle, UK
Contact:

Re: check_spammers_plain.php returning incorrect TRUE's

Postby MysteryFCM » Thu Sep 03, 2009 10:02 am

The space should be getting escaped (space replaced with +);

http://temerc.com/Check_Spammers/check_ ... ddress.com

If possible, could you open check_spammers_plain, and replace;

Code: Select all

$fspamcheck = getURL('http://www.stopforumspam.com/api?email='.$mail.'&ip='.$ip.'&username='.$name);


With;

Code: Select all

$fspamcheck = getURL('http://www.stopforumspam.com/api?email='.$mail.'&ip='.$ip.'&username='.$name);
echo 'DEBUG: '.$fspamcheck.'<br>';


Then post the results?
Regards

Steven Burn
I.T. Mate / hpHosts
it-mate.co.uk / hosts-file.net

Keeping it FREE!

strickly
Posts: 17
Joined: Wed Sep 02, 2009 4:57 pm
Contact:

Re: check_spammers_plain.php returning incorrect TRUE's

Postby strickly » Thu Sep 03, 2009 10:35 am

Result is:

StopForumSpam TRUEDEBUG: username yes 2009-06-13 17:35:05 1

User avatar
MysteryFCM
Site Admin
Site Admin
Posts: 3721
Joined: Sun May 15, 2005 12:42 pm
Location: Newcastle, UK
Contact:

Re: check_spammers_plain.php returning incorrect TRUE's

Postby MysteryFCM » Thu Sep 03, 2009 10:54 am

Oks, can you change;

Code: Select all

$curl = @curl_init();
curl_setopt($curl, CURLOPT_URL, 'http://<mydomain>/Check_Spammers/check_spammers_plain.php?name=Tony Mack');


To;

Code: Select all

$username='Tony Mack';
$username = urlencode($username);
$curl = @curl_init();
curl_setopt($curl, CURLOPT_URL, 'http://<mydomain>/Check_Spammers/check_spammers_plain.php?name='.$username);


Obviously you'd need to remove "$username='Tony Mack';" after testing (assuming the results are as expected).
Regards

Steven Burn
I.T. Mate / hpHosts
it-mate.co.uk / hosts-file.net

Keeping it FREE!

strickly
Posts: 17
Joined: Wed Sep 02, 2009 4:57 pm
Contact:

Re: check_spammers_plain.php returning incorrect TRUE's

Postby strickly » Thu Sep 03, 2009 11:12 am

Ok seems we are getting there.

Result is:
DEBUG: username no 0
FALSE

So final code I should use in functions_user.php is:

$username = urlencode($username);
$curl = @curl_init();
curl_setopt($curl, CURLOPT_URL, 'http://<my domain>/Check_Spammers/check_spammers_plain.php?name='.$username.'&email='.$email.'&ip='.$ip);
curl_setopt($curl, CURLOPT_VERBOSE, 1);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
$fspamcheck = @curl_exec($curl);
curl_close($curl);

Am I right?

User avatar
MysteryFCM
Site Admin
Site Admin
Posts: 3721
Joined: Sun May 15, 2005 12:42 pm
Location: Newcastle, UK
Contact:

Re: check_spammers_plain.php returning incorrect TRUE's

Postby MysteryFCM » Thu Sep 03, 2009 11:19 am

That's correct, yes :)
Regards

Steven Burn
I.T. Mate / hpHosts
it-mate.co.uk / hosts-file.net

Keeping it FREE!

strickly
Posts: 17
Joined: Wed Sep 02, 2009 4:57 pm
Contact:

Re: check_spammers_plain.php returning incorrect TRUE's

Postby strickly » Thu Sep 03, 2009 11:56 am

Cool, seems to be working. One last thing for now.

When a sign-up is blocked, the returned message is:

Your registration has been blocked by our spam filter. Please either try again or contact an administrator._USERNAME

What is this "_USERNAME" string? Where is it coming from?

In the code the lines I have are:

// Notify user
return 'Your registration has been blocked by our spam filter. Please either try again or contact an administrator.';
die();

Where is this _USERNAME string being added from? I don't get it.

User avatar
MysteryFCM
Site Admin
Site Admin
Posts: 3721
Joined: Sun May 15, 2005 12:42 pm
Location: Newcastle, UK
Contact:

Re: check_spammers_plain.php returning incorrect TRUE's

Postby MysteryFCM » Thu Sep 03, 2009 12:10 pm

Could you post a copy of the mod from your file please? (including the first 2-3 lines both before and after the mod) as this should not be happening.
Regards

Steven Burn
I.T. Mate / hpHosts
it-mate.co.uk / hosts-file.net

Keeping it FREE!

strickly
Posts: 17
Joined: Wed Sep 02, 2009 4:57 pm
Contact:

Re: check_spammers_plain.php returning incorrect TRUE's

Postby strickly » Thu Sep 03, 2009 12:23 pm

Sure, here you have. Please let me know if you need more of the code before and after it.

Code: Select all

   {
      return 'INVALID_CHARS';
   }

   $mbstring = $pcre = false;

   /// BEGIN SPAM MOD
   $email = request_var('email', '');
   $ip = $_SERVER['REMOTE_ADDR'];
   $username1 = urlencode($username);
   $curl = @curl_init();
   curl_setopt($curl, CURLOPT_URL, 'http://x/Check_Spammers/check_spammers_plain.php?name='.$username1.'&email='.$email.'&ip='.$ip);
   curl_setopt($curl, CURLOPT_VERBOSE, 1);
   curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
   curl_setopt($curl, CURLOPT_HEADER, 0);
   curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
   $fspamcheck = @curl_exec($curl);
   curl_close($curl);

   if (strpos($fspamcheck, 'TRUE') !==False) {

      // Notify admin via e-mail
      $blockedby = str_replace(' TRUE', '', $fspamcheck);
      $blockedby = str_replace(' ', ' & ', $blockedby);
      $msg = 'The following sign-up was blocked by '.$blockedby.' filter<br><br>Username: '.$username.'<br><br>Email: '.$email.'<br><br>IP: '.$ip;
      $to = "x";
      $from = "spamfilter@".$_SERVER['SERVER_NAME'];
      $subject = $username ." blocked by hpHosts Spam filter";
      $headers =    "MIME-Versin: 1.0\r\n" . "Content-type: text/html; charset=ISO-8859-1; format=flowed\r\n" . "Content-Transfer-Encoding: 8bit\r\n" . "From: " . $from . "\r\n" . "X-Mailer: hpHosts Spam Filter";
      mail($to, $subject, $msg, $headers);

      // Notify user
      return 'Your registration has been blocked by our spam filter. Please either try again or contact an administrator.';
      die();
   }
   /// END SPAM MOD

   // generic UTF-8 character types supported?
   if ((version_compare(PHP_VERSION, '5.1.0', '>=') || (version_compare(PHP_VERSION, '5.0.0-dev', '<=') && version_compare(PHP_VERSION, '4.4.0', '>='))) && @preg_match('/\p{L}/u', 'a') !== false)
   {

User avatar
MysteryFCM
Site Admin
Site Admin
Posts: 3721
Joined: Sun May 15, 2005 12:42 pm
Location: Newcastle, UK
Contact:

Re: check_spammers_plain.php returning incorrect TRUE's

Postby MysteryFCM » Thu Sep 03, 2009 12:46 pm

That is a bit strange. I've just checked my copy of functions_user.php (phpBB 3.0.5), and it doesn't actually contain that string (not in uppercase anyway).

At this point, I'm baffled as to where it's coming from. Could you upload a copy of your function_user.php file please?
Regards

Steven Burn
I.T. Mate / hpHosts
it-mate.co.uk / hosts-file.net

Keeping it FREE!

strickly
Posts: 17
Joined: Wed Sep 02, 2009 4:57 pm
Contact:

Re: check_spammers_plain.php returning incorrect TRUE's

Postby strickly » Thu Sep 03, 2009 2:53 pm

Here.

Thanks for all the help.
Attachments
functions_user.rar
(19.79 KiB) Downloaded 246 times

User avatar
MysteryFCM
Site Admin
Site Admin
Posts: 3721
Joined: Sun May 15, 2005 12:42 pm
Location: Newcastle, UK
Contact:

Re: check_spammers_plain.php returning incorrect TRUE's

Postby MysteryFCM » Thu Sep 03, 2009 3:03 pm

There's nothing in the file that I can see, that could be causing it. Could you check you cleared the phpBB cache folder please? (sadly if this is not the cause either, I'm out of ideas)
Regards

Steven Burn
I.T. Mate / hpHosts
it-mate.co.uk / hosts-file.net

Keeping it FREE!

strickly
Posts: 17
Joined: Wed Sep 02, 2009 4:57 pm
Contact:

Re: check_spammers_plain.php returning incorrect TRUE's

Postby strickly » Thu Sep 03, 2009 4:11 pm

Ye, no luck.

There's so many _username variables and arrays in that file. Difficult to tell where's the error.

I don't know either how that return statement works, could you give me some more info about it?

I guess I'll have to go thru the code in the file and look for something I don't know what it is lol.

User avatar
MysteryFCM
Site Admin
Site Admin
Posts: 3721
Joined: Sun May 15, 2005 12:42 pm
Location: Newcastle, UK
Contact:

Re: check_spammers_plain.php returning incorrect TRUE's

Postby MysteryFCM » Thu Sep 03, 2009 4:44 pm

Apologies for taking so long. The following part of the code simply informs the user that their registration attempt has been blocked due to their being flagged by one of the anti-spam databases;

Code: Select all

// Notify user
      return 'Your registration has been blocked by our spam filter. Please either try again or contact an administrator.';
      die();
Regards

Steven Burn
I.T. Mate / hpHosts
it-mate.co.uk / hosts-file.net

Keeping it FREE!

strickly
Posts: 17
Joined: Wed Sep 02, 2009 4:57 pm
Contact:

Re: check_spammers_plain.php returning incorrect TRUE's

Postby strickly » Thu Sep 03, 2009 5:32 pm

I see this blocker goes within function "function validate_username($username, $allowed_username = false)" right?
So I guess I'll have to go thru the code within it and see where that _USERNAME thing is coming from.

If you think of anything else looking at the code in my file let me know.

Appreciate all the help you've given me.

User avatar
MysteryFCM
Site Admin
Site Admin
Posts: 3721
Joined: Sun May 15, 2005 12:42 pm
Location: Newcastle, UK
Contact:

Re: check_spammers_plain.php returning incorrect TRUE's

Postby MysteryFCM » Thu Sep 03, 2009 6:05 pm

That's correct, yes.

I'll keep looking into it and post back if I find anything :)
Regards

Steven Burn
I.T. Mate / hpHosts
it-mate.co.uk / hosts-file.net

Keeping it FREE!


Return to “Help and Support”

Who is online

Users browsing this forum: No registered users and 3 guests