feat(core): 정적 최적화 서버 대응 자산 URL 이중 모드
nginx 의 정규식 location 은 프리픽스 location 보다 먼저 매칭되므로, `location ~* \.(js|css|json)$` 블록이 있는 서버에서는 확장자 붙은 동적 엔드포인트가 `try_files ... /index.php` 폴백이 실행될 기회 없이 404 가 된다. aaPanel/CyberPanel/Plesk 기본 템플릿에 들어있어 드물지 않으며, 관리자 화면조차 뜨지 않아 "서버 설정을 고치세요" 안내가 순환 참조가 된다. 관례를 깬 쪽이 G7 이므로 해소 책임도 G7 에 두고, 두 형태를 모두 서빙한 뒤 환경에 따라 택일한다. 확장자 형태는 영구 유지한다 — 제거하면 URL 을 하드코딩한 서드파티 확장이 깨진다. - 라우트: dualSuffix / dualSuffixSegment / dualAsset 매크로로 23개 엔드포인트와 프로브를 이중 등록. 확장자 형태를 먼저 등록한다 — 확장자 없는 쪽이 더 느슨한 패턴이라 순서가 뒤집히면 `.json` 요청까지 삼킨다 - URL 생성: 서버 App\Support\AssetUrl, 프론트 core/support/assetUrl.ts 로 집약. 기본 모드에서 생성 결과는 치환 이전과 문자열까지 동일하다 (쿼리 순서 포함 — 순서가 바뀌면 의미는 같아도 HTTP 캐시 키가 갈린다) - 자가 복구: 부트스트랩 자산 로드 실패 시 확장자 없는 형태로 1회 단방향 전환. 역방향 금지 + 기존 재시도 예산 공유로 무한 왕복을 막는다 - 감지·전환: 인스톨러 프로브(설치 시 확정) / 관리자 환경설정 일반 탭 / g7:asset-url-mode. 판정은 상태코드가 아니라 매직 토큰 + Content-Type 으로 한다. 상태코드만 보면 "404 대신 200 + 에러 HTML" 환경에서 영원히 오판한다 - 봇은 JavaScript 를 실행하지 않아 자가 복구가 닿지 않으므로, 모드 변경 시 SEO 프리렌더 캐시를 비워 재생성시킨다 가드: audit 룰 2종(dynamic-route-static-extension / asset-url-builder-required), Playwright 6건(정적 블록 가로채기 시뮬레이션), 루프 방지 불변식 L1~L9 전수 red 증명. 부수 정리: 양 Composer 에 중복돼 있던 확장 에셋 수집 123줄을 트레이트로 통합하고, 자산 확장자 화이트리스트 누락(.map)과 경로 정규화 우회 가능성을 함께 교정. sir.kr 커뮤니티의 hang 님께서 제보해주셨습니다.
This commit is contained in:
1 parent
74df8a4b09
commit
15cd4452bf
90 files changed
+4279
-546
No files matched your search
@@ -1554,11 +1554,94 @@
|
||||
/**
|
||||
* 실시간 검증 초기화
|
||||
*/
|
||||
/**
|
||||
* 자산 URL 방식을 브라우저에서 판정해 hidden 필드에 채운다 (이슈 #486 §6·§7).
|
||||
*
|
||||
* 정적 최적화 블록(`location ~* \.(js|css|json)$`)은 정규식 location 이라 프리픽스
|
||||
* location 보다 먼저 매칭되고, 그 안에 PHP 핸들러가 없으면 확장자 붙은 동적 응답이
|
||||
* PHP 에 도달하지 못한 채 404 가 된다. 설치 시점에 판정해 두지 않으면 설치 직후
|
||||
* 첫 화면부터 백지가 된다.
|
||||
*
|
||||
* 판정은 **쌍으로** 던진다. 단일 프로브는 "PHP 자체가 죽음" 과 구분되지 않는다.
|
||||
*
|
||||
* probe.js 실패 + probe 성공 = 정적 블록 가로채기 확정 → extensionless
|
||||
* 둘 다 성공 = extension
|
||||
* 둘 다 실패 = PHP/라우팅 문제 (모드 문제 아님) → 판정 보류
|
||||
*
|
||||
* 성공 판정은 상태코드가 아니라 **본문의 매직 토큰**으로 한다. 상태코드만 보면
|
||||
* "404 대신 200 + 에러 HTML" 이나 catch-all 200 페이지를 반환하는 설정에서
|
||||
* 영원히 오판한다.
|
||||
*/
|
||||
async function detectAssetUrlMode() {
|
||||
const field = document.getElementById('asset_url_mode');
|
||||
if (!field) return;
|
||||
|
||||
const TOKEN = 'G7_ASSET_PROBE_OK';
|
||||
const base = (document.querySelector('[name="app_url"]')?.value || '').replace(/\/+$/, '');
|
||||
|
||||
/**
|
||||
* 프로브 1건을 던져 매직 토큰 포함 여부를 반환한다.
|
||||
*/
|
||||
const probe = async (path) => {
|
||||
try {
|
||||
const res = await fetch(`${base}${path}`, { cache: 'no-store', credentials: 'omit' });
|
||||
if (!res.ok) return false;
|
||||
|
||||
// Content-Type 도 함께 본다 (L6). 토큰만 검사해도 200+HTML 오판은
|
||||
// 걸러지지만, 계획서는 두 신호를 모두 요구한다.
|
||||
const contentType = res.headers.get('content-type') || '';
|
||||
if (!/javascript|ecmascript/i.test(contentType)) return false;
|
||||
|
||||
return (await res.text()).includes(TOKEN);
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
const [withExt, withoutExt] = await Promise.all([
|
||||
probe('/api/system/asset-probe.js'),
|
||||
probe('/api/system/asset-probe'),
|
||||
]);
|
||||
|
||||
let detected = '';
|
||||
if (withExt && withoutExt) {
|
||||
detected = 'extension';
|
||||
} else if (!withExt && withoutExt) {
|
||||
detected = 'extensionless';
|
||||
}
|
||||
// 둘 다 실패 = 모드 문제가 아니다(PHP/라우팅 장애). 빈 값으로 두어 기본값을 따르게 한다.
|
||||
|
||||
field.value = detected;
|
||||
|
||||
// 수동 override — 감지 결과를 기본 선택으로 채우고 관리자가 바꿀 수 있게 한다.
|
||||
// 프로브가 CSP/프록시 등으로 둘 다 실패하면 자동 판정이 불가하므로,
|
||||
// 손댈 수단이 없으면 설치를 마친 뒤에야 문제를 알게 된다.
|
||||
const select = document.getElementById('asset_url_mode_select');
|
||||
const status = document.getElementById('asset_url_mode_status');
|
||||
if (select) {
|
||||
select.value = detected || 'extension';
|
||||
select.addEventListener('change', function () {
|
||||
field.value = this.value;
|
||||
});
|
||||
// 감지 실패 시에도 select 값이 hidden 에 반영되도록 초기 동기화
|
||||
field.value = select.value;
|
||||
}
|
||||
if (status) {
|
||||
status.textContent = status.getAttribute(
|
||||
detected ? `data-msg-${detected}` : 'data-msg-unavailable'
|
||||
) || '';
|
||||
status.classList.remove('hidden');
|
||||
}
|
||||
}
|
||||
|
||||
function initRealTimeValidation() {
|
||||
// Step 3 (config-form)이 있는 경우에만 실행
|
||||
const configForm = document.getElementById('config-form');
|
||||
if (!configForm) return;
|
||||
|
||||
// 자산 URL 방식 자동 감지 (비차단 — 실패해도 설치 진행에 지장 없음)
|
||||
detectAssetUrlMode();
|
||||
|
||||
const fieldsToValidate = [
|
||||
'app_name',
|
||||
'app_url',
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
use App\Support\PrivilegedDatabaseAccounts;
|
||||
|
||||
/**
|
||||
* 그누보드7 웹 인스톨러 요청 처리 핸들러
|
||||
*
|
||||
@@ -140,7 +142,7 @@ function validateDbUsername(string $username, string $field, array &$errors): vo
|
||||
return;
|
||||
}
|
||||
|
||||
if (\App\Support\PrivilegedDatabaseAccounts::isBlocked($username)) {
|
||||
if (PrivilegedDatabaseAccounts::isBlocked($username)) {
|
||||
$errors[$field] = lang('error_db_username_privileged', ['username' => $username]);
|
||||
}
|
||||
}
|
||||
@@ -205,6 +207,15 @@ function handleStep3Post(string $currentLang, array &$formData, array &$errors):
|
||||
}
|
||||
$formData['vendor_mode'] = $vendorMode;
|
||||
|
||||
// 자산 URL 방식 (이슈 #486) — Step 3 의 브라우저 프로브가 채운 hidden 필드.
|
||||
// 정적 최적화 블록이 있는 서버는 확장자 붙은 동적 응답이 PHP 에 도달하지 못하므로
|
||||
// 설치 시점에 확장자 없는 형태로 확정해야 첫 화면부터 정상 동작한다.
|
||||
// 판정 불가(프로브 실패·JS 미실행)면 키를 비워 defaults.json 기본값을 따르게 한다.
|
||||
$assetUrlMode = trim($formData['asset_url_mode'] ?? '');
|
||||
$formData['asset_url_mode'] = in_array($assetUrlMode, ['extension', 'extensionless'], true)
|
||||
? $assetUrlMode
|
||||
: '';
|
||||
|
||||
// 코어 업데이트 _pending 경로 검증 (입력된 경우만)
|
||||
$corePendingPath = trim($formData['core_update_pending_path'] ?? '');
|
||||
if ($corePendingPath !== '') {
|
||||
|
||||
@@ -1657,6 +1657,14 @@ if (! function_exists('createSettingsJsonSSE')) {
|
||||
|
||||
$defaults['general']['language'] = getCurrentLanguage();
|
||||
|
||||
// 자산 URL 방식 (이슈 #486) — 설치 화면이 브라우저에서 프로브를 던져 판정한 결과.
|
||||
// 정적 최적화 블록(`location ~* \.(js|css|json)$`)이 있는 서버는 확장자 붙은
|
||||
// 동적 응답이 PHP 에 도달하지 못하므로 확장자 없는 형태로 설치를 마쳐야 한다.
|
||||
// 미판정(구버전 설치 화면·프로브 실패)이면 defaults.json 의 기본값을 그대로 둔다.
|
||||
if (in_array($config['asset_url_mode'] ?? null, ['extension', 'extensionless'], true)) {
|
||||
$defaults['general']['asset_url_mode'] = $config['asset_url_mode'];
|
||||
}
|
||||
|
||||
foreach ($categories as $category) {
|
||||
if (! isset($defaults[$category])) {
|
||||
sendSSEEvent('log', ['message' => " - {$category}.json skipped (no defaults)"]);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
// /install/lang/en.php
|
||||
|
||||
return [
|
||||
@@ -424,7 +425,7 @@ return [
|
||||
'abort_rollback_success' => '[Aborted] Rollback completed: :message',
|
||||
'abort_rollback_failed' => '[Aborted] Rollback failed: :message (continuing)',
|
||||
'abort_no_rollback_needed' => '[Aborted] No rollback needed. (current_task is null or already completed)',
|
||||
'abort_by_user' => "[Aborted] User aborted installation. (Current task: :task)",
|
||||
'abort_by_user' => '[Aborted] User aborted installation. (Current task: :task)',
|
||||
'abort_installation_stopped' => 'Installation aborted.',
|
||||
|
||||
// Worker Failed Task Rollback Messages
|
||||
@@ -548,7 +549,7 @@ return [
|
||||
'validation_incomplete_title' => 'Please complete the following items:',
|
||||
'confirm_leave_page' => 'Settings have not been saved. Are you sure you want to leave this page?',
|
||||
'installation_in_progress_alert' => 'Installation is in progress. Do you want to go back to the settings page?',
|
||||
'confirm_go_to_settings' => "Do you want to go back to the settings page?",
|
||||
'confirm_go_to_settings' => 'Do you want to go back to the settings page?',
|
||||
'confirm_go_to_settings_simple' => "Do you want to go back to the settings page?\n\nInstallation state will be reset and all tasks will start from the beginning.\n\n⚠️ Database tables will NOT be deleted automatically.\nPlease clean up manually using phpMyAdmin if needed.",
|
||||
'confirm_go_to_settings_title' => 'Go to Settings Page',
|
||||
'confirm_go_to_settings_desc' => 'Installation state will be reset and all tasks will start from the beginning.\n\n⚠️ Database tables will NOT be deleted automatically. Please clean up manually using phpMyAdmin if needed.',
|
||||
@@ -712,7 +713,7 @@ Firewalls or proxies may be blocking long-lived HTTP connections.',
|
||||
'deselect_all' => 'Deselect All',
|
||||
|
||||
// install-worker.php i18n keys
|
||||
'db_task_abort_detected_before_start' => '[DB Task] Abort detected before start - skipping task.',
|
||||
'db_task_abort_detected_before_start' => '[DB Task] Abort detected before start - skipping task.',
|
||||
'db_task_failed_rollback_start' => '[DB Task] :task failed - starting rollback.',
|
||||
'db_task_abort_reason_connection' => 'Connection lost',
|
||||
'db_task_abort_reason_user' => 'User requested',
|
||||
@@ -831,6 +832,15 @@ Firewalls or proxies may be blocking long-lived HTTP connections.',
|
||||
'core_update_settings' => 'Core Update Settings (Optional)',
|
||||
'core_update_pending_path' => 'Update Pending Directory Path',
|
||||
'core_update_pending_path_help' => 'Leave empty to use the default (storage/app/core_pending). Enter an absolute path or a path relative to the Gnuboard7 root to use a custom location.',
|
||||
|
||||
// 자산 URL 방식 (이슈 #486)
|
||||
'asset_url_mode' => 'Asset file URL style',
|
||||
'asset_url_mode_extension' => 'Use file extensions (recommended)',
|
||||
'asset_url_mode_extensionless' => 'No file extensions',
|
||||
'asset_url_mode_help' => 'Detected automatically from your server setup. Some servers intercept .js/.css/.json URLs and pages fail to load; choose no extensions in that case.',
|
||||
'asset_url_mode_detected_extension' => 'Detected: file extensions work fine on this server.',
|
||||
'asset_url_mode_detected_extensionless' => 'Detected: the server intercepts extension URLs, so no extensions was selected.',
|
||||
'asset_url_mode_detected_unavailable' => 'Could not detect. If pages fail to load after installation, try switching to no extensions.',
|
||||
'core_update_github_url' => 'GitHub Repository URL',
|
||||
'core_update_github_url_help' => 'GitHub repository URL to check for core updates.',
|
||||
'core_update_github_token' => 'GitHub Access Token',
|
||||
@@ -915,4 +925,3 @@ Firewalls or proxies may be blocking long-lived HTTP connections.',
|
||||
// Relative path alternative
|
||||
'or_relative_path' => 'Or from the G7 root directory:',
|
||||
];
|
||||
?>
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
// /install/lang/ko.php
|
||||
|
||||
return [
|
||||
@@ -424,7 +425,7 @@ return [
|
||||
'abort_rollback_success' => '[중단] 롤백 완료: :message',
|
||||
'abort_rollback_failed' => '[중단] 롤백 실패: :message (계속 진행)',
|
||||
'abort_no_rollback_needed' => '[중단] 롤백할 작업이 없습니다. (current_task가 null이거나 이미 완료됨)',
|
||||
'abort_by_user' => "[중단] 사용자가 설치를 중단했습니다. (현재 작업: :task)",
|
||||
'abort_by_user' => '[중단] 사용자가 설치를 중단했습니다. (현재 작업: :task)',
|
||||
'abort_installation_stopped' => '설치가 중단되었습니다.',
|
||||
|
||||
// Worker 실패 시 롤백 관련 메시지
|
||||
@@ -548,7 +549,7 @@ return [
|
||||
'validation_incomplete_title' => '다음 항목을 완료해주세요:',
|
||||
'confirm_leave_page' => '설정이 저장되지 않았습니다. 페이지를 나가시겠습니까?',
|
||||
'installation_in_progress_alert' => '설치가 진행 중입니다. 설정 페이지로 돌아가시겠습니까?',
|
||||
'confirm_go_to_settings' => "설정 페이지로 이동하시겠습니까?",
|
||||
'confirm_go_to_settings' => '설정 페이지로 이동하시겠습니까?',
|
||||
'confirm_go_to_settings_simple' => "설정 페이지로 이동하시겠습니까?\n\n설치 상태가 초기화되며, 모든 작업이 처음부터 다시 실행됩니다.\n\n⚠️ 데이터베이스에 생성된 테이블은 자동으로 삭제되지 않습니다.\n필요 시 phpMyAdmin 등을 통해 수동으로 정리해주세요.",
|
||||
'confirm_go_to_settings_title' => '설정 페이지로 이동',
|
||||
'confirm_go_to_settings_desc' => '설치 상태가 초기화되며, 모든 작업이 처음부터 다시 실행됩니다.\n\n⚠️ 데이터베이스에 생성된 테이블은 자동으로 삭제되지 않습니다. 필요 시 phpMyAdmin 등을 통해 수동으로 정리해주세요.',
|
||||
@@ -712,7 +713,7 @@ ini_set(\'zlib.output_compression\', \'off\');
|
||||
'deselect_all' => '전체 해제',
|
||||
|
||||
// install-worker.php 다국어 키
|
||||
'db_task_abort_detected_before_start' => '[DB 작업] 시작 전 중단 상태 감지 - 작업을 건너뜁니다.',
|
||||
'db_task_abort_detected_before_start' => '[DB 작업] 시작 전 중단 상태 감지 - 작업을 건너뜁니다.',
|
||||
'db_task_failed_rollback_start' => '[DB 작업] :task 실패 - 롤백을 시작합니다.',
|
||||
'db_task_abort_reason_connection' => '연결 끊김',
|
||||
'db_task_abort_reason_user' => '사용자 요청',
|
||||
@@ -831,6 +832,15 @@ ini_set(\'zlib.output_compression\', \'off\');
|
||||
'core_update_settings' => '코어 업데이트 설정 (선택)',
|
||||
'core_update_pending_path' => '업데이트 대기 디렉토리 경로',
|
||||
'core_update_pending_path_help' => '비워두면 기본값(storage/app/core_pending)을 사용합니다. 외부 경로를 사용하려면 절대 경로 또는 그누보드7 루트 기준 상대 경로를 입력하세요.',
|
||||
|
||||
// 자산 URL 방식 (이슈 #486)
|
||||
'asset_url_mode' => '자산 파일 주소 방식',
|
||||
'asset_url_mode_extension' => '확장자 사용 (권장)',
|
||||
'asset_url_mode_extensionless' => '확장자 미사용',
|
||||
'asset_url_mode_help' => '서버 설정을 자동으로 감지해 선택합니다. 일부 서버는 .js/.css/.json 주소를 가로채 화면이 뜨지 않는데, 그 경우 확장자 미사용을 선택하세요.',
|
||||
'asset_url_mode_detected_extension' => '감지 결과: 확장자를 사용할 수 있는 환경입니다.',
|
||||
'asset_url_mode_detected_extensionless' => '감지 결과: 서버가 확장자 주소를 가로채고 있어 확장자 미사용을 선택했습니다.',
|
||||
'asset_url_mode_detected_unavailable' => '감지하지 못했습니다. 설치 후 화면이 뜨지 않으면 확장자 미사용으로 바꿔 보세요.',
|
||||
'core_update_github_url' => 'GitHub 저장소 URL',
|
||||
'core_update_github_url_help' => '코어 업데이트를 확인할 GitHub 저장소 URL입니다.',
|
||||
'core_update_github_token' => 'GitHub 액세스 토큰',
|
||||
@@ -915,4 +925,3 @@ ini_set(\'zlib.output_compression\', \'off\');
|
||||
// 상대경로 병기 안내
|
||||
'or_relative_path' => '또는 그누보드7 루트 디렉토리에서:',
|
||||
];
|
||||
?>
|
||||
@@ -5,8 +5,7 @@
|
||||
* 데이터베이스 설정, 사이트 설정, 관리자 계정을 입력받습니다.
|
||||
* $formData는 index.php에서 준비됨
|
||||
*/
|
||||
|
||||
if (!isset($errors)) {
|
||||
if (! isset($errors)) {
|
||||
$errors = [];
|
||||
}
|
||||
|
||||
@@ -22,15 +21,15 @@ $dbReadHash = getDatabaseFieldHash($formData, 'db_read');
|
||||
<div class="installer-container installer-container-wide">
|
||||
<h1 class="installer-title"><?= htmlspecialchars(lang('step_3_configuration')) ?></h1>
|
||||
|
||||
<?php if (!empty($errors)): ?>
|
||||
<?php if (! empty($errors)) { ?>
|
||||
<div class="alert alert-error">
|
||||
<ul class="alert-list">
|
||||
<?php foreach ($errors as $error): ?>
|
||||
<?php foreach ($errors as $error) { ?>
|
||||
<li><?= htmlspecialchars($error) ?></li>
|
||||
<?php endforeach; ?>
|
||||
<?php } ?>
|
||||
</ul>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php } ?>
|
||||
|
||||
<form method="POST" id="config-form" class="installer-form">
|
||||
<!-- 데이터베이스 설정 (Write DB) -->
|
||||
@@ -116,7 +115,7 @@ $dbReadHash = getDatabaseFieldHash($formData, 'db_read');
|
||||
<h3 class="requirement-card-title" style="margin: 0;"><?= htmlspecialchars(lang('use_read_db')) ?></h3>
|
||||
</label>
|
||||
<input type="checkbox" name="use_read_db" id="use-read-db" value="1"
|
||||
<?= !empty($formData['use_read_db']) ? 'checked' : '' ?>
|
||||
<?= ! empty($formData['use_read_db']) ? 'checked' : '' ?>
|
||||
class="toggle-switch">
|
||||
</div>
|
||||
<div id="read-db-section" class="requirement-card-body <?= empty($formData['use_read_db']) ? 'hidden' : '' ?>" style="transition: all 0.3s ease-out;">
|
||||
@@ -220,11 +219,11 @@ $dbReadHash = getDatabaseFieldHash($formData, 'db_read');
|
||||
<select name="admin_language" id="admin_language" class="form-select" required>
|
||||
<?php
|
||||
$selectedAdminLang = $formData['admin_language'] ?? getCurrentLanguage();
|
||||
foreach (SUPPORTED_LANGUAGES as $code => $label): ?>
|
||||
foreach (SUPPORTED_LANGUAGES as $code => $label) { ?>
|
||||
<option value="<?= $code ?>" <?= $selectedAdminLang === $code ? 'selected' : '' ?>>
|
||||
<?= htmlspecialchars($label) ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
@@ -266,6 +265,21 @@ $dbReadHash = getDatabaseFieldHash($formData, 'db_read');
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="form-label"><?= htmlspecialchars(lang('asset_url_mode')) ?></label>
|
||||
<select name="asset_url_mode_select" id="asset_url_mode_select" class="form-select">
|
||||
<option value="extension"><?= htmlspecialchars(lang('asset_url_mode_extension')) ?></option>
|
||||
<option value="extensionless"><?= htmlspecialchars(lang('asset_url_mode_extensionless')) ?></option>
|
||||
</select>
|
||||
<p id="asset_url_mode_status" class="form-help hidden"
|
||||
data-msg-extension="<?= htmlspecialchars(lang('asset_url_mode_detected_extension')) ?>"
|
||||
data-msg-extensionless="<?= htmlspecialchars(lang('asset_url_mode_detected_extensionless')) ?>"
|
||||
data-msg-unavailable="<?= htmlspecialchars(lang('asset_url_mode_detected_unavailable')) ?>"></p>
|
||||
<p class="form-help">
|
||||
<?= htmlspecialchars(lang('asset_url_mode_help')) ?>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="form-label"><?= htmlspecialchars(lang('core_update_github_url')) ?></label>
|
||||
<input type="url" name="core_update_github_url"
|
||||
@@ -307,7 +321,7 @@ $dbReadHash = getDatabaseFieldHash($formData, 'db_read');
|
||||
<h3 class="requirement-card-title" style="margin: 0;" id="php-cli-title"><?= htmlspecialchars(lang('php_cli_settings')) ?></h3>
|
||||
</label>
|
||||
<input type="checkbox" id="show-php-cli-settings" value="1"
|
||||
<?= (!empty($formData['php_binary']) && $formData['php_binary'] !== 'php') || !empty($formData['composer_binary']) ? 'checked' : '' ?>
|
||||
<?= (! empty($formData['php_binary']) && $formData['php_binary'] !== 'php') || ! empty($formData['composer_binary']) ? 'checked' : '' ?>
|
||||
class="toggle-switch">
|
||||
</div>
|
||||
<div id="php-cli-section" class="requirement-card-body <?= (empty($formData['php_binary']) || $formData['php_binary'] === 'php') && empty($formData['composer_binary']) ? 'hidden' : '' ?>" style="transition: all 0.3s ease-out;">
|
||||
@@ -384,14 +398,14 @@ $dbReadHash = getDatabaseFieldHash($formData, 'db_read');
|
||||
|
||||
<!-- ========== Vendor 설치 방식 ========== -->
|
||||
<?php
|
||||
$bundleZipExists = file_exists(BASE_PATH . '/vendor-bundle.zip');
|
||||
$zipArchiveAvailable = class_exists('ZipArchive');
|
||||
$procOpenAvailable = function_exists('proc_open')
|
||||
&& !in_array('proc_open', array_map('trim', explode(',', (string) ini_get('disable_functions'))), true);
|
||||
$bundleAvailable = $bundleZipExists && $zipArchiveAvailable;
|
||||
$composerAvailable = $procOpenAvailable;
|
||||
$currentVendorMode = $formData['vendor_mode'] ?? 'auto';
|
||||
?>
|
||||
$bundleZipExists = file_exists(BASE_PATH.'/vendor-bundle.zip');
|
||||
$zipArchiveAvailable = class_exists('ZipArchive');
|
||||
$procOpenAvailable = function_exists('proc_open')
|
||||
&& ! in_array('proc_open', array_map('trim', explode(',', (string) ini_get('disable_functions'))), true);
|
||||
$bundleAvailable = $bundleZipExists && $zipArchiveAvailable;
|
||||
$composerAvailable = $procOpenAvailable;
|
||||
$currentVendorMode = $formData['vendor_mode'] ?? 'auto';
|
||||
?>
|
||||
<div class="requirement-card">
|
||||
<div class="requirement-card-header">
|
||||
<h2 class="card-title"><?= htmlspecialchars(lang('vendor_mode_title')) ?></h2>
|
||||
@@ -437,15 +451,15 @@ $dbReadHash = getDatabaseFieldHash($formData, 'db_read');
|
||||
<p class="vendor-mode-card-description">
|
||||
<?= htmlspecialchars(lang('vendor_mode_composer_description')) ?>
|
||||
</p>
|
||||
<?php if (!$composerAvailable): ?>
|
||||
<?php if (! $composerAvailable) { ?>
|
||||
<p class="vendor-mode-card-status vendor-mode-card-status-error">
|
||||
<?= getSvgIcon('warning') ?: '⚠' ?> <?= htmlspecialchars(lang('vendor_mode_composer_status_blocked')) ?>
|
||||
</p>
|
||||
<?php else: ?>
|
||||
<?php } else { ?>
|
||||
<p class="vendor-mode-card-status vendor-mode-card-status-ok">
|
||||
<?= getSvgIcon('check') ?: '✓' ?> <?= htmlspecialchars(lang('vendor_mode_composer_status_ok')) ?>
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
<?php } ?>
|
||||
</label>
|
||||
|
||||
<!-- 번들 Vendor 사용 -->
|
||||
@@ -464,19 +478,19 @@ $dbReadHash = getDatabaseFieldHash($formData, 'db_read');
|
||||
<p class="vendor-mode-card-description">
|
||||
<?= htmlspecialchars(lang('vendor_mode_bundled_description')) ?>
|
||||
</p>
|
||||
<?php if (!$zipArchiveAvailable): ?>
|
||||
<?php if (! $zipArchiveAvailable) { ?>
|
||||
<p class="vendor-mode-card-status vendor-mode-card-status-error">
|
||||
<?= getSvgIcon('warning') ?: '⚠' ?> <?= htmlspecialchars(lang('vendor_mode_bundled_status_no_ziparchive')) ?>
|
||||
</p>
|
||||
<?php elseif (!$bundleZipExists): ?>
|
||||
<?php } elseif (! $bundleZipExists) { ?>
|
||||
<p class="vendor-mode-card-status vendor-mode-card-status-error">
|
||||
<?= getSvgIcon('warning') ?: '⚠' ?> <?= htmlspecialchars(lang('vendor_mode_bundled_status_no_zip')) ?>
|
||||
</p>
|
||||
<?php else: ?>
|
||||
<?php } else { ?>
|
||||
<p class="vendor-mode-card-status vendor-mode-card-status-ok">
|
||||
<?= getSvgIcon('check') ?: '✓' ?> <?= htmlspecialchars(lang('vendor_mode_bundled_status_ok')) ?>
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
<?php } ?>
|
||||
</label>
|
||||
</div>
|
||||
<p class="form-help" style="margin-top: var(--spacing-md);">
|
||||
@@ -502,6 +516,12 @@ $dbReadHash = getDatabaseFieldHash($formData, 'db_read');
|
||||
</div>
|
||||
|
||||
<!-- 네비게이션 -->
|
||||
<?php /* 자산 URL 방식 (이슈 #486) — 아래 스크립트가 브라우저에서 프로브를 던져 채운다.
|
||||
서버측에서 자기 APP_URL 로 curl 하면 loopback 이 vhost·프록시 체인을 우회해
|
||||
오판하므로 반드시 브라우저가 판정해야 한다. 판정 실패 시 빈 값으로 남고
|
||||
설치는 defaults.json 기본값(extension)으로 진행된다. */ ?>
|
||||
<input type="hidden" name="asset_url_mode" id="asset_url_mode" value="">
|
||||
|
||||
<div class="btn-group btn-group-spread">
|
||||
<button type="button" onclick="goToStep(2)" class="btn btn-secondary">
|
||||
<?= htmlspecialchars(lang('previous')) ?>
|
||||
@@ -588,18 +608,18 @@ window.CliValidator = {
|
||||
summary.style.display = '';
|
||||
|
||||
phpStatus.textContent = this.phpVerified
|
||||
? '<?= lang("cli_status_verified") ?>'
|
||||
: '<?= lang("cli_status_not_verified") ?>';
|
||||
? '<?= lang('cli_status_verified') ?>'
|
||||
: '<?= lang('cli_status_not_verified') ?>';
|
||||
phpStatus.style.color = this.phpVerified ? 'var(--success-color)' : 'var(--error-color)';
|
||||
|
||||
const composerOptional = !this.isComposerRequired();
|
||||
if (composerOptional) {
|
||||
composerStatus.textContent = '<?= lang("cli_status_optional_bundled") ?>';
|
||||
composerStatus.textContent = '<?= lang('cli_status_optional_bundled') ?>';
|
||||
composerStatus.style.color = 'var(--text-muted-color, #888)';
|
||||
} else {
|
||||
composerStatus.textContent = this.composerVerified
|
||||
? '<?= lang("cli_status_verified") ?>'
|
||||
: '<?= lang("cli_status_not_verified") ?>';
|
||||
? '<?= lang('cli_status_verified') ?>'
|
||||
: '<?= lang('cli_status_not_verified') ?>';
|
||||
composerStatus.style.color = this.composerVerified ? 'var(--success-color)' : 'var(--error-color)';
|
||||
}
|
||||
},
|
||||
@@ -663,8 +683,8 @@ async function initCliDetection() {
|
||||
const summary = document.getElementById('cli-status-summary');
|
||||
|
||||
if (summary) summary.style.display = '';
|
||||
if (phpStatus) { phpStatus.textContent = '<?= lang("cli_status_checking") ?>'; phpStatus.style.color = ''; }
|
||||
if (composerStatus) { composerStatus.textContent = '<?= lang("cli_status_checking") ?>'; composerStatus.style.color = ''; }
|
||||
if (phpStatus) { phpStatus.textContent = '<?= lang('cli_status_checking') ?>'; phpStatus.style.color = ''; }
|
||||
if (composerStatus) { composerStatus.textContent = '<?= lang('cli_status_checking') ?>'; composerStatus.style.color = ''; }
|
||||
|
||||
// PHP 감지 먼저 실행 (composer 감지 결과 포함) → Composer 검증
|
||||
const composerData = await detectAndVerifyPhp();
|
||||
@@ -736,10 +756,10 @@ function switchToRequiredMode() {
|
||||
window.CliValidator.cliRequired = true;
|
||||
|
||||
const title = document.getElementById('php-cli-title');
|
||||
if (title) title.textContent = '<?= lang("php_cli_settings_required") ?>';
|
||||
if (title) title.textContent = '<?= lang('php_cli_settings_required') ?>';
|
||||
|
||||
const helpText = document.getElementById('php-cli-help-text');
|
||||
if (helpText) helpText.textContent = '<?= lang("php_cli_settings_help_required") ?>';
|
||||
if (helpText) helpText.textContent = '<?= lang('php_cli_settings_help_required') ?>';
|
||||
|
||||
// 섹션 강제 오픈 + 토글 비활성화
|
||||
const section = document.getElementById('php-cli-section');
|
||||
@@ -760,7 +780,7 @@ async function testPhpBinary() {
|
||||
const resultDiv = document.getElementById('php-binary-test-result');
|
||||
|
||||
resultDiv.className = 'test-result';
|
||||
resultDiv.innerHTML = '<span class="loading-spinner"></span> ' + '<?= lang("checking") ?>';
|
||||
resultDiv.innerHTML = '<span class="loading-spinner"></span> ' + '<?= lang('checking') ?>';
|
||||
|
||||
try {
|
||||
const response = await fetch('api/check-configuration.php?action=test-php-binary', {
|
||||
@@ -781,7 +801,7 @@ async function testPhpBinary() {
|
||||
}
|
||||
} catch (e) {
|
||||
resultDiv.className = 'test-result test-error';
|
||||
resultDiv.innerHTML = '<?= lang("error_check_failed") ?>';
|
||||
resultDiv.innerHTML = '<?= lang('error_check_failed') ?>';
|
||||
window.CliValidator.setPhpVerified(false);
|
||||
}
|
||||
}
|
||||
@@ -793,7 +813,7 @@ async function testComposer() {
|
||||
const resultDiv = document.getElementById('composer-test-result');
|
||||
|
||||
resultDiv.className = 'test-result';
|
||||
resultDiv.innerHTML = '<span class="loading-spinner"></span> ' + '<?= lang("composer_checking") ?>';
|
||||
resultDiv.innerHTML = '<span class="loading-spinner"></span> ' + '<?= lang('composer_checking') ?>';
|
||||
|
||||
try {
|
||||
const response = await fetch('api/check-configuration.php?action=test-composer', {
|
||||
@@ -818,7 +838,7 @@ async function testComposer() {
|
||||
}
|
||||
} catch (e) {
|
||||
resultDiv.className = 'test-result test-error';
|
||||
resultDiv.innerHTML = '<?= lang("error_check_failed") ?>';
|
||||
resultDiv.innerHTML = '<?= lang('error_check_failed') ?>';
|
||||
window.CliValidator.setComposerVerified(false);
|
||||
showComposerInstallGuide();
|
||||
}
|
||||
@@ -847,40 +867,40 @@ function showComposerInstallGuide() {
|
||||
let html = '';
|
||||
|
||||
// 표준 설치 안내 (항상 표시)
|
||||
html += '<p class="fix-guide-label"><?= lang("composer_install_guide_global") ?></p>';
|
||||
html += '<p class="fix-guide-label"><?= lang('composer_install_guide_global') ?></p>';
|
||||
html += '<div class="code-box">';
|
||||
html += '<pre class="fix-command">curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer</pre>';
|
||||
html += '<button type="button" class="btn-copy" onclick="copyCliCommand(this)"><?= lang("copy_command") ?></button>';
|
||||
html += '<button type="button" class="btn-copy" onclick="copyCliCommand(this)"><?= lang('copy_command') ?></button>';
|
||||
html += '</div>';
|
||||
|
||||
html += '<p class="fix-guide-label" style="margin-top: var(--spacing-sm);"><?= lang("composer_install_guide_local") ?></p>';
|
||||
html += '<p class="fix-guide-label" style="margin-top: var(--spacing-sm);"><?= lang('composer_install_guide_local') ?></p>';
|
||||
html += '<div class="code-box">';
|
||||
html += '<pre class="fix-command">curl -sS https://getcomposer.org/installer | php</pre>';
|
||||
html += '<button type="button" class="btn-copy" onclick="copyCliCommand(this)"><?= lang("copy_command") ?></button>';
|
||||
html += '<button type="button" class="btn-copy" onclick="copyCliCommand(this)"><?= lang('copy_command') ?></button>';
|
||||
html += '</div>';
|
||||
|
||||
// 호스팅 환경 안내 (항상 표시 — 표준 방법 실패 시 대안)
|
||||
html += '<p class="fix-guide-label" style="margin-top: var(--spacing-md);"><?= lang("composer_install_guide_hosting") ?></p>';
|
||||
html += '<p class="fix-guide-label" style="margin-top: var(--spacing-md);"><?= lang('composer_install_guide_hosting') ?></p>';
|
||||
|
||||
html += '<div class="code-box">';
|
||||
html += '<pre class="fix-command">curl -o composer-setup.php https://getcomposer.org/installer</pre>';
|
||||
html += '<button type="button" class="btn-copy" onclick="copyCliCommand(this)"><?= lang("copy_command") ?></button>';
|
||||
html += '<button type="button" class="btn-copy" onclick="copyCliCommand(this)"><?= lang('copy_command') ?></button>';
|
||||
html += '</div>';
|
||||
|
||||
html += '<div class="code-box" style="margin-top: var(--spacing-xs);">';
|
||||
html += '<pre class="fix-command">' + escapeHtml(phpPath) + ' -d allow_url_fopen=On composer-setup.php</pre>';
|
||||
html += '<button type="button" class="btn-copy" onclick="copyCliCommand(this)"><?= lang("copy_command") ?></button>';
|
||||
html += '<button type="button" class="btn-copy" onclick="copyCliCommand(this)"><?= lang('copy_command') ?></button>';
|
||||
html += '</div>';
|
||||
|
||||
html += '<p class="fix-guide-hint" style="margin-top: var(--spacing-sm);"><?= lang("composer_install_guide_pwd_hint") ?></p>';
|
||||
html += '<p class="fix-guide-hint" style="margin-top: var(--spacing-sm);"><?= lang('composer_install_guide_pwd_hint') ?></p>';
|
||||
html += '<div class="code-box">';
|
||||
html += '<pre class="fix-command">pwd</pre>';
|
||||
html += '<button type="button" class="btn-copy" onclick="copyCliCommand(this)"><?= lang("copy_command") ?></button>';
|
||||
html += '<button type="button" class="btn-copy" onclick="copyCliCommand(this)"><?= lang('copy_command') ?></button>';
|
||||
html += '</div>';
|
||||
|
||||
html += '<p class="fix-guide-hint" style="margin-top: var(--spacing-sm);"><?= lang("composer_install_guide_phar_hint") ?></p>';
|
||||
html += '<p class="fix-guide-hint" style="margin-top: var(--spacing-sm);"><?= lang('composer_install_guide_phar_hint') ?></p>';
|
||||
|
||||
html += '<p class="fix-guide-hint" style="margin-top: var(--spacing-sm);"><?= lang("composer_install_guide_link") ?></p>';
|
||||
html += '<p class="fix-guide-hint" style="margin-top: var(--spacing-sm);"><?= lang('composer_install_guide_link') ?></p>';
|
||||
|
||||
commandsDiv.innerHTML = html;
|
||||
guide.style.display = '';
|
||||
@@ -903,7 +923,7 @@ function showDetectResult(data) {
|
||||
if (!resultDiv) return;
|
||||
|
||||
if (data.success && data.binaries && data.binaries.length > 0) {
|
||||
let html = '<strong>' + '<?= lang("detected_php_binaries") ?>' + '</strong><ul style="margin: var(--spacing-xs) 0; padding-left: var(--spacing-lg);">';
|
||||
let html = '<strong>' + '<?= lang('detected_php_binaries') ?>' + '</strong><ul style="margin: var(--spacing-xs) 0; padding-left: var(--spacing-lg);">';
|
||||
data.binaries.forEach(function(bin) {
|
||||
html += '<li><a href="#" onclick="selectPhpBinary(\'' + bin.path.replace(/'/g, "\\'") + '\'); return false;" style="cursor: pointer;">'
|
||||
+ bin.path + '</a> — PHP ' + bin.version + '</li>';
|
||||
@@ -913,7 +933,7 @@ function showDetectResult(data) {
|
||||
resultDiv.innerHTML = html;
|
||||
} else {
|
||||
resultDiv.className = 'test-result test-error';
|
||||
resultDiv.innerHTML = data.message || '<?= lang("no_php_detected") ?>';
|
||||
resultDiv.innerHTML = data.message || '<?= lang('no_php_detected') ?>';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -935,7 +955,7 @@ async function detectPhpBinaries() {
|
||||
const resultDiv = document.getElementById('php-detect-result');
|
||||
|
||||
resultDiv.className = 'test-result';
|
||||
resultDiv.innerHTML = '<span class="loading-spinner"></span> ' + '<?= lang("detecting_php") ?>';
|
||||
resultDiv.innerHTML = '<span class="loading-spinner"></span> ' + '<?= lang('detecting_php') ?>';
|
||||
|
||||
try {
|
||||
const response = await fetch('api/check-configuration.php?action=detect-php');
|
||||
@@ -947,7 +967,7 @@ async function detectPhpBinaries() {
|
||||
}
|
||||
} catch (e) {
|
||||
resultDiv.className = 'test-result test-error';
|
||||
resultDiv.innerHTML = '<?= lang("error_check_failed") ?>';
|
||||
resultDiv.innerHTML = '<?= lang('error_check_failed') ?>';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -958,7 +978,7 @@ function copyCliCommand(btn) {
|
||||
const command = btn.previousElementSibling.textContent;
|
||||
navigator.clipboard.writeText(command).then(function() {
|
||||
const originalText = btn.textContent;
|
||||
btn.textContent = '<?= lang("copied") ?>';
|
||||
btn.textContent = '<?= lang('copied') ?>';
|
||||
setTimeout(function() { btn.textContent = originalText; }, 2000);
|
||||
});
|
||||
}
|
||||
@@ -990,7 +1010,7 @@ async function checkCorePendingPath() {
|
||||
if (!path) return;
|
||||
|
||||
resultDiv.className = 'test-result';
|
||||
resultDiv.innerHTML = '<span class="loading-spinner"></span> ' + '<?= lang("checking") ?>';
|
||||
resultDiv.innerHTML = '<span class="loading-spinner"></span> ' + '<?= lang('checking') ?>';
|
||||
|
||||
try {
|
||||
const response = await fetch('api/check-configuration.php?action=check-core-pending-path&path=' + encodeURIComponent(path));
|
||||
@@ -1005,7 +1025,7 @@ async function checkCorePendingPath() {
|
||||
}
|
||||
} catch (e) {
|
||||
resultDiv.className = 'test-result test-error';
|
||||
resultDiv.innerHTML = '<?= lang("error_check_failed") ?>';
|
||||
resultDiv.innerHTML = '<?= lang('error_check_failed') ?>';
|
||||
}
|
||||
}
|
||||
</script>
|
||||
Reference in new issue
Block a user