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

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

· 9년 전 · 269

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

댓글 작성

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

로그인하기

게시글 목록

번호 제목
12211
12210
12208
12207
12206
12205
20383
12204
12203
12202
12201
12199
350
12197
12196
12195
12193
12190
12189
12188
12187
12186
12185
12183
12182