How Can I Secure My Links ?

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
saqib389
Forum Commoner
Posts: 44
Joined: Wed Nov 30, 2005 2:13 am

How Can I Secure My Links ?

Post by saqib389 »

i have a music website.. and many of persons use my links in their site..
i have login registration system in my site also.....
can any one tell me that how can i secure my links

i mean whenver some other person want to put my link into their site.. then there would not b download any thing....

coz my bandwidth is very much used if ppl used my links.. so please guyz if any one can tell me how can i secure my links.. that ppl cant uses into their sites.....


any one can write the code ????
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

you could send the file down with header()'s and check to see if a session var is set on your site...

If the session var isn't set, don't send it
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Post by josh »

If your site does not use sessions, you can also put a random token into the download link, and insert it into a mysql table, and then on the page that sends the file for downloading you check for the presence of a valid token
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

I would probably keep all your music outside the web directory, so only YOUR script has access to the music via header(), as burrito suggested, in combination with readfile().
saqib389
Forum Commoner
Posts: 44
Joined: Wed Nov 30, 2005 2:13 am

Post by saqib389 »

thx guyz
but not 100% clear...

can one refer me anyY code that will help me more.....
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

It sounds like you're talking about Hot Linking. Most hosts provide support for Hot Link protection which means that certain files can only be accessed from your own server. If someone links to a file from elsewhere you just get redirected.

Apache supports it as far as I know but I've never set it up myself.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

d11wtq wrote:It sounds like you're talking about Hot Linking. Most hosts provide support for Hot Link protection which means that certain files can only be accessed from your own server. If someone links to a file from elsewhere you just get redirected.

Apache supports it as far as I know but I've never set it up myself.
True.. but I like to get my hands dirty with a download script, because its much easier to handle statistical information without having to read through the great logs of apache ;)
Post Reply