Added the checknonusedpasswords.php script

This script checks for passwords that were not accessed for a while.
This commit is contained in:
Gergely Polonkai (W00d5t0ck) 2011-02-22 15:36:20 +01:00
parent 1ceaae308f
commit a850066271
2 changed files with 32 additions and 0 deletions

View File

@ -410,6 +410,14 @@ if (!class_exists('PWSdb'))
return $sth->fetchAll();
}
function getInactivePasswords($inactiveInterval)
{
$sth = $this->prepare('SELECT id, short, long, username, groups, lastaccess FROM passwords WHERE datetime(lastaccess, ?) < datetime(\'now\')');
$sth->execute(array($inactiveInterval));
return $sth->fetchAll();
}
}
}

View File

@ -0,0 +1,24 @@
<?php
// Check for inactive users
// OPTIONS
$webDir = '/var/www/localhost/htdocs/passwordstore';
require_once $webDir . '/config.php';
require_once $webDir . '/class.db.php';
$passwords = pwsdbh($dbDSN)->getInactivePasswords($passwordInactiveTime);
foreach ($passwords as $password)
{
if ($password['username'] == '')
{
printf("The password for %s (%s) was not accessed since %s\n", $password['short'], $password['long'], $password['lastaccess']);
}
else
{
printf("The password for %s on %s (%s) was not accessed since %s\n", $password['username'], $password['short'], $password['long'], $password['lastaccess']);
}
}