+/**
+ * @brief Expire and remove user entries
+ */
+function cron_expire_and_remove_users() {
+ // expire any expired accounts
+ q("UPDATE user SET `account_expired` = 1 where `account_expired` = 0
+ AND `account_expires_on` != '0000-00-00 00:00:00'
+ AND `account_expires_on` < UTC_TIMESTAMP() ");
+
+ // delete user and contact records for recently removed accounts
+ $r = q("SELECT * FROM `user` WHERE `account_removed` AND `account_expires_on` < UTC_TIMESTAMP() - INTERVAL 3 DAY");
+ if ($r) {
+ foreach($r as $user) {
+ q("DELETE FROM `contact` WHERE `uid` = %d", intval($user['uid']));
+ q("DELETE FROM `user` WHERE `uid` = %d", intval($user['uid']));
+ }
+ }
+}
+