Forum Moderators: coopster

Message Too Old, No Replies

Ban domain using php

having problem with php script I want to use to ban domains

         

richards1052

6:53 am on Aug 24, 2005 (gmt 0)

10+ Year Member



Because of the nature of my (WordPress) blog, various website & online forums sometimes link (usually unfavorably) to my site causing floods of flames and other abusive comments.

I've discovered a few ways you can ban visitors fr. these domains to access the site. Someone suggested this php script which I tried to insert into my header.php file:

<?php
$urls[0]='http://www.banneddomain.com';
$urls[1]='http://banneddomain.com/';
$ref=strtolower($_SERVER['HTTP_REFERER']);
$url='http://www.mydomain.com/403.shtml';
if(!in_array($ref, $urls)){
header('Location: '.$url);
}
?>

But after trying to add the script in 3 diff. places within the file I couldn't get it to work. When I tried to access my site I'd get a blank browser screen. Finally, I had to use ftp to remove the script.

Can anyone think of how this conflict might arise? Is there possibly something wrong w. the script (which I didn't write)?

Romeo

9:39 am on Aug 24, 2005 (gmt 0)

10+ Year Member



I'd get a blank browser screen

Looks like an error somewhere in a script on that page.
Have you looked in the error_log file about what the web server was thinking about that?

trying to add the script in 3 diff. places

Just a guess: the header statement will only work if it is the first thing to be sent out by the server; nothing else of your page content should have been sent before (not even a blank line), so put the script in the first place at the very beginning of all.

Regards,
R.