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