/home/mjc1/public_html/j3demo/shop/ajax.preg_replace.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
include_once("./_common.php");

if(
$vt=='sn'){
    
$vv preg_replace("/[^0-9]/"""$vv);
    if(
strlen($vv)==10){
        
$vx substr($vv,0,3)."-".substr($vv,3,2)."-".substr($vv,5,6);
    } else if(
strlen($vv)==13){
        
$vx substr($vv,0,6)."-".substr($vv,6,7);
    }
    if(
$config['comp_sn_dup']=='0'){
        
$sql "select count(*) as cnt from customers where comp_sn = '{$vx}' ";
        
$res mysql_query($sql,$connect_j3);
        
$info mysql_fetch_array($res);
        if(
$info['cnt']>0){
            echo 
"0^이미 사용되고 있는 사업자번호 입니다.";
        } else {
            echo 
$vx;
        }
    } else {
        echo 
$vx;
    }
}

if(
$vt=='sn_office'){
    
$vv preg_replace("/[^0-9]/"""$vv);
    if(
strlen($vv)==10){
        
$vx substr($vv,0,3)."-".substr($vv,3,2)."-".substr($vv,5,6);
    } else if(
strlen($vv)==13){
        
$vx substr($vv,0,6)."-".substr($vv,6,7);
    }
    echo 
$vx;
}

if(
$vt=='hp'){
    
$vv preg_replace("/[^0-9]/"""$vv);
    if(
substr($vv,0,2)=='02'){
        echo 
preg_replace("/([0-9]{2})([0-9]{3,4})([0-9]{4})$/""\\1-\\2-\\3"$vv);
    } else if(
strlen($vv)==8){
        echo 
preg_replace("/([0-9]{4})([0-9]{4})$/""\\1-\\2"$vv);
    } else {
        echo 
preg_replace("/([0-9]{3})([0-9]{3,4})([0-9]{4})$/""\\1-\\2-\\3"$vv);
    }
}

if(
$vt=='number'){
    
$vv preg_replace("/[^-0-9\.]/"""$vv);
   if(
$vv==''){
        echo 
"1";
    } else {
        echo 
number_format($vv);
    }
}
?>