}
if (!strstr($referer, basename(__FILE__))) {
    $_SESSION['redirect_uri'] = $referer;
}
$content = new KBContent();
$content->initWithUID($uid);
if ($content->parent_uid) {
    $parent = new KBContent();
    $parent->initWithUID($content->getTopContentUID());
    $board = new KBoard($parent->board_id);
} else {
    $board = new KBoard($content->board_id);
}
if (!$board->isEditor($content->member_uid)) {
    if ($board->permission_write == 'all') {
        if (!$board->isConfirm($content->password, $content->uid)) {
            $url = new KBUrl();
            $skin_path = KBOARD_URL_PATH . "/skin/{$board->skin}";
            include KBOARD_DIR_PATH . "/skin/{$board->skin}/confirm.php";
            exit;
        }
    } else {
        die('<script>alert("' . __('You do not have permission.', 'kboard') . '");history.go(-1);</script>');
    }
}
if ($file == 'thumbnail') {
    $content->removeThumbnail();
} else {
    $content->removeAttached($file);
}
header("Location:" . $_SESSION['redirect_uri']);
 /**
  * 첨부파일 삭제
  */
 public function fileDelete()
 {
     header('Content-Type: text/html; charset=UTF-8');
     $referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
     $host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '';
     if ($referer) {
         $url = parse_url($referer);
         $referer_host = $url['host'] . (isset($url['port']) && $url['port'] ? ':' . $url['port'] : '');
     } else {
         wp_die('KBoard : ' . __('This page is restricted from external access.', 'kboard'));
     }
     if (!in_array($referer_host, array($host))) {
         wp_die('KBoard : ' . __('This page is restricted from external access.', 'kboard'));
     }
     $uid = intval($_GET['uid']);
     if (isset($_GET['file'])) {
         $file = trim($_GET['file']);
         $file = kboard_htmlclear($file);
         $file = kboard_xssfilter($file);
         $file = esc_sql($file);
     } else {
         $file = '';
     }
     if (!$uid || !$file) {
         die('<script>alert("' . __('You do not have permission.', 'kboard') . '");history.go(-1);</script>');
     }
     $content = new KBContent();
     $content->initWithUID($uid);
     if ($content->parent_uid) {
         $parent = new KBContent();
         $parent->initWithUID($content->getTopContentUID());
         $board = new KBoard($parent->board_id);
     } else {
         $board = new KBoard($content->board_id);
     }
     if (!$board->isEditor($content->member_uid)) {
         if ($board->permission_write == 'all') {
             if (!$board->isConfirm($content->password, $content->uid)) {
                 $url = new KBUrl();
                 $skin_path = KBOARD_URL_PATH . "/skin/{$board->skin}";
                 include KBOARD_DIR_PATH . "/skin/{$board->skin}/confirm.php";
                 exit;
             }
         } else {
             die('<script>alert("' . __('You do not have permission.', 'kboard') . '");history.go(-1);</script>');
         }
     }
     if ($file == 'thumbnail') {
         $content->removeThumbnail();
     } else {
         $content->removeAttached($file);
     }
     header("Location:{$referer}");
     exit;
 }