38 lines
1.3 KiB
PHP
38 lines
1.3 KiB
PHP
<?php
|
|
if (!defined('_GNUBOARD_')) exit;
|
|
|
|
$config_path = __DIR__ . '/config.php';
|
|
if (!file_exists($config_path)) return;
|
|
include_once($config_path);
|
|
|
|
// 외부에서 전달된 $ga_id가 없으면 설정 파일의 기본값 사용
|
|
$target_ga_id = isset($ga_id) ? $ga_id : $google_ads_config['default_ga_id'];
|
|
|
|
// DB에서 광고 정보 가져오기
|
|
$ad = sql_fetch(" select * from g5_google_ads where ga_id = '{$target_ga_id}' and ga_use = 1 ");
|
|
|
|
if (!$ad) {
|
|
if ($is_admin) {
|
|
echo "<div style='padding:20px; border:2px dashed red; text-align:center;'>[관리자 알림] 구글 애드센스 정보를 찾을 수 없습니다. (ID: {$target_ga_id})</div>";
|
|
}
|
|
return;
|
|
}
|
|
|
|
$visual_id = 'google-ads-' . uniqid();
|
|
?>
|
|
|
|
<div class="google-ads-wrap" id="<?php echo $visual_id; ?>">
|
|
<!-- Google AdSense -->
|
|
<ins class="adsbygoogle"
|
|
style="display:block"
|
|
data-ad-client="<?php echo $ad['ga_client_id']; ?>"
|
|
data-ad-slot="<?php echo $ad['ga_slot_id']; ?>"
|
|
data-ad-format="<?php echo $ad['ga_format']; ?>"
|
|
<?php echo $ad['ga_responsive'] ? 'data-full-width-responsive="true"' : ''; ?>></ins>
|
|
<script>
|
|
(adsbygoogle = window.adsbygoogle || []).push({});
|
|
</script>
|
|
</div>
|
|
|
|
<link rel="stylesheet" href="<?php echo G5_THEME_URL; ?>/rb.custom/google_ads/module.css?ver=<?php echo G5_CSS_VER; ?>">
|