Refactor some code into a function to clean up the cleanup script

This commit is contained in:
Chris Morgan
2007-05-26 04:02:24 +00:00
committed by WineHQ
parent f27a2d8f7d
commit 4b61351551

View File

@@ -9,23 +9,44 @@ require("path.php");
require(BASE."include/incl.php");
require_once(BASE."include/mail.php");
inactiveUserCheck();
/* check to see if there are orphaned versions in the database */
orphanVersionCheck();
/* check and purge any orphaned messages stuck in sessionMessages table */
orphanSessionMessagesCheck();
/* check and purge any expired sessions from the session_list table */
orphanSessionListCheck();
/* report error log entries to admins and flush the error log after doing so */
reportErrorLogEntries();
/* remove screenshots that are missing their screenshot and thumbnail files */
removeScreenshotsWithMissingFiles();
/*
* Warn users that have been inactive for some number of months
* If it has been some period of time since the user was warned
* the user is deleted if they don't have any pending appdb data
*/
$usersWarned = 0;
$usersUnwarnedWithData = 0; /* users we would normally warn but who have data */
$usersDeleted = 0;
$usersWithData = 0; /* users marked for deletion that have data */
notifyAdminsOfCleanupStart();
/* users inactive for 6 months that haven't been warned already */
$hUsersToWarn = unwarnedAndInactiveSince(6);
if($hUsersToWarn)
function inactiveUserCheck()
{
$usersWarned = 0;
$usersUnwarnedWithData = 0; /* users we would normally warn but who have data */
$usersDeleted = 0;
$usersWithData = 0; /* users marked for deletion that have data */
notifyAdminsOfCleanupStart();
/* users inactive for 6 months that haven't been warned already */
$hUsersToWarn = unwarnedAndInactiveSince(6);
if($hUsersToWarn)
{
while($oRow = mysql_fetch_object($hUsersToWarn))
{
$oUser = new User($oRow->userid);
@@ -41,12 +62,12 @@ if($hUsersToWarn)
$usersUnwarnedWithData++;
}
}
}
}
/* warned >= 1 month ago */
$hUsersToDelete = warnedSince(1);
if($hUsersToDelete)
{
/* warned >= 1 month ago */
$hUsersToDelete = warnedSince(1);
if($hUsersToDelete)
{
while($oRow = mysql_fetch_object($hUsersToDelete))
{
$oUser = new User($oRow->userid);
@@ -65,25 +86,11 @@ if($hUsersToDelete)
$usersWithData++;
}
}
}
notifyAdminsOfCleanupExecution($usersWarned, $usersUnwarnedWithData, $usersDeleted, $usersWithData);
}
notifyAdminsOfCleanupExecution($usersWarned, $usersUnwarnedWithData, $usersDeleted, $usersWithData);
/* check to see if there are orphaned versions in the database */
orphanVersionCheck();
/* check and purge any orphaned messages stuck in sessionMessages table */
orphanSessionMessagesCheck();
/* check and purge any expired sessions from the session_list table */
orphanSessionListCheck();
/* report error log entries to admins and flush the error log after doing so */
reportErrorLogEntries();
/* remove screenshots that are missing their screenshot and thumbnail files */
removeScreenshotsWithMissingFiles();
/* Users that are unwarned and inactive since $iMonths */
function unwarnedAndInactiveSince($iMonths)
{