not sure where to start on this script :/

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

Post Reply
qads
DevNet Resident
Posts: 1199
Joined: Tue Apr 23, 2002 10:02 am
Location: Brisbane

not sure where to start on this script :/

Post 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
gxpark
Forum Commoner
Posts: 33
Joined: Fri Jun 21, 2002 4:01 pm
Location: Mexico City

Post by gxpark »

Here is what you need:

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

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

Enjoy.
qads
DevNet Resident
Posts: 1199
Joined: Tue Apr 23, 2002 10:02 am
Location: Brisbane

Post by qads »

thanks, that was great :D
will
Forum Contributor
Posts: 120
Joined: Fri Jun 21, 2002 9:38 am
Location: Memphis, TN

Post 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
qads
DevNet Resident
Posts: 1199
Joined: Tue Apr 23, 2002 10:02 am
Location: Brisbane

Post 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
will
Forum Contributor
Posts: 120
Joined: Fri Jun 21, 2002 9:38 am
Location: Memphis, TN

Post 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
qads
DevNet Resident
Posts: 1199
Joined: Tue Apr 23, 2002 10:02 am
Location: Brisbane

Post 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
will
Forum Contributor
Posts: 120
Joined: Fri Jun 21, 2002 9:38 am
Location: Memphis, TN

Post by will »

your ['host'] should be "www.icwizards.co.uk".... the http:// and the "/~ironfist/dl/" are other parts of the arrReferer array
User avatar
protokol
Forum Contributor
Posts: 353
Joined: Fri Jun 21, 2002 7:00 pm
Location: Cleveland, OH
Contact:

Post 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
qads
DevNet Resident
Posts: 1199
Joined: Tue Apr 23, 2002 10:02 am
Location: Brisbane

Post 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
qads
DevNet Resident
Posts: 1199
Joined: Tue Apr 23, 2002 10:02 am
Location: Brisbane

Post 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
will
Forum Contributor
Posts: 120
Joined: Fri Jun 21, 2002 9:38 am
Location: Memphis, TN

Post 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.
qads
DevNet Resident
Posts: 1199
Joined: Tue Apr 23, 2002 10:02 am
Location: Brisbane

Post 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
User avatar
dlgilbert
Forum Newbie
Posts: 6
Joined: Wed Jun 19, 2002 7:03 am
Location: Pennsylvania, USA
Contact:

I think I'm missing something...

Post 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?
Post Reply