Code: Select all
andCode: Select all
tags where appropriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
I’m trying to use a user-agent blocker using PHP in yahoo web hosting. Unfortunately Yahoo won’t let me use the following script inside an .html file (unless I change all my web site from .html to .php, which I won't do) to call up my PHP file robots.php (nor do they let me have a .htaccess file either):
<?PHP include "/robots.php"; ?>
So, I tried using Javascript instead for which I do receive the email warning me that a blocked useragent has accessed my web but e403.html does not show up afterwards.
<script language="JavaScript" type="text/javascript" src="/robots.php">
</script>
So what can i do so that e403.html will show up after i get the email?
This is the content of robots.php (whithout the 2 dashed lines):
------------------------------------------------------Code: Select all
<?php
$browser = array ("^crescent",
"wbdbot",
"Web Downloader",
"webauto",
"webbandit",
"WebCapture",
"webcollector",
"WebCopier",
"webdevil",
"WebEMailExtrac.*",
"WebFetch",
"webfetcher",
"WebFountain",
"webhook",
"webminer",
"WebMirror",
"webmole",
"WebReaper",
"WebSauger",
"WebSense",
"website",
"websnake",
"Webster",
"WebStripper",
"websucker",
"webweasel",
"WebWhacker",
"WebZIP",
"Wget",);
$punish = 0;
while (list ($key, $val) = each ($browser)) {
if (strstr ($HTTP_USER_AGENT, $val)) {
$punish = 1;
}
}
if ($punish) {
$msg .= "robots.php detected the following banned browser agent errors:\n";
$msg .= "Host: $REMOTE_ADDR\n";
$msg .= "Agent: $HTTP_USER_AGENT\n";
$msg .= "Referrer: $HTTP_REFERER\n";
$msg .= "Document: $SERVER_NAME" . $REQUEST_URI . "\n";
$headers .= "X-Priority: 1\n";
$headers .= "From: Robots.php <pfs@pfs.net>\n";
$headers .= "X-Sender: <pfs@pfs.net>\n";
mail ("pfs@pfs.net", "robots.php BANNED BROWSER
AGENT ERROR from pfs@pfs.net", $msg, $headers
);
include "/e403.html";
exit;
}
?>Sami | Please use
Code: Select all
andCode: Select all
tags where appropriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]