PHP Web Host - Quality Web Hosting For All PHP Applications Just Great Software
  Login or Register
 • Home • Downloads • Your Account • Forums • 

View next topic
View previous topic


Google
 
Web RavenPHPScripts (This Site)
Post new topic   Reply to topic
Author Message
blith
Client


Joined: Jul 18, 2003
Posts: 977

PostPosted: Fri Nov 12, 2004 10:52 am Reply with quote Back to top

I found the following and would like to know everyone's thoughts on it and what it does. Thank you for reading.

Code:
An even better way to stop bad bots is to trap them with php. Here's the code should anyone fancy using it:

Index.php:

<?php
header ("Location: http://www.yourwebsite.com/index.php");
?>

htaccess:

IndexIgnore *

Now make a "blckhole" to trap them by creating /sandtrap and ban/ip

Create /sandtrap in index.php:

<?php
$ip = "$REMOTE_ADDR\n" ;
$banip = '/path/to/ban-ip/ban-ip.txt';
$fp = fopen($banip, "a");
$write = fputs($fp, $ip);
fclose($fp);
?>

Anyone coming in to /sandtrap/index.php will have his IP address written to the file
/ ban-ip.txt. What you are doing is setting a trap:

Place a hidden link someplace on your home index page that points to /sandtrap/index.php. It should not be so far up the page that the indexers use it, but high as you can get it. DO NOT place any readable email addrsses on it though because harvesters work through links in order and so the first link logs the IP to our real time blackhole list before it is able to access our remaining links.

Stick this in robots.txt:

User-agent: *
Disallow: /sandtrap
Disallow: /ban-ip

Ban anyone from reading your bab-ip.txt in .htaccess:

SetEnvIfNoCase Request_URI ban-ip\.txt ban

<Files ~ "^.*$">
order allow,deny
allow from all
deny from env=ban
</Files>

Force everyoneto go through your home page by placing this code in all the child pages:

<?php
$engine = file('/path/to/indexer.txt');
$ref = getenv('HTTP_REFERER');
$ua = $HTTP_SERVER_VARS['HTTP_USER_AGENT'];
$home = "yourwebsite.com" ;
$browse = 0 ;

if (stristr($ref, $home))
{
$browse = 1 ;
}

foreach( $engine as $indexer )
{
$indexer = rtrim( $indexer ) ;
if (stristr($ua, $indexer))
$browse = 1 ;
}

if ($browse == 0)
{
header("Location: http://www.yourwebsite.com/index.php");
}
?>

Stick this at the top of the index page:

<?php
$sandtrap = file('/path/to/ban-ip.txt');
$ua = $HTTP_SERVER_VARS['HTTP_USER_AGENT'];
$ip = $REMOTE_ADDR ;

$punish = 0;
if ( $ua == "" )
{
$punish = 1 ;
}

foreach( $sandtrap as $blockip )
{
$blockip = rtrim( $blockip ) ;
if (stristr($ip, $blockip))
$punish = 1 ;
}

if ( $punish == 1 )
{
echo "<HTML><head><title>Access Denied</title></head>
<p>The software you are using to access our website is not allowed.</p>
}
?>


In the file indexer.txt place all the good bots:

Ask Jeeves
FAST-WebCrawler
GoogleBot
ia_archiver
IBM_Planetwide
Inktomi
Scooter
Slurp
WISENutbot
View user's profile Send private message Visit poster's website
Display posts from previous:       
Post new topic   Reply to topic

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Forums ©
 

All logos and trademarks in this site are property of their respective owner.
The comments are property of their posters, all the rest © 2002-2011 by Raven

You can syndicate our news using the file xml

CSE HTML Validator Helped Clean up This Page! [Valid RSS] valid RSS 2.0 Valid robots.txt Stop Spam Harvesters, Join Project Honey Pot

Website engines core code is © copyright by PHP-Nuke but has been heavily patched and modified by myself and others.
PHP-Nuke is a free software released under the GNU/GPL.


:: fisubice phpbb2 style by Daz :: PHP-Nuke theme by www.nukemods.com ::
:: fisubice Theme Modified by the RavenNuke™ Team ::

:: W3C CSS Compliance Validation :: W3C HTML 4.01 Transitional Compliance Validation ::

zerosum