false, 'message' => '°ü¸®ÀÚ ºñ¹Ð¹øÈ£°¡ ÀÏÄ¡ÇÏÁö ¾Ê½À´Ï´Ù.']); exit; } $title = $_POST['title']; $writer = "°ü¸®ÀÚ"; $date = date("Y-m-d"); $uploaded_files = []; // ´ÙÁß ÆÄÀÏ Ã³¸® if (isset($_FILES['files'])) { $count = count($_FILES['files']['name']); for ($i = 0; $i < $count; $i++) { $tmp = $_FILES['files']['tmp_name'][$i]; $name = basename($_FILES['files']['name'][$i]); $ext = strtolower(pathinfo($name, PATHINFO_EXTENSION)); if (in_array($ext, ['pdf', 'doc', 'docx'])) { // ÆÄÀÏ¸í ³¼öÈ $save_name = time() . '_' . mt_rand(100, 999) . '.' . $ext; $dest_path = $upload_dir . $save_name; if (move_uploaded_file($tmp, $dest_path)) { // À¥ °æ·Î·Î ÀúÀå $web_path = $web_url_base . $save_name; $uploaded_files[] = ['name' => $name, 'path' => $web_path]; } } } } if (empty($title)) { echo json_encode(['success'=>false, 'message'=>'Á¦¸ñÀ» ÀÔ·ÂÇØÁÖ¼¼¿ä.']); exit; } $posts = file_exists($data_file) ? json_decode(file_get_contents($data_file), true) : []; $new_id = empty($posts) ? 1 : max(array_column($posts, 'id')) + 1; $new_post = [ 'id' => $new_id, 'title' => $title, 'writer' => $writer, 'date' => $date, 'files' => $uploaded_files ]; array_unshift($posts, $new_post); file_put_contents($data_file, json_encode($posts, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE)); echo json_encode(['success' => true]); } // 3. ¼ø¼ º¯°æ ÀúÀå else if ($action === 'reorder' && $_SERVER['REQUEST_METHOD'] === 'POST') { $input = json_decode(file_get_contents('php://input'), true); if (strtolower(hash('sha256', $input['password'])) !== $admin_password_hash) { echo json_encode(['success' => false, 'message' => '±ÇÇÑ ¾øÀ½']); exit; } if (isset($input['posts'])) { file_put_contents($data_file, json_encode($input['posts'], JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE)); echo json_encode(['success' => true]); } else { echo json_encode(['success' => false]); } } } catch (Exception $e) { echo json_encode(['success' => false, 'message' => $e->getMessage()]); } // [ÇÙ½É] PHP 󸮰¡ ³¡³ª¸é ¿©±â¼ ½ÇÇàÀ» ¸ØÃç¾ß ¾Æ·¡ HTMLÀÌ ¼¯ÀÌÁö ¾Ê½À´Ï´Ù. exit; } ?>