<?
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가 

include_once("$g4[path]/lib/check_datetime.lib.php"); //남은날짜

$bo_w1 = $width;
$bo_w2 = $bo_w1 - 16;
$bo_w3 = $bo_w1 - 26;
$bo_w4 = $bo_w1 - 52;
$bo_w5 = $bo_w1 - 42;
$bo_w6 = $bo_w1 - 252;
$bo_w7 = $bo_w1 - 46;
$bo_w8 = $bo_w1 - 12;
$bo_w9 = $bo_w1 - 80;

$today_time = date("Y-m-d H:i:s"); //오늘 날짜
?>
<link rel="stylesheet" href="<?=$board_skin_path?>/board_style.css" type="text/css">
<!-- 게시글 보기 시작 -->
<table width="<?=$width?>" align="center" cellpadding="0" cellspacing="0" border="0"><tr height="5"><td></td></tr><tr><td>
<!-- 링크 버튼 -->
<? 
ob_start(); 
?>
<table width='100%' cellpadding=0 cellspacing=0 border=0>
<tr height=35>
    <td width=75%>
        <? if ($search_href) { echo "<a href=\"$search_href\"><img src='$board_skin_path/img/btn_search_list.gif' border='0' align='absmiddle'></a> "; } ?>
        <? echo "<a href=\"$list_href\"><img src='$board_skin_path/img/btn_list.gif' border='0' align='absmiddle'></a> "; ?>

        <? if ($write_href) { echo "<a href=\"$write_href\"><img src='$board_skin_path/img/btn_write.gif' border='0' align='absmiddle'></a> "; } ?>
        <? if ($reply_href) { echo "<a href=\"$reply_href\"><img src='$board_skin_path/img/btn_reply.gif' border='0' align='absmiddle'></a> "; } ?>

        <? if ($update_href) { echo "<a href=\"$update_href\"><img src='$board_skin_path/img/btn_update.gif' border='0' align='absmiddle'></a> "; } ?>
        <? if ($delete_href) { echo "<a href=\"$delete_href\"><img src='$board_skin_path/img/btn_delete.gif' border='0' align='absmiddle'></a> "; } ?>

        <? if ($good_href) { echo "<a href=\"$good_href\" target='hiddenframe'><img src='$board_skin_path/img/btn_good.gif' border='0' align='absmiddle'></a> "; } ?>
        <? if ($nogood_href) { echo "<a href=\"$nogood_href\" target='hiddenframe'><img src='$board_skin_path/img/btn_nogood.gif' border='0' align='absmiddle'></a> "; } ?>

        <? if ($scrap_href) { echo "<a href=\"javascript:;\" onclick=\"win_scrap('$scrap_href');\"><img src='$board_skin_path/img/btn_scrap.gif' border='0' align='absmiddle'></a> "; } ?>

        <? if ($copy_href) { echo "<a href=\"$copy_href\"><img src='$board_skin_path/img/btn_copy.gif' border='0' align='absmiddle'></a> "; } ?>
        <? if ($move_href) { echo "<a href=\"$move_href\"><img src='$board_skin_path/img/btn_move.gif' border='0' align='absmiddle'></a> "; } ?>
    </td>
    <td width=25% align=right>
        <? if ($prev_href) { echo "<a href=\"$prev_href\" title=\"$prev_wr_subject\"><img src='$board_skin_path/img/btn_prev.gif' border='0' align='absmiddle'></a>&nbsp;"; } ?>
        <? if ($next_href) { echo "<a href=\"$next_href\" title=\"$next_wr_subject\"><img src='$board_skin_path/img/btn_next.gif' border='0' align='absmiddle'></a>&nbsp;"; } ?>
    </td>
</tr>
</table>
<?
$link_buttons = ob_get_contents();
ob_end_clean();
?>
<table width="<?=$bo_w1?>" cellpadding="0" cellspacing="0" border="0" align="center">
<tr>
	<td colspan="2" width="8" height="5"><img src="<?=$board_skin_path?>/img/box1.gif" width="8" height="5"></td>
	<td bgcolor="#e1e2da" width="<?=$bo_w2?>" height="5"></td>
	<td colspan="2" width="8" height="5"><img src="<?=$board_skin_path?>/img/box2.gif" width="8" height="5"></td>
</tr>
<tr>
	<td colspan="2" width="8" height="3"><img src="<?=$board_skin_path?>/img/box1_2.gif" width="8" height="3"></td>
	<td width="<?=$bo_w2?>" height="3"></td>
	<td colspan="2" width="8" height="3"><img src="<?=$board_skin_path?>/img/box2_2.gif" width="8" height="3"></td>
</tr>
<tr>
	<td bgcolor="#e1e2da" width="5"></td>
	<td width="3"></td>
	<td style="padding:5 5 5 5px;">
<div id="subject">
<table width="<?=$bo_w3?>" cellpadding="0" cellspacing="0" border="0" align="center">
<tr>
	<td colspan="2" width="3" height="1"><img src="<?=$board_skin_path?>/img/i_box1.gif" width="3" height="1"></td>
	<td bgcolor="#ededdb" width="<?=$bo_w5?>" height="1"></td>
	<td colspan="2" width="3" height="1"><img src="<?=$board_skin_path?>/img/i_box2.gif" width="3" height="1"></td>
</tr>
<tr>
	<td colspan="2" width="3" height="2"><img src="<?=$board_skin_path?>/img/i_box1_2.gif" width="3" height="2"></td>
	<td bgcolor="#f2f5ec" width="<?=$bo_w5?>" height="2"></td>
	<td colspan="2" width="3" height="2"><img src="<?=$board_skin_path?>/img/i_box2_2.gif" width="3" height="2"></td>
</tr>
<tr>
	<td bgcolor="#ededdb" width="1"></td>
	<td bgcolor="#f2f5ec" width="2"></td>
	<td bgcolor="#f2f5ec" style="padding:0 5 0 5px;">
<table width="<?=$bo_w4?>" cellpadding="0" cellspacing="0" border="0" align="center">
<tr>
	<td width="<?=$bo_w4?>" height="40" colspan="2"><span id="writeSubject"><span class="v_sub"><?=cut_hangul_last(get_text($view[wr_subject]))?></span></span></td>
</tr>
<tr>
	<td background="<?=$board_skin_path?>/img/sub_dot.gif" width="<?=$bo_w4?>" height="1" colspan="2"></td>
</tr>
<tr>
	<td width="<?=$bo_w6?>" height="40"><span class="v_name"><?=$view[name]?><? if ($is_ip_view) { echo "&nbsp;($ip)"; } ?></span></td>
	<td width="200" height="40" align="right"><span style="color:#777777; font-size:11px; font-family:굴림; font-weight:bold;">답변</span>&nbsp;<span style="color:#f0761c; font-weight:bold;" class='small'><?=$view[wr_comment]?></span>&nbsp;&nbsp;<span style="color:#cccccc;" class="small">|</span>&nbsp;&nbsp;<span style="color:#777777; font-size:11px; font-family:굴림; font-weight:bold;">조회</span>&nbsp;<span style="color:#777777;" class='small'><?=$view[wr_hit]?></span></td>
</tr>
</table></td>
	<td bgcolor="#f2f5ec" width="2"></td>
	<td bgcolor="#ededdb" width="1"></td>
</tr>
<tr>
	<td colspan="2" width="3" height="2"><img src="<?=$board_skin_path?>/img/i_box3_2.gif" width="3" height="2"></td>
	<td bgcolor="#f2f5ec" width="<?=$bo_w5?>" height="2"></td>
	<td colspan="2" width="3" height="2"><img src="<?=$board_skin_path?>/img/i_box4_2.gif" width="3" height="2"></td>
</tr>
<tr>
	<td colspan="2" width="3" height="1"><img src="<?=$board_skin_path?>/img/i_box3.gif" width="3" height="1"></td>
	<td bgcolor="#ededdb" width="<?=$bo_w5?>" height="1"></td>
	<td colspan="2" width="3" height="1"><img src="<?=$board_skin_path?>/img/i_box4.gif" width="3" height="1"></td>
</tr>
</table>
</div>
<div id="content" style="padding:10 10 20 10px;">
<table width="<?=$bo_w7?>" cellpadding="0" cellspacing="0" border="0" align="center">
<tr>
	<td height="20">
<?
// 남은 기간 메세지
if ($view[wr_2] != '0')
{
    $gap_msg = "답변이 완료된 질문입니다.";
    $is_magam = true;
}
else if ($view[wr_6] == '1')
{
    $gap_msg = "미해결 질문입니다.";
    $is_magam = true;
}
else if ($g4[time_ymdhis] >= $view[wr_3] && $view[wr_2] == '0')
{
    $gap_msg = "답변 기간이 지난 질문입니다.";
    $is_magam = true;
}
else
{
    $gap = gap_time_ac(strtotime($g4[time_ymdhis]), strtotime($view[wr_3]));
    $gap_msg = "답변기간이 ";
    $is_magam = false;

    if ($gap[days]) {
	$gap_msg .= "{$gap[days]}일";
    }
    else if ($gap[hours]) {
	$gap_msg .= "{$gap[hours]}시간";
    }
    else if ($gap[minutes]) {
	$gap_msg .= "{$gap[minutes]}시간";
    }
    else if ($gap[seconds]) {
	$gap_msg .= "{$gap[seconds]}시간";
    }
    $gap_msg .= " 남았습니다.";
}
?>
<img src="<?=$board_skin_path?>/img/icon_time.gif" align="absmiddle"> <span class="v_date_end"><?=$gap_msg?></span> <span class="v_date">(<?=substr($view[wr_datetime],2,14)?> 작성)</span>
</td>
</tr>
<?
// 가변 파일

$cnt = 0;
$table_line = 0;
for ($i=0; $i<count($view[file]); $i++) 
{
    if ($view[file][$i][source] && !$view[file][$i][view]) 
    {
		
        $cnt++;
		$table_line = 1;
        echo "<tr><td height=30 style='padding:0 0 0 2px;'><img src='{$board_skin_path}/img/icon_file.gif' align=absmiddle><span style='padding:0 0 0 6px;'>참고자료</span> : <a href=\"javascript:file_download('{$view[file][$i][href]}', '{$view[file][$i][source]}');\" title='{$view[file][$i][content]}'><strong>{$view[file][$i][source]}</strong></a> (<font style='font-size:8pt;'>{$view[file][$i][size]}</font>)</td></tr>";
    }
}?>
<tr>
	<td height="10"></td>
</tr>
<tr>
	<td style="word-break:break-all;">
        <? 
        // 파일 출력
        for ($i=0; $i<=count($view[file]); $i++) {
            if ($view[file][$i][view]) 
                echo $view[file][$i][view] . "<p>";
        }
        ?>

        <!-- 내용 출력 -->
        <span class="v_con"><?=$view[content];?></span>
        
        <?//echo $view[rich_content]; // {이미지:0} 과 같은 코드를 사용할 경우?>
        <!-- 테러 태그 방지용 --></xml></xmp><a href=""></a><a href=''></a></td>
</tr>
<tr>
	<td height="10"></td>
</tr>
<?
// 답변 기간이 지나지 않았거나 답변 채택을 하지 않았을 때
if ($g4[time_ymdhis] < $view[wr_3] && $view[wr_2] == '0') {
?>
<tr>
	<td bgcolor="#ebebeb" height="1"></td>
</tr>
<tr>
	<td height="20"></td>
</tr>
<tr>
	<td>
<span class="v_msg">이 질문에 답변하시면 <span class="v_msg2">포인트 <?=number_format($board[bo_comment_point]);?>점</span> (답변 채택시 <span class="v_msg2">+<?=number_format($view[wr_1]);?>점</span>) 을 드립니다.</span></td>
</tr>
<? } ?>
</table>
</div></td>
	<td width="3"></td>
	<td bgcolor="#e1e2da" width="5"></td>
</tr>
<tr>
	<td colspan="2" width="8" height="3"><img src="<?=$board_skin_path?>/img/box3_2.gif" width="8" height="3"></td>
	<td width="<?=$bo_w2?>" height="3"></td>
	<td colspan="2" width="8" height="3"><img src="<?=$board_skin_path?>/img/box4_2.gif" width="8" height="3"></td>
</tr>
<tr>
	<td colspan="2" width="8" height="5"><img src="<?=$board_skin_path?>/img/box3.gif" width="8" height="5"></td>
	<td bgcolor="#e1e2da" width="<?=$bo_w2?>" height="5"></td>
	<td colspan="2" width="8" height="5"><img src="<?=$board_skin_path?>/img/box4.gif" width="8" height="5"></td>
</tr>
<?
include_once("./view_comment_nkin.php");
?>
</table>
<?=$link_buttons?>
</td></tr></table>

<script language="JavaScript">
function file_download(link, file) {
    <? if ($board[bo_download_point] < 0) { ?>if (confirm("'"+file+"' 파일을 다운로드 하시면 포인트가 차감(<?=number_format($board[bo_download_point])?>점)됩니다.\n\n포인트는 게시물당 한번만 차감되며 다음에 다시 다운로드 하셔도 중복하여 차감하지 않습니다.\n\n그래도 다운로드 하시겠습니까?"))<?}?>
    document.location.href=link;
}
</script>

<script language="JavaScript" src="<?="$g4[path]/js/board.js"?>"></script>
<script language="JavaScript">
window.onload=function() {
    resizeBoardImage(<?=(int)$board[bo_image_width]?>);
    drawFont();
}
</script>
<!-- 게시글 보기 끝 -->