Created
March 18, 2013 20:37
-
-
Save WPEtopher/5190594 to your computer and use it in GitHub Desktop.
Intercept POST Requests
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 | |
$log_file = "log.txt"; | |
// 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 3 lines | |
//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:")." URI: ".$_SERVER["REQUEST_URI"]." IP: ".$_SERVER["REMOTE_ADDR"]."\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