<?php
if (!defined('_GNUBOARD_')) exit;
// 외부 DB 연결
include_once('/home/www/DB/db_upbit.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="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.list.css">', 0);
error_reporting(E_ALL & ~E_NOTICE);
ini_set('display_errors', '0');
// 데이터 로드
$new_board = sql_query("select * from $write_table order by wr_datetime desc limit 1");
$lat_board = sql_fetch_array($new_board);
?>
<div id="SPACE_WRAP">
<div class="nebula"></div>
<div id="stars-container"></div>
<article id='LIST'>
<section class="TopTitle">
<p><?php echo strtoupper($bo_table); ?></p>
<span><i class="fa-solid fa-satellite"></i> <?php echo $board["bo_subject"]; ?></span>
</section>
<div class="Control-Bar">
<div class="ctrl-group">
<button type="button" onclick="$('#NoticeLayer').fadeIn();"><i class="fa-solid fa-bullhorn"></i> NOTICE</button>
<?php if ($is_category) { ?>
<select onchange="location.href=this.value;">
<option value="<?php echo get_pretty_url($bo_table); ?>">분류</option>
<?php
$categories = explode('|', $board['bo_category_list']);
foreach($categories as $ca) {
if(!$ca) continue;
$selected = ($sca == $ca) ? "selected" : "";
echo "<option value='".get_pretty_url($bo_table, '', 'sca='.urlencode($ca))."' $selected>$ca</option>";
}
?>
</select>
<select onchange="location.href=this.value;">
<option value="">종류</option>
<?php
$sql2 = "select distinct x2_ca2 from $write_table where x2_ca2 <> '' order by x2_ca2";
$res2 = sql_query($sql2);
while($row2 = sql_fetch_array($res2)) {
$selected = ($stx == $row2['x2_ca2']) ? "selected" : "";
echo "<option value='".get_pretty_url($bo_table, '', 'sfl=x2_ca2&stx='.urlencode($row2['x2_ca2']))."' $selected>".$row2['x2_ca2']."</option>";
}
?>
</select>
<select onchange="location.href=this.value;">
<option value="">형태</option>
<?php
$sql3 = "select distinct x2_ca3 from $write_table where x2_ca3 <> '' order by x2_ca3";
$res3 = sql_query($sql3);
while($row3 = sql_fetch_array($res3)) {
$selected = ($stx == $row3['x2_ca3']) ? "selected" : "";
echo "<option value='".get_pretty_url($bo_table, '', 'sfl=x2_ca3&stx='.urlencode($row3['x2_ca3']))."' $selected>".$row3['x2_ca3']."</option>";
}
?>
</select>
<?php } ?>
</div>
<div class="ctrl-group">
<!-- 실시간 검색 입력 폼 추가 -->
<input type="text" id="realtime_search" class="input-realtime" placeholder="Quick Filter (Table/Name)...">
<button type="button" onclick="$('#SCH').css('display','flex').fadeIn();"><i class="fa-solid fa-magnifying-glass"></i> SEARCH</button>
<?php if ($is_admin) { ?>
<button type="button" onclick="location.href='<?php echo G5_ADMIN_URL; ?>/board_form.php?w=u&bo_table=<?php echo $bo_table; ?>'" style="background:#475569; color:#fff;"><i class="fa-solid fa-gear"></i> ADMIN</button>
<?php } ?>
<?php if ($write_href) { ?>
<button type="button" onclick="location.href='<?php echo $write_href; ?>'" style="background:var(--accent-blue); color:#000; font-weight:bold;"><i class="fa-solid fa-pen"></i> WRITE</button>
<?php } ?>
</div>
</div>
<form name="fboardlist" id="fboardlist" action="./board_list_update.php" method="post">
<input type="hidden" name="bo_table" value="<?php echo $bo_table; ?>">
<table class="List-Table">
<thead>
<tr class="List-Header">
<th class="Num">번호</th>
<th class="Run">분류</th>
<th class="korea_name">이름</th>
<th class="subject">테이블</th>
<th class="event"></th>
<th class="daemon">데몬 / <span class="txt-events">이벤트</span></th>
<th class="memo">간략설명</th>
<th class="ca2">종류</th>
<th class="ca3">형태</th>
<th class="day">날짜</th>
</tr>
</thead>
<tbody id="main_list_body">
<?php
for ($i=0; $i<count($list); $i++) {
$is_notice = $list[$i]['is_notice'];
$delay = ($i * 0.03) + 0.2;
$run_val = $list[$i]['ca_name'];
if (($run_val == '업비트')) {
$run_text = '업비트';
$run_class = 'run_on';
} else if (($run_val == '바이비트')) {
$run_text = '바이비트';
$run_class = 'run_on2';
} else if (($run_val == '데몬')) {
$run_text = '데몬';
$run_class = 'run_off';
} else {
$run_text = '-';
$run_class = '';
}
?>
<tr class="list-row" onclick="location.href='<?php echo $list[$i]['href']; ?>'" style="animation-delay: <?php echo $delay; ?>s;">
<td class="Num">
<?php if ($is_notice) echo '<i class="fa-solid fa-thumbtack" style="color:var(--accent-blue)"></i>'; else echo $list[$i]['num']; ?>
</td>
<td class="Run">
<span class="run_btn <?php echo $run_class; ?>"><?php echo $run_text; ?></span>
</td>
<td class="korea_name">
<span><?php echo $list[$i]['wr_subject_kor'] ?: '-'; ?></span>
</td>
<td class="subject">
<span><?php echo $list[$i]['wr_subject']; ?></span>
</td>
<td class="event">
<span><i class="fa-solid fa-right-left"></i></span>
</td>
<td class="daemon">
<?php if ($list[$i]['x2_daemon']) { ?>
<span><?php echo $list[$i]['x2_daemon']; ?></span>
<?php } else if ($list[$i]['x2_events']) { ?>
<span class="txt-events"><?php echo $list[$i]['x2_events']; ?></span>
<?php } else { ?>
<span style="color:#ddd;">MULTI</span>
<?php } ?>
</td>
<td class="memo">
<span><?php echo $list[$i]['wr_1'] ?: 'No memo'; ?></span>
</td>
<td class="ca2"><?php echo $list[$i]['x2_ca2'] ?: "-"; ?></td>
<td class="ca3"><?php echo $list[$i]['x2_ca3'] ?: "-"; ?></td>
<td class="day">
<?php echo date("y-m-d", strtotime($list[$i]['wr_datetime'])); ?>
<span style="font-size:0.7rem; opacity:0.5;"><?php echo date("H:i", strtotime($list[$i]['wr_datetime'])); ?></span>
</td>
</tr>
<?php } ?>
<?php if (count($list) == 0) echo "<tr><td colspan='11' style='text-align:center; padding:100px; color:var(--text-dim);'>No system configurations found.</td></tr>"; ?>
</tbody>
</table>
</form>
<div class="Pagination">
<?php echo $write_pages; ?>
</div>
<div id="NoticeLayer" class="NoticeLayer">
<h3><i class="fa-solid fa-terminal"></i> SYSTEM NOTICE</h3>
<div class="notice-content">
<?php echo nl2br(stripslashes($board['notice'])); ?>
</div>
<div class="modal-footer">
<div>
<?php if ($is_admin) { ?>
<button type="button" onclick="window.open('<?php echo $board_skin_url;?>/notice.php?bo_table=<?php echo $bo_table;?>', 'notice_win', 'width=800,height=700,left='+(screen.availWidth-800)/2+',top='+(screen.availHeight-600)/2);" style="background:var(--accent-purple); color:#fff; border:none;">WRITE NOTICE</button>
<?php } ?>
</div>
<button type="button" onclick="$('#NoticeLayer').fadeOut();">DISMISS</button>
</div>
</div>
<section id="SCH">
<div class="search-box">
<form name="fsearch" method="get">
<input type="hidden" name="bo_table" value="<?php echo $bo_table; ?>">
<h3>TERMINAL SEARCH</h3>
<input type="text" name="stx" value="<?php echo stripslashes($stx); ?>" required placeholder="Keyword entry..." class="search-input">
<div style="margin-top:30px; display:flex; gap:12px;">
<button type="submit" style="flex:1; background:var(--accent-blue); color:#000; font-weight:bold; height:45px;">EXECUTE</button>
<button type="button" onclick="$('#SCH').fadeOut();" style="flex:1; height:45px; background:none; border:1px solid var(--text-dim); color:var(--text-dim);">CANCEL</button>
</div>
</form>
</div>
</section>
</article>
</div>
<?php include_once($board_skin_path.'/list/list.script.php'); ?>