Skip to content

Commit

Permalink
Add new data to sailaway
Browse files Browse the repository at this point in the history
  • Loading branch information
Ysurac committed Mar 14, 2018
1 parent 8cab2f8 commit d50392c
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions scripts/daemon-spotter.php
Original file line number Diff line number Diff line change
Expand Up @@ -928,30 +928,34 @@ function connect_all($hosts) {
exit(0);
}
if ($globalDebug) echo '! Download... ';
$buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/TrackAllBoats.pl?key='.$globalSailaway['key']);
$buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/TrackAllBoats.pl?key='.$globalSailaway['key'],'get','','','','',30);
if ($buffer != '') {
$data = json_decode($buffer,true);
//print_r($race_data);
//print_r($data);
if (isset($data['boats'])) {
foreach ($data['boats'] as $sail) {
$data = array();
$data['id'] = $sail['ubtnr'];
$data['datetime'] = date('Y-m-d H:i:s');
$data['last_update'] = date('Y-m-d H:i:s');
if ($sail['online'] == '1') $data['last_update'] = date('Y-m-d H:i:s');
$data['latitude'] = $sail['ubtlat'];
$data['longitude'] = $sail['ubtlon'];
$data['type_id'] = 36;
$data['heading'] = $sail['ubtheading'];
$data['ident'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($sail['ubtname'])));
$data['captain_name'] = $sail['usrname'];
$allboats = array('Sailaway Cruiser 38','Mini Transat','Caribbean Rose','52' Cruising Cat','50' Performance Cruiser','Nordic Folkboat');
$boattype = $sail['ubtbtpnr'];
$data['type'] = $allboats[$boattype-1];
$data['speed'] = round($sail['ubtspeed']*3.6,2);
$data['format_source'] = 'sailaway';
$data['id_source'] = $id_source;
if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
$MI->add($data);
unset($data);
}
}
}
} elseif ($globalDebug) echo 'Error in JSON parsing';
} elseif ($globalDebug) echo 'Empty result !'."\n";
$last_exec[$id]['last'] = time();
//} elseif (($value === 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value === 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) {
} elseif (
Expand Down

0 comments on commit d50392c

Please sign in to comment.