Forum Moderators: coopster & phranque

Message Too Old, No Replies

Ban submission by text phrase

ban user by text phrase

         

LisaPYN

2:53 pm on Feb 22, 2003 (gmt 0)

10+ Year Member



I guess all of us have at one point or another dealt with the frustrations of trying to ban dynamic IP addresses. I am dealing with one unwelcome dynamic IP visitor quite a bit of late. I'm not concerned with banning him from the site, but with stopping him from submitting on a form on the site. He always includes his URL, so I'll like to find a way to ban the URL from form submissions.

Does anyone know how to set up a text ban? For instance, if he always types the word "apple" in his submissions, how can I tell Perl not to allow a submission with the word "apple" in it to post? Any help at all would be appreciated. :-)

gsx

3:15 pm on Feb 22, 2003 (gmt 0)

10+ Year Member



Just use an if statement:

if($submission!~ /apple/i)
{
...do submit...
}
else
{
...create an error or do nothing...
}

(which means if submission does not contain the word 'apple', submit it - that part needs unusual characters to be prefixed with a '\', so a web address would be 'www\.wherever\.com' - the full stops have been prefixed, but a-z and 0-9 should not be)

andreasfriedrich

3:21 pm on Feb 22, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to WebmasterWorld [webmasterworld.com] LisaPYN.

Be sure to read Marcia`s WebmasterWorld Welcome and Guide to the Basics [webmasterworld.com] post.

Once you have gathered the submitted text and put it into some variable use regular expressions to check for the word like so:


if($text =~ m [perldoc.com]!\bapple\b!) {
print "Apple not allowed\n";
} else {
print "Welcome!"
}

Just adjust the regular expression to whatever it needs to match. If you need some help with regular expressions this is a nice regular expression tutorial [etext.lib.virginia.edu].

HTH Andreas

<added>I was too slow</added>

LisaPYN

3:51 pm on Feb 22, 2003 (gmt 0)

10+ Year Member



Thanks! I appreciate your suggestions and will give it a go now. This is all new to me (as I'm sure you can tell...lol), but with time, I hope to learn more. I appreciate you taking the time to help. :-)