Last active
October 24, 2024 15:02
-
-
Save aplneto/433d265c70a160373c52ae2362a52136 to your computer and use it in GitHub Desktop.
PHP Request Reflection Server
This file contains hidden or 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
| RewriteEngine On | |
| RewriteRule ^ index.php [L] | |
| RewriteRule ^\.htaccess$ - [F] | |
| RewriteRule ^config\.php$ - [F] | |
| RewriteRule .* - [e=HTTP_AUTHORIZATION:%{HTTP:Authorization}] |
This file contains hidden or 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 | |
| // Returns the content of HTTP Requests received | |
| // Set content-type to plaintext to avoid XSS problems | |
| header("Content-Type: text/plain"); | |
| // Request Method, URL and Protocol | |
| echo "{$_SERVER['REQUEST_METHOD']} {$_SERVER['REQUEST_URI']} {$_SERVER['SERVER_PROTOCOL']}\n"; | |
| // Request Headers | |
| foreach (apache_request_headers() as $header => $value) { | |
| echo "$header: $value\n"; | |
| } | |
| // x-www-form-urlencoded post data | |
| if ($_SERVER['REQUEST_METHOD'] === 'POST') { | |
| $post_data_array = []; | |
| foreach ($_POST as $key => $value) { | |
| array_push($post_data_array, "$key=$value"); | |
| } | |
| echo "\n\n" . join("&", $post_data_array); | |
| } | |
| // other post data | |
| $json = file_get_contents('php://input'); | |
| if ($json) { | |
| echo $json; | |
| } | |
| // TODO add multipart/form-data support |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment