$_POST['name'] ?? '', 'host' => $_POST['host'] ?? '', 'username' => $_POST['username'] ?? '', 'password' => preg_replace('/\s+/', '', $_POST['password'] ?? ''), // 비밀번호 공백 제거 'port' => (int)($_POST['port'] ?? 0), 'encryption' => $_POST['encryption'] ?? 'ssl', 'from_email' => $_POST['from_email'] ?? '', 'from_name' => $_POST['from_name'] ?? '', 'is_use' => isset($_POST['is_use']) ? 1 : 0, ]; try { if ($action === 'create') { $smtpManager->create($data); alert('SMTP 설정이 성공적으로 추가되었습니다.', './smtp_config.php'); } elseif ($action === 'update' && $id > 0) { $smtpManager->update($id, $data); alert('SMTP 설정이 성공적으로 수정되었습니다.', './smtp_config.php'); } elseif ($action === 'delete' && $id > 0) { $smtpManager->delete($id); alert('선택한 SMTP 설정이 삭제되었습니다.', './smtp_config.php'); } } catch (Exception $e) { // 데이터베이스 오류 등 예외 발생 시 처리 alert('작업 중 오류가 발생했습니다: '.$e->getMessage()); } // 작업 완료 후 페이지 이동 goto_url('./smtp_config.php'); exit; } // 5. 페이지 제목 설정 $g5['title'] = 'SMTP 설정 관리'; // 6. 뷰(View) 처리 (폼 또는 목록 표시) // 설정 추가 또는 수정 폼을 표시합니다. if ($action === 'create_form' || $action === 'edit_form') { $smtp = null; if ($action === 'edit_form') { if (!$id) { alert('잘못된 접근입니다.'); } $smtp = $smtpManager->get($id); if (!$smtp) { alert('존재하지 않는 SMTP 설정입니다.'); } } // smtp_config_form.php 파일 내에 admin.head.php와 admin.tail.php가 포함되어 있습니다. include_once('./templates/smtp_config_form.php'); exit; // 폼 출력 후 스크립트 실행을 중단합니다. } // 기본 페이지: SMTP 설정 목록을 가져옵니다. $smtp_list = $smtpManager->getAll(); // 목록 페이지의 상단 부분을 포함합니다. include_once(G5_ADMIN_PATH.'/admin.head.php'); include(__DIR__.'/templates/smtp_config_list.php'); // 목록 페이지의 하단 부분을 포함합니다. include_once(G5_ADMIN_PATH.'/admin.tail.php');