diff --git a/features/cookies.xml b/features/cookies.xml deleted file mode 100644 index 6a2ab92a02..0000000000 --- a/features/cookies.xml +++ /dev/null @@ -1,32 +0,0 @@ - - Cookies - - PHP는 HTTP Cookie를 투명하게(transparently) 지원한다. - Cookie 메카니즘은 트래킹이나 사용자 식별 등을 위해 원격 browser에 - 저장된 데이터를 돌려 받는 과정을 말한다. - 여러분은 cookie를 설정하기 위해 setcookie 함수를 사용할 수 있다. - Cookie는 HTTP 헤더의 한 부분이므로, setcookie 함수는 브라우저로 - 보내는 어떤 데이터보다도 앞에 사용해야 한다. - 이 제약은 header 함수와 같은 제약으로 보면 된다. - - 클라이언트가 보내준 모든 cookie는 자동적으로 GET이나 POST 방식 데이터와 같은 PHP 변수로 변환된다. - 만약 여러분이 동일한 cookie에 여러 값을 저장하고 싶다면 Cookie이름에 []를 더하면 된다. - 자세한 것은 setcookie 함수 설명을 참조하자. - - - diff --git a/features/error-handling.xml b/features/error-handling.xml deleted file mode 100644 index b3e721cba9..0000000000 --- a/features/error-handling.xml +++ /dev/null @@ -1,285 +0,0 @@ - - Error Handling - - PHP에는 다음과 같은 여러 에러와 경고 형태가 있다.: - - PHP error types - - - - Value - Constant - Description - Note - - - - - 1 - E_ERROR - Normal Function Errors (일반적인 에러) - - - - 2 - E_WARNING - Normal Warnings (일반적인 경고) - - - - 4 - E_PARSE - Parser Errors (문법 에러) - - - - 8 - E_NOTICE - - Notices (무시할 수 있는 알림이지만 버그의 가능성을 가지고 있는 경우) - - - - - 16 - E_CORE_ERROR - fatal errors that occur during PHP's initial startup - (PHP가 처음 시작될 때 발생한 치명적 에러) - PHP 4 only - - - 32 - E_CORE_WARNING - warnings (non fatal errors) that occur during PHP's initial startup - (PHP가 처음 시작될 때 발생한 치명적이지 않은 경고) - PHP 4 only - - - 64 - E_COMPILE_ERROR - fatal compile-time errors (컴파일시 생긴 치명적 에러) - PHP 4 only - - - 128 - E_COMPILE_WARNING - compile-time warnings (non fatal errors) (컴파일시 발생한 치명적이지 않은 경고) - PHP 4 only - - - 256 - E_USER_ERROR - user-generated error message (사용자가 만든 에러 메세지) - PHP 4 only - - - 512 - E_USER_WARNING - user-generated warning message (사용자가 만든 경고 메세지) - PHP 4 only - - - 1024 - E_USER_NOTICE - user-generated notice message (사용자가 만든 알림 메세지) - PHP 4 only - - - - E_ALL - all of the above, as supported (지원가능한 위의 것 모두) - - - - -
-
- - The above values (either numerical or symbolic) are used to build - up a bitmask that specifies which errors to report. You can use the - bitwise operators - to combine these values or mask out certain types of errors. Note - that only '|', '~', '!', and '&' will be understood within - php.ini, however, and that no bitwise - operators will be understood within php3.ini. - - - In PHP 4, the default error_reporting setting is - E_ALL & ~E_NOTICE, meaning to display all errors - and warnings which are not E_NOTICE-level. In PHP 3, the default - setting is (E_ERROR | E_WARNING | E_PARSE), - meaning the same thing. Note, however, that since constants are not - supported in PHP 3's php3.ini, the error_reporting setting there - must be numeric; hence, it is 7. - - - The initial setting can be changed in the ini file with the error_reporting directive, in - your Apache httpd.conf file with the - php_error_reporting (php3_error_reporting for PHP 3) directive, and - lastly it may be set at runtime within a script by using the - error_reporting function. - - - - When upgrading code or servers from PHP 3 to PHP 4 you should - check these settings and calls to - error_reporting or you might disable - reporting the new error types, especially E_COMPILE_ERROR. This - may lead to empty documents without any feedback of what happened - or where to look for the problem. - - - - 모든 PHP 표현식(expression)은 "@"를 앞에 붙이고 호출되면 error reporting을 하지 않는다. - 만약 track_errors 옵션이 Enabled로 되어 있고 해당 문장에서 에러가 발생했다면, - $php_errormsg라는 전역변수에 에러 메시지가 담겨 있게 된다. - - - - Currently the @ - error-control operator prefix will even disable error - reporting for critical errors that will terminate script - execution. Among other things, this means that if you use @ to suppress - errors from a certain function and either it isn't available or - has been mistyped, the script will die right there with no - indication as to why. - - - - Below we can see an example of using the error handling capabilities in - PHP. We define a error handling function which logs the information into - a file (using an XML format), and e-mails the developer in case a critical - error in the logic happens. - - Using error handling in a script - -<?php -// we will do our own error handling -error_reporting(0); - -// user defined error handling function -function userErrorHandler ($errno, $errmsg, $filename, $linenum, $vars) { - // timestamp for the error entry - $dt = date("Y-m-d H:i:s (T)"); - - // define an assoc array of error string - // in reality the only entries we should - // consider are 2,8,256,512 and 1024 - $errortype = array ( - 1 => "Error", - 2 => "Warning", - 4 => "Parsing Error", - 8 => "Notice", - 16 => "Core Error", - 32 => "Core Warning", - 64 => "Compile Error", - 128 => "Compile Warning", - 256 => "User Error", - 512 => "User Warning", - 1024=> "User Notice" - ); - // set of errors for which a var trace will be saved - $user_errors = array(E_USER_ERROR, E_USER_WARNING, E_USER_NOTICE); - - $err = "<errorentry>\n"; - $err .= "\t<datetime>".$dt."</datetime>\n"; - $err .= "\t<errornum>".$errno."</errnumber>\n"; - $err .= "\t<errortype>".$errortype[$errno]."</errortype>\n"; - $err .= "\t<errormsg>".$errmsg."</errormsg>\n"; - $err .= "\t<scriptname>".$filename."</scriptname>\n"; - $err .= "\t<scriptlinenum>".$linenum."</scriptlinenum>\n"; - - if (in_array($errno, $user_errors)) - $err .= "\t<vartrace>".wddx_serialize_value($vars,"Variables")."</vartrace>\n"; - $err .= "</errorentry>\n\n"; - - // for testing - // echo $err; - - // save to the error log, and e-mail me if there is a critical user error - error_log($err, 3, "/usr/local/php4/error.log"); - if ($errno == E_USER_ERROR) - mail("phpdev@mydomain.com","Critical User Error",$err); -} - - -function distance ($vect1, $vect2) { - if (!is_array($vect1) || !is_array($vect2)) { - trigger_error("Incorrect parameters, arrays expected", E_USER_ERROR); - return NULL; - } - - if (count($vect1) != count($vect2)) { - trigger_error("Vectors need to be of the same size", E_USER_ERROR); - return NULL; - } - - for ($i=0; $i<count($vect1); $i++) { - $c1 = $vect1[$i]; $c2 = $vect2[$i]; - $d = 0.0; - if (!is_numeric($c1)) { - trigger_error("Coordinate $i in vector 1 is not a number, using zero", - E_USER_WARNING); - $c1 = 0.0; - } - if (!is_numeric($c2)) { - trigger_error("Coordinate $i in vector 2 is not a number, using zero", - E_USER_WARNING); - $c2 = 0.0; - } - $d += $c2*$c2 - $c1*$c1; - } - return sqrt($d); -} - -$old_error_handler = set_error_handler("userErrorHandler"); - -// undefined constant, generates a warning -$t = I_AM_NOT_DEFINED; - -// define some "vectors" -$a = array(2,3,"foo"); -$b = array(5.5, 4.3, -1.6); -$c = array (1,-3); - -// generate a user error -$t1 = distance($c,$b)."\n"; - -// generate another user error -$t2 = distance($b,"i am not an array")."\n"; - -// generate a warning -$t3 = distance($a,$b)."\n"; - -?> - - - This is just a simple example showing how to use the - Error Handling and Logging - functions. - - - See also error_reporting, - error_log, - set_error_handler, - restore_error_handler, - trigger_error, - user_error - -
- diff --git a/features/http-auth.xml b/features/http-auth.xml deleted file mode 100644 index abe13fbe94..0000000000 --- a/features/http-auth.xml +++ /dev/null @@ -1,116 +0,0 @@ - - HTTP authentication with PHP - - (역자주. HTTP authentication이란 Web Client에게 ID와 Password를 입력받아, - 그 ID와 Password로 Web문서에 접근을 허가, 불허하는 기능을 말한다. - 자세히 알고 싶다면 RFC1945의 Authentication 부분을 참고하기 바란다. - http://pec.etri.re.kr/!qkim/HTTP/에 한글 번역 문서도 있으니 참조하자.) - - - PHP를 사용한 HTTP 인증은 Apache 모듈로 사용될 때만 동작한다. - CGI 버젼에서는 이 기능을 사용할 수 없다. - Apache 모듈의 PHP 스크립트에서 Header라는 함수를 사용하면 - Client 브라우저에게 Username과 Password를 입력받는 윈도우를 띄우도록 하는 - "인증 요구"("Authentication Required") 메시지를 보낼 수 있다. - 일단 사용자가 Username과 Password를 입력하면, - user name, password, authentication type의 값을 가지는 - $PHP_AUTH_USER, $PHP_AUTH_PW, $PHP_AUTH_TYPE의 3개의 변수를 가지고 - 해당 URL(PHP 스크립트를 포함한)이 다시 불리워진다. - 현재 authentication type은 "Basic"만이 지원된다. - 자세한 사용법은 Header 함수를 살펴 보자. - - client authentication을 사용하여 그 입력된 값을 출력하는 예제가 아래에 있다. : - - HTTP Authentication example - -<?php - if(!isset($PHP_AUTH_USER)) { - Header("WWW-Authenticate: Basic realm=\"My Realm\""); - Header("HTTP/1.0 401 Unauthorized"); - echo "Text to send if user hits Cancel button\n"; - exit; - } else { - echo "Hello $PHP_AUTH_USER.<P>"; - echo "You entered $PHP_AUTH_PW as your password.<P>"; - } -?> - - - - - 여러분은 $PHP_AUTH_USER 와 $PHP_AUTH_PW를 단순히 출력하는 대신, - 사용자의 식별을 위해 username과 password를 사용하기를 원할 것이다. - 이때는 Database에 Query하거나 직접 dbm 파일에서 찾아보는 등의 방법으로 가능할 것이다. - - Internet Explorer browser에서는 버그로 인해 Header의 순서가 매우 까다롭다. - WWW-Authenticate를 - HTTP/1.0 401보다 먼저 보내는 것이 현재 가능한 트릭으로 보인다. - - - 비밀번호의 유출을 우려하여 HTTP에서 제공하는 인증을 사용하는 대신 - 기존의 외부 메카니즘을 사용할 경우에는 물론 PHP_AUTH 변수는 설정되지 않는다. - 이런경우 externally-authenticated user를 확인하기 위해 $REMOTE_USER 변수를 사용할 수 있다. - - - 유의할 점은 인증이 필요한 페이지와 인증이 필요없는 페이지가 같은 서버상에 존재할 때, - 인증이 필요없는 URL을 control할 수 있는 누군가가, - 인증이 필요한 URL의 암호를 훔쳐보는 것은 막을 수 없다는 점이다. - - - Netscape와 Internet Explorer 모두 401응답 코드를 서버에서 받게되면 - local browser window의 authentication cache를 clear한다. - 즉, 이것은 "log out"개념이 되는 것으로, 사용자들로 하여금 username과 암호를 다시 입력하게 한다. - 일부는 이것을 통해 login의 "time out"이나 "log-out"버튼을 만드는데 사용한다 - - - HTTP Authentication example forcing a new name/password - -<?php - function authenticate() { - Header( "WWW-authenticate: basic realm=\"Test Authentication System\""); - Header( "HTTP/1.0 401 Unauthorized"); - echo "You must enter a valid login ID and password to access this resource\n"; - exit; - } - - if(!isset($PHP_AUTH_USER) || ($SeenBefore == 1 && !strcmp($OldAuth, $PHP_AUTH_USER)) ) { - authenticate(); - } - else { - echo "Welcome: $PHP_AUTH_USER<BR>"; - echo "Old: $OldAuth"; - echo "<FORM ACTION=\"$PHP_SELF\" METHOD=POST>\n"; - echo "<INPUT TYPE=HIDDEN NAME=\"SeenBefore\" VALUE=\"1\">\n"; - echo "<INPUT TYPE=HIDDEN NAME=\"OldAuth\" VALUE=\"$PHP_AUTH_USER\">\n"; - echo "<INPUT TYPE=Submit VALUE=\"Re Authenticate\">\n"; - echo "</FORM>\n"; - -} -?> - - - - 그러나 이 동작은 HTTP Basic authentication 기준에 보장된 것은 아니므로 이 기능에 의존하여서는 안된다. - Lynx에서는 401 서버 응답을 받아도 authentication 정보를 clear하지 않는다. - 따라서 Back을 누르고 다시 Forward 버튼을 눌러서 다시 접근할 수 있다. - - 또한 이 Authentication 기능은 Microsoft's IIS server에서 - CGI version의 PHP를 사용할 경우에는 IIS의 제약으로인해 동작하지 않는다. - - - diff --git a/features/images.xml b/features/images.xml deleted file mode 100644 index 1fc733fc79..0000000000 --- a/features/images.xml +++ /dev/null @@ -1,49 +0,0 @@ - - PHP에서 이미지 생성과 수정(Creating and manipulating images) - - PHP는 단지 HTML출력을 만드는 것만 할 수 있는 것이 아니다. - PHP는 GIF image file도 만들 수 있을 있을 뿐아니라, - 사용하기에 편리한 GIF image stream까지 만들 수 있다. - 이를 위해서 여러분은 PHP를 컴파일 할 때, image 함수를 가지고 있는 GD 라이브러리를 포함하여야 한다. - GD와 PHP는 사용하는 이미지 포맷 형태에 따라 다른 라이브러리도 요구한다. - GD는 버전 1.6부터 GIF 이미지 지원을 하지 않는다. - - - - PNG creation with PHP - -<?php - Header("Content-type: image/png"); - $string=implode($argv," "); - $im = imageCreateFromPng("images/button1.png"); - $orange = ImageColorAllocate($im, 220, 210, 60); - $px = (imagesx($im)-7.5*strlen($string))/2; - ImageString($im,3,$px,9,$string,$orange); - ImagePng($im); - ImageDestroy($im); -?> - - - 위의 예제는 <img src="button.php?text"> 와 같은 tag이 있는 페이지로부터 불려지게 될 것이다. - 그러면 위에있는 button.php 스크립트는 "text"라는 문자열을 - "images/button1.gif"에 오버레이 시켜 결과 image에 출력한다. - 이렇게 하면 버튼에 들어가는 글씨를 매번 손쉽게 바꿔 쓸 수 있고, - 또한 매번 이미지 파일을 만들 필요가 없어 효율적이고 간단하다. - - -