Skip to content

Instantly share code, notes, and snippets.

@christianchristensen
Last active December 24, 2015 07:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save christianchristensen/6763747 to your computer and use it in GitHub Desktop.
Save christianchristensen/6763747 to your computer and use it in GitHub Desktop.
Log additional request info into apache logs.
...
LogFormat "\"%r\" \"%{x-meh}o\"" test_123
CustomLog ${APACHE_LOG_DIR}/access.log test_123
...
<?php
$postdata = file_get_contents("php://input");
$method = "Not Available";
// Match method string in body
$pos = stripos($postdata, 'method');
if ($pos !== FALSE) {
$method = substr($HTTP_RAW_POST_DATA, $pos, 100);
}
header("x-meh: ${method}");
// Cleanup vars
unset($postdata, $pos, $method);
// Additional info:
// * http://httpd.apache.org/docs/2.2/logs.html
// * http://httpd.apache.org/docs/2.2/mod/mod_log_config.html#formats
// * http://82.157.70.109/mirrorbooks/apachesecurity/0596007248/apachesc-chp-8-sect-1.html "Integration with PHP"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment