This mod actually works properly to my tracker. My VPS runs PHP 5.2 but I think that will not be problems with the 5.3 and 5.4 versions.
The members that are inactive for over 90 days will be disabled, but before that happen they will receive 3 warning emails at 7 days interval.
These values can easily be changed in the Config section to fit your needs.
Run into database:
Add into backend/cleanup.php the next code:
The members that are inactive for over 90 days will be disabled, but before that happen they will receive 3 warning emails at 7 days interval.
These values can easily be changed in the Config section to fit your needs.
Run into database:
ALTER TABLE `users` ADD `averted1` enum('yes','no') NOT NULL default 'no';
ALTER TABLE `users` ADD `averted2` enum('yes','no') NOT NULL default 'no';
ALTER TABLE `users` ADD `averted3` enum('yes','no') NOT NULL default 'no';Add into backend/cleanup.php the next code:
//===| Start Disable Inactive Accounts |===//
//===| Config
$dw1 = 69; //===| Days until the first warning: three weeks to finish
$dw2 = 76; //===| Days until the second warning: two weeks to finish
$dw3 = 83; //===| Days until the third warning: one week to finish
$dtd = 90; //===| Days until the inactive accounts are disabled
$warning1 = sqlesc(get_date_time(gmtime() - ($dw1 * 86400)));
$warning2 = sqlesc(get_date_time(gmtime() - ($dw2 * 86400)));
$warning3 = sqlesc(get_date_time(gmtime() - ($dw3 * 86400)));
$disabled = sqlesc(get_date_time(gmtime() - ($dtd * 86400)));
//===| Reset emails averted if the user has been logged
$res0 = SQL_Query_exec("SELECT id, averted1, averted2, averted3 FROM users WHERE enabled = 'yes' AND averted1 = 'yes' || averted2 = 'yes' || averted3 = 'yes' AND last_access > $warning1");
while ($arr0 = mysql_fetch_assoc($res0))
{
SQL_Query_exec("UPDATE users SET averted1 = 'no', averted2 = 'no', averted3 = 'no' WHERE id = $arr0[id]");
}
//===| First warning
$res1 = SQL_Query_exec("SELECT id, username, email, averted1 FROM users WHERE enabled = 'yes' AND averted1 = 'no' AND last_access > $warning2 AND last_access < $warning1");
while ($arr1 = mysql_fetch_assoc($res1))
{
// Send first email
$subject = "Warning for inactivity";
$body = "You have received this email for the following reason:n------------------------------nYour account '".$arr1["username"]."' to ".$site_config['SITENAME']." has been marked as inactive and will be disabled after a few days!nTo delete this entry is enough to make us a visit and say hello: ".$site_config['SITEURL']."n------------------------------nnRegards, ".$site_config['SITENAME']." Staff";
sendmail($arr1["email"], "$subject", "$body", "From $site_config[SITEEMAIL]", "-f$site_config[SITEEMAIL]");
SQL_Query_exec("UPDATE users SET averted1 = 'yes' WHERE id = $arr1[id]");
}
//===| Second warning
$res2 = SQL_Query_exec("SELECT id, username, email, averted2 FROM users WHERE enabled = 'yes' AND averted2 = 'no' AND last_access > $warning3 AND last_access < $warning2");
while ($arr2 = mysql_fetch_assoc($res2))
{
// Send second email
$subject = "Warning for inactivity";
$body = "You have received this email for the following reason:n------------------------------nYour account '".$arr2["username"]."' to ".$site_config['SITENAME']." has been marked as inactive and will be disabled after a few days!nTo delete this entry is enough to make us a visit and say hello: ".$site_config['SITEURL']."n------------------------------nnRegards, ".$site_config['SITENAME']." Staff";
sendmail($arr2["email"], "$subject", "$body", "From $site_config[SITEEMAIL]", "-f$site_config[SITEEMAIL]");
SQL_Query_exec("UPDATE users SET averted2 = 'yes' WHERE id = $arr2[id]");
}
//===| Third Warning
$res3 = SQL_Query_exec("SELECT id, username, email, averted3 FROM users WHERE enabled = 'yes' AND averted3 = 'no' AND last_access > $disabled AND last_access < $warning3");
while ($arr3 = mysql_fetch_assoc($res3))
{
// Send third email
$subject = "Warning for inactivity";
$body = "You have received this email for the following reason:n------------------------------nYour account '".$arr3["username"]."' to ".$site_config['SITENAME']." has been marked as inactive and will be disabled after a few days!nTo delete this entry is enough to make us a visit and say hello: ".$site_config['SITEURL']."n------------------------------nnRegards, ".$site_config['SITENAME']." Staff";
sendmail($arr3["email"], "$subject", "$body", "From $site_config[SITEEMAIL]", "-f$site_config[SITEEMAIL]");
SQL_Query_exec("UPDATE users SET averted3 = 'yes' WHERE id = $arr3[id]");
}
//===| Disable accounts
$res4 = SQL_Query_exec("SELECT id, username, modcomment FROM users WHERE enabled = 'yes' AND last_access != '0000-00-00 00:00:00' AND last_access < $disabled");
while ($arr4 = mysql_fetch_assoc($res4))
{
$modcomment = htmlspecialchars($arr4["modcomment"]);
$modcomment = gmdate("d-M-Y") . " - Disabled for inactivity by Systemn". $modcomment;
$modcom = sqlesc($modcomment);
SQL_Query_exec("UPDATE users SET enabled = 'no', modcomment = $modcom WHERE id = $arr4[id]");
write_log("<a href=account-details.php?id=$arr4[id]><b>$arr4[username]</b></a> account has been disabled for inactivity by System");
}
//===| End Disable Inactive Accounts |===//
