Skip to content

Instantly share code, notes, and snippets.

@vansosnin
Last active September 8, 2015 04:58
Show Gist options
  • Save vansosnin/8fa3540a572cbf172ab6 to your computer and use it in GitHub Desktop.
Save vansosnin/8fa3540a572cbf172ab6 to your computer and use it in GitHub Desktop.
POST logging
<?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