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