Jump to content

Temporary Link Script


joshedgar

Recommended Posts

Hi guys,

 

Does anyone know how to make a PHP script to generate temporary download links that expire after 10 minutes?

And the temp link is generated at a PHP page which after 10 seconds redirects to their requested download?

I can use PHP and Htaccess for this.

 

This is what I want:

 

The user wants to download a file. So the link goes to say:

http://www.my-website.com/download.php?file=video.mp4

 

Then at that script, I want it to wait 10 seconds while they are looking at an advertisement, and then during that ten seconds, it should generate a random MD5 code, such as:

782d1a1a7a0a34c39995e1fa95efdbf5

 

It then passes this to a temporary download link on my server:

http://www.my-website.com/download/782d1a1a7a0a34c39995e1fa95efdbf5/videos/video.mp4

 

Which is a cover-up for the REAL file URL, which is:

http://www.my-website.com/files/videos/video.mp4

 

However, after about 10 minutes that temporary link expires and they have to go back to download.php for it to generate them a new code, if they want to download the file again.

E.g. I want to protect my files against leeching with using my own script, without using Lix.in or a Frame or anything.

 

Is there a way to do this?

 

Thanks!

Link to comment
Share on other sites

have a MySQL database that have 3 fields

file, hash, timestamp

 

if the timestamp is greater than the time+(10*60*60) then delete the records

 

now on a php page have the link something like ?file=782d1a1a7a0a34c39995e1fa95efdbf5

 

Now the 782d1a1a7a0a34c39995e1fa95efdbf5 is NOT the filename hash its something like md5(time().$filename) this is stored in the database under hash and the file name in the file field..

 

now when someone clicks the link ?file=782d1a1a7a0a34c39995e1fa95efdbf5

look up in the database to find hash=$_GET['file'], and pull the filename

 

now use readfile to pull that data, search form for forced downloads

 

i hope that makes sense

Link to comment
Share on other sites

I think I understand, but, I'd rather just keep it simple like having my links on the page be "download.php?file=videos/video.mp4".

My latest attempt was doing md5(rand,1) or something like that, I read it in a book. Then I was going to do some stuff in .htaccess to make that work but I realized that wouldn't terminate the links properly.

 

Basically what I want to do is something like this:

http://tanksoftware.com/tutes/leechprotection.html

 

But I don't understand all that, or how I'm going to start the functions properly with the current $_GET variables i have.

Thank you

Link to comment
Share on other sites

Just to clarify, the above code currently takes

http://www.pspstop.net/vip.php?path=music&filename=greenday.rar

And turns it into

http://www.pspstop-vip.info/vip_files/music/greenday.rar

 

I just want to have temporary links so they dont actually see that direct link, but a randomly generated temporary one.

 

<?php
// PSPStop Anti-Leech Script by Josh Edgar
$source = $_GET['source'];
$parseURL = "/";
$pspstopURL = "http://www.pspstop-vip.info/vip_files"; // Do not include a slash after .info or after VIP dir name
$retrieveStream = $parseURL.$_GET['path'].$parseURL.$_GET['filename'];
$retrieveType = $_GET['cat'];
$retrieveFile = $_GET['filename'];
$fullDirectStream = $pspstopURL.$parseURL.$_GET[path].$parseURL.$_GET[filename];
$fullRecordStream = $_GET[path].$parseURL.$_GET[filename];
$vipStream = "http://www.pspstop.net/vip.php";
$startVars = "?";
$splitVars = "&";
$getRefURL = $_GET['ref'];

/* Write info to a log */

// Open the file for writing.

$theFile = "LOGS/vip_log.html";
$fh = fopen($theFile, 'a') or die("Failed to open file for writing.");

// Preparing the string data

// IP ADDRESS
$ipdomain = GetHostByName($REMOTE_ADDR);

// Compiling the string data.

$string1 = "\n<font face='Verdana' size='2'><a href='http://whois-search.com/whois/" . $ipdomain . "'><b>" . $ipdomain . "</b></a>: ";
$string2 = $fullRecordStream . "<BR></font>";

$stringData = $string1.$string2;

// Write the string data to the file!

fwrite($fh, $stringData);
fclose($fh);

?>

<meta http-equiv="Refresh" content="0; URL=<?php echo $pspstopURL.$parseURL.$_GET[path].$parseURL.$_GET[filename]; ?>" />

<html>
<head>

<script language="JavaScript" type="text/javascript">
<!--
var sec = 01;   // set the seconds
var min = 00;   // set the minutes

function countDown() {
   sec--;
  if (sec == -01) {
   sec = 59;
   min = min - 1; }
  else {
   min = min; }

if (sec<=9) { sec = "" + sec; }

  time = (min<=9 ? "" + sec : sec) + "";

if (document.getElementById) { document.getElementById('theTime').innerHTML = time; }

SD=window.setTimeout("countDown();", 1000);
if (min == '00' && sec == '00') { sec = "00"; window.clearTimeout(SD); }
}
window.onload = countDown;
// -->
</script>

<style type="text/css">
<!--
.timeClass {
  font-family:verdana;
  font-weight:bold;
  font-size:10pt;
  }
-->
</style>

<title>PSPStop.net - Downloading: <?php echo $retrieveFile; ?></title>
<style type="text/css">
td.maina {
background: url('http://www.pspstop.net/Themes/PSPTheme/images/head_bg.gif') repeat-x;
height: 110px;
width: 30%;
}
td.mainb {
background: url('http://www.pspstop.net/Themes/PSPTheme/images/head_bg.gif') repeat-x;
height: 110px;
width: 70%;
}
</style>
</head>

<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" bgcolor="#313233">

<table width="100%" align="center" border="0" padding="0" cellspacing="0" cellpadding="0">
<tr>
	<td class="maina">
<img src="http://www.pspstop.net/Themes/PSPTheme/images/logo.gif" border="0" alt="PSPSTOP.NET" />
	</td>

	<td class="mainb" valign="center">
<CENTER><font face="Verdana" size="2" color="#FFFFFF">

Your file should begin immediately, VIP member...<br>
If it does not, please <a href="<?php echo $pspstopURL.$parseURL.$_GET[path].$parseURL.$_GET[filename]; ?>">click here</a>

</font></CENTER>
	</td>

</tr>
</table><br /><br />
<CENTER>

</body>
</html>

 

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.