From a85006627140301d9e63c1f192965b9e3f19d2d8 Mon Sep 17 00:00:00 2001 From: "Gergely Polonkai (W00d5t0ck)" Date: Tue, 22 Feb 2011 15:36:20 +0100 Subject: [PATCH] Added the checknonusedpasswords.php script This script checks for passwords that were not accessed for a while. --- class.db.php | 8 ++++++++ scripts/checknonusedpasswords.php | 24 ++++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 scripts/checknonusedpasswords.php diff --git a/class.db.php b/class.db.php index b63b243..6b062cf 100644 --- a/class.db.php +++ b/class.db.php @@ -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(); + } } } diff --git a/scripts/checknonusedpasswords.php b/scripts/checknonusedpasswords.php new file mode 100644 index 0000000..a9d8ab7 --- /dev/null +++ b/scripts/checknonusedpasswords.php @@ -0,0 +1,24 @@ +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']); + } +} +