Skip to content

나이를 알아 내어 성인인증을 하는 소스

MintState November 10, 2008 at 1:33 PM Views 15680

나이를 알아 내어 성인인증을 하는 소스

* 주민번호 앞자리를 이용하여 성인인증

$_auth = get_age2($_sn,'18');
//나이를 알아내는 함수 - 주민번호 앞자리 사용
//return이 1이면 인증 0이면 미인증
function get_age2($_sn,$_idx)	{
		$_year = substr($_sn,0,2);

		$_toYear = substr(date("Y"),2,2);
		if($_year > $_toYear) { 
				$birth = "19".$_year;
		}	else {
				$birth = "20".$_year;
		}
		$me_age = date("Y") - $birth;
		if($me_age < $_idx) {
				$_auth = 0;
		} else {
				$_days = substr($_sn,2,4);
				if($_days > date("md")) {
						$_auth = 0;
				} else {
						$_auth = 1;
				}
		}
		return $_auth;
}

* 년도를 사용하여 나이를 리턴

//나이를 알아내는 함수
// 1977형태나 77형태 모두 사용가능. 
function get_age($_year)	{
		if($_year > 100) {
				$me_age = date("Y") - $_year;
		} else {
				$_toYear = substr(date("Y"),2,2);
				if($_year > $_toYear) { 
						$birth = "19".$_year;
				}	else {
						$birth = "20".$_year;
				}
				$me_age = date("Y") - $birth;
		}
		return $me_age;
}
Share X Facebook LINE QR code

0 comments

Be the first to comment.