Added checkinactiveusers.php script
This script checks for inactive users and lists them.
This commit is contained in:
parent
ed41012109
commit
1ceaae308f
@ -402,6 +402,14 @@ if (!class_exists('PWSdb'))
|
|||||||
|
|
||||||
return $sth->fetchAll();
|
return $sth->fetchAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getInactiveUsers($inactiveInterval)
|
||||||
|
{
|
||||||
|
$sth = $this->prepare('SELECT id, username, lastlogin, administrator FROM users WHERE datetime(lastlogin, ?) < datetime(\'now\')');
|
||||||
|
$sth->execute(array($inactiveInterval));
|
||||||
|
|
||||||
|
return $sth->fetchAll();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
17
scripts/checkinactiveusers.php
Normal file
17
scripts/checkinactiveusers.php
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<?php
|
||||||
|
// Check for inactive users
|
||||||
|
|
||||||
|
|
||||||
|
// OPTIONS
|
||||||
|
$webDir = '/var/www/localhost/htdocs/passwordstore';
|
||||||
|
|
||||||
|
require_once $webDir . '/config.php';
|
||||||
|
require_once $webDir . '/class.db.php';
|
||||||
|
|
||||||
|
$users = pwsdbh($dbDSN)->getInactiveUsers($userInactiveTime);
|
||||||
|
|
||||||
|
foreach ($users as $user)
|
||||||
|
{
|
||||||
|
printf("User %s is inactive since %s%s\n", $user['username'], $user['lastlogin'], ($user['administrator'] == 1) ? ' (this user is an administrator)' : '');
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user