Refactor some code into a function to clean up the cleanup script
This commit is contained in:
@@ -9,23 +9,44 @@ require("path.php");
|
|||||||
require(BASE."include/incl.php");
|
require(BASE."include/incl.php");
|
||||||
require_once(BASE."include/mail.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
|
* Warn users that have been inactive for some number of months
|
||||||
* If it has been some period of time since the user was warned
|
* 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
|
* the user is deleted if they don't have any pending appdb data
|
||||||
*/
|
*/
|
||||||
|
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)
|
|
||||||
{
|
{
|
||||||
|
$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))
|
while($oRow = mysql_fetch_object($hUsersToWarn))
|
||||||
{
|
{
|
||||||
$oUser = new User($oRow->userid);
|
$oUser = new User($oRow->userid);
|
||||||
@@ -41,12 +62,12 @@ if($hUsersToWarn)
|
|||||||
$usersUnwarnedWithData++;
|
$usersUnwarnedWithData++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* warned >= 1 month ago */
|
/* warned >= 1 month ago */
|
||||||
$hUsersToDelete = warnedSince(1);
|
$hUsersToDelete = warnedSince(1);
|
||||||
if($hUsersToDelete)
|
if($hUsersToDelete)
|
||||||
{
|
{
|
||||||
while($oRow = mysql_fetch_object($hUsersToDelete))
|
while($oRow = mysql_fetch_object($hUsersToDelete))
|
||||||
{
|
{
|
||||||
$oUser = new User($oRow->userid);
|
$oUser = new User($oRow->userid);
|
||||||
@@ -65,25 +86,11 @@ if($hUsersToDelete)
|
|||||||
$usersWithData++;
|
$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 */
|
/* Users that are unwarned and inactive since $iMonths */
|
||||||
function unwarnedAndInactiveSince($iMonths)
|
function unwarnedAndInactiveSince($iMonths)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user