<?php
if (!defined('_GNUBOARD_')) exit;
add_stylesheet('<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">', 0);
add_stylesheet('<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700&family=Noto+Sans+KR:wght@300;500&display=swap">', 0);
add_stylesheet('<link rel="stylesheet" href="'.$board_skin_url.'/style.write.css">', 0);
error_reporting(E_ALL & ~E_NOTICE);
ini_set('display_errors', '0');
$s_ca2 = isset($_GET['s_ca2']) ? trim($_GET['s_ca2']) : '';
$s_ca3 = isset($_GET['s_ca3']) ? trim($_GET['s_ca3']) : '';
$s_ca4 = isset($_GET['s_ca4']) ? trim($_GET['s_ca4']) : '';
$is_top = isset($_GET['is_top']) ? trim($_GET['is_top']) : '';
$is_label = isset($_GET['is_label']) ? trim($_GET['is_label']) : '';
$is_ok = isset($_GET['is_ok']) ? trim($_GET['is_ok']) : '';
$is_set = isset($_GET['is_set']) ? trim($_GET['is_set']) : '';
$ca2_list = explode('|', (string)$board['bo_1']);
$ca3_list = explode('|', (string)$board['bo_2']);
$ca4_list = explode('|', (string)$board['bo_3']);
$list_params = array(
'bo_table' => $bo_table,
's_ca2' => $s_ca2,
's_ca3' => $s_ca3,
's_ca4' => $s_ca4,
'is_top' => $is_top,
'is_label' => $is_label,
'is_ok' => $is_ok,
'is_set' => $is_set,
'stx' => isset($_GET['stx']) ? $_GET['stx'] : ''
);
$toggle_url = function($key) use ($list_params) {
$next = $list_params;
$next[$key] = ($next[$key] === 'y') ? '' : 'y';
return G5_BBS_URL.'/board.php?'.http_build_query($next);
};
$sql_count_where = " WHERE wr_is_comment = '0' AND wr_parent = wr_id ";
if ($s_ca2 !== '') $sql_count_where .= " AND x2_ca2 = '".sql_real_escape_string($s_ca2)."' ";
if ($s_ca3 !== '') $sql_count_where .= " AND x2_ca3 = '".sql_real_escape_string($s_ca3)."' ";
if ($s_ca4 !== '') $sql_count_where .= " AND x2_ca4 = '".sql_real_escape_string($s_ca4)."' ";
if ($is_top === 'y') $sql_count_where .= " AND IFNULL(x2_top,'0') = '1' ";
if ($is_label === 'y') $sql_count_where .= " AND IFNULL(x2_label,'0') = '1' ";
if ($is_ok === 'y') $sql_count_where .= " AND IFNULL(x2_ok,'0') = '1' ";
if ($is_set === 'y') $sql_count_where .= " AND IFNULL(x2_set,'0') = '1' ";
if (!empty($_GET['stx'])) {
$stx_esc = sql_real_escape_string($_GET['stx']);
$sql_count_where .= " AND wr_subject LIKE '%{$stx_esc}%' ";
}
$total_count_row = sql_fetch("SELECT COUNT(*) AS cnt FROM {$write_table} {$sql_count_where}", false);
$total_count = isset($total_count_row['cnt']) ? (int)$total_count_row['cnt'] : 0;
$memo_cards = array();
$memo_sql = "SELECT wr_id, wr_subject, wr_datetime, x2_memo FROM {$write_table} WHERE wr_is_comment = '0' AND wr_parent = wr_id AND TRIM(IFNULL(x2_memo, '')) <> '' AND IFNULL(x2_memo_clean, '0') <> '1' ORDER BY wr_id DESC LIMIT 60";
$memo_res = sql_query($memo_sql, false);
if ($memo_res) {
while ($memo_row = sql_fetch_array($memo_res)) {
$memo_plain = trim(preg_replace('/\s+/', ' ', strip_tags($memo_row['x2_memo'])));
if ($memo_plain === '') continue;
if (function_exists('mb_substr')) {
$memo_preview = mb_substr($memo_plain, 0, 100, 'UTF-8');
if (mb_strlen($memo_plain, 'UTF-8') > 100) $memo_preview .= '...';
} else {
$memo_preview = substr($memo_plain, 0, 100);
if (strlen($memo_plain) > 100) $memo_preview .= '...';
}
$memo_cards[] = array(
'href' => get_pretty_url($bo_table, $memo_row['wr_id']),
'subject' => $memo_row['wr_subject'],
'preview' => $memo_preview,
'datetime' => $memo_row['wr_datetime']
);
}
}
$rows_top = array();
$rows_normal = array();
for ($i = 0; $i < count($list); $i++) {
$row = $list[$i];
$wr_id = (int)$row['wr_id'];
$meta = sql_fetch("SELECT ca_name, x2_ca2, x2_ca3, x2_ca4, x2_top, x2_label, x2_ok, x2_set, x2_ver, x2_txt FROM {$write_table} WHERE wr_id = '{$wr_id}'", false);
if (!is_array($meta)) $meta = array();
$row['ca_name'] = isset($meta['ca_name']) ? $meta['ca_name'] : '';
$row['x2_ca2'] = isset($meta['x2_ca2']) ? $meta['x2_ca2'] : '';
$row['x2_ca3'] = isset($meta['x2_ca3']) ? $meta['x2_ca3'] : '';
$row['x2_ca4'] = isset($meta['x2_ca4']) ? $meta['x2_ca4'] : '';
$row['x2_top'] = isset($meta['x2_top']) ? $meta['x2_top'] : '0';
$row['x2_label'] = isset($meta['x2_label']) ? $meta['x2_label'] : '0';
$row['x2_ok'] = isset($meta['x2_ok']) ? $meta['x2_ok'] : '0';
$row['x2_set'] = isset($meta['x2_set']) ? $meta['x2_set'] : '0';
$row['x2_ver'] = isset($meta['x2_ver']) ? $meta['x2_ver'] : '';
$row['x2_txt'] = isset($meta['x2_txt']) ? $meta['x2_txt'] : '';
$file_info = get_file($bo_table, $wr_id);
$row['has_file'] = false;
$row['is_zip'] = false;
if (is_array($file_info)) {
for ($f = 0; $f < count($file_info); $f++) {
if (empty($file_info[$f]['source'])) continue;
$row['has_file'] = true;
$ext = strtolower(pathinfo($file_info[$f]['source'], PATHINFO_EXTENSION));
if ($ext === 'zip') $row['is_zip'] = true;
}
}
if ($s_ca2 !== '' && $row['x2_ca2'] !== $s_ca2) continue;
if ($s_ca3 !== '' && $row['x2_ca3'] !== $s_ca3) continue;
if ($s_ca4 !== '' && $row['x2_ca4'] !== $s_ca4) continue;
if ($is_top === 'y' && $row['x2_top'] !== '1') continue;
if ($is_label === 'y' && $row['x2_label'] !== '1') continue;
if ($is_ok === 'y' && $row['x2_ok'] !== '1') continue;
if ($is_set === 'y' && $row['x2_set'] !== '1') continue;
if ($row['x2_top'] === '1') $rows_top[] = $row;
else $rows_normal[] = $row;
}
$render_rows = array_merge($rows_top, $rows_normal);
?>
<article id="LIST">
<section class="TopTitle">
<div class="top-title-row">
<p>SECURE ARCHIVE</p>
<span class="total-counter">TOTAL : <?php echo number_format($total_count); ?></span>
</div>
<span><i class="fa-solid fa-database"></i> <?php echo $board['bo_subject']; ?></span>
</section>
<div class="Control-Bar">
<div class="control-left">
<button type="button" class="label-toggle-btn" id="openNoticeBtn"><i class="fa-solid fa-bullhorn"></i> 공지사항</button>
<select id="filter_ca2" class="control-select" data-base="?bo_table=<?php echo $bo_table; ?>&s_ca3=<?php echo urlencode($s_ca3); ?>&s_ca4=<?php echo urlencode($s_ca4); ?>&is_top=<?php echo urlencode($is_top); ?>&is_label=<?php echo urlencode($is_label); ?>&is_ok=<?php echo urlencode($is_ok); ?>&is_set=<?php echo urlencode($is_set); ?>&stx=<?php echo urlencode(isset($_GET['stx']) ? $_GET['stx'] : ''); ?>">
<option value="">구분</option>
<?php foreach($ca2_list as $ca) { if(!trim($ca)) continue; $sel = ($s_ca2==$ca)?'selected':''; ?>
<option value="<?php echo get_text($ca); ?>" <?php echo $sel; ?>><?php echo get_text($ca); ?></option>
<?php } ?>
</select>
<select id="filter_ca3" class="control-select" data-base="?bo_table=<?php echo $bo_table; ?>&s_ca2=<?php echo urlencode($s_ca2); ?>&s_ca4=<?php echo urlencode($s_ca4); ?>&is_top=<?php echo urlencode($is_top); ?>&is_label=<?php echo urlencode($is_label); ?>&is_ok=<?php echo urlencode($is_ok); ?>&is_set=<?php echo urlencode($is_set); ?>&stx=<?php echo urlencode(isset($_GET['stx']) ? $_GET['stx'] : ''); ?>">
<option value="">형태</option>
<?php foreach($ca3_list as $ca) { if(!trim($ca)) continue; $sel = ($s_ca3==$ca)?'selected':''; ?>
<option value="<?php echo get_text($ca); ?>" <?php echo $sel; ?>><?php echo get_text($ca); ?></option>
<?php } ?>
</select>
<select id="filter_ca4" class="control-select" data-base="?bo_table=<?php echo $bo_table; ?>&s_ca2=<?php echo urlencode($s_ca2); ?>&s_ca3=<?php echo urlencode($s_ca3); ?>&is_top=<?php echo urlencode($is_top); ?>&is_label=<?php echo urlencode($is_label); ?>&is_ok=<?php echo urlencode($is_ok); ?>&is_set=<?php echo urlencode($is_set); ?>&stx=<?php echo urlencode(isset($_GET['stx']) ? $_GET['stx'] : ''); ?>">
<option value="">서브메뉴3</option>
<?php foreach($ca4_list as $ca) { if(!trim($ca)) continue; $sel = ($s_ca4==$ca)?'selected':''; ?>
<option value="<?php echo get_text($ca); ?>" <?php echo $sel; ?>><?php echo get_text($ca); ?></option>
<?php } ?>
</select>
<button type="button" class="label-toggle-btn <?php echo ($is_top==='y')?'active':''; ?>" data-href="<?php echo $toggle_url('is_top'); ?>">우선</button>
<button type="button" class="label-toggle-btn <?php echo ($is_label==='y')?'active':''; ?>" data-href="<?php echo $toggle_url('is_label'); ?>">라벨</button>
<button type="button" class="label-toggle-btn <?php echo ($is_ok==='y')?'active':''; ?>" data-href="<?php echo $toggle_url('is_ok'); ?>">완성</button>
<button type="button" class="label-toggle-btn <?php echo ($is_set==='y')?'active':''; ?>" data-href="<?php echo $toggle_url('is_set'); ?>">세트</button>
<button type="button" id="memoPanelToggleBtn" class="label-toggle-btn"><i class="fa-solid fa-note-sticky"></i> 메모</button>
</div>
<div class="control-right">
<input type="text" id="live_search" value="" placeholder="제목 실시간 검색" class="live-search-input">
<button type="button" class="label-toggle-btn" id="openSearchBtn"><i class="fa-solid fa-magnifying-glass"></i> 검색</button>
<?php if ($is_admin) { ?>
<button type="button" class="btn-admin" data-href="<?php echo G5_ADMIN_URL; ?>/board_form.php?w=u&bo_table=<?php echo $bo_table; ?>"><i class="fa-solid fa-user-shield"></i> 관리자</button>
<?php } ?>
<?php if ($write_href) { ?>
<button type="button" class="btn-write" data-href="<?php echo $write_href; ?>"><i class="fa-solid fa-pen"></i> 글쓰기</button>
<?php } ?>
</div>
</div>
<form name="fboardlist" id="fboardlist" action="./board_list_update.php" method="post">
<div id="board-list-body" class="Backup-Grid">
<?php if (!empty($render_rows)) { ?>
<?php foreach ($render_rows as $row) { ?>
<article class="backup-card <?php echo ($row['x2_ok'] === '1') ? 'ok-row' : ''; ?> <?php echo ($row['is_notice']) ? 'is-notice' : ''; ?>"
data-subject="<?php echo strtolower(strip_tags($row['subject'])); ?>"
data-href="<?php echo $row['href']; ?>">
<div class="card-head">
<span class="card-num"><?php echo (int)$row['num']; ?></span>
<span class="item-icons">
<?php if ($row['x2_label'] === '1') { ?><i class="fa-solid fa-star label-star-icon" title="라벨"></i><?php } ?>
<?php if ($row['x2_ok'] === '1') { ?><i class="fa-solid fa-circle-check done-icon" title="완성"></i><?php } ?>
<?php if ($row['wr_link1'] || $row['wr_link2']) { ?><i class="fa-solid fa-link" title="링크"></i><?php } ?>
<?php if ($row['has_file']) { ?><i class="fa-solid <?php echo $row['is_zip'] ? 'fa-file-zipper' : 'fa-paperclip'; ?>" title="첨부파일"></i><?php } ?>
<?php if (trim($row['x2_txt']) !== '') { ?><i class="fa-brands fa-php" title="추가 내용"></i><?php } ?>
</span>
</div>
<div class="subject-main">
<div class="subject-badges">
<?php if ($row['x2_top'] === '1') { ?><span class="badge-item badge-top" title="우선순위 높음"><i class="fa-solid fa-flag"></i> TOP</span><?php } ?>
<?php if ($row['is_notice']) { ?><span class="badge-item badge-notice" title="공지사항"><i class="fa-solid fa-bullhorn"></i> NOTICE</span><?php } ?>
</div>
<a href="<?php echo $row['href']; ?>" class="subject-link">
<?php if ($row['has_file']) { ?>
<i class="fa-solid <?php echo $row['is_zip'] ? 'fa-file-zipper' : 'fa-paperclip'; ?> subject-icon-file" title="첨부파일"></i>
<?php } ?>
<?php if (trim($row['x2_txt']) !== '') { ?>
<i class="fa-regular fa-file-code subject-icon-php" title="추가 내용"></i>
<?php } ?>
<?php echo $row['subject']; ?>
</a>
</div>
<div class="meta-info-grid">
<div class="meta-group-category">
<?php if (!empty($row['ca_name'])) { ?><span class="meta-tag tag-category"><?php echo get_text($row['ca_name']); ?></span><?php } ?>
<?php if (!empty($row['x2_ca2'])) { ?><span class="meta-tag tag-type"><?php echo get_text($row['x2_ca2']); ?></span><?php } ?>
<?php if (!empty($row['x2_ca3'])) { ?><span class="meta-tag tag-form"><?php echo get_text($row['x2_ca3']); ?></span><?php } ?>
<?php if (!empty($row['x2_ca4'])) { ?><span class="meta-tag tag-kind"><?php echo get_text($row['x2_ca4']); ?></span><?php } ?>
</div>
<div class="meta-group-status">
<?php if ($row['x2_label'] === '1') { ?>
<span class="status-icon status-label" title="라벨"><i class="fa-solid fa-tag"></i></span>
<?php } else { ?>
<span class="status-icon dim" title="라벨 미설정"><i class="fa-solid fa-tag"></i></span>
<?php } ?>
<?php if ($row['x2_ok'] === '1') { ?>
<span class="status-icon status-ok" title="완성"><i class="fa-solid fa-circle-check"></i></span>
<?php } else { ?>
<span class="status-icon dim" title="미완성"><i class="fa-regular fa-circle"></i></span>
<?php } ?>
<?php if ($row['x2_set'] === '1') { ?>
<span class="status-icon status-set" title="세트 구성"><i class="fa-solid fa-layer-group"></i></span>
<?php } else { ?>
<span class="status-icon dim" title="단품"><i class="fa-solid fa-square-full"></i></span>
<?php } ?>
</div>
</div>
<?php if (!empty($row['x2_ver'])) { ?>
<div class="meta-footer">
<span class="theme-version"><i class="fa-solid fa-code-branch"></i> <?php echo get_text($row['x2_ver']); ?></span>
</div>
<?php } ?>
<div class="card-foot">
<span class="item-date"><?php echo substr($row['wr_datetime'], 0, 16); ?></span>
</div>
</article>
<?php } ?>
<?php } else { ?>
<div class="no-signal live-empty-card">표시할 게시물이 없습니다.</div>
<?php } ?>
</div>
</form>
<?php if ($total_page > 1) { ?>
<div id="TERM_PAGING_DIRECT">
<?php
$pg_count = $config['cf_write_pages'];
$start_pg = (((int)(($page - 1) / $pg_count)) * $pg_count) + 1;
$end_pg = $start_pg + $pg_count - 1;
if ($end_pg >= $total_page) $end_pg = $total_page;
if ($page > 1) { echo '<a href="'.get_pretty_url($bo_table, '', $qstr.'&page=1').'" class="trm-btn"><i class="trm-ico-start"></i></a>'; }
if ($start_pg > 1) { echo '<a href="'.get_pretty_url($bo_table, '', $qstr.'&page='.($start_pg-1)).'" class="trm-btn"><i class="trm-ico-prev"></i></a>'; }
for ($k=$start_pg; $k<=$end_pg; $k++) {
if ($page != $k) { echo '<a href="'.get_pretty_url($bo_table, '', $qstr.'&page='.$k).'" class="trm-btn">'.$k.'</a>'; }
else { echo '<strong class="trm-btn trm-current">'.$k.'</strong>'; }
}
if ($total_page > $end_pg) { echo '<a href="'.get_pretty_url($bo_table, '', $qstr.'&page='.($end_pg+1)).'" class="trm-btn"><i class="trm-ico-next"></i></a>'; }
if ($page < $total_page) { echo '<a href="'.get_pretty_url($bo_table, '', $qstr.'&page='.$total_page).'" class="trm-btn"><i class="trm-ico-end"></i></a>'; }
?>
</div>
<?php } ?>
<aside id="memo_side_panel" class="memo-side-panel" aria-hidden="true">
<div class="memo-panel-head">
<div class="memo-panel-title"><i class="fa-solid fa-note-sticky"></i> 메모 메뉴</div>
<button type="button" class="memo-panel-close" id="memoPanelCloseBtn"><i class="fa-solid fa-xmark"></i></button>
</div>
<div class="memo-panel-layout-wrap">
<button type="button" class="memo-layout-switch" id="memoLayoutToggle" aria-pressed="false">
<span class="memo-layout-label memo-layout-label-1">1x1</span>
<span class="memo-layout-thumb"></span>
<span class="memo-layout-label memo-layout-label-2">1x2</span>
</button>
<span class="memo-total-text">TOTAL : <?php echo number_format(count($memo_cards)); ?></span>
</div>
<div class="memo-card-list layout-1" id="memoCardList">
<?php if (!empty($memo_cards)) { ?>
<?php foreach ($memo_cards as $memo_card) { ?>
<article class="memo-card-item">
<div class="memo-card-date"><?php echo date('Y-m-d H:i', strtotime($memo_card['datetime'])); ?></div>
<div class="memo-card-subject"><?php echo get_text($memo_card['subject']); ?></div>
<div class="memo-card-content"><?php echo get_text($memo_card['preview']); ?></div>
<a href="<?php echo $memo_card['href']; ?>" class="memo-card-link">게시물 보기</a>
</article>
<?php } ?>
<?php } else { ?>
<div class="memo-empty">표시할 메모가 없습니다.</div>
<?php } ?>
</div>
</aside>
<div id="NoticeLayer" class="NoticeLayer" style="display:none;">
<h3 class="notice-title"><i class="fa-solid fa-bullhorn"></i> 공지사항</h3>
<div class="notice-content">
<?php
$notice_text = trim((string)$board['notice']);
if ($notice_text !== '') echo nl2br(stripslashes($notice_text));
else echo '등록된 공지사항이 없습니다.';
?>
</div>
<div class="notice-actions">
<?php if ($is_admin) { ?>
<button type="button" class="btn-edit-notice" id="openNoticeWriteBtn" data-url="<?php echo $board_skin_url; ?>/notice.php?bo_table=<?php echo $bo_table; ?>">공지사항 글쓰기</button>
<?php } ?>
<button type="button" class="btn-edit-notice-dis" id="closeNoticeBtn">닫기</button>
</div>
</div>
<section id="SCH" class="Search" style="display:none;">
<div class="search-modal-box">
<form name="fsearch" method="get">
<input type="hidden" name="bo_table" value="<?php echo $bo_table; ?>">
<h3 class="search-title">검색</h3>
<input type="text" name="stx" value="<?php echo stripslashes(isset($_GET['stx']) ? $_GET['stx'] : ''); ?>" required placeholder="제목 검색" class="search-input">
<div class="search-actions">
<button type="submit" class="btn-search-submit">검색</button>
<button type="button" id="closeSearchBtn" class="btn-search-cancel">취소</button>
</div>
</form>
</div>
</section>
</article>
<?php include_once("{$board_skin_path}/list/list.script.php"); ?>