Last active
September 19, 2019 17:46
-
-
Save wellington1993/0c47d7ce8853e9e6e72210dcf04b7177 to your computer and use it in GitHub Desktop.
PHP Debug HTTP Request
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 | |
$date = new DateTime(); | |
$tempo = $date->getTimestamp(); | |
$my_file = "/tmp/output-$tempo.html"; | |
$handle = fopen($my_file, 'w'); | |
ob_start(); | |
echo '<pre>'; | |
if (!function_exists('getallheaders')) | |
{ | |
function getallheaders() | |
{ | |
$headers = array (); | |
foreach ($_SERVER as $name => $value) | |
{ | |
if (substr($name, 0, 5) == 'HTTP_') | |
{ | |
$headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value; | |
} | |
} | |
return $headers; | |
} | |
} else { | |
foreach (getallheaders() as $name => $value) { | |
echo "$name: $value\r\n"; | |
} | |
} | |
echo "\xA" . '---------' . "\xA"; | |
print_r($_SERVER); | |
echo "\xA" . '---------' . "\xA"; | |
print_r($_POST); | |
echo "\xA" . '---------' . "\xA"; | |
print_r($_GET); | |
echo "\xA" . '---------' . "\xA"; | |
print_r($_FILES); | |
echo "\xA" . '---------' . "\xA"; | |
print_r($_REQUEST); | |
echo "\xA" . '---------' . "\xA"; | |
var_dump($_POST, $_FILES); | |
$postdata = file_get_contents("php://input"); | |
echo "\xA" . '---------' . "\xA"; | |
print_r($postdata); | |
echo "\xA" . '---------' . "\xA"; | |
echo "\xA" . '---------' . "\xA"; | |
var_dump($postdata); | |
#if (!isset($_SERVER['PHP_AUTH_USER'])) { | |
# header('WWW-Authenticate: Basic realm="My Realm"'); | |
#} else { | |
# echo "<p>Olá, {$_SERVER['PHP_AUTH_USER']}.</p>"; | |
# echo "<p>Você digitou {$_SERVER['PHP_AUTH_PW']} como sua senha.</p>"; | |
#} | |
echo '</pre>'; | |
# Write | |
$htmlStr = ob_get_contents(); | |
ob_end_clean(); | |
fwrite($handle, $htmlStr); | |
rewind($handle); | |
fclose($handle); | |
echo file_get_contents($my_file); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment