-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcollector.php
35 lines (34 loc) · 906 Bytes
/
collector.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
/*
* 247 Relay Challenge Log File Collector / Parser
* @author Michael Bates <[email protected]>
* @package t47
*/
if(!$fp = fopen("c:\users\administrator\desktop\log.txt", 'r')) {
die("Could not open log file.");
}
while(true) {
if(!$pos = fopen("c:\pos.txt", 'r')) {
echo "Could not open position file for reading.";
usleep(20000);
continue;
}
fseek($fp, (int)fread($pos, 1024));
fclose($pos);
if(!$pos = fopen("c:\pos.txt", 'wb+')) {
echo "Could not open position file for writing.";
usleep(20000);
continue;
}
$line = fgets($fp);
$newpos = ftell($fp);
fwrite($pos, $newpos);
if(strlen($line) > 0) {
echo "New lap: ";
echo $line . PHP_EOL;
file_get_contents("http://10.128.17.3/api/lap/create?data=$line");
}
fclose($pos);
usleep(20000);
}
fclose($fp);