테스트 사이트 - 개발 중인 베타 버전입니다

휴대폰번호, 전화번호, 이메일주소 노출방지 함수

· 14년 전 · 6034 · 4
// 전화번호, 휴대폰번호 노출방지
function get_privacy_hidden($str)
{
    // 휴대폰번호 노출 방지
    $str = preg_replace("#01[016789][^\d]*\d{3,4}[^\d]*\d{4}#", "<span class='cloudy small'>*** 휴대폰번호 노출금지 ***</span>", $str);
    $str = preg_replace("#공일[공일이삼사오육칠팔구][^\d]*[공일이삼사오육칠팔구]{3,4}[^\d][공일이삼사오육칠팔구]{4}#", "<span class='cloudy small'>휴대폰번호 노출금지 ***</span>", $str);
    // 전화번호 노출 방지
    $str = preg_replace("#0(2|31|32|33|41|42|43|51|52|53|54|55|60|61|62|63|64|70|80)[^\d]*\d{3,4}[^\d]*\d{4}#", "<span class='cloudy small'>*** 전화번호 노출금지 ***</span>", $str);
    // 이메일주소 노출 방지
    $str = preg_replace("#<a href=[\"\']mailto:.*[\"\'][^>]*>(.*)?</a>#i", "$1", $str);
    $str = preg_replace("#((\w+\.)*\w+@(\w+\.)+[A-Za-z]+)#", "<span class='cloudy small'>*** 이메일주소 노출금지 ***</span>", $str);
    return $str;
}

댓글 작성

댓글을 작성하시려면 로그인이 필요합니다.

로그인하기

댓글 4개

14년 전
어디에 추가해야 하나요?
14년 전
좋은팁 감사합니다
14년 전
어디에 추가해야하나요 common.lib 가 맞나요 ^^*
이거 어디에다 추가 해야 하나요... common.lib.php 넣어도 그대로 나오던데...

게시글 목록

번호 제목
34021
33994
33922
33895
33889
33882
33868
33863
33859
33857
33849
33842
33835
33830
33828
33807
33797
33796
33791
33786