웹 서버를 이용한 인증 정보
PHP 웹 서버를 이용한 인증본문
웹서버를 이용한 인증 (apache용)
<?
$id = "test"; // user id
$pw = "test"; // password
if(!isset($_SERVER['PHP_AUTH_USER'])) {
$id = "test"; // user id
$pw = "test"; // password
if(!isset($_SERVER['PHP_AUTH_USER'])) {
header('WWW-Authenticate: Basic realm="My Private Stuff"');
header('HTTP/1.0 401 Unauthorized');
exit;
}else if (isset($_SERVER['PHP_AUTH_USER'])) {
header('HTTP/1.0 401 Unauthorized');
exit;
}else if (isset($_SERVER['PHP_AUTH_USER'])) {
if (($_SERVER['PHP_AUTH_USER'] != $id) || ($_SERVER['PHP_AUTH_PW'] != $pw)) {
header('WWW-Authenticate: Basic realm="Realm-Name"');
if(substr($SERVER_SOFTWARE, 0, 9) == "Microsoft"){
header('Status: 401 Unauthorized');
} else {
header('HTTP/1.0 401 Unauthorized');
}
echo "누구냐 넌...";
exit;
}
else {
echo "올바르게 접근했습니다.";
}
}
?>
header('WWW-Authenticate: Basic realm="Realm-Name"');
if(substr($SERVER_SOFTWARE, 0, 9) == "Microsoft"){
header('Status: 401 Unauthorized');
} else {
header('HTTP/1.0 401 Unauthorized');
}
echo "누구냐 넌...";
exit;
}
else {
echo "올바르게 접근했습니다.";
}
}
?>
[이 게시물은 관리자님에 의해 2011-10-31 17:12:10 PHP & HTML에서 이동 됨]
추천
1
1
댓글 1개
와 좋아요 아주 좋아요 ~~