41 lines
1.5 KiB
PHP
41 lines
1.5 KiB
PHP
<?php
|
|
// 이 파일은 AJAX 요청을 처리하므로 화면 출력이 없어야 합니다.
|
|
header('Content-Type: application/json');
|
|
|
|
// 그누보드 환경을 로드하여 DB 접속 및 보안 기능을 사용합니다.
|
|
|
|
// [수정] __DIR__ 을 사용하여 현재 파일의 절대 경로를 기준으로 _common.php를 포함합니다.
|
|
include_once(__DIR__."/_common.php");
|
|
|
|
// 최고 관리자만 이 기능에 접근할 수 있도록 제한합니다.
|
|
if ($is_admin != 'super') {
|
|
echo json_encode(['error' => '접근 권한이 없습니다.']);
|
|
exit;
|
|
}
|
|
|
|
// GET 파라미터로 받은 템플릿 코드를 가져옵니다.
|
|
$template_code = isset($_GET['code']) ? trim($_GET['code']) : '';
|
|
|
|
if (!$template_code) {
|
|
echo json_encode(['error' => '템플릿 코드가 전송되지 않았습니다.']);
|
|
exit;
|
|
}
|
|
|
|
// 템플릿 정보를 다루는 클래스를 포함합니다.
|
|
require_once(__DIR__ . '/classes/TemplateManager.php');
|
|
|
|
$templateManager = new TemplateManager();
|
|
|
|
// 코드로 템플릿 정보를 조회하여 ID를 얻습니다.
|
|
$template = $templateManager->getByCode($template_code);
|
|
if (!$template) {
|
|
echo json_encode(['error' => "템플릿을 찾을 수 없습니다: " . htmlspecialchars($template_code)]);
|
|
exit;
|
|
}
|
|
|
|
// 템플릿 ID를 사용하여 연관된 변수와 기본값들을 가져옵니다.
|
|
$variables = $templateManager->getVarsByTemplateId($template['id']);
|
|
|
|
// 성공적으로 조회된 변수 목록을 JSON 형식으로 반환합니다.
|
|
echo json_encode(['success' => true, 'variables' => $variables]);
|
|
exit; |