Last active
September 8, 2015 04:58
-
-
Save vansosnin/8fa3540a572cbf172ab6 to your computer and use it in GitHub Desktop.
POST logging
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) AND count($_POST)) { | |
ob_start(); | |
print_r($_POST); | |
$output = ob_get_clean(); | |
if (!empty($_SERVER['HTTP_CLIENT_IP'])) { | |
$ip = $_SERVER['HTTP_CLIENT_IP']; | |
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { | |
$ip = $_SERVER['HTTP_X_FORWARDED_FOR']; | |
} else { | |
$ip = $_SERVER['REMOTE_ADDR']; | |
} | |
$ccc = "IP: " . $ip . "\n"; | |
$ccc .= $_SERVER['REQUEST_URI']." POST:\n".$output . "\n"; | |
file_put_contents('/home/logs/'.date('Y-m-d'), $ccc."\n", FILE_APPEND); | |
$post_logged = TRUE; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment