Delete after x download time

All support enquiries for DFH go in here...

Delete after x download time

Postby coolguy » Sat Feb 26, 2011 9:53 am

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
coolguy
Standard Member
 
Posts: 27
Joined: Sat Feb 26, 2011 9:50 am

Re: Delete after x download time

Postby PeterS » Sat Feb 26, 2011 8:18 pm

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!
PeterS
Global Moderator
 
Posts: 159
Joined: Mon Feb 21, 2011 4:58 am

Re: Delete after x download time

Postby coolguy » Sat Feb 26, 2011 11:06 pm

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
coolguy
Standard Member
 
Posts: 27
Joined: Sat Feb 26, 2011 9:50 am

Re: Delete after x download time

Postby PeterS » Sat Feb 26, 2011 11:18 pm

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.
PeterS
Global Moderator
 
Posts: 159
Joined: Mon Feb 21, 2011 4:58 am

Re: Delete after x download time

Postby coolguy » Sun Feb 27, 2011 11:07 am

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
coolguy
Standard Member
 
Posts: 27
Joined: Sat Feb 26, 2011 9:50 am

Re: Delete after x download time

Postby PeterS » Sun Feb 27, 2011 11:19 am

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!
PeterS
Global Moderator
 
Posts: 159
Joined: Mon Feb 21, 2011 4:58 am

Re: Delete after x download time

Postby SamEA » Sun Feb 27, 2011 11:31 am

It wouldn't be a bad idea to add this in the mods section :D.
SamEA,
DaddyScripts' Admin & Developer.

Require a PHP or general IT freelancer? Don't hesitate to PM me.
User avatar
SamEA
Site Admin
 
Posts: 1165
Joined: Sat Feb 19, 2011 7:51 pm


Return to Daddy's File Host v1.X

Who is online

Users browsing this forum: No registered users and 25 guests

cron