Bandwidth stealing block

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

codewarrior
Forum Commoner
Posts: 81
Joined: Wed Aug 07, 2002 1:28 pm

Post by codewarrior »

Thanks! I can work on rest of it ;)
codewarrior
Forum Commoner
Posts: 81
Joined: Wed Aug 07, 2002 1:28 pm

Post by codewarrior »

Does this make sense:

Code: Select all

<?
$domain = "www.site.net";
//$domain = array("site.net","www.site.net","site.site.net");
$refr=getenv("HTTP_REFERER");
list($remove,$stuff)=split('//',$refr,2);
list($home,$stuff)=split('/',$stuff,2);

if($home!=$domain) {

header("Location: http://www.site.net/error.shtml");


} else {


$file = $pafiledb_sql->query($db, "SELECT * FROM $dbїprefix]_files WHERE file_id = '$id'", 1);
$time = time();
$update = $pafiledb_sql->query($db, "UPDATE $dbїprefix]_files SET file_dls=file_dls+1, file_last=$time WHERE file_id = '$id'", 0);
header("Location: $fileїfile_dlurl]");

}
?>
Can't figure out how to do that array thing. I need to get that array of sites to work, so when people come to the site, and dont put www. infront it will NOT block them also. :?
dusty
Forum Contributor
Posts: 122
Joined: Sun Apr 28, 2002 9:52 pm
Location: Portsmouth, VA

Post by dusty »

Code: Select all

if(!in_array($refr,$domain)) {
  error
} else {
  pass
}
i'm just guessing that's what you meant by using the domain array.
dusty
Forum Contributor
Posts: 122
Joined: Sun Apr 28, 2002 9:52 pm
Location: Portsmouth, VA

Post by dusty »

you might wanna use HTTP_HOST instead of REFERER also.

another option would be something like

Code: Select all

if(!eregi("domain.com",$refr)) {
  error
} else {
  pass
}
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

From the PHP manual:
'HTTP_REFERER'
The address of the page (if any) which referred the user agent to the current page. This is set by the user agent. Not all user agents will set this, and some provide the ability to modify HTTP_REFERER as a feature. In short, it cannot really be trusted.
as Dusty pointed out maybe you should consider checking something else in case you inadvertently prevent people from accessing the content from your own site.

Mac
codewarrior
Forum Commoner
Posts: 81
Joined: Wed Aug 07, 2002 1:28 pm

Post by codewarrior »

Yeah I know what you mean ... Isn't there some other way of blocking?
User avatar
Takuma
Forum Regular
Posts: 931
Joined: Sun Aug 04, 2002 10:24 am
Location: UK
Contact:

Post by Takuma »

I guess you just have to trust the user...
codewarrior
Forum Commoner
Posts: 81
Joined: Wed Aug 07, 2002 1:28 pm

Post by codewarrior »

I trust the users all the time ... but its the freaking bandwidth thieves that drive me nuts!!!!!!!!!! :lol:
EricS
Forum Contributor
Posts: 183
Joined: Thu Jul 11, 2002 12:02 am
Location: Atlanta, Ga

Post by EricS »

If you running on a *nix server, you can modify the .htaccess file to keep out bandwidth thieves. Don't remember the exact modification needed but a quick search should reveal the answer.

Hope this helps.
User avatar
Takuma
Forum Regular
Posts: 931
Joined: Sun Aug 04, 2002 10:24 am
Location: UK
Contact:

Post by Takuma »

codewarrior wrote:I trust the users all the time ... but its the freaking bandwidth thieves that drive me nuts!!!!!!!!!! :lol:
That means you not trusting them, cos bandwidth thieves are part of user :o
codewarrior
Forum Commoner
Posts: 81
Joined: Wed Aug 07, 2002 1:28 pm

Post by codewarrior »

EricS wrote:If you running on a *nix server, you can modify the .htaccess file to keep out bandwidth thieves. Don't remember the exact modification needed but a quick search should reveal the answer.

Hope this helps.
Ok thanks ;)
codewarrior
Forum Commoner
Posts: 81
Joined: Wed Aug 07, 2002 1:28 pm

Post by codewarrior »

Takuma wrote:
codewarrior wrote:I trust the users all the time ... but its the freaking bandwidth thieves that drive me nuts!!!!!!!!!! :lol:
That means you not trusting them, cos bandwidth thieves are part of user :o
:lol: Well, I trust that till they break the rule and then :twisted:
Post Reply