@(include_once G5_PLUGIN_PATH . "/sms5/JSON.php"); if (!function_exists('json_encode')) { function json_encode($data) { $json = new Services_JSON(); return $json->encode($data); } } ajax_auth_check($auth[$sub_menu], "r"); $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);
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); $log = @iconv('euc-kr', 'utf-8', $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='" . addslashes($hs_memo) . "', hs_log='" . addslashes($log) . "'", false); } $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 데이터 입력도중 에러가 발생하였습니다."); } ?>
$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 {
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='" . addslashes($name) . "', bk_hp='{$hp}', bk_receipt=1, bk_datetime='" . G5_TIME_YMDHIS . "'");
$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='" . addslashes($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) {
case 'h': // 개별 휴대폰 번호 입력 $item[$i] = explode(':', $item[$i]); $hp = get_hp($item[$i][0], 0); $name = $item[$i][0]; if (array_overlap($hps, $hp)) { $overlap++; continue; } array_push($list, array('bk_hp' => $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("중복되는 휴대폰번호가 없습니다. "); }
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);