Log in

View Full Version : PHPBB Help


L. Spiro
May 17th, 2008, 08:43
I am really quite sick of fag bots posting on my forums and I want to edit my posting_body.tpl to disallow posts containing certain text.

I need to modify the checkForm() function to scan for key words and then error (even if the error report makes no sense, I don’t really care).

I had this:

Code:
function checkForm() {

formErrors = false;

if (document.post.message.value.length < 2) {
formErrors = "{L_EMPTY_MESSAGE}";
}
if (stristr(document.post.message.value, 'sex') !== FALSE) {
formErrors = "{L_EMPTY_MESSAGE}";
}

if (formErrors) {
alert(formErrors);
return false;
} else {
bbstyle(-1);
//formObj.preview.disabled = true;
//formObj.submit.disabled = true;
return true;
}
}



It fails (no error thrown but always allows posts even when containing the offensive text).
Anyone know how to get this to work?


L. Spiro

Kayaker
May 17th, 2008, 11:52
Hi

The problem might be the !== FALSE syntax. What if you try

if (stristr(a,b) === TRUE) {

or

if (stristr(a,b)) {

L. Spiro
May 17th, 2008, 13:51
I don’t know if !== is valid or not but I tried === TRUE with the same result.
But actually I knew that wouldn’t work anyway because it returns the string it finds if it finds a string. But I don’t know how to check that the result is a string, except by checking that the return is not FALSE, so I invented !== in the hopes it would work.

http://www.w3schools.com/PHP/func_string_stristr.asp

So I either need to know how to see if the result is an actual string or how to check for it not equaling FALSE. Or I need to verify that document.post.message.value is actually a string value, and if not I need to know how to get the string value of the post.


L. Spiro

Kayaker
May 17th, 2008, 17:05
Yeah, I should have been more careful in my reply.

vBulletin php uses stristr with 4 different syntaxes, so these should all be valid choices for developing an IF statement construct:


if (stristr($a, 'string') === false) {

// equates to FALSE, probably not the construct you want

}


if (!stristr($a, 'string') {

// should also equate to FALSE being returned

}


if (stristr($a, 'string') {

// should equate to a valid string being returned, string was found

}


$foundstring = stristr($a, 'string');
(if strlen of $foundstring = 0, this should indicate no occurrences of 'string' were found, i.e. FALSE was returned)




You should be able to test if document.post.message.value is the correct member that defines the post message by outputting it with echo().

Alternatively, you should be able to output all members of the document.post.x array into a readable format with print_r() or var_dump(). Download the full php manual in CHM format, it's pretty handy.

Hope this helps.

Kayaker

dELTA
May 17th, 2008, 17:25
Taking one step back, I just must say you'll be much better off putting your energy into a good CAPTCHA. I manage several forums myself, run on multiple forum software backends, and the heavy spam was eliminated practically completely on all of them by simply making sure that the bots can't register automatically. Keyword filtering on the other hand will always lead to false positives, and/or some spam still getting through.

A very simple for extremely efficient CAPTCHA is the kind we use here: A simple textual question like e.g. "What is two times four, minus one?", to which the user should answer in text too.

I'm quite sure there are PHPBB plugins for that, and in the unlikely event that you can't find any good ones, simply hard-code the question into the registration process PHP code. Believe me, it's super efficient.

Just a tip based on experience.

Woodmann
May 17th, 2008, 18:37
Quote:
A very simple for extremely efficient CAPTCHA is the kind we use here: A simple textual question like e.g. "What is two times for, minus one?", to which the user should answer in text too.



Yes, use that and I can garauntee nobody will get in .

It should say:

"what is two times four minus one"
The answer should be in the form of a word.

Woodmann