appdb/cron cleanup.php
WineHQ
wineowner at wine.codeweavers.com
Fri May 25 23:02:24 CDT 2007
ChangeSet ID: 31137
CVSROOT: /opt/cvs-commit
Module name: appdb
Changes by: wineowner at winehq.org 2007/05/25 23:02:24
Modified files:
cron : cleanup.php
Log message:
Chris Morgan <cmorgan at alum.wpi.edu>
Refactor some code into a function to clean up the cleanup script
Patch: http://cvs.winehq.org/patch.py?id=31137
Old revision New revision Changes Path
1.33 1.34 +64 -57 appdb/cron/cleanup.php
Index: appdb/cron/cleanup.php
diff -u -p appdb/cron/cleanup.php:1.33 appdb/cron/cleanup.php:1.34
--- appdb/cron/cleanup.php:1.33 26 May 2007 4: 2:24 -0000
+++ appdb/cron/cleanup.php 26 May 2007 4: 2:24 -0000
@@ -9,80 +9,87 @@ 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);
+ $oUser = new User($oRow->userid);
- /* if we get back true the user was warned and flagged as being warned */
- /* if we get back false we didn't warn the user and didn't flag the user as warned */
- /* because they have data associated with their account */
- if($oUser->warnForInactivity())
- {
- $usersWarned++;
- } else
- {
- $usersUnwarnedWithData++;
- }
+ /* if we get back true the user was warned and flagged as being warned */
+ /* if we get back false we didn't warn the user and didn't flag the user as warned */
+ /* because they have data associated with their account */
+ if($oUser->warnForInactivity())
+ {
+ $usersWarned++;
+ } else
+ {
+ $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);
- if(!$oUser->hasDataAssociated())
+ $oUser = new User($oRow->userid);
+ if(!$oUser->hasDataAssociated())
+ {
+ $usersDeleted++;
+ deleteUser($oRow->userid);
+ } else
+ {
+ /* is the user a maintainer? if so remove their maintainer privileges */
+ if($oUser->isMaintainer())
{
- $usersDeleted++;
- deleteUser($oRow->userid);
- } else
- {
- /* is the user a maintainer? if so remove their maintainer privileges */
- if($oUser->isMaintainer())
- {
- Maintainer::deleteMaintainer($oUser);
- }
-
- $usersWithData++;
+ Maintainer::deleteMaintainer($oUser);
}
- }
-}
-
-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();
+ $usersWithData++;
+ }
+ }
+ }
-/* remove screenshots that are missing their screenshot and thumbnail files */
-removeScreenshotsWithMissingFiles();
+ notifyAdminsOfCleanupExecution($usersWarned, $usersUnwarnedWithData, $usersDeleted, $usersWithData);
+}
/* Users that are unwarned and inactive since $iMonths */
function unwarnedAndInactiveSince($iMonths)
More information about the wine-cvs
mailing list