get_file로 첨부파일 출력

get_file로 첨부파일 출력

QA

get_file로 첨부파일 출력

본문

get_file 함수를 이용해 a게시판에 글을 썼을때 b게시판에 첨부파일이 출력 되도록 했습니다.

그런데 b게시판에 글을 쓴 모든 회원의 이미지가 보여지게 됩니다. 이 부분을 내가 쓴 게시글의 첨부파일만 가지고 올 수 있나요? 

 

해당 부분의 코드입니다.


<?php if($do_cnt > 0) { ?>
                        <div class="do-list font-11">
                            <ul class="bxslider">
                                <?php
                                for($i = 0; $i < $do_cnt; $i++) {
                                    $file = get_file('dailydakku', $list[$cday][$i]['wr_id']);
                                  if(preg_match("/\.({$config['cf_image_extension']})$/i", $file[0]['file'])) {
                                        $file_src = '<img src="'.$file[0]['path'].'/'.$file[0]['file'].'" width="122" height="122">';
                                    } else {
                                        $file_src = '';
                                    }
                                    // 링크이동
                                    $list[$cday][$i]['target'] = '';
                                    if($is_target && $list[$cday][$i]['wr_link1']) {
                                        $list[$cday][$i]['target'] = $is_target;
                                        $list[$cday][$i]['href'] = $list[$cday][$i]['link_href'][1];
                                    }
                                    if($list[$cday][$i]['href']){
                                ?>
                                <li>
                                    <!-- <a href="<?php echo $list[$cday][$i]['href'];?>"<?php echo $list[$cday][$i]['target'];?> class="red day_subject"> -->
                                        <?php echo $file_src ?>
                                    <!-- </a> -->
                                </li>
                                <?php
                                    } //if
                                }
                                ?>
                            </ul>
                        </div>
                    <?php } ?>

$member['mb_id']를 써야 된다는 건 알겠는데 어디에 어떻게 들어가야 되는지 몰라서 질문드립니다.

방법을 알려주시면 감사하겠습니다.

이 질문에 댓글 쓰기 :

답변 3

프로그램은 상상하는 모든 것을 할 수 있습니다.

당연히 원하는 결과를 얻을 수 있는 방법은 여러가지가 있습니다.

g5_file 에 입력된 값을 직접 불러와서 보여주는 방법이 가장 확실한 방법일 것 같습니다.

해당 게시판에서 사용하는 같은 함수를 사용한다면 꼬일 수 있을 것입니다.

중복되지 않는 독특한 함수를 만들어서 사용해야 할 것입니다.

아래 함수를 적절하게 수정해서 사용하면 될 것입니다.

 



// 게시글에 첨부된 파일을 얻는다. (배열로 반환)
function get_file_my($bo_table, $wr_id)
{
    global $g5, $qstr;

    $file['count'] = 0;
    $sql = " select * from {$g5['board_file_table']} where bo_table = '$bo_table' and wr_id = '$wr_id' order by bf_no ";
    $result = sql_query($sql);
    while ($row = sql_fetch_array($result))
    {
        $no = $row['bf_no'];
        $file[$no]['href'] = G5_BBS_URL."/download.php?bo_table=$bo_table&wr_id=$wr_id&no=$no" . $qstr;
        $file[$no]['download'] = $row['bf_download'];
        // 4.00.11 - 파일 path 추가
        $file[$no]['path'] = G5_DATA_URL.'/file/'.$bo_table;
        $file[$no]['size'] = get_filesize($row['bf_filesize']);
        $file[$no]['datetime'] = $row['bf_datetime'];
        $file[$no]['source'] = addslashes($row['bf_source']);
        $file[$no]['bf_content'] = $row['bf_content'];
        $file[$no]['content'] = get_text($row['bf_content']);
        //$file[$no]['view'] = view_file_link($row['bf_file'], $file[$no]['content']);
        $file[$no]['view'] = view_file_link($row['bf_file'], $row['bf_width'], $row['bf_height'], $file[$no]['content']);
        $file[$no]['file'] = $row['bf_file'];
        $file[$no]['image_width'] = $row['bf_width'] ? $row['bf_width'] : 640;
        $file[$no]['image_height'] = $row['bf_height'] ? $row['bf_height'] : 480;
        $file[$no]['image_type'] = $row['bf_type'];
        $file['count']++;
    }

    return $file;
}

$filemy['count'] = 0;
    $sql = " select * from {$g5['board_file_table']} where bo_table = '수정' and wr_id = '$wr_id' order by bf_no ";


    while ($row = sql_fetch_array($result))
    {
        $no = $row['bf_no'];
        $filemy[$no]['path'] = G5_DATA_URL.'/file/'.$bo_table;
        $filemy[$no]['source'] = addslashes($row['bf_source']);
        $filemy$no]['bf_content'] = $row['bf_content'];
        $filemy[$no]['file'] = $row['bf_file'];
        $filemy['count']++;
    }
    return $filemy;

  이런식으로 수정하여 보세요

view.skin.php

에서 작업하시는 건가요?

select wr_id from g5_write_bbs_a

where mb_id='{$view['mb_id']}'

and wr_is_comment=0

여기서 나온 wr_id로 get_file() 

호출하면 될 듯하네요

캘린더 게시판 안에 있습니다. 제가 php 파일에 캘린더 게시판을 불러와서 사용하고 있는데 달력 형태로 보여주는 파일이 schedule.php 파일입니다. a게시판이랑 캘린더 게시판이랑 동시등록이 되어서 캘린더 게시판에 자동으로 글이 써지는데 제가 필요한 부분은 첨부파일 부분입니다. 저번에 질문을 올렸을때 힌트를 주신 get_file()을 사용하여 첨부파일을 불러오는 것은 성공했는데 모든 회원들의 첨부파일이 불러와져서 내가 쓴 글의 첨부파일만 불러오고 싶습니다. 밑의 코드가 schedule.php입니다.


<?php
include_once('../../../../../common.php');
include_once($board_skin_path.'/moonday.extend.php');
include_once(G5_LIB_PATH.'/thumbnail.lib.php');
$bo_table    = $_POST["bo_table"];
$is_today        = $_POST["is_today"];
$is_lunar        = $_POST["is_lunar"];
$is_target    = $_POST["is_target"];
$year            = $_POST["year"];
$month        = $_POST["month"];
// 날짜체크
$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 ($_POST["year"]) {
    $year = $_POST["year"];
}
if ($_POST["month"]) {
    $month = $_POST["month"];
}
$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));
$sca_qstr = ($qstr) ? '&'.$qstr : '';
if($month == 1) {
    $year_prev = $year - 1;
    $month_prev = 12;
    $year_next = $year;
    $month_next = $month + 1;
} else if($month == 12) {
    $year_prev = $year;
    $month_prev = $month - 1;
    $year_next = $year + 1;
    $month_next = 1;
} else {
    $year_prev = $year;
    $month_prev = $month - 1;
    $year_next = $year;
    $month_next = $month + 1;
}
if (isset($year)) {
    $year = preg_replace('/[^0-9_]/i', '', $year);
    $qstr .= '&year=' . urlencode($year);
}
if (isset($month)) {
    $month = preg_replace('/[^0-9_]/i', '', $month);
    $qstr .= '&month=' . urlencode($month);
}
// 요일
$yoil = array("토", "일", "월", "화", "수", "목", "금");
$write_table = $g5['write_prefix'] . $bo_table;
$board = sql_fetch(" select * from {$g5['board_table']} where bo_table = '$bo_table' ");
$admin_href = "";
// 최고관리자 또는 그룹관리자라면
if ($member['mb_id'] && ($is_admin === 'super' || $group['gr_admin'] === $member['mb_id']))
    $admin_href = G5_ADMIN_URL.'/board_form.php?w=u&bo_table='.$bo_table;
$write_href = '';
if ($member['mb_level'] >= $board['bo_write_level']) {
    $write_href = short_url_clean(G5_BBS_URL.'/write.php?bo_table='.$bo_table);
}
$nobr_begin = $nobr_end = "";
if (preg_match("/gecko|firefox/i", $_SERVER['HTTP_USER_AGENT'])) {
    $nobr_begin = '<nobr>';
    $nobr_end   = '</nobr>';
}
// RSS 보기 사용에 체크가 되어 있어야 RSS 보기 가능 061106
$rss_href = '';
if ($board['bo_use_rss_view']) {
    $rss_href = G5_BBS_URL.'/rss.php?bo_table='.$bo_table;
}
$category_option = '';
if ($is_category && $board['bo_use_category']) {
    $is_category = true;
    $category_href = get_pretty_url($bo_table);
    $category_option .= '<li><a href="'.$category_href.'"';
    if ($sca=='')
        $category_option .= ' id="bo_cate_on"';
    $category_option .= '>전체</a></li>';
    $categories = explode('|', $board['bo_category_list']); // 구분자가 , 로 되어 있음
    for ($i=0; $i<count($categories); $i++) {
        $category = trim($categories[$i]);
        if ($category=='') continue;
        $category_option .= '<li><a href="'.(get_pretty_url($bo_table,'','sca='.urlencode($category))).'"';
        $category_msg = '';
        if ($category==$sca) { // 현재 선택된 카테고리라면
            $category_option .= ' id="bo_cate_on"';
            $category_msg = '<span class="sound_only">열린 분류 </span>';
        }
        $category_option .= '>'.$category_msg.$category.'</a></li>';
    }
}
?>
<!-- 게시판 페이지 정보 및 버튼 시작 { -->
<div id="bo_btn_top">
    <?php if ($rss_href || $write_href) { ?>
    <ul class="btn_bo_user">
        <?php if ($admin_href) { ?><li class="list_btn_admin"><a href="<?php echo $admin_href ?>" class="btn_admin btn" title="관리자"><i class="fa fa-cog fa-spin fa-fw"></i><span>관리자</span></a></li><?php } ?>
        <?php if ($rss_href) { ?><li class="list_btn_rss"><a href="<?php echo $rss_href ?>" class="btn_b01 btn" title="RSS"><i class="fa fa-rss" aria-hidden="true"></i><span class="">RSS</span></a></li><?php } ?>
    </ul>
    <?php } ?>
</div>
<!-- } 게시판 페이지 정보 및 버튼 끝 -->
<!-- 게시판 카테고리 시작 { -->
<?php if ($is_category) { ?>
<nav id="bo_cate">
    <h2><?php echo $board['bo_subject'] ?> 카테고리</h2>
    <ul id="bo_cate_ul">
        <?php echo $category_option ?>
    </ul>
</nav>
<?php } ?>
<!-- } 게시판 카테고리 끝 -->
<h2 class="lat_title">
    <a href="javascript:;" OnClick="getSchedule('<?php echo $year_prev;?>','<?php echo $month_prev;?>')" onfocus="this.blur()" title="<?php echo  $month_prev; ?> 월"><button class="lat_title_icon lat_prev" aria-label="이전 달"></button></a>
    <a href="javascript:;" OnClick="getSchedule('<?php echo $year;?>','<?php echo $month;?>')" title="이번달">
        <?php echo $year;?>.<?php echo $month;?>
    </a>
    <a href="javascript:;" OnClick="getSchedule('<?php echo $year_next;?>','<?php echo $month_next;?>')" onfocus="this.blur()" title="<?php echo  $month_next; ?> 월"><button class="lat_title_icon lat_next" aria-label="이전 달"></button></a>
</h2>
<div class="gw_calender_box">
    <?php if($is_today){ ?>
    <div class="list-today">
        <div class="media">
            <div class="date-box pull-left">
                <div class="bg-orangered text-center">
                    <i class="fa fa-calendar-check-o"></i>
                </div>
                <div class="date-icon">
                    <?php echo ($is_month)?date("Y.m", G5_SERVER_TIME):date("Y.m.d", G5_SERVER_TIME);?>
                </div>
            </div>
            <div class="media-body">
                <ul>
                    <?php
                        // Today
                        $i = 0;
                        if($is_month){
                            $chk_today = $b_year.'-'.sprintf("%02d",$b_mon);
                            $result = sql_query("select * from $write_table where wr_is_comment = '0' and left(wr_1,7) <= '{$chk_today}' and left(wr_2,7) >= '{$chk_today}' order by wr_id asc");
                        }else{
                            $chk_today = $b_year.'-'.sprintf("%02d",$b_mon).'-'.sprintf("%02d",$b_day);
                            $result = sql_query("select * from $write_table where wr_is_comment = '0' and left(wr_1,10) <= '{$chk_today}' and left(wr_2,10) >= '{$chk_today}' order by wr_id asc");
                        }
                        while ($row1 = sql_fetch_array($result)) {
                            $row = get_list($row1, $board, $board_skin_url, G5_IS_MOBILE ? $board['bo_mobile_subject_len'] : $board['bo_subject_len']);
                            $row['href'] = short_url_clean(G5_BBS_URL.'/board.php?bo_table='.$bo_table, "wr_id={$row['wr_id']}{$qstr}");
                            // 링크이동
                            $row['target'] = '';
                            if($is_link_target && $row['wr_link1']) {
                                $row['target'] = $is_link_target;
                                $row['href'] = $row['link_href'][1];
                            }

                            $sql = " select count(*) as cnt from g5_write_{$bo_table} WHERE wr_id = wr_parent and  mb_id = '".$mb['mb_id']."'";
                            $row = sql_fetch($sql);
                            $total_count = $row['cnt'];
                            $total_page  = ceil($total_count / $rows);  // 전체 페이지 계산
                            if ($page < 1) { $page = 1; } // 페이지가 없으면 첫 페이지 (1 페이지)
                            $from_record = ($page - 1) * $rows; // 시작 열을 구함

                            $query = "select * from g5_write_{$bo_table}  WHERE wr_id = wr_parent and  mb_id = '".$mb['mb_id']."' {$sql_order} limit {$from_record}, {$rows}";
                            $result = sql_query($query);
                            while($data = sql_fetch_array($result)) {
                                $list[] = $data;
                            }
                    ?>
                    <li>
                        <a href="<?php echo $row['href'];?>"<?php echo $row['target'];?><?php echo $is_modal_js;?>>
                            <span>
                                <?php echo $row['subject'] ;?>
                            </span>
                            <?php if($row['wr_comment']) { ?>
                                <span class="count orangered">+ <?php echo $row['wr_comment'];?></span>
                            <?php } ?>
                        </a>
                    </li>
                    <?php $i++; } ?>
                </ul>
                <?php if(!$i) { ?>
                    <p><?php echo $b_year;?>년 <?php echo sprintf("%02d",$b_mon);?>월 <?php echo sprintf("%02d",$b_day);?>일 오늘 일정은 없습니다.</p>
                <?php } ?>
            </div>
        </div>
    </div>
    <?php } ?>
    <div class="list-head div-head">
        <span class="red">일요일</span>
        <span>월요일</span>
        <span>화요일</span>
        <span>수요일</span>
        <span>목요일</span>
        <span>금요일</span>
        <span class="blue">토요일</span>
    </div>
    <ul class="list-body">
        <?php
            $cday = 1;
            $sel_mon = sprintf("%02d",$month);
            $now_month = $year.'-'.$sel_mon;
            $sca_sql = ($sca) ? "and ca_name = '".$sca."'" : "";
            $result = sql_query("select * from {$write_table} where wr_is_comment = '0' and left(wr_1,7) <= '{$now_month}' and left(wr_2,7) >= '{$now_month}' $sca_sql order by wr_id asc");
            while ($row = sql_fetch_array($result)) {
                $start_day = (substr($row['wr_1'],0,7) <  $now_month) ? 1 : substr($row['wr_1'],8,2);
                $start_day = sprintf("%2.0f" , $start_day);
                $end_day = (substr($row['wr_2'],0,6) >  $now_month) ? $lastday[$month] : substr($row['wr_2'],8,2);
                $end_day = sprintf("%2.0f" , $end_day);
                $row2 = get_list($row, $board, $board_skin_url, G5_IS_MOBILE ? $board['bo_mobile_subject_len'] : $board['bo_subject_len']);
                for ($s = (int)$start_day; $s <= (int)$end_day; $s++) {
                    $list[$s][] = $row2;
                }
            }
            $temp = 7 - (($lastday[$month]+$dayoftheweek)%7);
            if($temp == 7) $temp = 0;
            $lastcount = $lastday[$month]+$dayoftheweek + $temp;
            for ($iz = 1; $iz <= $lastcount; $iz++) {
                $is_today = ($b_year == $year && $b_mon == $month && $b_day == $cday) ? true : false;
                $daycolor = ' black';
                $dayweek = $iz%7;
                if($dayweek == 1) {
                    echo '<li class="list-item">'.PHP_EOL;
                    $daycolor = ' red';
                } else if($dayweek == 0) {
                    $daycolor = ' blue';
                }
                //음력날짜
                $myarray = soltolun($year,$month,$cday);
                $daytext = ($is_today) ? '<span class="font-14 orangered"><i class="fa fa-calendar-check-o fa-lg"></i></span>' : $cday;
                $do_cnt = count($list[$cday]);
                if($dayoftheweek < $iz && $iz <= $lastday[$month]+$dayoftheweek) {
                    $fr_date = $year.'-'.sprintf("%02d",$month).'-'.sprintf("%02d",$cday);
                    $sca_qstr = "&fr_date={$fr_date}";
                    // 글작성 링크
                    $write_href = '';
                    if ($member['mb_level'] >= $board['bo_write_level']) {
                        $write_href = short_url_clean(G5_BBS_URL.'/write.php?bo_table='.$bo_table, "fr_date={$fr_date}");
                    }
                ?>
                    <div class="media<?php echo ($is_today) ? ' bg-today' : '';?>">
                        <!-- <a <?php echo ($write_href) ? ' href="'.$write_href.$sca_qstr.'"' : '';?>> -->
                            <span class="font-16 pull-left<?php echo $daycolor;?>">
                                <?php echo $daytext;?>
                            </span>
                            <?php if($is_lunar && ($is_today || $do_cnt > 0)){?>
                            <span class="font-16 num_lunar">
                                <?php echo $myarray['month'].'.'.$myarray['day'];?>
                            </span>
                            <?php } ?>
                        <!-- </a> -->
                    <!-- <?php if($do_cnt > 0) { ?> -->
                        <div class="do-list font-11">
                            <ul class="bxslider">
                                <?php
                                 for($i = 0; $i < $do_cnt; $i++) {
                                     $file = get_file('dailydakku', $list[$cday][$i]['wr_id']);
                                   if(preg_match("/\.({$config['cf_image_extension']})$/i", $file[0]['file'])) {
                                         $file_src = '<img src="'.$file[0]['path'].'/'.$file[0]['file'].'" width="122" height="122">';
                                     } else {
                                         $file_src = '';
                                     }

                                    // 링크이동
                                    $list[$cday][$i]['target'] = '';
                                    if($is_target && $list[$cday][$i]['wr_link1']) {
                                        $list[$cday][$i]['target'] = $is_target;
                                        $list[$cday][$i]['href'] = $list[$cday][$i]['link_href'][1];
                                    }
                                    if($list[$cday][$i]['href']){
                                ?>
                                <li>
                                    <!-- <a href="<?php echo $list[$cday][$i]['href'];?>"<?php echo $list[$cday][$i]['target'];?> class="red day_subject"> -->
                                        <?php echo $file_src ?>
                                    <!-- </a> -->
                                </li>
                                <?php
                                    } //if
                                }
                                ?>
                            </ul>
                        </div>
                    <!-- <?php } ?> -->
                </div>
            <?php
                $cday++;
            } else {
                echo '<div></div>'.PHP_EOL;
            }
            if($iz%7 == 0) echo '</li>'.PHP_EOL;
        }
        ?>
    </ul>
</div>

<script>
$(document).ready(function(){
    $('.bxslider').bxSlider({
        auto: true,
        speed: 500,
        pause: 4000,
        pager:true,
        touchEnabled:true,
        controls:false,
    });
});
</script>
 
답변을 작성하시기 전에 로그인 해주세요.
전체 0 | RSS
QA 내용 검색
  • 개별 목록 구성 제목 답변작성자조회작성일
  • 질문이 없습니다.

회원로그인

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