<?php
$sub_menu = "999100";
include_once('./_common.php');

auth_check($auth[$sub_menu], 'r');

if ($is_admin != 'super')
    alert('최고관리자만 접근 가능합니다.');

$g5['title'] = '이미지 주소 변경';
include_once ('../admin.head.php');

// 구사이트도메인 http://www. 제외
$old = $_POST['previous_site'];

$old = trim($old); // 도메인주소 앞뒤 공백 제거
$old = rtrim($old, '/'); // 도메인주소 마지막에 / 문자 제거

// 새사이트도메인 http://www. 제외
$new= $_POST['now_site'];

$sql = sql_query("select * from {$g5['board_table']}");

while($data = sql_fetch_array($sql)){
	sql_query("update {$g5['write_prefix']}{$data['bo_table']} set wr_content=REPLACE(`wr_content`,'$old','$new')");
	sql_query("update {$g5['board_table']} set bo_content_head=REPLACE(`bo_content_head`,'$old','$new')");
	sql_query("update {$g5['board_table']} set bo_mobile_content_head=REPLACE(`bo_mobile_content_head`,'$old','$new')");
}

$sql = sql_query("select * from {$g5['content_table']}");
sql_query("update {$g5['content_table']} set co_content=REPLACE(`co_content`,'$old','$new')");
sql_query("update {$g5['content_table']} set co_mobile_content=REPLACE(`co_mobile_content`,'$old','$new')");

if($g5['g5_shop_item_table']){
	$sql = sql_query("select * from {$g5['g5_shop_item_table']}");
	sql_query("update {$g5['g5_shop_item_table']} set it_explan=REPLACE(`it_explan`,'$old','$new')");
	sql_query("update {$g5['g5_shop_item_table']} set it_mobile_explan=REPLACE(`it_mobile_explan`,'$old','$new')");
}

alert('이미지 주소변경이 완료되었습니다.', './img_rename.php?'.$qstr);
