채택완료

영카드 파일이름

2019-01-03 (목) 11:21:50 2,060

$result = "";
$lines = @file(G5_PATH."/test/data.txt") or $result = "파일을 읽을 수 없습니다.";
if ($lines != null){
    $result = $lines[0];
}

$filename = basename($_SERVER['REQUEST_URI'], '?' . $_SERVER['QUERY_STRING']);
if(filename != "login.php" && !$is_admin && $result != 'false') {
    header("Location:/test/file.php");
}

이런식으로 코드를 짜서 data.txt파일의 내용이 true이고 로은인 페이지가 아니고, 어드민이 아니라면

점검페이지로 가는건데 어드민 인식이랑 data파일은 인식하는데 로그인창을 들어가도 계속

점검페이지로 들어가요 어떻게 해야하나요?

|

답변 1개

채택된 답변
+20 포인트

if(filename...) <--- $filename 이 되어야 할거 같네요.

그 외 if 문에서 파일 이름 체크 할 때 strpos 를 이용하는 편이 좋지 않을까 싶네요.

http://php.net/manual/kr/function.stripos.php

답변을 작성하려면 로그인이 필요합니다.