일반문서 권한 제한, 문서 접근시 로그인후 레벨별로 접근할 수 있도록 하려고 합니다. 채택완료
그누보드5, 영카트5 입니다.
일반문서(html, php)를 만들었습니다.
모든 문서 제일 상단에
include_once('./_common.php');
?>
를 넣었습니다. 그리고 아래와 같은 코드를 입력했습니다.
레벨별로 문서 접근 제한을 두려고 합니다.
아래 코드에 무슨 문제가 있나요.
=============================
방법1)
if ($is_guest) { ?>
alert('권한이 없습니다. 회원이시라면 로그인 후 이용해주세요.^^');
location = 'http://~~~~~.com/bbs/login.php">http://~~~~~.com/bbs/login.php';
} ?>
aaaaaaaaa
=============================
방법2)
if ($member['mb_level'] < 3) { ?>
alert('권한이 없습니다');
location = '=G5_PATH?>/bbs/login.php';
} ?>
aaaaaaaaa
=============================
방법3)
if ($member[mb_level] < 9) // 회원의 접근 권한 조정
{
echo "";
exit;
}
?>
aaaaaaaaa
=============================
방법4)
= '3') { // 레벨3 이상 ?>
aaaaaaaaa
=============================
방법5)
include_once('./_common.php');
print_r2($member);
$member = get_member($ss_mb_id);
if ($member[mb_level] < 9 || $member[mb_id] == '') // 회원의 접근 권한 조정
{
alert('죄송합니다. 정회원만 이용하실 수 있습니다');
exit;
}
?>
aaaaaaaaa
=============================
방법6)
include_once("./_common.php");
if (!$is_member||($member[mb_level]<3)) {
alert("회원레벨3이 아닙니다.");
}
?>
aaaaaaaaa
=============================
방법7)
include_once('./_common.php');
$member = get_member($ss_mb_id);
if ($member[mb_level] < 9 || $member[mb_id] == '') // 회원의 접근 권한 조정
{
alert('죄송합니다. 정회원만 이용하실 수 있습니다');
exit;
}
?>
aaaaaaaaa
=============================
방법8)
if ($member['mb_level'] < 5) {
if ($is_member)
alert('글을 읽을 권한이 없습니다.', G5_URL);
else
alert('글을 읽을 권한이 없습니다.\\n\\n회원이시라면 로그인 후 이용해 보십시오.', './login.php?url='.$urlencode);
}
?>
aaaaaaaaa
=============================
방법8)
include_once("../common.php");
?>
if ($is_guest) { ?>
alert('권한이 없습니다');
location = '=G5_PATH?>/bbs/login.php';
} ?>
aaaaaaaaa
=============================
방법9)
if (!$member["mb_id"]){
alert('로그인 후 접속하세요', '/bbs/login.php');
}
?>
aaaaaaaaa
=============================
방법10)
if ($is_guest) { ?>
} ?>
aaaaaaaaa
=============================
방법11)
if ($member['mb_level'] < 3) {
alert('권한이 없습니다.', G5_URL);
}
?>
aaaaaaaaa
aaaaaaaaa
=============================
방법12)
if ($member['mb_level'] < 3) { ?>
alert('권한이 없습니다');
location = '=G5_PATH?>/bbs/login.php';
} ?>
aaaaaaaaa
위와 같이 12가지를 다 적용해 보았습니다.
위의 소스중에서 차단이 되는 것도 있으나
관리자 및 통과할수 있는 레벨(예 레벨3) 이상도
차단을 합니다. 즉, 로그인이 되어있든 없든 차단을 합니다.
로그인이 안되어 있을때는 차단하고,
권한이 있는 레벨이 로그인 할때는 통과를 하게 하고 싶습니다
지도 부탁합니다. 감사합니다.^^
답변 2개
</p><p><?php</p><p>if(!$is_member) {</p><p style="margin-left: 0px;"> alert("회원만","이동할페이지");</p><p>} else {</p><p style="margin-left: 0px;"><span style="font-size: 14.6667px;"> </span><span style="font-size: 14.6667px;"> </span>switch($member['mb_level']) {</p><p style="margin-left: 0px;"><span style="font-size: 14.6667px;"> </span><span style="font-size: 14.6667px;"> </span>case 2:</p><p style="margin-left: 0px;"><span style="font-size: 14.6667px;"> </span><span style="font-size: 14.6667px;"> </span><span style="font-size: 14.6667px;"> </span><span style="font-size: 14.6667px;"> </span><span style="font-size: 11pt;">alert("2레벨은 빠빠이", "이동할 페이지");</span></p><p style="margin-left: 0px;"><span style="font-size: 14.6667px;"> </span><span style="font-size: 14.6667px;"> </span><span style="font-size: 14.6667px;"> </span><span style="font-size: 14.6667px;"> </span><span style="font-size: 11pt;">exit;</span></p><p style="margin-left: 0px; font-size: 14.6667px;"><span style="font-size: 14.6667px;"> </span><span style="font-size: 14.6667px;"> </span>case 3:</p><p style="margin-left: 0px; font-size: 14.6667px;"><span style="font-size: 14.6667px;"> </span><span style="font-size: 14.6667px;"> </span><span style="font-size: 14.6667px;"> </span><span style="font-size: 14.6667px;"> </span><span style="font-size: 14.6667px;">echo "3레벨은 환영이야";</span></p><p style="margin-left: 0px; font-size: 14.6667px;"><span style="font-size: 14.6667px;"> </span><span style="font-size: 14.6667px;"> </span><span style="font-size: 14.6667px;"> </span><span style="font-size: 14.6667px;"> </span><span style="font-size: 14.6667px;">break;</span></p><p style="margin-left: 0px; font-size: 14.6667px;"><span style="font-size: 14.6667px;"> </span><span style="font-size: 14.6667px;"> </span>case 4:</p><p style="margin-left: 0px; font-size: 14.6667px;"><span style="font-size: 14.6667px;"> </span><span style="font-size: 14.6667px;"> </span><span style="font-size: 14.6667px;"> </span><span style="font-size: 14.6667px;"> </span><span style="font-size: 14.6667px;">echo "4레벨도 환영이야. 나머지 레벨 안적어도 통과야";</span></p><p style="margin-left: 0px; font-size: 14.6667px;"><span style="font-size: 14.6667px;"> </span><span style="font-size: 14.6667px;"> </span><span style="font-size: 14.6667px;"> </span><span style="font-size: 14.6667px;"> </span><span style="font-size: 14.6667px;">break;</span></p><p style="margin-left: 0px;"><span style="font-size: 14.6667px;"> </span><span style="font-size: 14.6667px;"> </span>}</p><p>}</p><p>?></p><p>
댓글을 작성하려면 로그인이 필요합니다.
그림자밟기님, 답변 감사합니다.
제가 폴더를 html 속에 넣어서 실행할시에는 적용이 됩니다.
그런데, 폴더/폴더/폴더/실행파일(.php)를 실행하면 안됩니다.
adm, bbs 같은 위치에 있으면 되고, 하위 폴더에 실행하고자 하는
파일(.php)를 넣으면 안됩니다.
실행할 파일이 많이 있기때문에 adm, bbs 와 같은 위치에 놓으면
너무 복잡할 것 같아, 하위 폴더에 넣어서 실행하고자 합니다.
위처럼 폴더/폴더/폴더/실행파일(.php)를 실행할 수 있나요.
감사합니다.
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인