<?php
if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가
include_once(G5_LIB_PATH.'/thumbnail.lib.php');

// 선택옵션으로 인해 셀합치기가 가변적으로 변함
$colspan = 5;

if ($is_checkbox) $colspan++;
if ($is_good) $colspan++;
if ($is_nogood) $colspan++;

// add_stylesheet('css 구문', 출력순서); 숫자가 작을 수록 먼저 출력됨
//add_stylesheet('<link rel="stylesheet" href="'.$board_skin_url.'/style.css">', 0);
add_stylesheet('<link rel="stylesheet" href="'.$board_skin_url.'/autoptimize_bbs.css">', 0);
?>

<?php
// 날짜 계산 함수
function passing_time($datetime) {
	$time_lag = time() - strtotime($datetime);
	
	if($time_lag < 60) {
		$posting_time = "방금";
	} elseif($time_lag >= 60 and $time_lag < 3600) {
		$posting_time = floor($time_lag/60)."분 전";
	} elseif($time_lag >= 3600 and $time_lag < 86400) {
		$posting_time = floor($time_lag/3600)."시간 전";
	} elseif($time_lag >= 86400 and $time_lag < 2419200) {
		$posting_time = floor($time_lag/86400)."일 전";
	} else {
		$posting_time = date("y-m-d", strtotime($datetime));
	} 
	
	return $posting_time;
}
?>
<?php
$g5['title'] = "대메뉴2";
$g5['sub_title'] = "";

$g5['visual_tit'] = "웹진형";
$g5['visual_txt'] = "All progress takes place outside the comfort zone.";

?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="<?php echo G5_THEME_URL?>/css/sub.css">
    <link rel="stylesheet" href="<?php echo G5_THEME_URL?>/css/common.css">
</head>
<style>
    .sec {
        width:100%;
    }
    .board .inner {
        width:1240px;
        padding:5% 20px;
        margin:0 auto;
        position:relative;
    }
    .board {
        background-color:#fff;

    }
    .board .content {
        width:100%;
        overflow:hidden;
        padding-bottom:2%;
    }
    .board .fl_box {
        float:left;
        width:60%;
    }
    .board h3 {
        font-size:2em;
        font-weight:bold;
        color:#333;
        padding-top:4%;
        padding-bottom:5%;
    }
    .board_txt {
        font-size:1.1em;
        font-weight:400;
        color:#969696;
        width:70%;
        padding-bottom:5%;
    }
    .board .rt_box {
        float:left;;
        width:40%;
        text-align:center;
    }
    @media screen and (max-width:1200px) {
        .sec {
        width:100%;
        }
        .board .inner {
            width:100%;
            padding:5% 20px;
            margin:0 auto;
            position:relative;
        }
        .board {
            background-color:#fff;

        }
        .board .content {
            width:100%;
            overflow:hidden;
            padding-bottom:2%;
        }
        .board .fl_box {
            float:none;
            width:100%;
        }
        .board h3 {
            font-size:2em;
            font-weight:bold;
            color:#333;
            padding-top:4%;
            padding-bottom:5%;
            text-align:center;
        }
        .board_txt {
            font-size:1.1em;
            font-weight:400;
            color:#969696;
            width:100%;
            padding-bottom:5%;
            text-align:center;
        }
        .board .rt_box {
            float:none;
            width:100%;
            text-align:center;
        }
    }
</style>
<body>
    <div class="sub sub01" id="business01">
        <?php include_once(G5_THEME_PATH.'/head.php'); ?>
        <?php include_once(G5_THEME_PATH.'/sub/sub_visual.php');?>
        <div class="sub_tab">
            <div class="inner">
                <ul>
                    <li><a href="../bbs/board.php?bo_table=gallery2">갤러리형</a></li>
                    <li><a href="../bbs/board.php?bo_table=list">리스트형</a></li>
                    <li class="on"><a href="../bbs/board.php?bo_table=webzine">웹진형</a></li>
                </ul>
            </div>
        </div>
        <section class="sec sec1 board">
            <article class="inner">
 
                <form name="fboardlist" id="fboardlist" action="./board_list_update.php" onsubmit="return fboardlist_submit(this);" method="post">
							<input type="hidden" name="bo_table" value="<?php echo $bo_table ?>">
							<input type="hidden" name="sfl" value="<?php echo $sfl ?>">
							<input type="hidden" name="stx" value="<?php echo $stx ?>">
							<input type="hidden" name="spt" value="<?php echo $spt ?>">
							<input type="hidden" name="sca" value="<?php echo $sca ?>">
							<input type="hidden" name="sst" value="<?php echo $sst ?>">
							<input type="hidden" name="sod" value="<?php echo $sod ?>">
							<input type="hidden" name="page" value="<?php echo $page ?>">
							<input type="hidden" name="sw" value="">

                            <?php
                                for ($i=0; $i<count($list); $i++) {
                            ?>
                            <div class="content">
                                <div class="fl_box">
                                    <?php if ($is_checkbox) { ?><input type="checkbox" name="chk_wr_id[]" value="<?php echo $list[$i]['wr_id'] ?>" id="chk_wr_id_<?php echo $i ?>"><?php } ?>
                                    <h3 class="mt-0 mb-4">
                                        <a href="#" onclick="location.href='<?php echo $list[$i]['href'] ?>'"><?php echo $list[$i]['subject'] ?></a>
                                    </h3>
                                    <p class="board_txt"><?php echo cut_str(strip_tags($list[$i]['wr_content']),160," . . . ") ?></p>
                                </div>
                                <div class="rt_box">
                                    <a href="<?php echo $list[$i]['href'] ?>">
                                        <?php
                                                $thumb = get_list_thumbnail($board['bo_table'], $list[$i]['wr_id'], $board['bo_gallery_width'], $board['bo_gallery_height'], false, true);
                                            
                                                if($thumb['src']) {
                                                    $img_content = '<img src="'.$thumb['src'].'" alt="'.$thumb['alt'].'" >';
                                                } else {
                                                    $img_content = '<img src="'.$board_skin_url.'/img/noimage.png" alt="" />';
                                                }
                                                echo $img_content;
                                        ?>
                                    </a>
                                </div>
                                <div class="clear_box"></div>
                            </div>

                        <?php
                            }
                        ?>
                </form>

                <?php if($is_checkbox) { ?>
                <noscript>
                <p>자바스크립트를 사용하지 않는 경우<br>별도의 확인 절차 없이 바로 선택삭제 처리하므로 주의하시기 바랍니다.</p>
                </noscript>
                <?php } ?>



                <!-- 페이지 -->
                <?php echo $write_pages;  ?>


                <?php if ($is_checkbox) { ?>
                <script>
                function all_checked(sw) {
                    var f = document.fboardlist;

                    for (var i=0; i<f.length; i++) {
                        if (f.elements[i].name == "chk_wr_id[]")
                            f.elements[i].checked = sw;
                    }
                }

                function fboardlist_submit(f) {
                    var chk_count = 0;

                    for (var i=0; i<f.length; i++) {
                        if (f.elements[i].name == "chk_wr_id[]" && f.elements[i].checked)
                            chk_count++;
                    }

                    if (!chk_count) {
                        alert(document.pressed + "할 게시물을 하나 이상 선택하세요.");
                        return false;
                    }

                    if(document.pressed == "선택복사") {
                        select_copy("copy");
                        return;
                    }

                    if(document.pressed == "선택이동") {
                        select_copy("move");
                        return;
                    }

                    if(document.pressed == "선택삭제") {
                        if (!confirm("선택한 게시물을 정말 삭제하시겠습니까?\n\n한번 삭제한 자료는 복구할 수 없습니다\n\n답변글이 있는 게시글을 선택하신 경우\n답변글도 선택하셔야 게시글이 삭제됩니다."))
                            return false;

                        f.removeAttribute("target");
                        f.action = "./board_list_update.php";
                    }

                    return true;
                }

                // 선택한 게시물 복사 및 이동
                function select_copy(sw) {
                    var f = document.fboardlist;

                    if (sw == "copy")
                        str = "복사";
                    else
                        str = "이동";

                    var sub_win = window.open("", "move", "left=50, top=50, width=500, height=550, scrollbars=1");

                    f.sw.value = sw;
                    f.target = "move";
                    f.action = "./move.php";
                    f.submit();
                }
                </script>
                <?php } ?>
                <!-- } 게시판 목록 끝 -->

            </article>
        </section>
    </div>
</body>

