simple code that renames the file to be downloaded each time someone downloads it.
example:
you download my file, it will be rename to smth different that way you cant access the file using that URL anymore
here is the code:
for some reasons the renaming part doesnt work.
any input would be greatly appreciated
as122223333443.txt = the new generated name is updated to this file that way the next person to download gets the right link.
Expand|Select|Wrap|Line Numbers
- <?php
- function renom($file1, $file2)
- {
- rename($file1, $file2);
- }
- function updateit()
- {
- $random_digit=rand(0000,9999);
- $random_link = $random_digit.".zip";
- $myFile = "as122223333443.txt";
- $fh = fopen($myFile, 'w') or die("can't open file");
- $stringData = $random_link;
- fwrite($fh, $stringData);
- fclose($fh);
- $file1 = $thelink;
- $file2 = $random_link;
- renom($file1,$file2);
- }
- function downloada()
- {
- $dlink = "as122223333443.txt";
- $fh = fopen($dlink, 'r');
- $thelink= fread($fh, 25);
- fclose($fh);
- echo "http://www.site.com/".$thelink;
- updateit();
- }