286 lines
11 KiB
PHP
286 lines
11 KiB
PHP
<?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="/eng/index.php"></a></h1>
|
||
|
||
<!-- ✅ 사용자 관리 아이콘 (관리자 전용, 기본 숨김) -->
|
||
<div id="userListBtnWrap" class="menu_userlist" style="display:none;">
|
||
<a href="/eng/skin/member/basic/descope_user_list_skin_w3.php">
|
||
<img src="<?php echo eng_img_url('ico_userlist.svg'); ?>" alt="사용자 관리">
|
||
</a>
|
||
</div>
|
||
|
||
<div class="language">
|
||
<a href="/egbim/">KR</a>
|
||
<a href="#" class="on">EN</a>
|
||
</div>
|
||
|
||
<!-- ✅ 업로드 아이콘 (관리자 전용, 기본 숨김) -->
|
||
<div id="uploadBtnWrap" class="menu_upload" style="display:none;">
|
||
<a href="/eng/sw_upload/upload_page.php">
|
||
<img src="<?php echo eng_img_url('ico_upload.svg'); ?>" alt="업로드">
|
||
</a>
|
||
</div>
|
||
|
||
<div class="menu_my">
|
||
<img src="<?php echo eng_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();">Logout</a>
|
||
</li>
|
||
<li id="my_login" class="my_login full-width-login">
|
||
<a href="javascript:login();">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="/eng/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/en/interface01/" target="_blank">
|
||
<i></i>
|
||
<span>Guide</span>
|
||
</a></li>
|
||
<li class="floating_download">
|
||
<a href="<?= htmlspecialchars($download_url) ?>">
|
||
<i></i>
|
||
<span>Download</span>
|
||
</a></li>
|
||
<li class="floating_buy"><a href="/eng/bbs/buy.php">
|
||
<i></i>
|
||
<span>Contact</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="Close" 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;">[Login System Notice]</strong>
|
||
<p class="left" style="margin:0 0 6px;">
|
||
For improved security, the login system changed on August 8, 2025.<br>
|
||
Existing users also need to sign up again in the new system.
|
||
</p>
|
||
<p style="margin:0;">Support: <strong>+82-2-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>
|