Forum Moderators: coopster

Message Too Old, No Replies

How do I dump Raw $ POST data to a file

         

chadodes

7:20 pm on Jun 20, 2011 (gmt 0)

10+ Year Member



Hi,

I have a device that is posting raw data with no indexes that I am aware of and I would like to see what it's trying to post.

I have tried these different options to see if I could get anything

if (isset($_POST))
{
$string = "1 \n";
$string .= " ".$_POST." \n";
$string .= "2 \n";
$string .= " ".print_r(serialize($_POST), true)." \n";
$string .= "3 \n";
$string .= " ".var_dump($_POST)." \n";
$string .= "4 \n";
$string .= " ".var_export($_POST)." \n";

$fp = fopen('txtdump.txt', 'ab');

if ($fp)
{
fwrite($fp,$string);
fclose($fp);

echo 'OK';

}

}


all I get is:

 
1
Array
2
a:0:{}
3

4


When I use wireshark I get all kinds of data in hex that I can convert to ASCI to see tab delimited data.

How can I get this thing to print even the first part of the array contents to file?

I tried $_POST[0] or [1] and get offset errors.

Thanks for your ideas or input.
-Chad

chadodes

7:37 pm on Jun 20, 2011 (gmt 0)

10+ Year Member



After searching for a $_POST catchall I came across this and added it to my code but it didn't do anything for me..

$string .= "10 \n";
foreach($_POST as $k => $v) {
$string .= "Key: {$k}<br>\r\n";
$string .= "Value: {$v}<br><br>\r\n";
}


Still need help please. :{

coopster

2:03 pm on Jun 21, 2011 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld, chadodes.

Check your PHP configuration to see if you are populating the $_POST superglobal or not.

chadodes

3:07 pm on Jun 21, 2011 (gmt 0)

10+ Year Member



Hi I have figured it out..

$string = file_get_contents("php://input");

Thanks for you ideas and inputs.