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

웹서버(아파치)를 이용한 인증 입니다.

· 9년 전 · 270

<?
$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'])) {
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 "올바르게 접근했습니다.";
}
}
?>

댓글 작성

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

로그인하기

게시글 목록

번호 제목
12245
12244
12243
12241
12239
12238
12237
12233
12232
12230
355
12227
12226
12225
353
12221
12220
12219
12218
12217
12216
12215
12214
12213
12212