Poter

1원 짜리 팁. 글 등록시 다른 게시판에 같이 등록 하기 .....

· 2026-03-09 (월) 16:09:21 · 4071 · 10
1234.jpg

글 등록시 다른 게시판에 같이 등록 하기 .....

찾아 보니 원본 수정해서 쓰는건 있는거 같습니다. 

사용하실 스킨(오는 글을 받아줄)
폴더의 권한설정을 707로 변경 합니다. 


/////////////////////////////////////////////

아래는 글 보내는 쪽 입니다.
wirte.skin.php 적절한 곳에 ....


<div class="write_div">
    <label for="copy_to_other" style="cursor:pointer; font-weight:bold; color:#007bff;">
        <input type="checkbox" name="copy_to_other" value="1" id="copy_to_other"> 
        [basict20] 게시판으로 발주 내역 전송
    </label>
</div>

write_update.skin.php (없으시면 만드시면 됩니다)
바로 아래 타켓테이블 .....
사용할 테이블명 으로 변경해 주세요.


  $target_table = "basict20"; // 테이블명 수정


<?php
if (!defined('_GNUBOARD_')) exit;

// 1. 새글($w == '') 작성 시 체크박스 확인
if ($w == '' && isset($_POST['copy_to_other']) && $_POST['copy_to_other'] == '1') {
    
    $target_table = "basict20"; 
    $target_write_table = $g5['write_prefix'] . $target_table;

    // [중요] 타겟 게시판의 정렬 순번(wr_num) 생성
    // 기존 데이터 중 가장 작은 값보다 -1 하여 최상단에 배치
    $num_row = sql_fetch(" select min(wr_num) as min_num from $target_write_table ");
    $next_num = (int)$num_row['min_num'] - 1;
    if($next_num >= 0) $next_num = -1; 

    // [중요] 타겟 게시판의 새 wr_id 생성
    $row = sql_fetch(" select max(wr_id) as max_id from $target_write_table ");
    $next_id = (int)$row['max_id'] + 1;

    // 현재 게시판에서 업로드된 파일 개수 파악
    $file_count_row = sql_fetch(" select count(*) as cnt from {$g5['board_file_table']} where bo_table = '{$bo_table}' and wr_id = '{$wr_id}' ");
    $wr_file = (int)$file_count_row['cnt'];

    // 2. 게시글 데이터 복제 실행
    sql_query(" insert into $target_write_table
                set wr_id = '$next_id', 
                    wr_num = '$next_num', 
                    wr_reply = '',
                    wr_parent = '$next_id',
                    wr_file = '{$wr_file}', 
                    ca_name = '".addslashes($ca_name)."',
                    wr_option = '{$wr_option}',
                    wr_subject = '".addslashes($wr_subject)."',
                    wr_content = '".addslashes($wr_content)."',
                    wr_link1 = '".addslashes($wr_link1)."',
                    wr_link2 = '".addslashes($wr_link2)."',
                    mb_id = '{$member['mb_id']}',
                    wr_name = '".addslashes($wr_name)."',
                    wr_datetime = '".G5_TIME_YMDHIS."',
                    wr_last = '".G5_TIME_YMDHIS."',
                    wr_ip = '{$_SERVER['REMOTE_ADDR']}',
                    wr_1 = '".addslashes($wr_1)."', wr_2 = '".addslashes($wr_2)."',
                    wr_3 = '".addslashes($wr_3)."', wr_4 = '".addslashes($wr_4)."',
                    wr_5 = '".addslashes($wr_5)."', wr_6 = '".addslashes($wr_6)."',
                    wr_7 = '".addslashes($wr_7)."', wr_8 = '".addslashes($wr_8)."',
                    wr_9 = '".addslashes($wr_9)."', wr_10 = '".addslashes($wr_10)."' ");

    // 3. 첨부파일 정보 DB 복사 및 실제 파일 물리적 복사
    $f_res = sql_query(" select * from {$g5['board_file_table']} where bo_table = '{$bo_table}' and wr_id = '{$wr_id}' ");
    
    $dst_dir = G5_DATA_PATH.'/file/'.$target_table;
    if(!is_dir($dst_dir)) { 
        @mkdir($dst_dir, G5_DIR_PERMISSION); 
        @chmod($dst_dir, G5_DIR_PERMISSION); 
    }

    while ($f_row = sql_fetch_array($f_res)) {
        // 파일 정보 DB 입력
        sql_query(" insert into {$g5['board_file_table']}
                    set bo_table = '$target_table',
                        wr_id = '$next_id',
                        bf_no = '{$f_row['bf_no']}',
                        bf_source = '{$f_row['bf_source']}',
                        bf_file = '{$f_row['bf_file']}',
                        bf_download = 0,
                        bf_content = '".addslashes($f_row['bf_content'])."',
                        bf_filesize = '{$f_row['bf_filesize']}',
                        bf_width = '{$f_row['bf_width']}',
                        bf_height = '{$f_row['bf_height']}',
                        bf_type = '{$f_row['bf_type']}',
                        bf_datetime = '".G5_TIME_YMDHIS."' ");

        // 실제 파일 복사
        $src_file = G5_DATA_PATH.'/file/'.$bo_table.'/'.$f_row['bf_file'];
        if(file_exists($src_file)) { 
            @copy($src_file, $dst_dir.'/'.$f_row['bf_file']); 
        }
    }

    // 4. 타겟 게시판 통계 업데이트 (글수, 새글알림)
    sql_query(" update {$g5['board_table']} set bo_count_write = bo_count_write + 1 where bo_table = '{$target_table}' ");
    sql_query(" insert into {$g5['board_new_table']} ( bo_table, wr_id, wr_parent, bn_datetime, mb_id ) values ( '$target_table', '$next_id', '$next_id', '".G5_TIME_YMDHIS."', '{$member['mb_id']}' ) ");
}

// 5. 완료 후 현재 글 보기로 이동
goto_url(get_pretty_url($bo_table, $wr_id));
?>


- 이상 - 

test ID/PW 1234

https://ysmoto.kr/ys2/


 

첨부파일

1234.jpg (21.9 KB)
0회 2026-03-09 16:09
2명이 반응했습니다
|

댓글 10개

2026-03-10 (화) 08:27:32
감사합니다 ^^
고맙습니다.
감사 합니다.
좋은 하루 보내세요.
감사합니다~~~!!!
실력자 분이 여기서 이러시면 안됩니다. ~_~
감사합니다.
감사합니다.
네. 고맙습니다.
댓글을 작성하시려면 로그인이 필요합니다.

그누보드5 팁자료실

2,788건
+
제목 글쓴이 날짜 조회
22-06-20 조회 8,230
09-11 조회 144
09-04 조회 772
08-09 조회 1,630
08-05 조회 2,818
07-30 조회 1,629
07-30 조회 1,527
07-15 조회 2,812
07-01 조회 2,993
06-30 조회 2,993
06-22 조회 3,717
06-17 조회 2,863
06-14 조회 1,607
05-29 조회 1,698
05-16 조회 1,642
05-04 조회 3,144
04-29 조회 3,335
04-28 조회 3,149
04-27 조회 3,120
04-25 조회 2,146
04-24 조회 3,874
04-23 조회 3,273
04-14 조회 2,289
04-08 조회 3,129
04-01 조회 4,835
03-31 조회 3,851
03-16 조회 3,994
03-14 조회 5,165
03-13 조회 4,192
03-10 조회 3,948
03-09 조회 4,072