<?php
$ipCheck = false;
$compareIp = array();

$remote = $_SERVER[REMOTE_ADDR];
$remoteIp = explode(".", $remote);

$result = array('1.1.1.*','2.2.2.2');

foreach($result as $key) {
    $ip = explode(".", $key);
    if($key == "*" || $key == $remote) {
        $ipCheck = true;
        break;
	}

	for($i = 0;$i < count($ip);$i++) {
		if($ip[$i] != $remoteIp[$i] && $ip[$i] != "*") {
			continue;
		} else {
			$compareIp[$i] = true;
		}
	}

	if(@$compareIp[0] && @$compareIp[1] && @$compareIp[2] && @$compareIp[3]) {
		$ipCheck = true;
		break;  
	}
}

if($ipCheck != true) {
	echo "접속제한 IP입니다.";
	exit;
}
?>
블로그 이미지

디츠

“말은 쉽지, 코드를 보여줘.” “Talk is cheap. Show me the code.” – 리누스 토르발스(Linus Torvalds)

,