외부이미지 저장관련 질문좀 드릴게요
본문
untitled님의 외부이미지 저장 팁 (1번 게시판)
http://sir.kr/g5_tip/2657?sfl=wr_subject%7C%7Cwr_content&stx=%EC%99%B8%EB%B6%80
untitled님의 유투브 게시판 (2번 게시판)
http://sir.kr/g5_skin/8543?sfl=wr_name%2C1&stx=untitled
1번게판에는 외부이미지 write_update.skin.php 파일만 basic스킨에 넣었구요
2번 유투브게시판의 경우에는 정상적으로 설치하여 사용중에 있습니다
2번 유투브 게시판을 설치전에는 1번게시판이 정상적으로
외부이미지 저장이 되었는데요!
유투브 스킨을 설치후부터 1번게시판 글작성후 저장을 클릭하게되면
/bbs/write_update.php에서 list로 넘어가지 않고 그냥 하얀화면으로 오류가 발생하네요
1번게시판 스킨에서 write_update.skin.php 파일을 삭제후에
글을 쓰면 다시 정상적으로 되구요
제가 초보라 자세히 부탁드릴게요 ..
1번 게시판 write_update.skin.php
<?php
//ver1.0 150410 @_untitle_d
function save_remote_image($url, $save_path)
{
$ch = curl_init ($url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$data=curl_exec($ch);
curl_close ($ch);
$chars_array = array_merge(range(0,9), range('a','z'), range('A','Z'));
$filename = preg_replace("/\.(php|phtm|htm|cgi|pl|exe|jsp|asp|inc)/i", "$0-x", basename($url));
shuffle($chars_array);
$shuffle = implode("", $chars_array);
$change_filename = abs(ip2long($_SERVER[REMOTE_ADDR])).'_'.substr($shuffle,0,8).'_'.str_replace('%', '', urlencode(str_replace(' ', '_', $filename)));
$out_path = $save_path.$change_filename;
if(file_exists($out_path)) @unlink($out_path);
$fp = fopen($out_path,'x');
fwrite($fp, $data);
fclose($fp);
return $change_filename;
}
if ($w == '' || $w == 'r'){
$data_dir = G5_DATA_PATH.'/file/'.$bo_table.'/';
$data_url = G5_DATA_URL.'/file/'.$bo_table.'/';
$img_content = str_replace(">", ">", str_replace("<", "<", stripslashes($_POST[wr_content])));
$patten = "/<img[^>]*src=[\"']?([^>\"']+)[\"']?[^>]*>/i";
preg_match_all($patten, $img_content, $match);
if ($match[1]) {
foreach ($match[1] as $link) {
$url = parse_url($link);
if ($url[host] && $url[host] != $_SERVER[HTTP_HOST]) {
$img_content = str_replace($link, ($data_url.save_remote_image($link, $data_dir)), $img_content);
}
}
$sql = "update ".$write_table." set wr_content = '".sql_real_escape_string(trim($img_content))."' where wr_id = '".$wr_id."'";
sql_query($sql);
}
}
?>
2번 유투브 게시판 write_update.skin.php 소스입니다
<?php
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
//ver1.0 150723 @_untitle_d
if ($wr_link1)
{
$yt_id = get_youtube_id(trim($wr_link1));
sql_query(" update {$write_table} set wr_1 = '{$yt_id}' where wr_id = '{$wr_id}' ");
$return = get_youtube_info($yt_id);
$yt_title = $return['items'][0]['snippet']['title'];
$yt_thumb = $return['items'][0]['snippet']['thumbnails']['high']['url'];
$url = parse_url($yt_thumb);
if ($url['host'])
{
$data_dir = G5_DATA_PATH.'/file/'.$bo_table.'/';
$data_url = G5_DATA_URL.'/file/'.$bo_table.'/';
$sri = save_remote_image($yt_thumb, $data_dir);
$jpg_info = exif_read_data($data_dir.$sri);
$sql_common = " bf_source = '{$sri}',
bf_file = '{$sri}',
bf_filesize = '{$jpg_info['FileSize']}',
bf_width = '{$jpg_info['COMPUTED']['Width']}',
bf_height = '{$jpg_info['COMPUTED']['Height']}',
bf_type = '{$jpg_info['FileType']}',
bf_datetime = '".G5_TIME_YMDHIS."' ";
}else
$sql_common = " bf_source = '', bf_file = '', bf_filesize = '0', bf_width = '0', bf_height = '0', bf_type = '0', bf_datetime = '".G5_TIME_YMDHIS."' ";
$row = sql_fetch(" select count(*) as cnt from {$g5['board_file_table']} where bo_table = '{$bo_table}' and wr_id = '{$wr_id}' and bf_no = '0' ");
if ($row['cnt'])
sql_query(" update {$g5['board_file_table']} set {$sql_common} where bo_table = '{$bo_table}' and wr_id = '{$wr_id}' and bf_no = '0' ");
else
sql_query(" insert into {$g5['board_file_table']} set bo_table = '{$bo_table}', wr_id = '{$wr_id}', bf_no = '0', bf_download = 0, {$sql_common} ");
$row = sql_fetch(" select count(*) as cnt from {$g5['board_file_table']} where bo_table = '{$bo_table}' and wr_id = '{$wr_id}' ");
sql_query(" update {$write_table} set wr_file = '{$row['cnt']}' where wr_id = '{$wr_id}' ");
//if ($wr_subject == 'y' or $wr_subject == 'ㅛ')
// sql_querby(" update {$write_table} set wr_subject = '".mysql_real_escape_string($yt_title)."' where wr_id = '{$wr_id}' ");
}else{
sql_query(" update {$write_table} set wr_1 = '' where wr_id = '{$wr_id}' ");
$row = sql_fetch(" select bf_file from {$g5['board_file_table']} where bo_table = '{$bo_table}' and wr_id = '{$wr_id}' and bf_no = '0' ");
@unlink(G5_DATA_PATH.'/file/'.$bo_table.'/'.$row['bf_file']);
sql_query(" update {$g5['board_file_table']} set bf_source = '', bf_file = '', bf_filesize = '0', bf_width = '0', bf_height = '0', bf_type = '0', bf_datetime = '".G5_TIME_YMDHIS."' where bo_table = '{$bo_table}' and wr_id = '{$wr_id}' and bf_no = '0' ");
}
if ($wr_2){
$link = 'http://vd.whiteholic.net/'.base64_encode(trim($wr_2));
sql_query(" update {$write_table} set wr_link2 = '{$link}' where wr_id = '{$wr_id}' ");
}else{
sql_query(" update {$write_table} set wr_link2 = '' where wr_id = '{$wr_id}' ");
}
sql_query(" update {$write_table} set wr_3 = '".$pic_ratio1."|".$pic_ratio2."', wr_4 = '".$autoplay1."|".$autoplay2."' where wr_id = '{$wr_id}' ");
?>
답변을 작성하시기 전에 로그인 해주세요.