Skip to content

Instantly share code, notes, and snippets.

@heydonovan
Last active May 23, 2018 14:42
Show Gist options
  • Save heydonovan/8007370 to your computer and use it in GitHub Desktop.
Save heydonovan/8007370 to your computer and use it in GitHub Desktop.
<?php
// full path to customer log file
$log_file = __DIR__.'/../__admin_ajax.log';
// if it's not a POST request, just move along
if($_SERVER['REQUEST_METHOD'] != "POST") {
return(0);
}
// if you only want specific files like admin-ajax or xmlrpc, uncomment the next line
//if($_SERVER['PHP_SELF'] != "/wp-admin/admin-ajax.php" && $_SERVER['PHP_SELF'] != "/xmlrpc.php") { return(0); }
// write log function
function write_log($message) {
global $log_file;
if ( ! is_file($log_file) ) {
$start_log_date = date('l jS \of F Y h:i:s A');
file_put_contents($log_file, "--- log file start $start_log_date ---\n");
}
file_put_contents($log_file, "\n$message\n\n", FILE_APPEND);
}
// write the log!
write_log("**".@date("r")."|".$_SERVER["REMOTE_ADDR"]."|".$_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URI"]."\n".print_r($_POST,1)."\n".print_r($_REQUEST,1));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment