![]() |
![]() |
![]() |
||||
Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact us. |
![]() ![]() |
|
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed. |
|
Thread Tools |
![]() |
#1 |
Confirmed User
Industry Role:
Join Date: Jul 2001
Location: Utopia
Posts: 6,479
|
php code snippet guru's, please ...
I have this to kill some older files, backups...
PHP Code:
Any idea how i can change this "kill all older than 7 days", into "kill all BUT the latest three" <- so, could be there's one in there that is weeks old, as long as no new ones appear I have had TM3 break and the kill older than x days backups. When we found out TM3 was broken, it had also killed all good backups already ![]() Anyone? We're going to cron this.
__________________
seks.ai for sale - ping me |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#2 |
Too lazy to set a custom title
Industry Role:
Join Date: Sep 2003
Posts: 22,651
|
can't you just change the > to <= and adjust the time?
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#3 |
Too lazy to set a custom title
Industry Role:
Join Date: Sep 2003
Posts: 22,651
|
btw i'm not a guru :D
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#4 |
Confirmed User
Industry Role:
Join Date: Jul 2001
Location: Utopia
Posts: 6,479
|
No, that is my point;-)
__________________
seks.ai for sale - ping me |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#5 |
Confirmed User
Industry Role:
Join Date: Jan 2009
Posts: 420
|
You could place the file modified times, and file paths in an array. Sort by file modified times, remove the 3 most recent from the array, and recursively remove the remainder of the files.
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#6 |
Confirmed User
Industry Role:
Join Date: Jan 2009
Posts: 420
|
Here you go. Hasn't been tested:
PHP Code:
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#7 |
Confirmed User
Join Date: May 2004
Location: SW Palm Bay, Florida
Posts: 1,323
|
One thing I noticed about all the code posted in this thread is that it will always delete every file, because $days isn't set anywhere, which means the conditional if(time() - filemtime($file)) > ($days *86400) is always gonna be true, because 0 times any number is always 0...
__________________
subarus. |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#8 | |
Confirmed User
Industry Role:
Join Date: Jan 2009
Posts: 420
|
Quote:
Good looking out though.. ![]() |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#9 |
ICQ:649699063
Industry Role:
Join Date: Mar 2003
Posts: 27,763
|
No idea. Good luck.
__________________
Send me an email: [email protected] |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#10 | |
Confirmed User
Industry Role:
Join Date: Jul 2001
Location: Utopia
Posts: 6,479
|
Quote:
//Remove the newest 3 files from the array Obviously we want to kill the oldest, not the newest, right? So how does that come about?
__________________
seks.ai for sale - ping me |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#11 | |
Confirmed User
Industry Role:
Join Date: Jan 2009
Posts: 420
|
Quote:
Does that make sense? |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#12 | |
Confirmed User
Industry Role:
Join Date: Jul 2001
Location: Utopia
Posts: 6,479
|
Quote:
__________________
seks.ai for sale - ping me |
|
![]() |
![]() ![]() ![]() ![]() ![]() |