Files
egbim_homepage/egbim/skin/member/basic/main_header.skin.php
T
2026-07-27 17:23:52 +09:00

291 lines
11 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
include_once __DIR__ . '/asset_urls.php';
// include_once $_SERVER['DOCUMENT_ROOT']."/egbim/skin/member/basic/descope_session.php";
// 디버깅용 출력
echo "<!-- isAdmin = " . (isset($isAdmin) ? ($isAdmin ? "true" : "false") : "unset") . " -->";
// ✅ DB 연결
$pdo = new PDO("mysql:host=db;dbname=egbim;charset=utf8mb4", "egbim", "baron3840!!", [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
]);
// ✅ EG-BIM (product_code=8) 기준 최신 external_version 가져오기
$stmt = $pdo->prepare("
SELECT external_version
FROM deploy_versions
WHERE product_code = 1
ORDER BY updated_at DESC
LIMIT 1
");
$stmt->execute();
$version = $stmt->fetchColumn() ?: '1.0.0'; // fallback
// ✅ 다운로드 URL 자동 생성
$download_url = "https://release-download.hmac.kr/eg-bim/{$version}/setup_eg-bim_{$version}.exe";
?>
<header class="js__header">
<h1><a href="/egbim/index.php"></a></h1>
<div class="language">
<a href="#" class="on">KR</a>
<a href="/eng/">EN</a>
</div>
<!-- ✅ 사용자 관리 아이콘 (관리자 전용, 기본 숨김) -->
<div id="userListBtnWrap" class="menu_userlist" style="display:none;">
<a href="/egbim/skin/member/basic/descope_user_list_skin_w3.php" target="_blank" rel="noopener noreferrer">
<img src="<?php echo egbim_img_url('ico_userlist.svg'); ?>" alt="사용자 관리">
</a>
</div>
<!-- ✅ 업로드 아이콘 (관리자 전용, 기본 숨김) -->
<div id="uploadBtnWrap" class="menu_upload" style="display:none;">
<a href="/egbim/sw_upload/upload_page.php">
<img src="<?php echo egbim_img_url('ico_upload.svg'); ?>" alt="업로드">
</a>
</div>
<div class="menu_my">
<img src="<?php echo egbim_img_url('ico_my.svg'); ?>" alt="">
<ul class="menu_my_list" style="display: none;">
<li id="my_join2" class="my_join2">
<!-- JS에서 "마이페이지" or "관리페이지" 링크를 넣어줌 -->
</li>
<li id="my_login2" class="my_login2">
<a href="javascript:descopeLogout();">로그아웃</a>
</li>
<li id="my_join" class="my_join">
<a href="#" class="signup-disabled-link" aria-disabled="true">회원가입</a>
</li>
<li id="my_login" class="my_login">
<a href="javascript:login();">로그인</a>
</li>
</ul>
</div>
<div class="menu_ham"><a href="javascript:sitemap();"><div></div><div></div><div></div></a></div>
</header>
<!-- floating_menu -->
<div class="floating_menu">
<ul>
<li class="floating_faq"><a href="/egbim/bbs/descope_qa_list.php">
<i></i>
<span>Q&A</span>
</a></li>
<li class="floating_guide"><a href="https://baron-consultant.github.io/eg-bim_guide\help" target="_blank">
<i></i>
<span>사용가이드</span>
</a></li>
<li class="floating_download">
<a href="<?= htmlspecialchars($download_url) ?>">
<i></i>
<span>다운로드</span>
</a></li>
<li class="floating_buy"><a href="/egbim/bbs/buy.php">
<i></i>
<span>구매하기</span>
</a></li>
</ul>
</div>
<!-- //floating_menu -->
<script>
// 다운로드 버튼 안내
// $(document).on('click', '.floating_download a', function (e) {
// e.preventDefault(); // 링크 이동 막기
// alert('다운로드 기능은 준비중입니다.');
// });
(function () {
function getCookieValue(name) {
const prefix = name + '=';
const parts = document.cookie.split(';');
for (let i = 0; i < parts.length; i += 1) {
const part = parts[i].trim();
if (part.indexOf(prefix) === 0) {
return part.substring(prefix.length);
}
}
return '';
}
function decodeBase64Json(value) {
if (!value) return null;
try {
const binary = window.atob(value);
const bytes = Array.prototype.map.call(binary, function (char) {
return '%' + ('00' + char.charCodeAt(0).toString(16)).slice(-2);
}).join('');
return JSON.parse(decodeURIComponent(bytes));
} catch (error) {
return null;
}
}
function setStoredValue(key, value) {
if (typeof value === 'string' && value !== '') {
sessionStorage.setItem(key, value);
}
}
function restoreClientAuthSessionFromCookies() {
const baronUser = decodeBase64Json(getCookieValue('baron_user'));
if (baronUser && Array.isArray(baronUser.loginIds) && baronUser.loginIds[0]) {
const customAttributes = baronUser.customAttributes || {};
const roleNames = Array.isArray(baronUser.roleNames) ? baronUser.roleNames : [];
setStoredValue('authProvider', 'baron');
setStoredValue('loginId', baronUser.loginIds[0] || '');
setStoredValue('descopeUserId', baronUser.userId || '');
setStoredValue('userName', baronUser.name || '');
setStoredValue('phone', baronUser.phone || '');
setStoredValue('company', customAttributes.company || '');
setStoredValue('familyCompany', customAttributes.familyCompany || '');
setStoredValue('team', customAttributes.team || '');
setStoredValue('position', customAttributes.position || '');
setStoredValue('familyUniqueKey', customAttributes.familyUniqueKey || '');
setStoredValue('userRole', roleNames[0] || '');
setStoredValue('sessionJwt', sessionStorage.getItem('sessionJwt') || 'baron.session.marker');
return;
}
const descopeLoginId = getCookieValue('descope_login_id');
if (descopeLoginId && !sessionStorage.getItem('loginId')) {
const customAttributes = decodeBase64Json(getCookieValue('descope_custom_attributes')) || {};
const roleNames = decodeBase64Json(getCookieValue('descope_role_names')) || [];
setStoredValue('authProvider', sessionStorage.getItem('authProvider') || 'descope');
setStoredValue('loginId', descopeLoginId);
setStoredValue('descopeUserId', getCookieValue('descope_user_id'));
setStoredValue('userName', getCookieValue('descope_user_name'));
setStoredValue('phone', getCookieValue('descope_user_phone'));
setStoredValue('company', customAttributes.company || '');
setStoredValue('familyCompany', customAttributes.familyCompany || '');
setStoredValue('team', customAttributes.team || '');
setStoredValue('position', customAttributes.position || '');
setStoredValue('familyUniqueKey', customAttributes.familyUniqueKey || '');
setStoredValue('userRole', Array.isArray(roleNames) ? (roleNames[0] || '') : '');
}
}
restoreClientAuthSessionFromCookies();
})();
(function () {
const ADMIN_ICON_IDS = [
'b24014@hanmaceng.co.kr',
'kjy0426@hanmaceng.co.kr',
'b23065@hanmaceng.co.kr',
'shyeom1@samaneng.com',
'cjy627@hanmaceng.co.kr',
'b23072@hanmaceng.co.kr',
'b23018@hanmaceng.co.kr',
'm20331@hanmaceng.co.kr',
'cozyjin@hanmaceng.co.kr',
'm24031@hanmaceng.co.kr',
'b24051@hanmaceng.co.kr',
'rmsgud1202@hanmaceng.co.kr',
'm21318@hanmaceng.co.kr',
'b21367@hanmaceng.co.kr',
'b25023@hanmaceng.co.kr',
'sdi9429@naver.com',
'junsuy@hanmail.net',
'ilphilo92@gmail.com'
];
function normalizeLoginId(loginId) {
return String(loginId || '').trim().toLowerCase();
}
function isAdminLoginId(loginId) {
return ADMIN_ICON_IDS.includes(normalizeLoginId(loginId));
}
function applyAdminIconVisibility(loginId) {
const visible = isAdminLoginId(loginId || sessionStorage.getItem('loginId'));
$('#uploadBtnWrap').toggle(visible);
$('#userListBtnWrap').toggle(visible);
}
// 공지 HTML (닫기 가능 / 입력 방해 X)
const bannerHtml = `
<div id="login_notice_banner" class="login-notice-banner" style="
background:#0f3a2f;color:#fff;border-radius:12px;padding:14px 44px 14px 14px;
position:relative;margin:0 0 12px 0;line-height:1.6;word-break:keep-all;">
<button type="button" class="lnb-close" aria-label="닫기" style="
position:absolute;right:10px;top:8px;background:transparent;border:0;
color:#fff;font-size:20px;cursor:pointer;">×</button>
<strong style="display:block;margin-bottom:6px;">[로그인 시스템 변경 안내]</strong>
<p class="left" style="margin:0 0 6px;">
더 나은 보안을 위해 2025년 8월 8일부터
로그인 시스템이 변경되었습니다.
기존 회원 또한 신규 시스템에 맞춰<br>
재가입을 진행해주시기 바랍니다.
</p>
<p style="margin:0;">※ 로그인 및 가입 관련 문의: <strong>02-2141-7434</strong></p>
</div>
`;
function injectBanner() {
const $wrap = $('#pop_login .popup_contents_wrap');
if (!$wrap.length) return false;
if (!$('#login_notice_banner').length) {
$wrap.prepend(bannerHtml);
// 닫기 버튼
$('#login_notice_banner .lnb-close').on('click', function () {
$('#login_notice_banner').fadeOut(120);
});
} else {
$('#login_notice_banner').show();
}
return true;
}
// 로그인 메뉴 클릭 → 기존 login() 실행 + 배너 주입(팝업 DOM 뜰 때까지 재시도)
$(document).on('click', '#my_login a, .my_login a', function (e) {
e.preventDefault();
if (typeof login === 'function') login();
let tries = 0;
const maxTries = 20; // 1초 정도 재시도(50ms*20)
const iv = setInterval(() => {
tries++;
if (injectBanner() || tries >= maxTries) clearInterval(iv);
}, 50);
});
$(document).on('click', '.signup-disabled-link', function (e) {
e.preventDefault();
});
// 혹시 로그인 팝업을 다른 곳에서 열어도 배너가 필요하면, 팝업 열릴 때 한 번 더 시도
$(document).on('show-login-popup', function () {
injectBanner();
});
$(function () {
applyAdminIconVisibility();
});
window.addEventListener('storage', function (e) {
if (e.key === 'loginId') {
applyAdminIconVisibility(e.newValue || '');
}
});
window.addEventListener('descope-auth-changed', function (e) {
applyAdminIconVisibility(e.detail?.loginId || '');
});
let checkCount = 0;
const checkInterval = setInterval(function () {
checkCount += 1;
const loginId = sessionStorage.getItem('loginId') || '';
if (loginId || checkCount >= 20) {
applyAdminIconVisibility(loginId);
clearInterval(checkInterval);
}
}, 300);
})();
</script>