휴대폰 번호 만들기를 hyphen_hp_number 함수로 처리

This commit is contained in:
gnuboard
2013-04-26 13:53:25 +09:00
parent ba2874565c
commit da3c09523c
5 changed files with 49 additions and 71 deletions

View File

@ -1,6 +1,7 @@
<?php
$sub_menu = "200100";
include_once('./_common.php');
include_once("./_common.php");
include_once(G4_LIB_PATH."/register.lib.php");
if ($w == 'u')
check_demo();
@ -13,60 +14,47 @@ if ($member['mb_password'] != sql_password($_POST['admin_password'])) {
alert('패스워드가 다릅니다.');
}
$mb_id = mysql_real_escape_string(trim($_POST['mb_id']));
$mb_id = escape_trim($_POST['mb_id']);
// 핸드폰번호 체크
$mb_hp = $_POST['mb_hp'];
if($mb_hp) {
$mb_hp = preg_replace("/[^0-9]/", "", $mb_hp);
$hp_len = strlen($mb_hp);
if($hp_len == 10) {
$mb_hp = preg_replace("/([0-9]{3})([0-9]{3})([0-9]{4})/", "\\1-\\2-\\3", $mb_hp);
} else if($hp_len == 11) {
$mb_hp = preg_replace("/([0-9]{3})([0-9]{4})([0-9]{4})/", "\\1-\\2-\\3", $mb_hp);
} else {
alert('핸드폰번호를 올바르게 입력해 주십시오.');
}
// 중복체크
$sql = " select count(*) as cnt from {$g4['member_table']} where mb_hp = '$mb_hp' and mb_id <> '$mb_id' ";
$row = sql_fetch($sql);
if($row['cnt'])
alert('다른 회원이 사용 중인 핸드폰번호입니다.');
$result = exist_mb_hp($mb_hp, $mb_id);
if ($result)
alert($result);
}
$sql_common = " mb_name = '{$_POST['mb_name']}',
mb_nick = '{$_POST['mb_nick']}',
mb_email = '{$_POST['mb_email']}',
mb_homepage = '{$_POST['mb_homepage']}',
mb_tel = '{$_POST['mb_tel']}',
mb_hp = '$mb_hp',
mb_zip1 = '{$_POST['mb_zip1']}',
mb_zip2 = '{$_POST['mb_zip2']}',
mb_addr1 = '{$_POST['mb_addr1']}',
mb_addr2 = '{$_POST['mb_addr2']}',
mb_birth = '{$_POST['mb_birth']}',
mb_sex = '{$_POST['mb_sex']}',
mb_signature = '{$_POST['mb_signature']}',
mb_leave_date = '{$_POST['mb_leave_date']}',
mb_intercept_date='{$_POST['mb_intercept_date']}',
mb_memo = '{$_POST['mb_memo']}',
mb_mailling = '{$_POST['mb_mailling']}',
mb_sms = '{$_POST['mb_sms']}',
mb_open = '{$_POST['mb_open']}',
mb_profile = '{$_POST['mb_profile']}',
mb_level = '{$_POST['mb_level']}',
mb_1 = '{$_POST['mb_1']}',
mb_2 = '{$_POST['mb_2']}',
mb_3 = '{$_POST['mb_3']}',
mb_4 = '{$_POST['mb_4']}',
mb_5 = '{$_POST['mb_5']}',
mb_6 = '{$_POST['mb_6']}',
mb_7 = '{$_POST['mb_7']}',
mb_8 = '{$_POST['mb_8']}',
mb_9 = '{$_POST['mb_9']}',
mb_10 = '{$_POST['mb_10']}' ";
$sql_common = " mb_name = '{$_POST['mb_name']}',
mb_nick = '{$_POST['mb_nick']}',
mb_email = '{$_POST['mb_email']}',
mb_homepage = '{$_POST['mb_homepage']}',
mb_tel = '{$_POST['mb_tel']}',
mb_hp = '$mb_hp',
mb_zip1 = '{$_POST['mb_zip1']}',
mb_zip2 = '{$_POST['mb_zip2']}',
mb_addr1 = '{$_POST['mb_addr1']}',
mb_addr2 = '{$_POST['mb_addr2']}',
mb_birth = '{$_POST['mb_birth']}',
mb_sex = '{$_POST['mb_sex']}',
mb_signature = '{$_POST['mb_signature']}',
mb_leave_date = '{$_POST['mb_leave_date']}',
mb_intercept_date='{$_POST['mb_intercept_date']}',
mb_memo = '{$_POST['mb_memo']}',
mb_mailling = '{$_POST['mb_mailling']}',
mb_sms = '{$_POST['mb_sms']}',
mb_open = '{$_POST['mb_open']}',
mb_profile = '{$_POST['mb_profile']}',
mb_level = '{$_POST['mb_level']}',
mb_1 = '{$_POST['mb_1']}',
mb_2 = '{$_POST['mb_2']}',
mb_3 = '{$_POST['mb_3']}',
mb_4 = '{$_POST['mb_4']}',
mb_5 = '{$_POST['mb_5']}',
mb_6 = '{$_POST['mb_6']}',
mb_7 = '{$_POST['mb_7']}',
mb_8 = '{$_POST['mb_8']}',
mb_9 = '{$_POST['mb_9']}',
mb_10 = '{$_POST['mb_10']}' ";
if ($w == '')
{

View File

@ -1969,4 +1969,12 @@ function html_end()
}
return preg_replace('#(</title>)#', "$1$stylesheet", $buffer);
}
// 휴대폰번호의 숫자만 취한 후 중간에 하이픈(-)을 넣는다.
function hyphen_hp_number($hp)
{
$hp = preg_replace("/[^0-9]/", "", $hp);
return preg_replace("/([0-9]{3})([0-9]{3,4})([0-9]{4})$/", "\\1-\\2-\\3", $hp);
}
?>

View File

@ -159,14 +159,8 @@ function valid_mb_hp($reg_mb_hp)
function exist_mb_hp($reg_mb_hp, $reg_mb_id)
{
global $g4;
$reg_mb_hp = preg_replace("/[^0-9]/", "", $reg_mb_hp);
$len = strlen($reg_mb_hp);
if($len == 10)
$reg_mb_hp = preg_replace("/([0-9]{3})([0-9]{3})([0-9]{4})/", "\\1-\\2-\\3", $reg_mb_hp);
else if($len == 11)
$reg_mb_hp = preg_replace("/([0-9]{3})([0-9]{4})([0-9]{4})/", "\\1-\\2-\\3", $reg_mb_hp);
else
return "핸드폰번호를 올바르게 입력해 주십시오.";
$reg_mb_hp = hyphen_hp_number($reg_mb_hp);
$sql = "select count(*) as cnt from {$g4['member_table']} where mb_hp = '$reg_mb_hp' and mb_id <> '$reg_mb_id' ";
$row = sql_fetch($sql);

View File

@ -5,13 +5,7 @@ if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가
if ($msg = valid_mb_hp($mb_hp)) alert($msg, "", true, true);
if ($msg = exist_mb_hp($mb_hp, $mb_id)) alert($msg, "", true, true);
$reg_hp = preg_replace("/[^0-9]/", "", $mb_hp);
$hp_len = strlen($reg_hp);
if($hp_len == 10)
$reg_mb_hp = preg_replace("/([0-9]{3})([0-9]{3})([0-9]{4})/", "\\1-\\2-\\3", $reg_hp);
else if($hp_len == 11)
$reg_mb_hp = preg_replace("/([0-9]{3})([0-9]{4})([0-9]{4})/", "\\1-\\2-\\3", $reg_hp);
$reg_hp = hyphen_hp_number($mb_hp);
/* ======================================================================================================= */
/* = 휴대폰인증 및 성인인증 = */

View File

@ -163,13 +163,7 @@ else if( $cert_enc_use != "Y" )
$ct_cert->mf_clear();
// 휴대폰번호 포맷변경
$phone_no = preg_replace("/[^0-9]/", "", $phone_no);
$hp_len = strlen($phone_no);
if($hp_len == 10)
$phone_no = preg_replace("/([0-9]{3})([0-9]{3})([0-9]{4})/", "\\1-\\2-\\3", $phone_no);
else if($hp_len == 11)
$phone_no = preg_replace("/([0-9]{3})([0-9]{4})([0-9]{4})/", "\\1-\\2-\\3", $phone_no);
$phone_no = hyphen_hp_number($phone_no);
?>
<script>