초기 커밋: 5130 레거시 시스템
- URL 하드코딩 → .env APP_URL 기반 동적 URL로 변경 - DB 연결 하드코딩 → .env 기반으로 변경 - MySQL strict mode DATE 오류 수정
This commit is contained in:
98
models/basic_model.php
Normal file
98
models/basic_model.php
Normal file
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
// /models/basic_model.php
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . "/session.php");
|
||||
if (!isset($_SESSION["level"]) || $_SESSION["level"] > 5) {
|
||||
sleep(1);
|
||||
header("Location:" . $WebSite . "login/login_form.php");
|
||||
exit;
|
||||
}
|
||||
include $_SERVER['DOCUMENT_ROOT'] . '/load_header.php';
|
||||
$title_message = '기초모델관리';
|
||||
?>
|
||||
<title><?= $title_message ?></title>
|
||||
<?php if($chkMobile==true) { ?>
|
||||
<style>
|
||||
@media (max-width: 1000px) {
|
||||
body { font-size: 25px; }
|
||||
.form-control, .fw-bold, .table td, .table th { font-size: 25px; }
|
||||
button { font-size: 30px; }
|
||||
.modal-body, .modal-title { font-size: 30px; }
|
||||
}
|
||||
</style>
|
||||
<?php } ?>
|
||||
</head>
|
||||
<body>
|
||||
<?php require_once($_SERVER['DOCUMENT_ROOT'] . '/myheader.php'); ?>
|
||||
|
||||
<?php
|
||||
// JSON 파일 경로 설정: /models/basic_model.json
|
||||
$jsonFile = $_SERVER['DOCUMENT_ROOT'] . '/models/basic_model.json';
|
||||
|
||||
// 파일이 존재하면 읽어서 현재 모델명을 로드, 없으면 빈 값 사용
|
||||
$currentModel = "";
|
||||
if (file_exists($jsonFile)) {
|
||||
$jsonContent = file_get_contents($jsonFile);
|
||||
$data = json_decode($jsonContent, true);
|
||||
if (isset($data['model_name'])) {
|
||||
$currentModel = $data['model_name'];
|
||||
}
|
||||
}
|
||||
|
||||
// POST 요청 처리: 모델명 저장 및 수정
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$model_name = isset($_POST['model_name']) ? trim($_POST['model_name']) : "";
|
||||
$data = [
|
||||
"model_name" => $model_name,
|
||||
"updated_at" => date("Y-m-d H:i:s")
|
||||
];
|
||||
file_put_contents($jsonFile, json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE));
|
||||
header("Location: basic_model.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
// GET 요청으로 clear=1 전달 시 JSON 파일 삭제 (모델 초기화)
|
||||
if (isset($_GET['clear']) && $_GET['clear'] == 1) {
|
||||
if (file_exists($jsonFile)) {
|
||||
unlink($jsonFile);
|
||||
}
|
||||
header("Location: basic_model.php");
|
||||
exit;
|
||||
}
|
||||
?>
|
||||
|
||||
<div class="container mt-3">
|
||||
<h3><?= $title_message ?></h3>
|
||||
<form id="modelForm" method="post" action="basic_model.php" class="mb-4">
|
||||
<div class="mb-3">
|
||||
<label for="model_name" class="form-label">기초 모델명</label>
|
||||
<input type="text" id="model_name" name="model_name" class="form-control" placeholder="기초 모델명을 입력하세요" value="<?= htmlspecialchars($currentModel, ENT_QUOTES, 'UTF-8') ?>">
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">저장</button>
|
||||
<?php if (!empty($currentModel)): ?>
|
||||
<a href="basic_model.php?clear=1" class="btn btn-danger">삭제</a>
|
||||
<?php endif; ?>
|
||||
</form>
|
||||
|
||||
<?php if (!empty($currentModel)): ?>
|
||||
<div class="mt-3">
|
||||
<strong>현재 기초 모델명:</strong> <?= htmlspecialchars($currentModel, ENT_QUOTES, 'UTF-8') ?>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<div class="mt-3">
|
||||
<em>기초 모델명이 등록되어 있지 않습니다.</em>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<?php include $_SERVER['DOCUMENT_ROOT'] . '/common/modal.php'; ?>
|
||||
|
||||
<!-- 반드시 새로운 페이지에서 로더 숨김 스크립트를 포함 -->
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
var loader = document.getElementById('loadingOverlay');
|
||||
if(loader)
|
||||
loader.style.display = 'none';
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user