filter web addresses

the mail() function

Moderators: egami, macek, gesf

Post Reply
User avatar
egami
php-forum GURU
php-forum GURU
Posts: 2192
Joined: Wed Oct 06, 2010 11:19 am
Location: Happy Valley, UT

Wed Dec 21, 2011 6:54 am

Don't most addresses start with a Number?

like.. 49 E. CarryMeAway Lane?

So, it would be easy in those regards..

but, it would be better to look for this..

if (preg_match('/http[s]{0,1}:\/\/',$_POST['address'])) {
header("Location: you_suck.php");
}

User avatar
egami
php-forum GURU
php-forum GURU
Posts: 2192
Joined: Wed Oct 06, 2010 11:19 am
Location: Happy Valley, UT

Wed Dec 21, 2011 1:00 pm

First, create the you_suck.php page and in it do this..

you_suck.php

Code: Select all

echo "
<div>
  <h1>I'm sorry, but you suck, your robot sucks, and your scripting skills suck. Don't come back.</h1>
  <h2>IP: ".$_SERVER['REMOTE_ADDR']." (logged)</h2>
  <h3>Now go away.</h3>
</div>
";
 
If you really want to log it, take a look at php.net/fput, or throw down some dead presidents.
if you really want to block it, take a look at php.net/fget, php.net/array, php.net/foreach



Next,
Add that code I wrote earlier directly above the $address = (isset($_POST....... stuff)

Then try to add an http address in your address line, and see what it does.

User avatar
egami
php-forum GURU
php-forum GURU
Posts: 2192
Joined: Wed Oct 06, 2010 11:19 am
Location: Happy Valley, UT

Wed Dec 21, 2011 1:03 pm

Oh yes, before I forget..
If you do want to log it, and block it, make sure you set a timer or figure out how to block bigger blocks of addresses: Otherwise the little script kiddies could flood your server.

Although I doubt little johnny in Mommy's basement has access to 5000 plus robots.. You just never know who does.

Post Reply