사이트 내 전체검색
[php] file_exists 사용시 주의점
로빈아빠
https://cmd.kr/server/653 URL이 복사되었습니다.

본문

개발 이야기/PHP 2011/10/20 11:43

◈ file_exists()
- 문제점 : safe mode 일 때, 올바른 결과값을 출력하지 않을 위험성
- http://kr2.php.net/manual/kr/function.file-exists.php
- http://codeigniter-kr.org/tip/view/546/page/2

◈ file_exists() 문제의 해결
- is_file() 함수 사용

◈ safe mode
- 정의 : PHP 안전 모드는 공유-서버 보안 문제를 풀려는 시도. 이 문제를 PHP 수준에서 풀려고 하는것은 구조적으로 올바르지 않음. 그러나 웹서버와 OS 수준에서의 차선책이 아주 현실적이지는 않기 때문에, 많은 사람, 특히 ISP, 들이 현재 안전 모드를 사용. (php 6.0 에서는 삭제)
- 접근하는 디렉터리의 소유자나 소유그룹과 다를 때 문제가 발생
- php.ini 에서 "safe_mode = On" 설정 시 동작
- http://www.php.net/manual/kr/features.safe-mode.php
- http://learder.tistory.com/827190
- http://www.coldfusionfunnylog.com/blog/post.cfm/ubuntu-warning-safe-mode-restriction-in-effect

◈ safe mode 에 의해 제한/비활성화 되는 함수들
- http://php.net/manual/kr/features.safe-mode.functions.php

◈ file_exists() 와 is_file() 사용시 주의점
- 같은 파일 이름을 사용할 경우를 위해 함수 처리 결과를 캐시에 임시 저장하여 메모리의 일정 부분 자원으로 할당
- clearstatcache() 사용하여 캐시 삭제
- http://habony.tistory.com/35

◈ 처리 결과가 캐시 되는 함수들
- stat(), lstat(), file_exists(), is_writable(), is_readable(), is_executable(), is_file(), is_dir(), is_link(), filectime(), fileatime(), filemtime(), fileinode(), filegroup(), fileowner(), filesize(), filetype(), and fileperms()

댓글목록

등록된 댓글이 없습니다.

1,139 (4/23P)

Search

Copyright © Cmd 명령어 18.216.1.97