JSON¸¸ Ãâ·ÂÇÏ°í ¿©±â¼­ "ÇÁ·Î±×·¥ °­Á¦ Á¾·á(exit)" if ($action) { // Ȥ½Ã¶óµµ ¾Õ¼­ Ãâ·ÂµÈ °ø¹éÀ̳ª ¿¡·¯¸Þ½ÃÁö°¡ ÀÖ´Ù¸é Á¦°Å ob_clean(); header('Content-Type: application/json; charset=utf-8'); try { // 1. ¸ñ·Ï Á¶È¸ if ($action === 'list') { if (file_exists($data_file)) { echo file_get_contents($data_file); } else { echo json_encode([]); } } // 2. ±Û ¾²±â (ÆÄÀÏ ¾÷·Îµå) else if ($action === 'write' && $_SERVER['REQUEST_METHOD'] === 'POST') { $input_pw = isset($_POST['password']) ? $_POST['password'] : ''; // ºñ¹Ð¹øÈ£ °ËÁõ if (strtolower(hash('sha256', $input_pw)) !== $admin_password_hash) { echo json_encode(['success' => 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; $path = $upload_dir . $save_name; if (move_uploaded_file($tmp, $path)) { $uploaded_files[] = ['name' => $name, 'path' => $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; } ?> Çѹæ¹ÌÀÎÈ­ÀåǰHBMIC Çѹæ¹ÌÀÎÈ­ÀåǰHBMIC

ÀÚ·á½Ç

ÀÚ·á½Ç (¹®¼­ ºä¾î)

No Á¦¸ñ ÷ºÎÆÄÀÏ
·Îµù Áß...

»õ °Ô½Ã±Û µî·Ï

ÆÄÀÏ ¾øÀ½
¹®¼­ º¸±â