| OLD | NEW |
| 1 <?php | 1 <?php |
| 2 require_once '../../resources/portabilityLayer.php'; |
| 3 |
| 2 function prettify($name) { | 4 function prettify($name) { |
| 3 return str_replace(' ', '-', ucwords(str_replace('_', ' ', str_replace('http_
', '', strtolower($name))))); | 5 return str_replace(' ', '-', ucwords(str_replace('_', ' ', str_replace('http_
', '', strtolower($name))))); |
| 4 } | 6 } |
| 5 | 7 |
| 6 $beaconFilename = "beacon" . (isset($_REQUEST['name']) ? $_REQUEST['name'] : "")
. ".txt"; | 8 $beaconFilename = sys_get_temp_dir() . "/beacon" . (isset($_REQUEST['name']) ? $
_REQUEST['name'] : "") . ".txt"; |
| 7 $beaconFile = fopen($beaconFilename . ".tmp", 'w'); | 9 $beaconFile = fopen($beaconFilename . ".tmp", 'w'); |
| 8 $httpHeaders = $_SERVER; | 10 $httpHeaders = $_SERVER; |
| 9 ksort($httpHeaders, SORT_STRING); | 11 ksort($httpHeaders, SORT_STRING); |
| 10 $contentType = ""; | 12 $contentType = ""; |
| 11 foreach ($httpHeaders as $name => $value) { | 13 foreach ($httpHeaders as $name => $value) { |
| 12 if ($name === "CONTENT_TYPE" || $name === "HTTP_REFERER" || $name === "REQUE
ST_METHOD" || $name === "HTTP_COOKIE" || $name === "HTTP_ORIGIN") { | 14 if ($name === "CONTENT_TYPE" || $name === "HTTP_REFERER" || $name === "REQUE
ST_METHOD" || $name === "HTTP_COOKIE" || $name === "HTTP_ORIGIN") { |
| 13 if ($name === "CONTENT_TYPE") { | 15 if ($name === "CONTENT_TYPE") { |
| 14 $contentType = $value; | 16 $contentType = $value; |
| 15 $value = preg_replace('/boundary=.*$/', '', $value); | 17 $value = preg_replace('/boundary=.*$/', '', $value); |
| 16 } | 18 } |
| 17 $headerName = prettify($name); | 19 $headerName = prettify($name); |
| 18 fwrite($beaconFile, "$headerName: $value\n"); | 20 fwrite($beaconFile, "$headerName: $value\n"); |
| 19 } | 21 } |
| 20 } | 22 } |
| 21 $postdata = file_get_contents("php://input"); | 23 $postdata = file_get_contents("php://input"); |
| 22 if (strlen($postdata) == 0) | 24 if (strlen($postdata) == 0) |
| 23 $postdata = http_build_query($_POST); | 25 $postdata = http_build_query($_POST); |
| 24 | 26 |
| 25 fwrite($beaconFile, "Length: " . strlen($postdata) . "\n"); | 27 fwrite($beaconFile, "Length: " . strlen($postdata) . "\n"); |
| 26 if (strpos($contentType, "application/") !== false) { | 28 if (strpos($contentType, "application/") !== false) { |
| 27 $postdata = base64_encode($postdata); | 29 $postdata = base64_encode($postdata); |
| 28 } | 30 } |
| 29 | 31 |
| 30 fwrite($beaconFile, "Body: $postdata\n"); | 32 fwrite($beaconFile, "Body: $postdata\n"); |
| 31 fclose($beaconFile); | 33 fclose($beaconFile); |
| 32 rename($beaconFilename . ".tmp", $beaconFilename); | 34 rename($beaconFilename . ".tmp", $beaconFilename); |
| 33 foreach ($_COOKIE as $name => $value) | 35 foreach ($_COOKIE as $name => $value) |
| 34 setcookie($name, "deleted", time() - 60, "/"); | 36 setcookie($name, "deleted", time() - 60, "/"); |
| 35 ?> | 37 ?> |
| OLD | NEW |