GNU/skin/board/memo/write.skin.php
<?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);
add_stylesheet('<link rel="stylesheet" href="'.$board_skin_url.'/style.write.css">', 0);

// 버전 기본값 설정
if (!$write['x2_ver']) {
    $row_ver = sql_fetch(" select x2_ver from {$write_table} order by wr_id desc limit 1 ");
    $default_ver = isset($row_ver['x2_ver']) ? $row_ver['x2_ver'] : '';
} else {
    $default_ver = $write['x2_ver'];
}
// --------------------------------------------------------------------------
// 데이터 존재 여부 (에디터 내용, 링크, 파일)
$has_data = ($w == 'u' && (trim($write['wr_link1']) || trim($write['wr_link2']) || (isset($file[0]['file']) && $file[0]['file'])));
$extra_area_class = $has_data ? 'is-open' : 'is-close';
?>

<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; ?>">

            <div class="write-head">
                <h2 class="write-title"><i class="fa-solid fa-code-commit"></i> BYBIT_DAEMON_INTERFACE</h2>
                <div class="write-head-btns">
                    <button type="button" class="btn-toggle-clean btn-head-cancel" onclick="window.history.back();">취 소</button>
                    <button type="submit" class="btn-submit btn-head-cancel">데이터 저장</button>
                </div>
            </div>

            <table class="write-table">
                <tr>
                    <td class="td-label"><i class="fa-solid fa-bolt"></i> 메모 분류</td>
                    <td class="td-content">
                        <div class="row-flex row-gap-30">
                            <?php if ($is_category) { 
                                // 값이 없으면(신규 작성 시) 현재 날짜를 YYYY-MM 형식으로 기본값 설정
                                if (!$write['ca_name']) {
                                    $write['ca_name'] = date('Y-m');
                                }
                                // 설정된 기본값에 selected가 적용되도록 카테고리 옵션을 다시 생성
                                $category_option = get_category_option($board, $write['ca_name']);
                            ?>
                            <div class="form-group">
                                <span class="field-label">날짜 : </span>
                                <select name="ca_name" id="id_ca_name" required>
                                    <option value="">날짜 선택</option>
                                    <?php echo $category_option; ?>
                                </select>
                            </div>
                            <?php } ?>
                            <div class="form-group">
                                <span class="field-label">타입 : </span>
                                <select name="x2_ca2" id="id_x2_ca2">
                                    <option value=''>타입 선택</option>
                                    <?php $bo_1_opts = explode("|", $board['bo_1']); foreach($bo_1_opts as $val) { $selected = (isset($write['x2_ca2']) && $write['x2_ca2'] == $val) ? "selected" : ""; echo "<option value='{$val}' {$selected}>{$val}</option>"; } ?>
                                </select>
                            </div>
                            <div class="form-group">
                                <span class="field-label">종류 : </span>
                                <select name="x2_ca3" id="id_x2_ca3">
                                    <option value=''>기간 선택</option>
                                    <?php $bo_2_opts = explode("|", $board['bo_2']); foreach($bo_2_opts as $val) { $selected = (isset($write['x2_ca3']) && $write['x2_ca3'] == $val) ? "selected" : ""; echo "<option value='{$val}' {$selected}>{$val}</option>"; } ?>
                                </select>
                            </div>
                            <div class="form-group">
                                <span class="field-label">구분 : </span>
                                <select name="x2_ca4" id="id_x2_ca4">
                                    <option value=''>구분 선택</option>
                                    <?php $bo_3_opts = explode("|", $board['bo_3']); foreach($bo_3_opts as $val) { $selected = (isset($write['x2_ca4']) && $write['x2_ca4'] == $val) ? "selected" : ""; echo "<option value='{$val}' {$selected}>{$val}</option>"; } ?>
                                </select>
                            </div>
                            <div class="row-flex row-gap-8 row-ml-auto">
                                <span class="field-label">버전 : </span>
                                <input type="text" name="x2_ver" id="id_x2_ver" value="<?php echo $default_ver; ?>" size="12" placeholder="버전">
                            </div>
                        </div>
                    </td>
                </tr>
                <tr>
                    <td class="td-label"><i class="fa-solid fa-coins"></i> 자산 종목</td>
                    <td class="td-content">
                        <div class="row-flex">
                            <span class="field-label">핀 : </span>
                            <label class="toggle-btn">
                                <input type="checkbox" name="x2_pin" id="id_x2_pin" value="1" <?php echo !empty($write['x2_pin']) ? 'checked' : ''; ?>>
                                <span class="slider"></span>
                            </label>
                            <span class="field-label">라벨 : </span>
                            <label class="toggle-btn">
                                <input type="checkbox" name="x2_label" id="id_x2_label" value="1" <?php echo !empty($write['x2_label']) ? 'checked' : ''; ?>>
                                <span class="slider"></span>
                            </label>
                            <span class="field-label">포인트 : </span>
                            <label class="toggle-btn">
                                <input type="checkbox" name="x2_point" id="id_x2_point" value="1" <?php echo !empty($write['x2_point']) ? 'checked' : ''; ?>>
                                <span class="slider"></span>
                            </label>
                            <span class="field-label">완료 : </span>
                            <label class="toggle-btn">
                                <input type="checkbox" name="x2_end" id="id_x2_x2_end" value="1" <?php echo !empty($write['x2_end']) ? 'checked' : ''; ?>>
                                <span class="slider"></span>
                            </label>
                            <span class="field-label field-gap-left">태그 : </span>
                            <div class="form-group form-flex-1">
                                <input type="text" name="wr_1" id="id_tag" value="<?php echo isset($write['wr_1']) ? $write['wr_1'] : ''; ?>" class="w-full" placeholder="콤마로 구분된 태그">
                            </div>
                        </div>
                    </td>
                </tr>
                <tr>
                    <td class="td-content" colspan="2">
                        <textarea name="wr_subject" id="wr_subject" rows="6" class="w-full" placeholder="메모 내용을 입력하세요"><?php echo isset($write['wr_subject']) ? $write['wr_subject'] : ''; ?></textarea>
                    </td>
                </tr>
            </table>

            <button type="button" id="btn_extra_toggle" class="btn-toggle-clean" onclick="toggleExtraArea()">
                상세 파라미터 및 페이로드 관리 <i class="fa-solid <?php echo $has_data ? 'fa-chevron-up' : 'fa-chevron-down'; ?>" style="margin-left:8px;"></i>
            </button>

            <div id="extra_area" class="extra-area <?php echo $extra_area_class; ?>">
                <table class="write-table">
                    <tr>
                        <td class="td-label"><i class="fa-solid fa-paperclip"></i> 페이로드 첨부</td>
                        <td class="td-content">
                            <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-box-custom <?php echo $is_active; ?>" id="f_row_<?php echo $i; ?>">
                                    <label for="bf_file_<?php echo $i; ?>" class="file-btn-ui">파일 선택</label>
                                    <input type="file" name="bf_file[<?php echo $i; ?>]" id="bf_file_<?php echo $i; ?>" class="file-hidden" onchange="updateFileInfo(this, <?php echo $i; ?>)">
                                    
                                    <span id="f_name_<?php echo $i; ?>" class="file-info-ui">
                                        <?php echo (isset($file[$i]['file']) && $file[$i]['file']) ? $file[$i]['source'] : "데이터 없음"; ?>
                                    </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-ui" placeholder="파일 설명">
                                    <?php } ?>

                                    <?php if($w == 'u' && isset($file[$i]['file']) && $file[$i]['file']) { ?>
                                        <label class="file-del-label"><input type="checkbox" name="bf_file_del[<?php echo $i; ?>]" value="1"> 삭제</label>
                                    <?php } ?>
                                </div>
                                <?php } ?>
                            </div>
                            <button type="button" class="btn-toggle-clean btn-slot-add" onclick="addFileSlot();">+ 슬롯 추가</button>
                        </td>
                    </tr>
                    <!-- [링크 추가] 페이로드 첨부 아래 -->
                    <?php for ($i=1; $is_link && $i<=2; $i++) { ?>
                    <tr>
                        <td class="td-label"><i class="fa-solid fa-link"></i> 링크 #<?php echo $i ?></td>
                        <td class="td-content">
                            <input type="text" name="wr_link<?php echo $i ?>" value="<?php if($w=="u"){echo$write['wr_link'.$i];} ?>" class="frm_input w-full" size="50" placeholder="링크 URL을 입력하세요">
                        </td>
                    </tr>
                    <?php } ?>
                </table>
            </div>

            <div class="write-foot">
                <button type="submit" class="btn-submit">데이터 저장</button>
            </div>
        </form>
    </article>
</div>

<?php include_once($board_skin_path.'/write/write.script.php'); ?>