示例#1
0
文件: index.php 项目: jdegges/pipweb
            $CurrentFileHandlerMethod = $Files[$j]["HandlerMethod"];
            $CurrentFileHasThumbnail = $Files[$j]["ThumbnailPresent"];
            // Collect the item history
            $aItemHistory[] = $FileCounter;
            // Check to see if the current file is selected
            $Highlighted = false;
            if (($Config->FileID == $FileCounter || $FileCounter > $Config->FileID && $FilesToDisplay < $Config->FilesPerPage && $Config->FileID > 0) && $FilesToDisplay > 0) {
                $FileDisplay .= FormatDisplayedItem($FileCounter, $CurrentFileName, $CurrentFileSize, $CurrentFileHandlerMethod, $Params, $Config);
                $FilesToDisplay = $FilesToDisplay - 1;
                $Highlighted = true;
            }
            $FileList .= FormatListItem($FileCounter, $CurrentFileName, $CurrentPath, $CurrentFileSize, $CurrentFileDate, $Highlighted, $Params, $CurrentFileHasThumbnail, $Config);
            // Check for a "save as" request
            if ($Config->GetFileID == $FileCounter) {
                $FolderPath = substr($Config->CurrentBrowsingDirectory, strlen($Config->CurrentWorkingDirectory) + 1, strlen($Config->CurrentBrowsingDirectory) - strlen($Config->CurrentWorkingDirectory) + 1);
                SaveAsDialogue($FolderPath, $CurrentFileName);
            }
        }
        $FileList .= "</ul>\r\n";
    }
}
if ($FileDisplay == "" && $Config->FileID != 0) {
    $FileDisplay = "<div class=\"Introduction\">The requested file could not be found.</div>\r\n";
}
$FileDisplay = "<form name=\"frmLinkContainer\" action=\"\">" . $FileDisplay . "</form>\r\n";
// Build the folder listing
if ($Config->BrowseSubFolders && (count($FolderCollection) > 0 || count($Config->aFolderID) > 0)) {
    $Params->Remove("fid");
    $FileList .= "<h2>Folders</h2>\r\n      <ul class=\"List Folders\">";
    // Display the updirectory link if necessary
    if (count($Config->aFolderID) > 0 && $Config->BrowseSubFolders) {
 function CleanupForm(&$Context)
 {
     $this->ValidActions = array("Cleanup", "CleanupUsers", "CleanupComments", "CleanupDiscussions", "PurgeDiscussions", "BackupDatabase");
     $this->Constructor($Context);
     $this->Name = "CleanupForm";
     if ($this->IsPostBack) {
         if ($this->PostBackAction == "CleanupUsers") {
             $Days = ForceIncomingInt("Days", 30);
             $InactiveUsers = $this->GetInactiveUsers($Days);
             if (count($InactiveUsers) > 0) {
                 // Wipe out category blocks
                 $s = $this->Context->ObjectFactory->NewContextObject($this->Context, "SqlBuilder");
                 $s->SetMainTable("CategoryBlock", "cb");
                 $s->AddWhere("UserID", "(" . implode(",", $InactiveUsers) . ")", "in", "and", "", 0);
                 $this->Context->Database->Delete($this->Context, $s, $this->Name, "Constructor", "An error occurred while attempting to remove user category blocks.");
                 // Wipe out clippings
                 $s->Clear();
                 $s->SetMainTable("Clipping", "c");
                 $s->AddWhere("UserID", "(" . implode(",", $InactiveUsers) . ")", "in", "and", "", 0);
                 $this->Context->Database->Delete($this->Context, $s, $this->Name, "Constructor", "An error occurred while attempting to remove user clippings.");
                 // Wipe out comment blocks
                 $s->Clear();
                 $s->SetMainTable("CommentBlock", "c");
                 $s->AddWhere("BlockingUserID", "(" . implode(",", $InactiveUsers) . ")", "in", "and", "", 0);
                 $this->Context->Database->Delete($this->Context, $s, $this->Name, "Constructor", "An error occurred while attempting to remove user comment blocks.");
                 // Wipe out the ip history
                 $s->Clear();
                 $s->SetMainTable("IpHistory", "I");
                 $s->AddWhere("UserID", "(" . implode(",", $InactiveUsers) . ")", "in", "and", "", 0);
                 $this->Context->Database->Delete($this->Context, $s, $this->Name, "Constructor", "An error occurred while attempting to remove user IP history.");
                 // Update any styles associated with this user to be system styles
                 $s->Clear();
                 $s->SetMainTable("Style", "s");
                 $s->AddFieldNameValue("AuthUserID", "0");
                 $s->AddWhere("AuthUserID", "(" . implode(",", $InactiveUsers) . ")", "in", "and", "", 0);
                 $this->Context->Database->Update($this->Context, $s, $this->Name, "Constructor", "An error occurred while attempting to remove user style relations.");
                 // Wipe out any user blocks
                 $s->Clear();
                 $s->SetMainTable("UserBlock", "ub");
                 $s->AddWhere("BlockingUserID", "(" . implode(",", $InactiveUsers) . ")", "in", "or", "", 0);
                 $s->AddWhere("BlockedUserID", "(" . implode(",", $InactiveUsers) . ")", "in", "or", "", 0);
                 $this->Context->Database->Delete($this->Context, $s, $this->Name, "Constructor", "An error occurred while attempting to remove user blocks.");
                 // Wipe out bookmarks
                 $s->Clear();
                 $s->SetMainTable("UserBookmark", "ub");
                 $s->AddWhere("UserID", "(" . implode(",", $InactiveUsers) . ")", "in", "and", "", 0);
                 $this->Context->Database->Delete($this->Context, $s, $this->Name, "Constructor", "An error occurred while attempting to remove user bookmarks.");
                 // Wipe out user discussion watch
                 $s->Clear();
                 $s->SetMainTable("UserDiscussionWatch", "udw");
                 $s->AddWhere("UserID", "(" . implode(",", $InactiveUsers) . ")", "in", "and", "", 0);
                 $this->Context->Database->Delete($this->Context, $s, $this->Name, "Constructor", "An error occurred while attempting to remove user discussion tracking data.");
                 // Wipe out role history
                 $s->Clear();
                 $s->SetMainTable("UserRoleHistory", "urh");
                 $s->AddWhere("UserID", "(" . implode(",", $InactiveUsers) . ")", "in", "and", "", 0);
                 $this->Context->Database->Delete($this->Context, $s, $this->Name, "Constructor", "An error occurred while attempting to remove user role history.");
                 // Wipe out saved searches
                 $s->Clear();
                 $s->SetMainTable("UserSearch", "us");
                 $s->AddWhere("UserID", "(" . implode(",", $InactiveUsers) . ")", "in", "and", "", 0);
                 $this->Context->Database->Delete($this->Context, $s, $this->Name, "Constructor", "An error occurred while attempting to remove user searches.");
                 // Delete the users
                 $s->Clear();
                 $s->SetMainTable("User", "u");
                 $s->AddWhere("UserID", "(" . implode(",", $InactiveUsers) . ")", "in", "and", "", 0);
                 $this->Context->Database->Delete($this->Context, $s, $this->Name, "Constructor", "An error occurred while attempting to remove the users.");
             }
             $this->NumberOfUsersRemoved = count($InactiveUsers);
             $this->PostBackValidated = 1;
         } elseif ($this->PostBackAction == "CleanupComments") {
             // First get all of the hidden comment ids
             $s = $this->Context->ObjectFactory->NewContextObject($this->Context, "SqlBuilder");
             $s->SetMainTable("Comment", "c");
             $s->AddWhere("Deleted", "1", "=", "and", "", 0);
             $s->AddWhere("Deleted", "1", "=", "or");
             $s->AddSelect("CommentID", "c");
             $Result = $this->Context->Database->Select($this->Context, $s, $this->Name, "Constructor", "An error occurred while attempting to retrieve hidden comments.");
             $HiddenCommentIDs = array();
             while ($Row = $this->Context->Database->GetRow($Result)) {
                 $HiddenCommentIDs[] = ForceInt($Row["CommentID"], 0);
             }
             $HiddenCommentIDs[] = 0;
             // Now remove comment blocks
             $s->Clear();
             $s->SetMainTable("CommentBlock", "cb");
             $s->AddWhere("BlockedCommentID", "(" . implode(",", $HiddenCommentIDs) . ")", "in", "and", "", 0);
             $this->Context->Database->Delete($this->Context, $s, $this->Name, "Constructor", "An error occurred while attempting to remove hidden comment blocks.");
             // Now remove the comments
             $s->Clear();
             $s->SetMainTable("Comment", "c");
             $s->AddWhere("Deleted", "1", "=", "and", "", 0);
             $s->AddWhere("Deleted", "1", "=", "or");
             $this->Context->Database->Delete($this->Context, $s, $this->Name, "Constructor", "An error occurred while attempting to remove hidden comments.");
             $this->PostBackValidated = 1;
         } elseif ($this->PostBackAction == "CleanupDiscussions") {
             // First get all of the hidden discussion ids
             $s = $this->Context->ObjectFactory->NewContextObject($this->Context, "SqlBuilder");
             $s->SetMainTable("Discussion", "d");
             $s->AddSelect("DiscussionID", "d");
             $s->AddWhere("Active", "0", "=", "and", "", 0);
             $s->AddWhere("Active", "0", "=", "or");
             $Result = $this->Context->Database->Select($this->Context, $s, $this->Name, "Constructor", "An error occurred while attempting to retrieve hidden discussions.");
             $HiddenDiscussionIDs = array();
             while ($Row = $this->Context->Database->GetRow($Result)) {
                 $HiddenDiscussionIDs[] = ForceInt($Row["DiscussionID"], 0);
             }
             $HiddenDiscussionIDs[] = 0;
             // Now remove comments associated with those discussions
             $s->Clear();
             $s->SetMainTable("Comment", "c");
             $s->AddWhere("DiscussionID", "(" . implode(",", $HiddenDiscussionIDs) . ")", "in", "and", "", 0);
             $this->Context->Database->Delete($this->Context, $s, $this->Name, "Constructor", "An error occurred while attempting to remove hidden discussion comments.");
             // Clean up the whisper tables
             $s->Clear();
             $s->SetMainTable("DiscussionUserWhisperFrom", "wf");
             $s->AddWhere("DiscussionID", "(" . implode(",", $HiddenDiscussionIDs) . ")", "in", "and", "", 0);
             $this->Context->Database->Delete($this->Context, $s, $this->Name, "Constructor", "An error occurred while attempting to remove hidden discussion whisper data.");
             $s->Clear();
             $s->SetMainTable("DiscussionUserWhisperTo", "wt");
             $s->AddWhere("DiscussionID", "(" . implode(",", $HiddenDiscussionIDs) . ")", "in", "and", "", 0);
             $this->Context->Database->Delete($this->Context, $s, $this->Name, "Constructor", "An error occurred while attempting to remove hidden discussion whisper data.");
             // Remove bookmarks
             $s->Clear();
             $s->SetMainTable("UserBookmark", "ub");
             $s->AddWhere("DiscussionID", "(" . implode(",", $HiddenDiscussionIDs) . ")", "in", "and", "", 0);
             $this->Context->Database->Delete($this->Context, $s, $this->Name, "Constructor", "An error occurred while attempting to remove hidden discussion bookmark data.");
             // Discussion Watch data
             $s->Clear();
             $s->SetMainTable("UserDiscussionWatch", "uw");
             $s->AddWhere("DiscussionID", "(" . implode(",", $HiddenDiscussionIDs) . ")", "in", "and", "", 0);
             $this->Context->Database->Delete($this->Context, $s, $this->Name, "Constructor", "An error occurred while attempting to remove hidden discussion watch data.");
             // Now remove the discussions themselves
             $s->Clear();
             $s->SetMainTable("Discussion", "d");
             $s->AddWhere("Active", "0", "=", "and", "", 0);
             $s->AddWhere("Active", "0", "=", "or");
             $this->Context->Database->Delete($this->Context, $s, $this->Name, "Constructor", "An error occurred while attempting to remove hidden discussions.");
             $this->PostBackValidated = 1;
         } elseif ($this->PostBackAction == "PurgeDiscussions") {
             // Purge Whisper tables
             $Sql = "truncate table LUM_DiscussionUserWhisperFrom";
             $this->Context->Database->Execute($this->Context, $Sql, $this->Name, "Constructor", "An error occurred while attempting to truncate whisper relationships.");
             $Sql = "truncate table LUM_DiscussionUserWhisperTo";
             $this->Context->Database->Execute($this->Context, $Sql, $this->Name, "Constructor", "An error occurred while attempting to truncate whisper relationships.");
             // Comment Blocks
             $Sql = "truncate table LUM_CommentBlock";
             $this->Context->Database->Execute($this->Context, $Sql, $this->Name, "Constructor", "An error occurred while attempting to truncate comment blocks.");
             // Comments
             $Sql = "truncate table LUM_Comment";
             $this->Context->Database->Execute($this->Context, $Sql, $this->Name, "Constructor", "An error occurred while attempting to truncate comments.");
             // Discussions
             $Sql = "truncate table LUM_Discussion";
             $this->Context->Database->Execute($this->Context, $Sql, $this->Name, "Constructor", "An error occurred while attempting to truncate discussions.");
             // Bookmarks
             $Sql = "truncate table LUM_UserBookmark";
             $this->Context->Database->Execute($this->Context, $Sql, $this->Name, "Constructor", "An error occurred while attempting to truncate bookmarks.");
             // User discussion watch
             $Sql = "truncate table LUM_UserDiscussionWatch";
             $this->Context->Database->Execute($this->Context, $Sql, $this->Name, "Constructor", "An error occurred while attempting to truncate user discussion tracking data.");
             $this->PostBackValidated = 1;
         } elseif ($this->PostBackAction == "BackupDatabase") {
             $FileName = date("Y-m-d-H-i", mktime()) . "-" . dbNAME . ".sql";
             $Return = 1;
             $StringArray = array();
             // In order to enable the "system" function in windows, you've got to give
             // "read & execute" and "read" access to the internet guest account:
             // (machinename\iuser_machinename).
             @system(agMYSQL_DUMP_PATH . "mysqldump --opt -u " . dbUSER . " --password="******" " . dbNAME . " > " . agAPPLICATION_PATH . "images/" . $FileName);
             SaveAsDialogue(agAPPLICATION_PATH . "images/", $FileName, 1);
         } elseif ($this->PostBackAction == "Cleanup") {
             // Load some stats
             // 1. The number of hidden discussions
             $s = $this->Context->ObjectFactory->NewContextObject($this->Context, "SqlBuilder");
             $s->SetMainTable("Discussion", "d");
             $s->AddSelect("DiscussionID", "d", "HiddenDiscussionCount", "count");
             $s->AddWhere("Active", "0", "=", "and", "", 0);
             $s->AddWhere("Active", "0", "=", "or");
             $Result = $this->Context->Database->Select($this->Context, $s, $this->Name, "Constructor", "An error occurred while attempting to retrieve hidden discussion statistics.");
             $this->HiddenDiscussions = 0;
             while ($Row = $this->Context->Database->GetRow($Result)) {
                 $this->HiddenDiscussions = ForceInt($Row["HiddenDiscussionCount"], 0);
             }
             // 2. The number of hidden comments
             $s->Clear();
             $s->SetMainTable("Comment", "d");
             $s->AddSelect("CommentID", "d", "HiddenCommentCount", "count");
             $s->AddWhere("Deleted", "1", "=", "and", "", 0);
             $s->AddWhere("Deleted", "1", "=", "or");
             $Result = $this->Context->Database->Select($this->Context, $s, $this->Name, "Constructor", "An error occurred while attempting to retrieve hidden comment statistics.");
             $this->HiddenComments = 0;
             while ($Row = $this->Context->Database->GetRow($Result)) {
                 $this->HiddenComments = ForceInt($Row["HiddenCommentCount"], 0);
             }
             // 3. The number of non-posting users
             $this->InactiveUsers = count($this->GetInactiveUsers());
         }
     }
 }