[RC2] Anti Bot Question

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! No new topics are allowed in this forum.
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

IMPORTANT: MOD Development Forum rules

On February 1, 2009 this forum will be set to read only as part of retiring of phpBB2.
silveria
Registered User
Posts: 6
Joined: Thu Jun 02, 2005 11:55 pm
Contact:

Post by silveria » Wed Aug 02, 2006 9:37 pm

I have tried your suggestion although it did not make any sense to me. It does not say anywhere that you cannot have both Visual Confirmation and this mod running. Nevertheless I have tried it and it did not work. :(
I am usually pretty good at such stuff, more over it is straightforward, and I have no idea why it is not working. Unfortunately the support for this MOD is in german so I do not know where to ask for help. Other suggestions? :?
Silverchair Fan? www.s-chair.net

alvo
Registered User
Posts: 693
Joined: Thu Jun 22, 2006 3:57 am

Post by alvo » Thu Aug 03, 2006 7:54 pm

This will work with the phpBB captcha turned on. I installed this mod without turning off the original VC and a person would have to answer both challenges correctly to register or guest post. Since the original isn't effective there's no real advantage to having both since this mod will catch the bots very effectively.

It was mentioned earlier in this thread the problem of using images with blind visitors, and that's a valid point. I personally think that the image route isn't necessary and isn't anymore effective than written questions. The most effective way of posing questions is going to be ones that don't give a multiple choice answer, as then a bot couldn't be programmed to guess at one of the supplied answers. Questions like "What is the color of grass?" or "What is the opposite of slow?" are better than "Which is not a color? yellow, red, cow, blue"

talksina
Registered User
Posts: 24
Joined: Mon May 15, 2006 7:43 am
Location: Italy
Contact:

Post by talksina » Thu Aug 03, 2006 8:38 pm

there are lots of explanations here
http://www.w3.org/TR/turingtest
I think the best way is the combined of visual, audio and logic puzzle (the 3 alternatives)
But regarding audio, I know that it is not possible by PHPBB, as there can not be a way to read by Text-to-speech software, it's dependant on the user's client (if a Sapi technology would be used) and not often it works... on PHPBB hacks.com I got a "read topics aloud" hack, made using the MS agent, and didn't work...
And for server-side technology, it's not possible at all because it's dependent on technology, on linux server there is Festival TTS that must be implemented, and for Windows we have of course Sapi5 interface, but it costs $$$$$
That's why I think that for PHPBB, MagMo's solution is really really really the best!
Admins can decide whether or not to use pictures, sounds, links or normal questions and they can (if they wish) even change them every week...

VorowneTSG
Registered User
Posts: 257
Joined: Mon Sep 09, 2002 4:33 pm
Contact:

Post by VorowneTSG » Tue Aug 08, 2006 6:30 am

Hello, this is a great mod! But I'm having some trouble in installing it. I'm still running phpBB 2.0.6 and was hoping to get this to work with it. Everything looks like it will work, except for the following part of the instructions:

Code: Select all

#-----[ FIND ]------------------------------------------------ 
# 
				$error = TRUE;
				$error_msg .= ( ( isset($error_msg) ) ? '<br />' : '' ) . $lang['Confirm_code_wrong'];
			}
			$db->sql_freeresult($result);
		}
	}
This text does not exist as such in the usercp_register.php file for 2.0.6. There is a place that has $db->sql_freeresults($result);, but if I paste the code after that, the mod does not work. The question shows just fine on the registration page, but even if you enter in an incorrect answer, it fails to stop the registration from happening.

This is the code that I am needing the right place to paste for:

Code: Select all

#-----[ FIND ]------------------------------------------------ 
# 
				$error = TRUE;
				$error_msg .= ( ( isset($error_msg) ) ? '<br />' : '' ) . $lang['Confirm_code_wrong'];
			}
			$db->sql_freeresult($result);
		}
	}

# 
#-----[ AFTER, ADD ]------------------------------------------------ 
# 
	// Anti Bot Question Mod - Start
	if (($mode == 'register') && ($board_config['anti_bot_quest']))
	{
		$abq_aw = htmlspecialchars(stripslashes($abq_aw));
		$abq_id = intval(htmlspecialchars(stripslashes($idabq)));

		$sql = 'SELECT answer1, answer2, answer3, answer4, answer5
			FROM ' . ANTI_BOT_QUEST_TABLE . '
			WHERE id = ' . $abq_id;
		if(!$result = $db->sql_query($sql))
		{
			message_die(GENERAL_ERROR, 'Could not obtain anti-bot-question information', '', __LINE__, __FILE__, $sql);
		}
		if( $db->sql_numrows($result) == 0 )
		{
			$sql = 'SELECT answer
				FROM ' . ANTI_BOT_QUEST_TABLE . '
				WHERE lang = \'' . $board_config['default_lang'] . '\' 
				LIMIT 1';
			if(!$result = $db->sql_query($sql))
			{
				message_die(GENERAL_ERROR, 'Could not obtain anti-bot-question information', '', __LINE__, __FILE__, $sql);
			}
			if( $db->sql_numrows($result) == 0 )
			{
				// Keine Frage vorhanden > Anti-Bot-Question übergehen
			}
			else
			{
				$error = TRUE;
				$error_msg .= ( ( isset($error_msg) ) ? '<br />' : '' ) . $lang['ABQ_Incorrect'];
			}
		}
		else
		{
			$abqrow = $db->sql_fetchrow($result);
			if ($board_config['anti_bot_quest_casesen'])
			{
				if (($abq_aw == $abqrow['answer1']) || (($abqrow['answer2'] != '') && ($abq_aw == $abqrow['answer2'])) || (($abqrow['answer3'] != '') && ($abq_aw == $abqrow['answer3'])) || (($abqrow['answer4'] != '') && ($abq_aw == $abqrow['answer4'])) || (($abqrow['answer5'] != '') && ($abq_aw == $abqrow['answer5'])))
				{}
				else
				{
					$error = TRUE;
					$error_msg .= ( ( isset($error_msg) ) ? '<br />' : '' ) . $lang['ABQ_Incorrect'];
				}
			}
			else
			{
				$abq_aw = strtolower($abq_aw);
				if (($abq_aw == strtolower($abqrow['answer1'])) || (($abqrow['answer2'] != '') && ($abq_aw == strtolower($abqrow['answer2']))) || (($abqrow['answer3'] != '') && ($abq_aw == strtolower($abqrow['answer3']))) || (($abqrow['answer4'] != '') && ($abq_aw == strtolower($abqrow['answer4']))) || (($abqrow['answer5'] != '') && ($abq_aw == strtolower($abqrow['answer5']))))
				{}
				else
				{
					$error = TRUE;
					$error_msg .= ( ( isset($error_msg) ) ? '<br />' : '' ) . $lang['ABQ_Incorrect'];
				}
			}
		}
	}
	// Anti Bot Question Mod - End
And this is what the area in question looks like in my usercp_register.php file (the area that matches most closely with the FIND section above is at the very bottom of the code):

Code: Select all

			if ( $board_config['require_activation'] == USER_ACTIVATION_ADMIN )
			{
				$sql = "SELECT user_email, user_lang 
					FROM " . USERS_TABLE . "
					WHERE user_level = " . ADMIN;
				
				if ( !($result = $db->sql_query($sql)) )
				{
					message_die(GENERAL_ERROR, 'Could not select Administrators', '', __LINE__, __FILE__, $sql);
				}
				
				while ($row = $db->sql_fetchrow($result))
				{
					$emailer->from($board_config['board_email']);
					$emailer->replyto($board_config['board_email']);
					
					$emailer->email_address(trim($row['user_email']));
					$emailer->use_template("admin_activate", $row['user_lang']);
					$emailer->set_subject($lang['New_account_subject']);

					$emailer->assign_vars(array(
						'USERNAME' => preg_replace($unhtml_specialchars_match, $unhtml_specialchars_replace, substr(str_replace("\'", "'", $username), 0, 25)),
						'EMAIL_SIG' => str_replace('<br />', "\n", "-- \n" . $board_config['board_email_sig']),

						'U_ACTIVATE' => $server_url . '?mode=activate&' . POST_USERS_URL . '=' . $user_id . '&act_key=' . $user_actkey)
					);
					$emailer->send();
					$emailer->reset();
				}
				$db->sql_freeresult($result);
			}

			$message = $message . '<br /><br />' . sprintf($lang['Click_return_index'],  '<a href="' . append_sid("index.$phpEx") . '">', '</a>');

			message_die(GENERAL_MESSAGE, $message);
		} // if mode == register
	}
} // End of submit
Any help as to where I should paste the above code would be much appreciated!

Thank you!

VorowneTSG
Registered User
Posts: 257
Joined: Mon Sep 09, 2002 4:33 pm
Contact:

Post by VorowneTSG » Tue Aug 08, 2006 6:47 am

Update: I think I may have found a good place to put the code, but now I get this error when trying to register:
Could not obtain anti-bot-question information

DEBUG MODE

SQL Error : 1054 Unknown column 'answer' in 'field list'

SELECT answer FROM phpbb_anti_bot_quest WHERE lang = 'english' LIMIT 1

Line : 284
File : .../public_html/phpBB2/includes/usercp_register.php


What might be the problem?

Here's the offending part of the code:

Code: Select all

if( $db->sql_numrows($result) == 0 )
                {
                        $sql = 'SELECT answer
                                FROM ' . ANTI_BOT_QUEST_TABLE . '
                                WHERE lang = \'' . $board_config['default_lang'] . '\'
                                LIMIT 1';
Since it says there's no column named "answer", I changed "SELECT answer" to "SELECT answer1, answer2, answer3, answer4, answer5" and no longer got the above Error message, but now it says every answer is incorrect - even the correct ones! Very confusing problem...

MagMo
Registered User
Posts: 20
Joined: Sat Apr 15, 2006 3:01 pm
Contact:

Post by MagMo » Tue Aug 08, 2006 2:24 pm

VorowneTSG wrote: I'm still running phpBB 2.0.6...
For many reasons you should update your phpbb.
VorowneTSG wrote: Everything looks like it will work, except for the following part of the instructions:

Code: Select all

#-----[ FIND ]------------------------------------------------ 
# 
				$error = TRUE;
				$error_msg .= ( ( isset($error_msg) ) ? '<br />' : '' ) . $lang['Confirm_code_wrong'];
			}
			$db->sql_freeresult($result);
		}
	}
This text does not exist as such in the usercp_register.php file for 2.0.6.
Could you please link your "usercp_register.php" as a textfile for download?
VorowneTSG wrote: Here's the offending part of the code:
Code:
if( $db->sql_numrows($result) == 0 )
{
$sql = 'SELECT answer
FROM ' . ANTI_BOT_QUEST_TABLE . '
WHERE lang = \'' . $board_config['default_lang'] . '\'
LIMIT 1';


Since it says there's no column named "answer", I changed "SELECT answer" to "SELECT answer1, answer2, answer3, answer4, answer5" and no longer got the above Error message,...
:oops: 'SELECT answer' is wrong, therefore the mod is updated (version 1.0.3).

VorowneTSG
Registered User
Posts: 257
Joined: Mon Sep 09, 2002 4:33 pm
Contact:

Post by VorowneTSG » Tue Aug 08, 2006 10:56 pm

Here's my usercp_register.php file: download
For many reasons you should update your phpbb.

I'm indeed in the process of updating, but due to the large amount of mods I have installed, it's been a slow process.
'SELECT answer' is wrong, therefore the mod is updated (version 1.0.3).

Not sure what you mean by this :?. Is this to say the mod needs updating? Or that I have an updated copy somehow?

MagMo
Registered User
Posts: 20
Joined: Sat Apr 15, 2006 3:01 pm
Contact:

Post by MagMo » Wed Aug 09, 2006 5:49 am

Hi,
VorowneTSG wrote: ...but now it says every answer is incorrect
The reason for this problem is:
You forgot this code change:

Code: Select all

# 
#-----[ FIND ]------------------------------------------------ 
# 
	$strip_var_list = array('email' => 'email', 'icq' => 'icq', 'aim' => 'aim', 'msn' => 'msn', 'yim' => 'yim', 'website' => 'website', 'location' => 'location', 'occupation' => 'occupation', 'interests' => 'interests', 'confirm_code' => 'confirm_code');

# 
#-----[ IN-LINE FIND ]------------------------------------------------ 
# 
'confirm_code' => 'confirm_code'

# 
#-----[ IN-LINE AFTER, ADD ]------------------------------------------------ 
# 
, 'abq_aw' => $board_config['anti_bot_quest_get'], 'idabq' => 'idabq'
The find-text does not exist in your old usercp_register-file. Use this instead:

Code: Select all

# 
#-----[ FIND ]------------------------------------------------ 
# 
        $strip_var_list = array('username' => 'username', 'email' => 'email', 'icq' => 'icq', 'aim' => 'aim', 'msn' => 'msn', 'yim' => 'yim', 'website' => 'website', 'location' => 'location', 'occupation' => 'occupation', 'interests' => 'interests');

# 
#-----[ IN-LINE FIND ]------------------------------------------------ 
# 
'interests' => 'interests'

# 
#-----[ IN-LINE AFTER, ADD ]------------------------------------------------ 
# 
, 'abq_aw' => $board_config['anti_bot_quest_get'], 'idabq' => 'idabq'
VorowneTSG wrote: Everything looks like it will work, except for the following part of the instructions:

Code: Select all

#-----[ FIND ]------------------------------------------------ 
# 
            $error = TRUE; 
            $error_msg .= ( ( isset($error_msg) ) ? '<br />' : '' ) . $lang['Confirm_code_wrong']; 
         } 
         $db->sql_freeresult($result); 
      } 
   }
This text does not exist as such in the usercp_register.php file for 2.0.6.
Using

Code: Select all

# 
#-----[ FIND ]------------------------------------------------ 
# 
                if ( empty($username) || empty($new_password) || empty($password_confirm) || empty($email) )
                {
                        $error = TRUE;
                        $error_msg .= ( ( isset($error_msg) ) ? '<br />' : '' ) . $lang['Fields_empty'];
                }
        }

# 
#-----[ AFTER, ADD ]------------------------------------------------ 
# 
	// Anti Bot Question Mod - Start
	if (($mode == 'register') && ($board_config['anti_bot_quest']))
	{
...
instead of

Code: Select all

# 
#-----[ FIND ]------------------------------------------------ 
# 
				$error = TRUE;
				$error_msg .= ( ( isset($error_msg) ) ? '<br />' : '' ) . $lang['Confirm_code_wrong'];
			}
			$db->sql_freeresult($result);
		}
	}

# 
#-----[ AFTER, ADD ]------------------------------------------------ 
# 
	// Anti Bot Question Mod - Start
	if (($mode == 'register') && ($board_config['anti_bot_quest']))
	{
...
is a good solution to this problem.

VorowneTSG wrote: Not sure what you mean by this :?. Is this to say the mod needs updating? Or that I have an updated copy somehow?[/
It means I fixed the mod and updated the download file (current version: 1.0.3).
If you want to update your installed mod follow this instruction:

Code: Select all

# 
#-----[ OPEN ]------------------------------------------------ 
# 
includes/usercp_register.php

# 
#-----[ FIND ]------------------------------------------------ 
# 
			$sql = 'SELECT answer

# 
#-----[ REPLACE WITH ]------------------------------------------------ 
# 
			$sql = 'SELECT answer1, answer2, answer3, answer4, answer5

# 
#-----[ OPEN ]------------------------------------------------ 
# 
language/lang_english/lang_admin.php

# 
#-----[ FIND ]------------------------------------------------ 
# 
$lang['ABQ_Version'] = '1.0.2';

# 
#-----[ REPLACE WITH ]------------------------------------------------ 
# 
$lang['ABQ_Version'] = '1.0.3';

VorowneTSG
Registered User
Posts: 257
Joined: Mon Sep 09, 2002 4:33 pm
Contact:

Post by VorowneTSG » Wed Aug 09, 2006 8:21 am

It works perfectly now! Thanks a lot for the help, and for the mod itself. It's much appreciated.

JonBeinart
Registered User
Posts: 2
Joined: Thu Aug 10, 2006 1:19 pm
Contact:

Post by JonBeinart » Thu Aug 10, 2006 1:28 pm

Erk!! I have a huge issue with Spambots registering on my forum and bypassing the Visual confirmation. I run a very popular Forum for Surreal Artists http://surrealartforum.com and am going crazy with all of the rubbish users that appear each day advertising all sorts of tripe. This Mod sounds perfect, but I am practically php illiterate and know that If I tried to install this mod, I would almost definately cause my whole forum to implode on itself. I cant afford this after all of the work that has gone into it. Please help me someone. I will pay someone to install this mod. Anything to stop the constant barrage of Online gambling, viagra, tramadol etc. on my forum
Please email me at: beinart at gmail dot com

prokopton72
Registered User
Posts: 3
Joined: Thu Jun 08, 2006 2:52 am

Thank-you, MagMo

Post by prokopton72 » Fri Aug 11, 2006 9:54 pm

I've just installed this Mod and it works beautifully. I was getting about 3-10 spam accounts a day. I haven't had any yet.

Thanks, Magmo!
School, friends, family, Internet.

zx
Registered User
Posts: 37
Joined: Sat Mar 06, 2004 11:15 am

Post by zx » Sat Aug 12, 2006 7:42 am

Any ideas on what I should do now - when clicking on ABQ questions in the config section?

Could not query anti-bot-question information

DEBUG MODE

SQL Error : 1146 Table 'dt_forum.ANTI_BOT_QUEST_TABLE' doesn't exist

SELECT * FROM ANTI_BOT_QUEST_TABLE ORDER BY lang ASC, anti_bot_img ASC, question ASC

Line : 59
File : admin_anti_bot_quest.php

Have tried the db update a couple of times - same. Thanks.

MagMo
Registered User
Posts: 20
Joined: Sat Apr 15, 2006 3:01 pm
Contact:

Post by MagMo » Sat Aug 12, 2006 8:12 am

Hi,

are you sure that you made this change?

Code: Select all

# 
#-----[ OPEN ]------------------------------------------------ 
# 
includes/constants.php

# 
#-----[ FIND ]------------------------------------------------ 
# 
define('CONFIRM_TABLE', $table_prefix.'confirm');

# 
#-----[ AFTER, ADD ]------------------------------------------------ 
# 
// Anti Bot Question Mod - Start
define('ANTI_BOT_QUEST_TABLE', $table_prefix.'anti_bot_quest');
// Anti Bot Question Mod - End

zx
Registered User
Posts: 37
Joined: Sat Mar 06, 2004 11:15 am

Post by zx » Sat Aug 12, 2006 10:07 am

Thanks - I hadn't & now I can see them.

I have a broken image on the ABQ config page - why might that be? I've uploaded the images into SubSilver & the template I'm using. Maybe I should be configuring all this in SubSilver first?

fred007
Registered User
Posts: 44
Joined: Sun Jun 09, 2002 10:40 am

Post by fred007 » Sat Aug 12, 2006 4:05 pm

Hi,

I installed the mod using EM but had the following critical error:


Function Trace: open_files[5]->modio_open[1]

Could not open [language/lang_french/lang_admin.php] for reading.
MOD script line #740 :: FAQ :: Report

My default language is English. I would be very grateful for advice as to what to do. I am using the latest version of phpBB. Many thanks.

Post Reply

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