Initial commit: 교육 프로젝트 배포

This commit is contained in:
송대일
2026-07-01 18:32:42 +09:00
commit be6dccd120
1483 changed files with 5082202 additions and 0 deletions
+53
View File
@@ -0,0 +1,53 @@
<?php
require __DIR__ . '/../../bbs/db_conn.php';
header('Content-Type: application/json; charset=utf-8');
// PDO 연결 생성
$pdo = db_conn();
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
echo json_encode(['success' => false, 'message' => 'Invalid request']);
exit;
}
$content_id = isset($_POST['content_id']) ? trim($_POST['content_id']) : '';
$keywords_csv = isset($_POST['keywords']) ? trim($_POST['keywords']) : '';
$admin_id = 'admin'; // User login ID not provided in context, defaulting to 'admin'
if ($content_id === '') {
echo json_encode(['success' => false, 'message' => 'missing content_id']);
exit;
}
try {
$pdo->beginTransaction();
// Set all existing active keywords to inactive first
$updateStmt = $pdo->prepare("UPDATE edu_content_keywords SET is_active='0', updated_at=NOW(), updated_by=:admin WHERE content_id=:c AND is_active='1'");
$updateStmt->execute([':c' => $content_id, ':admin' => $admin_id]);
if ($keywords_csv !== '') {
$keywords = explode(',', $keywords_csv);
$insertStmt = $pdo->prepare("INSERT INTO edu_content_keywords (content_id, keyword_code, is_active, created_by, created_at, updated_by, updated_at)
VALUES (:c, :k, '1', :admin1, NOW(), :admin2, NOW())
ON DUPLICATE KEY UPDATE is_active='1', updated_by=:admin3, updated_at=NOW()");
foreach ($keywords as $k) {
$k = trim($k);
if ($k !== '') {
$insertStmt->execute([
':c' => $content_id,
':k' => $k,
':admin1' => $admin_id,
':admin2' => $admin_id,
':admin3' => $admin_id
]);
}
}
}
$pdo->commit();
echo json_encode(['success' => true]);
} catch (Exception $e) {
$pdo->rollBack();
echo json_encode(['success' => false, 'message' => $e->getMessage()]);
}