diff --git a/adm/admin.menu900.php b/adm/admin.menu900.php new file mode 100644 index 000000000..3f851232b --- /dev/null +++ b/adm/admin.menu900.php @@ -0,0 +1,16 @@ + \ No newline at end of file diff --git a/adm/css/admin.css b/adm/css/admin.css index 570ce4688..4bfdabfe3 100644 --- a/adm/css/admin.css +++ b/adm/css/admin.css @@ -46,7 +46,7 @@ h3 {margin:0 20px} #tnb #tnb_logout a {color:#ff3061} #tnb span {position:absolute;bottom:10px;left:0;width:100%;text-align:center} -/* gnb js off */ +/* gnb */ #gnb {position:relative;z-index:12;min-width:999px;background:#383a3f} #gnb h2 {margin:0;padding:0;font-size:0;line-height:0;overflow:hidden} #gnb_1dul {position:relative;margin:0 20px;padding:0;zoom:1} @@ -72,7 +72,7 @@ h3 {margin:0 20px} #lnb:after {display:block;visibility:hidden;clear:both;content:""} #lnb li {float:left} -#lnb a {display:inline-block;margin:0 0 0 10px;padding:0 10px 0 0;border-right:1px solid #ccc;font-size:0.95em;letter-spacing:-0.1em} +#lnb a {display:inline-block;padding:0 10px;border-right:1px solid #ccc;font-size:0.95em;letter-spacing:-0.1em} /* 중간 레이아웃 */ #wrapper {z-index:5;margin:20px 0;min-width:1000px;zoom:1} @@ -133,10 +133,8 @@ h3 {margin:0 20px} .btn_confirm02 a:focus {background:#555} -.btn_confirm03 {clear:both;margin-top:10px;text-align:right} - +.btn_submit {margin:0;padding:0;border:0;background:#ff3061;color:#fff;cursor:pointer} -.btn_submit {background:#ff3061;cursor:pointer} .btn_confirm .btn_submit {padding:0 15px;border:0;height:30px;color:#fff} .btn_cancel {display:inline-block;padding:0 15px;height:30px;border:0;background:#617d46;color:#fff;text-decoration:none} a.btn_cancel {line-height:2.5em;vertical-align:middle} @@ -159,7 +157,7 @@ a.btn_cancel {line-height:2.5em;vertical-align:middle} .btn_list {margin:0 20px 10px} /* 목록용 */ .btn_list01 {} -.btn_list01 input, .btn_list01 button, .btn_list01 a {display:inline-block;padding:10px;border:1px solid #ccc;background:#fafafa;text-decoration:none;cursor:pointer} +.btn_list01 input, .btn_list01 button, .btn_list01 a {display:inline-block;margin:0;padding:10px;border:1px solid #ccc;background:#fafafa;text-decoration:none;cursor:pointer} .btn_list01 a:focus {background:#555} .btn_list02 {} @@ -211,7 +209,7 @@ legend {position:absolute;width:0;height:0;font-size:0;line-height:0;text-indent /* 하단 레이아웃 */ -#ft {margin:20px 0;padding:10px 20px;min-width:960px;border-top:1px solid #d0d6d8} +#ft {clear:both;margin:20px 0;padding:10px 20px;min-width:960px;border-top:1px solid #d0d6d8} /* 페이지 내 검색 */ @@ -229,7 +227,7 @@ legend {position:absolute;width:0;height:0;font-size:0;line-height:0;text-indent .local_sch02 strong {display:inline-block;width:80px} .local_sch02 strong.sch_long {width:160px} .local_sch02 label {display:inline-block;margin:0 5px 0 0} -.local_sch02 button {margin:0;padding:3px 5px;border:1px solid #ced9de;background:#f6f9fa;font-size:0.95em;cursor:pointer} +.local_sch02 button {margin:0;padding:5px;border:1px solid #ced9de;background:#f6f9fa;font-size:0.95em;vertical-align:middle;cursor:pointer} /* 페이지 내 실행 */ .local_cmd {min-width:960px} @@ -248,7 +246,7 @@ legend {position:absolute;width:0;height:0;font-size:0;line-height:0;text-indent .local_desc01 a {text-decoration:underline} .local_desc02 {margin:0 20px 10px;min-width:960px} /* 주로 온라인 서식 관련 안내 내용에 사용 */ -.local_desc02 p {padding:0} +.local_desc02 p {padding:0;line-height:1.8em} /* 페이지 내 카운트 */ .local_ov {min-width:960px} @@ -437,6 +435,9 @@ td.td_grpset {width:160px;border-left:1px solid #e9ecee;text-align:center} .txt_true {color:#e8180c} .txt_false {color:#ccc} + +.txt_succeed {color:#40b300} +.txt_fail {color:#ce4242} .banner_or_img {margin:10px 0 0} .banner_or_img button {display:block;margin:5px 0 0} @@ -774,6 +775,14 @@ strong.sodr_nonpay {display:block;padding:5px 0;text-align:right} .new_win .tbl_wrap {margin:0 20px 20px;padding:0} + +.new_win .win_btn {clear:both;padding:20px;text-align:center} /* 새창용 */ +.new_win .win_btn button {display:inline-block;padding:0 10px;height:30px;border:0;background:#4b545e;color:#fff;line-height:2em;cursor:pointer} +.new_win .win_btn input {padding:0 10px;height:30px;line-height:2em} +.new_win .win_btn a {display:inline-block;padding:0 10px;height:30px;background:#4b545e;color:#fff;vertical-align:middle;line-height:2.4em} +.new_win .win_btn a:focus, .new_win .win_btn a:hover {text-decoration:none} + + .new_win .local_sch, .new_win .local_cmd, .new_win .local_desc01, .new_win .local_desc02, .new_win .local_ov {min-width:320px} /* 자바스크립트 alert 대안 */ @@ -816,4 +825,4 @@ strong.sodr_nonpay {display:block;padding:5px 0;text-align:right} #post_code #result ul {margin:0;padding:0;border-bottom:1px solid #dde4e9;background:#f0f5fc;list-style:none} #post_code #result li {padding:10px;border:1px solid #dde4e9;border-bottom:0} #post_code #result li div {margin:4px 0 0;color:#738D94} -#post_code #result li div:before {content:"▶ "} +#post_code #result li div:before {content:"▶ "} \ No newline at end of file diff --git a/adm/member_form_update.php b/adm/member_form_update.php index 50543e0d7..cddbf100d 100644 --- a/adm/member_form_update.php +++ b/adm/member_form_update.php @@ -13,7 +13,7 @@ check_token(); $mb_id = trim($_POST['mb_id']); // 휴대폰번호 체크 -$mb_hp = $_POST['mb_hp']; +$mb_hp = hyphen_hp_number($_POST['mb_hp']); if($mb_hp) { $result = exist_mb_hp($mb_hp, $mb_id); if ($result) @@ -34,7 +34,7 @@ $sql_common = " mb_name = '{$_POST['mb_name']}', mb_email = '{$_POST['mb_email']}', mb_homepage = '{$_POST['mb_homepage']}', mb_tel = '{$_POST['mb_tel']}', - mb_hp = '{$_POST['mb_hp']}', + mb_hp = '{$mb_hp}', mb_certify = '{$mb_certify}', mb_adult = '{$mb_adult}', mb_zip1 = '{$_POST['mb_zip1']}', diff --git a/adm/member_list.php b/adm/member_list.php index 861c3dd42..34b2cf704 100644 --- a/adm/member_list.php +++ b/adm/member_list.php @@ -77,7 +77,7 @@ $colspan = 16;
- diff --git a/adm/sms_admin/_common.php b/adm/sms_admin/_common.php new file mode 100644 index 000000000..289691141 --- /dev/null +++ b/adm/sms_admin/_common.php @@ -0,0 +1,15 @@ +', 0); +?> \ No newline at end of file diff --git a/adm/sms_admin/ajax.hp_chk.php b/adm/sms_admin/ajax.hp_chk.php new file mode 100644 index 000000000..560257309 --- /dev/null +++ b/adm/sms_admin/ajax.hp_chk.php @@ -0,0 +1,48 @@ +encode($data) ); + } +} + +$err = ''; +$arr_ajax_msg = array(); +$exist_hplist = array(); + +if( !$bk_hp ) + $err = '휴대폰번호를 입력해 주십시오.'; + +$bk_hp = get_hp($bk_hp); + +$sql = " select count(*) as cnt from {$g5['sms5_book_table']} where bk_hp = '$bk_hp' "; +if($w == 'u' && $bk_no) + $sql .= " and bk_no <> '$bk_no' "; +$row = sql_fetch($sql); + +if($row['cnt']) + $err = '같은 번호가 존재합니다.'; + +// 수정일 때 회원정보에서 중복체크 +if(!$row['cnt'] && $w == 'u') { + $sql = " select mb_id from {$g5['member_table']} where mb_hp = '{$bk_hp}' and mb_hp <> '' "; + + if( $mb_id ) + $sql .= " and mb_id <> '{$mb_id}' "; + + $result = sql_query($sql); + + while($row = sql_fetch_array($result)){ + $exist_hplist[] = $row['mb_id']; + } +} + +$arr_ajax_msg['error'] = $err; +$arr_ajax_msg['exist'] = $exist_hplist; + +die( json_encode($arr_ajax_msg) ); + +?> \ No newline at end of file diff --git a/adm/sms_admin/ajax.sms_write_form.php b/adm/sms_admin/ajax.sms_write_form.php new file mode 100644 index 000000000..da3745c6b --- /dev/null +++ b/adm/sms_admin/ajax.sms_write_form.php @@ -0,0 +1,82 @@ +encode($data) ); + } +} + +$page_size = 6; + +auth_check($auth[$sub_menu], "r"); + +if (!$page) $page = 1; + +if (is_numeric($fg_no)) + $sql_group = " and fg_no='$fg_no' "; +else + $sql_group = ""; + +if ($st == 'all') { + $sql_search = "and (fo_name like '%{$sv}%' or fo_content like '%{$sv}%')"; +} else if ($st == 'name') { + $sql_search = "and fo_name like '%{$sv}%'"; +} else if ($st == 'content') { + $sql_search = "and fo_content like '%{$sv}%'"; +} else { + $sql_search = ''; +} + +$total_res = sql_fetch("select count(*) as cnt from {$g5['sms5_form_table']} where 1 $sql_group $sql_search"); +$total_count = $total_res['cnt']; + +$total_page = (int)($total_count/$page_size) + ($total_count%$page_size==0 ? 0 : 1); +$page_start = $page_size * ( $page - 1 ); + +$vnum = $total_count - (($page-1) * $page_size); + +$group = array(); +$qry = sql_query("select * from {$g5['sms5_form_group_table']} order by fg_name"); +while ($res = sql_fetch_array($qry)) array_push($group, $res); + +$res = sql_fetch("select count(*) as cnt from {$g5['sms5_form_table']} where fg_no=0"); +$no_count = $res['cnt']; + +$count = 1; +$qry = sql_query("select * from {$g5['sms5_form_table']} where 1 $sql_group $sql_search order by fo_no desc limit $page_start, $page_size"); +$list_text = ""; + +if( !$total_count ){ + $list_text .=" +
  • + 데이터가 없습니다. +
  • + "; +} +while($res = sql_fetch_array($qry)) +{ + $tmp = sql_fetch("select fg_name from {$g5['sms5_form_group_table']} where fg_no='{$res['fg_no']}'"); + if (!$tmp) + $group_name = '미분류'; + else + $group_name = $tmp['fg_name']; + $list_text .=" +
  • + + + + ".cut_str($res['fo_name'],20)." +
  • + "; +} + +$arr_ajax_msg['error'] = ""; +$arr_ajax_msg['list_text'] = $list_text; +$arr_ajax_msg['page'] = $page; +$arr_ajax_msg['total_count'] = $total_count; +$arr_ajax_msg['total_page'] = $total_page; +die( json_encode($arr_ajax_msg) ); +?> \ No newline at end of file diff --git a/adm/sms_admin/ajax.sms_write_group.php b/adm/sms_admin/ajax.sms_write_group.php new file mode 100644 index 000000000..3e64577e4 --- /dev/null +++ b/adm/sms_admin/ajax.sms_write_group.php @@ -0,0 +1,42 @@ +1 order by bg_name"); +while ($res = sql_fetch_array($qry)) array_push($group, $res); +?> +
    + + + + + + + + + + + + + + + + + + + + + + +
    그룹명수신가능추가
    +
    \ No newline at end of file diff --git a/adm/sms_admin/ajax.sms_write_level.php b/adm/sms_admin/ajax.sms_write_level.php new file mode 100644 index 000000000..593236d8e --- /dev/null +++ b/adm/sms_admin/ajax.sms_write_level.php @@ -0,0 +1,56 @@ +encode($data) ); + } +} + +auth_check($auth[$sub_menu], "r"); + +$lev = array(); + +for ($i=1; $i<=10; $i++) +{ + $lev[$i] = 0; +} + +$qry = sql_query("select mb_level, count(*) as cnt from {$g5['member_table']} where mb_sms=1 and not (mb_hp='') group by mb_level"); + +while ($row = sql_fetch_array($qry)) +{ + $lev[$row['mb_level']] = $row['cnt']; +} +$str_json = array(); +$tmp_str = ''; +$tmp_str .= ' +
    + + + + + + + + + '; + for ($i=1; $i<=10; $i++) { + $bg = 'bg'.($line++%2); + $tmp_str .= ' + + + + + '; + } +$tmp_str .= ' + +
    권한수신가능추가
    '.$i.' 레벨'.number_format($lev[$i]).'
    +
    '; + +$str_json['html'] = $tmp_str; +echo json_encode($str_json); +?> \ No newline at end of file diff --git a/adm/sms_admin/ajax.sms_write_person.php b/adm/sms_admin/ajax.sms_write_person.php new file mode 100644 index 000000000..38c8c0b55 --- /dev/null +++ b/adm/sms_admin/ajax.sms_write_person.php @@ -0,0 +1,165 @@ + 0) + $sql_korean = korean_index('bk_name', $ap-1); +else { + $sql_korean = ''; + $ap = 0; +} + +if ($no_hp == 'yes') { + set_cookie('cookie_no_hp', 'yes', 60*60*24*365); + $no_hp_checked = 'checked'; +} else if ($no_hp == 'no') { + set_cookie('cookie_no_hp', '', 0); + $no_hp_checked = ''; +} else { + if (get_cookie('cookie_no_hp') == 'yes') + $no_hp_checked = 'checked'; + else + $no_hp_checked = ''; +} + +//if ($no_hp_checked == 'checked') + $sql_no_hp = "and bk_hp <> '' and bk_receipt=1"; + +$total_res = sql_fetch("select count(*) as cnt from {$g5['sms5_book_table']} where 1 $sql_group $sql_search $sql_korean $sql_no_hp"); +$total_count = $total_res['cnt']; + +$total_page = (int)($total_count/$page_size) + ($total_count%$page_size==0 ? 0 : 1); +$page_start = $page_size * ( $page - 1 ); + +$vnum = $total_count - (($page-1) * $page_size); + +$res = sql_fetch("select count(*) as cnt from {$g5['sms5_book_table']} where bk_receipt=1 $sql_group $sql_search $sql_korean $sql_no_hp"); +$receipt_count = $res['cnt']; +$reject_count = $total_count - $receipt_count; + +$res = sql_fetch("select count(*) as cnt from {$g5['sms5_book_table']} where mb_id='' $sql_group $sql_search $sql_korean $sql_no_hp"); +$no_member_count = $res['cnt']; +$member_count = $total_count - $no_member_count; + +$no_group = sql_fetch("select * from {$g5['sms5_book_group_table']} where bg_no=1"); + +$group = array(); +$qry = sql_query("select * from {$g5['sms5_book_group_table']} where bg_no>1 order by bg_name"); +while ($res = sql_fetch_array($qry)) array_push($group, $res); +?> +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + 이름휴대폰번호등급추가
    데이터가 없습니다.
    + + +
    +
    + +
    + + +
    + + + + + + + + + + + + + + + + + +
    + + \ No newline at end of file diff --git a/adm/sms_admin/config.php b/adm/sms_admin/config.php new file mode 100644 index 000000000..d6a3cb87f --- /dev/null +++ b/adm/sms_admin/config.php @@ -0,0 +1,181 @@ + $res[0], // 결과코드 + 'coin' => $res[1], // 고객 잔액 (충전제만 해당) + 'gpay' => $res[2], // 고객의 건수 별 차감액 표시 (충전제만 해당) + 'payment' => $res[3] // 요금제 표시, A:충전제, C:정액제 + ); +} + +if (!$config['cf_icode_id']) + $config['cf_icode_id'] = 'sir_'; + +if (!$sms5['cf_skin']) + $sms5['cf_skin'] = 'basic'; + +include_once(G5_ADMIN_PATH.'/admin.head.php'); + +?> + +
    +

    + SMS 기능을 사용하시려면 먼저 아이코드에 서비스 신청을 하셔야 합니다.
    + 아이코드 서비스 신청하기 +

    +
    + + + +
    + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + +
    + + + 현재 비밀번호가 입력되어 있지 않습니다. +
    요금제 + '; + } else if ($userinfo['payment'] == 'C') { + echo '정액제'; + echo ''; + } else { + echo '가입해주세요.'; + echo ''; + } + ?> +
    충전 잔액 + 원 + +
    건별 금액
    + 예) 010-123-4567"); ?> + +
    + + > 허용 +
    + + + 레벨 이상 +
    + + +
    + + +
    + +
    +
    + +
    + +
    +
    + + + +
    +

    SMS 문자전송 서비스를 사용할 수 없습니다.

    +
    +

    + SMS 를 사용하지 않고 있기 때문에, 문자 전송을 할 수 없습니다.
    + SMS 사용 설정은 환경설정 > 기본환경설정 > SMS설정 에서 SMS 사용을 아이코드로 변경해 주셔야 사용하실수 있습니다. +

    +
    +
    + + + + \ No newline at end of file diff --git a/adm/sms_admin/config_update.php b/adm/sms_admin/config_update.php new file mode 100644 index 000000000..e224d904b --- /dev/null +++ b/adm/sms_admin/config_update.php @@ -0,0 +1,49 @@ + $res[0], // 결과코드 + 'coin' => $res[1], // 고객 잔액 (충전제만 해당) + 'gpay' => $res[2], // 고객의 건수 별 차감액 표시 (충전제만 해당) + 'payment' => $res[3] // 요금제 표시, A:충전제, C:정액제 +); + +if ($userinfo['code'] == '202') + alert('아이코드 아이디와 패스워드가 맞지 않습니다.'); + +if ($cf_member == 'on') + $cf_member = 1; +else + $cf_member = 0; + +$res = sql_fetch("select * from ".$g5['sms5_config_table']." limit 1"); + +if (!$res) + $sql = "insert into "; +else + $sql = "update "; + +$sql .= $g5['sms5_config_table']." set cf_phone='$cf_phone', cf_register='$cf_register', cf_member='$cf_member', cf_level='$cf_level', cf_point='$cf_point', cf_day_count='$cf_day_count', cf_skin = '$cf_skin' "; + +sql_query($sql); + +// 아이코드 설정 +$sql = " update {$g5['config_table']} + set cf_sms_use = '$cf_sms_use', + cf_icode_id = '$cf_icode_id', + cf_icode_pw = '$cf_icode_pw', + cf_icode_server_ip = '$cf_icode_server_ip', + cf_icode_server_port = '$cf_icode_server_port' "; +sql_query($sql); + +goto_url("./config.php"); +?> \ No newline at end of file diff --git a/adm/sms_admin/css/sms5.css b/adm/sms_admin/css/sms5.css new file mode 100644 index 000000000..3677b3f6a --- /dev/null +++ b/adm/sms_admin/css/sms5.css @@ -0,0 +1,133 @@ +@charset "utf-8"; +/* SIR 지운아빠 */ + +/* 공통 */ +.sms5_txt_success {color:blue} +.sms5_txt_fail {color:red} + +/* 회원정보업데이트 */ +#sms5_mbup dl {zoom:1} +#sms5_mbup dl:after {display:block;visibility:hidden;clear:both;content:''} +#sms5_mbup dt {clear:both;float:left;margin:0 0 5px;width:100px} +#sms5_mbup dd {float:left;margin:0 0 5px} +#sms5_mbup p {clear:both} + +/* SMS BOX */ +.sms5_box {position:relative;padding:10px;border-radius:5px;background:#fbec99} +.sms5_box .box_ico {position:absolute;top:20px;left:-7px;width:7px;height:13px;background:url('../img/box_ico.gif') no-repeat} +.sms5_box .box_txt {border:0;background:transparent;word-break:break-all;resize:none;overflow:hidden} +.sms5_box .box_square {width:100px;height:90px} + +#write_wrap {z-index:9} +#wr_message_lbl {position:absolute;top:50px;left:50px;color:#999;font-size:0.95em;letter-spacing:-0.1em} +.write_scemo_btn {position:absolute;right:10px !important;right:50px;margin:0;padding:0;width:28px;height:28px;border:0;background:transparent;color:#999;font-size:0.95em} +#write_sc_btn {top:15px} +#write_emo_btn {top:50px} +.write_scemo {display:none;z-index:10;position:absolute;left:150px;border:1px solid #e9e9e9;background:#f7f7f7} +.scemo_ico {position:absolute;top:10px;left:-7px;width:7px;height:13px;background:url('../img/scemo_ico.gif') no-repeat} +.write_scemo .scemo_list {z-index:11;margin:0;padding:0;width:190px;height:150px;background:#fff;overflow-y:scroll} +.write_scemo .scemo_add {margin:0;padding:0;height:25px;border:0;background:transparent} +#write_sc {top:10px} +#write_sc .scemo_add {width:25px} +#write_emo {top:45px} +#write_emo .scemo_add {width:50px} +#write_emo .emo_long {width:80px} +.write_scemo .scemo_cls {text-align:right} +.write_scemo .scemo_cls button {margin:5px;padding:0;border:0;background:transparent;color:#666;font-size:0.95em} + +/* 문자보내기 */ +#sms5_send {position:relative;margin:-10px 0 0 20px;padding:0 0 0 490px;height:600px} +#sms5_send h2 {font-size:1em} +#sms5_send ul {margin:0;padding:0;list-style:none;zoom:1} +#sms5_send ul:after {display:block;visibility:hidden;clear:both;content:''} +#sms5_send #send_emo {position:absolute;top:0;left:0;padding:20px 0 0;width:280px} +#sms5_send #send_emo h2 {padding:0 0 10px} +#sms5_send #send_write {position:absolute;top:0;left:290px;padding:20px 20px 0 !important;padding:20px 0 0 20px;width:160px;height:600px;border-left:1px solid #efefef} +#sms5_send #send_write h2 {padding:0 0 10px} +#sms5_send #send_book {position:relative;margin:0 0 0 -1px;padding:20px 0 0;width:100%;height:600px;border-left:1px solid #efefef} +#sms5_send #send_book h2 {padding-bottom:10px} + +#sms5_send .tmp_loading {display:block;padding:180px 0 0;text-align:center} +#sms5_send #send_emo #emo_sel {position:absolute;top:20px;right:10px;margin:0} +#sms5_send #send_emo li {float:left;margin:0 10px 10px 0 !important;margin:0 5px 10px 0;width:110px} +#sms5_send #send_emo .sms5_box {background:#f7f7f7} +#sms5_send #send_emo .box_ico {display:none} +#sms5_send #send_emo .box_txt {cursor:pointer} +#sms5_send #send_emo .emo_tit {display:block;height:20px;line-height:2em;overflow:hidden;text-overflow:ellipsis;white-space:nowrap} +#sms5_send #send_emo .btn_submit {padding:0 5px;height:24px;border:1px solid #ccc;background:#fafafa;color:#000;font-size:0.95em;vertical-align:middle;cursor:pointer} + +#sms5_send #send_write {z-index:3} +#sms5_send .write_inner {position:relative;left:-20px;padding:15px 20px;width:160px;border-top:1px solid #efefef} +#sms5_send .write_inner h2 {margin:0;padding:0 0 10px !important} +#sms5_send .write_floater {position:absolute;top:15px;right:20px;text-align:right} +#sms5_send .write_floater_btn {margin:0;padding:0;border:0;background:transparent;color:#999;font-size:0.95em;letter-spacing:-0.1em} +#sms5_send .write_inner label, #sms5_send .write_inner input {margin:0 0 3px} +#sms5_send .write_inner label {display:inline-block} +#sms5_send #send_write .sms5_box {margin:0 0 5px} +#sms5_send #sms_byte {position:absolute;top:-37px;right:0;color:#999} +#sms5_send #write_preset {margin:10px 0;color:#999;font-size:0.95em;letter-spacing:-0.1em} +#sms5_send #write_reply {margin:0 0 15px} +#sms5_send #hp_list {width:100%;margin:0 0 5px} +#sms5_send #recv_add {position:relative} +#sms5_send #recv_add button {position:absolute;top:0;right:0 !important;right:20px;margin:0;padding:0;width:45px;height:51px;border:1px solid #ccc;background:#fafafa} +#sms5_send #write_rsv {line-height:1.8em} + +#sms5_send #send_book {z-index:2} +#sms5_send #num_book {margin:0 0 10px;width:auto !important;width:95%;height:500px;overflow-y:auto !important;overflow-y:scroll} +#sms5_send #book_tab {margin:0 35px 10px;text-align:right} +#sms5_send #book_tab a {display:inline-block;width:30px;text-align:center} +#sms5_send #sms_person_form {margin:0 20px} +#sms5_send #send_book .btn_submit {padding:0 5px;height:24px} +#sms5_send #book_desc {margin:0 20px;color:#999;font-size:0.95em;letter-spacing:-0.1em} + +/* 문자전송상세내역 */ +#sms5_sent {} +#sms5_sent #sent_overlap {margin:0 20px 20px;padding:0;border-top:1px solid #e9e9e9;list-style:none} +#sms5_sent #sent_overlap li {padding:10px 0;border-bottom:1px solid #e9e9e9} +#sms5_sent #con_sms {margin:0 20px 20px} + +/* 이모티콘 관리 */ +.sms_preset_sch form {display:inline-block} +#sms5_preset_sel {float:left;padding:8px 20px 0} +.btn_add {float:right} +#sms5_preset {clear:both;margin:0 0 10px;padding:30px 20px 20px 40px;background:#363a3d;list-style:none;zoom:1} +#sms5_preset:after {display:block;visibility:hidden;clear:both;content:''} +#sms5_preset li {float:left;margin:0 20px 20px 0;width:270px;height:125px;background:#fbec99;zoom:1} +#sms5_preset li:after {display:block;visibility:hidden;clear:both;content:''} +#sms5_preset .li_chk {position:absolute;bottom:10px;left:10px;} +#sms5_preset .li_preview {float:left;width:110px} +#sms5_preset .box_square {padding-right:7px;border-right:1px solid #e2d693} +#sms5_preset .li_info {float:left;margin:0 0 0 10px;width:150px;line-height:1.5em} +#sms5_preset .li_date {position:absolute;bottom:10px;left:30px;color:#86857d} +#sms5_preset .li_cmd {position:absolute;bottom:10px;right:10px} +#sms5_preset .li_cmd a {color:#86857d;font-size:0.95em;letter-spacing:-0.1em} + +#sms5_emo_add {position:relative} +#sms5_emo_add .sms5_box {padding:10px !important;padding:10px 5px;width:160px} +#sms5_emo_add .box_txt {margin:0 0 5px} +#sms5_emo_add .write_scemo_btn {right:10px} +#sms5_emo_add .write_scemo {left:170px} + +/* 휴대폰번호 관리 */ +#hp_check_el {width:148px} +#hp_check_el ul {margin:5px 0 0;padding:0;border:1px solid #f7c3cf;background:#f8e8eb;list-style:none} +#hp_check_el li {position:relative;padding:5px;border-bottom:1px solid #f6dae1} +#hp_check_el strong {position:absolute;top:6px;right:5px;color:#ff3061;font-size:0.95em;font-weight:normal;letter-spacing:-0.1em} + +/* 휴대폰번호 파일 */ +#sms5_fileup_frm {margin:0 0 10px;padding:0 20px 5px;border-bottom:1px solid #e9e9e9} +#sms5_fileup_frm div {padding:0 0 5px;margin:0 0 5px;border-bottom:1px solid #f4f4f4} +#sms5_fileup_frm div.sch_last {margin:0;border:0} +#sms5_fileup_frm strong {display:inline-block;width:80px} +#sms5_fileup_frm strong.sch_long {width:160px} +#sms5_fileup_frm label {display:inline-block;margin:0 5px 0 0} +#sms5_fileup_frm .btn_submit {padding:0 5px;height:24px} + +#sms5_fileup_frm #sms5_fileup {border:0} +#sms5_fileup_frm #upload_info {margin:20px 0} +#sms5_fileup_frm #upload_result {margin:0;padding:10px 0;border-top:3px solid #383838;border-bottom:3px solid #383838;list-style:none} +#sms5_fileup_frm #upload_result li {margin:0 0 5px} +#sms5_fileup_frm #upload_result .local_desc01 {margin:5px 0;padding:10px} +#sms5_fileup_frm #btn_fileup {margin:5px 0 0} + +#sms5_fileup_frm .sms_fileup_hide {display:none;border:0} diff --git a/adm/sms_admin/emoticon_move.php b/adm/sms_admin/emoticon_move.php new file mode 100644 index 000000000..592e273ce --- /dev/null +++ b/adm/sms_admin/emoticon_move.php @@ -0,0 +1,114 @@ + + +
    +

    + +
    + + + + +
    + + + + + + + + + + + + + + + + +
    이동할 그룹을 한개 이상 선택하여 주십시오.
    선택그룹
    + + + +
    +
    + +
    + + +
    +
    + +
    + + + + diff --git a/adm/sms_admin/emoticon_move_update.php b/adm/sms_admin/emoticon_move_update.php new file mode 100644 index 000000000..aa1227f6a --- /dev/null +++ b/adm/sms_admin/emoticon_move_update.php @@ -0,0 +1,60 @@ + + + +HEREDOC; +?> \ No newline at end of file diff --git a/adm/sms_admin/form_group.php b/adm/sms_admin/form_group.php new file mode 100644 index 000000000..4b713d3d0 --- /dev/null +++ b/adm/sms_admin/form_group.php @@ -0,0 +1,177 @@ + + + + +
    + +
    + + + +
    +
    + 건수 : +
    +
    + +
    +

    그룹명순으로 정렬됩니다.

    +
    + +
    + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    목록
    + + + 그룹명이모티콘수이동보기
    미분류 + + + + 보기 + +
    + + + + + + + > + + + + + + + + 보기 +
    + +
    + +
    + + + +
    + +
    + + \ No newline at end of file diff --git a/adm/sms_admin/form_group_move.php b/adm/sms_admin/form_group_move.php new file mode 100644 index 000000000..27faa14d1 --- /dev/null +++ b/adm/sms_admin/form_group_move.php @@ -0,0 +1,30 @@ + \ No newline at end of file diff --git a/adm/sms_admin/form_group_update.php b/adm/sms_admin/form_group_update.php new file mode 100644 index 000000000..058980a11 --- /dev/null +++ b/adm/sms_admin/form_group_update.php @@ -0,0 +1,92 @@ +'$fg_no' and fg_name='$fg_name'"); + if ($res) + alert('같은 그룹명이 존재합니다.'); + + sql_query("update {$g5['sms5_form_group_table']} set fg_name='$fg_name', fg_member='$fg_member' where fg_no='$fg_no'"); + sql_query("update {$g5['sms5_form_table']} set fg_member = '$fg_member' where fg_no = '$fg_no'"); + } +} +else if ($w == 'de') // 그룹삭제 +{ + for ($i=0; $i \ No newline at end of file diff --git a/adm/sms_admin/form_list.php b/adm/sms_admin/form_list.php new file mode 100644 index 000000000..4e6cae1f5 --- /dev/null +++ b/adm/sms_admin/form_list.php @@ -0,0 +1,238 @@ + + + + +
    + 건수 : +
    + +
    +
    + + +
    + +
    + + + + + + +
    +
    + +
    + + +
    + +
    + 이모티콘 추가 +
    + +
    + + + + + + +
    + + +
    + +
    + + + + + \ No newline at end of file diff --git a/adm/sms_admin/form_multi_update.php b/adm/sms_admin/form_multi_update.php new file mode 100644 index 000000000..5c1bd5930 --- /dev/null +++ b/adm/sms_admin/form_multi_update.php @@ -0,0 +1,27 @@ +'$fo_no' and fo_content='$fo_content'"); + if ($res) + alert('같은 이모티콘이 존재합니다.'); +*/ + $res = sql_fetch("select * from {$g5['sms5_form_table']} where fo_no='$fo_no'"); + if (!$res) + alert('존재하지 않는 데이터 입니다.'); + + if ($fg_no != $res['fg_no']) { + if ($res['fg_no']) + sql_query("update {$g5['sms5_form_group_table']} set fg_count = fg_count - 1 where fg_no='{$res[fg_no]}'"); + + sql_query("update {$g5['sms5_form_group_table']} set fg_count = fg_count + 1 where fg_no='$fg_no'"); + } + + $group = sql_fetch("select * from {$g5['sms5_form_group_table']} where fg_no = '$fg_no'"); + + sql_query("update {$g5['sms5_form_table']} set fg_no='$fg_no', fg_member='{$group['fg_member']}', fo_name='$fo_name', fo_content='$fo_content', fo_datetime='".G5_TIME_YMDHIS."' where fo_no='$fo_no'"); +} +else if ($w == 'd') // 삭제 +{ + if (!is_numeric($fo_no)) + alert('고유번호가 없습니다.'); + + $res = sql_fetch("select * from {$g5['sms5_form_table']} where fo_no='$fo_no'"); + if (!$res) + alert('존재하지 않는 데이터 입니다.'); + + sql_query("delete from {$g5['sms5_form_table']} where fo_no='$fo_no'"); + sql_query("update {$g5['sms5_form_group_table']} set fg_count = fg_count - 1 where fg_no = '{$res['fg_no']}'"); + + $get_fg_no = $fg_no; +} +else // 등록 +{ + if (!$fg_no) $fg_no = 0; + + if (!strlen(trim($fo_name))) + alert('이름을 입력해주세요'); + + if (!strlen(trim($fo_content))) + alert('이모티콘을 입력해주세요'); + + $res = sql_fetch("select * from {$g5['sms5_form_table']} where fo_content='$fo_content'"); + if ($res) + alert('같은 이모티콘이 존재합니다.'); + + $group = sql_fetch("select * from {$g5['sms5_form_group_table']} where fg_no = '$fg_no'"); + + sql_query("insert into {$g5['sms5_form_table']} set fg_no='$fg_no', fg_member='{$group['fg_member']}', fo_name='$fo_name', fo_content='$fo_content', fo_datetime='".G5_TIME_YMDHIS."'"); + sql_query("update {$g5['sms5_form_group_table']} set fg_count = fg_count + 1 where fg_no = '$fg_no'"); + + $get_fg_no = $fg_no; +} + +$go_url = './form_list.php?page='.$page.'&fg_no='.$get_fg_no; +goto_url($go_url); +?> \ No newline at end of file diff --git a/adm/sms_admin/form_write.php b/adm/sms_admin/form_write.php new file mode 100644 index 000000000..b5e5a9829 --- /dev/null +++ b/adm/sms_admin/form_write.php @@ -0,0 +1,233 @@ + + +
    + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + +
    목록
    + +
    메세지 +
    + + + + +
    0 / 80 byte
    + + +
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    +
    + +
    + +
    + + + + + + + + + + + + + + + + +
    +
    +
    +
    + +
    업데이트
    +
    +
    + + 목록 +
    +
    + + + + + + \ No newline at end of file diff --git a/adm/sms_admin/history_list.php b/adm/sms_admin/history_list.php new file mode 100644 index 000000000..82b6d8326 --- /dev/null +++ b/adm/sms_admin/history_list.php @@ -0,0 +1,100 @@ + + +
    class="local_sch01 local_sch" method="get"> + + + + + + + +
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    목록
    번호메세지회신번호전송일시예약총건수성공실패중복재전송관리
    + 데이터가 없습니다. +
    예약":'';?> + 수정 + +
    +
    + + + + \ No newline at end of file diff --git a/adm/sms_admin/history_member.php b/adm/sms_admin/history_member.php new file mode 100644 index 000000000..35873dcf8 --- /dev/null +++ b/adm/sms_admin/history_member.php @@ -0,0 +1,90 @@ + + +
    + + + + + +
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    목록
    번호회원보내는번호받는번호전송일시예약Log
    + 데이터가 없습니다. +
    예약":'';?>
    +
    + + + + \ No newline at end of file diff --git a/adm/sms_admin/history_num.php b/adm/sms_admin/history_num.php new file mode 100644 index 000000000..519f88b99 --- /dev/null +++ b/adm/sms_admin/history_num.php @@ -0,0 +1,108 @@ + + +
    + + + + + +
    + +
    + + + + + + + + + + + + + + + + + + + + + + {$res['mb_id']}"; + else + $mb_id = '비회원'; + ?> + + + + + + + + + + + + + + +
    목록
    번호그룹이름회원ID전화번호전송일시예약전송메세지관리
    + 데이터가 없습니다. +
    예약":'';?> + 수정 + +
    +
    + + + + \ No newline at end of file diff --git a/adm/sms_admin/history_send.php b/adm/sms_admin/history_send.php new file mode 100644 index 000000000..fe961494d --- /dev/null +++ b/adm/sms_admin/history_send.php @@ -0,0 +1,138 @@ + + + SMS_con($config['cf_icode_server_ip'], $config['cf_icode_id'], $config['cf_icode_pw'], $config['cf_icode_server_port']); + +$reply = str_replace('-', '', trim($write['wr_reply'])); + +$result = $SMS->Add($list, $reply, '', '', $write['wr_message'], '', $wr_total); + +if ($result) +{ + $result = $SMS->Send(); + + if ($result) //SMS 서버에 접속했습니다. + { + sql_query("insert into {$g5['sms5_write_table']} set wr_no='$wr_no', wr_renum='$new_wr_renum', wr_reply='{$write['wr_reply']}', wr_message='{$write['wr_message']}', wr_total='$wr_total', wr_datetime='".G5_TIME_YMDHIS."'"); + + $wr_success = 0; + $wr_failure = 0; + $count = 0; + + foreach ($SMS->Result as $result) + { + list($phone, $code) = explode(":", $result); + + if (substr($code,0,5) == "Error") + { + $hs_code = substr($code,6,2); + + switch ($hs_code) { + case '02': // "02:형식오류" + $hs_memo = "형식이 잘못되어 전송이 실패하였습니다."; + break; + case '23': // "23:인증실패,데이터오류,전송날짜오류" + $hs_memo = "데이터를 다시 확인해 주시기바랍니다."; + break; + case '97': // "97:잔여코인부족" + $hs_memo = "잔여코인이 부족합니다."; + break; + case '98': // "98:사용기간만료" + $hs_memo = "사용기간이 만료되었습니다."; + break; + case '99': // "99:인증실패" + $hs_memo = "인증 받지 못하였습니다. 계정을 다시 확인해 주세요."; + break; + default: // "미 확인 오류" + $hs_memo = "알 수 없는 오류로 전송이 실패하었습니다."; + break; + } + $wr_failure++; + $hs_flag = 0; + } + else + { + $hs_code = $code; + $hs_memo = get_hp($phone, 1)."로 전송했습니다."; + $wr_success++; + $hs_flag = 1; + } + + $row = array_shift($list); + $row['bk_hp'] = get_hp($row['bk_hp'], 1); + + $log = array_shift($SMS->Log); + sql_query("insert into {$g5['sms5_history_table']} set wr_no='$wr_no', wr_renum='$new_wr_renum', bg_no='{$row['bg_no']}', mb_id='{$row['mb_id']}', bk_no='{$row['bk_no']}', hs_name='{$row['hs_name']}', hs_hp='{$row['hs_hp']}', hs_datetime='".G5_TIME_YMDHIS."', hs_flag='$hs_flag', hs_code='$hs_code', hs_memo='$hs_memo', hs_log='$log'"); + } + $SMS->Init(); // 보관하고 있던 결과값을 지웁니다. + + sql_query("update {$g5['sms5_write_table']} set wr_success='$wr_success', wr_failure='$wr_failure' where wr_no='$wr_no' and wr_renum='$new_wr_renum'"); + sql_query("update {$g5['sms5_write_table']} set wr_re_total=wr_re_total+1 where wr_no='$wr_no' and wr_renum=0"); + } + else alert("에러: SMS 서버와 통신이 불안정합니다."); +} +else alert("에러: SMS 데이터 입력도중 에러가 발생하였습니다."); + +?> + + \ No newline at end of file diff --git a/adm/sms_admin/history_view.php b/adm/sms_admin/history_view.php new file mode 100644 index 000000000..6e29571da --- /dev/null +++ b/adm/sms_admin/history_view.php @@ -0,0 +1,246 @@ +(재전송)"; +} else + $sql_renum = " and wr_renum='0'"; + +$total_res = sql_fetch("select count(*) as cnt from {$g5['sms5_history_table']} where wr_no='$wr_no' $sql_search $sql_renum"); +$total_count = $total_res['cnt']; + +$total_spage = (int)($total_count/$spage_size) + ($total_count%$spage_size==0 ? 0 : 1); +$spage_start = $spage_size * ( $spage - 1 ); + +$vnum = $total_count - (($spage-1) * $spage_size); + +$write = sql_fetch("select * from {$g5['sms5_write_table']} where wr_no='$wr_no' $sql_renum"); +if ($write['wr_booking'] == '0000-00-00 00:00:00') + $write['wr_booking'] = '즉시전송'; + +include_once(G5_ADMIN_PATH.'/admin.head.php'); +?> + + + +
    + + + + + + + + + + +
    + +
    +
    + 전송건수 + 성공건수 + 실패건수 + 전송일시 + 예약일시 + 회신번호 +
    + +

    전송내용

    + +
    + + +
    + + +

    전송실패 문자 재전송 내역

    + + + + + + + + + + + + + + + + 0"); + $re_vnum = $res['cnt']; + + $qry = sql_query("select * from {$g5['sms5_write_table']} where wr_no='$wr_no' and wr_renum>0 order by wr_renum desc"); + while($res = sql_fetch_array($qry)) { + ?> + + + + + + + + + + + + + +
    번호전송일시총건수성공실패관리
    + 수정 + +
    + + + +

    중복번호

    + + + +

    문자전송 목록

    + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    번호그룹이름회원ID휴대폰번호전송일시결과비고내역
    + 데이터가 없습니다. +
    + 결과코드 :
    + 로그 :
    + 메모 : +
    + + 내역 + + 내역 + +
    +
    +
    + + + + \ No newline at end of file diff --git a/adm/sms_admin/img/ajax-loader.gif b/adm/sms_admin/img/ajax-loader.gif new file mode 100644 index 000000000..96fefbc51 Binary files /dev/null and b/adm/sms_admin/img/ajax-loader.gif differ diff --git a/adm/sms_admin/img/ajax-loader2.gif b/adm/sms_admin/img/ajax-loader2.gif new file mode 100644 index 000000000..fd1a189c2 Binary files /dev/null and b/adm/sms_admin/img/ajax-loader2.gif differ diff --git a/adm/sms_admin/img/box_ico.gif b/adm/sms_admin/img/box_ico.gif new file mode 100644 index 000000000..9d57d3668 Binary files /dev/null and b/adm/sms_admin/img/box_ico.gif differ diff --git a/adm/sms_admin/img/scemo_ico.gif b/adm/sms_admin/img/scemo_ico.gif new file mode 100644 index 000000000..625048e49 Binary files /dev/null and b/adm/sms_admin/img/scemo_ico.gif differ diff --git a/adm/sms_admin/install.php b/adm/sms_admin/install.php new file mode 100644 index 000000000..e420dd7c4 --- /dev/null +++ b/adm/sms_admin/install.php @@ -0,0 +1,87 @@ + +
    + +
    + + var answer = confirm("이미 sms5가 설치되어 있습니다.새로 설치 할 경우 db 자료가 망실됩니다. 새로 설치하시겠습니까?"); + if (answer){ + document.hidden_form.setup.value = "1"; + document.hidden_form.submit(); + } else { + history.back(); + } + + '; + exit; + } +} +?> + +
    +

    SMS5 설치가 시작되었습니다.

    +
      +
    1. 전체 테이블 생성중
    2. + +
    3. DB설정 중
    4. + +
    5. +
    + +

    + +
    +document.getElementById('sms5_job_01').innerHTML='전체 테이블 생성 완료';"; +flush(); usleep(50000); + +$read_point = -1; +$write_point = 5; +$comment_point = 1; +$download_point = -20; + +//------------------------------------------------------------------------------------------------- +// config 테이블 설정 +$sql = " insert into {$g5['sms5_book_group_table']} set bg_name='미분류'"; +mysql_query($sql) or die(mysql_error() . "

    " . $sql); + +echo ""; +flush(); usleep(50000); +//------------------------------------------------------------------------------------------------- + +echo ""; +flush(); usleep(50000); +?> + + + + + \ No newline at end of file diff --git a/adm/sms_admin/member_update.php b/adm/sms_admin/member_update.php new file mode 100644 index 000000000..b0b20bd3f --- /dev/null +++ b/adm/sms_admin/member_update.php @@ -0,0 +1,63 @@ + + +

    +
    +
    +

    + 새로운 회원정보로 업데이트 합니다.
    + 실행 후 '완료' 메세지가 나오기 전에 프로그램의 실행을 중지하지 마십시오. +

    +
    +
    +

    + 마지막 업데이트 일시 :
    +

    +
    + +
    +
    + +
    + +
    +
    +
    + + + + \ No newline at end of file diff --git a/adm/sms_admin/member_update_run.php b/adm/sms_admin/member_update_run.php new file mode 100644 index 000000000..1dba4cbf7 --- /dev/null +++ b/adm/sms_admin/member_update_run.php @@ -0,0 +1,118 @@ +encode($data) ); + } +} + +auth_check($auth[$sub_menu], "w"); + +$count = 0; +$hp_yes = 0; +$hp_no = 0; +$hp_empty = 0; +$leave = 0; +$receipt = 0; + +// 회원 데이터 마이그레이션 +$qry = sql_query("select mb_id, mb_name, mb_hp, mb_sms, mb_leave_date from ".$g5['member_table']." order by mb_datetime"); +while ($res = sql_fetch_array($qry)) +{ + if ($res['mb_leave_date'] != '') + $leave++; + else if ($res['mb_hp'] == '') + $hp_empty++; + else if (is_hp($res['mb_hp'])) + $hp_yes++ ; + else + $hp_no++; + + $hp = get_hp($res['mb_hp']); + + if ($hp == '') $bk_receipt = 0; else $bk_receipt = $res['mb_sms']; + + $field = "mb_id='{$res['mb_id']}', bk_name='{$res['mb_name']}', bk_hp='{$hp}', bk_receipt='{$bk_receipt}', bk_datetime='".G5_TIME_YMDHIS."'"; + + $res2 = sql_fetch("select * from {$g5['sms5_book_table']} where mb_id='{$res['mb_id']}'"); + if ($res2) // 기존에 등록되어 있을 경우 업데이트 + { + $res3 = sql_fetch("select count(*) as cnt from {$g5['sms5_book_table']} where mb_id='{$res2['mb_id']}'"); + $mb_count = $res3['cnt']; + + // 회원이 삭제되었다면 휴대폰번호 DB 에서도 삭제한다. + if ($res['mb_leave_date']) + { + sql_query("delete from {$g5['sms5_book_table']} where mb_id='{$res2['mb_id']}'"); + + $sql = "update {$g5['sms5_book_group_table']} set bg_count = bg_count - $mb_count, bg_member = bg_member - $mb_count"; + if ($res2['bk_receipt'] == 1) + $sql .= ", bg_receipt = bg_receipt - $mb_count"; + else + $sql .= ", bg_reject = bg_reject - $mb_count"; + $sql .= " where bg_no='{$res2['bg_no']}'"; + + sql_query($sql); + } + else + { + if ($bk_receipt != $res2['bk_receipt']) { + if ($bk_receipt == 1) + $sql_sms = "bg_receipt = bg_receipt + $mb_count, bg_reject = bg_reject - $mb_count"; + else + $sql_sms = "bg_receipt = bg_receipt - $mb_count, bg_reject = bg_reject + $mb_count"; + + sql_query("update {$g5['sms5_book_group_table']} set $sql_sms where bg_no='{$res2['bg_no']}'"); + } + + if ($bk_receipt) $receipt++; + + sql_query("update {$g5['sms5_book_table']} set $field where mb_id='$res[mb_id]'"); + } + } + else if ($res['mb_leave_date'] == '') // 기존에 등록되어 있지 않을 경우 추가 (삭제된 회원이 아닐 경우) + { + if ($bk_receipt == 1) { + $sql_sms = "bg_receipt = bg_receipt + 1"; + $receipt++; + } else { + $sql_sms = "bg_reject = bg_reject + 1"; + } + + sql_query("insert into {$g5['sms5_book_table']} set $field, bg_no=1"); + sql_query("update {$g5['sms5_book_group_table']} set bg_count = bg_count + 1, bg_member = bg_member + 1, $sql_sms where bg_no=1"); + } + + $count++; +} + +sql_query("update {$g5['sms5_config_table']} set cf_datetime='".G5_TIME_YMDHIS."'"); + +$msg = ''; + +$msg .= '

    회원정보를 휴대폰번호 DB로 업데이트 하였습니다.

    '; +$msg .= '
    '; +$msg .= '
    총 회원 수
    '.number_format($count).'명
    '; +$msg .= '
    삭제된 회원
    '.number_format($leave).'명
    '; +$msg .= '
    휴대폰번호 없음
    '.number_format($hp_empty).' 명
    '; +$msg .= '
    휴대폰번호 정상
    '.number_format($hp_yes).' 명 '; +$msg .= '(수신'.number_format($receipt).' 명'; +$msg .= ' / '; +$msg .= '거부'.number_format($hp_yes-$receipt).' 명)
    '; +$msg .= '
    휴대폰번호 오류
    '.number_format($hp_no).' 명
    '; +$msg .= '
    '; +$msg .= '

    프로그램의 실행을 끝마치셔도 좋습니다.

    '; + +if( $mtype == "json" ){ + $json_msg = array(); + $json_msg['datetime'] = G5_TIME_YMDHIS; + $json_msg['res_msg'] = $msg; + die( json_encode($json_msg) ); +} else { + die( $msg ); +} +?> \ No newline at end of file diff --git a/adm/sms_admin/num_book.php b/adm/sms_admin/num_book.php new file mode 100644 index 000000000..8c6e2ee4e --- /dev/null +++ b/adm/sms_admin/num_book.php @@ -0,0 +1,263 @@ + 0) + $sql_korean = korean_index('bk_name', $ap-1); +else { + $sql_korean = ''; + $ap = 0; +} + +if ($no_hp == 'yes') { + set_cookie('cookie_no_hp', 'yes', 60*60*24*365); + $no_hp_checked = 'checked'; +} else if ($no_hp == 'no') { + set_cookie('cookie_no_hp', '', 0); + $no_hp_checked = ''; +} else { + if (get_cookie('cookie_no_hp') == 'yes') + $no_hp_checked = 'checked'; + else + $no_hp_checked = ''; +} + +if ($no_hp_checked == 'checked') + $sql_no_hp = "and bk_hp <> ''"; + +$total_res = sql_fetch("select count(*) as cnt from {$g5['sms5_book_table']} where 1 $sql_group $sql_search $sql_korean $sql_no_hp"); +$total_count = $total_res[cnt]; + +$total_page = (int)($total_count/$page_size) + ($total_count%$page_size==0 ? 0 : 1); +$page_start = $page_size * ( $page - 1 ); + +$vnum = $total_count - (($page-1) * $page_size); + +$res = sql_fetch("select count(*) as cnt from {$g5['sms5_book_table']} where bk_receipt=1 $sql_group $sql_search $sql_korean $sql_no_hp"); +$receipt_count = $res['cnt']; +$reject_count = $total_count - $receipt_count; + +$res = sql_fetch("select count(*) as cnt from {$g5['sms5_book_table']} where mb_id='' $sql_group $sql_search $sql_korean $sql_no_hp"); +$no_member_count = $res['cnt']; +$member_count = $total_count - $no_member_count; + +$no_group = sql_fetch("select * from {$g5['sms5_book_group_table']} where bg_no = 1"); + +$group = array(); +$qry = sql_query("select * from {$g5['sms5_book_group_table']} where bg_no>1 order by bg_name"); +while ($res = sql_fetch_array($qry)) array_push($group, $res); + +include_once(G5_ADMIN_PATH.'/admin.head.php'); +?> + + + +
    + 회원정보 최근 업데이트 + 총 건수 + 회원 + 비회원 + 수신 + 거부 +
    + +
    + + + + + + +
    + +
    + + + onclick="no_hp_click(this.checked)"> + +
    + +
    + 번호추가 +
    + +
    + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    목록
    + + + 번호그룹이름휴대폰수신아이디업데이트관리
    데이터가 없습니다.
    + + + 수신' : '거부'?> + 수정 + 보내기 + 내역 +
    +
    + +
    + + + + + +
    +
    + + + + + \ No newline at end of file diff --git a/adm/sms_admin/num_book_file.php b/adm/sms_admin/num_book_file.php new file mode 100644 index 000000000..602a3b4f2 --- /dev/null +++ b/adm/sms_admin/num_book_file.php @@ -0,0 +1,158 @@ + 1 order by bg_name"); +while ($res = sql_fetch_array($qry)) array_push($group, $res); + +include_once(G5_ADMIN_PATH.'/admin.head.php'); +?> + +

    파일 업로드

    +
    +

    + 엑셀에 저장된 휴대폰번호 목록을 데이터베이스에 저장할 수 있습니다. +

    + +

    + 엑셀에는 이름과 휴대폰번호 두개만 저장해주세요. 첫번째 라인부터 저장됩니다.
    + ※ 휴대폰번호에 하이픈(-)은 포함되어도 되고 포함되지 않아도 됩니다. +

    + +

    + 엑셀파일은 XLS( Excel 97 - 2003 통합 문서 ) 또는 CSV형식만 업로드 할수 있습니다. (xlsx 불가)
    + CSV 저장방법 : 파일 > 다른 이름으로 저장 > 파일형식 : CSV (쉼표로 분리) (*.CSV) +

    + +

    + 이 작업을 실행하기 전에 회원정보업데이트를 먼저 실행해주세요. +

    +
    + +
    +
    + + +
    + +
    + + + + + + + 파일을 업로드 중입니다. 잠시만 기다려주세요. + + +
    +
    + 휴대폰번호를 DB에 저장중 입니다. 잠시만 기다려주세요. +
    +
    +
    + +

    파일 다운로드

    +
    +

    + 저장된 휴대폰번호 목록을 엑셀(xls) 파일로 다운로드 할 수 있습니다.
    + 다운로드 할 휴대폰번호 그룹을 선택해주세요. +

    +
    + +
    +

    + +
    + + +

    + + + + +
    + + + \ No newline at end of file diff --git a/adm/sms_admin/num_book_file_download.php b/adm/sms_admin/num_book_file_download.php new file mode 100644 index 000000000..65c1bdaa1 --- /dev/null +++ b/adm/sms_admin/num_book_file_download.php @@ -0,0 +1,67 @@ +''"; + +$sql = "select count(*) as cnt from {$g5['sms5_book_table']} where 1 $sql_bg $sql_hp order by bk_name"; +$total = sql_fetch($sql); + +if (!$total['cnt']) alert_just('데이터가 없습니다.'); + +$qry = sql_query("select * from {$g5['sms5_book_table']} where 1 $sql_bg $sql_hp order by bk_name"); + +/*================================================================================ +php_writeexcel http://www.bettina-attack.de/jonny/view.php/projects/php_writeexcel/ +=================================================================================*/ + +include_once(G5_LIB_PATH.'/Excel/php_writeexcel/class.writeexcel_workbook.inc.php'); +include_once(G5_LIB_PATH.'/Excel/php_writeexcel/class.writeexcel_worksheet.inc.php'); + +$fname = tempnam(G5_DATA_PATH, "tmp.xls"); +$workbook = new writeexcel_workbook($fname); +$worksheet = $workbook->addworksheet(); + +$num2_format =& $workbook->addformat(array(num_format => '\0#')); + +// Put Excel data +$data = array('이름', '전화번호'); +$data = array_map('iconv_euckr', $data); + +$col = 0; +foreach($data as $cell) { + $worksheet->write(0, $col++, $cell); +} + +for($i=1; $res=sql_fetch_array($qry); $i++) +{ + $res = array_map('iconv_euckr', $res); + + $hp = get_hp($res['bk_hp'], $hyphen); + + if ($no_hp && $res['bk_hp'] != '' && !$hp) continue; + + $worksheet->write($i, 0, $res['bk_name']); + $worksheet->write($i, 1, $hp, $num2_format); +} + +$workbook->close(); + +$filename = "휴대폰번호목록-".date("ymd", time()).".xls"; +if( is_ie() ) $filename = utf2euc($filename); + +header("Content-Type: application/x-msexcel; name=".$filename); +header("Content-Disposition: inline; filename=".$filename); +$fh=fopen($fname, "rb"); +fpassthru($fh); +unlink($fname); + +exit; +?> \ No newline at end of file diff --git a/adm/sms_admin/num_book_file_upload.php b/adm/sms_admin/num_book_file_upload.php new file mode 100644 index 000000000..f4596be41 --- /dev/null +++ b/adm/sms_admin/num_book_file_upload.php @@ -0,0 +1,166 @@ +setOutputEncoding('UTF-8'); + $data->read($file); + $num_rows = $data->sheets[0]['numRows']; + break; + default : + alert_after('xls파일과 csv파일만 허용합니다.'); +} + +$counter = 0; +$success = 0; +$failure = 0; +$inner_overlap = 0; +$overlap = 0; +$arr_hp = array(); +$encode = array('ASCII','UTF-8','EUC-KR'); + +for ($i = 1; $i <= $num_rows; $i++) { + $counter++; + $j = 1; + + switch ($ext) { + case '.csv' : + $name = $csv[$i][0]; + $str_encode = @mb_detect_encoding($name, $encode); + if( $str_encode == "EUC-KR" ){ + $name = iconv_utf8( $name ); + } + $name = addslashes($name); + $hp = addslashes($csv[$i][1]); + break; + case '.xls' : + $name = addslashes($data->sheets[0]['cells'][$i][$j++]); + $str_encode = @mb_detect_encoding($name, $encode); + if( $str_encode == "EUC-KR" ){ + $name = iconv_utf8( $name ); + } + $hp = addslashes(get_hp($data->sheets[0]['cells'][$i][$j++])); + break; + } + if (!(strlen($name)&&$hp)) + { + $failure++; + + } else { + if (in_array($hp, $arr_hp)) + { + $inner_overlap++; + } else { + + array_push($arr_hp, $hp); + + $res = sql_fetch("select * from {$g5['sms5_book_table']} where bk_hp='$hp'"); + if ($res) + { + $overlap++; + } + else if (!$confirm && $hp) + { + sql_query("insert into {$g5['sms5_book_table']} set bg_no='$bg_no', bk_name='$name', bk_hp='$hp', bk_receipt=1, bk_datetime='".G5_TIME_YMDHIS."'"); + sql_query("update {$g5['sms5_book_group_table']} set bg_count = bg_count + 1, bg_nomember = bg_nomember + 1, bg_receipt = bg_receipt + 1 where bg_no='$bg_no'"); + $success++; + } + } + } + if ($inner_overlap > 0) $overlap += $inner_overlap; +} + +unlink($_FILES['csv']['tmp_name']); + +if ($success){ + $sql = "select count(*) as cnt from {$g5['sms5_book_table']} where bg_no='$bg_no'"; + $total = sql_fetch($sql); + sql_query("update {$g5['sms5_book_group_table']} set bg_count = ".$total['cnt']." where bg_no='$bg_no'"); +} + +$result = $counter - $failure - $overlap; + +echo ""; + + +function alert_after($str) { + echo ""; + alert_just($str); +} +?> \ No newline at end of file diff --git a/adm/sms_admin/num_book_move.php b/adm/sms_admin/num_book_move.php new file mode 100644 index 000000000..1a68adece --- /dev/null +++ b/adm/sms_admin/num_book_move.php @@ -0,0 +1,128 @@ + + +
    +

    + +
    + + + + + +
    + + + + + + + + + + + + + + + + +
    할 그룹을 한개 이상 선택하여 주십시오.
    + + + + + 그룹
    + + + + +
    +
    + +
    + + +
    +
    + +
    + + + + diff --git a/adm/sms_admin/num_book_multi_update.php b/adm/sms_admin/num_book_multi_update.php new file mode 100644 index 000000000..172b6c014 --- /dev/null +++ b/adm/sms_admin/num_book_multi_update.php @@ -0,0 +1,63 @@ + \ No newline at end of file diff --git a/adm/sms_admin/num_book_update.php b/adm/sms_admin/num_book_update.php new file mode 100644 index 000000000..edb9dd373 --- /dev/null +++ b/adm/sms_admin/num_book_update.php @@ -0,0 +1,137 @@ +'$bk_no' and bk_hp='$bk_hp'"); + if ($res) + alert('같은 번호가 존재합니다.'); +*/ + $res = sql_fetch("select * from {$g5['sms5_book_table']} where bk_no='$bk_no'"); + if (!$res) + alert('존재하지 않는 데이터 입니다.'); + + if ($bg_no != $res['bg_no']) { + if ($res['mb_id']) $mem = "bg_member"; else $mem = "bg_nomember"; + if ($res['bk_receipt'] == 1) $sms = "bg_receipt"; else $sms = "bg_reject"; + sql_query("update {$g5['sms5_book_group_table']} set bg_count = bg_count - 1, $mem = $mem - 1, $sms = $sms - 1 where bg_no='{$res['bg_no']}'"); + sql_query("update {$g5['sms5_book_group_table']} set bg_count = bg_count + 1, $mem = $mem + 1, $sms = $sms + 1 where bg_no='$bg_no'"); + } + + if ($bk_receipt != $res['bk_receipt']) { + if ($bk_receipt == 1) + sql_query("update {$g5['sms5_book_group_table']} set bg_receipt = bg_receipt + 1, bg_reject = bg_reject - 1 where bg_no='$bg_no'"); + else + sql_query("update {$g5['sms5_book_group_table']} set bg_receipt = bg_receipt - 1, bg_reject = bg_reject + 1 where bg_no='$bg_no'"); + } + + sql_query("update {$g5['sms5_book_table']} set bg_no='$bg_no', bk_name='$bk_name', bk_hp='$bk_hp', bk_receipt='$bk_receipt', bk_datetime='".G5_TIME_YMDHIS."', bk_memo='$bk_memo' where bk_no='$bk_no'"); + if ($res['mb_id']){ //만약에 mb_id가 있다면... + // 휴대폰번호 중복체크 + $sql = " select mb_id from {$g5['member_table']} where mb_id <> '{$res['mb_id']}' and mb_hp = '{$bk_hp}' "; + $mb_hp_exist = sql_fetch($sql); + if ($mb_hp_exist['mb_id']) { //중복된 회원 휴대폰번호가 있다면 + $is_hp_exist = true; + } else { + sql_query("update {$g5['member_table']} set mb_name='$bk_name', mb_hp='$bk_hp', mb_sms='$bk_receipt' where mb_id='{$res['mb_id']}'", false); + } + } + $get_bg_no = $bg_no; + + $go_url = './num_book_write.php?bk_no='.$bk_no.'&w='.$w.'&page='.$page; + if( $is_hp_exist ){ //중복된 회원 휴대폰번호가 있다면 + //alert( "중복된 회원 휴대폰번호가 있어서 회원정보에는 반영되지 않았습니다.", $go_url ); + goto_url($go_url); + } else { + goto_url($go_url); + } + exit; +} +else if ($w=='d') // 삭제 +{ + if (!is_numeric($bk_no)) + alert('고유번호가 없습니다.'); + + $res = sql_fetch("select * from {$g5['sms5_book_table']} where bk_no='$bk_no'"); + if (!$res) + alert('존재하지 않는 데이터 입니다.'); + + if ($res['bk_receipt'] == 1) $bg_sms = 'bg_receipt'; else $bg_sms = 'bg_reject'; + if ($res['mb_id']) $bg_mb = 'bg_member'; else $bg_mb = 'bg_nomember'; + + sql_query("delete from {$g5['sms5_book_table']} where bk_no='$bk_no'"); + sql_query("update {$g5['sms5_book_group_table']} set bg_count = bg_count - 1, $bg_mb = $bg_mb - 1, $bg_sms = $bg_sms - 1 where bg_no = '{$res['bg_no']}'"); + +/* + if (!is_numeric($bk_no)) + alert('고유번호가 없습니다.'); + + $res = sql_fetch("select * from $g5[sms5_book_table] where bk_no='$bk_no'"); + if (!$res) + alert('존재하지 않는 데이터 입니다.'); + + if (!$res[mb_id]) + { + if ($res[receipt] == 1) + $sql_sms = "bg_receipt = bg_receipt - 1"; + else + $sql_sms = "bg_reject = bg_reject - 1"; + + sql_query("delete from $g5[sms5_book_table] where bk_no='$bk_no'"); + sql_query("update $g5[sms5_book_group_table] set bg_count = bg_count - 1, bg_nomember = bg_nomember - 1, $sql_sms where bg_no = '$res[bg_no]'"); + } + else + alert("회원은 삭제할 수 없습니다.\\n\\n회원관리 메뉴에서 삭제한 후\\n\\n회원정보업데이트 메뉴를 실행 해주세요."); +*/ +} +else // 등록 +{ + if (!$bg_no) $bg_no = 1; + + if (!$bk_receipt) $bk_receipt = 0; else $bk_receipt = 1; + + if (!strlen(trim($bk_name))) + alert('이름을 입력해주세요'); + + if ($bk_hp == '') + alert('휴대폰번호만 입력 가능합니다.'); + + $res = sql_fetch("select * from {$g5['sms5_book_table']} where bk_hp='$bk_hp'"); + if ($res) + alert('같은 번호가 존재합니다.'); + + if ($bk_receipt == 1) + $sql_sms = "bg_receipt = bg_receipt + 1"; + else + $sql_sms = "bg_reject = bg_reject + 1"; + + sql_query("insert into {$g5['sms5_book_table']} set bg_no='$bg_no', bk_name='$bk_name', bk_hp='$bk_hp', bk_receipt='$bk_receipt', bk_datetime='".G5_TIME_YMDHIS."', bk_memo='$bk_memo'"); + sql_query("update {$g5['sms5_book_group_table']} set bg_count = bg_count + 1, bg_nomember = bg_nomember + 1, $sql_sms where bg_no = '$bg_no'"); + + $get_bg_no = $bg_no; +} + +$go_url = './num_book.php?page='.$page.'&bg_no='.$get_bg_no.'&ap='.$ap; +goto_url($go_url); +?> \ No newline at end of file diff --git a/adm/sms_admin/num_book_write.php b/adm/sms_admin/num_book_write.php new file mode 100644 index 000000000..9a8777908 --- /dev/null +++ b/adm/sms_admin/num_book_write.php @@ -0,0 +1,216 @@ + '{$write['mb_id']}' and mb_hp <> '' "; + $result = sql_query($sql); + while($tmp = sql_fetch_array($result)){ + $exist_hplist[] = $tmp; + } + $exist_msg_1 = '(수정시 회원정보에 반영되지 않습니다.)'; + $exist_msg_2 = '(수정시 회원정보에 반영됩니다.)'; + $exist_msg = count($exist_hplist) ? $exist_msg_1 : $exist_msg_2; + } + $g5['title'] .= '수정'; +} +else { + $write['bg_no'] = $bg_no; + $g5['title'] .= '추가'; +} + +if (!is_numeric($write['bk_receipt'])) + $write['bk_receipt'] = 1; + +$no_group = sql_fetch("select * from {$g5['sms5_book_group_table']} where bg_no = 1"); + +include_once(G5_ADMIN_PATH."/admin.head.php"); +?> + +
    + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +
    + + +
    +
      + +
    • 중복됨
    • + +
    +
    + +
    수신여부 + > + + > + +
    회원아이디 '.$write['mb_id'].'' : '비회원'?>
    업데이트
    + +
    +
    + +
    + + 목록 +
    + +
    + + \ No newline at end of file diff --git a/adm/sms_admin/num_group.php b/adm/sms_admin/num_group.php new file mode 100644 index 000000000..07e5cf79f --- /dev/null +++ b/adm/sms_admin/num_group.php @@ -0,0 +1,186 @@ + 1 order by bg_name"); +while ($res = sql_fetch_array($qry)) array_push($group, $res); + +include_once(G5_ADMIN_PATH.'/admin.head.php'); +?> + + + + +
    + +
    + + + +
    +
    + 건수 : +
    +
    + +
    +

    그룹명순으로 정렬됩니다.

    +
    + +
    + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    목록
    + + + 그룹명회원비회원수신거부이동보기
    + + + + 보기 +
    + + + + + + + + + + + 보기 +
    +
    + +
    + + + +
    + +
    + \ No newline at end of file diff --git a/adm/sms_admin/num_group_move.php b/adm/sms_admin/num_group_move.php new file mode 100644 index 000000000..733585c16 --- /dev/null +++ b/adm/sms_admin/num_group_move.php @@ -0,0 +1,14 @@ + \ No newline at end of file diff --git a/adm/sms_admin/num_group_update.php b/adm/sms_admin/num_group_update.php new file mode 100644 index 000000000..3f7cc9990 --- /dev/null +++ b/adm/sms_admin/num_group_update.php @@ -0,0 +1,77 @@ +'$bg_no' and bg_name='$bg_name'"); + if ($res) + alert('같은 그룹명이 존재합니다.'); + + sql_query("update {$g5['sms5_book_group_table']} set bg_name='$bg_name' where bg_no='$bg_no'"); + } +} +else if ($w == 'de') // 그룹삭제 +{ + for ($i=0; $i \ No newline at end of file diff --git a/adm/sms_admin/number_move_update.php b/adm/sms_admin/number_move_update.php new file mode 100644 index 000000000..ad24a7010 --- /dev/null +++ b/adm/sms_admin/number_move_update.php @@ -0,0 +1,84 @@ += 1 "); + $bg_reject = (int)$bg_count['cnt'] - (int)$bg_receipt['cnt']; + $bg_member = sql_fetch("select count(*) as cnt from {$g5['sms5_book_table']} where bg_no='$v' and mb_id <> '' "); + $bg_nomember = (int)$bg_count['cnt'] - (int)$bg_member['cnt']; + $sql = "update {$g5['sms5_book_group_table']} set bg_count = {$bg_count['cnt']}, bg_receipt = {$bg_receipt['cnt']}, bg_reject = {$bg_reject}, bg_member = {$bg_member['cnt']}, bg_nomember = {$bg_nomember} where bg_no='$v' "; + sql_query($sql); + } +} + +$msg = '해당 번호를 선택한 그룹으로 '.$act.' 하였습니다.'; +$opener_href = './num_book.php?page='.$page; + +echo << + + +HEREDOC; +?> \ No newline at end of file diff --git a/adm/sms_admin/sms5.sql b/adm/sms_admin/sms5.sql new file mode 100644 index 000000000..ae8bcb2cf --- /dev/null +++ b/adm/sms_admin/sms5.sql @@ -0,0 +1,189 @@ +## 마이에스큐엘 dump 10.11 +## +## +## ###################################################### +## Server version 5.0.92-log + + + + + + + +## +## Table structure for table `{$g5['sms5_book_table']}` +## + +DROP TABLE IF EXISTS `{$g5['sms5_book_table']}`; + + +CREATE TABLE `{$g5['sms5_book_table']}` ( + `bk_no` int(11) NOT NULL auto_increment, + `bg_no` int(11) NOT NULL default '0', + `mb_no` int(11) NOT NULL default '0', + `mb_id` varchar(20) NOT NULL default '', + `bk_name` varchar(255) NOT NULL default '', + `bk_hp` varchar(255) NOT NULL default '', + `bk_receipt` tinyint(4) NOT NULL default '0', + `bk_datetime` datetime NOT NULL default '0000-00-00 00:00:00', + `bk_memo` text NOT NULL, + PRIMARY KEY (`bk_no`), + KEY `bk_name` (`bk_name`), + KEY `bk_hp` (`bk_hp`), + KEY `mb_no` (`mb_no`), + KEY `bg_no` (`bg_no`,`bk_no`), + KEY `mb_id` (`mb_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + + +## +## Table structure for table `{$g5['sms5_book_table']}_group` +## + +DROP TABLE IF EXISTS `{$g5['sms5_book_table']}_group`; + + +CREATE TABLE `{$g5['sms5_book_table']}_group` ( + `bg_no` int(11) NOT NULL auto_increment, + `bg_name` varchar(255) NOT NULL default '', + `bg_count` int(11) NOT NULL default '0', + `bg_member` int(11) NOT NULL default '0', + `bg_nomember` int(11) NOT NULL default '0', + `bg_receipt` int(11) NOT NULL default '0', + `bg_reject` int(11) NOT NULL default '0', + PRIMARY KEY (`bg_no`), + KEY `bg_name` (`bg_name`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + + +## +## Table structure for table `{$g5['sms5_config_table']}` +## + +DROP TABLE IF EXISTS `{$g5['sms5_config_table']}`; + + +CREATE TABLE `{$g5['sms5_config_table']}` ( + `cf_phone` varchar(255) NOT NULL default '', + `cf_register` varchar(255) NOT NULL default '', + `cf_datetime` datetime NOT NULL default '0000-00-00 00:00:00', + `cf_member` tinyint(4) NOT NULL default '1', + `cf_level` tinyint(4) NOT NULL default '2', + `cf_point` int(11) NOT NULL default '0', + `cf_day_count` int(11) NOT NULL default '0', + `cf_skin` varchar(100) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + + +## +## Table structure for table `{$g5['sms5_form_table']}` +## + +DROP TABLE IF EXISTS `{$g5['sms5_form_table']}`; + + +CREATE TABLE `{$g5['sms5_form_table']}` ( + `fo_no` int(11) NOT NULL auto_increment, + `fg_no` tinyint(4) NOT NULL default '0', + `fg_member` char(1) NOT NULL default '0', + `fo_name` varchar(255) NOT NULL default '', + `fo_content` text NOT NULL, + `fo_datetime` datetime NOT NULL default '0000-00-00 00:00:00', + PRIMARY KEY (`fo_no`), + KEY `fg_no` (`fg_no`,`fo_no`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + + +## +## Table structure for table `{$g5['sms5_form_table']}_group` +## + +DROP TABLE IF EXISTS `{$g5['sms5_form_table']}_group`; + + +CREATE TABLE `{$g5['sms5_form_table']}_group` ( + `fg_no` int(11) NOT NULL auto_increment, + `fg_name` varchar(255) NOT NULL default '', + `fg_count` int(11) NOT NULL default '0', + `fg_member` tinyint(4) NOT NULL, + PRIMARY KEY (`fg_no`), + KEY `fg_name` (`fg_name`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + + +## +## Table structure for table `{$g5['sms5_history_table']}` +## + +DROP TABLE IF EXISTS `{$g5['sms5_history_table']}`; + + +CREATE TABLE `{$g5['sms5_history_table']}` ( + `hs_no` int(11) NOT NULL auto_increment, + `wr_no` int(11) NOT NULL default '0', + `wr_renum` int(11) NOT NULL default '0', + `bg_no` int(11) NOT NULL default '0', + `mb_no` int(11) NOT NULL default '0', + `mb_id` varchar(20) NOT NULL default '', + `bk_no` int(11) NOT NULL default '0', + `hs_name` varchar(30) NOT NULL default '', + `hs_hp` varchar(255) NOT NULL default '', + `hs_datetime` datetime NOT NULL default '0000-00-00 00:00:00', + `hs_flag` tinyint(4) NOT NULL default '0', + `hs_code` varchar(255) NOT NULL default '', + `hs_memo` varchar(255) NOT NULL default '', + `hs_log` varchar(255) NOT NULL default '', + PRIMARY KEY (`hs_no`), + KEY `wr_no` (`wr_no`), + KEY `mb_no` (`mb_no`), + KEY `bk_no` (`bk_no`), + KEY `hs_hp` (`hs_hp`), + KEY `hs_code` (`hs_code`), + KEY `bg_no` (`bg_no`), + KEY `mb_id` (`mb_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + + +## +## Table structure for table `{$g5['sms5_write_table']}` +## + +DROP TABLE IF EXISTS `{$g5['sms5_write_table']}`; + + +CREATE TABLE `{$g5['sms5_write_table']}` ( + `wr_no` int(11) NOT NULL default '1', + `wr_renum` int(11) NOT NULL default '0', + `wr_reply` varchar(255) NOT NULL default '', + `wr_message` varchar(255) NOT NULL default '', + `wr_booking` datetime NOT NULL default '0000-00-00 00:00:00', + `wr_total` int(11) NOT NULL default '0', + `wr_re_total` int(11) NOT NULL default '0', + `wr_success` int(11) NOT NULL default '0', + `wr_failure` int(11) NOT NULL default '0', + `wr_datetime` datetime NOT NULL default '0000-00-00 00:00:00', + `wr_memo` text NOT NULL, + KEY `wr_no` (`wr_no`,`wr_renum`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + + +## +## Table structure for table `{$g5['sms5_member_history_table']}` +## + +DROP TABLE IF EXISTS `{$g5['sms5_member_history_table']}`; + + +CREATE TABLE `{$g5['sms5_member_history_table']}` ( + `mh_no` int(11) NOT NULL auto_increment, + `mb_id` varchar(30) NOT NULL, + `mh_reply` varchar(30) NOT NULL, + `mh_hp` varchar(30) NOT NULL, + `mh_datetime` datetime NOT NULL, + `mh_booking` datetime NOT NULL, + `mh_log` varchar(255) NOT NULL, + `mh_ip` varchar(15) NOT NULL, + PRIMARY KEY (`mh_no`), + KEY `mb_id` (`mb_id`,`mh_datetime`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + diff --git a/adm/sms_admin/sms_ing.php b/adm/sms_admin/sms_ing.php new file mode 100644 index 000000000..3c8fdbabb --- /dev/null +++ b/adm/sms_admin/sms_ing.php @@ -0,0 +1,22 @@ + + + + + + +SMS 전송 중 + + + + +

    SMS를 전송 중입니다.
    잠시만 기다려주십시오.
    + + + diff --git a/adm/sms_admin/sms_write.php b/adm/sms_admin/sms_write.php new file mode 100644 index 000000000..871402560 --- /dev/null +++ b/adm/sms_admin/sms_write.php @@ -0,0 +1,779 @@ + + +
    + 회원정보 최근 업데이트 : +
    + + +
    + +
    +

    이모티콘 목록

    + +
    + +
    +
    + + +

    보낼내용

    +
    + + + + +
    0 / 80 byte
    + + +
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    +
    + +
    + +
    + + + + + + + + + + + + + + + + +
    +
    +
    + +
    + +
    + {이름} : 받는사람 이름 +
    + +
    + + +
    + +
    +

    받는사람

    + + + + + +
    + +
    + + +
    +
    +
    + +
    +

    예약전송

    + +
    + + +
    + + + +
    + + + +
    + + + + +
    + +
    + + +
    +
    +
    + +
    +

    휴대폰번호 목록

    +
    + 그룹 + 개인 + 권한 +
    + +
    + +
    SMS 수신을 허용한 회원님만 출력됩니다.
    +
    +
    + + + +\n"; + echo "var hp_list = document.getElementById('hp_list');\n"; + //echo "add(\"$row[wr_message]\");\n"; + $wr_message = str_replace('"', '\"', $row['wr_message']); + $wr_message = str_replace("\r\n", "\\n", $wr_message); + echo "add(\"$wr_message\");\n"; + echo "document.getElementById('wr_reply').value = '{$row['wr_reply']}';\n"; + + // 회원목록 + $sql = " select * from {$g5['sms5_history_table']} where wr_no = '$wr_no' and bk_no > 0 "; + $qry = sql_query($sql); + $tot = mysql_num_rows($qry); + + if ($tot > 0) { + + $str = '재전송그룹 ('.number_format($tot).'명)'; + $val = 'p,'; + + while ($row = sql_fetch_array($qry)) + { + $val .= $row['bk_no'].','; + } + + echo "hp_list.options[hp_list.length] = new Option('$str', '$val');\n"; + } + + // 비회원 목록 + $sql = " select * from {$g5['sms5_history_table']} where wr_no = '$wr_no' and bk_no = 0 "; + $qry = sql_query($sql); + $tot = mysql_num_rows($qry); + + if ($tot > 0) + { + while ($row = sql_fetch_array($qry)) + { + $str = "{$row['hs_name']} ({$row['hs_hp']})"; + $val = "h,{$row['hs_name']}:{$row['hs_hp']}"; + echo "hp_list.options[hp_list.length] = new Option('$str', '$val');\n"; + } + } + echo "\n"; +} +?> + + + + +
    +

    SMS 문자전송 서비스를 사용할 수 없습니다.

    +
    +

    + SMS 를 사용하지 않고 있기 때문에, 문자 전송을 할 수 없습니다.
    + SMS 사용 설정은 환경설정 > 기본환경설정 > SMS설정 에서 SMS 사용을 아이코드로 변경해 주셔야 사용하실수 있습니다. +

    +
    +
    + + + + \ No newline at end of file diff --git a/adm/sms_admin/sms_write_form.php b/adm/sms_admin/sms_write_form.php new file mode 100644 index 000000000..781b3fbb8 --- /dev/null +++ b/adm/sms_admin/sms_write_form.php @@ -0,0 +1,132 @@ + + +
    + + +
    + +
      +
    + +
    + + + + + + + + +
    + + + + + \ No newline at end of file diff --git a/adm/sms_admin/sms_write_overlap_check.php b/adm/sms_admin/sms_write_overlap_check.php new file mode 100644 index 000000000..100ed6ba3 --- /dev/null +++ b/adm/sms_admin/sms_write_overlap_check.php @@ -0,0 +1,69 @@ + $hp, 'bk_name' => $name)); + array_push($hps, $hp); + break; + + case 'p': // 개인 선택 + $res = sql_fetch("select * from {$g5['sms5_book_table']} where bk_no='$item[$i]'"); + $res['bk_hp'] = get_hp($res['bk_hp'], 0); + if (array_overlap($hps, $res['bk_hp'])) { + $overlap ++; + continue; + } + array_push($list, $res); + array_push($hps, $res['bk_hp']); + break; + } + } +} + +if ($overlap) + die("중복되는 휴대폰번호가 $overlap 건 있습니다. "); +else + die("중복되는 휴대폰번호가 없습니다. "); +?> \ No newline at end of file diff --git a/adm/sms_admin/sms_write_send.php b/adm/sms_admin/sms_write_send.php new file mode 100644 index 000000000..348e44141 --- /dev/null +++ b/adm/sms_admin/sms_write_send.php @@ -0,0 +1,231 @@ + $hp, 'bk_name' => $name, 'mb_id' => $mb_id, 'bg_no' => $bg_no, 'bk_no' => $bk_no)); + array_push($hps, $hp); + } + break; + + case 'h': // 권한(mb_leve) 선택 + + $item[$i] = explode(':', $item[$i]); + $hp = get_hp($item[$i][1], 0); + $name = $item[$i][0]; + + if ($wr_overlap && array_overlap($hps, $hp)) { + $overlap++; + array_push( $duplicate_data['hp'], $row['bk_hp'] ); + continue; + } + + array_push($list, array('bk_hp' => $hp, 'bk_name' => $name)); + array_push($hps, $hp); + break; + + case 'p': // 개인 선택 + + $row = sql_fetch("select * from {$g5['sms5_book_table']} where bk_no='$item[$i]'"); + $row['bk_hp'] = get_hp($row['bk_hp'], 0); + + if ($wr_overlap && array_overlap($hps, $row['bk_hp'])) { + $overlap++; + array_push( $duplicate_data['hp'], $row['bk_hp'] ); + continue; + } + array_push($list, $row); + array_push($hps, $row['bk_hp']); + break; + } + } +} + +if( count($duplicate_data['hp']) ){ //중복된 번호가 있다면 + $duplicate_data['total'] = $overlap; + $str_serialize = serialize($duplicate_data); +} + +$wr_total = count($list); + +// 예약전송 +if ($wr_by && $wr_bm && $wr_bd && $wr_bh && $wr_bi) { + $wr_booking = "$wr_by-$wr_bm-$wr_bd $wr_bh:$wr_bi"; + $booking = $wr_by.$wr_bm.$wr_bd.$wr_bh.$wr_bi; +} else { + $wr_booking = ''; + $booking = ''; +} + +if ($config['cf_sms_use'] != 'icode') { + alert('기본환경설정에서 icode sms 사용이 비활성화 되어 있습니다.'); +} + +include_once(G5_ADMIN_PATH.'/admin.head.php'); + +$SMS = new SMS5; +$SMS->SMS_con($config['cf_icode_server_ip'], $config['cf_icode_id'], $config['cf_icode_pw'], $config['cf_icode_server_port']); + +$reply = str_replace('-', '', trim($wr_reply)); + +$result = $SMS->Add($list, $reply, '', '', $wr_message, $booking, $wr_total); + +if ($result) +{ + $result = $SMS->Send(); + + if ($result) //SMS 서버에 접속했습니다. + { + $row = sql_fetch("select max(wr_no) as wr_no from {$g5['sms5_write_table']}"); + if ($row) + $wr_no = $row['wr_no'] + 1; + else + $wr_no = 1; + + sql_query("insert into {$g5['sms5_write_table']} set wr_no='$wr_no', wr_renum=0, wr_reply='$wr_reply', wr_message='$wr_message', wr_booking='$wr_booking', wr_total='$wr_total', wr_datetime='".G5_TIME_YMDHIS."'"); + + $wr_success = 0; + $wr_failure = 0; + $count = 0; + + foreach ($SMS->Result as $result) + { + list($phone, $code) = explode(":", $result); + + if (substr($code,0,5) == "Error") + { + $hs_code = substr($code,6,2); + + switch ($hs_code) { + case '02': // "02:형식오류" + $hs_memo = "형식이 잘못되어 전송이 실패하였습니다."; + break; + case '23': // "23:인증실패,데이터오류,전송날짜오류" + $hs_memo = "데이터를 다시 확인해 주시기바랍니다."; + break; + case '97': // "97:잔여코인부족" + $hs_memo = "잔여코인이 부족합니다."; + break; + case '98': // "98:사용기간만료" + $hs_memo = "사용기간이 만료되었습니다."; + break; + case '99': // "99:인증실패" + $hs_memo = "인증 받지 못하였습니다. 계정을 다시 확인해 주세요."; + break; + default: // "미 확인 오류" + $hs_memo = "알 수 없는 오류로 전송이 실패하었습니다."; + break; + } + $wr_failure++; + $hs_flag = 0; + } + else + { + $hs_code = $code; + $hs_memo = get_hp($phone, 1)."로 전송했습니다."; + $wr_success++; + $hs_flag = 1; + } + + $row = array_shift($list); + $row['bk_hp'] = get_hp($row['bk_hp'], 1); + + $log = array_shift($SMS->Log); + sql_query("insert into {$g5['sms5_history_table']} set wr_no='$wr_no', wr_renum=0, bg_no='{$row['bg_no']}', mb_id='{$row['mb_id']}', bk_no='{$row['bk_no']}', hs_name='{$row['bk_name']}', hs_hp='{$row['bk_hp']}', hs_datetime='".G5_TIME_YMDHIS."', hs_flag='$hs_flag', hs_code='$hs_code', hs_memo='$hs_memo', hs_log='".stripslashes($log)."'"); + } + $SMS->Init(); // 보관하고 있던 결과값을 지웁니다. + + sql_query("update {$g5['sms5_write_table']} set wr_success='$wr_success', wr_failure='$wr_failure', wr_memo='$str_serialize' where wr_no='$wr_no' and wr_renum=0"); + } + else win_close_alert("에러: SMS 서버와 통신이 불안정합니다."); +} +else win_close_alert("에러: SMS 데이터 입력도중 에러가 발생하였습니다."); + +function win_close_alert($msg) { + + $html = ""; + + echo $html; + exit; +} + +?> + + \ No newline at end of file diff --git a/extend/sms5.extend.php b/extend/sms5.extend.php new file mode 100644 index 000000000..8b47fc273 --- /dev/null +++ b/extend/sms5.extend.php @@ -0,0 +1,57 @@ + \ No newline at end of file diff --git a/install/install_db.php b/install/install_db.php index 2fbaadd62..294931c07 100644 --- a/install/install_db.php +++ b/install/install_db.php @@ -22,7 +22,9 @@ $admin_id = $_POST['admin_id']; $admin_pass = $_POST['admin_pass']; $admin_name = $_POST['admin_name']; $admin_email = $_POST['admin_email']; -$g5_install = $_POST['g5_install']; +$g5_install = 0; +if (isset($_POST['g5_install'])) + $g5_install = $_POST['g5_install']; $g5_shop_prefix = $_POST['g5_shop_prefix']; $g5_shop_install= $_POST['g5_shop_install']; diff --git a/js/common.js b/js/common.js index 5848854a0..00cfccb59 100644 --- a/js/common.js +++ b/js/common.js @@ -368,6 +368,14 @@ var win_zip = function(href) { new_win.focus(); } +/** + * sms5 창 + **/ +var win_sms5 = function(href) { + var new_win = window.open(href, 'win_zip', 'width=474, height=560, scrollbars=1'); + new_win.focus(); +} + /** * 새로운 비밀번호 분실 창 : 101123 **/ @@ -452,6 +460,11 @@ $(function(){ return false; }); + $(".win_sms5").click(function() { + win_sms5(this.href); + return false; + }); + /* $(".win_poll").click(function() { win_poll(this.href); diff --git a/js/jquery.sms_paging.js b/js/jquery.sms_paging.js new file mode 100644 index 000000000..a35f3b623 --- /dev/null +++ b/js/jquery.sms_paging.js @@ -0,0 +1,93 @@ +/************************************************************************************** + * jQuery Paging 0.1.7 + * by composite (ukjinplant@msn.com) + * http://composite.tistory.com + * This project licensed under a MIT License. + **************************************************************************************/; +(function($){ + //default properties. + var a=/a/i,defs={ + liitem:'li', item:'a',next:'[>{5}]',prev:'[{4}<]',format:'[{0}]', + itemClass:'',appendhtml:'',sideClass:'paging-side',prevClass:'paging-side', + itemCurrent:'active',length:10,max:1,current:1,append:false + ,href:'#{0}',event:true,first:'[1<<]',last:'[>>{6}]' + },InStr=function(strSearch, charSearchFor) { + return strSearch.indexOf(charSearchFor); + },format=function(str){ + var arg=arguments; + return str.replace(/\{(\d+)\}/g,function(m,d){ + if(+d<0) return m; + else return arg[+d+1]||""; + }); + },item,make=function(op,page,cls,str){ + var is_current = false; + if( InStr( cls , op.itemCurrent) > -1 ){ + item=document.createElement("strong"); + is_current = true; + } else { + item=document.createElement(op.item); + } + item.className=cls; + item.innerHTML=format(str,page,op.length,op.start,op.end,op.start-1,op.end+1,op.max); + if(a.test(op.item)) item.href=format(op.href,page); + if(op.event){ + $(item).bind('click',function(e){ + var fired=true; + if($.isFunction(op.onclick)) fired=op.onclick.call(item,e,page,op); + if(fired==undefined||fired) + op.origin.paging($.extend({},op,{current:page})); + return fired; + }); + /* + $liitem= $(document.createElement(op.liitem)); + $liitem.addClass(cls); + $liitem.append($(item)); + */ + if(op.appendhtml){ + $(item).append(op.appendhtml); + } + $(item).appendTo(op.origin); + if( is_current ){ + $(item).prepend('열린'); + } else { + (op.origin).append('\n'); + } + //bind event for each elements. + var ev='on'; + switch(str){ + case op.prev:ev+='prev';break; + case op.next:ev+='next';break; + case op.first:ev+='first';break; + case op.last:ev+='last';break; + default:ev+='item';break; + } + if($.isFunction(op[ev])) op[ev].call(item,page,op); + } + return item; + }; + + $.fn.paging=function(op){ + op=$.extend({origin:this},defs,op||{});this.html(''); + if(op.max<1) op.max=1; if(op.current<1) op.current=1; + op.start=Math.floor((op.current-1)/op.length)*op.length+1; + op.end=op.start-1+op.length; + if(op.end>op.max) op.end=op.max; + if(!op.append) this.empty(); + //prev button + if(op.current>op.length){ + //if(op.first!==false) make(op,1,op.sideClass,op.first); + make(op,op.start-1,op.prevClass,op.prev); + } + //pages button + for(var i=op.start;i<=op.end;i++){ + make(op,i,op.itemClass+(i==op.current?' '+op.itemCurrent:''),op.format); + } + //next button + if(op.current<=Math.floor(op.max/op.length)*op.length){ + if(op.max > op.length && op.max > op.end ){ make(op,op.end+1,op.sideClass,op.next); } + //if(op.last!==false) make(op,op.max,op.sideClass,op.last); + } + + //last button + }; +})(jQuery); \ No newline at end of file diff --git a/lib/common.lib.php b/lib/common.lib.php index 829e4ed3c..87839e139 100644 --- a/lib/common.lib.php +++ b/lib/common.lib.php @@ -1205,7 +1205,7 @@ function get_sideview($mb_id, $name='', $email='', $homepage='') { global $config; global $g5; - global $bo_table, $sca, $is_admin; + global $bo_table, $sca, $is_admin, $member; $email = base64_encode($email); $homepage = set_http($homepage); @@ -1273,6 +1273,10 @@ function get_sideview($mb_id, $name='', $email='', $homepage='') } if($mb_id) $str2 .= "전체게시물\n"; + if($g5['sms5_use_sideview']){ + $mb = get_member($mb_id, " mb_open, mb_sms , mb_hp "); + if( $mb['mb_open'] && $mb['mb_sms'] && $mb['mb_hp'] ) $str2 .= "문자보내기\n"; + } if($is_admin == "super" && $mb_id) { $str2 .= "회원정보변경\n"; $str2 .= "포인트내역\n"; diff --git a/plugin/editor/ckeditor4/editor.lib.php b/plugin/editor/ckeditor4/editor.lib.php index 6f53df5fb..06ef5a1f3 100644 --- a/plugin/editor/ckeditor4/editor.lib.php +++ b/plugin/editor/ckeditor4/editor.lib.php @@ -13,7 +13,7 @@ function editor_html($id, $content, $is_dhtml_editor=true) if ($is_dhtml_editor) $html .= ''; - if ($js) { + if ($is_dhtml_editor && $js) { $html .= "\n".''; $html .= "\n".''; $html .= "\n".''; diff --git a/plugin/sms5/JSON.php b/plugin/sms5/JSON.php new file mode 100644 index 000000000..8dc8a6f01 --- /dev/null +++ b/plugin/sms5/JSON.php @@ -0,0 +1,933 @@ + + * @author Matt Knapp + * @author Brett Stimmerman + * @copyright 2005 Michal Migurski + * @version CVS: $Id: JSON.php 305040 2010-11-02 23:19:03Z alan_k $ + * @license http://www.opensource.org/licenses/bsd-license.php + * @link http://pear.php.net/pepr/pepr-proposal-show.php?id=198 + */ + +/** + * Marker constant for Services_JSON::decode(), used to flag stack state + */ +define('SERVICES_JSON_SLICE', 1); + +/** + * Marker constant for Services_JSON::decode(), used to flag stack state + */ +define('SERVICES_JSON_IN_STR', 2); + +/** + * Marker constant for Services_JSON::decode(), used to flag stack state + */ +define('SERVICES_JSON_IN_ARR', 3); + +/** + * Marker constant for Services_JSON::decode(), used to flag stack state + */ +define('SERVICES_JSON_IN_OBJ', 4); + +/** + * Marker constant for Services_JSON::decode(), used to flag stack state + */ +define('SERVICES_JSON_IN_CMT', 5); + +/** + * Behavior switch for Services_JSON::decode() + */ +define('SERVICES_JSON_LOOSE_TYPE', 16); + +/** + * Behavior switch for Services_JSON::decode() + */ +define('SERVICES_JSON_SUPPRESS_ERRORS', 32); + +/** + * Behavior switch for Services_JSON::decode() + */ +define('SERVICES_JSON_USE_TO_JSON', 64); + +/** + * Converts to and from JSON format. + * + * Brief example of use: + * + * + * // create a new instance of Services_JSON + * $json = new Services_JSON(); + * + * // convert a complexe value to JSON notation, and send it to the browser + * $value = array('foo', 'bar', array(1, 2, 'baz'), array(3, array(4))); + * $output = $json->encode($value); + * + * print($output); + * // prints: ["foo","bar",[1,2,"baz"],[3,[4]]] + * + * // accept incoming POST data, assumed to be in JSON notation + * $input = file_get_contents('php://input', 1000000); + * $value = $json->decode($input); + * + */ +class Services_JSON +{ + /** + * constructs a new JSON instance + * + * @param int $use object behavior flags; combine with boolean-OR + * + * possible values: + * - SERVICES_JSON_LOOSE_TYPE: loose typing. + * "{...}" syntax creates associative arrays + * instead of objects in decode(). + * - SERVICES_JSON_SUPPRESS_ERRORS: error suppression. + * Values which can't be encoded (e.g. resources) + * appear as NULL instead of throwing errors. + * By default, a deeply-nested resource will + * bubble up with an error, so all return values + * from encode() should be checked with isError() + * - SERVICES_JSON_USE_TO_JSON: call toJSON when serializing objects + * It serializes the return value from the toJSON call rather + * than the object it'self, toJSON can return associative arrays, + * strings or numbers, if you return an object, make sure it does + * not have a toJSON method, otherwise an error will occur. + */ + function Services_JSON($use = 0) + { + $this->use = $use; + $this->_mb_strlen = function_exists('mb_strlen'); + $this->_mb_convert_encoding = function_exists('mb_convert_encoding'); + $this->_mb_substr = function_exists('mb_substr'); + } + // private - cache the mbstring lookup results.. + var $_mb_strlen = false; + var $_mb_substr = false; + var $_mb_convert_encoding = false; + + /** + * convert a string from one UTF-16 char to one UTF-8 char + * + * Normally should be handled by mb_convert_encoding, but + * provides a slower PHP-only method for installations + * that lack the multibye string extension. + * + * @param string $utf16 UTF-16 character + * @return string UTF-8 character + * @access private + */ + function utf162utf8($utf16) + { + // oh please oh please oh please oh please oh please + if($this->_mb_convert_encoding) { + return mb_convert_encoding($utf16, 'UTF-8', 'UTF-16'); + } + + $bytes = (ord($utf16{0}) << 8) | ord($utf16{1}); + + switch(true) { + case ((0x7F & $bytes) == $bytes): + // this case should never be reached, because we are in ASCII range + // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 + return chr(0x7F & $bytes); + + case (0x07FF & $bytes) == $bytes: + // return a 2-byte UTF-8 character + // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 + return chr(0xC0 | (($bytes >> 6) & 0x1F)) + . chr(0x80 | ($bytes & 0x3F)); + + case (0xFFFF & $bytes) == $bytes: + // return a 3-byte UTF-8 character + // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 + return chr(0xE0 | (($bytes >> 12) & 0x0F)) + . chr(0x80 | (($bytes >> 6) & 0x3F)) + . chr(0x80 | ($bytes & 0x3F)); + } + + // ignoring UTF-32 for now, sorry + return ''; + } + + /** + * convert a string from one UTF-8 char to one UTF-16 char + * + * Normally should be handled by mb_convert_encoding, but + * provides a slower PHP-only method for installations + * that lack the multibye string extension. + * + * @param string $utf8 UTF-8 character + * @return string UTF-16 character + * @access private + */ + function utf82utf16($utf8) + { + // oh please oh please oh please oh please oh please + if($this->_mb_convert_encoding) { + return mb_convert_encoding($utf8, 'UTF-16', 'UTF-8'); + } + + switch($this->strlen8($utf8)) { + case 1: + // this case should never be reached, because we are in ASCII range + // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 + return $utf8; + + case 2: + // return a UTF-16 character from a 2-byte UTF-8 char + // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 + return chr(0x07 & (ord($utf8{0}) >> 2)) + . chr((0xC0 & (ord($utf8{0}) << 6)) + | (0x3F & ord($utf8{1}))); + + case 3: + // return a UTF-16 character from a 3-byte UTF-8 char + // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 + return chr((0xF0 & (ord($utf8{0}) << 4)) + | (0x0F & (ord($utf8{1}) >> 2))) + . chr((0xC0 & (ord($utf8{1}) << 6)) + | (0x7F & ord($utf8{2}))); + } + + // ignoring UTF-32 for now, sorry + return ''; + } + + /** + * encodes an arbitrary variable into JSON format (and sends JSON Header) + * + * @param mixed $var any number, boolean, string, array, or object to be encoded. + * see argument 1 to Services_JSON() above for array-parsing behavior. + * if var is a strng, note that encode() always expects it + * to be in ASCII or UTF-8 format! + * + * @return mixed JSON string representation of input var or an error if a problem occurs + * @access public + */ + function encode($var) + { + header('Content-type: application/json'); + return $this->encodeUnsafe($var); + } + /** + * encodes an arbitrary variable into JSON format without JSON Header - warning - may allow XSS!!!!) + * + * @param mixed $var any number, boolean, string, array, or object to be encoded. + * see argument 1 to Services_JSON() above for array-parsing behavior. + * if var is a strng, note that encode() always expects it + * to be in ASCII or UTF-8 format! + * + * @return mixed JSON string representation of input var or an error if a problem occurs + * @access public + */ + function encodeUnsafe($var) + { + // see bug #16908 - regarding numeric locale printing + $lc = setlocale(LC_NUMERIC, 0); + setlocale(LC_NUMERIC, 'C'); + $ret = $this->_encode($var); + setlocale(LC_NUMERIC, $lc); + return $ret; + + } + /** + * PRIVATE CODE that does the work of encodes an arbitrary variable into JSON format + * + * @param mixed $var any number, boolean, string, array, or object to be encoded. + * see argument 1 to Services_JSON() above for array-parsing behavior. + * if var is a strng, note that encode() always expects it + * to be in ASCII or UTF-8 format! + * + * @return mixed JSON string representation of input var or an error if a problem occurs + * @access public + */ + function _encode($var) + { + + switch (gettype($var)) { + case 'boolean': + return $var ? 'true' : 'false'; + + case 'NULL': + return 'null'; + + case 'integer': + return (int) $var; + + case 'double': + case 'float': + return (float) $var; + + case 'string': + // STRINGS ARE EXPECTED TO BE IN ASCII OR UTF-8 FORMAT + $ascii = ''; + $strlen_var = $this->strlen8($var); + + /* + * Iterate over every character in the string, + * escaping with a slash or encoding to UTF-8 where necessary + */ + for ($c = 0; $c < $strlen_var; ++$c) { + + $ord_var_c = ord($var{$c}); + + switch (true) { + case $ord_var_c == 0x08: + $ascii .= '\b'; + break; + case $ord_var_c == 0x09: + $ascii .= '\t'; + break; + case $ord_var_c == 0x0A: + $ascii .= '\n'; + break; + case $ord_var_c == 0x0C: + $ascii .= '\f'; + break; + case $ord_var_c == 0x0D: + $ascii .= '\r'; + break; + + case $ord_var_c == 0x22: + case $ord_var_c == 0x2F: + case $ord_var_c == 0x5C: + // double quote, slash, slosh + $ascii .= '\\'.$var{$c}; + break; + + case (($ord_var_c >= 0x20) && ($ord_var_c <= 0x7F)): + // characters U-00000000 - U-0000007F (same as ASCII) + $ascii .= $var{$c}; + break; + + case (($ord_var_c & 0xE0) == 0xC0): + // characters U-00000080 - U-000007FF, mask 110XXXXX + // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 + if ($c+1 >= $strlen_var) { + $c += 1; + $ascii .= '?'; + break; + } + + $char = pack('C*', $ord_var_c, ord($var{$c + 1})); + $c += 1; + $utf16 = $this->utf82utf16($char); + $ascii .= sprintf('\u%04s', bin2hex($utf16)); + break; + + case (($ord_var_c & 0xF0) == 0xE0): + if ($c+2 >= $strlen_var) { + $c += 2; + $ascii .= '?'; + break; + } + // characters U-00000800 - U-0000FFFF, mask 1110XXXX + // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 + $char = pack('C*', $ord_var_c, + @ord($var{$c + 1}), + @ord($var{$c + 2})); + $c += 2; + $utf16 = $this->utf82utf16($char); + $ascii .= sprintf('\u%04s', bin2hex($utf16)); + break; + + case (($ord_var_c & 0xF8) == 0xF0): + if ($c+3 >= $strlen_var) { + $c += 3; + $ascii .= '?'; + break; + } + // characters U-00010000 - U-001FFFFF, mask 11110XXX + // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 + $char = pack('C*', $ord_var_c, + ord($var{$c + 1}), + ord($var{$c + 2}), + ord($var{$c + 3})); + $c += 3; + $utf16 = $this->utf82utf16($char); + $ascii .= sprintf('\u%04s', bin2hex($utf16)); + break; + + case (($ord_var_c & 0xFC) == 0xF8): + // characters U-00200000 - U-03FFFFFF, mask 111110XX + // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 + if ($c+4 >= $strlen_var) { + $c += 4; + $ascii .= '?'; + break; + } + $char = pack('C*', $ord_var_c, + ord($var{$c + 1}), + ord($var{$c + 2}), + ord($var{$c + 3}), + ord($var{$c + 4})); + $c += 4; + $utf16 = $this->utf82utf16($char); + $ascii .= sprintf('\u%04s', bin2hex($utf16)); + break; + + case (($ord_var_c & 0xFE) == 0xFC): + if ($c+5 >= $strlen_var) { + $c += 5; + $ascii .= '?'; + break; + } + // characters U-04000000 - U-7FFFFFFF, mask 1111110X + // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 + $char = pack('C*', $ord_var_c, + ord($var{$c + 1}), + ord($var{$c + 2}), + ord($var{$c + 3}), + ord($var{$c + 4}), + ord($var{$c + 5})); + $c += 5; + $utf16 = $this->utf82utf16($char); + $ascii .= sprintf('\u%04s', bin2hex($utf16)); + break; + } + } + return '"'.$ascii.'"'; + + case 'array': + /* + * As per JSON spec if any array key is not an integer + * we must treat the the whole array as an object. We + * also try to catch a sparsely populated associative + * array with numeric keys here because some JS engines + * will create an array with empty indexes up to + * max_index which can cause memory issues and because + * the keys, which may be relevant, will be remapped + * otherwise. + * + * As per the ECMA and JSON specification an object may + * have any string as a property. Unfortunately due to + * a hole in the ECMA specification if the key is a + * ECMA reserved word or starts with a digit the + * parameter is only accessible using ECMAScript's + * bracket notation. + */ + + // treat as a JSON object + if (is_array($var) && count($var) && (array_keys($var) !== range(0, sizeof($var) - 1))) { + $properties = array_map(array($this, 'name_value'), + array_keys($var), + array_values($var)); + + foreach($properties as $property) { + if(Services_JSON::isError($property)) { + return $property; + } + } + + return '{' . join(',', $properties) . '}'; + } + + // treat it like a regular array + $elements = array_map(array($this, '_encode'), $var); + + foreach($elements as $element) { + if(Services_JSON::isError($element)) { + return $element; + } + } + + return '[' . join(',', $elements) . ']'; + + case 'object': + + // support toJSON methods. + if (($this->use & SERVICES_JSON_USE_TO_JSON) && method_exists($var, 'toJSON')) { + // this may end up allowing unlimited recursion + // so we check the return value to make sure it's not got the same method. + $recode = $var->toJSON(); + + if (method_exists($recode, 'toJSON')) { + + return ($this->use & SERVICES_JSON_SUPPRESS_ERRORS) + ? 'null' + : new Services_JSON_Error(class_name($var). + " toJSON returned an object with a toJSON method."); + + } + + return $this->_encode( $recode ); + } + + $vars = get_object_vars($var); + + $properties = array_map(array($this, 'name_value'), + array_keys($vars), + array_values($vars)); + + foreach($properties as $property) { + if(Services_JSON::isError($property)) { + return $property; + } + } + + return '{' . join(',', $properties) . '}'; + + default: + return ($this->use & SERVICES_JSON_SUPPRESS_ERRORS) + ? 'null' + : new Services_JSON_Error(gettype($var)." can not be encoded as JSON string"); + } + } + + /** + * array-walking function for use in generating JSON-formatted name-value pairs + * + * @param string $name name of key to use + * @param mixed $value reference to an array element to be encoded + * + * @return string JSON-formatted name-value pair, like '"name":value' + * @access private + */ + function name_value($name, $value) + { + $encoded_value = $this->_encode($value); + + if(Services_JSON::isError($encoded_value)) { + return $encoded_value; + } + + return $this->_encode(strval($name)) . ':' . $encoded_value; + } + + /** + * reduce a string by removing leading and trailing comments and whitespace + * + * @param $str string string value to strip of comments and whitespace + * + * @return string string value stripped of comments and whitespace + * @access private + */ + function reduce_string($str) + { + $str = preg_replace(array( + + // eliminate single line comments in '// ...' form + '#^\s*//(.+)$#m', + + // eliminate multi-line comments in '/* ... */' form, at start of string + '#^\s*/\*(.+)\*/#Us', + + // eliminate multi-line comments in '/* ... */' form, at end of string + '#/\*(.+)\*/\s*$#Us' + + ), '', $str); + + // eliminate extraneous space + return trim($str); + } + + /** + * decodes a JSON string into appropriate variable + * + * @param string $str JSON-formatted string + * + * @return mixed number, boolean, string, array, or object + * corresponding to given JSON input string. + * See argument 1 to Services_JSON() above for object-output behavior. + * Note that decode() always returns strings + * in ASCII or UTF-8 format! + * @access public + */ + function decode($str) + { + $str = $this->reduce_string($str); + + switch (strtolower($str)) { + case 'true': + return true; + + case 'false': + return false; + + case 'null': + return null; + + default: + $m = array(); + + if (is_numeric($str)) { + // Lookie-loo, it's a number + + // This would work on its own, but I'm trying to be + // good about returning integers where appropriate: + // return (float)$str; + + // Return float or int, as appropriate + return ((float)$str == (integer)$str) + ? (integer)$str + : (float)$str; + + } elseif (preg_match('/^("|\').*(\1)$/s', $str, $m) && $m[1] == $m[2]) { + // STRINGS RETURNED IN UTF-8 FORMAT + $delim = $this->substr8($str, 0, 1); + $chrs = $this->substr8($str, 1, -1); + $utf8 = ''; + $strlen_chrs = $this->strlen8($chrs); + + for ($c = 0; $c < $strlen_chrs; ++$c) { + + $substr_chrs_c_2 = $this->substr8($chrs, $c, 2); + $ord_chrs_c = ord($chrs{$c}); + + switch (true) { + case $substr_chrs_c_2 == '\b': + $utf8 .= chr(0x08); + ++$c; + break; + case $substr_chrs_c_2 == '\t': + $utf8 .= chr(0x09); + ++$c; + break; + case $substr_chrs_c_2 == '\n': + $utf8 .= chr(0x0A); + ++$c; + break; + case $substr_chrs_c_2 == '\f': + $utf8 .= chr(0x0C); + ++$c; + break; + case $substr_chrs_c_2 == '\r': + $utf8 .= chr(0x0D); + ++$c; + break; + + case $substr_chrs_c_2 == '\\"': + case $substr_chrs_c_2 == '\\\'': + case $substr_chrs_c_2 == '\\\\': + case $substr_chrs_c_2 == '\\/': + if (($delim == '"' && $substr_chrs_c_2 != '\\\'') || + ($delim == "'" && $substr_chrs_c_2 != '\\"')) { + $utf8 .= $chrs{++$c}; + } + break; + + case preg_match('/\\\u[0-9A-F]{4}/i', $this->substr8($chrs, $c, 6)): + // single, escaped unicode character + $utf16 = chr(hexdec($this->substr8($chrs, ($c + 2), 2))) + . chr(hexdec($this->substr8($chrs, ($c + 4), 2))); + $utf8 .= $this->utf162utf8($utf16); + $c += 5; + break; + + case ($ord_chrs_c >= 0x20) && ($ord_chrs_c <= 0x7F): + $utf8 .= $chrs{$c}; + break; + + case ($ord_chrs_c & 0xE0) == 0xC0: + // characters U-00000080 - U-000007FF, mask 110XXXXX + //see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 + $utf8 .= $this->substr8($chrs, $c, 2); + ++$c; + break; + + case ($ord_chrs_c & 0xF0) == 0xE0: + // characters U-00000800 - U-0000FFFF, mask 1110XXXX + // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 + $utf8 .= $this->substr8($chrs, $c, 3); + $c += 2; + break; + + case ($ord_chrs_c & 0xF8) == 0xF0: + // characters U-00010000 - U-001FFFFF, mask 11110XXX + // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 + $utf8 .= $this->substr8($chrs, $c, 4); + $c += 3; + break; + + case ($ord_chrs_c & 0xFC) == 0xF8: + // characters U-00200000 - U-03FFFFFF, mask 111110XX + // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 + $utf8 .= $this->substr8($chrs, $c, 5); + $c += 4; + break; + + case ($ord_chrs_c & 0xFE) == 0xFC: + // characters U-04000000 - U-7FFFFFFF, mask 1111110X + // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 + $utf8 .= $this->substr8($chrs, $c, 6); + $c += 5; + break; + + } + + } + + return $utf8; + + } elseif (preg_match('/^\[.*\]$/s', $str) || preg_match('/^\{.*\}$/s', $str)) { + // array, or object notation + + if ($str{0} == '[') { + $stk = array(SERVICES_JSON_IN_ARR); + $arr = array(); + } else { + if ($this->use & SERVICES_JSON_LOOSE_TYPE) { + $stk = array(SERVICES_JSON_IN_OBJ); + $obj = array(); + } else { + $stk = array(SERVICES_JSON_IN_OBJ); + $obj = new stdClass(); + } + } + + array_push($stk, array('what' => SERVICES_JSON_SLICE, + 'where' => 0, + 'delim' => false)); + + $chrs = $this->substr8($str, 1, -1); + $chrs = $this->reduce_string($chrs); + + if ($chrs == '') { + if (reset($stk) == SERVICES_JSON_IN_ARR) { + return $arr; + + } else { + return $obj; + + } + } + + //print("\nparsing {$chrs}\n"); + + $strlen_chrs = $this->strlen8($chrs); + + for ($c = 0; $c <= $strlen_chrs; ++$c) { + + $top = end($stk); + $substr_chrs_c_2 = $this->substr8($chrs, $c, 2); + + if (($c == $strlen_chrs) || (($chrs{$c} == ',') && ($top['what'] == SERVICES_JSON_SLICE))) { + // found a comma that is not inside a string, array, etc., + // OR we've reached the end of the character list + $slice = $this->substr8($chrs, $top['where'], ($c - $top['where'])); + array_push($stk, array('what' => SERVICES_JSON_SLICE, 'where' => ($c + 1), 'delim' => false)); + //print("Found split at {$c}: ".$this->substr8($chrs, $top['where'], (1 + $c - $top['where']))."\n"); + + if (reset($stk) == SERVICES_JSON_IN_ARR) { + // we are in an array, so just push an element onto the stack + array_push($arr, $this->decode($slice)); + + } elseif (reset($stk) == SERVICES_JSON_IN_OBJ) { + // we are in an object, so figure + // out the property name and set an + // element in an associative array, + // for now + $parts = array(); + + if (preg_match('/^\s*(["\'].*[^\\\]["\'])\s*:/Uis', $slice, $parts)) { + // "name":value pair + $key = $this->decode($parts[1]); + $val = $this->decode(trim(substr($slice, strlen($parts[0])), ", \t\n\r\0\x0B")); + if ($this->use & SERVICES_JSON_LOOSE_TYPE) { + $obj[$key] = $val; + } else { + $obj->$key = $val; + } + } elseif (preg_match('/^\s*(\w+)\s*:/Uis', $slice, $parts)) { + // name:value pair, where name is unquoted + $key = $parts[1]; + $val = $this->decode(trim(substr($slice, strlen($parts[0])), ", \t\n\r\0\x0B")); + + if ($this->use & SERVICES_JSON_LOOSE_TYPE) { + $obj[$key] = $val; + } else { + $obj->$key = $val; + } + } + + } + + } elseif ((($chrs{$c} == '"') || ($chrs{$c} == "'")) && ($top['what'] != SERVICES_JSON_IN_STR)) { + // found a quote, and we are not inside a string + array_push($stk, array('what' => SERVICES_JSON_IN_STR, 'where' => $c, 'delim' => $chrs{$c})); + //print("Found start of string at {$c}\n"); + + } elseif (($chrs{$c} == $top['delim']) && + ($top['what'] == SERVICES_JSON_IN_STR) && + (($this->strlen8($this->substr8($chrs, 0, $c)) - $this->strlen8(rtrim($this->substr8($chrs, 0, $c), '\\'))) % 2 != 1)) { + // found a quote, we're in a string, and it's not escaped + // we know that it's not escaped becase there is _not_ an + // odd number of backslashes at the end of the string so far + array_pop($stk); + //print("Found end of string at {$c}: ".$this->substr8($chrs, $top['where'], (1 + 1 + $c - $top['where']))."\n"); + + } elseif (($chrs{$c} == '[') && + in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) { + // found a left-bracket, and we are in an array, object, or slice + array_push($stk, array('what' => SERVICES_JSON_IN_ARR, 'where' => $c, 'delim' => false)); + //print("Found start of array at {$c}\n"); + + } elseif (($chrs{$c} == ']') && ($top['what'] == SERVICES_JSON_IN_ARR)) { + // found a right-bracket, and we're in an array + array_pop($stk); + //print("Found end of array at {$c}: ".$this->substr8($chrs, $top['where'], (1 + $c - $top['where']))."\n"); + + } elseif (($chrs{$c} == '{') && + in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) { + // found a left-brace, and we are in an array, object, or slice + array_push($stk, array('what' => SERVICES_JSON_IN_OBJ, 'where' => $c, 'delim' => false)); + //print("Found start of object at {$c}\n"); + + } elseif (($chrs{$c} == '}') && ($top['what'] == SERVICES_JSON_IN_OBJ)) { + // found a right-brace, and we're in an object + array_pop($stk); + //print("Found end of object at {$c}: ".$this->substr8($chrs, $top['where'], (1 + $c - $top['where']))."\n"); + + } elseif (($substr_chrs_c_2 == '/*') && + in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) { + // found a comment start, and we are in an array, object, or slice + array_push($stk, array('what' => SERVICES_JSON_IN_CMT, 'where' => $c, 'delim' => false)); + $c++; + //print("Found start of comment at {$c}\n"); + + } elseif (($substr_chrs_c_2 == '*/') && ($top['what'] == SERVICES_JSON_IN_CMT)) { + // found a comment end, and we're in one now + array_pop($stk); + $c++; + + for ($i = $top['where']; $i <= $c; ++$i) + $chrs = substr_replace($chrs, ' ', $i, 1); + + //print("Found end of comment at {$c}: ".$this->substr8($chrs, $top['where'], (1 + $c - $top['where']))."\n"); + + } + + } + + if (reset($stk) == SERVICES_JSON_IN_ARR) { + return $arr; + + } elseif (reset($stk) == SERVICES_JSON_IN_OBJ) { + return $obj; + + } + + } + } + } + + /** + * @todo Ultimately, this should just call PEAR::isError() + */ + function isError($data, $code = null) + { + if (class_exists('pear')) { + return PEAR::isError($data, $code); + } elseif (is_object($data) && (get_class($data) == 'services_json_error' || + is_subclass_of($data, 'services_json_error'))) { + return true; + } + + return false; + } + + /** + * Calculates length of string in bytes + * @param string + * @return integer length + */ + function strlen8( $str ) + { + if ( $this->_mb_strlen ) { + return mb_strlen( $str, "8bit" ); + } + return strlen( $str ); + } + + /** + * Returns part of a string, interpreting $start and $length as number of bytes. + * @param string + * @param integer start + * @param integer length + * @return integer length + */ + function substr8( $string, $start, $length=false ) + { + if ( $length === false ) { + $length = $this->strlen8( $string ) - $start; + } + if ( $this->_mb_substr ) { + return mb_substr( $string, $start, $length, "8bit" ); + } + return substr( $string, $start, $length ); + } + +} + +if (class_exists('PEAR_Error')) { + + class Services_JSON_Error extends PEAR_Error + { + function Services_JSON_Error($message = 'unknown error', $code = null, + $mode = null, $options = null, $userinfo = null) + { + parent::PEAR_Error($message, $code, $mode, $options, $userinfo); + } + } + +} else { + + /** + * @todo Ultimately, this class shall be descended from PEAR_Error + */ + class Services_JSON_Error + { + function Services_JSON_Error($message = 'unknown error', $code = null, + $mode = null, $options = null, $userinfo = null) + { + + } + } + +} diff --git a/plugin/sms5/_common.php b/plugin/sms5/_common.php new file mode 100644 index 000000000..14553420b --- /dev/null +++ b/plugin/sms5/_common.php @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/plugin/sms5/ajax.sms_emoticon.php b/plugin/sms5/ajax.sms_emoticon.php new file mode 100644 index 000000000..7299bc157 --- /dev/null +++ b/plugin/sms5/ajax.sms_emoticon.php @@ -0,0 +1,70 @@ +encode($data) ); + } +} + +$page_size = 9; + +if (!$page) $page = 1; + +if (is_numeric($fg_no)) + $sql_group = " and fg_no='$fg_no' "; +else + $sql_group = ""; + +if ($st == 'all') { + $sql_search = "and (fo_name like '%{$sv}%' or fo_content like '%{$sv}%')"; +} else if ($st == 'name') { + $sql_search = "and fo_name like '%{$sv}%'"; +} else if ($st == 'content') { + $sql_search = "and fo_content like '%{$sv}%'"; +} else { + $sql_search = ''; +} + +$total_res = sql_fetch("select count(*) as cnt from {$g5['sms5_form_table']} where fg_member = 1 $sql_group $sql_search"); +$total_count = $total_res['cnt']; + +$total_page = (int)($total_count/$page_size) + ($total_count%$page_size==0 ? 0 : 1); +$page_start = $page_size * ( $page - 1 ); + +$vnum = $total_count - (($page-1) * $page_size); + +$group = array(); +$qry = sql_query("select * from {$g5['sms5_form_group_table']} where fg_member = 1 order by fg_name"); +while ($res = sql_fetch_array($qry)) array_push($group, $res); + +$res = sql_fetch("select count(*) as cnt from {$g5['sms5_form_table']} where fg_no=0"); +$no_count = $res['cnt']; + +$count = 1; +$qry = sql_query("select * from {$g5['sms5_form_table']} where fg_member = 1 $sql_group $sql_search order by fo_no desc limit $page_start, $page_size"); +$list_text = array(); + +for($k=0;$res = sql_fetch_array($qry);$k++) +{ + $tmp = sql_fetch("select fg_name from {$g5['sms5_form_group_table']} where fg_no='{$res['fg_no']}'"); + if (!$tmp) + $group_name = '미분류'; + else + $group_name = $tmp['fg_name']; + + $list_text[$k]['fo_no'] = $res['fo_no']; + $list_text[$k]['fo_content'] = $res['fo_content']; + $list_text[$k]['fo_content'] = $res['fo_content']; + $list_text[$k]['fo_name'] = cut_str($res['fo_name'],20); +} + +$arr_ajax_msg['error'] = ""; +$arr_ajax_msg['list_text'] = $list_text; +$arr_ajax_msg['page'] = $page; +$arr_ajax_msg['total_count'] = $total_count; +$arr_ajax_msg['total_page'] = $total_page; +die( json_encode($arr_ajax_msg) ); +?> \ No newline at end of file diff --git a/plugin/sms5/index.php b/plugin/sms5/index.php new file mode 100644 index 000000000..087803eb5 --- /dev/null +++ b/plugin/sms5/index.php @@ -0,0 +1,11 @@ + \ No newline at end of file diff --git a/plugin/sms5/skin/basic/img/ajax-loader.gif b/plugin/sms5/skin/basic/img/ajax-loader.gif new file mode 100644 index 000000000..96fefbc51 Binary files /dev/null and b/plugin/sms5/skin/basic/img/ajax-loader.gif differ diff --git a/plugin/sms5/skin/basic/img/box_ico.gif b/plugin/sms5/skin/basic/img/box_ico.gif new file mode 100644 index 000000000..9d57d3668 Binary files /dev/null and b/plugin/sms5/skin/basic/img/box_ico.gif differ diff --git a/plugin/sms5/skin/basic/img/scemo_ico.gif b/plugin/sms5/skin/basic/img/scemo_ico.gif new file mode 100644 index 000000000..625048e49 Binary files /dev/null and b/plugin/sms5/skin/basic/img/scemo_ico.gif differ diff --git a/plugin/sms5/skin/basic/mobile.css b/plugin/sms5/skin/basic/mobile.css new file mode 100644 index 000000000..24956c39b --- /dev/null +++ b/plugin/sms5/skin/basic/mobile.css @@ -0,0 +1,48 @@ +#sms5_send {position:relative} + +.sms5_box {position:relative;padding:10px;border-radius:5px;background:#fbec99} +.sms5_box .box_ico {position:absolute;top:20px;left:-7px;width:7px;height:13px;background:url('img/box_ico.gif') no-repeat} +.sms5_box .box_txt {border:0;background:transparent;word-break:break-all;resize:none;overflow:hidden} +.sms5_box .box_square {width:100px;height:90px} + +#send_write {padding:0 20px !important} +#send_write h2 {padding:0 0 10px} +#send_write .sms5_box {margin:0 0 5px;text-align:center} +#send_write .box_txt {width:90%;height:80px} +#wr_message_lbl {position:absolute;top:45px;left:48%;color:#999;font-size:0.95em;letter-spacing:-0.1em} + +.write_inner {position:relative;padding:10px 0;border-bottom:1px solid #efefef;zoom:1} +.write_inner:after {display:block;visibility:hidden;clear:both;content:''} +.write_inner h2 {margin:0;padding:0 0 20px !important} +.write_floater {position:absolute;top:10px;right:0;text-align:right} +.write_floater_btn {margin:0;padding:0;border:0;background:transparent;color:#999;font-size:0.95em;letter-spacing:-0.1em} + +#write_rcv {margin:0 0 10px} +#write_rcv strong {display:inline-block;margin:0 10px 0 0} +#write_reply label {display:inline-block;margin:0 10px 0 0;font-weight:bold} +#write_reply #mh_reply {padding:0 5px;width:90px;height:20px;border:1px solid #e9e9e9;text-align:center;line-height:1.8em} + +#write_rsv .rsv_line {display:block;height:10px} + +.write_scemo strong {display:block;margin:0 0 10px} +.write_scemo .scemo_btn {margin:0 0 1px;padding:10px 0;width:100%;border:0;background:#686868;color:#fff;text-align:center} +.write_scemo .scemo_list {display:none;letter-spacing:-4px} +.write_scemo .list_closer {margin:5px 0;text-align:right} +.write_scemo .list_closer_btn {margin:0;padding:10px 0;width:100%;border:0;background:#383838;color:#fff;letter-spacing:0} +.write_scemo .scemo_add {margin:0;padding:0;width:25%;height:40px;border:1px solid #e9e9e9;background:transparent;letter-spacing:0} +#write_sc .scemo_list {margin:0 0 20px} + +#sms_byte {position:absolute;top:-27px;right:0;color:#999} + +#send_emo {position:relative;padding:20px;border-top:1px solid #e9e9e9;background:#f7f7f7} +#send_emo h2 {margin:0 0 20px} +#send_emo .tmp_loading {display:block;padding:180px 0 0;text-align:center} +#send_emo #emo_sel {position:absolute;top:20px;right:20px;margin:0} +#send_emo .emo_list {margin:0;padding:0;list-style:none} +#send_emo li {float:left;margin:0 2% 10px 0;width:49%} +#send_emo li:nth-of-type(even) {margin:0 0 10px} +#send_emo .sms5_box {background:#fbec99} +#send_emo .box_ico {display:none} +#send_emo .box_txt {cursor:pointer} +#send_emo .emo_tit {display:block;height:20px;line-height:2em;overflow:hidden;text-overflow:ellipsis;white-space:nowrap} +#send_emo .btn_submit {padding:0 5px;height:24px;border:1px solid #ccc;background:#fafafa;color:#000;font-size:0.95em;vertical-align:middle;cursor:pointer} \ No newline at end of file diff --git a/plugin/sms5/skin/basic/style.css b/plugin/sms5/skin/basic/style.css new file mode 100644 index 000000000..36bb9c94f --- /dev/null +++ b/plugin/sms5/skin/basic/style.css @@ -0,0 +1,50 @@ +#sms5_send {position:relative} + +.sms5_box {position:relative;padding:10px;border-radius:5px;background:#fbec99} +.sms5_box .box_ico {position:absolute;top:20px;left:-7px;width:7px;height:13px;background:url('img/box_ico.gif') no-repeat} +.sms5_box .box_txt {border:0;background:transparent;word-break:break-all;resize:none;overflow:hidden} +.sms5_box .box_square {width:100px;height:90px} + +#send_write {padding:0 20px !important} +#send_write h2 {padding:0 0 10px} +#send_write .sms5_box {margin:0 0 5px;text-align:center} +#send_write .box_txt {width:390px;height:80px} +#wr_message_lbl {position:absolute;top:45px;left:200px;color:#999;font-size:0.95em;letter-spacing:-0.1em} + +.write_inner {position:relative;padding:10px 0;border-bottom:1px solid #efefef;zoom:1} +.write_inner:after {display:block;visibility:hidden;clear:both;content:''} +.write_inner h2 {margin:0;padding:0 0 10px !important} +.write_floater {position:absolute;top:15px;right:0;text-align:right} +.write_floater_btn {margin:0;padding:0;border:0;background:transparent;color:#999;font-size:0.95em;letter-spacing:-0.1em} + +#write_rcv {float:left;height:22px;line-height:1.8em} +#write_rcv strong {display:inline-block;margin:0 10px 0 0} +#write_reply {float:right} +#write_reply label {display:inline-block;margin:0 10px 0 0;font-weight:bold} +#write_reply #mh_reply {padding:0 5px;width:90px;height:20px;border:1px solid #e9e9e9;text-align:center;line-height:1.8em} + +.write_scemo {width:48%} +.write_scemo strong {display:block;margin:0 0 10px} +.write_scemo .scemo_list {letter-spacing:-4px} +.write_scemo .scemo_add {margin:0;padding:0;height:25px;border:1px solid #e9e9e9;background:transparent;letter-spacing:0} +#write_sc {float:left} +#write_sc .scemo_add {width:25px} +#write_emo {float:right} +#write_emo .scemo_list {text-align:right} +#write_emo .scemo_add {width:66px} +#write_emo .emo_long {} + +#sms_byte {position:absolute;top:-27px;right:0;color:#999} + +#send_emo {position:relative;padding:20px;border-top:1px solid #e9e9e9;background:#f7f7f7} +#send_emo h2 {margin:0 0 20px} +#send_emo .tmp_loading {display:block;padding:180px 0 0;text-align:center} +#send_emo #emo_sel {position:absolute;top:20px;right:20px;margin:0} +#send_emo .emo_list {margin:0;padding:0;list-style:none} +#send_emo li {float:left;margin:0 10px 10px 0 !important;margin:0 5px 10px 0;width:113px !important;width:110px} +#send_emo li:nth-of-type(3n) {margin:0 0 10px !important} +#send_emo .sms5_box {background:#fbec99} +#send_emo .box_ico {display:none} +#send_emo .box_txt {cursor:pointer} +#send_emo .emo_tit {display:block;height:20px;line-height:2em;overflow:hidden;text-overflow:ellipsis;white-space:nowrap} +#send_emo .btn_submit {padding:0 5px;height:24px;border:1px solid #ccc;background:#fafafa;color:#000;font-size:0.95em;vertical-align:middle;cursor:pointer} \ No newline at end of file diff --git a/plugin/sms5/skin/basic/write.skin.php b/plugin/sms5/skin/basic/write.skin.php new file mode 100644 index 000000000..632bdf272 --- /dev/null +++ b/plugin/sms5/skin/basic/write.skin.php @@ -0,0 +1,378 @@ +', 0); +?> + +
    +

    SMS 보내기

    + +
    +
    + + + +

    보낼내용

    +
    + + + +
    0 / 80 byte
    +
    + +
    + +
    + 수신회원 +
    + +
    + + readonly> +
    +
    + +
    +

    예약전송

    + +
    + + +
    + + 년 + 월 + 일 + 시 + 분 +
    + +
    +
    + 특수기호 +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    +
    + 이모티콘 +
    + + + + + + + + + + + + + + + +
    +
    +
    + +
    + + +
    +
    + +
    + + +
    +

    이모티콘 목록

    +
    + + +
    + +
      +
    + + + + +
    + + +
    + + + + \ No newline at end of file diff --git a/plugin/sms5/skin/basic/write_mobile.skin.php b/plugin/sms5/skin/basic/write_mobile.skin.php new file mode 100644 index 000000000..f8bdca77d --- /dev/null +++ b/plugin/sms5/skin/basic/write_mobile.skin.php @@ -0,0 +1,394 @@ +', 0); +?> + +
    +

    SMS 보내기

    + +
    +
    + + + +

    보낼내용

    +
    + + + +
    0 / 80 byte
    +
    + +
    + +
    + 수신회원 +
    + +
    + + readonly> +
    +
    + +
    +

    예약전송

    + +
    + + +
    + + 년 + 월 + + 일 + 시 + 분 +
    + +
    +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    +
    +
    + +
    +
    + + + + + + + + + + + + + + + +
    +
    +
    +
    + +
    + + +
    +
    + +
    + + +
    +

    이모티콘 목록

    +
    + + +
    + +
      +
    + + + + +
    + + +
    + + + + \ No newline at end of file diff --git a/plugin/sms5/sms5.lib.php b/plugin/sms5/sms5.lib.php new file mode 100644 index 000000000..7ff5fc61d --- /dev/null +++ b/plugin/sms5/sms5.lib.php @@ -0,0 +1,269 @@ +\n"; + for ($i=0; $i선택"; + $str .= option_selected($skins[$i], $selected); + } + $str .= ""; + return $str; +} + +if ( ! function_exists('array_overlap')) { + function array_overlap($arr, $val) { + for ($i=0, $m=count($arr); $i<$m; $i++) { + if ($arr[$i] == $val) + return true; + } + return false; + } +} +if ( ! function_exists('get_hp')) { + function get_hp($hp, $hyphen=1) + { + global $g5; + + if (!is_hp($hp)) return ''; + + if ($hyphen) $preg = "$1-$2-$3"; else $preg = "$1$2$3"; + + $hp = str_replace('-', '', trim($hp)); + $hp = preg_replace("/^(01[016789])([0-9]{3,4})([0-9]{4})$/", $preg, $hp); + + if ($g5['sms5_demo']) + $hp = '0100000000'; + + return $hp; + } +} +if ( ! function_exists('is_hp')) { + function is_hp($hp) + { + $hp = str_replace('-', '', trim($hp)); + if (preg_match("/^(01[016789])([0-9]{3,4})([0-9]{4})$/", $hp)) + return true; + else + return false; + } +} +if ( ! function_exists('alert_just')) { + // 경고메세지를 경고창으로 + function alert_just($msg='', $url='') + { + global $g5; + + if (!$msg) $msg = '올바른 방법으로 이용해 주십시오.'; + + //header("Content-Type: text/html; charset=$g5[charset]"); + echo ""; + echo ""; + exit; + } +} + +if ( ! function_exists('utf2euc')) { + function utf2euc($str) { + return iconv("UTF-8","cp949//IGNORE", $str); + } +} +if ( ! function_exists('is_ie')) { + function is_ie() { + return isset($_SERVER['HTTP_USER_AGENT']) && (strpos($_SERVER['HTTP_USER_AGENT'], 'Trident') !== false || strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false); + } +} + +/** + * SMS 발송을 관장하는 메인 클래스이다. + * + * 접속, 발송, URL발송, 결과등의 실질적으로 쓰이는 모든 부분이 포함되어 있다. + */ + +class SMS5 extends SMS { + var $Log = array(); + + function SMS_con($sms_server,$sms_id,$sms_pw,$port) { + $this->ID=$sms_id; // 계약 후 지정 + $this->PWD=$sms_pw; // 계약 후 지정 + $this->SMS_Server=$sms_server; + $this->SMS_Port=$port; + $this->ID = spacing($this->ID,10); + $this->PWD = spacing($this->PWD,10); + } + + /** + * 발송번호의 값이 정확한 값인지 확인합니다. + * + * @param strDest 발송번호 배열입니다. + * nCount 배열의 크기입니다. + * @return 처리결과입니다. + */ + function CheckCommonTypeDest($strDest, $nCount) { + for ($i=0; $i<$nCount; $i++) { + $hp_number = preg_replace("/[^0-9]/","",$strDest[$i]['bk_hp']); + if (strlen($hp_number)<10 || strlen($hp_number)>11) return "휴대폰 번호가 틀렸습니다"; + + $CID=substr($hp_number,0,3); + if ( preg_match("/[^0-9]/",$CID) || ($CID!='010' && $CID!='011' && $CID!='016' && $CID!='017' && $CID!='018' && $CID!='019') ) return "휴대폰 앞자리 번호가 잘못되었습니다"; + } + } + + /** + * 회신번호의 값이 정확한 값인지 확인합니다. + * + * @param strDest 회신번호입니다. + * @return 처리결과입니다. + */ + function CheckCommonTypeCallBack($strCallBack) { + if (preg_match("/[^0-9]/", $strCallBack)) return "회신 전화번호가 잘못되었습니다"; + } + + + /** + * 예약날짜의 값이 정확한 값인지 확인합니다. + * + * @param text 원하는 문자열입니다. + * size 원하는 길이입니다. + * @return 처리결과입니다. + */ + function CheckCommonTypeDate($strDate) { + $strDate=preg_replace("/[^0-9]/","",$strDate); + if ($strDate) { + if (!checkdate(substr($strDate,4,2),substr($strDate,6,2),substr($rsvTime,0,4))) return "예약날짜가 잘못되었습니다"; + if (substr($strDate,8,2)>23 || substr($strDate,10,2)>59) return "예약시간이 잘못되었습니다"; + } + } + + + /** + * URL콜백용으로 메세지 크기를 수정합니다. + * + * @param url URL 내용입니다. + * msg 결과메시지입니다. + * desk 문자내용입니다. + */ + function CheckCallCenter($url, $dest, $data) { + switch (substr($dest,0,3)) { + case '010': //20바이트 + return cut_char($data,20); + break; + case '011': //80바이트 + return cut_char($data,80); + break; + case '016': // 80바이트 + return cut_char($data,80); + break; + case '017': // URL 포함 80바이트 + return cut_char($data,80 - strlen($url)); + break; + case '018': // 20바이트 + return cut_char($data,20); + break; + case '019': // 20바이트 + return cut_char($data,20); + break; + default: + return cut_char($data,80); + break; + } + } + function Add($strDest, $strCallBack, $strCaller, $strURL, $strMessage, $strDate="", $nCount) { + global $g5; + + $Error = $this->CheckCommonTypeDest($strDest, $nCount); + $Error = $this->CheckCommonTypeCallBack($strCallBack); + $Error = $this->CheckCommonTypeDate($strDate); + + $strCallBack = spacing($strCallBack,11); + $strCaller = spacing($strCaller,10); + $strDate = spacing($strDate,12); + + + for ($i=0; $i<$nCount; $i++) { + $hp_number = spacing($strDest[$i]['bk_hp'],11); + $strData = $strMessage; + if( !empty($strDest[$i]['bk_name']) ){ + $strData = str_replace("{이름}", $strDest[$i]['bk_name'], $strData); + } + // 아이코드에서는 문자에 utf-8 인코딩 형식을 아직 지원하지 않는다. + $strData = iconv('utf-8', "euc-kr", stripslashes($strData)); + + if (!$strURL) { + $strData = spacing(cut_char($strData,80),80); + + $this->Data[$i] = '01144 '.$this->ID.$this->PWD.$hp_number.$strCallBack.$strCaller.$strDate.$strData; + } else { + $strURL = spacing($strURL,50); + $strData = spacing($this->CheckCallCenter($strURL, $hp_number, $strData),80); + + $this->Data[$i] = '05173 '.$this->ID.$this->PWD.$hp_number.$strCallBack.$strURL.$strDate.$strData; + } + } + return true; // 수정대기 + } + + function Send() { + global $g5; + + $count = 1; + + if ($g5['sms5_demo_send']) { + foreach($this->Data as $puts) { + if (rand(0,10)) { + $phone = substr($puts,26,11); + $code = '47022497 '; + } else { + $phone = substr($puts,26,11); + $code = 'Error(02)'; + } + $this->Result[] = "$phone:$code"; + $this->Log[] = $puts; + } + $this->Data = ""; + return true; + exit; + } + + $fsocket=fsockopen($this->SMS_Server,$this->SMS_Port); + if (!$fsocket) return false; + set_time_limit(300); + + ## php4.3.10일경우 + ## zend 최신버전으로 업해주세요.. + ## 또는 69번째 줄을 $this->Data as $tmp => $puts 로 변경해 주세요. + + foreach($this->Data as $puts) { + $dest = substr($puts,26,11); + fputs($fsocket, $puts); + while(!$gets) { + $gets = fgets($fsocket,30); + } + if (substr($gets,0,19) == "0223 00".$dest) { + $this->Result[] = $dest.":".substr($gets,19,10); + $this->Log[] = $puts; + } else { + $this->Result[$dest] = $dest.":Error(".substr($gets,6,2).")"; + $this->Log[] = $puts; + } + $gets = ""; + + // 1천건씩 전송 후 5초 쉼 + if ($count++%1000 == 0) sleep(5); + } + fclose($fsocket); + $this->Data = ""; + return true; + } +} +?> \ No newline at end of file diff --git a/plugin/sms5/write.php b/plugin/sms5/write.php new file mode 100644 index 000000000..dc250dcb9 --- /dev/null +++ b/plugin/sms5/write.php @@ -0,0 +1,72 @@ + 0 && $is_admin != 'super') { + if ($total >= $sms5['cf_day_count']) { + $err = "하루에 보낼수 있는 문자갯수(".number_format($sms5['cf_day_count'])." 건)를 초과하였습니다."; + alert_close($err); + } +} + +// 포인트 검사 +if (!$err and $sms5['cf_point'] > 0 && $is_admin != 'super') { + if ($sms5['cf_point'] > $member['mb_point']) { + $err = "보유하신 포인트(".number_format($member['mb_point'])." 포인트)가 없거나 모자라서\\n\\n문자전송(".number_format($sms5['cf_point'])." 포인트)이 불가합니다.\\n\\n포인트를 적립하신 후 다시 시도 해 주십시오."; + alert_close($err); + } +} + +// 특정회원에게 문자 전송 +if ($mb_id) { + $mb = get_member($mb_id); + if (!$mb['mb_hp']) alert_close("회원 휴대폰번호가 없습니다."); + if (!$mb['mb_open']) alert_close("정보를 공개하지 않았습니다."); + if (!$mb['mb_sms']) alert_close("SMS 수신여부가 비활성화 되어 있습니다."); + //$hp = $mb['mb_hp']; +} + +$g5['title'] = "문자전송"; + +$token = get_token(); + +$emoticon_group = array(); +$qry = sql_query("select * from {$g5['sms5_form_group_table']} where fg_member = 1 order by fg_name"); +while ($res = sql_fetch_array($qry)) array_push($emoticon_group, $res); + +$action_url = "./write_update.php"; + +if( G5_IS_MOBILE ){ + $write_skin_page = "/write_mobile.skin.php"; +} else { + $write_skin_page = "/write.skin.php"; +} +include_once ($sms5_skin_path.$write_skin_page); +echo PHP_EOL.''.PHP_EOL; +?> \ No newline at end of file diff --git a/plugin/sms5/write_update.php b/plugin/sms5/write_update.php new file mode 100644 index 000000000..735004fc7 --- /dev/null +++ b/plugin/sms5/write_update.php @@ -0,0 +1,157 @@ + 0 && $is_admin != 'super') { + $row = sql_fetch(" select count(*) as cnt from {$g5['sms5_member_history_table']} where mb_id='{$member['mb_id']}' and date_format(mh_datetime, '%Y-%m-%d') = '".G5_TIME_YMD."' "); + if ($row['cnt'] + $total > $sms5['cf_day_count']) { + alert("하루에 보낼수 있는 문자갯수(".number_format($sms5['cf_day_count']).")를 초과하였습니다."); + } +} + +// 포인트 검사 +if ($sms5['cf_point'] > 0 && $is_admin != 'super') { + $minus_point = $sms5['cf_point'] * $total; + if ($minus_point > $member['mb_point']) + alert("보유하신 포인트(".number_format($member['mb_point']).")가 없거나 모자라서 문자전송(".number_format($minus_point).")이 불가합니다.\\n\\n포인트를 적립하신 후 다시 시도 해 주십시오."); +} else + $minus_point = 0; + +// 예약전송 +if ($mh_by && $mh_bm && $mh_bd && $mh_bh && $mh_bi) { + $mh_booking = "$mh_by-$mh_bm-$mh_bd $mh_bh:$mh_bi:00"; + $booking = $mh_by.$mh_bm.$mh_bd.$mh_bh.$mh_bi; +} else { + $mh_booking = ''; + $booking = ''; +} + +$SMS = new SMS5; +$SMS->SMS_con($config['cf_icode_server_ip'], $config['cf_icode_id'], $config['cf_icode_pw'], $config['cf_icode_server_port']); + +$result = $SMS->Add($mh_hp, $mh_reply, '', '', $mh_message, $booking, $total); + +$is_success = null; + +if ($result) +{ + $result = $SMS->Send(); + + if ($result) //SMS 서버에 접속했습니다. + { + foreach ($SMS->Result as $result) + { + list($hp, $code) = explode(":", $result); + + if (substr($code,0,5) == "Error") + { + $is_success = false; + + switch (substr($code,6,2)) { + case '02': // "02:형식오류" + $mh_log = "형식이 잘못되어 전송이 실패하였습니다."; + break; + case '23': // "23:인증실패,데이터오류,전송날짜오류" + $mh_log = "데이터를 다시 확인해 주시기바랍니다."; + break; + case '97': // "97:잔여코인부족" + $mh_log = "잔여코인이 부족합니다."; + break; + case '98': // "98:사용기간만료" + $mh_log = "사용기간이 만료되었습니다."; + break; + case '99': // "99:인증실패" + $mh_log = "인증 받지 못하였습니다. 계정을 다시 확인해 주세요."; + break; + default: // "미 확인 오류" + $mh_log = "알 수 없는 오류로 전송이 실패하었습니다."; + break; + } + } + else + { + $is_success = true; + $mh_log = "문자전송:".get_hp($hp, 1); + } + + $hp = get_hp($hp, 1); + $log = array_shift($SMS->Log); + sql_query("insert into {$g5['sms5_member_history_table']} set mb_id='{$member['mb_id']}', mh_reply='$mh_reply', mh_hp='$hp', mh_datetime='".G5_TIME_YMDHIS."', mh_booking='$mh_booking', mh_log='$mh_log', mh_ip='".$_SERVER['REMOTE_ADDR']."'"); + + if ($is_admin == 'super') + $sms5['cf_point'] = 0; + + if ($is_success) + insert_point($member['mb_id'], (-1) * $sms5['cf_point'], "$mh_log"); + + } + $SMS->Init(); // 보관하고 있던 결과값을 지웁니다. + } + else alert("에러: SMS 서버와 통신이 불안정합니다."); +} +else alert("에러: SMS 데이터 입력도중 에러가 발생하였습니다."); + +alert_close("$total 건의 문자메세지 전송을 완료하였습니다."); +?> \ No newline at end of file