Page 1 of 1

Delete after x download time

PostPosted: Sat Feb 26, 2011 9:53 am
by coolguy
Would it be possible to modify the script to where the file would be deleted after a x amount of days no matter if the file/image has been downloaded or not?
ps great script by the way

Re: Delete after x download time

PostPosted: Sat Feb 26, 2011 8:18 pm
by PeterS
Yes, that would be possible, however you would have to change the way DFH stores the file's data into the database. At the moment, DFH does not store when the file was first uploaded, but instead when it was last downloaded. The key factor here is to add the First Uploaded date attribute into the database and modifying the deleting script.

I'm glad you are liking DFH, however if you still require support on this issue, please PM me with the script's URL or include it in your next post.

Goodluck!

Re: Delete after x download time

PostPosted: Sat Feb 26, 2011 11:06 pm
by coolguy
As of now im playing around with the script on my localhost, but when i get it modified to my liking it will be more than likely uploaded to dizzyurl.com
Still cant figured out what files will need modified

Re: Delete after x download time

PostPosted: Sat Feb 26, 2011 11:18 pm
by PeterS
Thank you for confirming the script's url.

Okay, open ./upload.php and try to locate this line:
Code: Select all
fwrite($filelist, $rand2 ."|". basename($_FILES['upfile']['name']) ."|". $passkey ."|". $userip ."|". $time."|0|".$description."|".$passwerd."|".$cat."|".$_POST['pprotect']."|\n");


This is the part where PHP writes to the database.

Now you'll have to add the $time variable again at the end of the file.

Example:

Code: Select all
fwrite($filelist, $rand2 ."|". basename($_FILES['upfile']['name']) ."|". $passkey ."|". $userip ."|". $time."|0|".$description."|".$passwerd."|".$cat."|".$_POST['pprotect'] ."|". $time."|\n");


Now the first $time variable is assigned to the last time the file was downloaded, and now we'll assign the last $time variable as being the time it was originally first uploaded.

Now we want to modify the deleting script located in ./admin.php

Find:
Code: Select all
if ($filedata[4] < $deleteseconds) {


Replace with:
Code: Select all
if ($filedata[9] < $deleteseconds) {


In theory this should work and the script should now delete all files according to when they were last uploaded and not downloaded.

Re: Delete after x download time

PostPosted: Sun Feb 27, 2011 11:07 am
by coolguy
In theory i should be able to run http://localhost/dfh/admin.php?act=deloldfiles after the modification and all the files uploaded that are xx old will be destroyed?

in the settings.php i See
Delete files if not downloaded after this many days= and the default looks to be 30 days. with the above modification does this make this feature useless or will i be able to change that feature in the admin panel without issues

I would like files to be destroyed 4 days after the upload
THANKS for the help

Re: Delete after x download time

PostPosted: Sun Feb 27, 2011 11:19 am
by PeterS
Yes that is correct, and the 30 day value will not be useless, but very essential for the mod to function properly. Instead of the value being used to compare 30 days against the last downloaded variable, it will compare it against when the file was first uploaded.

No worries coolguy, it's what we are here for :).

Goodluck!

Re: Delete after x download time

PostPosted: Sun Feb 27, 2011 11:31 am
by SamEA
It wouldn't be a bad idea to add this in the mods section :D.