티스토리 뷰

라이믹스

라이믹스 입력 폼

xemaker 2026. 6. 12. 15:16

이전글에 insDoc.html 파일이 있으니 입력 html은 그것을 참고 하면 되고..

라이믹스마다 좀 다른게 있는지 수정했다.

insDoc 폴더를 하나 만들고 거기에 insDoc.html, insert_proc.php 파일 2개를 넣고 하면 된다.

다른 호스팅에서 하니까 기존 파일에 ,member_srl,email_address,homepage,ipaddress 이 부분이 필수라고 해서 추가한 버전이다.

 

<?php
ob_start();
error_reporting(0);
ini_set('display_errors', 0);

define('__XE__', true);
require_once('../config/config.inc.php');
$oContext = &Context::getInstance();
$oContext->init();

header('Content-Type: application/json');

try {
    // 1. 데이터 수집
    $title = "후원신청서 - " . ($_POST['member_name'] ?: '무명후원자');
    $member_name = $_POST['member_name'] ?? '미입력';
    $support_type = $_POST['support_type'] ?? '정기후원';
    $support_category = $_POST['support_category'] ?? '미선택';
    $support_amount = $_POST['support_amount'] ?? '0';
    $member_type = $_POST['member_type'] ?? '개인';
    $phone = $_POST['phone'] ?? '미입력';
    $email = $_POST['email'] ?? '미입력';
    $bank_name = $_POST['bank_name'] ?? '미선택';
    $account_num = $_POST['account_num'] ?? '미입력';
    $pay_date = $_POST['pay_date'] ?? '미지정';
    
    // 서명 데이터 (Base64)
    $signature_data = $_POST['signature_image'] ?? ''; 

    // --- 추가: 약관 동의 데이터 수집 (반복문 처리) ---
    $agreement_list_html = "";
    for ($i = 0; $i < 5; $i++) {
        $t_title   = $_POST["term_title_$i"]; // HTML hidden 필드에서 전달됨
        $t_content = $_POST["term_content_$i"]; // HTML hidden 필드에서 전달됨
        $t_agree   = ($_POST["agree_$i"] == 'Y') ? '동의/확인함' : '미동의';

        if($t_title) {
            $agreement_list_html .= "
                <div style='margin-bottom:12px; border-bottom:1px dashed #ccc; padding-bottom:8px;'>
                    <div style='font-weight:bold; font-size:13px; color:#333;'>▣ {$t_title}</div>
                    <div style='font-size:11px; color:#666; margin:4px 0; line-height:1.4;'>{$t_content}</div>
                    <div style='font-size:12px;'>결과: <span style='color:#007aff; font-weight:bold;'>{$t_agree}</span></div>
                </div>";
        }
    }

    $module_srl = 2301; 
    $oDB = DB::getInstance();
    $document_srl = getNextSequence();
    $regdate = date('YmdHis');

    // 2. 정적 HTML 파일 생성 경로 설정
    $html_save_dir = '../files/saved_html/';
    if(!is_dir($html_save_dir)) mkdir($html_save_dir, 0777, true);

    $html_filename = "support_{$document_srl}.html";
    $html_web_path = '/rx/files/saved_html/' . $html_filename;
    $html_full_path = $html_save_dir . $html_filename;

    // 3. 서류 디자인 (증빙용 HTML)
    $saved_html_content = '
    <!DOCTYPE html>
    <html lang="ko">
    <head>
        <meta charset="UTF-8">
        <title>후원신청서 증빙 - ' . htmlspecialchars($member_name) . '</title>
        <style>
            body { font-family: "Malgun Gothic", sans-serif; padding: 30px; line-height: 1.5; color: #333; }
            .doc-wrap { max-width: 700px; margin: 0 auto; border: 1px solid #000; padding: 30px; }
            h1 { text-align: center; font-size: 24px; text-decoration: underline; margin-bottom: 30px; }
            table { width: 100%; border-collapse: collapse; margin-bottom: 20px; }
            th, td { border: 1px solid #ccc; padding: 10px; font-size: 14px; }
            th { background: #f4f4f4; width: 30%; text-align: left; }
            .sig-box { text-align: center; margin-top: 40px; border-top: 2px solid #333; padding-top: 20px; }
            .sig-image { border: 1px solid #eee; width: 250px; height: 100px; margin-top: 10px; }
            .term-area { margin-top:30px; border:1px solid #eee; padding:15px; background:#fafafa; page-break-before: always; }
            @media print { .no-print { display: none; } }
        </style>
    </head>
    <body>
        <div class="no-print" style="text-align:right;"><button onclick="window.print()">PDF 저장 / 인쇄</button></div>
        <div class="doc-wrap">
            <h1>후 원 신 청 서</h1>
            <p style="text-align:right;">접수번호: ' . $document_srl . '</p>
            
            <h3>1. 후원 정보</h3>
            <table>
                <tr><th>후원방식/종류</th><td>' . $support_type . ' / ' . $support_category . '</td></tr>
                <tr><th>후원금액</th><td>' . number_format((int)$support_amount) . ' 원</td></tr>
            </table>

            <h3>2. 후원자 정보</h3>
            <table>
                <tr><th>성명(단체명)</th><td>' . htmlspecialchars($member_name) . ' (' . $member_type . ')</td></tr>
                <tr><th>연락처</th><td>' . htmlspecialchars($phone) . '</td></tr>
                <tr><th>이메일</th><td>' . htmlspecialchars($email) . '</td></tr>
            </table>

            <h3>3. 결제 정보 (CMS)</h3>
            <table>
                <tr><th>은행명</th><td>' . htmlspecialchars($bank_name) . '</td></tr>
                <tr><th>계좌번호</th><td>' . htmlspecialchars($account_num) . '</td></tr>
                <tr><th>출금희망일</th><td>매월 ' . $pay_date . '</td></tr>
            </table>

            <div class="term-area">
                <h3>4. 이용 약관 및 동의 기록</h3>
                ' . $agreement_list_html . '
            </div>

            <div class="sig-box">
                <p>본인은 위와 같이 정기 후원을 신청하며, 개인정보 활용 및 약관에 동의합니다.</p>
                <p>' . date('Y년 m월 d일') . '</p>
                <p style="font-size:18px; font-weight:bold;">신청인: ' . htmlspecialchars($member_name) . ' (인)</p>
                <img src="' . $signature_data . '" class="sig-image" alt="서명">
            </div>
        </div>
    </body>
    </html>';

    file_put_contents($html_full_path, $saved_html_content);

    // 4. 게시판 본문에 저장될 상세 내용 구성
    $db_content = '
    <div class="sponsorship-detail" style="font-family:sans-serif; line-height:1.6; max-width:600px; border:1px solid #ddd; padding:20px;">
        <h2 style="border-bottom:2px solid #007aff; padding-bottom:10px; color:#333;">후원 신청 상세 정보</h2>
        
        <table style="width:100%; border-collapse:collapse; margin-top:15px;">
            <tr><th style="width:30%; padding:8px; border:1px solid #ddd; background:#f9f9f9; text-align:left;">후원방식/종류</th><td style="padding:8px; border:1px solid #ddd;">' . htmlspecialchars($support_type) . ' / ' . htmlspecialchars($support_category) . '</td></tr>
            <tr><th style="padding:8px; border:1px solid #ddd; background:#f9f9f9; text-align:left;">후원금액</th><td style="padding:8px; border:1px solid #ddd;"><strong>' . number_format((int)$support_amount) . '원</strong></td></tr>
            <tr><th style="padding:8px; border:1px solid #ddd; background:#f9f9f9; text-align:left;">성명(단체명)</th><td style="padding:8px; border:1px solid #ddd;">' . htmlspecialchars($member_name) . ' (' . htmlspecialchars($member_type) . ')</td></tr>
            <tr><th style="padding:8px; border:1px solid #ddd; background:#f9f9f9; text-align:left;">연락처</th><td style="padding:8px; border:1px solid #ddd;">' . htmlspecialchars($phone) . '</td></tr>
            <tr><th style="padding:8px; border:1px solid #ddd; background:#f9f9f9; text-align:left;">이메일</th><td style="padding:8px; border:1px solid #ddd;">' . htmlspecialchars($email) . '</td></tr>
            <tr><th style="padding:8px; border:1px solid #ddd; background:#f9f9f9; text-align:left;">은행/계좌</th><td style="padding:8px; border:1px solid #ddd;">' . htmlspecialchars($bank_name) . ' / ' . htmlspecialchars($account_num) . '</td></tr>
            <tr><th style="padding:8px; border:1px solid #ddd; background:#f9f9f9; text-align:left;">출금희망일</th><td style="padding:8px; border:1px solid #ddd;">매월 ' . htmlspecialchars($pay_date) . '</td></tr>
        </table>

        <div style="margin-top:20px; padding:15px; border:1px solid #e1e1e1; background:#fcfcfc;">
            <h4 style="margin:0 0 10px 0; color:#007aff;">[약관 동의 기록]</h4>
            ' . $agreement_list_html . '
        </div>

        <div style="margin-top:20px; text-align:center; background:#f5f5f5; padding:10px;">
            <p style="font-size:12px; color:#666; margin-bottom:5px;">[후원자 서명 확인]</p>
            <img src="' . $signature_data . '" style="width:200px; height:80px; border:1px solid #ccc; background:#fff;" alt="서명">
        </div>

        <div style="margin-top:20px; padding:15px; border:2px solid #007aff; background:#f0f8ff; text-align:center;">
            <strong style="color:#007aff;">[증빙용 문서 다운로드]</strong><br>
            <a href="' . $html_web_path . '" target="_blank" style="font-size:15px; font-weight:bold; color:#d9534f; text-decoration:underline;">
                ▶ 서명 포함된 후원신청서(HTML) 열기
            </a>
        </div>
    </div>';

    // 5. DB 저장
    $password = $_POST['password'] ?: '1111';
    $hash_password = getModel('member')->hashPassword($password);

    $query = "INSERT INTO documents (document_srl, module_srl, title, content,user_name, nick_name, password, regdate, last_update, list_order, update_order, status,member_srl,email_address,homepage,ipaddress) 
              VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 'SECRET',?,?,?,?)";
    
    $args = array($document_srl, $module_srl, $title, $db_content, $member_name,$member_name, $hash_password, $regdate, $regdate, $document_srl*-1, $document_srl*-1,0,$email,'a',0);
    $oDB->prepare($query)->execute($args);

    ob_end_clean();
    echo json_encode(array('error' => 0, 'message' => '후원 신청이 정상적으로 완료되었습니다.'));

} catch (Exception $e) {
    ob_end_clean();
    echo json_encode(array('error' => -1, 'message' => $e->getMessage()));
}
댓글
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2026/07   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함