/home/mjc1/public_html/sms/smssendUtf8.php


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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?
header
("Content-type:text/html;charset=euc-kr"); 
// include 정의
include_once("dbconnect.php");    // DB Connect Information
include_once("smsLibUtf8.php");        // SMS Library Function

$charSet_sql "set names utf8";      
mysql_query($charSet_sql$conn);

// Notice Error 방지
if(!isset($_POST['sendType']))    $_POST['sendType']    = "";
if(!isset(
$_POST['userId']))    $_POST['userId']    = "";
if(!isset(
$_POST['userPw']))    $_POST['userPw']    = "";
if(!isset(
$_POST['message']))    $_POST['message']    = "";
if(!isset(
$_POST['fromTel']))    $_POST['fromTel']    = "";
if(!isset(
$_POST['toTel']))        $_POST['toTel']        = "";

// 변수 선언
$sendType    $_POST['sendType'];    // 문자전송 타입(sms, mms)
$userId        $_POST['userId'];        // 사용자 ID
$userPw        $_POST['userPw'];        // 비밀번호
$message    $_POST['message'];    // 문자내용
$fromTel    $_POST['fromTel'];    // 전송자 번호
$toTel        $_POST['toTel'];        // 받는사람 번호
$userInfo    "";                    // 사용자 정보
$sms_no        "";                    // SMS 고유번호
$errorMsg    "";                    // Error 메세지

/*
$sendType = "mms";
$userId = "mijin";
$userPw = "1011010";
$toTel = "01025400030";
$fromTel = "15448680";
$message = "sms 전송 테스트 하고 있다";
*/

// 필수항목이 누락 되었을 경우 Error Message 출력 후 종료.
if($sendType == "" || $userId == "" || $userPw == "" || $message == "" || $fromTel == "" || $toTel == ""){
    echo 
$errorMsg "필수항목이 누락 되었습니다.";
    
// 디버깅 모드
    /*/
    foreach($_POST as $k => $value){
        echo $k."=>".$v."<br>";
    }
    */
    
exit;
}
$sql "SELECT userid FROM smsuser WHERE userid = '{$userId}' LIMIT 1";
$result mysql_query($sql$conn);
while(
$row mysql_fetch_assoc($result)){
    
// SQL Injection 공격을 막기 위해 비밀번호 체크 Query 분할
    
if($row['userid']){
        
$sql "SELECT userid, userpw, restcnt FROM smsuser WHERE userid = '{$row['userid']}' AND userpw = '{$userPw}'";
        
$result mysql_query($sql$conn);
        while(
$row mysql_fetch_assoc($result)){
            
$userInfo $row;
        }
    }
}
if(
$userInfo['userid'] == "" || $userInfo['userid'] == null){
    echo 
$errorMsg "아이디 및 비밀번호를 확인하세요.";
    exit;    
}
if(
$userInfo['restcnt'] <= 0){
    echo 
$errorMsg "잔여포인트가 부족합니다.";
    exit;    
}

// 실제 로직 처리 함수 호출 부분.
if($sendType == "sms"){
    echo 
SendSMS($userInfo['userid'], $toTel$fromTel$message$userInfo['restcnt']); // sms 전송 함수(사용자ID, 받는사람핸드폰, 보내는사람(회신전화번호), 발송일, 메세지, 현재포인트)
    
exit;
}else if(
$sendType == "mms"){
    echo 
SendMMS($userInfo['userid'], $toTel$fromTel$message$userInfo['restcnt']); // mms 전송 함수(사용자ID, 받는사람핸드폰, 보내는사람(회신전화번호), 발송일, 메세지, 현재포인트)
    
exit;
}else{
    echo 
$errorMsg "필수항목이 누락 되었습니다.";
    exit;
}
?>