1원 짜리 팁. 글 등록시 다른 게시판에 같이 등록 하기 ..... 폭파 추가.
받는 쪽만 폭파 됩니다.받는 쪽 폴더 707로 권한 변경
받는 쪽 list.skin.php 에 상단에 아래 추가.
$target_table = "basict1000"; 테이블명 수정해 주셔야 합니다.
$target_table = "basict1000";
$write_table = $g5['write_prefix'] . $target_table;
// 1. 삭제 대상 ID 먼저 가져오기 (성능과 안정성을 위해 분리)
$now_time = G5_TIME_YMDHIS;
$sql_ids = " select wr_id from $write_table where wr_1 != '' and wr_1 <= '$now_time' ";
$result_ids = sql_query($sql_ids);
$ids_to_delete = array();
while ($row = sql_fetch_array($result_ids)) {
$ids_to_delete[] = $row['wr_id'];
}
// 2. 대상이 있을 때만 삭제 실행
if (count($ids_to_delete) > 0) {
$delete_ids_str = implode(',', $ids_to_delete);
// 원글 삭제
sql_query(" delete from $write_table where wr_id in ($delete_ids_str) ");
// 새글 알림 삭제 (에러를 유발하던 서브쿼리 제거)
sql_query(" delete from {$g5['board_new_table']} where bo_table = '$target_table' and wr_id in ($delete_ids_str) ");
// 전체 글 수 재카운트
$row_count = sql_fetch(" select count(*) as cnt from $write_table where wr_is_comment = 0 ");
$total_cnt = (int)$row_count['cnt'];
sql_query(" update {$g5['board_table']} set bo_count_write = '$total_cnt' where bo_table = '$target_table' ");
// 화면 새로고침
goto_url(G5_BBS_URL."/board.php?bo_table=".$target_table);
}
보내는 쪽 write.skin.php 적절한 곳에
<div class="custom-order-box">
<!-- 왼쪽: 발주 전송 체크 -->
<div class="order-item write_div_custom">
<input type="checkbox" name="copy_to_other" value="1" id="copy_to_other">
<label for="copy_to_other">
🚀 [테스트1000] 게시판으로 발주 전송
</label>
</div>
<?php
// 값이 있으면 가져오고, 없으면 빈 값을 넣어서 에러 방지
$saved_days = isset($write['wr_9']) ? $write['wr_9'] : '';
?>
<!-- 오른쪽: 폭파 기간 선택 -->
<?php $saved_days = isset($write['wr_9']) ? $write['wr_9'] : ''; ?>
<div style="flex:1; margin-left:10px;">
<label style="display:block; font-weight:bold; margin-bottom:8px; color:#2563eb; font-size:0.9em;">⏳ 발주시만 해당 / 자동 폭파 기간</label>
<select name="wr_9" id="wr_9" style="width:100%; height:42px; border:1px solid #bfdbfe; border-radius:8px; padding:0 10px; color:#2563eb; font-weight:bold; background:#eff6ff; cursor:pointer; font-size:13px;">
<option value="" <?php echo ($saved_days == "") ? "selected" : ""; ?>>기한 없음 (수동)</option>
<option value="1" <?php echo ($saved_days == "1") ? "selected" : ""; ?>>1일 후 자동 폭파</option>
<option value="3" <?php echo ($saved_days == "3") ? "selected" : ""; ?>>3일 후 자동 폭파</option>
<option value="7" <?php echo ($saved_days == "7") ? "selected" : ""; ?>>7일 후 자동 폭파</option>
<option value="30" <?php echo ($saved_days == "30") ? "selected" : ""; ?>>30일 후 자동 폭파</option>
</select>
</div>
</div>
write_update.head.skin.php (없으시면 만드시면 됩니다)
$target_table = "basict1000"; 바로 아래 .... 사용하실 테이블명 으로
변경해 주세요.
<?php
if (!defined('_GNUBOARD_')) exit;
// 새글 작성($w == '') 시 실행
if ($w == '' && isset($_POST['wr_9']) && $_POST['wr_9'] != '') {
$target_table = "basict1000"; // 복제될 대상 테이블
$target_write_table = $g5['write_prefix'] . $target_table;
// [폭파 시각 및 복제 로직 계산]
$copy_wr_1 = "";
$wr_9_val = $_POST['wr_9'];
if ($wr_9_val == '1m') {
// [테스트용] 1분 뒤로 설정
$copy_wr_1 = date('Y-m-d H:i:s', strtotime("+1 minutes"));
} else {
// [기본] 선택한 일(days) 단위로 설정
$days = (int)$wr_9_val;
$copy_wr_1 = date('Y-m-d H:i:s', strtotime("+{$days} days"));
}
// [글 복제 실행]
$sql = " insert into $target_write_table
set wr_num = '".get_next_num($target_write_table)."',
wr_reply = '',
wr_parent = 0,
wr_subject = '".sql_real_escape_string($_POST['wr_subject'])."',
wr_content = '".sql_real_escape_string($_POST['wr_content'])."',
mb_id = '{$member['mb_id']}',
wr_name = '".sql_real_escape_string($wr_name)."',
wr_datetime = '".G5_TIME_YMDHIS."',
wr_last = '".G5_TIME_YMDHIS."',
wr_ip = '{$_SERVER['REMOTE_ADDR']}',
wr_1 = '{$copy_wr_1}',
wr_9 = '".sql_real_escape_string($wr_9_val)."' ";
sql_query($sql);
$new_id = sql_insert_id();
// 부모글 번호 업데이트
sql_query(" update $target_write_table set wr_parent = '$new_id' where wr_id = '$new_id' ");
// [대상 게시판 카운트 및 새글 알림 업데이트]
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', '$new_id', '$new_id', '".G5_TIME_YMDHIS."', '{$member['mb_id']}' ) ");
}
?>
- 이상 -
03250920
내용:
오작동 수정
test ID/PW 1234
https://ysmoto.kr/ys2/bbs/board.php?bo_table=basict10&device=pc
총 1명이 반응했습니다
|
댓글을 작성하시려면 로그인이 필요합니다.
댓글 6개