/**
  * Bulk remove attachments
  *
  * @access	private
  * @return	void		[Outputs to screen]
  */
 private function _bulkRemoveAttachments()
 {
     foreach ($_POST as $key => $value) {
         if (preg_match("/^attach_(\\d+)\$/", $key, $match)) {
             if ($this->request[$match[0]]) {
                 $ids[] = $match[1];
             }
         }
     }
     $ids = IPSLib::cleanIntArray($ids);
     $attach_tid = array();
     if (count($ids)) {
         //-----------------------------------------
         // Get attach details?
         //-----------------------------------------
         $this->DB->build(array('select' => 'a.*', 'from' => array('attachments' => 'a'), 'where' => "a.attach_rel_id > 0 AND a.attach_id IN(" . implode(",", $ids) . ")", 'add_join' => array(array('select' => 'p.pid, p.topic_id', 'from' => array('posts' => 'p'), 'where' => "p.pid=a.attach_rel_id AND attach_rel_module='post'", 'type' => 'left'))));
         $this->DB->execute();
         while ($killmeh = $this->DB->fetch()) {
             if ($killmeh['attach_location']) {
                 @unlink($this->settings['upload_dir'] . "/" . $killmeh['attach_location']);
             }
             if ($killmeh['attach_thumb_location']) {
                 @unlink($this->settings['upload_dir'] . "/" . $killmeh['attach_thumb_location']);
             }
             $attach_tid[$killmeh['topic_id']] = $killmeh['topic_id'];
         }
         $this->DB->delete('attachments', "attach_id IN(" . implode(",", $ids) . ")");
         $this->registry->adminFunctions->saveAdminLog(sprintf($this->lang->words['deleted_attachments'], implode(",", $ids)));
         //-----------------------------------------
         // Recount topic upload marker
         //-----------------------------------------
         require_once IPSLib::getAppDir('forums') . '/sources/classes/post/classPost.php';
         $postlib = new classPost($this->registry);
         foreach ($attach_tid as $tid) {
             if ($tid) {
                 $postlib->recountTopicAttachments($tid);
             }
         }
         $this->registry->output->global_message = $this->lang->words['attachments_removed'];
     } else {
         $this->registry->output->global_message = $this->lang->words['noattach_to_remove'];
     }
     if ($this->request['return'] == 'stats') {
         $this->registry->output->silentRedirectWithMessage($this->settings['base_url'] . 'module=attachments&section=stats');
     } else {
         if ($_POST['url']) {
             foreach (explode('&', $_POST['url']) as $u) {
                 list($k, $v) = explode('=', $u);
                 $this->request[$k] = $v;
             }
         }
         $this->_searchResults();
     }
 }