Page 1 of 1

not sure where to start on this script :/

Posted: Sun Jun 23, 2002 5:18 pm
by qads
:? i am not sure where to start on this:

"something that can stop people from linking
files from ur site on their site so when someone links
a file for download from my site on theirs my
webserver is getting used not theirs.. a script that
stops that from happening would be great something
that hides then url where the file is located"

that is a quote from one of the emails i got and i would like to make it.
but i don't really have any ideas where to start on it, hmm how about
<?php :wink:

some help would be great,

thanks in adv

Posted: Sun Jun 23, 2002 5:27 pm
by gxpark
Here is what you need:

http://php.dot-totally.co.uk/?id=2

Found it through http://www.hotscripts.com

Enjoy.

Posted: Sun Jun 23, 2002 5:30 pm
by qads
thanks, that was great :D

Posted: Sun Jun 23, 2002 5:34 pm
by will
at the very least, this will get you started. it checks the host of the page that referred to this one, and returns whatever file if it is your host. you'd prolly want to pass in a variable $file that holds hte name of the desired file (that way this one page will work for all of your 'protected' files). This file is actually stored in some unknown, possibly even protected directory.

Code: Select all

$arrReferer = parse_url($HTTP_REFERER);

if($arrReferer&#1111;'host'] == "www.yourdomain.com") &#123;
	//return file from wherever it is (some unknown directory)
&#125; else &#123;
	// possibly return a file that states this file is being stolen
	// from your site - that'll stop em fast :)
&#125;
might also wanna add some error checking to make sure there is a referring URL

Posted: Sun Jun 23, 2002 5:41 pm
by qads
hmm, this one seems more useful will, and i understand it more then the first one :)


hmm, a message to scar the file downloader :twisted:

"STOP THIFE OR I WILL PUT A 01011011 SPELL ON YOU"

how is that :P

hehe, nerdy i know 8O

:) thanks guys

Posted: Sun Jun 23, 2002 5:48 pm
by will
here's a working example of what i described....

try going to http://www.wirewater.org/test/bandwidth_thief/test.php

then go to http://www.wirewater.org/test/bandwidth_thief/link.php and follow the link.

same file, but serves up a different image. view the source of test.php at http://www.wirewater.org/test/bandwidth_thief/test.phps

Posted: Mon Jun 24, 2002 11:19 am
by qads
ok, it does't work for me :(

<?php
$arrReferer = parse_url($HTTP_REFERER);

if($arrReferer['host'] == "http://www.icwizards.co.uk/~ironfist/dl/") {
print("not a thief :) and the file name is: $file");
} else {
print("you are a thief >:|");
}
?>

here is the code, what's wrong with it? you can check it at
http://www.icwizards.co.uk/~ironfist/dl\htm.htm


thanks for your help

Posted: Mon Jun 24, 2002 11:25 am
by will
your ['host'] should be "www.icwizards.co.uk".... the http:// and the "/~ironfist/dl/" are other parts of the arrReferer array

Posted: Mon Jun 24, 2002 11:26 am
by protokol
try echoing the value of $arrReferer['host'] .. you'll notice that it will be http://www.icwizards.co.uk and NOT http://www.icwizards.co.uk/~ironfist/dl/

Code: Select all

// instead of:

if($arrReferer&#1111;'host'] == "http://www.icwizards.co.uk/~ironfist/dl/") 

// use this:

if($arrReferer&#1111;'host'] == "www.icwizards.co.uk")
check http://www.php.net/manual/en/function.parse-url.php to learn more about what can be done with the parse_url() function

Posted: Mon Jun 24, 2002 4:29 pm
by qads
hmm, one more question;
i am useing

Code: Select all

<a href="test.php?file=filename">Download</a>
to find out what file the user wants to download...
how do the users get the file? or how do i get the file and pop up the download box?

thanks

Posted: Mon Jun 24, 2002 4:33 pm
by qads
hmm, sorry guys, i tested
header(); and it works, just have to make sure that this code is used at the top of any page.



thanks

Posted: Mon Jun 24, 2002 9:51 pm
by will
qads wrote:hmm, sorry guys, i tested
header(); and it works, just have to make sure that this code is used at the top of any page.
what are you passing into header()? if it is just a location to redirect to, then you are no longer hiding the URL of the file... since you're sending the visitor right to it. instead, you would want the script to actually return the file itself, not the URL.

Posted: Tue Jun 25, 2002 4:24 am
by qads
yes, i am useinh header like this:

Code: Select all

header("loaction:$path/$file");
this way it does't even go to download page, just pops up the download box :P

I think I'm missing something...

Posted: Wed Jun 26, 2002 8:15 am
by dlgilbert
How will any of this work if someone is linking directly to an image?

For instance: http://www.somesite.com/image.jpg

That won't be calling or executing any PHP code to check the referrer.

What am I missing?