HTTP Connection Information Logging

HTTP Connection Information Logging

This is to check if the connection information is correct for testing when using OpenAPI.

Method values, host, POST values upon connection.

[PHP]

<?
$log = $_SERVER['REQUEST_METHOD'].' '.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'].' n';

foreach($_SERVER as $k => $v)
{
if($k=='HTTP_HOST') continue;
if(substr($k, 0,5)!='HTTP_') continue;
$log .= '$k: $v'." ";
}

$log .= " ";

$post = array_map('urldecode', explode('&', file_get_contents('php://input')));
foreach($post as $v)
{
$log .= "$v ";
}

$log .= "--------------- ";

file_put_contents('log.txt', $log, FILE_APPEND | LOCK_EX);
?>

[/PHP]

Leave a Reply

이메일 주소는 공개되지 않습니다. (* 질문, 건의사항 등은 "질문게시판"을 이용해주세요)