Updated daily.sh/daily.php to support removing users that have not logged in for X days - Radius only for now

This commit is contained in:
laf
2015-12-13 16:16:39 +00:00
parent dcf4d0f378
commit 58d585e6fe
2 changed files with 20 additions and 3 deletions

View File

@@ -30,7 +30,7 @@ Take a look at https://dev.mysql.com/doc/refman/5.6/en/innodb-buffer-pool.html f
The ' . $config['project_name'] . ' team.';
send_mail($config['alert']['default_mail'],$subject,$message,$html=false);
}
}
echo warn_innodb_buffer($innodb_buffer);
exit(2);
}
@@ -110,3 +110,19 @@ if ($options['f'] === 'device_perf') {
if ($options['f'] === 'notifications') {
include_once 'notifications.php';
}
if ($options['f'] === 'purgeusers') {
$purge = 0;
if (is_numeric($config['radius']['users_purge']) && $config['auth_mechanism'] === 'radius') {
$purge = $config['radius']['users_purge'];
}
if ($purge > 0) {
foreach (dbFetchRows("SELECT DISTINCT(`user`) FROM `authlog` WHERE `datetime` >= DATE_SUB(NOW(), INTERVAL ? DAY)", array($purge)) as $user) {
$users[] = $user['user'];
}
$del_users = '"'.implode('","',$users).'"';
if (dbDelete('users', "username NOT IN ($del_users)",array($del_users))) {
echo "Removed users that haven't logged in for $purge days";
}
}
}