[DEV] AntiSpam ACP Optimized for Stop forum spam

A place for MOD Authors to post and receive feedback on MODs still in development. No MODs within this forum should be used within a live environment!
Scam Warning
Locked
User avatar
jsebean
Registered User
Posts: 378
Joined: Sat Dec 12, 2009 3:20 pm
Location: Atlantic Canada
Name: Jonah
Contact:

[DEV] AntiSpam ACP Optimized for Stop forum spam

Post by jsebean »

UPDATED MARCH 19, 2012

So I really forgot all about this "mod" but after Peter77sx sent me a friendly reminder I figured I'd update it, plus rewrite this whole post.

The changes here are for AntiSpam ACP by Exreaction (get the mod at Lithium Studios) version 1.0.3 PL1.

The stop forum spam by default in AntiSpam ACP checks usernames and email addresses submitted, not IPs, also, when it gets a positive, it just says:
One or more of the fields entered was marked as spam.
These quick changes adds in checking against blacklisted IP addresses, and Email address, and removes username checking (since I feel blacklisting user
names is a bad way of doing things).

Keep in mind I'm a noob at php and the code is a bit messy, but it should work. I did these changes once before on my board and it worked. The changes I am posting here I believe are the same I use, but I don't have an active phpBB install so I haven't tested. So if you do these changes and it doesn't work for ya let me know :D.

Step 1. Install latest version AntiSpam ACP v1.0.3 PL1.
Step 2. Open the file /antispam/asacp.php
Step 3. Find this:

Code: Select all

		// Stop Forum Spam stuff
		if (!sizeof($error) && $config['asacp_sfs_action'] > 1)
		{
			if (!function_exists('get_remote_file'))
			{
				global $phpbb_root_path, $phpEx;
				include($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
			}

			$stop_forum_spam_urls = array(
				'api?username=' . urlencode($data['username']),
				'api?email=' . urlencode($data['email']),
				//'api?ip=' . $user->ip,
			);

			foreach ($stop_forum_spam_urls as $url)
			{
				$errstr = $errno = '';
				$file = get_remote_file('stopforumspam.com', '', $url, $errstr, $errno);

				if ($file !== false)
				{
					$file = str_replace("\r\n", "\n", $file);
					$file = explode("\n", $file);

					$appears = $frequency = false;
					foreach ($file as $line)
					{
						if (strpos($line, '<appears>') !== false && strpos($line, '</appears>') !== false)
						{
							$start = strpos($line, '<appears>') + 9;
							$end = strpos($line, '</appears>') - $start;
							$appears = (substr($line, $start, $end) == 'yes') ? true : false;
						}
						else if (strpos($line, '<frequency>') !== false && strpos($line, '</frequency>') !== false)
						{
							$start = strpos($line, '<frequency>') + 11;
							$end = strpos($line, '</frequency>') - $start;
							$frequency = (int) substr($line, $start, $end);
						}
					}

					if ($appears && $frequency >= $config['asacp_sfs_min_freq'])
					{
						self::$sfs_spam = true;
					}
				}
			}

			if (self::$sfs_spam)
			{
				switch ($config['asacp_sfs_action'])
				{
					case 3 :
						$config['require_activation'] = USER_ACTIVATION_SELF;
					break;

					case 4 :
						$config['require_activation'] = USER_ACTIVATION_ADMIN;
					break;

					case 5 :
            $user->add_lang('mods/asacp');
						$error[] = $user->lang['PROFILE_SPAM_DENIED'];
					break;
				}
			}
		}
And change it to this:

Code: Select all

		// Stop Forum Spam stuff
		if (!sizeof($error) && $config['asacp_sfs_action'] > 1)
		{
			if (!function_exists('get_remote_file'))
			{
				global $phpbb_root_path, $phpEx;
				include($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
			}

			$stop_forum_spam_urls = array(
				//'api?username=' . urlencode($data['username']),
				'api?email=' . urlencode($data['email']),
				//'api?ip=' . $user->ip,
			);

			foreach ($stop_forum_spam_urls as $url)
			{
				$errstr = $errno = '';
				$file = get_remote_file('stopforumspam.com', '', $url, $errstr, $errno);

				if ($file !== false)
				{
					$file = str_replace("\r\n", "\n", $file);
					$file = explode("\n", $file);

					$appears = $frequency = false;
					foreach ($file as $line)
					{
						if (strpos($line, '<appears>') !== false && strpos($line, '</appears>') !== false)
						{
							$start = strpos($line, '<appears>') + 9;
							$end = strpos($line, '</appears>') - $start;
							$appears = (substr($line, $start, $end) == 'yes') ? true : false;
						}
						else if (strpos($line, '<frequency>') !== false && strpos($line, '</frequency>') !== false)
						{
							$start = strpos($line, '<frequency>') + 11;
							$end = strpos($line, '</frequency>') - $start;
							$frequency = (int) substr($line, $start, $end);
						}
					}

					if ($appears && $frequency >= $config['asacp_sfs_min_freq'])
					{
						self::$sfs_spam = true;
					}
				}
			}

			if (self::$sfs_spam)
			{
				switch ($config['asacp_sfs_action'])
				{
					case 3 :
						$config['require_activation'] = USER_ACTIVATION_SELF;
					break;

					case 4 :
						$config['require_activation'] = USER_ACTIVATION_ADMIN;
					break;

					case 5 :
            $user->add_lang('mods/asacp');
						$error[] = $user->lang['PROFILE_SPAM_DENIED_EMAIL'];
					break;
				}
			}
		}




		// Stop Forum Spam stuff
		if (!sizeof($error) && $config['asacp_sfs_action'] > 1)
		{
			if (!function_exists('get_remote_file'))
			{
				global $phpbb_root_path, $phpEx;
				include($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
			}

			$stop_forum_spam_urls = array(
				//'api?username=' . urlencode($data['username']),
				//'api?email=' . urlencode($data['email']),
				'api?ip=' . $user->ip,
			);

			foreach ($stop_forum_spam_urls as $url)
			{
				$errstr = $errno = '';
				$file = get_remote_file('stopforumspam.com', '', $url, $errstr, $errno);

				if ($file !== false)
				{
					$file = str_replace("\r\n", "\n", $file);
					$file = explode("\n", $file);

					$appears = $frequency = false;
					foreach ($file as $line)
					{
						if (strpos($line, '<appears>') !== false && strpos($line, '</appears>') !== false)
						{
							$start = strpos($line, '<appears>') + 9;
							$end = strpos($line, '</appears>') - $start;
							$appears = (substr($line, $start, $end) == 'yes') ? true : false;
						}
						else if (strpos($line, '<frequency>') !== false && strpos($line, '</frequency>') !== false)
						{
							$start = strpos($line, '<frequency>') + 11;
							$end = strpos($line, '</frequency>') - $start;
							$frequency = (int) substr($line, $start, $end);
						}
					}

					if ($appears && $frequency >= $config['asacp_sfs_min_freq'])
					{
						self::$sfs_spam = true;
					}
				}
			}

			if (self::$sfs_spam)
			{
				switch ($config['asacp_sfs_action'])
				{
					case 3 :
						$config['require_activation'] = USER_ACTIVATION_SELF;
					break;

					case 4 :
						$config['require_activation'] = USER_ACTIVATION_ADMIN;
					break;

					case 5 :
            $user->add_lang('mods/asacp');
						$error[] = $user->lang['PROFILE_SPAM_DENIED_IP'];
					break;
				}
			}
		}
Then save and upload the file.

Step 4. Open /language/en/mods/asacp.php
Step 5. On line 44 find:

Code: Select all

	'PROFILE_SPAM_DENIED'	=> 'One or more of the fields entered was marked as spam.',
After Add:

Code: Select all

'PROFILE_SPAM_DENIED_EMAIL'	=> 'The email address you have entered has been blacklisted as a spammer at <a href=\'http://stopforumspam.com/\'>StopForumSpam.com</a> and thus, registration has been blocked. If you feel this is incorrect please contact the Board Administrator via email to have your account registered, you can also visit <a href=\'http://stopforumspam.com/\'>StopForumSpam.com</a> to find more details about this and find out how to be removed so you don\'t experience this issue on future website.',
'PROFILE_SPAM_DENIED_IP'	=> 'The IP address you are registering from has been blacklisted as a spammer at <a href=\'http://stopforumspam.com/\'>StopForumSpam.com</a> and thus, registration has been blocked. If you feel this is incorrect please contact the Board Administrator via email to have your account registered, you can also visit <a href=\'http://stopforumspam.com/\'>StopForumSpam.com</a> to find more details about this and find out how to be removed so you don\'t experience this issue on future website.',
Save and Upload the file.
NOTE: You can change the array to you liking to say what you want it to say.

And that be it. Setup stopforumspam.com settings in the ACP and it should work. You can test by using an email like [email protected] and test the IP block by using a well know proxy that is blacklisted.

Hope this helps :D.
Last edited by jsebean on Mon Mar 19, 2012 1:21 pm, edited 1 time in total.
-Jonah
:lol:
coreno
Registered User
Posts: 1
Joined: Mon Jun 20, 2011 8:24 pm

Re: [DEV] AntiSpam ACP Optimized for Stop forum spam

Post by coreno »

Hello, I am interested in this. I'm so interested, I'm even interested in helping develop it if needed. I've already started working on my own version, and will continue to do so unless I hear back from you.

My big hurdle is I've never made a PHPbb mod, so just learning that step is something thats taking some time for me.
User avatar
Ashley.S.
Registered User
Posts: 469
Joined: Mon Aug 04, 2008 6:01 pm
Location: Falmouth, Cornwall, UK
Name: Ashley .S.
Contact:

Re: [DEV] AntiSpam ACP Optimized for Stop forum spam

Post by Ashley.S. »

Sounds like some great changes to a great mod, I'll be watching closely 8-)
Regards,
-Ashley.S. [ PurephpBB Founder ]
User avatar
jsebean
Registered User
Posts: 378
Joined: Sat Dec 12, 2009 3:20 pm
Location: Atlantic Canada
Name: Jonah
Contact:

Re: [DEV] AntiSpam ACP Optimized for Stop forum spam

Post by jsebean »

Hey folks,
Sorry for being so long to respond I almost forgot about this topic :lol: . I actually did (semi) finish this project once on my board however lost it all :roll: :oops: . I since then migrated to myBB (which I miss phpBB now for many reasons) and I'll be migrating back. With that said, I'll start working on something like this again since the last time i did it, it was very effective to prevent spam bots (and some humans?).

I'll try to post a few things I do on there in the mod, maybe not actually release it as a mod but just post the changes i did to the existing code by Exreaction? I dunno guess we'll see, but I do intend on doing it again since I want to go back to phpBB now :P

-Jonah
-Jonah
:lol:
Peter77sx
Registered User
Posts: 3260
Joined: Wed Nov 09, 2005 2:51 pm

Re: [DEV] AntiSpam ACP Optimized for Stop forum spam

Post by Peter77sx »

I was about to install his MOD on a new forum i opened up. How is this coming along, can we see your changes soon? thanks for doing this. :)
User avatar
jsebean
Registered User
Posts: 378
Joined: Sat Dec 12, 2009 3:20 pm
Location: Atlantic Canada
Name: Jonah
Contact:

Re: [DEV] AntiSpam ACP Optimized for Stop forum spam

Post by jsebean »

I updated the first post with the code changes you can make to make this functional :D.
-Jonah
:lol:
Locked

Return to “[3.0.x] MODs in Development”