<?php
if (!defined('_GNUBOARD_')) exit;
include_once("{$board_skin_path}/db_update.php");
add_stylesheet('<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">', 0);
// 5. 버전 폼 기본값 설정 (이전 게시물 값 가져오기)
if (!$write['x2_ver']) {
$row_ver = sql_fetch(" select x2_ver from {$write_table} order by wr_id desc limit 1 ");
$default_ver = $row_ver['x2_ver'];
} else {
$default_ver = $write['x2_ver'];
}
// 카테고리 기본값 설정 (현재 날짜 기준 Y-m 형식)
if ($is_category) {
$ca_name_default = ($write['ca_name']) ? $write['ca_name'] : date("Y-m");
}
$file_count = (isset($board['bo_upload_count']) && $board['bo_upload_count']) ? $board['bo_upload_count'] : 0;
?>
<style>
/* 0. 커스텀 스크롤바 (페이지 & 입력창) - 디자인 보정 추가 */
html::-webkit-scrollbar, textarea::-webkit-scrollbar { width: 10px; height: 10px; }
html::-webkit-scrollbar-track, textarea::-webkit-scrollbar-track { background: rgba(0, 0, 0, 0.3); }
html::-webkit-scrollbar-thumb, textarea::-webkit-scrollbar-thumb {
background: linear-gradient(to bottom, #00f2ff, #0062ff);
border-radius: 6px;
border: 2px solid #090a0f;
}
html::-webkit-scrollbar-thumb:hover, textarea::-webkit-scrollbar-thumb:hover { background: #fff; }
/* 1. 애니메이션 & 배경 */
@keyframes fadeInUp { from { opacity: 0; transform: translateY(30px); } to { opacity: 1; transform: translateY(0); } }
#WRITE_WRAP { position: relative; min-height: 100vh; background: radial-gradient(circle at center, #1b2735 0%, #090a0f 100%); padding: 60px 0; font-family: 'Pretendard', sans-serif; }
#space-canvas { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 1; }
#WRITE { position: relative; z-index: 2; width: 90%; margin: 0 auto; animation: fadeInUp 1s ease-out forwards; }
#fwrite { background: rgba(14, 22, 40, 0.92); backdrop-filter: blur(20px); border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 6px; box-shadow: 0 25px 50px rgba(0,0,0,0.5); overflow: hidden; }
/* 2. 테이블 레이아웃 */
.write-table { width: 100%; border-collapse: collapse; }
.write-table tr { border-bottom: 1px solid rgba(255, 255, 255, 0.05); transition: 0.3s; }
.td-label { width: 200px; padding: 25px 30px; color: #e2e8f0; font-size: 0.9rem; font-weight: 700; background: rgba(255, 255, 255, 0.02); }
.td-label i { width: 28px; color: #00f2ff; margin-right: 12px; }
/* 3. 폼 입력창 및 셀렉트 메뉴 (다크 테마 적용) */
input[type="text"], input[type="date"], input[type="time"], select, textarea {
background: rgba(0, 0, 0, 0.4) !important;
border: 1px solid rgba(255, 255, 255, 0.15) !important;
color: #00f2ff !important;
padding: 12px 18px !important;
border-radius: 6px !important;
font-size: 0.8rem;
transition: all 0.3s ease;
}
/* 셀렉트 내부 옵션 다크 배경 처리 */
select option { background-color: #1b2735 !important; color: #fff !important; }
textarea { line-height:27px; padding: 25px; color: #fff !important; font-family: 'Consolas', 'Monaco', monospace; }
/* 마우스 오버 및 포커스 효과 */
input[type="text"]:hover, select:hover, input[type="date"]:hover, input[type="time"]:hover {
border-color: rgba(0, 242, 255, 0.5) !important;
background: rgba(255, 255, 255, 0.05) !important;
}
input[type="text"]:focus, select:focus {
border-color: #00f2ff !important;
box-shadow: 0 0 15px rgba(0, 242, 255, 0.3);
outline: none;
}
/* 4. 달력(Date/Time) UI 디자인 */
input[type="date"], input[type="time"] { position: relative; }
input[type="date"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator { filter: invert(1); cursor: pointer; opacity: 0.8; }
/* 5. 첨부파일 UI */
.file-row { display: none; align-items: center; gap: 12px; margin-bottom: 12px; padding: 12px; background: rgba(255, 255, 255, 0.03); border-radius: 7px; }
.file-row.active { display: flex; flex-wrap: wrap; }
.file-btn-custom { background: #00f2ff; color: #000; padding: 7px 15px; border-radius: 4px; font-weight: 700; cursor: pointer; font-size: 0.8rem; transition: 0.3s; }
.file-btn-custom:hover { background: #fff; transform: scale(1.05); }
.file-desc-input { background: rgba(255, 255, 255, 0.05) !important; border: 1px solid rgba(255, 255, 255, 0.1) !important; width: 300px !important; font-size: 0.8rem !important; height: 35px !important; color: #fff !important; }
/* 6. 버튼 스타일 */
.btn-action { transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); cursor: pointer; }
.btn-action:hover { transform: translateY(-3px) scale(1.03); filter: brightness(1.1); box-shadow: 0 10px 25px rgba(0, 242, 255, 0.4); }
.btn-save-main { background: linear-gradient(45deg, #00f2ff, #0062ff); color: #fff; padding: 18px 100px; border-radius: 5px; font-weight: 800; border: none; }
.btn-save-top { background: #00f2ff; color: #000; border: none; padding: 10px 25px; border-radius: 6px; font-weight: 700; }
.btn-cancel-top { background: #1e293b; color: #fff; border: none; padding: 10px 25px; border-radius: 6px; }
/* 7. 태그 스타일 */
.tag-input-wrap { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.tag-icon { color: #00f2ff; font-size: 0.8rem; }
.tag-input { flex: 1; background: transparent !important; border: none !important; border-bottom: 1px solid rgba(255,255,255,0.2) !important; border-radius: 0 !important; padding: 5px 0 !important; font-size: 0.9rem !important; color: #fff !important; }
.tag-input:focus { border-bottom-color: #00f2ff !important; box-shadow: none !important; }
</style>
<div id="WRITE_WRAP">
<article id="WRITE">
<form name="fwrite" id="fwrite" action="<?php echo $action_url; ?>" onsubmit="return fwrite_submit(this);" method="post" enctype="multipart/form-data" autocomplete="off">
<input type="hidden" name="w" value="<?php echo $w; ?>">
<input type="hidden" name="bo_table" value="<?php echo $bo_table; ?>">
<input type="hidden" name="wr_id" value="<?php echo $wr_id; ?>">
<input type="hidden" name="sca" value="<?php echo $sca; ?>">
<input type="hidden" name="uid" value="<?php echo get_uniqid(); ?>">
<div style="padding: 30px 40px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid rgba(255,255,255,0.1);">
<h2 style="margin:0; font-size:1.8rem; color:#00f2ff; letter-spacing:1px; font-weight:800;"><i class="fa-solid fa-rocket"></i> DATA CONTROL</h2>
<div style="display:flex; gap:15px;">
<button type="button" class="btn-action btn-cancel-top" onclick="window.history.back();">CANCEL</button>
<button type="submit" class="btn-action btn-save-top">SAVE MISSION</button>
</div>
</div>
<table class="write-table">
<tr>
<td class="td-label"><i class="fa-solid fa-satellite-dish"></i> 분류/시간 설정</td>
<td style="padding:20px 40px;">
<div style="display:flex; flex-wrap:wrap; gap:15px; align-items:center;">
<?php if ($is_category) { ?>
<select name="ca_name" id="ca_name" required>
<option value="">분류 선택</option>
<?php
$categories = explode("|", $board['bo_category_list']);
foreach($categories as $category) {
$category = trim($category);
if(!$category) continue;
$selected = ($ca_name_default == $category) ? "selected" : "";
echo '<option value="'.$category.'" '.$selected.'>'.$category.'</option>'.PHP_EOL;
}
?>
</select>
<?php } ?>
<span style="color:#64748b; font-size:0.9rem;">종류</span>
<select name="x2_ca2">
<option value=''>선택</option>
<?php
$bo_1_opts = explode("|", $board['bo_1']);
foreach($bo_1_opts as $val) {
$selected = ($write['x2_ca2'] == $val) ? "selected" : "";
echo "<option value='{$val}' {$selected}>{$val}</option>";
}
?>
</select>
<span style="color:#64748b; font-size:0.9rem;">형태</span>
<select name="x2_ca3" id="x2_ca3">
<option value=''>선택</option>
<?php
$bo_2_opts = explode("|", $board['bo_2']);
foreach($bo_2_opts as $val) {
if (!trim($val)) continue;
$selected = (isset($write['x2_ca3']) && $write['x2_ca3'] == $val) ? "selected" : "";
echo "<option value='{$val}' {$selected}>{$val}</option>";
}
?>
</select>
<span style="color:#64748b; font-size:0.9rem;">VER</span>
<input type="text" name="x2_ver" value="<?php echo $default_ver; ?>" size="8" placeholder="Version">
<div style="margin-left:auto; display:flex; gap:10px; align-items:center;">
<i class="fa-regular fa-calendar-check" style="color:#fff; font-size:1.1rem;"></i>
<input type="date" name="wr_date_custom" value="<?php echo substr($write['wr_datetime'],0,10); ?>">
<input type="time" name="wr_time_custom" value="<?php echo substr($write['wr_datetime'],11,8); ?>" step="1">
</div>
</div>
</td>
</tr>
<tr>
<td class="td-label"><i class="fa-solid fa-pen-fancy"></i> 미션 제목</td>
<td style="padding:20px 40px;">
<input type="text" name="wr_subject" value="<?php echo $subject; ?>" required style="width:100%" placeholder="제목을 입력하세요">
</td>
</tr>
<tr>
<td class="td-label"><span class="tag-icon"><i class="fa-solid fa-tags"></i></span> 태그</td>
<td style="padding:20px 40px;">
<div class="tag-input-wrap">
<input type="text" name="wr_1" value="<?php echo $write['wr_1']; ?>" class="tag-input" placeholder="태그를 입력하세요 (쉼표로 구분)">
</div>
</td>
</tr>
<tr>
<td colspan="2" style="text-align:center; padding:15px; background:rgba(255,255,255,0.01);">
<button type="button" class="btn-action" style="background:none; border:1px dashed #00f2ff; color:#00f2ff; padding:8px 30px; border-radius:5px; cursor:pointer;" onclick="$('#Editor-Area').slideToggle();">데이터 에디터 & 첨부파일 관리</button>
</td>
</tr>
</table>
<div id="Editor-Area" style="<?php echo ($w=='u' || $write['wr_content']) ? 'display:block;' : 'display:none;'; ?>">
<div style="padding:30px; background: rgba(0, 0, 0, 0.4);">
<?php echo $editor_html; ?>
</div>
<table class="write-table">
<tr>
<td class="td-label"><i class="fa-solid fa-code"></i> 추가 코드</td>
<td style="padding:20px 40px;">
<textarea name="x2_txt" id="x2_txt" rows="10" placeholder="추가 코드를 입력하세요" style="width:100%"><?php echo get_text($write['x2_txt'], 0); ?></textarea>
</td>
</tr>
<tr>
<td class="td-label"><i class="fa-solid fa-link"></i> 참조 링크 #1</td>
<td style="padding:20px 40px;">
<input type="text" name="wr_link1" value="<?php echo $write['wr_link1']; ?>" style="width:100%" placeholder="https://...">
</td>
</tr>
<tr>
<td class="td-label"><i class="fa-solid fa-link"></i> 참조 링크 #2</td>
<td style="padding:20px 40px;">
<input type="text" name="wr_link2" value="<?php echo $write['wr_link2']; ?>" style="width:100%" placeholder="https://...">
</td>
</tr>
<tr>
<td class="td-label"><i class="fa-solid fa-paperclip"></i> 페이로드 첨부</td>
<td style="padding:20px 40px;">
<div id="variableFiles">
<?php for ($i=0; $is_file && $i<$file_count; $i++) {
$is_active = ($i == 0 || (isset($file[$i]['file']) && $file[$i]['file'])) ? "active" : "";
?>
<div class="file-row <?php echo $is_active; ?>" id="file_row_<?php echo $i; ?>">
<label for="bf_file_<?php echo $i; ?>" class="file-btn-custom">FILE #<?php echo $i+1; ?></label>
<input type="file" name="bf_file[<?php echo $i; ?>]" id="bf_file_<?php echo $i; ?>" style="display:none;" onchange="updateFileName(this, <?php echo $i; ?>)">
<span id="file_name_<?php echo $i; ?>" style="color:#8fa3ad; font-size:0.85rem; flex:1;">
<?php if($w == 'u' && isset($file[$i]['file']) && $file[$i]['file']) {
echo $file[$i]['source'];
echo " <label style='color:#ff4757; margin-left:10px; cursor:pointer;'><input type='checkbox' name='bf_file_del[$i]' value='1'> 삭제</label>";
} else { echo "No file selected"; } ?>
</span>
<?php if ($board['bo_use_file_content']) { ?>
<input type="text" name="bf_content[<?php echo $i; ?>]" value="<?php echo ($w == 'u') ? stripslashes($file[$i]['bf_content']) : ''; ?>" class="file-desc-input" placeholder="파일 설명 입력">
<?php } ?>
</div>
<?php } ?>
</div>
<button type="button" class="btn-action" style="background:none; border:1px solid #334155; color:#8fa3ad; padding:8px 20px; border-radius:6px; cursor:pointer;" onclick="file_add();">+ ADD FILE SLOT</button>
</td>
</tr>
</table>
</div>
<div style="padding:60px; text-align:center; border-top:1px solid rgba(255,255,255,0.05);">
<button type="submit" class="btn-action btn-save-main">MISSION COMPLETE & SAVE</button>
</div>
</form>
</article>
</div>
<script>
function updateFileName(input, index) {
const fileName = input.files[0] ? input.files[0].name : "No file selected";
document.getElementById('file_name_' + index).innerText = fileName;
document.getElementById('file_name_' + index).style.color = "#00f2ff";
}
function file_add() {
var rows = document.querySelectorAll('.file-row:not(.active)');
if (rows.length > 0) rows[0].classList.add('active');
}
function fwrite_submit(f) {
<?php echo $editor_js; ?>
return true;
}
</script>