From 1ceaae308fd4db2c26cc09574fb3709469fbaf44 Mon Sep 17 00:00:00 2001 From: "Gergely Polonkai (W00d5t0ck)" Date: Tue, 22 Feb 2011 15:15:46 +0100 Subject: [PATCH] Added checkinactiveusers.php script This script checks for inactive users and lists them. --- class.db.php | 8 ++++++++ scripts/checkinactiveusers.php | 17 +++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 scripts/checkinactiveusers.php diff --git a/class.db.php b/class.db.php index 79a259d..b63b243 100644 --- a/class.db.php +++ b/class.db.php @@ -402,6 +402,14 @@ if (!class_exists('PWSdb')) 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(); + } } } diff --git a/scripts/checkinactiveusers.php b/scripts/checkinactiveusers.php new file mode 100644 index 0000000..7cef676 --- /dev/null +++ b/scripts/checkinactiveusers.php @@ -0,0 +1,17 @@ +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)' : ''); +} +