first commit 2
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
if (!defined('_GNUBOARD_')) exit;
|
||||
|
||||
/**
|
||||
* rb.custom :: google_ads/config.php
|
||||
* 구글 애드센스 출력 모듈 설정
|
||||
*/
|
||||
|
||||
$google_ads_config = array(
|
||||
// 기본적으로 출력할 광고 ID (관리자 페이지의 ga_id)
|
||||
// module.php를 include할 때 $ga_id 변수로 덮어쓸 수 있습니다.
|
||||
'default_ga_id' => 1,
|
||||
);
|
||||
?>
|
||||
@@ -0,0 +1,10 @@
|
||||
.google-ads-wrap {
|
||||
width: 100%;
|
||||
margin: 20px 0;
|
||||
text-align: center;
|
||||
background-color: #f9f9f9; /* 광고 로딩 전 영역 표시용 (선택 사항) */
|
||||
min-height: 90px; /* 최소 높이 확보 */
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?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; ?>">
|
||||
Reference in New Issue
Block a user