최초 커밋

This commit is contained in:
root
2026-07-23 16:15:57 +09:00
commit c8f5efb6b7
14652 changed files with 4812531 additions and 0 deletions
+154
View File
@@ -0,0 +1,154 @@
<?php
// descope_qa_detail.php
if (!defined('_GNUBOARD_')) define('_GNUBOARD_', true);
if (!defined('G5_URL')) define('G5_URL', '/eng');
if (!defined('G5_BBS_URL')) define('G5_BBS_URL', '/eng/bbs');
if (!defined('G5_IMG_URL')) define('G5_IMG_URL', '/eng/img');
// (1) 에러 출력 (개발 시)
// ini_set('display_errors', 1);
// error_reporting(E_ALL);
// (2) 세션·로그인 검사
//session_start();
// if (empty($_SESSION['user']['userId'])) {
// header('Location: login_form.php');
// exit;
// }
require_once __DIR__ . '/../skin/member/basic/descope_session.php';
require_once $_SERVER['DOCUMENT_ROOT'].'/eng/bbs/admin_guard.php';
$me = $_SESSION['user']['loginIds'][0] ?? '';
$admin = is_qna_admin();
// 첨부파일 접근 제어용 flag
$isLoggedIn = !empty($_SESSION['user']['userId']);
// (3) DB 연결
$host = 'db';
$dbname = 'egbim';
$user = 'egbim';
$pass = 'baron3840!!';
$charset= 'utf8mb4';
$pdo = new PDO(
"mysql:host={$host};dbname={$dbname};charset={$charset}",
$user,
$pass,
[PDO::ATTR_ERRMODE=>PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE=>PDO::FETCH_ASSOC]
);
// $postId = (int)($_GET['id']??0);
// 글·댓글 조회…
// (4) postId 검증
$postId = isset($_GET['id']) ? (int)$_GET['id'] : 0;
if ($postId < 1) {
exit('잘못된 접근입니다.');
}
// 2) 글 조회
$stmt = $pdo->prepare("
SELECT post_id, login_id, user_id, category, title, content,
is_secret, status, created_at,
is_internal, company, family_company, department, user_name, phone
FROM qa_posts
WHERE post_id = :pid
");
$stmt->execute([':pid'=>$postId]);
$post = $stmt->fetch();
if (!$post) exit('존재하지 않는 글입니다.');
// 관리자/일반 사용자 표시 이름 가공
$post['display_name'] = get_admin_display_name(
$post['login_id'],
$post['user_name'] ?: $post['login_id']
);
//관리자 글 조회시 new 미표시
if ($admin && $post['category'] !== 'notice') {
$pdo->prepare("UPDATE qa_posts SET is_read_admin = 1 WHERE post_id = ?")
->execute([$postId]);
}
// ▼ 비밀글 접근 체크 ▼
if ($post['is_secret'] && $post['login_id'] !== $me && !$admin) {
exit('⚠️ 비밀글은 작성자만 또는 관리자만 확인할 수 있습니다.');
}
// 회사/부서 표시 로직
if ((int)$post['is_internal'] === 1) {
// 내부 사용자 → family_company + department
$post['org_display'] = trim($post['family_company'] . ' ' . $post['department']);
} else {
// 외부 사용자 → company + department
$post['org_display'] = trim($post['company'] . ' ' . $post['department']);
}
// 3) 댓글 조회
$cm = $pdo->prepare("
SELECT comment_id,
commenter AS login_id,
user_name,
content AS comment_text,
created_at
FROM qa_comments
WHERE post_id = :pid
ORDER BY created_at
");
$cm->execute([':pid'=>$postId]);
$comments = $cm->fetchAll();
/* 관리자 이름 고정 처리 */
foreach ($comments as &$c) {
$c['user_name'] = get_admin_display_name($c['login_id'], $c['user_name']);
}
unset($c); // 참조 해제
// 첨부파일 조회
$attachments = [];
$af = $pdo->prepare("
SELECT id, ori_name, save_path, file_size, uploaded_at
FROM qa_attachments
WHERE post_id = :pid
ORDER BY id ASC
");
$af->execute([':pid'=>$postId]);
$attachments = $af->fetchAll();
// 상태/구분 라벨 매핑
$STATUS_LABELS = [
'new' => 'New',
'review' => 'Review',
'deep' => 'Checking',
'patch' => 'Patch',
'done' => 'Done'
];
$CATEGORY_LABELS = [
'general' => 'Other',
'improvement' => 'Impr.',
'error' => 'Error',
'notice' => '공지사항',
'admin' => '관리글',
];
// detail 뷰용 라벨 추가
$post['status_label'] = ($post['category'] === 'notice') ? '' : ($STATUS_LABELS[$post['status']] ?? $post['status']);
$post['category_label'] = $CATEGORY_LABELS[$post['category']] ?? $post['category'];
//Q&A user login_version
$isAdmin = $admin;
$loginVersion = null;
if ($isAdmin) {
$st = $pdo->prepare("SELECT login_version
FROM user_program_info
WHERE login_id = ?
ORDER BY id DESC
LIMIT 1");
$st->execute([$post['login_id']]); // 글쓴이 로그인 ID 기준
$loginVersion = $st->fetchColumn();
}
// 4) 뷰 렌더링 (데이터 준비가 완료된 뒤에)
include __DIR__ . '/../skin/qa/basic/descope_qa_detail.skin.php';
?>