Click to See Complete Forum and Search --> : Inactive Members with localtime


druss
01-07-2003, 12:59 AM
i have made a script that removes any inactive members that i may have in my database, the script i use is below.


open("users","$datadir/members.db");
@users = <users>;
close("users");

$member_active = "0";
$member_inactive = "0";

$time = time();
@array = split(/ +/ , localtime($time));

foreach $slot (@users) {
@info = split (/\s*\|\s*/,$slot);
if($info[7] =~ m"$array[1]") { $member_active++; }
else { $member_inactive++; }
}


the problem is this. if someone joins on the 31'st, they will be deleted the next day because the months are diffirent and thats all that my script recognises. What i want is to delete ppl once 3 months is passed, it dosent have to be accurate so long as 3 months have passed and since the localtime method displays months as text i cannot find a way to enforce this.

Can you please help me. Thanks
Goran

jeffmott
01-07-2003, 03:35 AM
You can measure their time of activity is seconds with time. Take 3 months (~30 days per month).

Seconds = 60 seconds in a minute * 60 minutes in an hour * 24 hours in a day * 30 days * 3 months = 7776000

So you would say (generalized):

if (time - $users_last_active_time > 7776000) {
&nbsp; ++$inactive;
} else {
&nbsp; ++$active;
}