From ac9a784f7e3f1a492ac9c84224abe8faf2a2ab25 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 27 Aug 2026 16:57:49 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20Q&A=20=ED=8C=8C=EC=9D=BC=20=EC=97=85?= =?UTF-8?q?=EB=A1=9C=EB=93=9C=20=EA=B6=8C=ED=95=9C=20=EC=98=A4=EB=A5=98=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- egbim/bbs/descope_qa_write.php | 24 ++++++++++++++---------- eng/bbs/descope_qa_write.php | 24 ++++++++++++++---------- scripts/deploy_remote.sh | 11 +++++++++-- scripts/setup_gitea_remote.sh | 2 +- 4 files changed, 38 insertions(+), 23 deletions(-) diff --git a/egbim/bbs/descope_qa_write.php b/egbim/bbs/descope_qa_write.php index 4b7b317..6b0a84f 100644 --- a/egbim/bbs/descope_qa_write.php +++ b/egbim/bbs/descope_qa_write.php @@ -62,16 +62,20 @@ if ($isEdit) { } // === 파일 업로드 처리 공통 함수 === -function handle_file_uploads(PDO $pdo, int $postId, array &$errors) { - if (empty($_FILES['attach']['name'][0])) return; - - $uploadDir = __DIR__ . '/../uploads/qa/'; - if (!is_dir($uploadDir)) { - mkdir($uploadDir, 0777, true); - } - if (!is_writable($uploadDir)) { - @chmod($uploadDir, 0777); - } +function handle_file_uploads(PDO $pdo, int $postId, array &$errors) { + if (empty($_FILES['attach']['name'][0])) return; + + $uploadDir = dirname(__DIR__) . '/uploads/qa'; + if (!is_dir($uploadDir)) { + if (!mkdir($uploadDir, 0777, true) && !is_dir($uploadDir)) { + $errors[] = '업로드 폴더를 생성할 수 없습니다.'; + return; + } + } + if (!is_writable($uploadDir)) { + @chmod($uploadDir, 0777); + clearstatcache(true, $uploadDir); + } if (!is_writable($uploadDir)) { $errors[] = '업로드 폴더에 쓰기 권한이 없습니다.'; return; diff --git a/eng/bbs/descope_qa_write.php b/eng/bbs/descope_qa_write.php index 25fbe8f..1da475a 100644 --- a/eng/bbs/descope_qa_write.php +++ b/eng/bbs/descope_qa_write.php @@ -62,16 +62,20 @@ if ($isEdit) { } // === 파일 업로드 처리 공통 함수 === -function handle_file_uploads(PDO $pdo, int $postId, array &$errors) { - if (empty($_FILES['attach']['name'][0])) return; - - $uploadDir = __DIR__ . '/../uploads/qa/'; - if (!is_dir($uploadDir)) { - mkdir($uploadDir, 0777, true); - } - if (!is_writable($uploadDir)) { - @chmod($uploadDir, 0777); - } +function handle_file_uploads(PDO $pdo, int $postId, array &$errors) { + if (empty($_FILES['attach']['name'][0])) return; + + $uploadDir = dirname(__DIR__) . '/uploads/qa'; + if (!is_dir($uploadDir)) { + if (!mkdir($uploadDir, 0777, true) && !is_dir($uploadDir)) { + $errors[] = 'Upload folder could not be created.'; + return; + } + } + if (!is_writable($uploadDir)) { + @chmod($uploadDir, 0777); + clearstatcache(true, $uploadDir); + } if (!is_writable($uploadDir)) { $errors[] = 'Upload folder is not writable.'; return; diff --git a/scripts/deploy_remote.sh b/scripts/deploy_remote.sh index 5adbe07..7edccaa 100755 --- a/scripts/deploy_remote.sh +++ b/scripts/deploy_remote.sh @@ -69,9 +69,16 @@ mkdir -p \ egbim/data/cache \ egbim/data/session \ egbim/data/log \ + egbim/uploads/qa \ eng/data/cache \ eng/data/session \ - eng/data/log + eng/data/log \ + eng/uploads/qa + +# uploads/qa 는 Git이 디렉터리 권한을 보존하지 않으며, app 컨테이너의 +# Apache(www-data)가 bind mount 된 호스트 디렉터리에 파일을 저장해야 한다. +# 배포 직후에도 Q&A 첨부파일을 저장할 수 있도록 권한을 명시한다. +chmod 0777 egbim/uploads/qa eng/uploads/qa mkdir -p docker/mysql/init @@ -111,4 +118,4 @@ if [[ -f "$db_dump_path" && ! -f "$db_import_marker" ]]; then docker compose exec -T db mariadb-admin ping -h localhost -uroot "-p${MARIADB_ROOT_PASSWORD}" >/dev/null 2>&1 docker compose exec -T db mariadb -u"${G5_MYSQL_USER}" "-p${G5_MYSQL_PASSWORD}" "${G5_MYSQL_DB}" < "$db_dump_path" touch "$db_import_marker" -fi \ No newline at end of file +fi diff --git a/scripts/setup_gitea_remote.sh b/scripts/setup_gitea_remote.sh index 58186d9..4175550 100755 --- a/scripts/setup_gitea_remote.sh +++ b/scripts/setup_gitea_remote.sh @@ -9,7 +9,7 @@ case "$remote_mode" in remote_url="https://gitea.hmac.kr/b24014/egbim_homepage.git" ;; ssh) - remote_url="ssh://git@172.16.10.175:22/b24014/egbim_homepage.git" + remote_url="ssh://git@10.13.10.4:22/b24014/egbim_homepage.git" ;; *) echo "Usage: $0 [https|ssh]" >&2