/**
  * @see AbstractLostAndFounDatabaseItem::deleteAll()
  */
 public static function deleteAll()
 {
     $itemIDs = self::getMarkedItems('attachmentsFilesystem');
     foreach ($itemIDs as $itemID) {
         $item = new AttachmentsFilesystemLostAndFoundItem($itemID);
         $item->delete();
     }
 }
 /**
  * Reads attachment items
  */
 public function readAttachments()
 {
     switch ($this->activeSubTabMenuItem) {
         case 'database':
             require_once WCF_DIR . 'lib/acp/admintools/lostandfound/AttachmentsDatabaseLostAndFoundItem.class.php';
             $this->markedItems = intval(count(AttachmentsDatabaseLostAndFoundItem::getMarkedItems('attachmentsDatabase')));
             $this->classname = 'AttachmentsDatabaseLostAndFoundItem';
             // private attachments won't be read
             $sql = "SELECT attachment.*, user.username FROM wcf" . WCF_N . "_attachment attachment\n\t\t\t\t\t\tLEFT JOIN wcf" . WCF_N . "_user user\n\t\t\t\t\t\tON (user.userID = attachment.userID)\n\t\t\t\t\t\tLEFT JOIN wcf" . WCF_N . "_attachment_container_type type\n\t\t\t\t\t\tON(type.containerType = attachment.containerType)\n\t\t\t\t\t\tWHERE type.isPrivate = 0";
             $result = WCF::getDB()->sendQuery($sql);
             $i = 0;
             while ($row = WCF::getDB()->fetchArray($result)) {
                 if (!is_file(WCF_DIR . 'attachments/attachment-' . $row['attachmentID'])) {
                     if ($i < ($this->pageNo - 1) * $this->itemsPerPage || $i > $this->pageNo * $this->itemsPerPage) {
                         $i++;
                         continue;
                     }
                     $attachment = new AttachmentsDatabaseLostAndFoundItem($row['attachmentID']);
                     $attachment->filename = $row['attachmentName'];
                     $attachment->filesize = round($row['attachmentSize'] / 1000, 2) . ' kB';
                     $attachment->fileLastModTime = $row['uploadTime'];
                     $attachment->user = $row['username'];
                     $this->itemData[] = $attachment;
                 }
             }
             $this->count = $i;
             break;
         case 'filesystem':
             require_once WCF_DIR . 'lib/acp/admintools/lostandfound/AttachmentsFilesystemLostAndFoundItem.class.php';
             AttachmentsFilesystemLostAndFoundItem::createVirtualIDSpace();
             $this->markedItems = intval(count(AttachmentsFilesystemLostAndFoundItem::getMarkedItems('attachmentsFilesystem')));
             $this->classname = 'AttachmentsFilesystemLostAndFoundItem';
             chdir(WCF_DIR . 'attachments');
             $dh = opendir(WCF_DIR . 'attachments');
             $attachmentIDs = array();
             while ($file = readdir($dh)) {
                 if (preg_match("/^(attachment|thumbnail).*/", $file) && $file != '.' && $file != '..' && $file != '.htaccess' && !preg_match("/^.*\\.php\$/", $file)) {
                     $attachmentID = (int) preg_replace("/.*\\-(\\d+)\$/", "\$1", $file);
                     if ($attachmentID > 0) {
                         $attachmentIDs[] = $attachmentID;
                     }
                 }
             }
             if (count($attachmentIDs)) {
                 $sql = "SELECT attachmentID FROM wcf" . WCF_N . "_attachment WHERE attachmentID IN (" . implode(',', $attachmentIDs) . ")";
                 $result = WCF::getDB()->sendQuery($sql);
                 $physicalAttachments = array_flip($attachmentIDs);
                 while ($row = WCF::getDB()->fetchArray($result)) {
                     unset($physicalAttachments[$row['attachmentID']]);
                 }
                 $physicalAttachments = array_keys($physicalAttachments);
                 $this->count = count($physicalAttachments);
                 $i = 0;
                 foreach ($physicalAttachments as $attachmentID) {
                     if ($i < ($this->pageNo - 1) * $this->itemsPerPage || $i > $this->pageNo * $this->itemsPerPage) {
                         $i++;
                         continue;
                     }
                     $file = WCF_DIR . 'attachments/attachment-' . $attachmentID;
                     $attachment = new AttachmentsFilesystemLostAndFoundItem(AttachmentsFilesystemLostAndFoundItem::getVirtualID('attachmentsFilesystem', $file));
                     $attachment->filename = $file;
                     $attachment->filesize = round(filesize($file) / 1000, 2) . ' kB';
                     $attachment->fileLastModTime = filemtime($file);
                     $this->itemData[] = $attachment;
                     $i++;
                 }
             }
             closedir($dh);
             break;
     }
 }