476 lines
20 KiB
PHP
476 lines
20 KiB
PHP
<?php
|
|
/**
|
|
* from avocado common.lib
|
|
* @var string|int $year
|
|
* @var string|int $year_pre
|
|
* @var string|int $month_pre
|
|
* @var string|int $sc_no
|
|
*/
|
|
|
|
if (!defined('_GNUBOARD_'))
|
|
exit;
|
|
|
|
//include_once $board_skin_path."/moonday.php"; // 석봉운님의 음력날짜 함수
|
|
|
|
include_once G5_LIB_PATH . '/thumbnail.lib.php';
|
|
|
|
if (preg_match('/%/', $width)) {
|
|
//표의 가로 폭이 100보다 크면 픽셀값입력
|
|
$col_width = "14%";
|
|
} else {
|
|
//표의 가로 폭이 100보다 작거나 같으면 백분율 값을 입력
|
|
$col_width = round($width / 7);
|
|
}
|
|
|
|
//내용 들어갈 사각공간의 세로길이를 가로 폭과 같도록
|
|
$col_height = 80;
|
|
|
|
$offset = $board['bo_3'] ? " " . $board['bo_3'] . " hours" : "";
|
|
$today = date('Ymd', strtotime(date('Y/m/d H:i:s') . $offset));
|
|
$b_mon = date('n', strtotime($today));
|
|
$b_day = date('j', strtotime($today));
|
|
$b_year = date('Y', strtotime($today));
|
|
|
|
// 오늘의 달력 일때
|
|
if ($year < 1) {
|
|
$month = $b_mon;
|
|
$mday = $b_day;
|
|
$year = $b_year;
|
|
}
|
|
|
|
if (!$year)
|
|
$year = date("Y");
|
|
// 기념일 폴더 위치 지정
|
|
$file_index = $board_skin_path . "/day";
|
|
|
|
// 양력 기념일 파일 지정 : 해당년도 파일이 없으면 기본파일(solar.txt)을 불러온다
|
|
// $dayfile = file($file_index."/solar.txt");
|
|
|
|
$lastday = array(0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
|
|
if ($year % 4 == 0)
|
|
$lastday[2] = 29;
|
|
$dayoftheweek = date("w", mktime(0, 0, 0, $month, 1, $year));
|
|
$cday = 1;
|
|
$sel_mon = sprintf("%02d", $month);
|
|
|
|
// add_stylesheet('css 구문', 출력순서); 숫자가 작을 수록 먼저 출력됨
|
|
add_stylesheet('<link rel="stylesheet" href="' . $board_skin_url . '/style.css">', 0);
|
|
|
|
$width = $board['bo_table_width'] ? $board['bo_table_width'] : 1000;
|
|
if ($width > 100)
|
|
$width .= "px";
|
|
else
|
|
$width .= "%";
|
|
$gall_w = $board['bo_1'] ? $board['bo_1'] : 400;
|
|
$gall_h = $board['bo_2'] ? $board['bo_2'] : 300;
|
|
|
|
$year_pre = 0;
|
|
$month_pre = 0;
|
|
?>
|
|
<div id="bo_frame" style="max-width:<?= $width ?>;margin:0 auto;">
|
|
<!-- 상단 공지 부분 -->
|
|
<?php if (empty($stx)) { ?>
|
|
<nav class="pg_wrap theme-box">
|
|
<span class="pg control">
|
|
<a href="<?= G5_BBS_URL . "/board.php?bo_table=" . $bo_table . "&";
|
|
if ($month == 1) {
|
|
$year_pre = $year - 1;
|
|
$month_pre = $month;
|
|
} else {
|
|
$year_pre = $year - 1;
|
|
$month_pre = $month;
|
|
}
|
|
echo ("year=$year_pre&month=$month_pre&sc_no=$sc_no"); ?>" class="pg_page">
|
|
<i class="ico prevyr txt-default"><?= $year_pre ?></i>
|
|
</a><a href="<?= G5_BBS_URL . "/board.php?bo_table=" . $bo_table . "&";
|
|
if ($month == 1) {
|
|
$year_pre = $year - 1;
|
|
$month_pre = 12;
|
|
} else {
|
|
$year_pre = $year;
|
|
$month_pre = $month - 1;
|
|
}
|
|
echo ("year=$year_pre&month=$month_pre&sc_no=$sc_no"); ?>" class="pg_page">
|
|
<i class="ico prevmth txt-default"><?= $month_pre ?></i>
|
|
</a>
|
|
</span>
|
|
<span class="pg">
|
|
<strong class="year"><?= $year ?></strong><?php for ($m = 1; $m <= 12; $m++) {
|
|
if ($m == $month) {
|
|
?><strong class="pg_current pg_page month" title="<?= $year ?>년 <?= $m ?>월"><span
|
|
class="txt-point"><?= $m ?></span></strong><?php } else { ?>
|
|
<a href="<?= G5_BBS_URL . "/board.php?bo_table=" . $bo_table . "&year=" . $year . "&month=" . $m . "&sc_no=" . $sc_no; ?>"
|
|
class="pg_page month">
|
|
<span class="txt-default"><?= $m ?></span>
|
|
</a>
|
|
<?php } ?>
|
|
<?php } ?>
|
|
</span>
|
|
<span class="pg control">
|
|
<a href="<?= G5_BBS_URL . "/board.php?bo_table=" . $bo_table . "&";
|
|
if ($month == 12) {
|
|
$year_pre = $year + 1;
|
|
$month_pre = 1;
|
|
} else {
|
|
$year_pre = $year;
|
|
$month_pre = $month + 1;
|
|
}
|
|
echo ("year=$year_pre&month=$month_pre&sc_no=$sc_no"); ?>" class="pg_page">
|
|
<i class="ico nextmth txt-default"><?= $month_pre ?></i>
|
|
</a><a href="<?= G5_BBS_URL . "/board.php?bo_table=" . $bo_table . "&";
|
|
if ($month == 12) {
|
|
$year_pre = $year + 1;
|
|
$month_pre = $month;
|
|
} else {
|
|
$year_pre = $year + 1;
|
|
$month_pre = $month;
|
|
}
|
|
echo ("year={$year_pre}&month={$month_pre}&sc_no={$sc_no}"); ?>" class="pg_page">
|
|
<i class="ico nextyr txt-default"><?= $year_pre ?></i>
|
|
</a>
|
|
</span>
|
|
</nav>
|
|
<?php } else { ?>
|
|
<nav class="pg_wrap theme-box">
|
|
<span></span>
|
|
<h2 class="this-month txt-point" style="padding: 8px 0"><?=$stx?>의 검색 결과</h2>
|
|
</nav>
|
|
<?php } ?>
|
|
<div id="bo_list">
|
|
<section id="diary_calendar">
|
|
<div class="diary-calendar theme-box">
|
|
<?php
|
|
if (!empty($stx)) {
|
|
?>
|
|
<h2 class="this-month txt-point">
|
|
<a href="<?= G5_BBS_URL ?>/board.php?bo_table=<?=$bo_table?>">돌아가기</a>
|
|
</h2>
|
|
<div class="controls txt-right">
|
|
<?php if ($admin_href) { ?><a href="<?= $admin_href ?>" class="ui-btn small admin">관리자</a><?php } ?>
|
|
</div>
|
|
<?
|
|
} else {
|
|
?>
|
|
<h2 class="this-month txt-point"><?= $year ?>/<?= $sel_mon ?></h2>
|
|
<div class="controls txt-right">
|
|
<?php if ($admin_href) { ?><a href="<?= $admin_href ?>" class="ui-btn small admin">관리자</a><?php } ?>
|
|
</div>
|
|
<table class="theme-list calendar-list">
|
|
<thead>
|
|
<tr class="txt-center">
|
|
<th class="sun">일</th>
|
|
<th>월</th>
|
|
<th>화</th>
|
|
<th>수</th>
|
|
<th>목</th>
|
|
<th>금</th>
|
|
<th class="sat">토</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php
|
|
$query = "SELECT * FROM {$write_table} WHERE wr_1!='' and left(wr_1,6) = '$year$sel_mon' ORDER BY wr_id ASC";
|
|
$result = sql_query($query);
|
|
$j = 0; // layer id
|
|
// 내용을 보여주는 부분
|
|
while ($row = sql_fetch_array($result)) { // 제목글 뽑아서 링크 문자열 만들기..
|
|
if (strstr($row['wr_option'], "secret") && (!$is_admin || ($row['mb_id'] && $member['mb_id'] != $member['mb_id'])))
|
|
continue;
|
|
if (substr($row['wr_1'], 0, 6) < $year . $sel_mon) {
|
|
$start_day = 1;
|
|
$start_day = (int) $start_day;
|
|
} else {
|
|
$start_day = substr($row['wr_1'], 6, 2);
|
|
$start_day = (int) $start_day;
|
|
}
|
|
|
|
$end_day = $start_day;
|
|
|
|
if (!$write_href) {
|
|
$link = '';
|
|
$cursor = " default";
|
|
} else if ($is_admin || ($member['mb_id'] && $member['mb_id'] == $row['mb_id'])) {
|
|
$cursor = "";
|
|
$link = "get_info('" . $row['wr_1'] . "');";
|
|
} else {
|
|
$link = "";
|
|
$cursor = " default";
|
|
}
|
|
$secret = strstr($row['wr_option'], "secret") ? "secret" : "";
|
|
|
|
$html_day[$start_day] .= '<a href="#" onclick="' . $link . ' return false;" id="d_' . $row['wr_1'] . '" class="wr-date ui-btn point' . $cursor . '">';
|
|
$html_day[$start_day] .= '<i>' . $start_day . '</i>';
|
|
$html_day[$start_day] .= '</a>';
|
|
}
|
|
|
|
// 달력의 틀을 보여주는 부분
|
|
|
|
$temp = 7 - (($lastday[$month] + $dayoftheweek) % 7);
|
|
|
|
if ($temp == 7)
|
|
$temp = 0;
|
|
$lastcount = $lastday[$month] + $dayoftheweek + $temp;
|
|
|
|
for ($iz = 1; $iz <= $lastcount; $iz++) { // 42번을 칠하게 된다.
|
|
$bgcolor = "days"; // 쭉 흰색으로 칠하고
|
|
if ($b_year == $year && $b_mon == $month && $b_day == $cday)
|
|
$bgcolor = "today"; // 오늘날짜 표기
|
|
$re = $iz % 7;
|
|
if ($re == 1)
|
|
echo ("<tr>"); // 주당 7개씩 한쎌씩을 쌓는다.
|
|
if ($dayoftheweek < $iz && $iz <= $lastday[$month] + $dayoftheweek) {
|
|
// 전체 루프안에서 숫자가 들어가는 셀들만 해당됨
|
|
// 즉 11월 달에서 1일부터 30 일까지만 해당
|
|
$daytext = "$cday"; // $cday 는 숫자 예> 11월달은 1~ 30일 까지
|
|
//$daytext 은 셀에 써질 날짜 숫자 넣을 공간
|
|
|
|
// 여기까지 숫자와 들어갈 내용에 대한 변수들의 세팅이 끝나고
|
|
// 이제 여기 부터 직접 셀이 그려지면서 그 안에 내용이 들어 간다.
|
|
if ($re == 0)
|
|
$col = "right";
|
|
else if ($re == 1)
|
|
$col = "left";
|
|
else
|
|
$col = "";
|
|
$fr_date = $year . sprintf("%02d", $month) . sprintf("%02d", $cday);
|
|
echo ("<td width=$col_width height=$col_height class='{$bgcolor} {$col}' valign='top'>");
|
|
|
|
|
|
// 기념일 파일 내용 비교위한 변수 선언, 월과 일을 두자리 포맷으로 고정
|
|
if (strlen($month) == 1) {
|
|
$monthp = "0" . $month;
|
|
} else {
|
|
$monthp = $month;
|
|
}
|
|
if (strlen($cday) == 1) {
|
|
$cdayp = "0" . $cday;
|
|
} else {
|
|
$cdayp = $cday;
|
|
}
|
|
$memday = $year . $monthp . $cdayp;
|
|
$daycont = "";
|
|
|
|
// 기념일(양력) 표시
|
|
/*
|
|
for($i=0 ; $i < sizeof($dayfile) ; $i++) { // 파일 첫 행부터 끝행까지 루프
|
|
$arrDay = explode("|", $dayfile[$i]);
|
|
if($memday == $year.$arrDay[0]) {
|
|
$daycont = $arrDay[1];
|
|
$daycontcolor = $arrDay[2];
|
|
if(substr($arrDay[2],0,3)=="red") $daycolor = "red"; // 공휴일은 날짜를 빨간색으로 표시
|
|
}
|
|
}
|
|
*/
|
|
// 석봉운님의 음력날짜 변수선언
|
|
/*
|
|
$myarray = soltolun($year,$month,$cday);
|
|
if ($myarray[day]==1 || $myarray[day]==11 || $myarray[day]==21) {
|
|
$moonday ="<font color='gray'> (음)$myarray[month].$myarray[day]$myarray[leap]</font>";
|
|
} else {
|
|
$moonday="";
|
|
}
|
|
|
|
include $file_index."/lunar.txt"; ### 음력 기념일 파일 지정
|
|
|
|
if ($annivmoonday&&$daycont) $blank="<br />"; // 음력절기와 양력기념일이 동시에 있으면 한칸 띔
|
|
else $blank="";
|
|
*/
|
|
if ($html_day[$cday]) {
|
|
echo $html_day[$cday];
|
|
} else {
|
|
if ($write_href) {
|
|
$wlink = "get_info('" . $fr_date . "');";
|
|
$cursor = "";
|
|
} else {
|
|
$wlink = "";
|
|
$cursor = " default";
|
|
}
|
|
$html_day[$cday] .= '<a href="#" onclick="' . $wlink . ' return false;" id="w_' . $fr_date . '" class="wr-date ui-btn etc' . $cursor . '" data-date="' . $fr_date . '" data-mood="" data-etc="" data-wid="">';
|
|
$html_day[$cday] .= '<i>' . $daytext . '</i>';
|
|
$html_day[$cday] .= '</a>';
|
|
echo $html_day[$cday];
|
|
}
|
|
echo ("</td>"); // 한칸을 마무리
|
|
$cday++; // 날짜를 카운팅
|
|
}
|
|
// 유효날짜가 아니면 그냥 회색을 칠한다.
|
|
else {
|
|
echo ("<td width=$col_width height=$col_height class='noday'> </td>");
|
|
}
|
|
if ($re == 0)
|
|
echo ("</tr>");
|
|
} // 반복구문이 끝남
|
|
unset($row);
|
|
?>
|
|
</tbody>
|
|
</table>
|
|
<?php } ?>
|
|
</div>
|
|
<?php if ($board['bo_content_head']) { ?>
|
|
<hr class="padding small">
|
|
<div class="board-notice">
|
|
<?= stripslashes($board['bo_content_head']); ?>
|
|
</div>
|
|
<?php } ?>
|
|
<?php if ($is_member && $write_href) { ?>
|
|
<hr class="padding small">
|
|
<div id="diary_write" class="none-trans">
|
|
<div class="theme-box">
|
|
<a href="#" onclick="$('#bo_w').toggleClass('on');return false;" id="write_open">▶ 글쓰기</a>
|
|
<?php include_once $board_skin_path . '/write.php'; ?>
|
|
</div>
|
|
</div>
|
|
<hr class="padding small">
|
|
<?php } ?>
|
|
|
|
<fieldset id="bo_sch">
|
|
<legend>게시물 검색</legend>
|
|
|
|
<form name="fsearch" method="get">
|
|
<input type="hidden" name="bo_table" value="<?php echo $bo_table ?>">
|
|
<input type="hidden" name="sca" value="<?php echo $sca ?>">
|
|
<input type="hidden" name="sop" value="and">
|
|
<input type="hidden" name="sfl" value="wr_content">
|
|
<label for="stx" class="sound_only">검색어<strong class="sound_only"> 필수</strong></label>
|
|
<input type="text" name="stx" value="<?php echo stripslashes($stx) ?>" required id="stx"
|
|
class="frm_input required" size="15" maxlength="20">
|
|
<button type="submit" class="ui-btn"><i class="material-icons">search</i></button>
|
|
</form>
|
|
</fieldset>
|
|
</section>
|
|
<section id="diary_list">
|
|
<div class="diary-cont">
|
|
<?php
|
|
$order = $board['bo_4'] ? "asc" : "desc";
|
|
$result = sql_query("SELECT * FROM {$write_table} WHERE wr_1!='' and left(wr_1,6) = '$year$sel_mon' ORDER BY wr_1 {$order}");
|
|
if (!empty($stx)) {
|
|
// need after fix for secure
|
|
$stx = "\"%".stripslashes($stx)."%\"";
|
|
$result = sql_query("SELECT * FROM {$write_table} WHERE wr_content LIKE {$stx} ORDER BY wr_id");
|
|
}
|
|
for ($i = 0; $row = sql_fetch_array($result); $i++) {
|
|
if (strstr($row['wr_option'], "secret") && (!$is_admin || ($row['mb_id'] && $member['mb_id'] != $member['mb_id'])))
|
|
continue;
|
|
?>
|
|
<div class="theme-box" id="w_<?= $row['wr_1'] ?>" data-date="<?= $row['wr_1'] ?>"
|
|
data-wid="<?= $row['wr_id'] ?>">
|
|
<div class="options">
|
|
<h3 class="wr_date">
|
|
<?= substr($row['wr_1'], 0, 4) ?>/<?= substr($row['wr_1'], 4, 2) ?>/<?= substr($row['wr_1'], 6, 2) ?><span
|
|
class="secret"><?= strstr($row['wr_option'], "secret") ? " ::" : ""; ?></span>
|
|
</h3>
|
|
<p class="btn_confirm">
|
|
<?php if ($is_admin || ($member['mb_id'] && $member['mb_id'] == $row['mb_id'])) {
|
|
$cursor = "";
|
|
$delete_href = "";
|
|
// 로그인중이고 자신의 글이라면 또는 관리자라면 패스워드를 묻지 않고 바로 수정, 삭제 가능
|
|
if (($member['mb_id'] && ($member['mb_id'] == $row['mb_id'])) || $is_admin) {
|
|
$delete_href = "javascript:del('./delete.php?bo_table=" . $bo_table . "&wr_id=" . $row['wr_id'] . "&page=" . $page . urldecode($qstr) . "');";
|
|
if ($is_admin) {
|
|
$delete_href = "javascript:del('./delete.php?bo_table=" . $bo_table . "&wr_id=" . $row['wr_id'] . "&token=" . $token . "&page=" . $page . urldecode($qstr) . "');";
|
|
}
|
|
} else if (!$write['mb_id']) { // 회원이 쓴 글이 아니라면
|
|
$delete_href = "./password.php?w=d&bo_table=" . $bo_table . "&wr_id=" . $row['wr_id'] . "&page=" . $page . $qstr;
|
|
}
|
|
?><a href="#" onclick="get_info('<?= $row['wr_1'] ?>'); return false;">M</a><a
|
|
href="<?= $delete_href ?>">D</a>
|
|
<?php
|
|
} ?>
|
|
</p>
|
|
</div>
|
|
<hr class="line">
|
|
<div class="ui-cont<?= $row['wr_file'] ? " with-image" : ""; ?>">
|
|
<div class="ui-thumb file" data-file="<?= $row['wr_file'] ?>">
|
|
<?php if ($row['wr_file']) {
|
|
$thumb = get_list_thumbnail($bo_table, $row['wr_id'], $gall_w, $gall_h, false, true);
|
|
$thumb2 = get_mmb_image($bo_table, $row['wr_id']);
|
|
?>
|
|
<a href="<?= $thumb2['src'] ?>" onclick="view_img(this.href);return false;"><img
|
|
src="<?= $thumb['src'] ?>"></a>
|
|
<?php } ?>
|
|
</div>
|
|
<div class="diary-text">
|
|
<p class="misc"><?php if ($row['wr_4']) { ?><em><?= $board['bo_5'] ? $board['bo_5'] : "[날씨]"; ?></em>
|
|
<span class="weather"><?= $row['wr_4'] ?></span><?php }
|
|
if ($row['wr_3']) { ?><em><?= $board['bo_6'] ? $board['bo_6'] : "[무드]"; ?></em>
|
|
<span class="mood"><?= $row['wr_3'] ?></span><?php } ?>
|
|
</p>
|
|
<div class="content"><?= nl2br($row['wr_content']) ?></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<hr class="padding small">
|
|
<?php } ?>
|
|
</div>
|
|
</section>
|
|
</div>
|
|
</div>
|
|
<div id="view_img">
|
|
<a href="#" onclick="$('#img_cont').empty();$('#view_img').removeClass();return false;" id="img_close">
|
|
<div id="img_cont"></div>
|
|
</a>
|
|
</div>
|
|
<script>
|
|
function view_img(url) {
|
|
$("#view_img").addClass('on');
|
|
$("#img_cont").empty().html('<p><img src="' + url + '"></p>');
|
|
}
|
|
const bo_skin_url = "<?= $board_skin_url ?>";
|
|
<?php if ($is_member && $write_href) { ?>
|
|
const idx = $("td.today .wr-date").data("wid");
|
|
if (idx != '') $("#btn_submit").prop("disabled", true);
|
|
function get_info(wr_id) {
|
|
$('#bo_w').addClass('on');
|
|
let elem = $("#w_" + wr_id);
|
|
let wid = elem.data("wid");
|
|
let w_date = elem.data("date");
|
|
let contents = $("#wr_content").val();
|
|
if (contents != '' && $("#write_w").val() == '') {
|
|
var result = confirm("작성하던 내용을 파기합니까?");
|
|
if (!result) return false;
|
|
}
|
|
$("#btn_submit").prop("disabled", false);
|
|
|
|
$("#write_open").text("▶ 글쓰기");
|
|
$("#wr_subject").val(w_date);
|
|
$("#wr_1").val(w_date);
|
|
$("#wr_3").val("");
|
|
$("#wr_4").val("");
|
|
$("#wr_content").val("");
|
|
$("#write_w").val("");
|
|
$("#write_id").val("");
|
|
$("#wr_file").val("");
|
|
$("#file_del").addClass("sound_only");
|
|
$("#secret").prop("checked", false);
|
|
if (wid > 0) {
|
|
$("#write_open").text("▶ 글수정");
|
|
let w_3 = elem.find(".mood").text();
|
|
let w_4 = elem.find(".weather").text();
|
|
let w_content = elem.find(".content").text();
|
|
let w_file = elem.find(".file").data("file");
|
|
let w_secret = elem.find(".secret").text();
|
|
$("#wr_content").val(w_content);
|
|
$("#wr_3").val(w_3);
|
|
$("#wr_4").val(w_4);
|
|
$("#write_w").val("u");
|
|
$("#write_id").val(wid);
|
|
if (w_file == '1') $("#file_del").removeClass();
|
|
if (w_secret) $("#secret").prop("checked", true);
|
|
}
|
|
|
|
|
|
};
|
|
const d_pos = $("#diary_write").offset().top;
|
|
console.log(d_pos);
|
|
if ($(window).width() <= 720) {
|
|
$(window).scroll(function () {
|
|
var w_pos = $(window).scrollTop();
|
|
if (w_pos >= d_pos) {
|
|
$("#diary_write").addClass("scroll-fix");
|
|
} else if (w_pos < d_pos) {
|
|
$("#diary_write").removeClass("scroll-fix").css("transform", "translateY(0)");
|
|
}
|
|
});
|
|
}
|
|
<?php } ?>
|
|
</script>
|