OLD | NEW |
(Empty) | |
| 1 <?php |
| 2 $beaconFilename = "beacon" . (isset($_REQUEST['name']) ? $_REQUEST['name'] : "")
. ".txt"; |
| 3 $retries = isset($_REQUEST['retries']) ? (int)$_REQUEST['retries'] : -1; |
| 4 while (!file_exists($beaconFilename) && $retries != 0) { |
| 5 usleep(10000); |
| 6 # file_exists() caches results, we want to invalidate the cache. |
| 7 clearstatcache(); |
| 8 $retries--; |
| 9 } |
| 10 |
| 11 header('Content-Type: text/plain'); |
| 12 header('Access-Control-Allow-Origin: *'); |
| 13 if (file_exists($beaconFilename)) { |
| 14 echo "Beacon sent successfully\n"; |
| 15 $beaconFile = fopen($beaconFilename, 'r'); |
| 16 while ($line = fgets($beaconFile)) { |
| 17 $trimmed = trim($line); |
| 18 if ($trimmed != "") |
| 19 echo "$trimmed\n"; |
| 20 } |
| 21 fclose($beaconFile); |
| 22 unlink($beaconFilename); |
| 23 } else { |
| 24 echo "Beacon not sent\n"; |
| 25 } |
| 26 ?> |
OLD | NEW |