From 40c757ea36cc7baf5833a33d120449bf91ed5d96 Mon Sep 17 00:00:00 2001 From: KWON Date: Mon, 15 Dec 2025 17:55:17 +0900 Subject: [PATCH] =?UTF-8?q?=EB=A9=94=EC=9D=B8=20=EB=B0=B0=EB=84=88=20?= =?UTF-8?q?=EC=98=81=EC=83=81=EC=9E=AC=EC=83=9D=20=EA=B8=B0=EB=8A=A5?= =?UTF-8?q?=EC=B6=94=EA=B0=80.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- adm/rb/banner_form.php | 87 ++++++++++++++- adm/rb/banner_form_update.php | 89 +++++++++++++-- .../banner/skin/rb.wide_slide/banner.skin.php | 103 ++++++++++++++---- 3 files changed, 244 insertions(+), 35 deletions(-) diff --git a/adm/rb/banner_form.php b/adm/rb/banner_form.php index c16af3f18..98df5d5b6 100644 --- a/adm/rb/banner_form.php +++ b/adm/rb/banner_form.php @@ -29,6 +29,26 @@ if (!sql_query("SELECT bn_device FROM rb_banner LIMIT 0, 1")) { sql_query("UPDATE rb_banner SET bn_device = 'pc'", true); } +// 콘텐츠 유형 필드 추가 (image/video/video_url/youtube/vimeo) +if (!sql_query("SELECT bn_content_type FROM rb_banner LIMIT 0, 1")) { + sql_query("ALTER TABLE `rb_banner` ADD `bn_content_type` varchar(20) NOT NULL DEFAULT 'image' AFTER `bn_device`", true); +} + +// 비디오 URL 필드 추가 +if (!sql_query("SELECT bn_video_url FROM rb_banner LIMIT 0, 1")) { + sql_query("ALTER TABLE `rb_banner` ADD `bn_video_url` varchar(500) NOT NULL DEFAULT '' AFTER `bn_content_type`", true); +} + +// 유튜브 URL 필드 추가 +if (!sql_query("SELECT bn_youtube_url FROM rb_banner LIMIT 0, 1")) { + sql_query("ALTER TABLE `rb_banner` ADD `bn_youtube_url` varchar(500) NOT NULL DEFAULT '' AFTER `bn_video_url`", true); +} + +// 비메오 URL 필드 추가 +if (!sql_query("SELECT bn_vimeo_url FROM rb_banner LIMIT 0, 1")) { + sql_query("ALTER TABLE `rb_banner` ADD `bn_vimeo_url` varchar(500) NOT NULL DEFAULT '' AFTER `bn_youtube_url`", true); +} + include_once(G5_ADMIN_PATH . '/admin.head.php'); ?> @@ -45,9 +65,23 @@ include_once(G5_ADMIN_PATH . '/admin.head.php'); + + + + + + + + 이미지 - + + + 동영상 파일 + + + +

업로드된 파일: ' . basename($video_file) . '

'; + echo ' '; + } + } + ?> + + + + 비디오 URL + + + + + + + 유튜브 + + + + + + + 비메오 + + + + + @@ -205,6 +276,20 @@ include_once(G5_ADMIN_PATH . '/admin.head.php'); + + \ No newline at end of file diff --git a/adm/rb/banner_form_update.php b/adm/rb/banner_form_update.php index 358ddac37..2c8144bfd 100644 --- a/adm/rb/banner_form_update.php +++ b/adm/rb/banner_form_update.php @@ -16,24 +16,60 @@ check_admin_token(); $bn_bimg = isset($_FILES['bn_bimg']['tmp_name']) ? $_FILES['bn_bimg']['tmp_name'] : null; $bn_bimg_name = isset($_FILES['bn_bimg']['name']) ? $_FILES['bn_bimg']['name'] : null; +$bn_video_file = isset($_FILES['bn_video_file']['tmp_name']) ? $_FILES['bn_video_file']['tmp_name'] : null; +$bn_video_name = isset($_FILES['bn_video_file']['name']) ? $_FILES['bn_video_file']['name'] : null; +$bn_content_type = isset($bn_content_type) ? $bn_content_type : 'image'; +$bn_video_url = isset($bn_video_url) ? clean_xss_tags($bn_video_url) : ''; +$bn_youtube_url = isset($bn_youtube_url) ? clean_xss_tags($bn_youtube_url) : ''; +$bn_vimeo_url = isset($bn_vimeo_url) ? clean_xss_tags($bn_vimeo_url) : ''; $bn_id = isset($bn_id) ? (int) $bn_id : 0; $bn_bimg_del = isset($bn_bimg_del) ? $bn_bimg_del : null; +$bn_video_del = isset($bn_video_del) ? $bn_video_del : null; if ($bn_bimg_del) { @unlink(G5_DATA_PATH."/banners/$bn_id"); } -// 파일이 이미지인지 체크합니다. -if ($bn_bimg || $bn_bimg_name) { - if (!preg_match('/\.(gif|jpe?g|bmp|png)$/i', $bn_bimg_name)) { - alert("이미지 파일만 업로드 할 수 있습니다."); - } +if ($bn_video_del) { + @unlink(G5_DATA_PATH."/banners/$bn_id"); +} - $timg = @getimagesize($bn_bimg); - if ($timg === false || $timg[2] < 1 || $timg[2] > 16) { - alert("이미지 파일만 업로드 할 수 있습니다."); +// 콘텐츠 유형에 따른 검증 +if ($bn_content_type === 'image') { + // 파일이 이미지인지 체크합니다. + if ($bn_bimg || $bn_bimg_name) { + if (!preg_match('/\.(gif|jpe?g|bmp|png)$/i', $bn_bimg_name)) { + alert("이미지 파일만 업로드 할 수 있습니다."); + } + + $timg = @getimagesize($bn_bimg); + if ($timg === false || $timg[2] < 1 || $timg[2] > 16) { + alert("이미지 파일만 업로드 할 수 있습니다."); + } + } +} elseif ($bn_content_type === 'video') { + // 동영상 파일 검증 + if ($bn_video_file || $bn_video_name) { + if (!preg_match('/\.(mp4|mkv|mov|avi|webm|flv|wmv|m4v)$/i', $bn_video_name)) { + alert("동영상 파일(MP4, MKV, MOV, AVI, WebM, FLV, WMV, M4V)만 업로드 할 수 있습니다."); + } + } +} elseif ($bn_content_type === 'video_url') { + // URL 검증 + if (!$bn_video_url) { + alert("비디오 URL을 입력하세요."); + } +} elseif ($bn_content_type === 'youtube') { + // 유튜브 URL 검증 + if (!$bn_youtube_url) { + alert("유튜브 URL을 입력하세요."); + } +} elseif ($bn_content_type === 'vimeo') { + // 비메오 URL 검증 + if (!$bn_vimeo_url) { + alert("비메오 URL을 입력하세요."); } } @@ -50,7 +86,22 @@ if(isset($_POST['bn_position_use']) && $_POST['bn_position_use']) { } if ($w == "") { - if (!$bn_bimg_name) alert('배너 이미지를 업로드 하세요.'); + // 콘텐츠 유형별 필수 검사 + if ($bn_content_type === 'image' && !$bn_bimg_name) { + alert('배너 이미지를 업로드 하세요.'); + } + if ($bn_content_type === 'video' && !$bn_video_name) { + alert('동영상 파일을 업로드 하세요.'); + } + if ($bn_content_type === 'video_url' && !$bn_video_url) { + alert('비디오 URL을 입력하세요.'); + } + if ($bn_content_type === 'youtube' && !$bn_youtube_url) { + alert('유튜브 URL을 입력하세요.'); + } + if ($bn_content_type === 'vimeo' && !$bn_vimeo_url) { + alert('비메오 URL을 입력하세요.'); + } sql_query("ALTER TABLE rb_banner AUTO_INCREMENT=1"); @@ -61,6 +112,10 @@ if ($w == "") { bn_alt4 = '$bn_alt4', bn_url = '$bn_url', bn_device = '$bn_device', + bn_content_type = '$bn_content_type', + bn_video_url = '$bn_video_url', + bn_youtube_url = '$bn_youtube_url', + bn_vimeo_url = '$bn_vimeo_url', bn_position = '$bn_position', bn_border = '$bn_border', bn_radius = '$bn_radius', @@ -82,6 +137,10 @@ if ($w == "") { bn_alt4 = '$bn_alt4', bn_url = '$bn_url', bn_device = '$bn_device', + bn_content_type = '$bn_content_type', + bn_video_url = '$bn_video_url', + bn_youtube_url = '$bn_youtube_url', + bn_vimeo_url = '$bn_vimeo_url', bn_position = '$bn_position', bn_border = '$bn_border', bn_radius = '$bn_radius', @@ -100,9 +159,17 @@ if ($w == "") { } if ($w == "" || $w == "u") { - if (isset($_FILES['bn_bimg']['name']) && $_FILES['bn_bimg']['name']) { - rb_upload_files($_FILES['bn_bimg']['tmp_name'], $bn_id, G5_DATA_PATH."/banners"); + // 콘텐츠 유형에 따라 파일 업로드 + if ($bn_content_type === 'image') { + if (isset($_FILES['bn_bimg']['name']) && $_FILES['bn_bimg']['name']) { + rb_upload_files($_FILES['bn_bimg']['tmp_name'], $bn_id, G5_DATA_PATH."/banners"); + } + } elseif ($bn_content_type === 'video') { + if (isset($_FILES['bn_video_file']['name']) && $_FILES['bn_video_file']['name']) { + rb_upload_files($_FILES['bn_video_file']['tmp_name'], $bn_id, G5_DATA_PATH."/banners"); + } } + // 나머지 타입(video_url, youtube, vimeo)은 파일 업로드 필요 없음 (URL만 저장) goto_url("./banner_form.php?w=u&bn_id=$bn_id"); } else { diff --git a/rb/rb.mod/banner/skin/rb.wide_slide/banner.skin.php b/rb/rb.mod/banner/skin/rb.wide_slide/banner.skin.php index 8f9b4758c..3decafca0 100644 --- a/rb/rb.mod/banner/skin/rb.wide_slide/banner.skin.php +++ b/rb/rb.mod/banner/skin/rb.wide_slide/banner.skin.php @@ -49,21 +49,85 @@ while ($row = sql_fetch_array($result)) { $bn_border = isset($row['bn_border']) && $row['bn_border'] ? ' bn_border' : ''; $bn_radius = isset($row['bn_radius']) && $row['bn_radius'] ? ' bn_radius' : ''; $bn_image = G5_DATA_URL.'/banners/'.$row['bn_id']; + $bn_content_type = isset($row['bn_content_type']) ? $row['bn_content_type'] : 'image'; + $bn_video_url = isset($row['bn_video_url']) ? $row['bn_video_url'] : ''; + $bn_youtube_url = isset($row['bn_youtube_url']) ? $row['bn_youtube_url'] : ''; + $bn_vimeo_url = isset($row['bn_vimeo_url']) ? $row['bn_vimeo_url'] : ''; // 새창 옵션 $bn_new_win = isset($row['bn_new_win']) && $row['bn_new_win'] ? ' target="_blank"' : ''; - if ($i == 0) echo '
    '.PHP_EOL; - + // 콘텐츠 파일 존재 여부 확인 $bimg = G5_DATA_PATH.'/banners/'.$row['bn_id']; - if (file_exists($bimg)) { - $banner = ''; - $size = getimagesize($bimg); - $img_width = $size[0]; + $file_exists = file_exists($bimg); + + // 콘텐츠 유형별 출력 가능 여부 확인 + $can_display = false; + if ($bn_content_type === 'image' && $file_exists) { + $can_display = true; + } elseif ($bn_content_type === 'video' && $file_exists) { + $can_display = true; + } elseif ($bn_content_type === 'video_url' && !empty($bn_video_url)) { + $can_display = true; + } elseif ($bn_content_type === 'youtube' && !empty($bn_youtube_url)) { + $can_display = true; + } elseif ($bn_content_type === 'vimeo' && !empty($bn_vimeo_url)) { + $can_display = true; + } + + // 출력 가능한 배너만 처리 + if ($can_display) { + if ($i == 0) echo '
      '.PHP_EOL; + echo '
      '.PHP_EOL; echo '
      '.PHP_EOL; - echo ''.PHP_EOL; + + // 콘텐츠 유형별 렌더링 + if ($bn_content_type === 'image') { + echo ''.PHP_EOL; + } elseif ($bn_content_type === 'video') { + // 로컬 업로드 동영상 + echo ''.PHP_EOL; + } elseif ($bn_content_type === 'video_url') { + // 외부 비디오 URL (MP4, M3U8 등) + echo ''.PHP_EOL; + } elseif ($bn_content_type === 'youtube') { + // 유튜브 embed URL 변환 + $youtube_embed_url = ''; + if (preg_match('/youtube\.com\/watch\?v=([a-zA-Z0-9_-]+)/', $bn_youtube_url, $match)) { + $youtube_embed_url = 'https://www.youtube.com/embed/' . $match[1]; + } elseif (preg_match('/youtu\.be\/([a-zA-Z0-9_-]+)/', $bn_youtube_url, $match)) { + $youtube_embed_url = 'https://www.youtube.com/embed/' . $match[1]; + } else { + $youtube_embed_url = $bn_youtube_url; + } + echo ''.PHP_EOL; + } elseif ($bn_content_type === 'vimeo') { + // 비메오 embed URL 변환 + $vimeo_embed_url = ''; + if (preg_match('/vimeo\.com\/(\d+)/', $bn_vimeo_url, $match)) { + $vimeo_embed_url = 'https://player.vimeo.com/video/' . $match[1]; + } else { + $vimeo_embed_url = $bn_vimeo_url; + } + echo ''.PHP_EOL; + } elseif ($bn_content_type === 'link') { + // 외부 영상 링크 (MP4, M3U8, 스트리밍 URL 등) + echo ''.PHP_EOL; + } + echo '
      '.PHP_EOL; echo '
      '.PHP_EOL; @@ -93,6 +157,8 @@ while ($row = sql_fetch_array($result)) { echo '
      '.$row['bn_alt2'].'
      '.PHP_EOL; } + // 배너 링크 처리 + $banner = ''; if(isset($row['bn_url']) && $row['bn_url']) { if ($row['bn_url'][0] == '#') { $banner .= ''; @@ -111,10 +177,10 @@ while ($row = sql_fetch_array($result)) { } } - $banner .= '
      '.PHP_EOL; - - - echo $banner; + if($banner) { + echo $banner; + echo '
      '.PHP_EOL; + } echo '
        '.PHP_EOL; @@ -128,18 +194,9 @@ while ($row = sql_fetch_array($result)) { echo '
      '.PHP_EOL; - echo '
      '.PHP_EOL; - - - echo '
      '.PHP_EOL; - - - - - if (isset($row['bn_ad_ico']) && $row['bn_ad_ico']) { - echo 'AD'.PHP_EOL; - } - echo '
      '.PHP_EOL; + echo '
    '.PHP_EOL; // sl_content 닫기 + echo '
    '.PHP_EOL; // sl_bn_inner 닫기 + echo '
'.PHP_EOL; // swiper-slide 닫기 } $i++; }