안녕하세요...
산이님이 phpschool에 올려주신 내용에 대한 문의가 있어 이렇게
글을 올림니다.
이벤트 핸들러에 대한 액션이 동작할때 제일아래쪽의
readfile($img);
에 의해 이미지가 출력되는 것 같은데 ..
제가 test해 보니 이미지를 "aa.jpg"를
아파치 에러로그에 /action.php/aa.jpg에서
찾는 로그가 남더라구요 ...
이것을 어찌해야 하는지 ..
Action에 대해 debug 하는 방법이랑 약간의 설명을 부탁 드립니다.
감사 합니다.
//--- 첨부//---
[Tue Sep 23 18:59:02 2003] [error] [client 218.39.201.56] File does not exist:
/usr/local/httpd/htdocs/test/actimg.php/aa/a.jpg, referer: http://61.100.5.66/test.php
AddHandler chk-image .gif .png .jpg .jpeg .swf
Action chk-image /actimg.php
이렇게 설정하고,
DocumentRoot/actimg.php 파일에 다음과 같은 비슷한 방법으로
체크하고
이미지를 클라이언트에게
전송하면 됩니다.
<?php
## get file extension(tail)
##
function get_ftail($file)
{
$tail = substr(strrchr($file,'.'),1);
return strtolower($tail);
}
function get_stype($ftail)
{
$stype = array
(
'gif' => 'image/gif',
'jpg' => 'image/jpeg',
'jpeg' => 'image/jpeg',
'png' => 'image/png',
'swf' => 'application/x-shockwave-flash',
);
return $stype[$ftail];
}
if(!preg_match(";$_SERVER[HTTP_HOST];",$_SERVER[HTTP_REFERER]))
{ exit; }
if(!file_exists($img=$_SERVER[PATH_TRANSLATED]))
{ exit; }
## 그외 $_COOKIE 등등 체크
$header = get_stype(get_ftail($_SERVER[PATH_INFO]));
header('Content-type:'.$header);
readfile($img);
exit; // don't print any messages
?>
|