feat: GTSIT 사이트 구축

This commit is contained in:
박성필
2026-08-10 21:19:10 +09:00
commit dbb35d35c4
87 changed files with 48246 additions and 0 deletions

35
bin/create-admin.php Normal file
View File

@@ -0,0 +1,35 @@
<?php
declare(strict_types=1);
if (PHP_SAPI !== 'cli') {
http_response_code(404);
exit;
}
require dirname(__DIR__) . '/app/bootstrap.php';
use App\Database;
$username = trim((string) readline('관리자 아이디: '));
$displayName = trim((string) readline('표시 이름: '));
fwrite(STDOUT, '관리자 비밀번호: ');
if (function_exists('shell_exec')) shell_exec('stty -echo');
$password = trim((string) fgets(STDIN));
if (function_exists('shell_exec')) shell_exec('stty echo');
fwrite(STDOUT, PHP_EOL);
if ($username === '' || $displayName === '' || strlen($password) < 12) {
fwrite(STDERR, "아이디와 표시 이름, 12자 이상의 비밀번호가 필요합니다.\n");
exit(1);
}
$statement = Database::connection()->prepare(
'INSERT INTO admins (username, password_hash, display_name) VALUES (:username, :password_hash, :display_name)'
);
$statement->execute([
'username' => $username,
'password_hash' => password_hash($password, PASSWORD_DEFAULT),
'display_name' => $displayName,
]);
fwrite(STDOUT, "관리자 계정이 생성되었습니다.\n");

View File

@@ -0,0 +1,27 @@
<?php
declare(strict_types=1);
if (PHP_SAPI !== 'cli') {
http_response_code(404);
exit;
}
require dirname(__DIR__) . '/app/bootstrap.php';
use App\Database;
$sql = file_get_contents(dirname(__DIR__) . '/database/migrate-20260805-inquiry-pin.sql');
if ($sql === false) {
fwrite(STDERR, "마이그레이션 파일을 읽을 수 없습니다.\n");
exit(1);
}
$statements = preg_split('/;\s*(?:\R|$)/', trim($sql)) ?: [];
foreach ($statements as $statement) {
if (trim($statement) !== '') {
Database::connection()->exec($statement);
}
}
fwrite(STDOUT, "문의 조회 PIN 마이그레이션을 적용했습니다.\n");

21
bin/purge-inquiries.php Normal file
View File

@@ -0,0 +1,21 @@
<?php
declare(strict_types=1);
if (PHP_SAPI !== 'cli') {
http_response_code(404);
exit;
}
require dirname(__DIR__) . '/app/bootstrap.php';
use App\Database;
$statement = Database::connection()->prepare(
'DELETE FROM inquiries
WHERE closed_at IS NOT NULL
AND closed_at < DATE_SUB(NOW(), INTERVAL 1 YEAR)'
);
$statement->execute();
fwrite(STDOUT, sprintf("보유기간이 지난 문의 %d건을 삭제했습니다.\n", $statement->rowCount()));