게시글 문자발송 문의드려요

게시글 문자발송 문의드려요

QA

게시글 문자발송 문의드려요

본문

로그에도 정상적으로 문자가 발송되었다고 뜨는데

문자가 안와요 아래소스중 뭐가 문제있는걸까요?ㅠㅠ



<?php
include_once('./_common.php');
// ===================================================================================
// 1. 보안 및 기본 체크
// ===================================================================================
if (!$is_member) {
    alert('회원만 접근 가능합니다.');
}
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
    alert('올바른 방법으로 접근해 주십시오.');
}
// CSRF 토큰 검증 (토큰이 있는 경우)
if (function_exists('check_admin_token')) {
    check_admin_token();
}
// ===================================================================================
// 2. 폼 데이터 받기 및 변수 정리
// ===================================================================================
// 수정 모드인지 신규 작성 모드인지 구분하기 위한 re_id
$re_id = isset($_POST['re_id']) ? (int)$_POST['re_id'] : 0;
$mb_id = sql_real_escape_string($member['mb_id']);
// 모든 폼 데이터 받기
$post_data = array(
    're_title'            => trim($_POST['re_title'] ?? ''),
    're_content'          => trim($_POST['re_content'] ?? ''),
    're_age'              => trim($_POST['re_age'] ?? ''),
    're_gender'           => trim($_POST['re_gender'] ?? ''),
    're_phone'            => trim($_POST['re_phone'] ?? ''),
    're_phone_visible'    => isset($_POST['re_phone_visible']) ? (int)$_POST['re_phone_visible'] : 1,
    're_messenger_type'   => trim($_POST['re_messenger_type'] ?? ''),
    're_messenger_id'     => trim($_POST['re_messenger_id'] ?? ''),
    're_current_status'   => trim($_POST['re_current_status'] ?? ''),
    're_experience_level' => trim($_POST['re_experience_level'] ?? ''),
    're_desired_industry' => trim($_POST['re_desired_industry'] ?? ''),
    're_desired_region'   => trim($_POST['re_desired_region'] ?? ''),
    're_salary_type'      => trim($_POST['re_salary_type'] ?? ''),
    're_salary_amount'    => trim($_POST['re_salary_amount'] ?? ''),
    're_expose_status'    => isset($_POST['re_expose_status']) ? (int)$_POST['re_expose_status'] : 1
);
// ===================================================================================
// 2-1. 필수 필드 검증
// ===================================================================================
$required_fields = array('re_age', 're_gender', 're_phone', 're_current_status');
foreach ($required_fields as $field) {
    if (empty($post_data[$field])) {
        alert('필수 입력 항목을 모두 채워주세요. (' . $field . ')');
    }
}
// 체크박스 값 처리 (배열 -> 쉼표로 구분된 문자열)
$skills_array = isset($_POST['re_skills']) && is_array($_POST['re_skills']) ? $_POST['re_skills'] : array();
$post_data['re_skills'] = '';
if (!empty($skills_array)) {
    $safe_skills = array();
    foreach ($skills_array as $skill) {
        $safe_skills[] = sql_real_escape_string(trim($skill));
    }
    $post_data['re_skills'] = implode(',', $safe_skills);
}
$conditions_array = isset($_POST['re_work_conditions']) && is_array($_POST['re_work_conditions']) ? $_POST['re_work_conditions'] : array();
$post_data['re_work_conditions'] = '';
if (!empty($conditions_array)) {
    $safe_conditions = array();
    foreach ($conditions_array as $condition) {
        $safe_conditions[] = sql_real_escape_string(trim($condition));
    }
    $post_data['re_work_conditions'] = implode(',', $safe_conditions);
}
// ===================================================================================
// 3. 사진 파일 업로드 처리
// ===================================================================================
$re_photo_path = '';
// 수정 모드일 경우, 기존 사진 경로를 먼저 불러옵니다.
if ($re_id) {
    $result = sql_fetch(" SELECT re_photo FROM g5_write_resumes WHERE re_id = {$re_id} AND mb_id = '{$mb_id}' ");
    if ($result && isset($result['re_photo'])) {
        $re_photo_path = $result['re_photo'];
    }
}
// 새 파일이 업로드된 경우
if (isset($_FILES['re_photo']) && $_FILES['re_photo']['error'] == 0 && !empty($_FILES['re_photo']['name'])) {
    $file = $_FILES['re_photo'];
    
    // 파일 검증
    $ext = strtolower(pathinfo($file['name'], PATHINFO_EXTENSION));
    $allowed_ext = array('jpg', 'jpeg', 'png', 'gif');
    
    if (!in_array($ext, $allowed_ext)) {
        alert('이미지 파일(jpg, jpeg, png, gif)만 업로드 가능합니다.');
    }
    
    // 파일 크기 체크 (예: 5MB 이하)
    $max_size = 5 * 1024 * 1024;
    if ($file['size'] > $max_size) {
        alert('파일 크기는 5MB 이하여야 합니다.');
    }
    
    // 업로드 디렉토리 생성
    $upload_dir = G5_DATA_PATH . '/resume_photo';
    if (!is_dir($upload_dir)) {
        if (!($upload_dir, G5_DIR_PERMISSION, true)) {
            alert('업로드 폴더 생성에 실패했습니다. 관리자에게 문의하세요.');
        }
        @chmod($upload_dir, G5_DIR_PERMISSION);
    }
    
    // 새 파일명 생성 (보안)
    $new_filename = $member['mb_id'] . '_' . time() . '_' . rand(1000, 9999) . '.' . $ext;
    $upload_path = $upload_dir . '/' . $new_filename;
    
    if (move_uploaded_file($file['tmp_name'], $upload_path)) {
        // 기존 파일이 있다면 삭제
        if ($re_photo_path && file_exists(G5_PATH . $re_photo_path)) {
            @unlink(G5_PATH . $re_photo_path);
        }
        $re_photo_path = '/data/resume_photo/' . $new_filename;
    } else {
        alert('사진 파일 업로드에 실패했습니다. 폴더 권한 등을 확인해주세요.');
    }
} elseif (isset($_FILES['re_photo']) && $_FILES['re_photo']['error'] != 0) {
    // 파일 업로드 실패
    $error_msg = '';
    switch ($_FILES['re_photo']['error']) {
        case UPLOAD_ERR_INI_SIZE:
        case UPLOAD_ERR_FORM_SIZE:
            $error_msg = '파일 크기가 너무 큽니다.';
            break;
        case UPLOAD_ERR_NO_FILE:
            break;
        default:
            $error_msg = '파일 업로드 중 오류가 발생했습니다.';
    }
    if ($error_msg) {
        alert($error_msg);
    }
}
$post_data['re_photo'] = $re_photo_path;
// ===================================================================================
// 4. 데이터베이스(DB) 저장 (신규 등록 / 수정 분기 처리)
// ===================================================================================
// SQL 쿼리에 들어갈 key=value 형태의 문자열 생성
$sql_set_clauses = array();
foreach ($post_data as $key => $value) {
    // SQL 인젝션 방어 및 HTML 엔티티 인코딩
    $safe_value = sql_real_escape_string(htmlspecialchars($value, ENT_QUOTES, 'UTF-8'));
    $sql_set_clauses[] = " {$key} = '{$safe_value}' ";
}
$sql_set_string = implode(', ', $sql_set_clauses);
if ($re_id) {
    // ----- 수정 모드 -----
    // 자신의 이력서가 맞는지 한번 더 확인
    $resume = sql_fetch(" SELECT re_id FROM g5_write_resumes WHERE re_id = {$re_id} AND mb_id = '{$mb_id}' ");
    if (empty($resume['re_id'])) {
        alert('자신의 이력서만 수정할 수 있습니다.');
    }
    $sql = " UPDATE g5_write_resumes 
             SET {$sql_set_string},
                 re_updated_datetime = '" . G5_TIME_YMDHIS . "'
             WHERE re_id = {$re_id} AND mb_id = '{$mb_id}' ";
    
    $success_msg = '이력서가 성공적으로 수정되었습니다.';
} else {
    // ----- 신규 등록 모드 -----
    $sql = " INSERT INTO g5_write_resumes 
             SET mb_id = '{$mb_id}',
                 {$sql_set_string},
                 re_datetime = '" . G5_TIME_YMDHIS . "',
                 re_updated_datetime = '" . G5_TIME_YMDHIS . "' ";
    $success_msg = '이력서가 성공적으로 등록되었습니다.';
}
// SMS 라이브러리 포함
@include_once(G5_LIB_PATH.'/icode.sms.lib.php');
// SQL 실행
if (!sql_query($sql)) {
    alert('데이터 저장 중 오류가 발생했습니다. 관리자에게 문의하세요.');
}
// SMS 문자전송 시작
if ($config['cf_sms_use'] == 'icode') {
    // 핸드폰번호에서 숫자만 취함
    $receive_number = preg_replace("/[^0-9]/", "", $member['mb_hp']);
    $send_number = preg_replace("/[^0-9]/", "", $config['cf_phone']);
    // SMS 메시지
    $sms_contents = $re_id ? 
        "[이력서 알림] ".$member['mb_name']."님의 이력서가 수정되었습니다." : 
        "[이력서 알림] ".$member['mb_name']."님의 이력서가 등록되었습니다.";
    // SMS 로그
    $log_file = G5_DATA_PATH.'/sms_debug.log';
    $log_content = date('Y-m-d H:i:s')." - SMS 전송 시도\n";
    $log_content .= "수신 번호: ".$receive_number."\n";
    $log_content .= "발신 번호: ".$send_number."\n";
    $log_content .= "메시지: ".$sms_contents."\n";
    // LMS 타입인 경우
    if ($config['cf_sms_type'] == 'LMS') {
        include_once(G5_LIB_PATH.'/icode.lms.lib.php');
        $port_setting = get_icode_port_type($config['cf_icode_id'], $config['cf_icode_pw']);
        if ($port_setting !== false) {
            $SMS = new LMS;
            $SMS->SMS_con(
                $config['cf_icode_server_ip'], 
                $config['cf_icode_id'], 
                $config['cf_icode_pw'], 
                $port_setting
            );
            $strDest = array($receive_number);
            $strCallBack = $send_number;
            $strCaller = iconv_euckr(trim($config['cf_title']));
            $strSubject = '';
            $strURL = '';
            $strData = iconv_euckr($sms_contents);
            $strDate = '';
            $nCount = 1;
            $res = $SMS->Add($strDest, $strCallBack, $strCaller, $strSubject, $strURL, $strData, $strDate, $nCount);
            $send_result = $SMS->Send();
            $SMS->Init();
            $log_content .= "LMS 발송 결과: ".print_r($send_result, true)."\n";
        }
    } 
    // SMS 타입인 경우
    else {
        include_once(G5_LIB_PATH.'/icode.sms.lib.php');
        $SMS = new SMS; // SMS 연결
        $SMS->SMS_con(
            $config['cf_icode_server_ip'], 
            $config['cf_icode_id'], 
            $config['cf_icode_pw'], 
            $config['cf_icode_server_port']
        );
        
        $SMS->Add(
            $receive_number, 
            $send_number, 
            $config['cf_icode_id'], 
            iconv_euckr(stripslashes($sms_contents)), 
            ""
        );
        
        $send_result = $SMS->Send();
        $SMS->Init();
        $log_content .= "SMS 발송 결과: ".print_r($send_result, true)."\n";
    }
    // 로그 기록
    file_put_contents($log_file, $log_content, FILE_APPEND);
}
alert($success_msg, './_my_resume.php');

이 질문에 댓글 쓰기 :

답변 1

아이코드에 충전은 정상적으로 되어 있는지 발송하는쪽에 문제는 없는지 확인해 보셔야 할듯 합니다.
아이코드들어가면 발송내역에 제대로 기록되어 있는지 확인해 보셔야 할듯 합니다.

답변을 작성하시기 전에 로그인 해주세요.
전체 129,664 | RSS
QA 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1402호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT