114 lines
5.1 KiB
PHP
114 lines
5.1 KiB
PHP
<?php
|
|
include_once('./_common.php');
|
|
|
|
if (!$is_admin) {
|
|
alert('관리자만 접근 가능합니다.');
|
|
}
|
|
|
|
// curl을 사용하여 이미지를 다운로드하는 함수
|
|
function download_image_with_curl($url, $save_path) {
|
|
$ch = curl_init($url);
|
|
$fp = fopen($save_path, 'wb');
|
|
|
|
curl_setopt($ch, CURLOPT_FILE, $fp);
|
|
curl_setopt($ch, CURLOPT_HEADER, 0);
|
|
// Referer 설정 (필요시)
|
|
curl_setopt($ch, CURLOPT_REFERER, 'https://www.laser.or.kr/');
|
|
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36');
|
|
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
|
|
|
$result = curl_exec($ch);
|
|
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
|
|
|
curl_close($ch);
|
|
fclose($fp);
|
|
|
|
if ($result && $http_code == 200 && filesize($save_path) > 0) {
|
|
return true;
|
|
} else {
|
|
@unlink($save_path);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
$banners = [
|
|
['url' => 'http://www.lg.co.kr/', 'img' => 'foot-logo1.png', 'alt' => 'LG'],
|
|
['url' => '#', 'img' => 'foot-logo2.png', 'alt' => 'Partner'],
|
|
['url' => 'http://www.swhitech.com/main/', 'img' => 'foot-logo3.png', 'alt' => 'SWHitech'],
|
|
['url' => 'http://www.hblaser.co.kr', 'img' => 'foot-logo4.png', 'alt' => 'HBLaser'],
|
|
['url' => 'http://www.lasersystem.co.kr/', 'img' => 'foot-logo5.png', 'alt' => 'LaserSystem'],
|
|
['url' => 'http://www.eotechnics.com/page/main/main.php', 'img' => 'foot-logo6.png', 'alt' => 'EO Technics'],
|
|
['url' => 'https://www.lpkf.com/de/', 'img' => 'foot-logo7.jpg', 'alt' => 'LPKF'],
|
|
['url' => 'https://amplitude-laser.com/', 'img' => 'foot-logo8.png', 'alt' => 'Amplitude'],
|
|
['url' => 'http://www.mutechkorea.co.kr/', 'img' => 'foot-logo9.png', 'alt' => 'Mutech'],
|
|
['url' => 'http://www.ainnotech.com/', 'img' => 'foot-logo10.png', 'alt' => 'Ainnotech'],
|
|
['url' => 'https://www.edmundoptics.co.kr/', 'img' => 'foot-logo11.png', 'alt' => 'Edmund Optics'],
|
|
['url' => 'https://www.coherent.com/', 'img' => 'foot-logo12_new.png', 'alt' => 'Coherent'],
|
|
['url' => 'https://www.mksinst.com/', 'img' => 'foot-logo13.png', 'alt' => 'MKS'],
|
|
['url' => 'http://daekhon.co.kr/', 'img' => 'foot-logo14.png', 'alt' => 'Daekhon'],
|
|
['url' => 'https://lightrun.co.kr/', 'img' => 'foot-logo15.png', 'alt' => 'Lightrun'],
|
|
['url' => 'https://www.uniotech.kr/', 'img' => 'foot-logo16.png', 'alt' => 'Uniotech'],
|
|
['url' => 'http://www.hls-scansonic.kr/main/index.html', 'img' => 'foot-logo17.png', 'alt' => 'HLS'],
|
|
['url' => 'http://coslaser.co.kr/', 'img' => 'Wooyang_Logo.png', 'alt' => 'Wooyang'],
|
|
['url' => 'https://www.excelitas.com/', 'img' => 'foot-logo18.png', 'alt' => 'Excelitas'],
|
|
['url' => 'http://www.evlaser.co.kr/', 'img' => 'foot-logo19.jpg', 'alt' => 'EV Laser'],
|
|
['url' => 'https://www.precitec.com/kr/', 'img' => 'foot-logo20.jpg', 'alt' => 'Precitec'],
|
|
['url' => 'https://www.amadaweldtech.co.kr/', 'img' => 'foot-logo21.png', 'alt' => 'Amada']
|
|
];
|
|
|
|
// 💡 [핵심 수정] 이미지 경로에 /KOR/ 추가
|
|
$base_img_url = 'https://www.laser.or.kr/KOR/images/comm/';
|
|
$save_path = G5_DATA_PATH . '/banners/';
|
|
|
|
if (!is_dir($save_path)) {
|
|
@mkdir($save_path, G5_DIR_PERMISSION);
|
|
@chmod($save_path, G5_DIR_PERMISSION);
|
|
}
|
|
|
|
echo "<h1>배너 자동 등록 시작 (경로 수정됨)</h1>";
|
|
echo "<ul>";
|
|
|
|
$success_count = 0;
|
|
|
|
foreach ($banners as $idx => $item) {
|
|
$row = sql_fetch(" SELECT bn_id FROM rb_banner WHERE bn_alt = '{$item['alt']}' AND bn_position = 'rolling_footer' ");
|
|
|
|
if ($row['bn_id']) {
|
|
$bn_id = $row['bn_id'];
|
|
echo "<li>[중복] ID: {$bn_id} - {$item['alt']} 이미 등록됨. 이미지 다운로드만 재시도합니다.</li>";
|
|
} else {
|
|
$sql = " INSERT INTO rb_banner
|
|
SET bn_alt = '{$item['alt']}',
|
|
bn_url = '{$item['url']}',
|
|
bn_device = 'both',
|
|
bn_position = 'rolling_footer',
|
|
bn_border = '0',
|
|
bn_new_win = '1',
|
|
bn_begin_time = '" . date('Y-m-d H:i:s') . "',
|
|
bn_end_time = '" . date('Y-m-d H:i:s', strtotime('+10 years')) . "',
|
|
bn_time = '" . date('Y-m-d H:i:s') . "',
|
|
bn_hit = 0,
|
|
bn_order = " . ($idx + 1);
|
|
|
|
sql_query($sql);
|
|
$bn_id = sql_insert_id();
|
|
}
|
|
|
|
if ($bn_id) {
|
|
$remote_img = $base_img_url . $item['img'];
|
|
$local_img = $save_path . $bn_id;
|
|
|
|
if (download_image_with_curl($remote_img, $local_img)) {
|
|
echo "<li>[성공] ID: {$bn_id} - {$item['alt']} 이미지 저장 완료</li>";
|
|
$success_count++;
|
|
} else {
|
|
echo "<li style='color:red;'>[실패] ID: {$bn_id} - 이미지 다운로드 실패 ({$remote_img})</li>";
|
|
}
|
|
}
|
|
}
|
|
|
|
echo "</ul>";
|
|
echo "<h2>총 {$success_count}개의 배너 이미지가 저장되었습니다.</h2>";
|
|
echo "<p><a href='" . G5_ADMIN_URL . "/rb/banner_list.php'>[배너 관리 페이지로 이동]</a></p>";
|
|
?>
|