<?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);
// [삭제됨] 업비트용 기존 코인 리스트 추출(Select용) 로직 제거함
// 바이비트는 워낙 종류가 많아서 직접 입력(Input)이 정답입니다 오빠.
// 5. 마진 단위(USDT/USD) 기본값 설정
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'] ? $row_ver['x2_ver'] : "USDT";
} else {
$default_ver = $write['x2_ver'];
}
$file_count = (isset($board['bo_upload_count']) && $board['bo_upload_count']) ? $board['bo_upload_count'] : 0;
?>
<style>
@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&family=JetBrains+Mono:wght@400;700&display=swap');
:root {
--neon-cyan: #00d4ff; --neon-pink: #ff2d55; --bg-black: #0d1117;
--panel-bg: #161b22; --input-bg: #0d1117; --border-color: #30363d;
--text-dim: #8b949e; color-scheme: dark;
}
.toggle-switch { position: relative; display: inline-block; width: 44px; height: 20px; vertical-align: middle; margin: 0 5px; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: var(--input-bg); border: 1px solid var(--border-color); transition: .3s; border-radius: 20px; }
.slider:before { position: absolute; content: ""; height: 12px; width: 12px; left: 3px; bottom: 3px; background-color: var(--text-dim); transition: .3s; border-radius: 50%; }
input:checked + .slider { background-color: rgba(255, 45, 85, 0.2); border-color: var(--neon-pink); }
input:checked + .slider:before { transform: translateX(24px); background-color: var(--neon-pink); box-shadow: 0 0 8px var(--neon-pink); }
.toggle-label { font-family: 'Orbitron'; font-size: 0.6rem; color: var(--text-dim); letter-spacing: 1px; }
#CYBER_LOADER { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: var(--bg-black); z-index: 10000; display: flex; flex-direction: column; align-items: center; justify-content: center; transition: opacity 0.5s ease; }
.load-text { font-family: 'Orbitron'; color: var(--neon-cyan); letter-spacing: 3px; margin-bottom: 20px; font-size: 0.9rem; }
.load-bar-wrap { width: 200px; height: 1px; background: rgba(255,255,255,0.1); position: relative; }
.load-bar { width: 0%; height: 100%; background: var(--neon-cyan); animation: loadingProgress 1.5s forwards; }
@keyframes loadingProgress { to { width: 100%; } }
#WRITE_WRAP { position: relative; min-height: 100vh; background: var(--bg-black); padding: 40px 0; font-family: 'Pretendard', sans-serif; color: #c9d1d9; overflow-x: hidden; }
#space-canvas { position: fixed; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 1; opacity: 0.2; }
#WRITE { position: relative; z-index: 2; width: calc(100% - 100px); margin: 0 50px; max-width: none !important; animation: fadeIn 0.6s ease-out; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
#fwrite { background: var(--panel-bg); border: 1px solid var(--border-color); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,0.5); overflow: hidden; position: relative; }
#fwrite::before, #fwrite::after { content: ''; position: absolute; width: 30px; height: 30px; border: 2px solid var(--neon-cyan); z-index: 10; pointer-events: none; }
#fwrite::before { top: -1px; left: -1px; border-right: 0; border-bottom: 0; border-radius: 8px 0 0 0; }
#fwrite::after { bottom: -1px; right: -1px; border-left: 0; border-top: 0; border-radius: 0 0 8px 0; }
.form-header { padding: 20px 30px; border-bottom: 1px solid var(--border-color); display: flex; justify-content: space-between; align-items: center; background: linear-gradient(90deg, rgba(0, 212, 255, 0.05), transparent); }
.form-header h2 { margin:0; font-family: 'Orbitron'; font-size: 1rem; color: var(--neon-cyan); font-weight: 700; letter-spacing: 1px; }
.write-table { width: 100%; border-collapse: collapse; }
.write-table tr { border-bottom: 1px solid var(--border-color); }
.td-label { width: 160px; padding: 15px 25px; color: var(--text-dim); font-size: 0.7rem; font-family: 'Orbitron'; font-weight: 600; background: rgba(0, 0, 0, 0.15); border-right: 1px solid var(--border-color); text-transform: uppercase; }
.td-label i { margin-right: 8px; color: var(--neon-cyan); font-size: 0.8rem; }
input[type="text"], input[type="date"], input[type="time"], select, textarea { background: var(--input-bg) !important; border: 1px solid var(--border-color) !important; color: #c9d1d9 !important; padding: 8px 12px !important; border-radius: 4px !important; font-size: 0.8rem; transition: 0.2s; font-family: 'JetBrains Mono', monospace; }
select[name="x2_coin"] { width: 200px !important; }
.btn-action { border: 1px solid var(--border-color); background: transparent; color: var(--text-dim); padding: 7px 15px; border-radius: 4px; font-family: 'Orbitron'; font-weight: 600; cursor: pointer; transition: 0.2s; font-size: 0.65rem; }
.btn-save-main { background: var(--neon-cyan); color: #000; padding: 15px 60px; font-size: 0.9rem; font-weight: 800; margin-top: 30px; border: none; border-radius: 6px; transition: 0.3s; cursor: pointer; font-family: 'Orbitron'; letter-spacing: 2px; }
.tag-input-wrap { margin-top: 10px; display: flex; align-items: center; gap: 10px; background: rgba(0,0,0,0.2); padding: 6px 12px; border: 1px solid var(--border-color); border-radius: 4px; border-left: 3px solid var(--neon-pink); }
.file-row { display: none; align-items: center; gap: 10px; margin-bottom: 8px; padding: 10px; background: rgba(255,255,255,0.02); border: 1px solid var(--border-color); border-radius: 4px; border-left: 2px solid var(--neon-cyan); }
.file-row.active { display: flex; }
#Editor-Area { border-top: 1px solid var(--border-color); padding: 20px; background: rgba(0,0,0,0.1); }
</style>
<div id="CYBER_LOADER">
<div class="load-text">READY_SYSTEM</div>
<div class="load-bar-wrap"><div class="load-bar"></div></div>
</div>
<div id="WRITE_WRAP">
<canvas id="space-canvas"></canvas>
<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 class="form-header">
<h2><i class="fa-solid fa-database"></i> DATA_INPUT_MODULE</h2>
<div style="display:flex; gap:8px;">
<button type="button" class="btn-action" onclick="window.history.back();">ABORT</button>
<button type="submit" class="btn-action">SAVE_DATA</button>
</div>
</div>
<table class="write-table">
<tr>
<td class="td-label"><i class="fa-solid fa-sliders"></i> 옵션 세팅</td>
<td style="padding:15px 30px;">
<div style="display:flex; flex-wrap:wrap; gap:10px; align-items:center;">
<?php if ($is_category) { ?>
<span style="color:var(--neon-pink); font-family:'Orbitron'; font-size:0.6rem; font-weight:bold;">분류</span>
<select name="ca_name" required><option value="">CATEGORY</option><?php echo $category_option; ?></select>
<?php } ?>
<span style="color:var(--neon-pink); font-family:'Orbitron'; font-size:0.6rem; font-weight:bold;">타입</span>
<select name="x2_ca2">
<option value=''>SELECT</option>
<?php
$bo_1_opts = explode("|", $board['bo_1']);
foreach($bo_1_opts as $val) {
$val = trim($val); if(!$val) continue;
$selected = ($write['x2_ca2'] == $val) ? "selected" : "";
echo "<option value='{$val}' {$selected}>{$val}</option>";
}
?>
</select>
<span style="color:var(--neon-pink); font-family:'Orbitron'; font-size:0.6rem; font-weight:bold;">코인</span>
<input type="text" name="x2_coin" value="<?php echo $write['x2_coin']; ?>" required
style="width:180px; font-size:0.7rem; font-weight:700; text-transform:uppercase;"
placeholder="예: BTCUSDT"
oninput="this.value=this.value.toUpperCase().replace(/\s+/g,'');">
<span style="color:var(--neon-pink); font-family:'Orbitron'; font-size:0.6rem; font-weight:bold;">포지션</span>
<select name="x2_ca4" required>
<option value=''>SELECT</option>
<?php
$bo_3_opts = explode("|", $board['bo_3']);
foreach($bo_3_opts as $val) {
$val = trim($val); if (!$val) continue;
$selected = ($write['x2_ca4'] == $val) ? "selected" : "";
echo "<option value='{$val}' {$selected}>{$val}</option>";
}
?>
</select>
<span style="color:var(--neon-pink); font-family:'Orbitron'; font-size:0.6rem; font-weight:bold;">가동</span>
<label class="toggle-switch">
<input type="checkbox" name="x2_ca3" value="1" <?php echo ($write['x2_ca3'] == "1") ? "checked" : ""; ?>>
<span class="slider"></span>
</label>
<span class="toggle-label">OFF/ON</span>
<span style="color:var(--neon-pink); font-family:'Orbitron'; font-size:0.6rem; font-weight:bold; margin-left:10px;">마진</span>
<select name="x2_ver" style="width:90px; text-align:center;">
<option value="USDT" <?php echo (strtoupper($default_ver)==='USDT'?'selected':''); ?>>USDT</option>
<option value="USD" <?php echo (strtoupper($default_ver)==='USD'?'selected':''); ?>>USD</option>
</select>
</div>
</td>
</tr>
<tr>
<td class="td-label" style="border-bottom:none;"><i class="fa-solid fa-pen"></i> 아웃라인 설정</td>
<td style="padding:15px 30px; border-bottom: none;">
<div style="display:flex; align-items:center; gap:20px; flex-wrap:wrap;">
<div>
<span style="color:var(--neon-pink); font-family:'Orbitron'; font-size:0.6rem; font-weight:bold;">감시금</span>
<input type="text" name="wr_subject" value="<?php echo $subject; ?>" required style="font-size:0.7rem; font-weight:600; width:120px;" placeholder="감시 금액">
</div>
<div>
<span style="color:var(--neon-pink); font-family:'Orbitron'; font-size:0.6rem; font-weight:bold;">목표선택</span>
<select name="x2_target_type" id="x2_target_type" onchange="toggleTargetInput(this.value)" style="width:100px;">
<option value="amount" <?php echo ($write['x2_target_type'] != 'rate') ? 'selected' : ''; ?>>목표금</option>
<option value="rate" <?php echo ($write['x2_target_type'] == 'rate') ? 'selected' : ''; ?>>목표율</option>
</select>
</div>
<div id="target_amount_wrap">
<span style="color:var(--neon-cyan); font-family:'Orbitron'; font-size:0.6rem; font-weight:bold;">목표금</span>
<input type="text" name="x2_target" value="<?php echo $write['x2_target']; ?>" style="font-size:0.7rem; font-weight:600; width:120px;" placeholder="수익 금액">
</div>
<div id="target_rate_wrap" style="display:none;">
<span style="color:var(--neon-cyan); font-family:'Orbitron'; font-size:0.6rem; font-weight:bold;">목표율(%)</span>
<input type="text" name="x2_rate" value="<?php echo $write['x2_rate']; ?>" style="font-size:0.7rem; font-weight:600; width:120px;" placeholder="목표 수익률">
</div>
</div>
<div class="tag-input-wrap">
<span style="color:var(--neon-pink); font-size:0.7rem; font-weight:bold;"># 태그</span>
<input type="text" name="x2_tag" value="<?php echo $write['x2_tag']; ?>" style="flex:1; border:none !important; background:transparent !important; font-size:0.75rem;">
</div>
</td>
</tr>
</table>
<div id="Editor-Area" style="<?php echo $editor_display; ?>">
<div style="margin-bottom:20px;"><?php echo $editor_html; ?></div>
<div style="padding-top:20px; border-top:1px solid var(--border-color);">
<h3 style="font-family:'Orbitron'; font-size:0.75rem; color:var(--text-dim); margin-bottom:12px;"><i class="fa-solid fa-file-export"></i> PAYLOAD_FILES</h3>
<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; ?>" style="cursor:pointer; color:var(--neon-cyan); font-size:0.65rem;">[SLOT_0<?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:#6e7681; font-size:0.7rem; flex:1; margin-left:10px;">
<?php if($w == 'u' && isset($file[$i]['file']) && $file[$i]['file']) { echo $file[$i]['source']; } else { echo "READY_TO_ATTACH"; } ?>
</span>
</div>
<?php } ?>
</div>
<button type="button" class="btn-action" onclick="file_add();">+ ADD_SLOT</button>
</div>
</div>
<div style="padding:30px 0; text-align:center;"><button type="submit" class="btn-save-main">COMMIT_TO_DATABASE</button></div>
</form>
</article>
</div>
<script>
// 5. 목표선택에 따른 폼 제어 로직
function toggleTargetInput(type) {
const amountWrap = document.getElementById('target_amount_wrap');
const rateWrap = document.getElementById('target_rate_wrap');
if (type === 'amount') {
amountWrap.style.display = 'block';
rateWrap.style.display = 'none';
} else {
amountWrap.style.display = 'none';
rateWrap.style.display = 'block';
}
}
window.addEventListener('load', function() {
// 초기 로드시 설정값에 따른 폼 노출 결정
const initialType = document.getElementById('x2_target_type').value;
toggleTargetInput(initialType);
setTimeout(() => { document.getElementById('CYBER_LOADER').style.opacity = '0'; setTimeout(() => document.getElementById('CYBER_LOADER').style.visibility = 'hidden', 500); }, 800);
});
const canvas = document.getElementById('space-canvas'); const ctx = canvas.getContext('2d'); let stars = [];
function initSpace() { canvas.width = window.innerWidth; canvas.height = window.innerHeight; stars = []; for(let i=0; i<80; i++) stars.push({ x: Math.random() * canvas.width, y: Math.random() * canvas.height, size: Math.random() * 1.1, speed: Math.random() * 0.15 }); }
function animateSpace() { ctx.clearRect(0, 0, canvas.width, canvas.height); ctx.fillStyle = "rgba(201, 209, 217, 0.3)"; stars.forEach(star => { ctx.beginPath(); ctx.arc(star.x, star.y, star.size, 0, Math.PI*2); ctx.fill(); star.y += star.speed; if(star.y > canvas.height) star.y = 0; }); requestAnimationFrame(animateSpace); }
initSpace(); animateSpace(); window.addEventListener('resize', initSpace);
function updateFileName(input, index) { document.getElementById('file_name_' + index).innerText = input.files[0] ? input.files[0].name : "READY_TO_ATTACH"; document.getElementById('file_name_' + index).style.color = "var(--neon-cyan)"; }
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>