Created
May 30, 2017 21:31
-
-
Save zhabinka/d3f81e949511ac64ce670c6c12536580 to your computer and use it in GitHub Desktop.
Логирование POST-запросов
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
php_value auto_prepend_file /home/.../log.php | |
# Путь узнаём из phpinfo в переменной _ENV["DOCUMENT_ROOT"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if(isset($_POST) && count($_POST)>0){ | |
$data=""; | |
foreach($_POST as $key=>$val){ | |
if(is_string($val) && strlen($val)>2000 ) | |
$val=substr($val,0,2000); | |
$data.=$key."=>".$val."\n"; | |
} | |
//вместо /home/user/data/www/site.ru/ указываем свой путь от корня сервера, куда должен писаться лог | |
$fp=fopen("/home/.../log_ck/".$_SERVER['HTTP_HOST']."--".date("Ymd").".log","a"); | |
fwrite($fp,date("Y-m-d H:i:s")." ".$_SERVER['REMOTE_ADDR']." ".$_SERVER['SCRIPT_FILENAME']."\n".$data."---------------------------\n"); | |
fclose($fp); | |
$data=""; | |
reset($_POST); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment