읽기 쓰기 병합된 list에서 읽기와 쓰기 분리

읽기 쓰기 병합된 list에서 읽기와 쓰기 분리

QA

읽기 쓰기 병합된 list에서 읽기와 쓰기 분리

본문

list에서 쓰기와 보기가 모두 되는 것입니다만..

편법으로 대충 해놨더니.. 엉망이네요.

소스보기로 정보들이 노출되기에 이걸 쓰기와 보기 화면을 모두 일반 게시판처럼 처리하고 싶네요.

리스트에서 항목을 누르면 팝업창으로 내용이 보이게 되어 있고..

수정하기를 누르면 새 창이 뜨며 수정할 수 있게끔 되어 있습니다.

이걸 그냥 리스트에서 클릭 시 보기 화면으로 넘어가고.. 거기서 수정하기도 처리되게 하려면 어떡할까요.

 

 

 

 


<?php
if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가
//회원이면 로그아웃
/*if($is_member){
    echo '<script>
    location.href=\''.G5_BBS_URL.'/logout.php?url='.$urlencode.'\'
    </script>';
}*/
 
set_session('ss_delete_token', $token = uniqid(time())); //삭제
include_once("$board_skin_path/moonday.php"); // 석봉운님의 음력날짜 함수
 
if (preg_match('/%/', $width)) {
  $col_width = "14%"; //표의 가로 폭이 100보다 크면 픽셀값입력
} else{
  $col_width = round($width/7); //표의 가로 폭이 100보다 작거나 같으면 백분율 값을 입력
}
$col_height= 124 ;//내용 들어갈 사각공간의 세로길이를 가로 폭과 같도록
$today = getdate();
$b_mon = $today['mon'];
$b_day = $today['mday'];
$b_year = $today['year'];
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)을 불러온다
if(file_exists($file_index."/".$year.".txt")) {
$dayfile = file($file_index."/".$year.".txt");
} else {
$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));
 
// add_stylesheet('css 구문', 출력순서); 숫자가 작을 수록 먼저 출력됨
add_stylesheet('<link rel="stylesheet" href="'.$board_skin_url.'/style.css">', 0);
?>
 
<table width="1030" border=0 cellpadding="0" cellspacing="0" class="sche_tb_head">
  <tr>
       <td width="20%" class="fg_title"> </td>
       <td width="60%" align="center"><div style="padding:34px;">
       
<table border="0" cellspacing="3" cellpadding="0">
<tr>
<td class="arr_btn"><?php if ($is_admin) { ?><a href="<?php echo $_SERVER[PHP_SELF]."?bo_table=".$bo_table."&"; ?><?php 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");?>"><img src="<?php echo $board_skin_url ?>/img/m_prev.gif" border="0" alt="<?php echo $month_pre ?>월"></a><?php } ?></td>
<td style="padding:0 10px;font-size:18px;font-weight:bold;"><a href="<?php echo $_SERVER[PHP_SELF]."?bo_table=".$bo_table; ?>" title="오늘로" onfocus="this.blur()"><?php echo $year ?>년 <?php echo $month ?>월</a></td>
<td class="arr_btn"><a href="<?php echo $_SERVER[PHP_SELF]."?bo_table=".$bo_table."&"; ?><?php 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");?>"><img src="<?php echo $board_skin_url ?>/img/m_next.gif" border="0" alt="<?php echo $month_pre ?>월"></a></td>
</tr>
</table>
</div></td>
<td width="20%" class="pd15">
        <?php if ($rss_href || $write_href) { ?>
 
<ul class="btn_bo_user">
            <?php if ($rss_href) { ?><li><a href="<?php echo $rss_href ?>" class="btn_b01 btn"><i class="fa fa-rss" aria-hidden="true"></i> RSS</a></li><?php } ?>
            <?php if ($admin_href) { ?><li><a href="<?php echo $admin_href ?>" class="btn_admin btn"><i class="fa fa-user-circle" aria-hidden="true"></i> 관리자</a></li><?php } ?>
            <!--<?php if ($write_href) { ?><li><a href="<?php echo $write_href ?>" class="btn_b02 btn"><i class="fa fa-pencil" aria-hidden="true"></i> 일정추가</a></li><?php } ?>-->
        </ul>
 
        <?php } ?>
</td>
  </tr>
</table>
 
<div id="bo_list">
<table width="1030" class="sche_tb">
<thead>
  <tr align="center">     
<th style="color:red">SUN</th>
<th>MON</th>
<th>TUE</th>
<th>WED</th>
<th>THU</th>
<th>FRI</th>
<th style="color:blue">SAT</th>
  </tr>
</thead>
<tbody>
<?php
$cday = 1;
$sel_mon = sprintf("%02d",$month);
 
$query = "SELECT * FROM $write_table WHERE left(wr_1,6) <= '$year$sel_mon' and left(wr_2,6) >= '$year$sel_mon' ORDER BY wr_8 ASC";
$result = sql_query($query);
$j=0; // layer id
// 내용을 보여주는 부분
while ($row = sql_fetch_array($result)) {  // 제목글 뽑아서 링크 문자열 만들기..
  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;
  }
 
  if( substr($row[wr_2],0,6) >  $year.$sel_mon ) {
$end_day = $lastday[$month];
$end_day= (int)$end_day;
  } else {
$end_day = substr($row[wr_2],6,2);
$end_day= (int)$end_day;
  }
 
  // 아이디에 따라 다른 아이콘이미지 출력 하고 싶을때 ///주석을 해제
  //$imgown = 'icon';
 
  for ($i = $start_day ; $i <= $end_day;  $i++) {
 
    if (strlen($row[wr_3]) > 0) {  // 입력된 아이콘 값이 있을 때
      $imgown = $row[wr_3] ;
}
 
    $j++; // layer ID
 
    $list[comment_cnt] = " ".$row[wr_comment]; // row에 대하여 코멘트 카운터 정의
    if($row[wr_comment] == 0) {
      $list[comment_cnt] = null ;
    } else {
  //if($list[comment_cnt]!=null) $list[comment_cnt] = "<b><span class='colorRed'>".$list[comment_cnt]."</span></b>";
  //if($list[comment_cnt]!=null) $list[comment_cnt] = "<span style='color:#f79100;'>".$row['wr_9'].$row['wr_7']."</span>";
    }
 
    $row[wr_subject] = cut_str(get_text($row[wr_subject]),$board[bo_subject_len],"…"); // subject length cut
    //$row[wr_7] = cut_str(get_text($row['wr_7']),"5","*"); // subject length cut
    
    
 
    
    
    
    
    
    
 
    $list['icon_new'] = '';
if ($row['wr_datetime'] >= date("Y-m-d H:i:s", G5_SERVER_TIME - ($board['bo_new'] * 3600)))
      $list['icon_new'] = " <img src='$board_skin_url/img/icon_new.gif' align='absmiddle' alt='새글'>";
 
    if ($member[mb_level] < $board[bo_read_level]) {
      $showLayer="" ;
    } else {
      $showLayer=" onmouseover=\"PopupShow('".$j."')\" onmouseout=\"PopupHide('".$j."')\" ";
    }
      
    $update_href = G5_BBS_URL.'/write.php?w=u&bo_table='.$bo_table.'&wr_id='.$row[wr_id].'&wr_password=1&page='.$page.$qstr; //수정
    
      
    $html_day[$i].= "<br /><span style='color:#f79100;font-weight:bold;'>".$row['wr_9']."</span>". " <a href='".G5_BBS_URL."/board.php?bo_table=$bo_table&year=$year&month=$month&wr_id=$row[wr_id]&sc_no=$sc_no' id='subject_".$j."' ".$showLayer." class='day_sjt'>".$row[wr_subject]."</a>".'<div class="p_view"><h4>'."room ".$row[wr_9]."  ".$row[wr_subject]."시    ".$row[wr_7]."님".'</h4><p>'.substr($row['wr_1'],4,2)."/".substr($row['wr_1'],6,2)." ~ ".substr($row['wr_2'],4,2)."/".substr($row['wr_2'],6,2).'</p><div class="cont">'.nl2br($row[wr_content]).'</div><div class="btnField"><a href="#" onclick="modify('.$row[wr_id].');" class="p_btn mod">수정</a><a href="'.G5_BBS_URL.'/delete.php?bo_table='.$bo_table.'&wr_id='.$row[wr_id].'&token='.$_SESSION['ss_delete_token'].'&wr_password=1" class="p_btn del">삭제</a></div></div>'.  cut_str(get_text($row['wr_7']),"2","*").$list[comment_cnt];
    /* 위 부분은 캘린더 매일 매항목 내용과 팝업으로 내용 보기를 보여줌 */
    /*
    $html_day[$i].= "<br /><span style='color:#f79100;font-weight:bold;'>".$row['wr_9']."</span>". " <a href='".G5_BBS_URL."/board.php?bo_table=$bo_table&year=$year&month=$month&wr_id=$row[wr_id]&sc_no=$sc_no' id='subject_".$j."' ".$showLayer." class='day_sjt'>".$row[wr_subject]."</a>".'<div class="p_view"><h4>'.$row[wr_subject].'</h4><p>'.substr($row['wr_1'],4,2)."/".substr($row['wr_1'],6,2)." ~ ".substr($row['wr_2'],4,2)."/".substr($row['wr_2'],6,2).'</p><div class="cont">'.nl2br($row[wr_content]).'</div><div class="btnField"><a href="#" onclick="modify('.$row[wr_id].');" class="p_btn mod">수정</a><a href="'.G5_BBS_URL.'/delete.php?bo_table='.$bo_table.'&wr_id='.$row[wr_id].'&token='.$_SESSION['ss_delete_token'].'&wr_password=1" class="p_btn del">삭제</a></div></div>'.  $row['wr_7'].$list[comment_cnt];
    */
?>
 
<?php
//오늘 스케줄 구하기
if ($row[wr_id] != $sc_id && date('Ymd', strtotime($row[wr_1])) <= date(Ymd) && date('Ymd', strtotime($row[wr_2])) >= date(Ymd)) {
$today_schedule .= "<p><img src='$board_skin_url/img/".$imgown.".gif' border=0 align=absmiddle />";
$today_schedule .= " <a href='".G5_BBS_URL."/board.php?bo_table=$bo_table&year=$year&month=$month&wr_id=$row[wr_id]&sc_no=$sc_no' class='cpOn'><b>".$row[wr_subject]."</b></a>";
$today_schedule .= " (".substr($row['wr_1'],4,2)."/".substr($row['wr_1'],6,2)." ~ ".substr($row['wr_2'],4,2)."/".substr($row['wr_2'],6,2).")<br />";
$today_schedule .= $viewlist."</p><br />";
}
$sc_id = $row[wr_id];
    }
  }
 
  // 달력의 틀을 보여주는 부분
 
  $temp = 7- (($lastday[$month]+$dayoftheweek)%7);
 
  if ($temp == 7) $temp = 0;
     $lastcount = $lastday[$month]+$dayoftheweek + $temp;
 
  for ($iz = 1; $iz <= $lastcount; $iz++) { // 42번을 칠하게 된다.
    $bgcolor = "#ffffff";  // 쭉 흰색으로 칠하고
    if ($b_year==$year && $b_mon==$month && $b_day==$cday) $bgcolor = "#DEFADE";      //  "#DFFDDF"; // 오늘날짜 연두색으로 표기
    if (($iz%7) == 1) echo ("<tr>"); // 주당 7개씩 한쎌씩을 쌓는다.
    if ($dayoftheweek < $iz  &&  $iz <= $lastday[$month]+$dayoftheweek) {
// 전체 루프안에서 숫자가 들어가는 셀들만 해당됨
// 즉 11월 달에서 1일부터 30 일까지만 해당
$daytext = "$cday";   // $cday 는 숫자 예> 11월달은 1~ 30일 까지
//$daytext 은 셀에 써질 날짜 숫자 넣을 공간
$daycontcolor = "" ;
$daycolor = "";
if ($iz%7 == 1) $daycolor = "red"; // 일요일
if ($iz%7 == 0) $daycolor = "blue"; // 토요일
 
// 여기까지 숫자와 들어갈 내용에 대한 변수들의 세팅이 끝나고
// 이제 여기 부터 직접 셀이 그려지면서 그 안에 내용이 들어 간다.
echo ("<td width=$col_width height=$col_height bgcolor=$bgcolor valign=top>");
 
$f_date = $year.sprintf("%02d",$month).sprintf("%02d",$cday);
 
// 기념일 파일 내용 비교위한 변수 선언, 월과 일을 두자리 포맷으로 고정
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 ="<span class='colorGray'> (음)$myarray[month].$myarray[day]$myarray[leap]</span>";
    } else {
      $moonday="";
    }
 
include($file_index."/lunar.txt"); ### 음력 기념일 파일 지정
 
    if ($annivmoonday&&$daycont) $blank="<br />"; // 음력절기와 양력기념일이 동시에 있으면 한칸 띔
    else $blank="";
 
    if ($write_href) {
      // $write_href (글쓰기 권한)이 있으면
      // 날짜를 클릭하면 글씨쓰기가 가능한 링크를 넣어서 출력하기
      echo "<a href='./board.php?bo_table=$bo_table&t=$f_date' title='일정보기' class='day_w'><b><i class='fa fa-calendar-check-o' aria-hidden='true'></i></b> </a><a href='javascript:;' class='day_add'><span style='color:$daycolor'>$daytext</span></a>$moonday <span style='color:$daycontcolor'>$daycont</span>$blank $annivmoonday";
    } else { // 글쓰기 권한이 없으면 글쓰기 링크는 넣지 않고 그냥 숫자와 기념일 내용만 출력하기
      echo "<a href='./board.php?bo_table=$bo_table&t=$f_date' title='일정보기'><b><i class='fa fa-calendar-check-o' aria-hidden='true'></i></b></a> <span style='color:$daycolor'>$daytext</span>$moonday <span style='color:$daycontcolor'>$daycont</span>$blank $annivmoonday";
    }
    echo $html_day[$cday];
    echo ("</td>");  // 한칸을 마무리
    $cday++; // 날짜를 카운팅
  }
  // 유효날짜가 아니면 그냥 회색을 칠한다.
  else { echo ("     <td width=$col_width height=$col_height valign=top class='day_disabled'> </td>"); }
  if (($iz%7) == 0) echo ("  </tr>");
   
} // 반복구문이 끝남
?>
</tbody>
</table>
</div>
 
 
<?php if ($is_admin) { ?>
<table cellpadding='0' cellspacing='0' width="1030">
<tr>
<td>
 
<div>
    <div style="font-size:16pt;padding:50px 0 18px 14px;"><h3>일정추가</h3></div>
    <form name="fwrite" id="fwrite" action="<?php echo $action_url ?>" onsubmit="return fwrite_submit(this);" method="post" enctype="multipart/form-data" autocomplete="off" ?>
        <? include_once (G5_BBS_PATH.'/write.php'); ?>
    </form>
</div>
 
<!--글쓰기-->
<?
include_once(G5_PLUGIN_PATH.'/jquery-ui/datepicker.php');
include_once(G5_CAPTCHA_PATH.'/captcha.lib.php');
 
$captcha_html = '';
$captcha_js   = '';
if ($is_guest) {
    $captcha_html = captcha_html();
    $captcha_js   = chk_captcha_js();
}
?>
 
</td>
</tr>
</table>
<?php } ?>
 
 
 
<script language="JavaScript">
 
// 미리보기 팝업 보이기
function PopupShow(n) {
var position = $("#subject_"+n).position();
$("#popup_"+n).animate({left:position.left-10+"px", top:position.top+30+"px"},0);
$("#popup_"+n).show();
}
 
// 미리보기 팝업 숨기기
function PopupHide(n) {
$("#popup_"+n).hide();
}
    
$(function(){ // 날짜 입력
    $("#wr_1, #wr_2").datepicker({ changeMonth: true, changeYear: true, dateFormat: "yymmdd", showButtonPanel: true });
});
 
$(function(){
    $('.sche_tb .day_sjt').on('click',function(){
        $(this).next('.p_view').show(0);
        return false;
    })
 
    $('.p_view').append('<div class="p_view_close"></div>');
    $('.p_view_close').append('<span></span><span></span>')
    $(document).on('click','.p_view_close',function(){
        $('.p_view').hide(0);
    })
    
    //오늘일정 일정목록 팝업
    $(document).on('click','.cpOn',function(){
        var href = $(this).attr('href');
        $('.day_sjt').each(function(i,e){
            if( $(e).attr('href') == href ){
                $(e).next('.p_view').show(0);
            }
        });
        return false;
    })
})
//popup수정
var windowW = 1120;  // 창의 가로 길이
var windowH = 900;  // 창의 세로 길이
    
function modify(id){
    var left = Math.ceil((window.screen.width - windowW)/2);
    var top = Math.ceil((window.screen.height - windowH)/2);
    
    window.open(
        "<?=G5_BBS_URL?>/write.php?w=u&bo_table=<?=$bo_table?>&wr_id="+id+"&wr_password=1&page=<?=$page.$qstr?>",
        "글수정 새창",
        "width="+windowW+",height="+windowH+",left="+left+",top="+top+", toolbar=no, menubar=no, scrollbars=no, resizable=yes"
    );
    $('.p_view').hide(0);
}
</script>

이 질문에 댓글 쓰기 :

답변 1

보기 페이지는 따로 view.php 파일을 생성해서 

그 페이지로 이동 시켜야 하구요.

 

수정의 경우에는..

function modify(id) 함수에서

window.open 부분을 self.location 으로 이동시키고,

해당 write.php 파일에서 head.php 와 tail.php 파일을 include 해주면 됩니다.

답변을 작성하시기 전에 로그인 해주세요.
전체 123,563
QA 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT