phpsource/파일분석2003. 6. 25. 09:35
초기화 파일의 구조
초기화 파일의 구조를 알아보기 위해 php.ini 파일의 예를 들어 보겠습니다. 아래는 php.ini 파일에 있는 내용 중의 세션 관련 부분만 나타낸 것입니다.
[Session]
; Handler used to store/retrieve data.
session.save_handler = files

; Argument passed to save_handler. In the case of files, this is the path
; where data files are stored. Note: Windows users have to change this
; variable in order to use PHP's session functions.
session.save_path = /tmp

; Whether to use cookies.
session.use_cookies = 1


; Name of the session (used as cookie name).
session.name = PHPSESSID

; Initialize session on request startup.
session.auto_start = 0

; Lifetime in seconds of cookie or, if 0, until browser is restarted.
session.cookie_lifetime = 0

; The path for which the cookie is valid.
session.cookie_path = /

; The domain for which the cookie is valid.
session.cookie_domain =

; Handler used to serialize data. php is the standard serializer of PHP.
session.serialize_handler = php

; Percentual probability that the 'garbage collection' process is started
; on every session initialization.
session.gc_probability = 1

; After this number of seconds, stored data will be seen as 'garbage' and
; cleaned up by the garbage collection process.
session.gc_maxlifetime = 1440

; Check HTTP Referer to invalidate externally stored URLs containing ids.
session.referer_check =

; How many bytes to read from the file.
session.entropy_length = 0

; Specified here to create the session id.
session.entropy_file =

;session.entropy_length = 16

;session.entropy_file = /dev/urandom

; Set to {nocache,private,public} to determine HTTP caching aspects.
session.cache_limiter = nocache

; Document expires after n minutes.
session.cache_expire = 180

; use transient sid support if enabled by compiling with --enable-trans-sid.
session.use_trans_sid = 1

url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=fakeentry"
초기화 파일 내용을 보면 아래와 같이 크게 4부분으로 구성되어 있습니다.
  • 섹션(section)
  • 주석(comment)
  • 빈줄(empty line)
  • 키정보(KEY=VALUE pair)
섹션(section)
초기화 파일의 각 섹션은 "[Session]"와 같이 대괄호([,])로 둘러싸인 키워드로 시작되며 이어서 여러 줄의 설정(주석, 빈줄, 키정보)이 뒤따릅니다. 섹션명은 대소문자를 구분합니다.
대부분의 키정보들은 먼저 섹션을 지정한 후 해당 섹션 내에 지정하게 됩니다. 그러나 때에 따라서는 섹션없이 바로 키를 지정할 수도 있습니다. 이 문서에서는 이와같이 섹션없이 지정된 키정보들을 담고 있는 공간을 글로벌 섹션(global section)이라고 부르겠습니다.
; test configuration settings
; written by : hwooky hwooky@phpclass.com
; last modified : 2003.05.30
;
LOCKED = Off ; On/Off - run-time changes rejected/allowed, resp.

[ErrorHandler]
;
; - Show only errors
;
level = E_ALL & ~E_NOTICE
MAIL_LOG = hwooky@phpclass.com
위와 같은 초기화 파일의 경우를 보면 키 "LOCKED"는 글로벌 섹션에 포함되며, 키 "level" 및 "MAIL_LOG"는 "ErrorHandler"라는 섹션에 포합됩니다.
주석(comment)
초기화 파일에서 주석은 세미콜론(;)으로 시작합니다. 따라서 각 행의 문장에서 세미콜론 뒤쪽에 있는 문자는 모두 주석으로 처리됩니다.
빈줄(empty line)
Whitespace로만 구성된 행은 모두 빈 행으로 처리됩니다.
키정보(KEY=VALUE pair)
각 키에 값을 할당하기 위해서 아래와 같이 지정합니다.
key = value
위에 있는 php.ini의 예제에서 볼 수 있듯이 value값은 그 값이 문자열이라 하더라도 인용부호없이 지정할 수 있습니다. 그러나 만약 value 값에 등호부호(=) 또는 세미콜론(;)과 같은 특수문자가 포함되어야 한다면 아래와 같이 이중인용부호(")로 둘러싸여 있어야 합니다.
url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=fakeentry"
이중인용부호(") 대신에 단일인용부호(')를 사용할 수 없으며, 키명은 대소문자를 구별합니다. 따라서 "foo=bar"은 "FOO=bar"과 다릅니다.
키 값에 지정할 수 있는 것은 문자열, 숫자, PHP 상수(예를 들어 E_ALL), 초기화 파일에서 사용되는 상수들(On, Off, True, False, Yes, No 및 None) 또는 수식(예를 들어 E_ALL & ~E_NOTICE) 또는 이중인용부호(")로 둘러싸인 문자열(예를 들어 "foo") 등 입니다.
초기화 파일에서 사용되는 상수들(On, Off, True, False, Yes, No 및 None)은 대소문자를 구별하지 않습니다.
초기화 파일의 보안
초기화 파일은 텍스트 파일이므로 누구나 쉽게 읽거나 바꿀 수가 있습니다. 따라서 데이터베이스에 대한 정보(호스트명,사용자명,패스워드,데이터베이스명,테이블명 등)와 같은 공개되어서는 안되는 중요한 정보가 초기화 파일에 포함되어 있다면 URL 접근을 통해 다운로드되거나 그 내용이 브라우저에 나타나지 않도록 주의해야 할 것입니다.
중요한 정보가 기록된 초기화 파일에 대한 보안을 소홀히 하게되면 심각한 결과를 초래할 수 있으니 주의하기 바랍니다.

'phpsource > 파일분석' 카테고리의 다른 글

{INI 파일}5.값의 평가  (0) 2003.06.25
{INI 파일}4.사용 함수  (0) 2003.06.25
{INI 파일}2.INI 핸들러  (0) 2003.06.25
{INI 파일}1.개요  (0) 2003.06.25
{TAR 파일}8.클래스 다운로드  (0) 2002.09.16
Posted by 방글24