Jump to content

changing a download link every 5 minutes?


L

Recommended Posts

So basically you want help figuring out how to make the links expire?

 

Make a table in the database like this

 

TABLE links
-----------
linkID - Auto-increment, primary key
key - this will be a unique ID for the url generated by the function uniqid()
time_created - the time the link was created

 

Now have your links look something like this

www.domain.com/download.php?key=121w21e

 

When the user clicks on that link, you need to check the database to check if there is a link that exists with that key and is less than 5 minutes old.

 

Hopefully you get the idea. Just let me know if you need more explaining on something.

Link to comment
Share on other sites

So basically you want help figuring out how to make the links expire?

 

Make a table in the database like this

 

TABLE links
-----------
linkID - Auto-increment, primary key
key - this will be a unique ID for the url generated by the function uniqid()
time_created - the time the link was created

 

Now have your links look something like this

www.domain.com/download.php?key=121w21e

 

When the user clicks on that link, you need to check the database to check if there is a link that exists with that key and is less than 5 minutes old.

 

Hopefully you get the idea. Just let me know if you need more explaining on something.

 

using db is much complicated

i think session can do that

 

something like set an index for session that will contain the time etc..

then once he click the lick pass it to other page that will check if the session is set and its within the tme then if its ok redirect them on the right path

 

 

Link to comment
Share on other sites

like above, create a download links table, then create a cronjob, change the download link every 5 minutes, or change ti automatically when they download and update the sql table and rename the file, boom simple :).

what if i access the page during my first minute and it change the link  ???

Link to comment
Share on other sites

So basically you want help figuring out how to make the links expire?

 

Make a table in the database like this

 

TABLE links
-----------
linkID - Auto-increment, primary key
key - this will be a unique ID for the url generated by the function uniqid()
time_created - the time the link was created

 

Now have your links look something like this

www.domain.com/download.php?key=121w21e

 

When the user clicks on that link, you need to check the database to check if there is a link that exists with that key and is less than 5 minutes old.

 

Hopefully you get the idea. Just let me know if you need more explaining on something.

 

using db is much complicated

i think session can do that

 

something like set an index for session that will contain the time etc..

then once he click the lick pass it to other page that will check if the session is set and its within the tme then if its ok redirect them on the right path

 

 

 

don't really like your algorithm, I think my way was more polished idea of doing it.

Link to comment
Share on other sites

like above, create a download links table, then create a cronjob, change the download link every 5 minutes, or change ti automatically when they download and update the sql table and rename the file, boom simple :).

what if i access the page during my first minute and it change the link  ???

 

you can put a start time in the db using the time(), then just subtract 5 minutes  from the current db time and check if its greater or less then the last 5 minutes, if it was then rename it, pretty simple...  shit you don't even have to do that, just let the cron job do its job..and password protect the directory..

Link to comment
Share on other sites

The reason I was avoiding sessions was that if they closed the browser, the session would be lost and there goes the download link. I guess they could set a cookie, although I'm not quite sure how secure that would be.

 

like above, create a download links table, then create a cronjob, change the download link every 5 minutes, or change ti automatically when they download and update the sql table and rename the file, boom simple Smiley.

 

Why change the download link? Just have the link become inactive after 5 minutes, no need to change it. Then the cron job can come through and delete all the entries that are 5 minutes+ old. They wouldn't even have to run the cron every 5 minutes, they could code the page to just give an error if it is more than 5 minutes old.

Link to comment
Share on other sites

like above, create a download links table, then create a cronjob, change the download link every 5 minutes, or change ti automatically when they download and update the sql table and rename the file, boom simple :).

what if i access the page during my first minute and it change the link  ???

 

you can put a start time in the db using the time(), then just subtract 5 minutes  from the current db time and check if its greater or less then the last 5 minutes, if it was then rename it, pretty simple...  shit you don't even have to do that, just let the cron job do its job..and password protect the directory..

 

dont act like you always have good idea ??? this is forum men all  idea  is welcome

i remember when thorpe comment on my answer and i just said im not gonna do that but i did i use thorpes idea on one of my validation

;)

Link to comment
Share on other sites

Well I got my cron job knowledge down...but the database thing is confusing me...

 

pocobueno said that it would delete whatever is 5 minutes old from the database, which I good, but how would I put new links back in for the same files?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.