sosososo

도메인이 바뀐경우  게시판 이미지 경로 바꾸기 입니다.

· 2026-04-24 (금) 00:50:57 · 3886 · 6

도메인이 바뀐경우  게시판 이미지 경로 바꾸기 입니다.

 

에디터에 등록된 모든 이미지 경로를 /data로  수정

 

예)   도메인.com/data/editor/images.jpg  >  /data/editor/images.jpg

<?php
include_once('./_common.php');
if (!defined('_GNUBOARD_')) exit;
if (!$is_admin) die('관리자만 실행 가능합니다.');
set_time_limit(0);
echo '<pre>';
$sql = " SELECT bo_table FROM {$g5['board_table']} ORDER BY bo_table ";
$result = sql_query($sql);
$total_board = 0;
$total_post  = 0;
/*
 * /data/editor/ 앞에 어떤 도메인이 붙어 있든 제거
 * 예:
 * http://a.도메인.com/data/editor/...
 * https://a.도메인.com/data/editor/...
 * //a.도메인.com/data/editor/...
 * 모두 => /data/editor/...
 */
$pattern = '#(?:https?:)?//[^"\']+/data/editor/#i';
$replacement = '/data/editor/';
while ($row = sql_fetch_array($result)) {
    $bo_table = $row['bo_table'];
    $write_table = $g5['write_prefix'] . $bo_table;
    $total_board++;
    echo "게시판 처리중: {$bo_table}\n";
    $select_sql = " SELECT wr_id, wr_content FROM {$write_table} ";
    $write_result = sql_query($select_sql);
    $board_count = 0;
    while ($wr = sql_fetch_array($write_result)) {
        $wr_id = (int)$wr['wr_id'];
        $content = $wr['wr_content'];
        $new_content = preg_replace($pattern, $replacement, $content);
        if ($new_content !== $content) {
            $escaped_content = sql_real_escape_string($new_content);
            $update_sql = "
                UPDATE {$write_table}
                SET wr_content = '{$escaped_content}'
                WHERE wr_id = '{$wr_id}'
            ";
            sql_query($update_sql);
            $board_count++;
            $total_post++;
            echo " - 수정됨: wr_id = {$wr_id}\n";
        }
    }
    echo " => {$bo_table} 수정 건수: {$board_count}\n\n";
}
echo "전체 게시판 수: {$total_board}\n";
echo "전체 수정 게시글 수: {$total_post}\n";
echo "완료\n";
echo '</pre>';
?>
 

7명이 반응했습니다
|

댓글 6개

새파일 만든 후  소스 넣고  실행 하시면 됩니다.
 
좋은 팁이 될것 같습니다.
2026-04-24 (금) 22:38:40
감사합니다 ^^
우~~~~와
감사합니다.
2026-07-03 (금) 12:11:53
한방에 수정했습니다. 감사합니다.
댓글을 작성하시려면 로그인이 필요합니다.

그누보드5 팁자료실

2,788건
+
제목 글쓴이 날짜 조회
22-06-20 조회 8,240
09-11 조회 146
09-04 조회 784
08-09 조회 1,644
08-05 조회 2,830
07-30 조회 1,640
07-30 조회 1,544
07-15 조회 2,822
07-01 조회 3,001
06-30 조회 2,998
06-22 조회 3,729
06-17 조회 2,876
06-14 조회 1,618
05-29 조회 1,712
05-16 조회 1,656
05-04 조회 3,157
04-29 조회 3,343
04-28 조회 3,158
04-27 조회 3,126
04-25 조회 2,155
04-24 조회 3,887
04-23 조회 3,281
04-14 조회 2,300
04-08 조회 3,137
04-01 조회 4,842
03-31 조회 3,857
03-16 조회 4,005
03-14 조회 5,174
03-13 조회 4,198
03-10 조회 3,957
03-09 조회 4,083