#!/usr/bin/php userid); if($oUser->isMaintainer()) warnMaintainer($oUser->sEmail); elseif(!hasDataAssociated($oRow->userid)) warnUser($oUser->sEmail); } $hSevenMonth = inactiveSince(7); while($oRow = mysql_fetch_object($hSevenMonth)) { $oUser = new User($oRow->userid); if($oUser->isMaintainer()) deleteMaintainer($oRow->userid); elseif(!hasDataAssociated($oRow->userid)) deleteUser($oRow->userid); } function inactiveSince($iMonths) { $sQuery = "SELECT userid FROM user_list WHERE DATE_SUB(CURDATE(),INTERVAL $iMonths MONTH) >= stamp"; $hResult = query_appdb($sQuery); return $hResult; } function hasDataAssociated($iUserId) { $sQuery = "SELECT * FROM appComments WHERE userId = $iUserId"; $hResult = query_appdb($sQuery); if(mysql_num_rows($hResult)) return true; $sQuery = "SELECT * FROM appDataQueue WHERE userId = $iUserId"; $hResult = query_appdb($sQuery); if(mysql_num_rows($hResult)) return true; $sQuery = "SELECT * FROM appMaintainerQueue WHERE userId = $iUserId"; $hResult = query_appdb($sQuery); if(mysql_num_rows($hResult)) return true; $sQuery = "SELECT * FROM appVotes WHERE userId = $iUserId"; $hResult = query_appdb($sQuery); if(mysql_num_rows($hResult)) return true; return false; } function deleteUser($iUserId) { $oUser = new User($iUserId); warnUserDeleted($oUser->sEmail); echo "user ".$oUser->sEmail." deleted.\n"; $sQuery = "DELETE FROM user_list WHERE userid = $iUserId"; $hResult = query_appdb($sQuery); $sQuery = "DELETE FROM user_prefs WHERE userid = $iUserId"; $hResult = query_appdb($sQuery); } function deleteMaintainer($iUserId) { $oUser = new User($iUserId); $sQuery = "DELETE FROM appMaintainers WHERE userId = $iUserId"; $hResult = query_appdb($sQuery); warnMaintainerDeleted($oUser->sEmail); echo "user ".$oUser->sEmail." is not a maintainer anymore.\n"; } function warnUser($sEmail) { $sSubject = "Warning: inactivity detected"; $sMsg = "You didn't log in in the past six month to the AppDB.\r\n"; $sMsg .= "Please log in or your account will automatically be deleted in one month.\r\n"; mail_appdb($sEmail, $sSubject, $sMsg); } function warnMaintainer($sEmail) { $sSubject = "Warning: inactivity detected"; $sMsg = "You didn't log in in the past six month to the AppDB.\r\n"; $sMsg .= "As a maintainer we would be pleased to see you once in a while.\r\n"; $sMsg .= "Please log in or you will lose your maintainer's abilities in one month.\r\n"; mail_appdb($sEmail, $sSubject, $sMsg); } function warnUserDeleted($sEmail) { $sSubject = "Warning: account removed"; $sMsg = "You didn't log in in the past seven month to the AppDB.\r\n"; $sMsg .= "As you don't have any data associated to your account we have removed it.\r\n"; $sMsg .= "Please feel free to recreate an account anytime.\r\n"; mail_appdb($sEmail, $sSubject, $sMsg); } function warnMaintainerDeleted($sEmail) { $sSubject = "Warning: maintainer rights revoked\r\n"; $sMsg = "You didn't log in in the past seven month to the AppDB.\r\n"; $sMsg .= "As a result, you are not a maintainer anymore.\r\n"; $sMsg .= "Please feel free to enroll again as a maintainer anytime.\r\n"; mail_appdb($sEmail, $sSubject, $sMsg); } ?>