Esempio n. 1
0
 }
 //is it a position message?
 if ($parts[1] !== "3") {
     continue;
 }
 $radioId = $helicopters[$parts[4]];
 $lat = $parts[14];
 $lon = $parts[15];
 if (!$lat || !$lon) {
     continue;
 }
 $time = date_parse($parts[6] . ' ' . $parts[7]);
 $position_time = mktime($time['hour'], $time['minute'], $time['second'], $time['month'], $time['day'], $time['year']);
 //check the time it was last entered into database by this station
 if (!isset($sent[$radioId]) or $sent[$radioId] + $position_interval < time()) {
     $coords = $converter->wgs84_to_osgb36($lat, $lon);
     $data = ['userid' => $userid, 'password' => $password, 'x' => floor($coords[0]), 'y' => floor($coords[1]), 'validFor' => 120, 'radioId' => $radioId, 'type' => "aircraft", 'time' => $position_time];
     $ch = curl_init($sendUrl);
     # Form data string
     $postString = http_build_query($data, '', '&');
     # Setting our options
     curl_setopt($ch, CURLOPT_POST, 1);
     curl_setopt($ch, CURLOPT_POSTFIELDS, $postString);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     # Get the response
     $response = curl_exec($ch);
     echo $response;
     echo PHP_EOL;
     curl_close($ch);
     //store time last sent
     $sent[$radioId] = time();