Added checkinactiveusers.php script

This script checks for inactive users and lists them.
This commit is contained in:
Gergely Polonkai (W00d5t0ck) 2011-02-22 15:15:46 +01:00
parent ed41012109
commit 1ceaae308f
2 changed files with 25 additions and 0 deletions

View File

@ -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();
}
} }
} }

View 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)' : '');
}