1원 짜리 팁. 글 등록시 다른 게시판에 같이 등록 하기 .....
글 등록시 다른 게시판에 같이 등록 하기 .....
찾아 보니 원본 수정해서 쓰는건 있는거 같습니다.
사용하실 스킨(오는 글을 받아줄)
폴더의 권한설정을 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을 구해서 더 낮게 설정 (그누보드 번호 정렬의 핵심)
$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; // 데이터가 하나도 없었을 경우 대비
// 2. 대상 게시판의 새 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'];
// 3. 게시글 데이터 복제 (wr_num을 $next_num으로 교체!)
sql_query(" insert into $target_write_table
set wr_id = '$next_id',
wr_num = '$next_num',
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)."' ");
// 4. 첨부파일 정보 및 실제 파일 복사 (그대로 유지)
$f_res = sql_query(" select * from {$g5['board_file_table']} where bo_table = '{$bo_table}' and wr_id = '{$wr_id}' ");
while ($f_row = sql_fetch_array($f_res)) {
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'];
$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); }
if(file_exists($src_file)) { @copy($src_file, $dst_dir.'/'.$f_row['bf_file']); }
}
// 5. 대상 게시판 전체 글 수 카운트 업데이트 (그대로 유지)
sql_query(" update {$g5['board_table']} set bo_count_write = bo_count_write + 1 where bo_table = '{$target_table}' ");
}
// 6. 주소 리다이렉트
goto_url(get_pretty_url($bo_table, $wr_id));
?>
- 이상 -
test ID/PW 1234
https://ysmoto.kr/ys2/bbs/board.php?bo_table=basict10&device=pc
첨부파일
총 1명이 반응했습니다
|
댓글을 작성하시려면 로그인이 필요합니다.
댓글 6개