Last active
May 23, 2018 14:42
-
-
Save heydonovan/8007370 to your computer and use it in GitHub Desktop.
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 | |
// 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