@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | require_once('../require/settings.php'); |
3 | 3 | require_once('../require/class.Language.php'); |
4 | -setcookie("MapFormat",'2d'); |
|
4 | +setcookie("MapFormat", '2d'); |
|
5 | 5 | header('Content-Type: text/javascript'); |
6 | 6 | ?> |
7 | 7 | /** |
@@ -27,10 +27,10 @@ discard block |
||
27 | 27 | |
28 | 28 | <?php |
29 | 29 | if (isset($_GET['famsatid'])) { |
30 | - $famsatid = filter_input(INPUT_GET,'famsatid',FILTER_SANITIZE_STRING); |
|
30 | + $famsatid = filter_input(INPUT_GET, 'famsatid', FILTER_SANITIZE_STRING); |
|
31 | 31 | } |
32 | 32 | if (isset($_GET['ident'])) { |
33 | - $ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING); |
|
33 | + $ident = filter_input(INPUT_GET, 'ident', FILTER_SANITIZE_STRING); |
|
34 | 34 | } |
35 | 35 | if (!isset($ident) && !isset($famsatid)) { |
36 | 36 | ?> |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | <?php |
176 | 176 | } else { |
177 | 177 | ?> |
178 | - var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000); |
|
178 | + var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000 + 20000; ?>+feature.properties.sqt*1000); |
|
179 | 179 | return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{ |
180 | 180 | <?php |
181 | 181 | } |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | /* |
192 | 192 | shadowUrl: iconURLShadowpath, |
193 | 193 | shadowSize: [<?php print $globalAircraftSize; ?>, <?php print $globalAircraftSize; ?>], |
194 | - shadowAnchor: [<?php print ($globalAircraftSize/2)+1; ?>, <?php print $globalAircraftSize; ?>] |
|
194 | + shadowAnchor: [<?php print ($globalAircraftSize/2) + 1; ?>, <?php print $globalAircraftSize; ?>] |
|
195 | 195 | */ |
196 | 196 | }) |
197 | 197 | }) |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | <?php |
233 | 233 | } else { |
234 | 234 | ?> |
235 | - var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000); |
|
235 | + var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000 + 20000; ?>+feature.properties.sqt*1000); |
|
236 | 236 | return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{ |
237 | 237 | <?php |
238 | 238 | } |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | <?php |
289 | 289 | } else { |
290 | 290 | ?> |
291 | - var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000); |
|
291 | + var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000 + 20000; ?>+feature.properties.sqt*1000); |
|
292 | 292 | return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{ |
293 | 293 | <?php |
294 | 294 | } |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | require_once('../require/settings.php'); |
3 | 3 | require_once('../require/class.Language.php'); |
4 | -setcookie("MapFormat",'2d'); |
|
4 | +setcookie("MapFormat", '2d'); |
|
5 | 5 | header('Content-Type: text/javascript'); |
6 | 6 | ?> |
7 | 7 | /** |
@@ -112,16 +112,16 @@ discard block |
||
112 | 112 | <?php |
113 | 113 | } |
114 | 114 | if (isset($_GET['ident'])) { |
115 | - $ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING); |
|
115 | + $ident = filter_input(INPUT_GET, 'ident', FILTER_SANITIZE_STRING); |
|
116 | 116 | } |
117 | 117 | if (isset($_GET['flightaware_id'])) { |
118 | - $flightaware_id = filter_input(INPUT_GET,'flightaware_id',FILTER_SANITIZE_STRING); |
|
118 | + $flightaware_id = filter_input(INPUT_GET, 'flightaware_id', FILTER_SANITIZE_STRING); |
|
119 | 119 | } |
120 | 120 | if (isset($_GET['latitude'])) { |
121 | - $latitude = filter_input(INPUT_GET,'latitude',FILTER_SANITIZE_STRING); |
|
121 | + $latitude = filter_input(INPUT_GET, 'latitude', FILTER_SANITIZE_STRING); |
|
122 | 122 | } |
123 | 123 | if (isset($_GET['longitude'])) { |
124 | - $longitude = filter_input(INPUT_GET,'longitude',FILTER_SANITIZE_STRING); |
|
124 | + $longitude = filter_input(INPUT_GET, 'longitude', FILTER_SANITIZE_STRING); |
|
125 | 125 | } |
126 | 126 | ?> |
127 | 127 | |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | } else { |
150 | 150 | if ((isset($globalCenterLatitude) && $globalCenterLatitude != '' && isset($globalCenterLongitude) && $globalCenterLongitude != '') || isset($_COOKIE['lastcentercoord'])) { |
151 | 151 | if (isset($_COOKIE['lastcentercoord'])) { |
152 | - $lastcentercoord = explode(',',$_COOKIE['lastcentercoord']); |
|
152 | + $lastcentercoord = explode(',', $_COOKIE['lastcentercoord']); |
|
153 | 153 | $viewcenterlatitude = $lastcentercoord[0]; |
154 | 154 | $viewcenterlongitude = $lastcentercoord[1]; |
155 | 155 | $viewzoom = $lastcentercoord[2]; |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | || navigator.userAgent.match(/BlackBerry/i) |
171 | 171 | || navigator.userAgent.match(/Windows Phone/i)) |
172 | 172 | { |
173 | - var zoom = <?php if (isset($viewzoom) && $viewzoom == $globalLiveZoom) print $viewzoom-1; elseif (isset($viewzoom)) print $viewzoom; else print '8'; ?>; |
|
173 | + var zoom = <?php if (isset($viewzoom) && $viewzoom == $globalLiveZoom) print $viewzoom - 1; elseif (isset($viewzoom)) print $viewzoom; else print '8'; ?>; |
|
174 | 174 | } else { |
175 | 175 | var zoom = <?php if (isset($viewzoom)) print $viewzoom; else print '9'; ?>; |
176 | 176 | } |
@@ -314,19 +314,19 @@ discard block |
||
314 | 314 | map.addLayer(yandexLayer); |
315 | 315 | <?php |
316 | 316 | } elseif ($MapType == 'Bing-Aerial') { |
317 | - if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType','OpenStreetMap'); |
|
317 | + if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType', 'OpenStreetMap'); |
|
318 | 318 | ?> |
319 | 319 | var bingLayer = new L.tileLayer.bing({bingMapsKey: '<?php print $globalBingMapKey; ?>',imagerySet: 'Aerial'}); |
320 | 320 | map.addLayer(bingLayer); |
321 | 321 | <?php |
322 | 322 | } elseif ($MapType == 'Bing-Hybrid') { |
323 | - if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType','OpenStreetMap'); |
|
323 | + if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType', 'OpenStreetMap'); |
|
324 | 324 | ?> |
325 | 325 | var bingLayer = new L.tileLayer.bing({bingMapsKey: '<?php print $globalBingMapKey; ?>',imagerySet: 'AerialWithLabels'}); |
326 | 326 | map.addLayer(bingLayer); |
327 | 327 | <?php |
328 | 328 | } elseif ($MapType == 'Bing-Road') { |
329 | - if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType','OpenStreetMap'); |
|
329 | + if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType', 'OpenStreetMap'); |
|
330 | 330 | ?> |
331 | 331 | var bingLayer = new L.tileLayer.bing({bingMapsKey: '<?php print $globalBingMapKey; ?>',imagerySet: 'Road'}); |
332 | 332 | map.addLayer(bingLayer); |
@@ -464,7 +464,7 @@ discard block |
||
464 | 464 | |
465 | 465 | function update_tsk() { |
466 | 466 | var bbox = map.getBounds().toBBoxString(); |
467 | - var tskLayerQuery = $.getJSON("<?php print $globalURL; ?>/tsk-geojson.php?tsk=<?php echo filter_input(INPUT_GET,'tsk',FILTER_SANITIZE_URL); ?>",function (data) { |
|
467 | + var tskLayerQuery = $.getJSON("<?php print $globalURL; ?>/tsk-geojson.php?tsk=<?php echo filter_input(INPUT_GET, 'tsk', FILTER_SANITIZE_URL); ?>",function (data) { |
|
468 | 468 | tskLayer = L.geoJson(data,{ |
469 | 469 | onEachFeature: function (feature, layer) { |
470 | 470 | tskPopup(feature, layer); |
@@ -59,20 +59,20 @@ discard block |
||
59 | 59 | die; |
60 | 60 | } |
61 | 61 | //$hosts = array($globalSBS1Host.':'.$globalSBS1Port); |
62 | - $globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port); |
|
62 | + $globalSources[] = array('host' => $globalSBS1Host, 'port' => $globalSBS1Port); |
|
63 | 63 | } |
64 | 64 | } |
65 | 65 | |
66 | -$options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver','enable-aircraft','disable-aircraft','enable-tracker','disable-tracker','enable-marine','disable-marine')); |
|
66 | +$options = getopt('s::', array('source::', 'server', 'nodaemon', 'idsource::', 'aprsserverssid::', 'aprsserverpass::', 'aprsserverhost::', 'aprsserverport::', 'format::', 'noaprsserver', 'enable-aircraft', 'disable-aircraft', 'enable-tracker', 'disable-tracker', 'enable-marine', 'disable-marine')); |
|
67 | 67 | //if (isset($options['s'])) $hosts = array($options['s']); |
68 | 68 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
69 | 69 | if (isset($options['s'])) { |
70 | 70 | $globalSources = array(); |
71 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
71 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['s'], 'format' => $options['format']); |
|
72 | 72 | else $globalSources[] = array('host' => $options['s']); |
73 | 73 | } elseif (isset($options['source'])) { |
74 | 74 | $globalSources = array(); |
75 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
75 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['source'], 'format' => $options['format']); |
|
76 | 76 | else $globalSources[] = array('host' => $options['source']); |
77 | 77 | } |
78 | 78 | if (isset($options['aprsserverhost'])) { |
@@ -113,13 +113,13 @@ discard block |
||
113 | 113 | else $id_source = 1; |
114 | 114 | if (isset($globalServer) && $globalServer) { |
115 | 115 | if ($globalDebug) echo "Using Server Mode\n"; |
116 | - $SI=new SpotterServer(); |
|
116 | + $SI = new SpotterServer(); |
|
117 | 117 | /* |
118 | 118 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
119 | 119 | $SI = new adsb2aprs(); |
120 | 120 | $SI->connect(); |
121 | 121 | */ |
122 | -} else $SI=new SpotterImport($Connection->db); |
|
122 | +} else $SI = new SpotterImport($Connection->db); |
|
123 | 123 | |
124 | 124 | if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
125 | 125 | if (isset($globalMarine) && $globalMarine) { |
@@ -133,17 +133,17 @@ discard block |
||
133 | 133 | $MI = new MarineImport($Connection->db); |
134 | 134 | } |
135 | 135 | //$APRS=new APRS($Connection->db); |
136 | -$SBS=new SBS(); |
|
136 | +$SBS = new SBS(); |
|
137 | 137 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
138 | - $ACARS=new ACARS($Connection->db,true); |
|
139 | - $Source=new Source($Connection->db); |
|
138 | + $ACARS = new ACARS($Connection->db, true); |
|
139 | + $Source = new Source($Connection->db); |
|
140 | 140 | } |
141 | -$Common=new Common(); |
|
141 | +$Common = new Common(); |
|
142 | 142 | date_default_timezone_set('UTC'); |
143 | 143 | //$servertz = system('date +%Z'); |
144 | 144 | // signal handler - playing nice with sockets and dump1090 |
145 | 145 | if (function_exists('pcntl_fork')) { |
146 | - pcntl_signal(SIGINT, function() { |
|
146 | + pcntl_signal(SIGINT, function() { |
|
147 | 147 | global $sockets; |
148 | 148 | echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
149 | 149 | die("Bye!\n"); |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | |
160 | 160 | function connect_all($hosts) { |
161 | 161 | //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
162 | - global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
162 | + global $sockets, $httpfeeds, $globalSources, $globalDebug, $aprs_connect, $last_exec, $globalSourcesRights, $use_aprs, $reset, $context; |
|
163 | 163 | $reset++; |
164 | 164 | if ($globalDebug) echo 'Connect to all...'."\n"; |
165 | 165 | foreach ($hosts as $id => $value) { |
@@ -167,33 +167,33 @@ discard block |
||
167 | 167 | $udp = false; |
168 | 168 | $globalSources[$id]['last_exec'] = 0; |
169 | 169 | // Here we check type of source(s) |
170 | - if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
|
171 | - if (preg_match('/deltadb.txt$/i',$host)) { |
|
170 | + if (filter_var($host, FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
|
171 | + if (preg_match('/deltadb.txt$/i', $host)) { |
|
172 | 172 | //$formats[$id] = 'deltadbtxt'; |
173 | 173 | $globalSources[$id]['format'] = 'deltadbtxt'; |
174 | 174 | //$last_exec['deltadbtxt'] = 0; |
175 | 175 | if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
176 | - } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
176 | + } else if (preg_match('/vatsim-data.txt$/i', $host)) { |
|
177 | 177 | //$formats[$id] = 'vatsimtxt'; |
178 | 178 | $globalSources[$id]['format'] = 'vatsimtxt'; |
179 | 179 | //$last_exec['vatsimtxt'] = 0; |
180 | 180 | if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
181 | - } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
181 | + } else if (preg_match('/aircraftlist.json$/i', $host)) { |
|
182 | 182 | //$formats[$id] = 'aircraftlistjson'; |
183 | 183 | $globalSources[$id]['format'] = 'aircraftlistjson'; |
184 | 184 | //$last_exec['aircraftlistjson'] = 0; |
185 | 185 | if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
186 | - } else if (preg_match('/aircraft.json$/i',$host)) { |
|
186 | + } else if (preg_match('/aircraft.json$/i', $host)) { |
|
187 | 187 | //$formats[$id] = 'aircraftjson'; |
188 | 188 | $globalSources[$id]['format'] = 'aircraftjson'; |
189 | 189 | //$last_exec['aircraftlistjson'] = 0; |
190 | 190 | if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n"; |
191 | - } else if (preg_match('/aircraft$/i',$host)) { |
|
191 | + } else if (preg_match('/aircraft$/i', $host)) { |
|
192 | 192 | //$formats[$id] = 'planefinderclient'; |
193 | 193 | $globalSources[$id]['format'] = 'planefinderclient'; |
194 | 194 | //$last_exec['aircraftlistjson'] = 0; |
195 | 195 | if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n"; |
196 | - } else if (preg_match('/opensky/i',$host)) { |
|
196 | + } else if (preg_match('/opensky/i', $host)) { |
|
197 | 197 | //$formats[$id] = 'aircraftlistjson'; |
198 | 198 | $globalSources[$id]['format'] = 'opensky'; |
199 | 199 | //$last_exec['aircraftlistjson'] = 0; |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | exit(0); |
211 | 211 | } |
212 | 212 | */ |
213 | - } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
213 | + } else if (preg_match('/planeUpdateFAA.php$/i', $host)) { |
|
214 | 214 | //$formats[$id] = 'planeupdatefaa'; |
215 | 215 | $globalSources[$id]['format'] = 'planeupdatefaa'; |
216 | 216 | //$last_exec['planeupdatefaa'] = 0; |
@@ -219,37 +219,37 @@ discard block |
||
219 | 219 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
220 | 220 | exit(0); |
221 | 221 | } |
222 | - } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
222 | + } else if (preg_match('/\/action.php\/acars\/data$/i', $host)) { |
|
223 | 223 | //$formats[$id] = 'phpvmacars'; |
224 | 224 | $globalSources[$id]['format'] = 'phpvmacars'; |
225 | 225 | //$last_exec['phpvmacars'] = 0; |
226 | 226 | if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
227 | - } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) { |
|
227 | + } else if (preg_match('/\/api\/v1\/acars\/data$/i', $host)) { |
|
228 | 228 | //$formats[$id] = 'phpvmacars'; |
229 | 229 | $globalSources[$id]['format'] = 'vaos'; |
230 | 230 | //$last_exec['phpvmacars'] = 0; |
231 | 231 | if ($globalDebug) echo "Connect to vaos source (".$host.")...\n"; |
232 | - } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
232 | + } else if (preg_match('/VAM-json.php$/i', $host)) { |
|
233 | 233 | //$formats[$id] = 'phpvmacars'; |
234 | 234 | $globalSources[$id]['format'] = 'vam'; |
235 | 235 | if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
236 | - } else if (preg_match('/whazzup/i',$host)) { |
|
236 | + } else if (preg_match('/whazzup/i', $host)) { |
|
237 | 237 | //$formats[$id] = 'whazzup'; |
238 | 238 | $globalSources[$id]['format'] = 'whazzup'; |
239 | 239 | //$last_exec['whazzup'] = 0; |
240 | 240 | if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
241 | - } else if (preg_match('/blitzortung/i',$host)) { |
|
241 | + } else if (preg_match('/blitzortung/i', $host)) { |
|
242 | 242 | $globalSources[$id]['format'] = 'blitzortung'; |
243 | 243 | if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n"; |
244 | - } else if (preg_match('/airwhere/i',$host)) { |
|
244 | + } else if (preg_match('/airwhere/i', $host)) { |
|
245 | 245 | $globalSources[$id]['format'] = 'airwhere'; |
246 | 246 | if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
247 | - } else if (preg_match('/recentpireps/i',$host)) { |
|
247 | + } else if (preg_match('/recentpireps/i', $host)) { |
|
248 | 248 | //$formats[$id] = 'pirepsjson'; |
249 | 249 | $globalSources[$id]['format'] = 'pirepsjson'; |
250 | 250 | //$last_exec['pirepsjson'] = 0; |
251 | 251 | if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
252 | - } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
252 | + } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i', $host)) { |
|
253 | 253 | //$formats[$id] = 'fr24json'; |
254 | 254 | $globalSources[$id]['format'] = 'fr24json'; |
255 | 255 | //$last_exec['fr24json'] = 0; |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
259 | 259 | exit(0); |
260 | 260 | } |
261 | - } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
261 | + } else if (preg_match(':myshiptracking.com/:i', $host)) { |
|
262 | 262 | //$formats[$id] = 'fr24json'; |
263 | 263 | $globalSources[$id]['format'] = 'myshiptracking'; |
264 | 264 | //$last_exec['fr24json'] = 0; |
@@ -268,14 +268,14 @@ discard block |
||
268 | 268 | exit(0); |
269 | 269 | } |
270 | 270 | //} else if (preg_match('/10001/',$host)) { |
271 | - } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
271 | + } else if (preg_match('/10001/', $host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
272 | 272 | //$formats[$id] = 'tsv'; |
273 | 273 | $globalSources[$id]['format'] = 'tsv'; |
274 | 274 | if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
275 | 275 | } |
276 | - } elseif (filter_var($host,FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailawayfull') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'acarsjson')) { |
|
276 | + } elseif (filter_var($host, FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailawayfull') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'acarsjson')) { |
|
277 | 277 | if ($globalSources[$id]['format'] == 'aisnmeahttp' || $globalSources[$id]['format'] == 'acarsjson') { |
278 | - $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
278 | + $idf = fopen($globalSources[$id]['host'], 'r', false, $context); |
|
279 | 279 | if ($idf !== false) { |
280 | 280 | $httpfeeds[$id] = $idf; |
281 | 281 | if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
@@ -283,8 +283,8 @@ discard block |
||
283 | 283 | } elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n"; |
284 | 284 | elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailawayfull') echo "Connect to ".$globalSources[$id]['format']." source (sailawayfull)...\n"; |
285 | 285 | elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
286 | - } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
287 | - $hostport = explode(':',$host); |
|
286 | + } elseif (!filter_var($host, FILTER_VALIDATE_URL)) { |
|
287 | + $hostport = explode(':', $host); |
|
288 | 288 | if (isset($hostport[1])) { |
289 | 289 | $port = $hostport[1]; |
290 | 290 | $hostn = $hostport[0]; |
@@ -294,20 +294,20 @@ discard block |
||
294 | 294 | } |
295 | 295 | $Common = new Common(); |
296 | 296 | if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acarsjsonudp' && $globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
297 | - $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
297 | + $s = $Common->create_socket($hostn, $port, $errno, $errstr); |
|
298 | 298 | } else { |
299 | 299 | $udp = true; |
300 | - $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
300 | + $s = $Common->create_socket_udp($hostn, $port, $errno, $errstr); |
|
301 | 301 | } |
302 | 302 | if ($s) { |
303 | 303 | $sockets[$id] = $s; |
304 | 304 | if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
305 | - if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
305 | + if (preg_match('/aprs/', $hostn) || $port == '10152' || $port == '14580') { |
|
306 | 306 | //$formats[$id] = 'aprs'; |
307 | 307 | $globalSources[$id]['format'] = 'aprs'; |
308 | 308 | //$aprs_connect = 0; |
309 | 309 | //$use_aprs = true; |
310 | - } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
310 | + } elseif (preg_match('/pub-vrs/', $hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
311 | 311 | $globalSources[$id]['format'] = 'vrstcp'; |
312 | 312 | } elseif ($port == '10001') { |
313 | 313 | //$formats[$id] = 'tsv'; |
@@ -349,7 +349,7 @@ discard block |
||
349 | 349 | else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut; |
350 | 350 | else $timeout = 20; |
351 | 351 | $errno = ''; |
352 | -$errstr=''; |
|
352 | +$errstr = ''; |
|
353 | 353 | |
354 | 354 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
355 | 355 | /* Initiate connections to all the hosts simultaneously */ |
@@ -357,7 +357,7 @@ discard block |
||
357 | 357 | //connect_all($globalSources); |
358 | 358 | |
359 | 359 | if (isset($globalProxy) && $globalProxy) { |
360 | - $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
360 | + $context = stream_context_create(array('http' => array('timeout' => $timeout, 'proxy' => $globalProxy, 'request_fulluri' => true))); |
|
361 | 361 | } else { |
362 | 362 | $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
363 | 363 | } |
@@ -387,16 +387,16 @@ discard block |
||
387 | 387 | |
388 | 388 | if ($use_aprs) { |
389 | 389 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
390 | - $APRS=new APRS(); |
|
390 | + $APRS = new APRS(); |
|
391 | 391 | $aprs_connect = 0; |
392 | 392 | $aprs_keep = 120; |
393 | 393 | $aprs_last_tx = time(); |
394 | 394 | if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; |
395 | - else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
395 | + else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName); |
|
396 | 396 | if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid; |
397 | - else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
397 | + else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8); |
|
398 | 398 | if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter; |
399 | - else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
399 | + else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
400 | 400 | if ($aprs_full) $aprs_filter = ''; |
401 | 401 | if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass; |
402 | 402 | else $aprs_pass = '-1'; |
@@ -410,12 +410,12 @@ discard block |
||
410 | 410 | sleep(1); |
411 | 411 | if ($globalDebug) echo "SCAN MODE \n\n"; |
412 | 412 | if (!isset($globalCronEnd)) $globalCronEnd = 60; |
413 | -$endtime = time()+$globalCronEnd; |
|
413 | +$endtime = time() + $globalCronEnd; |
|
414 | 414 | $i = 1; |
415 | 415 | $tt = array(); |
416 | 416 | // Delete all ATC |
417 | 417 | if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) { |
418 | - $ATC=new ATC($Connection->db); |
|
418 | + $ATC = new ATC($Connection->db); |
|
419 | 419 | } |
420 | 420 | if (!$globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
421 | 421 | $ATC->deleteAll(); |
@@ -425,7 +425,7 @@ discard block |
||
425 | 425 | while ($i > 0) { |
426 | 426 | if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
427 | 427 | |
428 | - if (!$globalDaemon) $i = $endtime-time(); |
|
428 | + if (!$globalDaemon) $i = $endtime - time(); |
|
429 | 429 | // Delete old ATC |
430 | 430 | if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
431 | 431 | if ($globalDebug) echo 'Delete old ATC...'."\n"; |
@@ -439,7 +439,7 @@ discard block |
||
439 | 439 | } |
440 | 440 | if ($max < $globalMinFetch) { |
441 | 441 | if ($globalDebug) echo 'Sleeping...'."\n"; |
442 | - sleep($globalMinFetch-$max+2); |
|
442 | + sleep($globalMinFetch - $max + 2); |
|
443 | 443 | } |
444 | 444 | } |
445 | 445 | |
@@ -494,10 +494,10 @@ discard block |
||
494 | 494 | //$buffer = $Common->getData($hosts[$id]); |
495 | 495 | $buffer = $Common->getData($value['host']); |
496 | 496 | if ($buffer != '') { |
497 | - $all_data = json_decode($buffer,true); |
|
497 | + $all_data = json_decode($buffer, true); |
|
498 | 498 | foreach ($all_data as $line) { |
499 | 499 | $data = array(); |
500 | - $data['datetime'] = date('Y-m-d H:i:s',$line['uti']); |
|
500 | + $data['datetime'] = date('Y-m-d H:i:s', $line['uti']); |
|
501 | 501 | $data['hex'] = $line['hex']; // hex |
502 | 502 | $data['ident'] = $line['fli']; // ident |
503 | 503 | $data['altitude'] = $line['alt']; // altitude |
@@ -532,11 +532,11 @@ discard block |
||
532 | 532 | ) |
533 | 533 | ) { |
534 | 534 | date_default_timezone_set('CET'); |
535 | - $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
535 | + $buffer = $Common->getData(str_replace('{date}', date('Ymd'), $value['host'])); |
|
536 | 536 | date_default_timezone_set('UTC'); |
537 | 537 | if ($buffer != '') $reset = 0; |
538 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
539 | - $buffer = explode('\n',$buffer); |
|
538 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
539 | + $buffer = explode('\n', $buffer); |
|
540 | 540 | foreach ($buffer as $line) { |
541 | 541 | if ($line != '') { |
542 | 542 | //echo "'".$line."'\n"; |
@@ -544,7 +544,7 @@ discard block |
||
544 | 544 | $ais_data = $AIS->parse_line(trim($line)); |
545 | 545 | $data = array(); |
546 | 546 | if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
547 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
547 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'], -9); |
|
548 | 548 | if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
549 | 549 | if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
550 | 550 | if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
@@ -556,7 +556,7 @@ discard block |
||
556 | 556 | if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
557 | 557 | if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
558 | 558 | if (isset($ais_data['timestamp'])) { |
559 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
559 | + $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); |
|
560 | 560 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
561 | 561 | $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
562 | 562 | $add = true; |
@@ -579,21 +579,21 @@ discard block |
||
579 | 579 | $w = $e = null; |
580 | 580 | |
581 | 581 | if (isset($arr[$id])) { |
582 | - $nn = stream_select($arr,$w,$e,$timeout); |
|
582 | + $nn = stream_select($arr, $w, $e, $timeout); |
|
583 | 583 | if ($nn > 0) { |
584 | 584 | foreach ($httpfeeds as $feed) { |
585 | - $buffer = stream_get_line($feed,2000,"\n"); |
|
585 | + $buffer = stream_get_line($feed, 2000, "\n"); |
|
586 | 586 | if ($buffer === FALSE) { |
587 | 587 | connect_all($globalSources); |
588 | 588 | } |
589 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
590 | - $buffer = explode('\n',$buffer); |
|
589 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
590 | + $buffer = explode('\n', $buffer); |
|
591 | 591 | foreach ($buffer as $line) { |
592 | 592 | if ($line != '') { |
593 | 593 | $ais_data = $AIS->parse_line(trim($line)); |
594 | 594 | $data = array(); |
595 | 595 | if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
596 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
596 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'], -9); |
|
597 | 597 | if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
598 | 598 | if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
599 | 599 | if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
@@ -605,9 +605,9 @@ discard block |
||
605 | 605 | if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
606 | 606 | if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
607 | 607 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
608 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
608 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']); |
|
609 | 609 | if (isset($ais_data['timestamp'])) { |
610 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
610 | + $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); |
|
611 | 611 | } else { |
612 | 612 | $data['datetime'] = date('Y-m-d H:i:s'); |
613 | 613 | } |
@@ -639,10 +639,10 @@ discard block |
||
639 | 639 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
640 | 640 | ) |
641 | 641 | ) { |
642 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
642 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20'); |
|
643 | 643 | if ($buffer != '') { |
644 | 644 | //echo $buffer; |
645 | - $all_data = json_decode($buffer,true); |
|
645 | + $all_data = json_decode($buffer, true); |
|
646 | 646 | //print_r($all_data); |
647 | 647 | if (isset($all_data[0]['DATA'])) { |
648 | 648 | foreach ($all_data[0]['DATA'] as $line) { |
@@ -651,7 +651,7 @@ discard block |
||
651 | 651 | $data['ident'] = $line['NAME']; |
652 | 652 | $data['mmsi'] = $line['MMSI']; |
653 | 653 | if (strlen($data['mmsi']) > 9) { |
654 | - $data['mmsi'] = substr($data['mmsi'],-9); |
|
654 | + $data['mmsi'] = substr($data['mmsi'], -9); |
|
655 | 655 | } |
656 | 656 | $data['speed'] = $line['SOG']; |
657 | 657 | $data['heading'] = $line['COG']; |
@@ -661,8 +661,8 @@ discard block |
||
661 | 661 | //$data['type_id'] = $line['TYPE']; |
662 | 662 | $data['imo'] = $line['IMO']; |
663 | 663 | if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST']; |
664 | - if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV'])); |
|
665 | - $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
|
664 | + if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s', strtotime($line['ARV'])); |
|
665 | + $data['datetime'] = date('Y-m-d H:i:s', $line['T']); |
|
666 | 666 | $data['format_source'] = 'myshiptracking'; |
667 | 667 | $data['id_source'] = $id_source; |
668 | 668 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
@@ -679,16 +679,16 @@ discard block |
||
679 | 679 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
680 | 680 | ) |
681 | 681 | ) { |
682 | - $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
682 | + $buffer = $Common->getData(str_replace('{timestamp}', time(), $value['host'])); |
|
683 | 683 | if ($buffer != '') { |
684 | - $all_data = json_decode($buffer,true); |
|
684 | + $all_data = json_decode($buffer, true); |
|
685 | 685 | if (isset($all_data[0]['mmsi'])) { |
686 | 686 | foreach ($all_data as $line) { |
687 | 687 | if ($line != '') { |
688 | 688 | $data = array(); |
689 | 689 | $data['ident'] = $line['shipname']; |
690 | 690 | $data['callsign'] = $line['callsign']; |
691 | - $data['mmsi'] = substr($line['mmsi'],-9); |
|
691 | + $data['mmsi'] = substr($line['mmsi'], -9); |
|
692 | 692 | $data['speed'] = $line['sog']; |
693 | 693 | if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
694 | 694 | $data['latitude'] = $line['latitude']; |
@@ -715,14 +715,14 @@ discard block |
||
715 | 715 | ) { |
716 | 716 | $buffer = $Common->getData($value['host']); |
717 | 717 | if ($buffer != '') { |
718 | - $all_data = json_decode($buffer,true); |
|
718 | + $all_data = json_decode($buffer, true); |
|
719 | 719 | if (isset($all_data['features'][0]['id'])) { |
720 | 720 | foreach ($all_data['features'] as $line) { |
721 | 721 | print_r($line); |
722 | 722 | $data = array(); |
723 | 723 | if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name']; |
724 | 724 | if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign']; |
725 | - if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'],-9); |
|
725 | + if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'], -9); |
|
726 | 726 | if (isset($line['properties']['imo'])) $data['imo'] = $line['properties']['imo']; |
727 | 727 | if (isset($line['properties']['speed'])) $data['speed'] = $line['properties']['speed']; |
728 | 728 | if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) $data['heading'] = $line['properties']['heading']; |
@@ -749,31 +749,31 @@ discard block |
||
749 | 749 | ) |
750 | 750 | ) { |
751 | 751 | if ($globalDebug) echo 'download...'; |
752 | - $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
752 | + $buffer = $Common->getData($value['host'], 'post', $value['post'], '', '', '', '', 'ShipPlotter'); |
|
753 | 753 | if ($globalDebug) echo 'done !'."\n"; |
754 | 754 | // FIXME: Need more work |
755 | 755 | if ($buffer != '') $reset = 0; |
756 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
757 | - $buffer = explode('\n',$buffer); |
|
756 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
757 | + $buffer = explode('\n', $buffer); |
|
758 | 758 | foreach ($buffer as $line) { |
759 | 759 | if ($line != '') { |
760 | 760 | $data = array(); |
761 | 761 | //echo $line."\n"; |
762 | - $data['mmsi'] = (int)substr($line,0,9); |
|
763 | - $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
764 | - $data['status_id'] = substr($line,21,2); |
|
765 | - $data['type_id'] = substr($line,24,3); |
|
766 | - $data['latitude'] = substr($line,29,9); |
|
767 | - $data['longitude'] = substr($line,41,9); |
|
768 | - $data['speed'] = round(substr($line,51,5)); |
|
762 | + $data['mmsi'] = (int) substr($line, 0, 9); |
|
763 | + $data['datetime'] = date('Y-m-d H:i:s', substr($line, 10, 10)); |
|
764 | + $data['status_id'] = substr($line, 21, 2); |
|
765 | + $data['type_id'] = substr($line, 24, 3); |
|
766 | + $data['latitude'] = substr($line, 29, 9); |
|
767 | + $data['longitude'] = substr($line, 41, 9); |
|
768 | + $data['speed'] = round(substr($line, 51, 5)); |
|
769 | 769 | //$data['course'] = substr($line,57,5); |
770 | - $data['heading'] = round(substr($line,63,3)); |
|
770 | + $data['heading'] = round(substr($line, 63, 3)); |
|
771 | 771 | //$data['draft'] = substr($line,67,4); |
772 | 772 | //$data['length'] = substr($line,72,3); |
773 | 773 | //$data['beam'] = substr($line,76,2); |
774 | - $data['ident'] = trim(utf8_encode(substr($line,78,20))); |
|
774 | + $data['ident'] = trim(utf8_encode(substr($line, 78, 20))); |
|
775 | 775 | //$data['callsign'] = trim(substr($line,100,7); |
776 | - $data['arrival_code'] = substr($line,108,20); |
|
776 | + $data['arrival_code'] = substr($line, 108, 20); |
|
777 | 777 | //$data['etaDate'] = substr($line,129,5); |
778 | 778 | //$data['etaTime'] = substr($line,135,5); |
779 | 779 | $data['format_source'] = 'shipplotter'; |
@@ -796,28 +796,28 @@ discard block |
||
796 | 796 | exit(0); |
797 | 797 | } |
798 | 798 | $sailawayoption = array('key' => $globalSailaway['key']); |
799 | - if (isset($globalSailaway['usrnr'])) $sailawayoption = array_merge($sailawayoption,array('usrnr' => $globalSailaway['usrnr'])); |
|
800 | - if (isset($globalSailaway['ubtnr'])) $sailawayoption = array_merge($sailawayoption,array('ubtnr' => $globalSailaway['ubtnr'])); |
|
799 | + if (isset($globalSailaway['usrnr'])) $sailawayoption = array_merge($sailawayoption, array('usrnr' => $globalSailaway['usrnr'])); |
|
800 | + if (isset($globalSailaway['ubtnr'])) $sailawayoption = array_merge($sailawayoption, array('ubtnr' => $globalSailaway['ubtnr'])); |
|
801 | 801 | |
802 | 802 | for ($i = 0; $i <= 1; $i++) { |
803 | 803 | if ($globalDebug) echo '! Download... '; |
804 | - $buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/GetMissions.pl?'.http_build_query($sailawayoption).'&race='.$i.'&tutorial=0&hist=1&racetype=2&challengetype=2','get','','','','',30); |
|
804 | + $buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/GetMissions.pl?'.http_build_query($sailawayoption).'&race='.$i.'&tutorial=0&hist=1&racetype=2&challengetype=2', 'get', '', '', '', '', 30); |
|
805 | 805 | if ($globalDebug) echo 'done'."\n"; |
806 | 806 | if ($buffer != '') { |
807 | - $all_data = json_decode($buffer,true); |
|
807 | + $all_data = json_decode($buffer, true); |
|
808 | 808 | if (isset($all_data['missions'])) { |
809 | 809 | foreach ($all_data['missions'] as $mission) { |
810 | 810 | $mission_user = $mission['usrname']; |
811 | - $mission_name = preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($mission['mistitle'])); |
|
812 | - if (!isset($globalFilter['sailway']['race']) || (isset($globalFilter['sailway']['race']) && in_array($mission['misnr'],$globalFilter['sailway']['race']))) { |
|
811 | + $mission_name = preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $Common->remove_accents($mission['mistitle'])); |
|
812 | + if (!isset($globalFilter['sailway']['race']) || (isset($globalFilter['sailway']['race']) && in_array($mission['misnr'], $globalFilter['sailway']['race']))) { |
|
813 | 813 | //print_r($mission); |
814 | 814 | $datar = array(); |
815 | 815 | $datar['id'] = $mission['misnr']; |
816 | 816 | $datar['desc'] = $mission['misdescr']; |
817 | 817 | //$datar['creator'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($mission['usrname']))); |
818 | 818 | $datar['creator'] = ''; |
819 | - $datar['name'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($mission['mistitle']))); |
|
820 | - if (isset($mission['misstart'])) $datar['startdate'] = date('Y-m-d H:i:s',strtotime($mission['misstart'])); |
|
819 | + $datar['name'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $Common->remove_accents($mission['mistitle']))); |
|
820 | + if (isset($mission['misstart'])) $datar['startdate'] = date('Y-m-d H:i:s', strtotime($mission['misstart'])); |
|
821 | 821 | else $datar['startdate'] = '1970-01-01 00:00:00'; |
822 | 822 | /* |
823 | 823 | $markers = array(); |
@@ -837,9 +837,9 @@ discard block |
||
837 | 837 | if ($globalDebug) echo '=== Wait... ==='; |
838 | 838 | sleep(10*60); |
839 | 839 | } |
840 | - $buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/TrackAllBoats.pl?'.http_build_query($sailawayoption),'get','','','','',30); |
|
840 | + $buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/TrackAllBoats.pl?'.http_build_query($sailawayoption), 'get', '', '', '', '', 30); |
|
841 | 841 | if ($buffer != '') { |
842 | - $data = json_decode($buffer,true); |
|
842 | + $data = json_decode($buffer, true); |
|
843 | 843 | //print_r($data); |
844 | 844 | if (isset($data['boats'])) { |
845 | 845 | foreach ($data['boats'] as $sail) { |
@@ -851,12 +851,12 @@ discard block |
||
851 | 851 | $data['longitude'] = $sail['ubtlon']; |
852 | 852 | $data['type_id'] = 36; |
853 | 853 | $data['heading'] = $sail['ubtheading']; |
854 | - $data['ident'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($sail['ubtname']))); |
|
854 | + $data['ident'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $Common->remove_accents($sail['ubtname']))); |
|
855 | 855 | $data['captain_name'] = $sail['usrname']; |
856 | - $allboats = array('Sailaway Cruiser 38','Mini Transat','Caribbean Rose','52' Cruising Cat','50' Performance Cruiser','Nordic Folkboat','32' Offshore Racer'); |
|
856 | + $allboats = array('Sailaway Cruiser 38', 'Mini Transat', 'Caribbean Rose', '52' Cruising Cat', '50' Performance Cruiser', 'Nordic Folkboat', '32' Offshore Racer'); |
|
857 | 857 | $boattype = $sail['ubtbtpnr']; |
858 | - if (isset($allboats[$boattype-1])) $data['type'] = $allboats[$boattype-1]; |
|
859 | - $data['speed'] = round($sail['ubtspeed']*3.6,2); |
|
858 | + if (isset($allboats[$boattype - 1])) $data['type'] = $allboats[$boattype - 1]; |
|
859 | + $data['speed'] = round($sail['ubtspeed']*3.6, 2); |
|
860 | 860 | $data['format_source'] = 'sailaway'; |
861 | 861 | $data['id_source'] = $id_source; |
862 | 862 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
@@ -889,11 +889,11 @@ discard block |
||
889 | 889 | } |
890 | 890 | if ($globalDebug) echo '! Download... '; |
891 | 891 | $sailawayoption = array('key' => $globalSailaway['key']); |
892 | - if (isset($globalSailaway['usrnr'])) $sailawayoption = array_merge($sailawayoption,array('usrnr' => $globalSailaway['usrnr'])); |
|
893 | - if (isset($globalSailaway['ubtnr'])) $sailawayoption = array_merge($sailawayoption,array('ubtnr' => $globalSailaway['ubtnr'])); |
|
894 | - $buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/TrackAllBoats.pl?'.http_build_query($sailawayoption),'get','','','','',30); |
|
892 | + if (isset($globalSailaway['usrnr'])) $sailawayoption = array_merge($sailawayoption, array('usrnr' => $globalSailaway['usrnr'])); |
|
893 | + if (isset($globalSailaway['ubtnr'])) $sailawayoption = array_merge($sailawayoption, array('ubtnr' => $globalSailaway['ubtnr'])); |
|
894 | + $buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/TrackAllBoats.pl?'.http_build_query($sailawayoption), 'get', '', '', '', '', 30); |
|
895 | 895 | if ($buffer != '') { |
896 | - $data = json_decode($buffer,true); |
|
896 | + $data = json_decode($buffer, true); |
|
897 | 897 | //print_r($data); |
898 | 898 | if (isset($data['boats'])) { |
899 | 899 | foreach ($data['boats'] as $sail) { |
@@ -905,12 +905,12 @@ discard block |
||
905 | 905 | $data['longitude'] = $sail['ubtlon']; |
906 | 906 | $data['type_id'] = 36; |
907 | 907 | $data['heading'] = $sail['ubtheading']; |
908 | - $data['ident'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($sail['ubtname']))); |
|
908 | + $data['ident'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $Common->remove_accents($sail['ubtname']))); |
|
909 | 909 | $data['captain_name'] = $sail['usrname']; |
910 | - $allboats = array('Sailaway Cruiser 38','Mini Transat','Caribbean Rose','52' Cruising Cat','50' Performance Cruiser','Nordic Folkboat','32' Offshore Racer'); |
|
910 | + $allboats = array('Sailaway Cruiser 38', 'Mini Transat', 'Caribbean Rose', '52' Cruising Cat', '50' Performance Cruiser', 'Nordic Folkboat', '32' Offshore Racer'); |
|
911 | 911 | $boattype = $sail['ubtbtpnr']; |
912 | - if (isset($allboats[$boattype-1])) $data['type'] = $allboats[$boattype-1]; |
|
913 | - $data['speed'] = round($sail['ubtspeed']*3.6,2); |
|
912 | + if (isset($allboats[$boattype - 1])) $data['type'] = $allboats[$boattype - 1]; |
|
913 | + $data['speed'] = round($sail['ubtspeed']*3.6, 2); |
|
914 | 914 | $data['format_source'] = 'sailaway'; |
915 | 915 | $data['id_source'] = $id_source; |
916 | 916 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
@@ -938,8 +938,8 @@ discard block |
||
938 | 938 | ) { |
939 | 939 | //$buffer = $Common->getData($hosts[$id]); |
940 | 940 | $buffer = $Common->getData($value['host']); |
941 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
942 | - $buffer = explode('\n',$buffer); |
|
941 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
942 | + $buffer = explode('\n', $buffer); |
|
943 | 943 | $reset = 0; |
944 | 944 | foreach ($buffer as $line) { |
945 | 945 | if ($line != '') { |
@@ -950,7 +950,7 @@ discard block |
||
950 | 950 | else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
951 | 951 | $data['pilot_id'] = $line[1]; |
952 | 952 | $data['pilot_name'] = $line[2]; |
953 | - $data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT); |
|
953 | + $data['hex'] = str_pad(dechex($Common->str2int($line[1])), 6, '000000', STR_PAD_LEFT); |
|
954 | 954 | $data['ident'] = $line[0]; // ident |
955 | 955 | if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude |
956 | 956 | $data['speed'] = $line[8]; // speed |
@@ -966,7 +966,7 @@ discard block |
||
966 | 966 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); |
967 | 967 | //if (isset($line[37])) $data['last_update'] = $line[37]; |
968 | 968 | $data['departure_airport_icao'] = $line[11]; |
969 | - $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
969 | + $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':'); |
|
970 | 970 | $data['arrival_airport_icao'] = $line[13]; |
971 | 971 | $data['frequency'] = $line[4]; |
972 | 972 | $data['type'] = $line[18]; |
@@ -975,7 +975,7 @@ discard block |
||
975 | 975 | $data['id_source'] = $id_source; |
976 | 976 | //$data['arrival_airport_time'] = ; |
977 | 977 | if ($line[9] != '') { |
978 | - $aircraft_data = explode('/',$line[9]); |
|
978 | + $aircraft_data = explode('/', $line[9]); |
|
979 | 979 | if (count($aircraft_data) == 2) { |
980 | 980 | //line[9] may equal to something like 'B738/L' in old FSD server's whazzup.txt file |
981 | 981 | $data['aircraft_icao'] = $aircraft_data[0]; |
@@ -994,9 +994,9 @@ discard block |
||
994 | 994 | if ($line[3] === 'PILOT') $SI->add($data); |
995 | 995 | elseif ($line[3] === 'ATC') { |
996 | 996 | //print_r($data); |
997 | - $data['info'] = str_replace('^§','<br />',$data['info']); |
|
998 | - $data['info'] = str_replace('&sect;','',$data['info']); |
|
999 | - $typec = substr($data['ident'],-3); |
|
997 | + $data['info'] = str_replace('^§', '<br />', $data['info']); |
|
998 | + $data['info'] = str_replace('&sect;', '', $data['info']); |
|
999 | + $typec = substr($data['ident'], -3); |
|
1000 | 1000 | if ($typec === 'APP') $data['type'] = 'Approach'; |
1001 | 1001 | elseif ($typec === 'TWR') $data['type'] = 'Tower'; |
1002 | 1002 | elseif ($typec === 'OBS') $data['type'] = 'Observer'; |
@@ -1008,8 +1008,8 @@ discard block |
||
1008 | 1008 | elseif ($data['type'] === '') $data['type'] = 'Observer'; |
1009 | 1009 | if (!isset($data['source_name'])) $data['source_name'] = ''; |
1010 | 1010 | if (isset($ATC)) { |
1011 | - if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) echo $ATC->update($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']); |
|
1012 | - else echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']); |
|
1011 | + if (count($ATC->getByIdent($data['ident'], $data['format_source'])) > 0) echo $ATC->update($data['ident'], $data['frequency'], $data['latitude'], $data['longitude'], $data['range'], $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name'], $data['format_source'], $data['source_name']); |
|
1012 | + else echo $ATC->add($data['ident'], $data['frequency'], $data['latitude'], $data['longitude'], $data['range'], $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name'], $data['format_source'], $data['source_name']); |
|
1013 | 1013 | } |
1014 | 1014 | } |
1015 | 1015 | unset($data); |
@@ -1025,24 +1025,24 @@ discard block |
||
1025 | 1025 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1026 | 1026 | ) |
1027 | 1027 | ) { |
1028 | - $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20'); |
|
1028 | + $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php', 'get', '', '', '', '', '20'); |
|
1029 | 1029 | if ($buffer != '') { |
1030 | 1030 | $all_data = simplexml_load_string($buffer); |
1031 | - foreach($all_data->children() as $childdata) { |
|
1031 | + foreach ($all_data->children() as $childdata) { |
|
1032 | 1032 | $data = array(); |
1033 | 1033 | $line = $childdata; |
1034 | 1034 | //$data['hex'] = str_pad(dechex((int)$line['pktPilotID']),6,'000000',STR_PAD_LEFT); |
1035 | - $data['id'] = date('Ymd').(int)$line['pktPilotID']; |
|
1036 | - $data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST')); |
|
1037 | - $data['latitude'] = (float)$line['pktLatitude']; |
|
1038 | - $data['longitude'] = (float)$line['pktLongitude']; |
|
1039 | - if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack']; |
|
1040 | - if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed']; |
|
1041 | - $data['altitude'] = round((int)$line['pktAltitude']*3.28084); |
|
1035 | + $data['id'] = date('Ymd').(int) $line['pktPilotID']; |
|
1036 | + $data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['entryTime'].' BST')); |
|
1037 | + $data['latitude'] = (float) $line['pktLatitude']; |
|
1038 | + $data['longitude'] = (float) $line['pktLongitude']; |
|
1039 | + if ((float) $line['pktTrack'] != 0) $data['heading'] = (float) $line['pktTrack']; |
|
1040 | + if ((int) $line['pktSpeed'] != 0) $data['speed'] = (int) $line['pktSpeed']; |
|
1041 | + $data['altitude'] = round((int) $line['pktAltitude']*3.28084); |
|
1042 | 1042 | $data['altitude_relative'] = 'AMSL'; |
1043 | - $data['pilot_id'] = (int)$line['pktPilotID']; |
|
1043 | + $data['pilot_id'] = (int) $line['pktPilotID']; |
|
1044 | 1044 | $data['aircraft_icao'] = 'PARAGLIDER'; |
1045 | - $pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id'])); |
|
1045 | + $pilot_data = explode(',', $Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id'])); |
|
1046 | 1046 | if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4]; |
1047 | 1047 | $data['format_source'] = $value['format']; |
1048 | 1048 | $SI->add($data); |
@@ -1050,22 +1050,22 @@ discard block |
||
1050 | 1050 | } |
1051 | 1051 | } |
1052 | 1052 | $Source->deleteOldLocationByType('gs'); |
1053 | - $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20'); |
|
1053 | + $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php', 'get', '', '', '', '', '20'); |
|
1054 | 1054 | if ($buffer != '') { |
1055 | 1055 | $all_data = simplexml_load_string($buffer); |
1056 | - foreach($all_data->children() as $childdata) { |
|
1056 | + foreach ($all_data->children() as $childdata) { |
|
1057 | 1057 | $data = array(); |
1058 | 1058 | $line = $childdata; |
1059 | - $data['id'] = (int)$line['gsID']; |
|
1060 | - $data['latitude'] = (float)$line['gsLatitude']; |
|
1061 | - $data['longitude'] = (float)$line['gsLongitude']; |
|
1062 | - $data['altitude'] = round((int)$line['gsHeight']*3.28084); |
|
1059 | + $data['id'] = (int) $line['gsID']; |
|
1060 | + $data['latitude'] = (float) $line['gsLatitude']; |
|
1061 | + $data['longitude'] = (float) $line['gsLongitude']; |
|
1062 | + $data['altitude'] = round((int) $line['gsHeight']*3.28084); |
|
1063 | 1063 | $data['altitude_relative'] = 'AMSL'; |
1064 | - $data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['gsLastUpdate'].' BST')); |
|
1064 | + $data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['gsLastUpdate'].' BST')); |
|
1065 | 1065 | if (count($Source->getLocationInfoByLocationID($data['id'])) > 0) { |
1066 | - $Source->updateLocationByLocationID('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']); |
|
1066 | + $Source->updateLocationByLocationID('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']); |
|
1067 | 1067 | } else { |
1068 | - $Source->addLocation('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']); |
|
1068 | + $Source->addLocation('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']); |
|
1069 | 1069 | } |
1070 | 1070 | unset($data); |
1071 | 1071 | } |
@@ -1083,9 +1083,9 @@ discard block |
||
1083 | 1083 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1084 | 1084 | ) |
1085 | 1085 | ) { |
1086 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
1086 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20'); |
|
1087 | 1087 | if ($buffer != '') { |
1088 | - $all_data = json_decode($buffer,true); |
|
1088 | + $all_data = json_decode($buffer, true); |
|
1089 | 1089 | if (isset($all_data['acList'])) { |
1090 | 1090 | $reset = 0; |
1091 | 1091 | foreach ($all_data['acList'] as $line) { |
@@ -1101,7 +1101,7 @@ discard block |
||
1101 | 1101 | if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
1102 | 1102 | $data['emergency'] = ''; // emergency |
1103 | 1103 | if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
1104 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
1104 | + if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000)); |
|
1105 | 1105 | else $data['datetime'] = date('Y-m-d H:i:s'); |
1106 | 1106 | //$data['datetime'] = date('Y-m-d H:i:s'); |
1107 | 1107 | if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
@@ -1126,7 +1126,7 @@ discard block |
||
1126 | 1126 | $data['verticalrate'] = $line['vrt']; // verticale rate |
1127 | 1127 | $data['squawk'] = $line['squawk']; // squawk |
1128 | 1128 | $data['emergency'] = ''; // emergency |
1129 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
1129 | + if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000)); |
|
1130 | 1130 | else $data['datetime'] = date('Y-m-d H:i:s'); |
1131 | 1131 | $data['format_source'] = 'aircraftlistjson'; |
1132 | 1132 | $data['id_source'] = $id_source; |
@@ -1147,7 +1147,7 @@ discard block |
||
1147 | 1147 | ) |
1148 | 1148 | ) { |
1149 | 1149 | $buffer = $Common->getData($value['host']); |
1150 | - $all_data = json_decode($buffer,true); |
|
1150 | + $all_data = json_decode($buffer, true); |
|
1151 | 1151 | if (isset($all_data['planes'])) { |
1152 | 1152 | $reset = 0; |
1153 | 1153 | foreach ($all_data['planes'] as $key => $line) { |
@@ -1164,12 +1164,12 @@ discard block |
||
1164 | 1164 | $data['emergency'] = ''; // emergency |
1165 | 1165 | $data['registration'] = $line[2]; |
1166 | 1166 | $data['aircraft_icao'] = $line[0]; |
1167 | - $deparr = explode('-',$line[1]); |
|
1167 | + $deparr = explode('-', $line[1]); |
|
1168 | 1168 | if (count($deparr) === 2) { |
1169 | 1169 | $data['departure_airport_icao'] = $deparr[0]; |
1170 | 1170 | $data['arrival_airport_icao'] = $deparr[1]; |
1171 | 1171 | } |
1172 | - $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
1172 | + $data['datetime'] = date('Y-m-d H:i:s', $line[9]); |
|
1173 | 1173 | $data['format_source'] = 'planeupdatefaa'; |
1174 | 1174 | $data['id_source'] = $id_source; |
1175 | 1175 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
@@ -1187,7 +1187,7 @@ discard block |
||
1187 | 1187 | ) |
1188 | 1188 | ) { |
1189 | 1189 | $buffer = $Common->getData($value['host']); |
1190 | - $all_data = json_decode($buffer,true); |
|
1190 | + $all_data = json_decode($buffer, true); |
|
1191 | 1191 | if (isset($all_data['states'])) { |
1192 | 1192 | $reset = 0; |
1193 | 1193 | foreach ($all_data['states'] as $key => $line) { |
@@ -1204,7 +1204,7 @@ discard block |
||
1204 | 1204 | //$data['emergency'] = ''; // emergency |
1205 | 1205 | //$data['registration'] = $line[2]; |
1206 | 1206 | //$data['aircraft_icao'] = $line[0]; |
1207 | - $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
1207 | + $data['datetime'] = date('Y-m-d H:i:s', $line[3]); |
|
1208 | 1208 | $data['format_source'] = 'opensky'; |
1209 | 1209 | $data['id_source'] = $id_source; |
1210 | 1210 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
@@ -1221,8 +1221,8 @@ discard block |
||
1221 | 1221 | ) |
1222 | 1222 | ) { |
1223 | 1223 | $buffer = $Common->getData($value['host']); |
1224 | - $all_data = json_decode($buffer,true); |
|
1225 | - if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time()-1800) { |
|
1224 | + $all_data = json_decode($buffer, true); |
|
1225 | + if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time() - 1800) { |
|
1226 | 1226 | $reset = 0; |
1227 | 1227 | foreach ($all_data['aircraft'] as $key => $line) { |
1228 | 1228 | $data = array(); |
@@ -1260,7 +1260,7 @@ discard block |
||
1260 | 1260 | ) |
1261 | 1261 | ) { |
1262 | 1262 | $buffer = $Common->getData($value['host']); |
1263 | - $all_data = json_decode($buffer,true); |
|
1263 | + $all_data = json_decode($buffer, true); |
|
1264 | 1264 | if (isset($all_data['aircraft'])) { |
1265 | 1265 | $reset = 0; |
1266 | 1266 | foreach ($all_data['aircraft'] as $key => $line) { |
@@ -1277,7 +1277,7 @@ discard block |
||
1277 | 1277 | //$data['emergency'] = ''; // emergency |
1278 | 1278 | if (isset($line['reg'])) $data['registration'] = $line['reg']; |
1279 | 1279 | if (isset($line['type'])) $data['aircraft_icao'] = $line['type']; |
1280 | - $data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']); |
|
1280 | + $data['datetime'] = date('Y-m-d H:i:s', $line['pos_update_time']); |
|
1281 | 1281 | $data['format_source'] = 'planefinderclient'; |
1282 | 1282 | $data['id_source'] = $id_source; |
1283 | 1283 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
@@ -1296,7 +1296,7 @@ discard block |
||
1296 | 1296 | ) { |
1297 | 1297 | //$buffer = $Common->getData($hosts[$id]); |
1298 | 1298 | $buffer = $Common->getData($value['host']); |
1299 | - $all_data = json_decode($buffer,true); |
|
1299 | + $all_data = json_decode($buffer, true); |
|
1300 | 1300 | if (!empty($all_data)) $reset = 0; |
1301 | 1301 | foreach ($all_data as $key => $line) { |
1302 | 1302 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
@@ -1334,11 +1334,11 @@ discard block |
||
1334 | 1334 | ) |
1335 | 1335 | ) { |
1336 | 1336 | //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
1337 | - $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
1337 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150'); |
|
1338 | 1338 | //echo $buffer; |
1339 | - $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
1340 | - $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
1341 | - $all_data = json_decode($buffer,true); |
|
1339 | + $buffer = str_replace(array("\n", "\r"), "", $buffer); |
|
1340 | + $buffer = preg_replace('/,"num":(.+)/', '}', $buffer); |
|
1341 | + $all_data = json_decode($buffer, true); |
|
1342 | 1342 | if (json_last_error() != JSON_ERROR_NONE) { |
1343 | 1343 | die(json_last_error_msg()); |
1344 | 1344 | } |
@@ -1361,7 +1361,7 @@ discard block |
||
1361 | 1361 | //$data['departure_airport_iata'] = $line[11]; |
1362 | 1362 | //$data['arrival_airport_iata'] = $line[12]; |
1363 | 1363 | //$data['emergency'] = ''; // emergency |
1364 | - $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
|
1364 | + $data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10] |
|
1365 | 1365 | $data['format_source'] = 'radarvirtueljson'; |
1366 | 1366 | $data['id_source'] = $id_source; |
1367 | 1367 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
@@ -1382,14 +1382,14 @@ discard block |
||
1382 | 1382 | ) { |
1383 | 1383 | //$buffer = $Common->getData($hosts[$id]); |
1384 | 1384 | $buffer = $Common->getData($value['host'].'?'.time()); |
1385 | - $all_data = json_decode(utf8_encode($buffer),true); |
|
1385 | + $all_data = json_decode(utf8_encode($buffer), true); |
|
1386 | 1386 | |
1387 | 1387 | if (isset($all_data['pireps'])) { |
1388 | 1388 | $reset = 0; |
1389 | 1389 | foreach ($all_data['pireps'] as $line) { |
1390 | 1390 | $data = array(); |
1391 | 1391 | $data['id'] = $line['id']; |
1392 | - $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
1392 | + $data['hex'] = substr(str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT), 0, 6); |
|
1393 | 1393 | $data['ident'] = $line['callsign']; // ident |
1394 | 1394 | if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
1395 | 1395 | if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
@@ -1419,9 +1419,9 @@ discard block |
||
1419 | 1419 | $SI->add($data); |
1420 | 1420 | // print_r($data); |
1421 | 1421 | } elseif ($line['icon'] === 'ct') { |
1422 | - $data['info'] = str_replace('^§','<br />',$data['info']); |
|
1423 | - $data['info'] = str_replace('&sect;','',$data['info']); |
|
1424 | - $typec = substr($data['ident'],-3); |
|
1422 | + $data['info'] = str_replace('^§', '<br />', $data['info']); |
|
1423 | + $data['info'] = str_replace('&sect;', '', $data['info']); |
|
1424 | + $typec = substr($data['ident'], -3); |
|
1425 | 1425 | $data['type'] = ''; |
1426 | 1426 | if ($typec === 'APP') $data['type'] = 'Approach'; |
1427 | 1427 | elseif ($typec === 'TWR') $data['type'] = 'Tower'; |
@@ -1432,7 +1432,7 @@ discard block |
||
1432 | 1432 | elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station'; |
1433 | 1433 | elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre'; |
1434 | 1434 | else $data['type'] = 'Observer'; |
1435 | - if (isset($ATC)) echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']); |
|
1435 | + if (isset($ATC)) echo $ATC->add($data['ident'], '', $data['latitude'], $data['longitude'], '0', $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name'], $data['format_source']); |
|
1436 | 1436 | } |
1437 | 1437 | unset($data); |
1438 | 1438 | } |
@@ -1449,7 +1449,7 @@ discard block |
||
1449 | 1449 | //$buffer = $Common->getData($hosts[$id]); |
1450 | 1450 | if ($globalDebug) echo 'Get Data...'."\n"; |
1451 | 1451 | $buffer = $Common->getData($value['host']); |
1452 | - $all_data = json_decode($buffer,true); |
|
1452 | + $all_data = json_decode($buffer, true); |
|
1453 | 1453 | if ($buffer != '' && is_array($all_data)) { |
1454 | 1454 | $reset = 0; |
1455 | 1455 | foreach ($all_data as $line) { |
@@ -1457,7 +1457,7 @@ discard block |
||
1457 | 1457 | //$data['id'] = $line['id']; // id not usable |
1458 | 1458 | if (isset($line['pilotid']) && isset($line['registration'])) $data['id'] = $line['pilotid'].$line['flightnum'].trim($line['registration']); |
1459 | 1459 | elseif (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
1460 | - $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1460 | + $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex |
|
1461 | 1461 | if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
1462 | 1462 | if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
1463 | 1463 | $data['ident'] = $line['flightnum']; // ident |
@@ -1472,7 +1472,7 @@ discard block |
||
1472 | 1472 | //$data['datetime'] = $line['lastupdate']; |
1473 | 1473 | //$data['last_update'] = $line['lastupdate']; |
1474 | 1474 | if (isset($value['timezone'])) { |
1475 | - $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
|
1475 | + $datetime = new DateTime($line['lastupdate'], new DateTimeZone($value['timezone'])); |
|
1476 | 1476 | $datetime->setTimeZone(new DateTimeZone('UTC')); |
1477 | 1477 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
1478 | 1478 | } else $data['datetime'] = date('Y-m-d H:i:s'); |
@@ -1488,14 +1488,14 @@ discard block |
||
1488 | 1488 | if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
1489 | 1489 | if (isset($line['aircraftname'])) { |
1490 | 1490 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
1491 | - $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
|
1492 | - $aircraft_data = explode('-',$line['aircraftname']); |
|
1491 | + $line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']); |
|
1492 | + $aircraft_data = explode('-', $line['aircraftname']); |
|
1493 | 1493 | if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
1494 | 1494 | elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
1495 | 1495 | else { |
1496 | - $aircraft_data = explode(' ',$line['aircraftname']); |
|
1497 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
1498 | - else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
1496 | + $aircraft_data = explode(' ', $line['aircraftname']); |
|
1497 | + if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-', '', $aircraft_data[1]); |
|
1498 | + else $data['aircraft_icao'] = str_replace('-', '', $line['aircraftname']); |
|
1499 | 1499 | } |
1500 | 1500 | } |
1501 | 1501 | if (isset($line['route'])) $data['waypoints'] = $line['route']; |
@@ -1520,7 +1520,7 @@ discard block |
||
1520 | 1520 | //$buffer = $Common->getData($hosts[$id]); |
1521 | 1521 | if ($globalDebug) echo 'Get Data...'."\n"; |
1522 | 1522 | $buffer = $Common->getData($value['host']); |
1523 | - $all_data = json_decode($buffer,true); |
|
1523 | + $all_data = json_decode($buffer, true); |
|
1524 | 1524 | if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) { |
1525 | 1525 | $reset = 0; |
1526 | 1526 | foreach ($all_data['ACARSData'] as $line) { |
@@ -1531,7 +1531,7 @@ discard block |
||
1531 | 1531 | //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
1532 | 1532 | if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username']; |
1533 | 1533 | if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id']; |
1534 | - $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident |
|
1534 | + $data['ident'] = str_replace(' ', '', $line['bid']['flightnum']); // ident |
|
1535 | 1535 | if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident']; |
1536 | 1536 | $data['altitude'] = $line['altitude']; // altitude |
1537 | 1537 | $data['speed'] = $line['groundspeed']; // speed |
@@ -1542,7 +1542,7 @@ discard block |
||
1542 | 1542 | //$data['squawk'] = ''; // squawk |
1543 | 1543 | //$data['emergency'] = ''; // emergency |
1544 | 1544 | if (isset($value['timezone'])) { |
1545 | - $datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone'])); |
|
1545 | + $datetime = new DateTime($line['updated_at'], new DateTimeZone($value['timezone'])); |
|
1546 | 1546 | $datetime->setTimeZone(new DateTimeZone('UTC')); |
1547 | 1547 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
1548 | 1548 | } else $data['datetime'] = date('Y-m-d H:i:s'); |
@@ -1578,14 +1578,14 @@ discard block |
||
1578 | 1578 | //$buffer = $Common->getData($hosts[$id]); |
1579 | 1579 | if ($globalDebug) echo 'Get Data...'."\n"; |
1580 | 1580 | $buffer = $Common->getData($value['host']); |
1581 | - $all_data = json_decode($buffer,true); |
|
1581 | + $all_data = json_decode($buffer, true); |
|
1582 | 1582 | if ($buffer != '' && is_array($all_data)) { |
1583 | 1583 | $reset = 0; |
1584 | 1584 | foreach ($all_data as $line) { |
1585 | 1585 | $data = array(); |
1586 | 1586 | //$data['id'] = $line['id']; // id not usable |
1587 | 1587 | $data['id'] = trim($line['flight_id']); |
1588 | - $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1588 | + $data['hex'] = substr(str_pad(bin2hex($line['callsign']), 6, '000000', STR_PAD_LEFT), -6); // hex |
|
1589 | 1589 | $data['pilot_name'] = $line['pilot_name']; |
1590 | 1590 | $data['pilot_id'] = $line['pilot_id']; |
1591 | 1591 | $data['ident'] = trim($line['callsign']); // ident |
@@ -1629,24 +1629,24 @@ discard block |
||
1629 | 1629 | //$buffer = $Common->getData($hosts[$id]); |
1630 | 1630 | if ($globalDebug) echo 'Get Data...'."\n"; |
1631 | 1631 | $buffer = $Common->getData($value['host']); |
1632 | - $all_data = json_decode($buffer,true); |
|
1632 | + $all_data = json_decode($buffer, true); |
|
1633 | 1633 | if ($buffer != '') { |
1634 | 1634 | $Source->deleteLocationBySource('blitzortung'); |
1635 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
1636 | - $buffer = explode('\n',$buffer); |
|
1635 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
1636 | + $buffer = explode('\n', $buffer); |
|
1637 | 1637 | foreach ($buffer as $buffer_line) { |
1638 | - $line = json_decode($buffer_line,true); |
|
1638 | + $line = json_decode($buffer_line, true); |
|
1639 | 1639 | if (isset($line['time'])) { |
1640 | 1640 | $data = array(); |
1641 | 1641 | $data['altitude'] = $line['alt']; // altitude |
1642 | 1642 | $data['latitude'] = $line['lat']; // lat |
1643 | 1643 | $data['longitude'] = $line['lon']; // long |
1644 | - $data['datetime'] = date('Y-m-d H:i:s',substr($line['time'],0,10)); |
|
1644 | + $data['datetime'] = date('Y-m-d H:i:s', substr($line['time'], 0, 10)); |
|
1645 | 1645 | $data['id_source'] = $id_source; |
1646 | 1646 | $data['format_source'] = 'blitzortung'; |
1647 | 1647 | $SI->add($data); |
1648 | 1648 | if ($globalDebug) echo '☈ Lightning added'."\n"; |
1649 | - $Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']); |
|
1649 | + $Source->addLocation('', $data['latitude'], $data['longitude'], 0, '', '', 'blitzortung', 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime']); |
|
1650 | 1650 | unset($data); |
1651 | 1651 | } |
1652 | 1652 | } |
@@ -1658,15 +1658,15 @@ discard block |
||
1658 | 1658 | $arr = $httpfeeds; |
1659 | 1659 | $w = $e = null; |
1660 | 1660 | if (isset($arr[$id])) { |
1661 | - $nn = stream_select($arr,$w,$e,$timeout); |
|
1661 | + $nn = stream_select($arr, $w, $e, $timeout); |
|
1662 | 1662 | if ($nn > 0) { |
1663 | 1663 | foreach ($httpfeeds as $feed) { |
1664 | - $buffer = stream_get_line($feed,2000,"\n"); |
|
1664 | + $buffer = stream_get_line($feed, 2000, "\n"); |
|
1665 | 1665 | if ($buffer === FALSE) { |
1666 | 1666 | connect_all($globalSources); |
1667 | 1667 | } |
1668 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
1669 | - $buffer = explode('\n',$buffer); |
|
1668 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
1669 | + $buffer = explode('\n', $buffer); |
|
1670 | 1670 | foreach ($buffer as $line) { |
1671 | 1671 | if ($line != '') { |
1672 | 1672 | $line = json_decode($line, true); |
@@ -1706,11 +1706,11 @@ discard block |
||
1706 | 1706 | //$value = $formats[$nb]; |
1707 | 1707 | $format = $globalSources[$nb]['format']; |
1708 | 1708 | if ($format === 'sbs' || $format === 'aprs' || $format === 'famaprs' || $format === 'raw' || $format === 'tsv' || $format === 'acarssbs3') { |
1709 | - $buffer = @socket_read($r, 6000,PHP_NORMAL_READ); |
|
1709 | + $buffer = @socket_read($r, 6000, PHP_NORMAL_READ); |
|
1710 | 1710 | } elseif ($format === 'vrstcp') { |
1711 | 1711 | $buffer = @socket_read($r, 6000); |
1712 | 1712 | } else { |
1713 | - $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); |
|
1713 | + $az = socket_recvfrom($r, $buffer, 6000, 0, $remote_ip, $remote_port); |
|
1714 | 1714 | } |
1715 | 1715 | //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
1716 | 1716 | //echo $buffer."\n"; |
@@ -1720,8 +1720,8 @@ discard block |
||
1720 | 1720 | //$SI::del(); |
1721 | 1721 | if ($buffer !== FALSE) { |
1722 | 1722 | if ($format === 'vrstcp') { |
1723 | - $buffer = explode('},{',$buffer); |
|
1724 | - } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
1723 | + $buffer = explode('},{', $buffer); |
|
1724 | + } else $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer)); |
|
1725 | 1725 | } |
1726 | 1726 | // SBS format is CSV format |
1727 | 1727 | if ($buffer !== FALSE && $buffer !== '') { |
@@ -1748,7 +1748,7 @@ discard block |
||
1748 | 1748 | $ais_data = $AIS->parse_line(trim($buffer)); |
1749 | 1749 | $data = array(); |
1750 | 1750 | if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
1751 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
1751 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'], -9); |
|
1752 | 1752 | if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
1753 | 1753 | if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
1754 | 1754 | if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
@@ -1759,13 +1759,13 @@ discard block |
||
1759 | 1759 | if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
1760 | 1760 | if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
1761 | 1761 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
1762 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1762 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']); |
|
1763 | 1763 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1764 | 1764 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
1765 | 1765 | if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
1766 | 1766 | |
1767 | 1767 | if (isset($ais_data['timestamp'])) { |
1768 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
1768 | + $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); |
|
1769 | 1769 | } else { |
1770 | 1770 | $data['datetime'] = date('Y-m-d H:i:s'); |
1771 | 1771 | } |
@@ -1776,10 +1776,10 @@ discard block |
||
1776 | 1776 | } elseif ($format === 'flightgearsp') { |
1777 | 1777 | //echo $buffer."\n"; |
1778 | 1778 | if (strlen($buffer) > 5) { |
1779 | - $line = explode(',',$buffer); |
|
1779 | + $line = explode(',', $buffer); |
|
1780 | 1780 | $data = array(); |
1781 | 1781 | //XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p |
1782 | - $data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]),6,'000000',STR_PAD_LEFT),0,6); |
|
1782 | + $data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]), 6, '000000', STR_PAD_LEFT), 0, 6); |
|
1783 | 1783 | $data['ident'] = $line[6]; |
1784 | 1784 | $data['aircraft_name'] = $line[7]; |
1785 | 1785 | $data['longitude'] = $line[1]; |
@@ -1796,25 +1796,25 @@ discard block |
||
1796 | 1796 | } elseif ($format === 'acars') { |
1797 | 1797 | if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
1798 | 1798 | $ACARS->add(trim($buffer)); |
1799 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
1799 | + socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port); |
|
1800 | 1800 | $ACARS->deleteLiveAcarsData(); |
1801 | 1801 | } elseif ($format === 'acarsjsonudp') { |
1802 | 1802 | if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
1803 | 1803 | $line = json_decode(trim($buffer), true); |
1804 | 1804 | if (!empty($line)) { |
1805 | - $line = array_merge(array('text' => '','tail' => '','label' => '','block_id' => '','flight' => '','msgno' => ''),$line); |
|
1805 | + $line = array_merge(array('text' => '', 'tail' => '', 'label' => '', 'block_id' => '', 'flight' => '', 'msgno' => ''), $line); |
|
1806 | 1806 | $ACARS->add(isset($line['text']) ? $line['text'] : '', array('registration' => str_replace('.', '', $line['tail']), 'ident' => $line['flight'], 'label' => $line['label'], 'block_id' => $line['block_id'], 'msg_no' => $line['msgno'], 'message' => (isset($line['text']) ? $line['text'] : ''))); |
1807 | 1807 | $ACARS->deleteLiveAcarsData(); |
1808 | 1808 | } |
1809 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
1809 | + socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port); |
|
1810 | 1810 | } elseif ($format === 'flightgearmp') { |
1811 | - if (substr($buffer,0,1) != '#') { |
|
1811 | + if (substr($buffer, 0, 1) != '#') { |
|
1812 | 1812 | $data = array(); |
1813 | 1813 | //echo $buffer."\n"; |
1814 | - $line = explode(' ',$buffer); |
|
1814 | + $line = explode(' ', $buffer); |
|
1815 | 1815 | if (count($line) === 11) { |
1816 | - $userserver = explode('@',$line[0]); |
|
1817 | - $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
1816 | + $userserver = explode('@', $line[0]); |
|
1817 | + $data['hex'] = substr(str_pad(bin2hex($line[0]), 6, '000000', STR_PAD_LEFT), 0, 6); // hex |
|
1818 | 1818 | $data['ident'] = $userserver[0]; |
1819 | 1819 | $data['registration'] = $userserver[0]; |
1820 | 1820 | $data['latitude'] = $line[4]; |
@@ -1822,8 +1822,8 @@ discard block |
||
1822 | 1822 | $data['altitude'] = $line[6]; |
1823 | 1823 | $data['datetime'] = date('Y-m-d H:i:s'); |
1824 | 1824 | $aircraft_type = $line[10]; |
1825 | - $aircraft_type = preg_split(':/:',$aircraft_type); |
|
1826 | - $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
1825 | + $aircraft_type = preg_split(':/:', $aircraft_type); |
|
1826 | + $data['aircraft_name'] = substr(end($aircraft_type), 0, -4); |
|
1827 | 1827 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1828 | 1828 | if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
1829 | 1829 | } |
@@ -1832,8 +1832,8 @@ discard block |
||
1832 | 1832 | echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
1833 | 1833 | die; |
1834 | 1834 | } elseif ($format === 'vrstcp') { |
1835 | - foreach($buffer as $all_data) { |
|
1836 | - $line = json_decode('{'.$all_data.'}',true); |
|
1835 | + foreach ($buffer as $all_data) { |
|
1836 | + $line = json_decode('{'.$all_data.'}', true); |
|
1837 | 1837 | $data = array(); |
1838 | 1838 | if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
1839 | 1839 | if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
@@ -1859,16 +1859,16 @@ discard block |
||
1859 | 1859 | if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
1860 | 1860 | unset($data); |
1861 | 1861 | } |
1862 | - } elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') { |
|
1862 | + } elseif ($format === 'tsv' || substr($buffer, 0, 4) === 'clock') { |
|
1863 | 1863 | $line = explode("\t", $buffer); |
1864 | - for($k = 0; $k < count($line); $k=$k+2) { |
|
1864 | + for ($k = 0; $k < count($line); $k = $k + 2) { |
|
1865 | 1865 | $key = $line[$k]; |
1866 | - $lined[$key] = $line[$k+1]; |
|
1866 | + $lined[$key] = $line[$k + 1]; |
|
1867 | 1867 | } |
1868 | 1868 | if (count($lined) > 3) { |
1869 | 1869 | $data['hex'] = $lined['hexid']; |
1870 | 1870 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
1871 | - $data['datetime'] = date('Y-m-d H:i:s');; |
|
1871 | + $data['datetime'] = date('Y-m-d H:i:s'); ; |
|
1872 | 1872 | if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
1873 | 1873 | if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
1874 | 1874 | if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
@@ -1887,23 +1887,23 @@ discard block |
||
1887 | 1887 | } else $error = true; |
1888 | 1888 | } elseif ($format === 'aprs' && $use_aprs) { |
1889 | 1889 | if ($aprs_connect === 0) { |
1890 | - $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
|
1890 | + $send = @ socket_send($r, $aprs_login, strlen($aprs_login), 0); |
|
1891 | 1891 | $aprs_connect = 1; |
1892 | 1892 | } |
1893 | 1893 | |
1894 | - if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
1894 | + if ($aprs_keep > 60 && time() - $aprs_last_tx > $aprs_keep) { |
|
1895 | 1895 | $aprs_last_tx = time(); |
1896 | 1896 | $data_aprs = "# Keep alive"; |
1897 | - $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
|
1897 | + $send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0); |
|
1898 | 1898 | } |
1899 | 1899 | |
1900 | 1900 | //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
1901 | 1901 | //echo 'APRS data : '.$buffer."\n"; |
1902 | - $buffer = str_replace('APRS <- ','',$buffer); |
|
1903 | - $buffer = str_replace('APRS -> ','',$buffer); |
|
1902 | + $buffer = str_replace('APRS <- ', '', $buffer); |
|
1903 | + $buffer = str_replace('APRS -> ', '', $buffer); |
|
1904 | 1904 | //echo $buffer."\n"; |
1905 | 1905 | date_default_timezone_set('UTC'); |
1906 | - if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
1906 | + if (substr($buffer, 0, 1) != '#' && substr($buffer, 0, 1) != '@' && substr($buffer, 0, 5) != 'APRS ') { |
|
1907 | 1907 | $line = $APRS->parse($buffer); |
1908 | 1908 | //if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) { |
1909 | 1909 | if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) { |
@@ -1918,7 +1918,7 @@ discard block |
||
1918 | 1918 | if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date']; |
1919 | 1919 | if (isset($line['typeid'])) $data['type_id'] = $line['typeid']; |
1920 | 1920 | if (isset($line['statusid'])) $data['status_id'] = $line['statusid']; |
1921 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1921 | + if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']); |
|
1922 | 1922 | else $data['datetime'] = date('Y-m-d H:i:s'); |
1923 | 1923 | //$data['datetime'] = date('Y-m-d H:i:s'); |
1924 | 1924 | if (isset($line['ident'])) $data['ident'] = $line['ident']; |
@@ -2006,29 +2006,29 @@ discard block |
||
2006 | 2006 | } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
2007 | 2007 | if (!isset($data['altitude'])) $data['altitude'] = 0; |
2008 | 2008 | $Source->deleteOldLocationByType('gs'); |
2009 | - if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) { |
|
2010 | - $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
|
2009 | + if (count($Source->getLocationInfoByNameType($data['ident'], 'gs')) > 0) { |
|
2010 | + $Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']); |
|
2011 | 2011 | } else { |
2012 | - $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
|
2012 | + $Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']); |
|
2013 | 2013 | } |
2014 | 2014 | } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') { |
2015 | 2015 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
2016 | 2016 | if ($globalDebug) echo '# Weather Station added'."\n"; |
2017 | 2017 | $Source->deleteOldLocationByType('wx'); |
2018 | 2018 | $weather_data = json_encode($line); |
2019 | - if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) { |
|
2020 | - $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data); |
|
2019 | + if (count($Source->getLocationInfoByNameType($data['ident'], 'wx')) > 0) { |
|
2020 | + $Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data); |
|
2021 | 2021 | } else { |
2022 | - $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data); |
|
2022 | + $Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data); |
|
2023 | 2023 | } |
2024 | 2024 | } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) { |
2025 | 2025 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
2026 | 2026 | if ($globalDebug) echo '☈ Lightning added'."\n"; |
2027 | 2027 | $Source->deleteOldLocationByType('lightning'); |
2028 | - if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) { |
|
2029 | - $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']); |
|
2028 | + if (count($Source->getLocationInfoByNameType($data['ident'], 'lightning')) > 0) { |
|
2029 | + $Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']); |
|
2030 | 2030 | } else { |
2031 | - $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']); |
|
2031 | + $Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']); |
|
2032 | 2032 | } |
2033 | 2033 | } elseif ($globalDebug) { |
2034 | 2034 | echo '/!\ Not added: '.$buffer."\n"; |
@@ -2037,7 +2037,7 @@ discard block |
||
2037 | 2037 | unset($data); |
2038 | 2038 | } |
2039 | 2039 | elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
2040 | - $Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']); |
|
2040 | + $Source->updateLocationDescByName($line['ident'], $line['source'], $id, $line['comment']); |
|
2041 | 2041 | } |
2042 | 2042 | /* |
2043 | 2043 | elseif (is_array($line) && $globalDebug && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] === 'Car' || $line['symbol'] === 'Ambulance' || $line['symbol'] === 'Van' || $line['symbol'] === 'Truck' || $line['symbol'] === 'Truck (18 Wheeler)' || $line['symbol'] === 'Motorcycle')) { |
@@ -2046,7 +2046,7 @@ discard block |
||
2046 | 2046 | */ |
2047 | 2047 | //elseif ($line === false && $globalDebug) echo 'Ignored ('.$buffer.")\n"; |
2048 | 2048 | elseif ($line === true && $globalDebug) echo '!! Failed : '.$buffer."!!\n"; |
2049 | - if (isset($Source) && isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) { |
|
2049 | + if (isset($Source) && isset($globalSources[$nb]['last_weather_clean']) && time() - $globalSources[$nb]['last_weather_clean'] > 60*5) { |
|
2050 | 2050 | $Source->deleteOldLocationByType('lightning'); |
2051 | 2051 | $Source->deleteOldLocationByType('wx'); |
2052 | 2052 | $globalSources[$nb]['last_weather_clean'] = time(); |
@@ -2133,7 +2133,7 @@ discard block |
||
2133 | 2133 | connect_all($sourceee); |
2134 | 2134 | $sourceee = array(); |
2135 | 2135 | //connect_all($globalSources); |
2136 | - $tt[$format]=0; |
|
2136 | + $tt[$format] = 0; |
|
2137 | 2137 | break; |
2138 | 2138 | } |
2139 | 2139 | //else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."..."; |
@@ -2143,14 +2143,14 @@ discard block |
||
2143 | 2143 | } else { |
2144 | 2144 | $error = socket_strerror(socket_last_error()); |
2145 | 2145 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
2146 | - if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
|
2146 | + if ($globalDebug) echo "ERROR : socket_select give this error ".$error."\n"; |
|
2147 | 2147 | if (isset($globalDebug)) echo "Restarting...\n"; |
2148 | 2148 | // Restart the script if possible |
2149 | 2149 | if (is_array($sockets)) { |
2150 | 2150 | if ($globalDebug) echo "Shutdown all sockets..."; |
2151 | 2151 | |
2152 | 2152 | foreach ($sockets as $sock) { |
2153 | - @socket_shutdown($sock,2); |
|
2153 | + @socket_shutdown($sock, 2); |
|
2154 | 2154 | @socket_close($sock); |
2155 | 2155 | } |
2156 | 2156 |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | /* |
23 | 23 | * Initialize DB connection |
24 | 24 | */ |
25 | - public function __construct($dbc = null,$fromACARSscript = false) { |
|
25 | + public function __construct($dbc = null, $fromACARSscript = false) { |
|
26 | 26 | $Connection = new Connection($dbc); |
27 | 27 | $this->db = $Connection->db(); |
28 | 28 | if ($this->db === null) die('Error: No DB connection. (ACARS)'); |
@@ -39,14 +39,14 @@ discard block |
||
39 | 39 | * @return String the icao |
40 | 40 | */ |
41 | 41 | public function ident2icao($ident) { |
42 | - if (substr($ident,0,2) == 'AF') { |
|
43 | - if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident; |
|
44 | - else $icao = 'AFR'.ltrim(substr($ident,2),'0'); |
|
42 | + if (substr($ident, 0, 2) == 'AF') { |
|
43 | + if (filter_var(substr($ident, 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident; |
|
44 | + else $icao = 'AFR'.ltrim(substr($ident, 2), '0'); |
|
45 | 45 | } else { |
46 | 46 | $Spotter = new Spotter($this->db); |
47 | - $identicao = $Spotter->getAllAirlineInfo(substr($ident,0,2)); |
|
47 | + $identicao = $Spotter->getAllAirlineInfo(substr($ident, 0, 2)); |
|
48 | 48 | if (isset($identicao[0])) { |
49 | - $icao = $identicao[0]['icao'].ltrim(substr($ident,2),'0'); |
|
49 | + $icao = $identicao[0]['icao'].ltrim(substr($ident, 2), '0'); |
|
50 | 50 | } else $icao = $ident; |
51 | 51 | } |
52 | 52 | return $icao; |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | |
71 | 71 | $sth = $this->db->prepare($query); |
72 | 72 | $sth->execute(); |
73 | - } catch(PDOException $e) { |
|
73 | + } catch (PDOException $e) { |
|
74 | 74 | return "error"; |
75 | 75 | } |
76 | 76 | return "success"; |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | |
95 | 95 | $sth = $this->db->prepare($query); |
96 | 96 | $sth->execute(); |
97 | - } catch(PDOException $e) { |
|
97 | + } catch (PDOException $e) { |
|
98 | 98 | return "error"; |
99 | 99 | } |
100 | 100 | return "success"; |
@@ -120,15 +120,15 @@ discard block |
||
120 | 120 | $ident = ''; |
121 | 121 | $message = ''; |
122 | 122 | $result = array(); |
123 | - $n = sscanf($data,'%*[0-9a-z.] %*d %*02d/%*02d/%*04d %*02d:%*02d:%*02d %*d %*[0-9-] %*[A-Z0-9] %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message); |
|
124 | - if ($n == 0 || $message == '') $n = sscanf($data,'AC%*c %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message); |
|
125 | - if ($n == 0 || $message == '') $n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%6[0-9A-Z-],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message); |
|
126 | - if ($n == 0 || $message == '') $n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%6[0-9A-Z-],,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message); |
|
127 | - if ($n == 0 || $message == '') $n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%5[0-9A-Z],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message); |
|
128 | - if ($n == 0 || $message == '') $n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%6[0-9A-Z-],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message); |
|
123 | + $n = sscanf($data, '%*[0-9a-z.] %*d %*02d/%*02d/%*04d %*02d:%*02d:%*02d %*d %*[0-9-] %*[A-Z0-9] %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]', $registration, $label, $block_id, $msg_no, $ident, $message); |
|
124 | + if ($n == 0 || $message == '') $n = sscanf($data, 'AC%*c %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]', $registration, $label, $block_id, $msg_no, $ident, $message); |
|
125 | + if ($n == 0 || $message == '') $n = sscanf($data, '%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%6[0-9A-Z-],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]', $registration, $label, $block_id, $msg_no, $ident, $message); |
|
126 | + if ($n == 0 || $message == '') $n = sscanf($data, '%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%6[0-9A-Z-],,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]', $registration, $label, $block_id, $msg_no, $ident, $message); |
|
127 | + if ($n == 0 || $message == '') $n = sscanf($data, '%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%5[0-9A-Z],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]', $registration, $label, $block_id, $msg_no, $ident, $message); |
|
128 | + if ($n == 0 || $message == '') $n = sscanf($data, '%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%6[0-9A-Z-],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]', $registration, $label, $block_id, $msg_no, $ident, $message); |
|
129 | 129 | if ($n != 0 && ($registration != '' || $ident != '' || $label != '' || $block_id != '' || $msg_no != '')) { |
130 | - $registration = str_replace('.','',$registration); |
|
131 | - $result = array('registration' => $registration, 'ident' => $ident,'label' => $label, 'block_id' => $block_id,'msg_no' => $msg_no,'message' => $message); |
|
130 | + $registration = str_replace('.', '', $registration); |
|
131 | + $result = array('registration' => $registration, 'ident' => $ident, 'label' => $label, 'block_id' => $block_id, 'msg_no' => $msg_no, 'message' => $message); |
|
132 | 132 | if ($globalDebug) echo "Reg. : ".$registration." - Ident : ".$ident." - Label : ".$label." - Message : ".$message."\n"; |
133 | 133 | } else $message = $data; |
134 | 134 | $decode = array(); |
@@ -148,14 +148,14 @@ discard block |
||
148 | 148 | $temp = ''; |
149 | 149 | $n = sscanf($message, "FST01%4c%4c%c%06d%c%07d%03d%*8[0-9a-zA-Z ]-%02dC", $dair, $darr, $lac, $la, $lnc, $ln, $alt, $temp); |
150 | 150 | if ($n > 5 && ($lac == 'N' || $lac == 'S') && ($lnc == 'E' || $lnc == 'W')) { |
151 | - $latitude = $la / 10000.0; |
|
152 | - $longitude = $ln / 10000.0; |
|
151 | + $latitude = $la/10000.0; |
|
152 | + $longitude = $ln/10000.0; |
|
153 | 153 | if ($lac == 'S') $latitude = '-'.$latitude; |
154 | 154 | if ($lnc == 'W') $longitude = '-'.$longitude; |
155 | 155 | // Temp not always available |
156 | 156 | if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude.' - airport depart : '.$dair.' - airport arrival : '.$darr.' - température : '.$temp."°C\n"; |
157 | - if ($temp == '') $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr,'Altitude' => $alt); |
|
158 | - else $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt,'Temperature' => $temp.'°C'); |
|
157 | + if ($temp == '') $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => $alt); |
|
158 | + else $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt, 'Temperature' => $temp.'°C'); |
|
159 | 159 | |
160 | 160 | //$icao = $Translation->checkTranslation($ident); |
161 | 161 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
@@ -167,19 +167,19 @@ discard block |
||
167 | 167 | $dhour = ''; |
168 | 168 | $darr = ''; |
169 | 169 | $ahour = ''; |
170 | - $n = sscanf($message, "ARR01 %4[A-Z]%4d %4[A-Z]%4d", $dair, $dhour, $darr,$ahour); |
|
170 | + $n = sscanf($message, "ARR01 %4[A-Z]%4d %4[A-Z]%4d", $dair, $dhour, $darr, $ahour); |
|
171 | 171 | if ($n == 4 && strlen($darr) == 4) { |
172 | - if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
173 | - if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2); |
|
174 | - if ($globalDebug) echo 'departure airport : '.$dair.' - arrival airport : '. $darr.' - departure hour : '. $dhour.' - arrival hour : '.$ahour."\n"; |
|
172 | + if ($dhour != '') $dhour = substr(sprintf('%04d', $dhour), 0, 2).':'.substr(sprintf('%04d', $dhour), 2); |
|
173 | + if ($ahour != '') $ahour = substr(sprintf('%04d', $ahour), 0, 2).':'.substr(sprintf('%04d', $ahour), 2); |
|
174 | + if ($globalDebug) echo 'departure airport : '.$dair.' - arrival airport : '.$darr.' - departure hour : '.$dhour.' - arrival hour : '.$ahour."\n"; |
|
175 | 175 | //$icao = ACARS->ident2icao($ident); |
176 | 176 | //$icao = $Translation->checkTranslation($ident); |
177 | 177 | //$Schedule->addSchedule($icao,$dair,$dhour,$darr,$ahour,'ACARS'); |
178 | 178 | $decode = array('Departure airport' => $dair, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour); |
179 | 179 | $found = true; |
180 | 180 | } |
181 | - elseif ($n == 2 || $n == 4) { |
|
182 | - if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
181 | + elseif ($n == 2 || $n == 4) { |
|
182 | + if ($dhour != '') $dhour = substr(sprintf('%04d', $dhour), 0, 2).':'.substr(sprintf('%04d', $dhour), 2); |
|
183 | 183 | if ($globalDebug) echo 'airport arrival : '.$dair.' - arrival hour : '.$dhour."\n"; |
184 | 184 | //$icao = ACARS->ident2icao($ident); |
185 | 185 | //$icao = $Translation->checkTranslation($ident); |
@@ -237,11 +237,11 @@ discard block |
||
237 | 237 | $ahour = ''; |
238 | 238 | $aair = ''; |
239 | 239 | $apiste = ''; |
240 | - $n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "%*[0-9A-Z]/%*3d/%4s/%*cSCH/%6[0-9A-Z ]/%4c/%4c/%5s/%4d%*3c/%4d/%4c/%[0-9A-Z ]/", $airicao,$aident,$dair, $darr, $ddate, $dhour,$ahour, $aair, $apiste); |
|
240 | + $n = sscanf(str_replace(array("\r\n", "\n", "\r"), '', $message), "%*[0-9A-Z]/%*3d/%4s/%*cSCH/%6[0-9A-Z ]/%4c/%4c/%5s/%4d%*3c/%4d/%4c/%[0-9A-Z ]/", $airicao, $aident, $dair, $darr, $ddate, $dhour, $ahour, $aair, $apiste); |
|
241 | 241 | if ($n > 8) { |
242 | - if ($globalDebug) echo 'airicao : '. $airicao.' - ident : '.$aident.' - departure airport : '.$dair.' - arrival airport : '. $darr.' - date depart : '.$ddate.' - departure hour : '. $dhour.' - arrival hour : '.$ahour.' - arrival airport : '.$aair.' - arrival piste : '.$apiste."\n"; |
|
243 | - if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
244 | - if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2); |
|
242 | + if ($globalDebug) echo 'airicao : '.$airicao.' - ident : '.$aident.' - departure airport : '.$dair.' - arrival airport : '.$darr.' - date depart : '.$ddate.' - departure hour : '.$dhour.' - arrival hour : '.$ahour.' - arrival airport : '.$aair.' - arrival piste : '.$apiste."\n"; |
|
243 | + if ($dhour != '') $dhour = substr(sprintf('%04d', $dhour), 0, 2).':'.substr(sprintf('%04d', $dhour), 2); |
|
244 | + if ($ahour != '') $ahour = substr(sprintf('%04d', $ahour), 0, 2).':'.substr(sprintf('%04d', $ahour), 2); |
|
245 | 245 | $icao = trim($aident); |
246 | 246 | |
247 | 247 | //$decode = 'Departure airport : '.$dair.' ('.$ddate.' at '.$dhour.') - Arrival Airport : '.$aair.' (at '.$ahour.') way '.$apiste; |
@@ -266,8 +266,8 @@ discard block |
||
266 | 266 | if ($n == 10 && ($lac == 'N' || $lac == 'S') && ($lnc == 'E' || $lnc == 'W')) { |
267 | 267 | $las = $las.'.'.$lass; |
268 | 268 | $lns = $lns.'.'.$lns; |
269 | - $latitude = $las / 1000.0; |
|
270 | - $longitude = $lns / 1000.0; |
|
269 | + $latitude = $las/1000.0; |
|
270 | + $longitude = $lns/1000.0; |
|
271 | 271 | if ($lac == 'S') $latitude = '-'.$latitude; |
272 | 272 | if ($lnc == 'W') $longitude = '-'.$longitude; |
273 | 273 | if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude."\n"; |
@@ -362,17 +362,17 @@ discard block |
||
362 | 362 | $alt = ''; |
363 | 363 | $fuel = ''; |
364 | 364 | $speed = ''; |
365 | - $n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "#DFB(POS-%s -%4d%c%5d%c/%*d F%dRMK/FUEL %f M%f", $aident, $las, $lac, $lns, $lnc, $alt, $fuel, $speed); |
|
365 | + $n = sscanf(str_replace(array("\r\n", "\n", "\r"), '', $message), "#DFB(POS-%s -%4d%c%5d%c/%*d F%dRMK/FUEL %f M%f", $aident, $las, $lac, $lns, $lnc, $alt, $fuel, $speed); |
|
366 | 366 | if ($n == 9) { |
367 | 367 | //if (self->$debug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
368 | 368 | $icao = trim($aident); |
369 | 369 | $decode['icao'] = $icao; |
370 | - $latitude = $las / 100.0; |
|
371 | - $longitude = $lns / 100.0; |
|
370 | + $latitude = $las/100.0; |
|
371 | + $longitude = $lns/100.0; |
|
372 | 372 | if ($lac == 'S') $latitude = '-'.$latitude; |
373 | 373 | if ($lnc == 'W') $longitude = '-'.$longitude; |
374 | 374 | |
375 | - $decode = array('Latitude' => $latitude,'Longitude' => $longitude,'Altitude' => 'FL'.$alt,'Fuel' => $fuel,'speed' => $speed); |
|
375 | + $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Altitude' => 'FL'.$alt, 'Fuel' => $fuel, 'speed' => $speed); |
|
376 | 376 | $found = true; |
377 | 377 | } |
378 | 378 | } |
@@ -391,7 +391,7 @@ discard block |
||
391 | 391 | if ($lac == 'S') $latitude = '-'.$latitude; |
392 | 392 | if ($lnc == 'W') $longitude = '-'.$longitude; |
393 | 393 | |
394 | - $decode = array('Latitude' => $latitude,'Longitude' => $longitude); |
|
394 | + $decode = array('Latitude' => $latitude, 'Longitude' => $longitude); |
|
395 | 395 | $found = true; |
396 | 396 | } |
397 | 397 | } |
@@ -424,7 +424,7 @@ discard block |
||
424 | 424 | $dair = ''; |
425 | 425 | $darr = ''; |
426 | 426 | $aident = ''; |
427 | - $n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "%*[0-9A-Z],,%*[0-9A-Z],%*[0-9A-Z],%4s,%4s,.%*6s,%*4[A-Z],%[0-9A-Z],", $dair, $darr, $aident); |
|
427 | + $n = sscanf(str_replace(array("\r\n", "\n", "\r"), '', $message), "%*[0-9A-Z],,%*[0-9A-Z],%*[0-9A-Z],%4s,%4s,.%*6s,%*4[A-Z],%[0-9A-Z],", $dair, $darr, $aident); |
|
428 | 428 | if ($n == 8) { |
429 | 429 | if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
430 | 430 | $icao = trim($aident); |
@@ -456,7 +456,7 @@ discard block |
||
456 | 456 | */ |
457 | 457 | $dair = ''; |
458 | 458 | $darr = ''; |
459 | - $n = sscanf($message,'%4[A-Z]%4[A-Z]%*4d',$dair,$darr); |
|
459 | + $n = sscanf($message, '%4[A-Z]%4[A-Z]%*4d', $dair, $darr); |
|
460 | 460 | if ($n == 3) { |
461 | 461 | if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
462 | 462 | //$icao = $Translation->checkTranslation($ident); |
@@ -471,7 +471,7 @@ discard block |
||
471 | 471 | */ |
472 | 472 | $dair = ''; |
473 | 473 | $darr = ''; |
474 | - $n = sscanf($message,'3J01 DSPTCH %*d/%*d %4s/%4s .%*6s',$dair,$darr); |
|
474 | + $n = sscanf($message, '3J01 DSPTCH %*d/%*d %4s/%4s .%*6s', $dair, $darr); |
|
475 | 475 | if ($n == 3) { |
476 | 476 | if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
477 | 477 | //$icao = $Translation->checkTranslation($ident); |
@@ -481,7 +481,7 @@ discard block |
||
481 | 481 | } |
482 | 482 | } |
483 | 483 | if (!$found) { |
484 | - $n = sscanf($message,'MET01%4c',$airport); |
|
484 | + $n = sscanf($message, 'MET01%4c', $airport); |
|
485 | 485 | if ($n == 1) { |
486 | 486 | if ($globalDebug) echo 'airport name : '.$airport; |
487 | 487 | $decode = array('Airport/Waypoint name' => $airport); |
@@ -489,241 +489,241 @@ discard block |
||
489 | 489 | } |
490 | 490 | } |
491 | 491 | if ($label == 'H1') { |
492 | - if (preg_match('/^#CFBFLR/',$message) || preg_match('/^#CFBWRN/',$message)) { |
|
493 | - $decode = array_merge(array('Message nature' => 'Equipment failure'),$decode); |
|
492 | + if (preg_match('/^#CFBFLR/', $message) || preg_match('/^#CFBWRN/', $message)) { |
|
493 | + $decode = array_merge(array('Message nature' => 'Equipment failure'), $decode); |
|
494 | 494 | } |
495 | - elseif (preg_match('/^#DFB\*TKO/',$message) || preg_match('/^#DFBTKO/',$message)) { |
|
496 | - $decode = array_merge(array('Message nature' => 'Take off performance data'),$decode); |
|
495 | + elseif (preg_match('/^#DFB\*TKO/', $message) || preg_match('/^#DFBTKO/', $message)) { |
|
496 | + $decode = array_merge(array('Message nature' => 'Take off performance data'), $decode); |
|
497 | 497 | } |
498 | - elseif (preg_match('/^#DFB\*CRZ/',$message) || preg_match('/^#DFBCRZ/',$message)) { |
|
499 | - $decode = array_merge(array('Message nature' => 'Cruise performance data'),$decode); |
|
498 | + elseif (preg_match('/^#DFB\*CRZ/', $message) || preg_match('/^#DFBCRZ/', $message)) { |
|
499 | + $decode = array_merge(array('Message nature' => 'Cruise performance data'), $decode); |
|
500 | 500 | } |
501 | - elseif (preg_match('/^#DFB\*WOB/',$message) || preg_match('/^#DFBWOB/',$message)) { |
|
502 | - $decode = array_merge(array('Message nature' => 'Weather observation'),$decode); |
|
501 | + elseif (preg_match('/^#DFB\*WOB/', $message) || preg_match('/^#DFBWOB/', $message)) { |
|
502 | + $decode = array_merge(array('Message nature' => 'Weather observation'), $decode); |
|
503 | 503 | } |
504 | - elseif (preg_match(':^#DFB/PIREP:',$message)) { |
|
505 | - $decode = array_merge(array('Message nature' => 'Pilot Report'),$decode); |
|
504 | + elseif (preg_match(':^#DFB/PIREP:', $message)) { |
|
505 | + $decode = array_merge(array('Message nature' => 'Pilot Report'), $decode); |
|
506 | 506 | } |
507 | - elseif (preg_match('/^#DFBEDA/',$message) || preg_match('/^#DFBENG/',$message)) { |
|
508 | - $decode = array_merge(array('Message nature' => 'Engine Data'),$decode); |
|
507 | + elseif (preg_match('/^#DFBEDA/', $message) || preg_match('/^#DFBENG/', $message)) { |
|
508 | + $decode = array_merge(array('Message nature' => 'Engine Data'), $decode); |
|
509 | 509 | } |
510 | - elseif (preg_match(':^#M1AAEP:',$message)) { |
|
511 | - $decode = array_merge(array('Message nature' => 'Position/Weather Report'),$decode); |
|
510 | + elseif (preg_match(':^#M1AAEP:', $message)) { |
|
511 | + $decode = array_merge(array('Message nature' => 'Position/Weather Report'), $decode); |
|
512 | 512 | } |
513 | - elseif (preg_match(':^#M2APWD:',$message)) { |
|
514 | - $decode = array_merge(array('Message nature' => 'Flight plan predicted wind data'),$decode); |
|
513 | + elseif (preg_match(':^#M2APWD:', $message)) { |
|
514 | + $decode = array_merge(array('Message nature' => 'Flight plan predicted wind data'), $decode); |
|
515 | 515 | } |
516 | - elseif (preg_match(':^#M1BREQPWI:',$message)) { |
|
517 | - $decode = array_merge(array('Message nature' => 'Predicted wind info request'),$decode); |
|
516 | + elseif (preg_match(':^#M1BREQPWI:', $message)) { |
|
517 | + $decode = array_merge(array('Message nature' => 'Predicted wind info request'), $decode); |
|
518 | 518 | } |
519 | - elseif (preg_match(':^#CF:',$message)) { |
|
520 | - $decode = array_merge(array('Message nature' => 'Central Fault Display'),$decode); |
|
519 | + elseif (preg_match(':^#CF:', $message)) { |
|
520 | + $decode = array_merge(array('Message nature' => 'Central Fault Display'), $decode); |
|
521 | 521 | } |
522 | - elseif (preg_match(':^#DF:',$message)) { |
|
523 | - $decode = array_merge(array('Message nature' => 'Digital Flight Data Acquisition Unit'),$decode); |
|
522 | + elseif (preg_match(':^#DF:', $message)) { |
|
523 | + $decode = array_merge(array('Message nature' => 'Digital Flight Data Acquisition Unit'), $decode); |
|
524 | 524 | } |
525 | - elseif (preg_match(':^#EC:',$message)) { |
|
526 | - $decode = array_merge(array('Message nature' => 'Engine Display System'),$decode); |
|
525 | + elseif (preg_match(':^#EC:', $message)) { |
|
526 | + $decode = array_merge(array('Message nature' => 'Engine Display System'), $decode); |
|
527 | 527 | } |
528 | - elseif (preg_match(':^#EI:',$message)) { |
|
529 | - $decode = array_merge(array('Message nature' => 'Engine Report'),$decode); |
|
528 | + elseif (preg_match(':^#EI:', $message)) { |
|
529 | + $decode = array_merge(array('Message nature' => 'Engine Report'), $decode); |
|
530 | 530 | } |
531 | - elseif (preg_match(':^#H1:',$message)) { |
|
532 | - $decode = array_merge(array('Message nature' => 'HF Data Radio - Left'),$decode); |
|
531 | + elseif (preg_match(':^#H1:', $message)) { |
|
532 | + $decode = array_merge(array('Message nature' => 'HF Data Radio - Left'), $decode); |
|
533 | 533 | } |
534 | - elseif (preg_match(':^#H2:',$message)) { |
|
535 | - $decode = array_merge(array('Message nature' => 'HF Data Radio - Right'),$decode); |
|
534 | + elseif (preg_match(':^#H2:', $message)) { |
|
535 | + $decode = array_merge(array('Message nature' => 'HF Data Radio - Right'), $decode); |
|
536 | 536 | } |
537 | - elseif (preg_match(':^#HD:',$message)) { |
|
538 | - $decode = array_merge(array('Message nature' => 'HF Data Radio - Selected'),$decode); |
|
537 | + elseif (preg_match(':^#HD:', $message)) { |
|
538 | + $decode = array_merge(array('Message nature' => 'HF Data Radio - Selected'), $decode); |
|
539 | 539 | } |
540 | - elseif (preg_match(':^#M1:',$message)) { |
|
541 | - $decode = array_merge(array('Message nature' => 'Flight Management Computer - Left'),$decode); |
|
540 | + elseif (preg_match(':^#M1:', $message)) { |
|
541 | + $decode = array_merge(array('Message nature' => 'Flight Management Computer - Left'), $decode); |
|
542 | 542 | } |
543 | - elseif (preg_match(':^#M2:',$message)) { |
|
544 | - $decode = array_merge(array('Message nature' => 'Flight Management Computer - Right'),$decode); |
|
543 | + elseif (preg_match(':^#M2:', $message)) { |
|
544 | + $decode = array_merge(array('Message nature' => 'Flight Management Computer - Right'), $decode); |
|
545 | 545 | } |
546 | - elseif (preg_match(':^#M3:',$message)) { |
|
547 | - $decode = array_merge(array('Message nature' => 'Flight Management Computer - Center'),$decode); |
|
546 | + elseif (preg_match(':^#M3:', $message)) { |
|
547 | + $decode = array_merge(array('Message nature' => 'Flight Management Computer - Center'), $decode); |
|
548 | 548 | } |
549 | - elseif (preg_match(':^#MD:',$message)) { |
|
550 | - $decode = array_merge(array('Message nature' => 'Flight Management Computer - Selected'),$decode); |
|
549 | + elseif (preg_match(':^#MD:', $message)) { |
|
550 | + $decode = array_merge(array('Message nature' => 'Flight Management Computer - Selected'), $decode); |
|
551 | 551 | } |
552 | - elseif (preg_match(':^#PS:',$message)) { |
|
553 | - $decode = array_merge(array('Message nature' => 'Keyboard/Display Unit'),$decode); |
|
552 | + elseif (preg_match(':^#PS:', $message)) { |
|
553 | + $decode = array_merge(array('Message nature' => 'Keyboard/Display Unit'), $decode); |
|
554 | 554 | } |
555 | - elseif (preg_match(':^#S1:',$message)) { |
|
556 | - $decode = array_merge(array('Message nature' => 'SDU - Left'),$decode); |
|
555 | + elseif (preg_match(':^#S1:', $message)) { |
|
556 | + $decode = array_merge(array('Message nature' => 'SDU - Left'), $decode); |
|
557 | 557 | } |
558 | - elseif (preg_match(':^#S2:',$message)) { |
|
559 | - $decode = array_merge(array('Message nature' => 'SDU - Right'),$decode); |
|
558 | + elseif (preg_match(':^#S2:', $message)) { |
|
559 | + $decode = array_merge(array('Message nature' => 'SDU - Right'), $decode); |
|
560 | 560 | } |
561 | - elseif (preg_match(':^#SD:',$message)) { |
|
562 | - $decode = array_merge(array('Message nature' => 'SDU - Selected'),$decode); |
|
561 | + elseif (preg_match(':^#SD:', $message)) { |
|
562 | + $decode = array_merge(array('Message nature' => 'SDU - Selected'), $decode); |
|
563 | 563 | } |
564 | - elseif (preg_match(':^#T[0-8]:',$message)) { |
|
565 | - $decode = array_merge(array('Message nature' => 'Cabin Terminal Messages'),$decode); |
|
564 | + elseif (preg_match(':^#T[0-8]:', $message)) { |
|
565 | + $decode = array_merge(array('Message nature' => 'Cabin Terminal Messages'), $decode); |
|
566 | 566 | } |
567 | - elseif (preg_match(':^#WO:',$message)) { |
|
568 | - $decode = array_merge(array('Message nature' => 'Weather Observation Report'),$decode); |
|
567 | + elseif (preg_match(':^#WO:', $message)) { |
|
568 | + $decode = array_merge(array('Message nature' => 'Weather Observation Report'), $decode); |
|
569 | 569 | } |
570 | - elseif (preg_match(':^#A1:',$message)) { |
|
571 | - $decode = array_merge(array('Message nature' => 'Oceanic Clearance'),$decode); |
|
570 | + elseif (preg_match(':^#A1:', $message)) { |
|
571 | + $decode = array_merge(array('Message nature' => 'Oceanic Clearance'), $decode); |
|
572 | 572 | } |
573 | - elseif (preg_match(':^#A3:',$message)) { |
|
574 | - $decode = array_merge(array('Message nature' => 'Departure Clearance Response'),$decode); |
|
573 | + elseif (preg_match(':^#A3:', $message)) { |
|
574 | + $decode = array_merge(array('Message nature' => 'Departure Clearance Response'), $decode); |
|
575 | 575 | } |
576 | - elseif (preg_match(':^#A4:',$message)) { |
|
577 | - $decode = array_merge(array('Message nature' => 'Flight Systems Message'),$decode); |
|
576 | + elseif (preg_match(':^#A4:', $message)) { |
|
577 | + $decode = array_merge(array('Message nature' => 'Flight Systems Message'), $decode); |
|
578 | 578 | } |
579 | - elseif (preg_match(':^#A6:',$message)) { |
|
580 | - $decode = array_merge(array('Message nature' => 'Request ADS Reports'),$decode); |
|
579 | + elseif (preg_match(':^#A6:', $message)) { |
|
580 | + $decode = array_merge(array('Message nature' => 'Request ADS Reports'), $decode); |
|
581 | 581 | } |
582 | - elseif (preg_match(':^#A8:',$message)) { |
|
583 | - $decode = array_merge(array('Message nature' => 'Deliver Departure Slot'),$decode); |
|
582 | + elseif (preg_match(':^#A8:', $message)) { |
|
583 | + $decode = array_merge(array('Message nature' => 'Deliver Departure Slot'), $decode); |
|
584 | 584 | } |
585 | - elseif (preg_match(':^#A9:',$message)) { |
|
586 | - $decode = array_merge(array('Message nature' => 'ATIS report'),$decode); |
|
585 | + elseif (preg_match(':^#A9:', $message)) { |
|
586 | + $decode = array_merge(array('Message nature' => 'ATIS report'), $decode); |
|
587 | 587 | } |
588 | - elseif (preg_match(':^#A0:',$message)) { |
|
589 | - $decode = array_merge(array('Message nature' => 'ATIS Facility Notification (AFN)'),$decode); |
|
588 | + elseif (preg_match(':^#A0:', $message)) { |
|
589 | + $decode = array_merge(array('Message nature' => 'ATIS Facility Notification (AFN)'), $decode); |
|
590 | 590 | } |
591 | - elseif (preg_match(':^#AA:',$message)) { |
|
592 | - $decode = array_merge(array('Message nature' => 'ATCComm'),$decode); |
|
591 | + elseif (preg_match(':^#AA:', $message)) { |
|
592 | + $decode = array_merge(array('Message nature' => 'ATCComm'), $decode); |
|
593 | 593 | } |
594 | - elseif (preg_match(':^#AB:',$message)) { |
|
595 | - $decode = array_merge(array('Message nature' => 'TWIP Report'),$decode); |
|
594 | + elseif (preg_match(':^#AB:', $message)) { |
|
595 | + $decode = array_merge(array('Message nature' => 'TWIP Report'), $decode); |
|
596 | 596 | } |
597 | - elseif (preg_match(':^#AC:',$message)) { |
|
598 | - $decode = array_merge(array('Message nature' => 'Pushback Clearance'),$decode); |
|
597 | + elseif (preg_match(':^#AC:', $message)) { |
|
598 | + $decode = array_merge(array('Message nature' => 'Pushback Clearance'), $decode); |
|
599 | 599 | } |
600 | - elseif (preg_match(':^#AD:',$message)) { |
|
601 | - $decode = array_merge(array('Message nature' => 'Expected Taxi Clearance'),$decode); |
|
600 | + elseif (preg_match(':^#AD:', $message)) { |
|
601 | + $decode = array_merge(array('Message nature' => 'Expected Taxi Clearance'), $decode); |
|
602 | 602 | } |
603 | - elseif (preg_match(':^#AF:',$message)) { |
|
604 | - $decode = array_merge(array('Message nature' => 'CPC Command/Response'),$decode); |
|
603 | + elseif (preg_match(':^#AF:', $message)) { |
|
604 | + $decode = array_merge(array('Message nature' => 'CPC Command/Response'), $decode); |
|
605 | 605 | } |
606 | - elseif (preg_match(':^#B1:',$message)) { |
|
607 | - $decode = array_merge(array('Message nature' => 'Request Oceanic Clearance'),$decode); |
|
606 | + elseif (preg_match(':^#B1:', $message)) { |
|
607 | + $decode = array_merge(array('Message nature' => 'Request Oceanic Clearance'), $decode); |
|
608 | 608 | } |
609 | - elseif (preg_match(':^#B2:',$message)) { |
|
610 | - $decode = array_merge(array('Message nature' => 'Oceanic Clearance Readback'),$decode); |
|
609 | + elseif (preg_match(':^#B2:', $message)) { |
|
610 | + $decode = array_merge(array('Message nature' => 'Oceanic Clearance Readback'), $decode); |
|
611 | 611 | } |
612 | - elseif (preg_match(':^#B3:',$message)) { |
|
613 | - $decode = array_merge(array('Message nature' => 'Request Departure Clearance'),$decode); |
|
612 | + elseif (preg_match(':^#B3:', $message)) { |
|
613 | + $decode = array_merge(array('Message nature' => 'Request Departure Clearance'), $decode); |
|
614 | 614 | } |
615 | - elseif (preg_match(':^#B4:',$message)) { |
|
616 | - $decode = array_merge(array('Message nature' => 'Departure Clearance Readback'),$decode); |
|
615 | + elseif (preg_match(':^#B4:', $message)) { |
|
616 | + $decode = array_merge(array('Message nature' => 'Departure Clearance Readback'), $decode); |
|
617 | 617 | } |
618 | - elseif (preg_match(':^#B6:',$message)) { |
|
619 | - $decode = array_merge(array('Message nature' => 'Provide ADS Report'),$decode); |
|
618 | + elseif (preg_match(':^#B6:', $message)) { |
|
619 | + $decode = array_merge(array('Message nature' => 'Provide ADS Report'), $decode); |
|
620 | 620 | } |
621 | - elseif (preg_match(':^#B8:',$message)) { |
|
622 | - $decode = array_merge(array('Message nature' => 'Request Departure Slot'),$decode); |
|
621 | + elseif (preg_match(':^#B8:', $message)) { |
|
622 | + $decode = array_merge(array('Message nature' => 'Request Departure Slot'), $decode); |
|
623 | 623 | } |
624 | - elseif (preg_match(':^#B9:',$message)) { |
|
625 | - $decode = array_merge(array('Message nature' => 'Request ATIS Report'),$decode); |
|
624 | + elseif (preg_match(':^#B9:', $message)) { |
|
625 | + $decode = array_merge(array('Message nature' => 'Request ATIS Report'), $decode); |
|
626 | 626 | } |
627 | - elseif (preg_match(':^#B0:',$message)) { |
|
628 | - $decode = array_merge(array('Message nature' => 'ATS Facility Notification'),$decode); |
|
627 | + elseif (preg_match(':^#B0:', $message)) { |
|
628 | + $decode = array_merge(array('Message nature' => 'ATS Facility Notification'), $decode); |
|
629 | 629 | } |
630 | - elseif (preg_match(':^#BA:',$message)) { |
|
631 | - $decode = array_merge(array('Message nature' => 'ATCComm'),$decode); |
|
630 | + elseif (preg_match(':^#BA:', $message)) { |
|
631 | + $decode = array_merge(array('Message nature' => 'ATCComm'), $decode); |
|
632 | 632 | } |
633 | - elseif (preg_match(':^#BB:',$message)) { |
|
634 | - $decode = array_merge(array('Message nature' => 'Request TWIP Report'),$decode); |
|
633 | + elseif (preg_match(':^#BB:', $message)) { |
|
634 | + $decode = array_merge(array('Message nature' => 'Request TWIP Report'), $decode); |
|
635 | 635 | } |
636 | - elseif (preg_match(':^#BC:',$message)) { |
|
637 | - $decode = array_merge(array('Message nature' => 'Pushback Clearance Request'),$decode); |
|
636 | + elseif (preg_match(':^#BC:', $message)) { |
|
637 | + $decode = array_merge(array('Message nature' => 'Pushback Clearance Request'), $decode); |
|
638 | 638 | } |
639 | - elseif (preg_match(':^#BD:',$message)) { |
|
640 | - $decode = array_merge(array('Message nature' => 'Expected Taxi Clearance Request'),$decode); |
|
639 | + elseif (preg_match(':^#BD:', $message)) { |
|
640 | + $decode = array_merge(array('Message nature' => 'Expected Taxi Clearance Request'), $decode); |
|
641 | 641 | } |
642 | - elseif (preg_match(':^#BE:',$message)) { |
|
643 | - $decode = array_merge(array('Message nature' => 'CPC Aircraft Log-On/Off Request'),$decode); |
|
642 | + elseif (preg_match(':^#BE:', $message)) { |
|
643 | + $decode = array_merge(array('Message nature' => 'CPC Aircraft Log-On/Off Request'), $decode); |
|
644 | 644 | } |
645 | - elseif (preg_match(':^#BF:',$message)) { |
|
646 | - $decode = array_merge(array('Message nature' => 'CPC WILCO/UNABLE Response'),$decode); |
|
645 | + elseif (preg_match(':^#BF:', $message)) { |
|
646 | + $decode = array_merge(array('Message nature' => 'CPC WILCO/UNABLE Response'), $decode); |
|
647 | 647 | } |
648 | - elseif (preg_match(':^#H3:',$message)) { |
|
649 | - $decode = array_merge(array('Message nature' => 'Icing Report'),$decode); |
|
648 | + elseif (preg_match(':^#H3:', $message)) { |
|
649 | + $decode = array_merge(array('Message nature' => 'Icing Report'), $decode); |
|
650 | 650 | } |
651 | 651 | } |
652 | 652 | if ($label == '10') { |
653 | - if (preg_match(':^DTO01:',$message)) { |
|
654 | - $decode = array_merge(array('Message nature' => 'Delayed Takeoff Report'),$decode); |
|
653 | + if (preg_match(':^DTO01:', $message)) { |
|
654 | + $decode = array_merge(array('Message nature' => 'Delayed Takeoff Report'), $decode); |
|
655 | 655 | } |
656 | - elseif (preg_match(':^AIS01:',$message)) { |
|
657 | - $decode = array_merge(array('Message nature' => 'AIS Request'),$decode); |
|
656 | + elseif (preg_match(':^AIS01:', $message)) { |
|
657 | + $decode = array_merge(array('Message nature' => 'AIS Request'), $decode); |
|
658 | 658 | } |
659 | - elseif (preg_match(':^FTX01:',$message)) { |
|
660 | - $decode = array_merge(array('Message nature' => 'Free Text Downlink'),$decode); |
|
659 | + elseif (preg_match(':^FTX01:', $message)) { |
|
660 | + $decode = array_merge(array('Message nature' => 'Free Text Downlink'), $decode); |
|
661 | 661 | } |
662 | - elseif (preg_match(':^FPL01:',$message)) { |
|
663 | - $decode = array_merge(array('Message nature' => 'Flight Plan Request'),$decode); |
|
662 | + elseif (preg_match(':^FPL01:', $message)) { |
|
663 | + $decode = array_merge(array('Message nature' => 'Flight Plan Request'), $decode); |
|
664 | 664 | } |
665 | - elseif (preg_match(':^WAB01:',$message)) { |
|
666 | - $decode = array_merge(array('Message nature' => 'Weight & Balance Request'),$decode); |
|
665 | + elseif (preg_match(':^WAB01:', $message)) { |
|
666 | + $decode = array_merge(array('Message nature' => 'Weight & Balance Request'), $decode); |
|
667 | 667 | } |
668 | - elseif (preg_match(':^MET01:',$message)) { |
|
669 | - $decode = array_merge(array('Message nature' => 'Weather Data Request'),$decode); |
|
668 | + elseif (preg_match(':^MET01:', $message)) { |
|
669 | + $decode = array_merge(array('Message nature' => 'Weather Data Request'), $decode); |
|
670 | 670 | } |
671 | - elseif (preg_match(':^WAB02:',$message)) { |
|
672 | - $decode = array_merge(array('Message nature' => 'Weight and Balance Acknowledgement'),$decode); |
|
671 | + elseif (preg_match(':^WAB02:', $message)) { |
|
672 | + $decode = array_merge(array('Message nature' => 'Weight and Balance Acknowledgement'), $decode); |
|
673 | 673 | } |
674 | 674 | } |
675 | 675 | if ($label == '15') { |
676 | - if (preg_match(':^FST01:',$message)) { |
|
677 | - $decode = array_merge(array('Message nature' => 'Flight Status Report'),$decode); |
|
676 | + if (preg_match(':^FST01:', $message)) { |
|
677 | + $decode = array_merge(array('Message nature' => 'Flight Status Report'), $decode); |
|
678 | 678 | } |
679 | 679 | } |
680 | 680 | if (!$found && $label == 'SA') { |
681 | - $n = sscanf($message, "%d%c%c%6[0-9]", $version,$state,$type,$at); |
|
681 | + $n = sscanf($message, "%d%c%c%6[0-9]", $version, $state, $type, $at); |
|
682 | 682 | if ($n == 4) { |
683 | 683 | $vsta = array('Version' => $version); |
684 | 684 | if ($state == 'E') { |
685 | - $vsta = array_merge($vsta,array('Link state' => 'Established')); |
|
685 | + $vsta = array_merge($vsta, array('Link state' => 'Established')); |
|
686 | 686 | } |
687 | 687 | elseif ($state == 'L') { |
688 | - $vsta = array_merge($vsta,array('Link state' => 'Lost')); |
|
688 | + $vsta = array_merge($vsta, array('Link state' => 'Lost')); |
|
689 | 689 | } |
690 | 690 | else { |
691 | - $vsta = array_merge($vsta,array('Link state' => 'Unknown')); |
|
691 | + $vsta = array_merge($vsta, array('Link state' => 'Unknown')); |
|
692 | 692 | } |
693 | 693 | if ($type == 'V') { |
694 | - $vsta = array_merge($vsta,array('Link type' => 'VHF ACARS')); |
|
694 | + $vsta = array_merge($vsta, array('Link type' => 'VHF ACARS')); |
|
695 | 695 | } |
696 | 696 | elseif ($type == 'S') { |
697 | - $vsta = array_merge($vsta,array('Link type' => 'Generic SATCOM')); |
|
697 | + $vsta = array_merge($vsta, array('Link type' => 'Generic SATCOM')); |
|
698 | 698 | } |
699 | 699 | elseif ($type == 'H') { |
700 | - $vsta = array_merge($vsta,array('Link type' => 'HF')); |
|
700 | + $vsta = array_merge($vsta, array('Link type' => 'HF')); |
|
701 | 701 | } |
702 | 702 | elseif ($type == 'G') { |
703 | - $vsta = array_merge($vsta,array('Link type' => 'GlobalStar SATCOM')); |
|
703 | + $vsta = array_merge($vsta, array('Link type' => 'GlobalStar SATCOM')); |
|
704 | 704 | } |
705 | 705 | elseif ($type == 'C') { |
706 | - $vsta = array_merge($vsta,array('Link type' => 'ICO SATCOM')); |
|
706 | + $vsta = array_merge($vsta, array('Link type' => 'ICO SATCOM')); |
|
707 | 707 | } |
708 | 708 | elseif ($type == '2') { |
709 | - $vsta = array_merge($vsta,array('Link type' => 'VDL Mode 2')); |
|
709 | + $vsta = array_merge($vsta, array('Link type' => 'VDL Mode 2')); |
|
710 | 710 | } |
711 | 711 | elseif ($type == 'X') { |
712 | - $vsta = array_merge($vsta,array('Link type' => 'Inmarsat Aero')); |
|
712 | + $vsta = array_merge($vsta, array('Link type' => 'Inmarsat Aero')); |
|
713 | 713 | } |
714 | 714 | elseif ($type == 'I') { |
715 | - $vsta = array_merge($vsta,array('Link type' => 'Irridium SATCOM')); |
|
715 | + $vsta = array_merge($vsta, array('Link type' => 'Irridium SATCOM')); |
|
716 | 716 | } |
717 | 717 | else { |
718 | - $vsta = array_merge($vsta,array('Link type' => 'Unknown')); |
|
718 | + $vsta = array_merge($vsta, array('Link type' => 'Unknown')); |
|
719 | 719 | } |
720 | - $vsta = array_merge($vsta,array('Event occured at' => implode(':',str_split($at,2)))); |
|
721 | - $decode = array_merge($vsta,$decode); |
|
720 | + $vsta = array_merge($vsta, array('Event occured at' => implode(':', str_split($at, 2)))); |
|
721 | + $decode = array_merge($vsta, $decode); |
|
722 | 722 | } |
723 | 723 | } |
724 | 724 | |
725 | 725 | $title = $this->getTitlefromLabel($label); |
726 | - if ($title != '') $decode = array_merge(array('Message title' => $title),$decode); |
|
726 | + if ($title != '') $decode = array_merge(array('Message title' => $title), $decode); |
|
727 | 727 | /* |
728 | 728 | // Business jets always use GS0001 |
729 | 729 | if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude); |
@@ -744,21 +744,21 @@ discard block |
||
744 | 744 | * @param String ACARS data in acarsdec data |
745 | 745 | * |
746 | 746 | */ |
747 | - public function add($data,$message = array()) { |
|
747 | + public function add($data, $message = array()) { |
|
748 | 748 | global $globalDebug, $globalACARSArchive; |
749 | 749 | $Image = new Image($this->db); |
750 | 750 | $Schedule = new Schedule($this->db); |
751 | 751 | $Translation = new Translation($this->db); |
752 | 752 | |
753 | - $message = array_merge($message,$this->parse($data)); |
|
753 | + $message = array_merge($message, $this->parse($data)); |
|
754 | 754 | if (isset($message['registration']) && $message['registration'] != '' && $message['ident'] != '' && $message['registration'] != '!') { |
755 | - $ident = (string)$message['ident']; |
|
755 | + $ident = (string) $message['ident']; |
|
756 | 756 | $label = $message['label']; |
757 | 757 | $block_id = $message['block_id']; |
758 | 758 | $msg_no = $message['msg_no']; |
759 | 759 | $msg = $message['message']; |
760 | 760 | $decode = $message['decode']; |
761 | - $registration = (string)$message['registration']; |
|
761 | + $registration = (string) $message['registration']; |
|
762 | 762 | if (isset($decode['latitude'])) $latitude = $decode['latitude']; |
763 | 763 | else $latitude = ''; |
764 | 764 | if (isset($decode['longitude'])) $longitude = $decode['longitude']; |
@@ -772,20 +772,20 @@ discard block |
||
772 | 772 | $Image->addSpotterImage($registration); |
773 | 773 | } |
774 | 774 | // Business jets always use GS0001 |
775 | - if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude); |
|
775 | + if ($ident != 'GS0001') $info = $this->addModeSData($ident, $registration, $icao, $airicao, $latitude, $longitude); |
|
776 | 776 | if ($globalDebug && isset($info) && $info != '') echo $info; |
777 | 777 | if (count($decode) > 0) $decode_json = json_encode($decode); |
778 | 778 | else $decode_json = ''; |
779 | 779 | if (isset($decode['Departure airport']) && isset($decode['Departure hour']) && isset($decode['Arrival airport']) && isset($decode['Arrival hour'])) { |
780 | - $Schedule->addSchedule($icao,$decode['Departure airport'],$decode['Departure hour'],$decode['Arrival airport'],$decode['Arrival hour'],'ACARS'); |
|
780 | + $Schedule->addSchedule($icao, $decode['Departure airport'], $decode['Departure hour'], $decode['Arrival airport'], $decode['Arrival hour'], 'ACARS'); |
|
781 | 781 | } elseif (isset($decode['Departure airport']) && isset($decode['Arrival airport'])) { |
782 | - $Schedule->addSchedule($icao,$decode['Departure airport'],'',$decode['Arrival airport'],'','ACARS'); |
|
782 | + $Schedule->addSchedule($icao, $decode['Departure airport'], '', $decode['Arrival airport'], '', 'ACARS'); |
|
783 | 783 | } |
784 | - $result = $this->addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json); |
|
785 | - if (!isset($globalACARSArchive)) $globalACARSArchive = array('10','80','81','82','3F'); |
|
786 | - if ($result && in_array($label,$globalACARSArchive)) $this->addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json); |
|
784 | + $result = $this->addLiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $msg, $decode_json); |
|
785 | + if (!isset($globalACARSArchive)) $globalACARSArchive = array('10', '80', '81', '82', '3F'); |
|
786 | + if ($result && in_array($label, $globalACARSArchive)) $this->addArchiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $msg, $decode_json); |
|
787 | 787 | if ($globalDebug && count($decode) > 0) { |
788 | - echo "Human readable data : ".implode(' - ',$decode)."\n"; |
|
788 | + echo "Human readable data : ".implode(' - ', $decode)."\n"; |
|
789 | 789 | } |
790 | 790 | } |
791 | 791 | } |
@@ -802,7 +802,7 @@ discard block |
||
802 | 802 | * @param string $decode |
803 | 803 | * @return bool |
804 | 804 | */ |
805 | - public function addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') { |
|
805 | + public function addLiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $message, $decode = '') { |
|
806 | 806 | global $globalDebug; |
807 | 807 | date_default_timezone_set('UTC'); |
808 | 808 | if ($label != 'SQ' && $label != 'Q0' && $label != '_d' && $message != '') { |
@@ -810,22 +810,22 @@ discard block |
||
810 | 810 | $this->db = $Connection->db; |
811 | 811 | if ($globalDebug) echo "Test if not already in Live ACARS table..."; |
812 | 812 | $query_test = "SELECT COUNT(*) as nb FROM acars_live WHERE ident = :ident AND registration = :registration AND message = :message"; |
813 | - $query_test_values = array(':ident' => $ident,':registration' => $registration, ':message' => $message); |
|
813 | + $query_test_values = array(':ident' => $ident, ':registration' => $registration, ':message' => $message); |
|
814 | 814 | try { |
815 | 815 | $stht = $this->db->prepare($query_test); |
816 | 816 | $stht->execute($query_test_values); |
817 | - } catch(PDOException $e) { |
|
817 | + } catch (PDOException $e) { |
|
818 | 818 | echo "error : ".$e->getMessage(); |
819 | 819 | return false; |
820 | 820 | } |
821 | 821 | if ($stht->fetchColumn() == 0) { |
822 | 822 | if ($globalDebug) echo "Add Live ACARS data..."; |
823 | 823 | $query = "INSERT INTO acars_live (ident,registration,label,block_id,msg_no,message,decode,date) VALUES (:ident,:registration,:label,:block_id,:msg_no,:message,:decode,:date)"; |
824 | - $query_values = array(':ident' => $ident,':registration' => $registration, ':label' => $label,':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode,':date' => date("Y-m-d H:i:s")); |
|
824 | + $query_values = array(':ident' => $ident, ':registration' => $registration, ':label' => $label, ':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode, ':date' => date("Y-m-d H:i:s")); |
|
825 | 825 | try { |
826 | 826 | $sth = $this->db->prepare($query); |
827 | 827 | $sth->execute($query_values); |
828 | - } catch(PDOException $e) { |
|
828 | + } catch (PDOException $e) { |
|
829 | 829 | echo "error : ".$e->getMessage(); |
830 | 830 | return false; |
831 | 831 | } |
@@ -851,10 +851,10 @@ discard block |
||
851 | 851 | * @param string $decode |
852 | 852 | * @return string |
853 | 853 | */ |
854 | - public function addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') { |
|
854 | + public function addArchiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $message, $decode = '') { |
|
855 | 855 | global $globalDebug; |
856 | 856 | date_default_timezone_set('UTC'); |
857 | - if ($label != 'SQ' && $label != 'Q0' && $label != '_d' && $message != '' && preg_match('/^MET0/',$message) === 0 && preg_match('/^ARR0/',$message) === 0 && preg_match('/^ETA/',$message) === 0 && preg_match('/^WXR/',$message) === 0 && preg_match('/^FTX01.FIC/',$message) === 0) { |
|
857 | + if ($label != 'SQ' && $label != 'Q0' && $label != '_d' && $message != '' && preg_match('/^MET0/', $message) === 0 && preg_match('/^ARR0/', $message) === 0 && preg_match('/^ETA/', $message) === 0 && preg_match('/^WXR/', $message) === 0 && preg_match('/^FTX01.FIC/', $message) === 0) { |
|
858 | 858 | /* |
859 | 859 | if ($globalDebug) echo "Test if not already in Archive ACARS table..."; |
860 | 860 | $query_test = "SELECT COUNT(*) as nb FROM acars_archive WHERE ident = :ident AND registration = :registration AND message = :message"; |
@@ -869,11 +869,11 @@ discard block |
||
869 | 869 | */ |
870 | 870 | if ($globalDebug) echo "Add Live ACARS data..."; |
871 | 871 | $query = "INSERT INTO acars_archive (ident,registration,label,block_id,msg_no,message,decode) VALUES (:ident,:registration,:label,:block_id,:msg_no,:message,:decode)"; |
872 | - $query_values = array(':ident' => $ident,':registration' => $registration, ':label' => $label,':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode); |
|
872 | + $query_values = array(':ident' => $ident, ':registration' => $registration, ':label' => $label, ':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode); |
|
873 | 873 | try { |
874 | 874 | $sth = $this->db->prepare($query); |
875 | 875 | $sth->execute($query_values); |
876 | - } catch(PDOException $e) { |
|
876 | + } catch (PDOException $e) { |
|
877 | 877 | return "error : ".$e->getMessage(); |
878 | 878 | } |
879 | 879 | if ($globalDebug) echo "Done\n"; |
@@ -895,7 +895,7 @@ discard block |
||
895 | 895 | try { |
896 | 896 | $sth = $this->db->prepare($query); |
897 | 897 | $sth->execute($query_values); |
898 | - } catch(PDOException $e) { |
|
898 | + } catch (PDOException $e) { |
|
899 | 899 | echo "error : ".$e->getMessage(); |
900 | 900 | return ''; |
901 | 901 | } |
@@ -915,7 +915,7 @@ discard block |
||
915 | 915 | try { |
916 | 916 | $sth = $this->db->prepare($query); |
917 | 917 | $sth->execute($query_values); |
918 | - } catch(PDOException $e) { |
|
918 | + } catch (PDOException $e) { |
|
919 | 919 | echo "error : ".$e->getMessage(); |
920 | 920 | return array(); |
921 | 921 | } |
@@ -936,7 +936,7 @@ discard block |
||
936 | 936 | try { |
937 | 937 | $sth = $this->db->prepare($query); |
938 | 938 | $sth->execute($query_values); |
939 | - } catch(PDOException $e) { |
|
939 | + } catch (PDOException $e) { |
|
940 | 940 | echo "error : ".$e->getMessage(); |
941 | 941 | return array(); |
942 | 942 | } |
@@ -952,7 +952,7 @@ discard block |
||
952 | 952 | * @param string $label |
953 | 953 | * @return array Return ACARS data in array |
954 | 954 | */ |
955 | - public function getLatestAcarsData($limit = '',$label = '') { |
|
955 | + public function getLatestAcarsData($limit = '', $label = '') { |
|
956 | 956 | global $globalURL; |
957 | 957 | $Image = new Image($this->db); |
958 | 958 | $Spotter = new Spotter($this->db); |
@@ -963,8 +963,8 @@ discard block |
||
963 | 963 | if ($limit != "") |
964 | 964 | { |
965 | 965 | $limit_array = explode(",", $limit); |
966 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
967 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
966 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
967 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
968 | 968 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
969 | 969 | { |
970 | 970 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
@@ -980,7 +980,7 @@ discard block |
||
980 | 980 | try { |
981 | 981 | $sth = $this->db->prepare($query); |
982 | 982 | $sth->execute($query_values); |
983 | - } catch(PDOException $e) { |
|
983 | + } catch (PDOException $e) { |
|
984 | 984 | echo "error : ".$e->getMessage(); |
985 | 985 | return array(); |
986 | 986 | } |
@@ -988,39 +988,39 @@ discard block |
||
988 | 988 | while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
989 | 989 | $data = array(); |
990 | 990 | if ($row['registration'] != '') { |
991 | - $row['registration'] = str_replace('.','',$row['registration']); |
|
991 | + $row['registration'] = str_replace('.', '', $row['registration']); |
|
992 | 992 | $image_array = $Image->getSpotterImage($row['registration']); |
993 | - if (count($image_array) > 0) $data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website'])); |
|
994 | - else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
995 | - } else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
993 | + if (count($image_array) > 0) $data = array_merge($data, array('image' => $image_array[0]['image'], 'image_thumbnail' => $image_array[0]['image_thumbnail'], 'image_copyright' => $image_array[0]['image_copyright'], 'image_source' => $image_array[0]['image_source'], 'image_source_website' => $image_array[0]['image_source_website'])); |
|
994 | + else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => '')); |
|
995 | + } else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => '')); |
|
996 | 996 | if ($row['registration'] == '') $row['registration'] = 'NA'; |
997 | 997 | if ($row['ident'] == '') $row['ident'] = 'NA'; |
998 | - $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2)); |
|
998 | + $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'], 0, 2)); |
|
999 | 999 | if (isset($identicao[0])) { |
1000 | - if (substr($row['ident'],0,2) == 'AF') { |
|
1001 | - if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
1002 | - else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
1003 | - } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
1004 | - $data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name'])); |
|
1000 | + if (substr($row['ident'], 0, 2) == 'AF') { |
|
1001 | + if (filter_var(substr($row['ident'], 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
1002 | + else $icao = 'AFR'.ltrim(substr($row['ident'], 2), '0'); |
|
1003 | + } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'], 2), '0'); |
|
1004 | + $data = array_merge($data, array('airline_icao' => $identicao[0]['icao'], 'airline_name' => $identicao[0]['name'])); |
|
1005 | 1005 | } else $icao = $row['ident']; |
1006 | - $icao = $Translation->checkTranslation($icao,false); |
|
1007 | - $decode = json_decode($row['decode'],true); |
|
1006 | + $icao = $Translation->checkTranslation($icao, false); |
|
1007 | + $decode = json_decode($row['decode'], true); |
|
1008 | 1008 | $found = false; |
1009 | - if ($decode != '' && array_key_exists('Departure airport',$decode)) { |
|
1009 | + if ($decode != '' && array_key_exists('Departure airport', $decode)) { |
|
1010 | 1010 | $airport_info = $Spotter->getAllAirportInfo($decode['Departure airport']); |
1011 | 1011 | if (isset($airport_info[0]['icao'])) { |
1012 | 1012 | $decode['Departure airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
1013 | 1013 | $found = true; |
1014 | 1014 | } |
1015 | 1015 | } |
1016 | - if ($decode != '' && array_key_exists('Arrival airport',$decode)) { |
|
1016 | + if ($decode != '' && array_key_exists('Arrival airport', $decode)) { |
|
1017 | 1017 | $airport_info = $Spotter->getAllAirportInfo($decode['Arrival airport']); |
1018 | 1018 | if (isset($airport_info[0]['icao'])) { |
1019 | 1019 | $decode['Arrival airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
1020 | 1020 | $found = true; |
1021 | 1021 | } |
1022 | 1022 | } |
1023 | - if ($decode != '' && array_key_exists('Airport/Waypoint name',$decode)) { |
|
1023 | + if ($decode != '' && array_key_exists('Airport/Waypoint name', $decode)) { |
|
1024 | 1024 | $airport_info = $Spotter->getAllAirportInfo($decode['Airport/Waypoint name']); |
1025 | 1025 | if (isset($airport_info[0]['icao'])) { |
1026 | 1026 | $decode['Airport/Waypoint name'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
@@ -1028,7 +1028,7 @@ discard block |
||
1028 | 1028 | } |
1029 | 1029 | } |
1030 | 1030 | if ($found) $row['decode'] = json_encode($decode); |
1031 | - $data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode'])); |
|
1031 | + $data = array_merge($data, array('registration' => $row['registration'], 'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode'])); |
|
1032 | 1032 | $result[] = $data; |
1033 | 1033 | $i++; |
1034 | 1034 | } |
@@ -1046,7 +1046,7 @@ discard block |
||
1046 | 1046 | * @param string $label |
1047 | 1047 | * @return array Return ACARS data in array |
1048 | 1048 | */ |
1049 | - public function getArchiveAcarsData($limit = '',$label = '') { |
|
1049 | + public function getArchiveAcarsData($limit = '', $label = '') { |
|
1050 | 1050 | global $globalURL; |
1051 | 1051 | $Image = new Image($this->db); |
1052 | 1052 | $Spotter = new Spotter($this->db); |
@@ -1056,8 +1056,8 @@ discard block |
||
1056 | 1056 | if ($limit != "") |
1057 | 1057 | { |
1058 | 1058 | $limit_array = explode(",", $limit); |
1059 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1060 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1059 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
1060 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
1061 | 1061 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
1062 | 1062 | { |
1063 | 1063 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
@@ -1078,45 +1078,45 @@ discard block |
||
1078 | 1078 | try { |
1079 | 1079 | $sth = $this->db->prepare($query); |
1080 | 1080 | $sth->execute($query_values); |
1081 | - } catch(PDOException $e) { |
|
1081 | + } catch (PDOException $e) { |
|
1082 | 1082 | echo "error : ".$e->getMessage(); |
1083 | 1083 | return array(); |
1084 | 1084 | } |
1085 | - $i=0; |
|
1085 | + $i = 0; |
|
1086 | 1086 | $result = array(); |
1087 | 1087 | while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
1088 | 1088 | $data = array(); |
1089 | 1089 | if ($row['registration'] != '') { |
1090 | - $row['registration'] = str_replace('.','',$row['registration']); |
|
1090 | + $row['registration'] = str_replace('.', '', $row['registration']); |
|
1091 | 1091 | $image_array = $Image->getSpotterImage($row['registration']); |
1092 | - if (count($image_array) > 0) $data = array_merge($data,array('image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website'])); |
|
1093 | - else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
1094 | - } else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
1092 | + if (count($image_array) > 0) $data = array_merge($data, array('image_thumbnail' => $image_array[0]['image_thumbnail'], 'image_copyright' => $image_array[0]['image_copyright'], 'image_source' => $image_array[0]['image_source'], 'image_source_website' => $image_array[0]['image_source_website'])); |
|
1093 | + else $data = array_merge($data, array('image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => '')); |
|
1094 | + } else $data = array_merge($data, array('image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => '')); |
|
1095 | 1095 | $icao = ''; |
1096 | 1096 | if ($row['registration'] == '') $row['registration'] = 'NA'; |
1097 | 1097 | if ($row['ident'] == '') $row['ident'] = 'NA'; |
1098 | - $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2)); |
|
1098 | + $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'], 0, 2)); |
|
1099 | 1099 | if (isset($identicao[0])) { |
1100 | - if (substr($row['ident'],0,2) == 'AF') { |
|
1101 | - if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
1102 | - else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
1103 | - } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
1104 | - $data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name'])); |
|
1100 | + if (substr($row['ident'], 0, 2) == 'AF') { |
|
1101 | + if (filter_var(substr($row['ident'], 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
1102 | + else $icao = 'AFR'.ltrim(substr($row['ident'], 2), '0'); |
|
1103 | + } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'], 2), '0'); |
|
1104 | + $data = array_merge($data, array('airline_icao' => $identicao[0]['icao'], 'airline_name' => $identicao[0]['name'])); |
|
1105 | 1105 | } else $icao = $row['ident']; |
1106 | 1106 | $icao = $Translation->checkTranslation($icao); |
1107 | - $decode = json_decode($row['decode'],true); |
|
1107 | + $decode = json_decode($row['decode'], true); |
|
1108 | 1108 | $found = false; |
1109 | - if ($decode != '' && array_key_exists('Departure airport',$decode)) { |
|
1109 | + if ($decode != '' && array_key_exists('Departure airport', $decode)) { |
|
1110 | 1110 | $airport_info = $Spotter->getAllAirportInfo($decode['Departure airport']); |
1111 | 1111 | if (isset($airport_info[0]['icao'])) $decode['Departure airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
1112 | 1112 | $found = true; |
1113 | 1113 | } |
1114 | - if ($decode != '' && array_key_exists('Arrival airport',$decode)) { |
|
1114 | + if ($decode != '' && array_key_exists('Arrival airport', $decode)) { |
|
1115 | 1115 | $airport_info = $Spotter->getAllAirportInfo($decode['Arrival airport']); |
1116 | 1116 | if (isset($airport_info[0]['icao'])) $decode['Arrival airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
1117 | 1117 | $found = true; |
1118 | 1118 | } |
1119 | - if ($decode != '' && array_key_exists('Airport/Waypoint name',$decode)) { |
|
1119 | + if ($decode != '' && array_key_exists('Airport/Waypoint name', $decode)) { |
|
1120 | 1120 | $airport_info = $Spotter->getAllAirportInfo($decode['Airport/Waypoint name']); |
1121 | 1121 | if (isset($airport_info[0]['icao'])) { |
1122 | 1122 | $decode['Airport/Waypoint name'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
@@ -1124,7 +1124,7 @@ discard block |
||
1124 | 1124 | } |
1125 | 1125 | } |
1126 | 1126 | if ($found) $row['decode'] = json_encode($decode); |
1127 | - $data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode'])); |
|
1127 | + $data = array_merge($data, array('registration' => $row['registration'], 'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode'])); |
|
1128 | 1128 | $result[] = $data; |
1129 | 1129 | $i++; |
1130 | 1130 | } |
@@ -1145,7 +1145,7 @@ discard block |
||
1145 | 1145 | * @param string $longitude |
1146 | 1146 | * @return string |
1147 | 1147 | */ |
1148 | - public function addModeSData($ident,$registration,$icao = '',$ICAOTypeCode = '',$latitude = '', $longitude = '') { |
|
1148 | + public function addModeSData($ident, $registration, $icao = '', $ICAOTypeCode = '', $latitude = '', $longitude = '') { |
|
1149 | 1149 | global $globalDebug, $globalDBdriver; |
1150 | 1150 | $ident = trim($ident); |
1151 | 1151 | $Translation = new Translation($this->db); |
@@ -1158,7 +1158,7 @@ discard block |
||
1158 | 1158 | if ($globalDebug) echo "Ident or registration null, exit\n"; |
1159 | 1159 | return ''; |
1160 | 1160 | } |
1161 | - $registration = str_replace('.','',$registration); |
|
1161 | + $registration = str_replace('.', '', $registration); |
|
1162 | 1162 | $ident = $Translation->ident2icao($ident); |
1163 | 1163 | // Check if a flight with same registration is flying now, if ok check if callsign = name in ACARS, else add it to translation |
1164 | 1164 | if ($globalDebug) echo "Check if needed to add translation ".$ident.'... '; |
@@ -1167,7 +1167,7 @@ discard block |
||
1167 | 1167 | try { |
1168 | 1168 | $sthsi = $this->db->prepare($querysi); |
1169 | 1169 | $sthsi->execute($querysi_values); |
1170 | - } catch(PDOException $e) { |
|
1170 | + } catch (PDOException $e) { |
|
1171 | 1171 | if ($globalDebug) echo $e->getMessage(); |
1172 | 1172 | return "error : ".$e->getMessage(); |
1173 | 1173 | } |
@@ -1177,8 +1177,8 @@ discard block |
||
1177 | 1177 | $Translation = new Translation($this->db); |
1178 | 1178 | $trans_ident = $Translation->getOperator($resultsi['ident']); |
1179 | 1179 | if ($globalDebug) echo 'Add translation to table : '.$ident.' -> '.$resultsi['ident'].' '; |
1180 | - if ($ident != $trans_ident) $Translation->addOperator($resultsi['ident'],$ident,'ACARS'); |
|
1181 | - elseif ($trans_ident == $ident) $Translation->updateOperator($resultsi['ident'],$ident,'ACARS'); |
|
1180 | + if ($ident != $trans_ident) $Translation->addOperator($resultsi['ident'], $ident, 'ACARS'); |
|
1181 | + elseif ($trans_ident == $ident) $Translation->updateOperator($resultsi['ident'], $ident, 'ACARS'); |
|
1182 | 1182 | } else { |
1183 | 1183 | if ($registration != '' && $latitude != '' && $longitude != '') { |
1184 | 1184 | $query = "SELECT ModeS FROM aircraft_modes WHERE Registration = :registration LIMIT 1"; |
@@ -1186,7 +1186,7 @@ discard block |
||
1186 | 1186 | try { |
1187 | 1187 | $sth = $this->db->prepare($query); |
1188 | 1188 | $sth->execute($query_values); |
1189 | - } catch(PDOException $e) { |
|
1189 | + } catch (PDOException $e) { |
|
1190 | 1190 | if ($globalDebug) echo $e->getMessage(); |
1191 | 1191 | return "error : ".$e->getMessage(); |
1192 | 1192 | } |
@@ -1194,7 +1194,7 @@ discard block |
||
1194 | 1194 | $sth->closeCursor(); |
1195 | 1195 | if (isset($result['modes'])) $hex = $result['modes']; |
1196 | 1196 | else $hex = ''; |
1197 | - $SI_data = array('hex' => $hex,'ident' => $ident,'aircraft_icao' => $ICAOTypeCode,'registration' => $registration,'latitude' => $latitude,'$longitude' => $longitude,'format_source' => 'ACARS'); |
|
1197 | + $SI_data = array('hex' => $hex, 'ident' => $ident, 'aircraft_icao' => $ICAOTypeCode, 'registration' => $registration, 'latitude' => $latitude, '$longitude' => $longitude, 'format_source' => 'ACARS'); |
|
1198 | 1198 | if ($this->fromACARSscript) $this->SI->add($SI_data); |
1199 | 1199 | } |
1200 | 1200 | } |
@@ -1204,7 +1204,7 @@ discard block |
||
1204 | 1204 | try { |
1205 | 1205 | $sth = $this->db->prepare($query); |
1206 | 1206 | $sth->execute($query_values); |
1207 | - } catch(PDOException $e) { |
|
1207 | + } catch (PDOException $e) { |
|
1208 | 1208 | if ($globalDebug) echo $e->getMessage(); |
1209 | 1209 | return "error : ".$e->getMessage(); |
1210 | 1210 | } |
@@ -1214,7 +1214,7 @@ discard block |
||
1214 | 1214 | if (isset($result['ModeS'])) $ModeS = $result['ModeS']; |
1215 | 1215 | else $ModeS = ''; |
1216 | 1216 | if ($ModeS == '') { |
1217 | - $id = explode('-',$result['flightaware_id']); |
|
1217 | + $id = explode('-', $result['flightaware_id']); |
|
1218 | 1218 | $ModeS = $id[0]; |
1219 | 1219 | } |
1220 | 1220 | if ($ModeS != '') { |
@@ -1224,20 +1224,20 @@ discard block |
||
1224 | 1224 | try { |
1225 | 1225 | $sthc = $this->db->prepare($queryc); |
1226 | 1226 | $sthc->execute($queryc_values); |
1227 | - } catch(PDOException $e) { |
|
1227 | + } catch (PDOException $e) { |
|
1228 | 1228 | if ($globalDebug) echo $e->getMessage(); |
1229 | 1229 | return "error : ".$e->getMessage(); |
1230 | 1230 | } |
1231 | 1231 | $row = $sthc->fetch(PDO::FETCH_ASSOC); |
1232 | 1232 | $sthc->closeCursor(); |
1233 | - if (count($row) == 0) { |
|
1233 | + if (count($row) == 0) { |
|
1234 | 1234 | if ($globalDebug) echo " Add to ModeS table - "; |
1235 | 1235 | $queryi = "INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:ModeS,:ModeSCountry,:Registration, :ICAOTypeCode,'ACARS')"; |
1236 | - $queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode); |
|
1236 | + $queryi_values = array(':ModeS' => $ModeS, ':ModeSCountry' => $country, ':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode); |
|
1237 | 1237 | try { |
1238 | 1238 | $sthi = $this->db->prepare($queryi); |
1239 | 1239 | $sthi->execute($queryi_values); |
1240 | - } catch(PDOException $e) { |
|
1240 | + } catch (PDOException $e) { |
|
1241 | 1241 | if ($globalDebug) echo $e->getMessage(); |
1242 | 1242 | return "error : ".$e->getMessage(); |
1243 | 1243 | } |
@@ -1245,15 +1245,15 @@ discard block |
||
1245 | 1245 | if ($globalDebug) echo " Update ModeS table - "; |
1246 | 1246 | if ($ICAOTypeCode != '') { |
1247 | 1247 | $queryi = "UPDATE aircraft_modes SET ModeSCountry = :ModeSCountry,Registration = :Registration,ICAOTypeCode = :ICAOTypeCode,Source = 'ACARS',LastModified = NOW() WHERE ModeS = :ModeS"; |
1248 | - $queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode); |
|
1248 | + $queryi_values = array(':ModeS' => $ModeS, ':ModeSCountry' => $country, ':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode); |
|
1249 | 1249 | } else { |
1250 | 1250 | $queryi = "UPDATE aircraft_modes SET ModeSCountry = :ModeSCountry,Registration = :Registration,Source = 'ACARS',LastModified = NOW() WHERE ModeS = :ModeS"; |
1251 | - $queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration); |
|
1251 | + $queryi_values = array(':ModeS' => $ModeS, ':ModeSCountry' => $country, ':Registration' => $registration); |
|
1252 | 1252 | } |
1253 | 1253 | try { |
1254 | 1254 | $sthi = $this->db->prepare($queryi); |
1255 | 1255 | $sthi->execute($queryi_values); |
1256 | - } catch(PDOException $e) { |
|
1256 | + } catch (PDOException $e) { |
|
1257 | 1257 | if ($globalDebug) echo $e->getMessage(); |
1258 | 1258 | return "error : ".$e->getMessage(); |
1259 | 1259 | } |
@@ -1290,12 +1290,12 @@ discard block |
||
1290 | 1290 | elseif ($globalDBdriver == 'pgsql') { |
1291 | 1291 | $queryi = "UPDATE spotter_output SET registration = :Registration WHERE ident = :ident AND date >= NOW() AT TIME ZONE 'UTC' - INTERVAL '1 HOUR'"; |
1292 | 1292 | } |
1293 | - $queryi_values = array(':Registration' => $registration,':ident' => $icao); |
|
1293 | + $queryi_values = array(':Registration' => $registration, ':ident' => $icao); |
|
1294 | 1294 | } |
1295 | 1295 | try { |
1296 | 1296 | $sthi = $this->db->prepare($queryi); |
1297 | 1297 | $sthi->execute($queryi_values); |
1298 | - } catch(PDOException $e) { |
|
1298 | + } catch (PDOException $e) { |
|
1299 | 1299 | if ($globalDebug) echo $e->getMessage(); |
1300 | 1300 | return "error : ".$e->getMessage(); |
1301 | 1301 | } |
@@ -41,12 +41,12 @@ discard block |
||
41 | 41 | $currentdate = date('Y-m-d'); |
42 | 42 | $sourcestat = $Stats->getStatsSource($currentdate); |
43 | 43 | if (!empty($sourcestat)) { |
44 | - foreach($sourcestat as $srcst) { |
|
44 | + foreach ($sourcestat as $srcst) { |
|
45 | 45 | $type = $srcst['stats_type']; |
46 | 46 | if ($type == 'polar' || $type == 'hist') { |
47 | 47 | $source = $srcst['source_name']; |
48 | 48 | $data = $srcst['source_data']; |
49 | - $this->stats[$currentdate][$source][$type] = json_decode($data,true); |
|
49 | + $this->stats[$currentdate][$source][$type] = json_decode($data, true); |
|
50 | 50 | } |
51 | 51 | } |
52 | 52 | } |
@@ -58,14 +58,14 @@ discard block |
||
58 | 58 | if (isset($globalGeoid) && $globalGeoid) { |
59 | 59 | try { |
60 | 60 | $GeoidClass = new GeoidHeight(); |
61 | - } catch(Exception $e) { |
|
61 | + } catch (Exception $e) { |
|
62 | 62 | if ($globalDebug) echo "Can't calculate geoid, check that you downloaded it via update_db.php (".$e.")\n"; |
63 | 63 | $GeoidClass = FALSE; |
64 | 64 | } |
65 | 65 | } |
66 | 66 | } |
67 | 67 | |
68 | - public function get_Schedule($id,$ident) { |
|
68 | + public function get_Schedule($id, $ident) { |
|
69 | 69 | global $globalDebug, $globalFork, $globalSchedulesFetch; |
70 | 70 | // Get schedule here, so it's done only one time |
71 | 71 | |
@@ -90,8 +90,8 @@ discard block |
||
90 | 90 | $schedule = $Schedule->fetchSchedule($operator); |
91 | 91 | if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) { |
92 | 92 | if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
93 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime'])); |
|
94 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime'])); |
|
93 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $schedule['DepartureTime'])); |
|
94 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $schedule['ArrivalTime'])); |
|
95 | 95 | // Should also check if route schedule = route from DB |
96 | 96 | if ($schedule['DepartureAirportIATA'] != '') { |
97 | 97 | if ($this->all_flights[$id]['departure_airport'] != $Spotter->getAirportIcao($schedule['DepartureAirportIATA'])) { |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | } |
112 | 112 | } |
113 | 113 | } |
114 | - $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']); |
|
114 | + $Schedule->addSchedule($operator, $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['arrival_airport_time'], $schedule['Source']); |
|
115 | 115 | } |
116 | 116 | } else $scheduleexist = true; |
117 | 117 | } else $scheduleexist = true; |
@@ -119,8 +119,8 @@ discard block |
||
119 | 119 | if ($scheduleexist) { |
120 | 120 | if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n"; |
121 | 121 | $sch = $Schedule->getSchedule($operator); |
122 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport' => $sch['arrival_airport_icao'],'departure_airport' => $sch['departure_airport_icao'],'departure_airport_time' => $sch['departure_airport_time'],'arrival_airport_time' => $sch['arrival_airport_time'])); |
|
123 | - if ($this->all_flights[$id]['addedSpotter'] == 1) $Spotter->updateLatestScheduleSpotterData($this->all_flights[$id]['id'],$sch['departure_airport_icao'],$sch['departure_airport_time'],$sch['arrival_airport_icao'],$sch['arrival_airport_time']); |
|
122 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport' => $sch['arrival_airport_icao'], 'departure_airport' => $sch['departure_airport_icao'], 'departure_airport_time' => $sch['departure_airport_time'], 'arrival_airport_time' => $sch['arrival_airport_time'])); |
|
123 | + if ($this->all_flights[$id]['addedSpotter'] == 1) $Spotter->updateLatestScheduleSpotterData($this->all_flights[$id]['id'], $sch['departure_airport_icao'], $sch['departure_airport_time'], $sch['arrival_airport_icao'], $sch['arrival_airport_time']); |
|
124 | 124 | } |
125 | 125 | $Spotter->db = null; |
126 | 126 | $Schedule->db = null; |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].' '.$this->all_flights[$key]['longitude']."\n"; |
148 | 148 | $Spotter = new Spotter($this->db); |
149 | 149 | $real_arrival = $this->arrival($key); |
150 | - if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],'',$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
|
150 | + if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'], $this->all_flights[$key]['ident'], $this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $this->all_flights[$key]['altitude'], '', $this->all_flights[$key]['ground'], $this->all_flights[$key]['speed'], $this->all_flights[$key]['datetime'], $real_arrival['airport_icao'], $real_arrival['airport_time']); |
|
151 | 151 | } |
152 | 152 | } |
153 | 153 | } |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | $airport_time = ''; |
162 | 162 | if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50; |
163 | 163 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
164 | - $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist); |
|
164 | + $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $globalClosestMinDist); |
|
165 | 165 | if (isset($closestAirports[0])) { |
166 | 166 | if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) { |
167 | 167 | $airport_icao = $closestAirports[0]['icao']; |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | break; |
177 | 177 | } |
178 | 178 | } |
179 | - } elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude']+5000))) { |
|
179 | + } elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude'] + 5000))) { |
|
180 | 180 | $airport_icao = $closestAirports[0]['icao']; |
181 | 181 | $airport_time = $this->all_flights[$key]['datetime']; |
182 | 182 | } else { |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | } else { |
190 | 190 | if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
191 | 191 | } |
192 | - return array('airport_icao' => $airport_icao,'airport_time' => $airport_time); |
|
192 | + return array('airport_icao' => $airport_icao, 'airport_time' => $airport_time); |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | |
202 | 202 | foreach ($this->all_flights as $key => $flight) { |
203 | 203 | if (isset($flight['lastupdate'])) { |
204 | - if ($flight['lastupdate'] < (time()-1800)) { |
|
204 | + if ($flight['lastupdate'] < (time() - 1800)) { |
|
205 | 205 | $this->delKey($key); |
206 | 206 | } |
207 | 207 | } |
@@ -218,10 +218,10 @@ discard block |
||
218 | 218 | $Spotter = new Spotter($this->db); |
219 | 219 | $SpotterLive = new SpotterLive($this->db); |
220 | 220 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
221 | - $result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],'',$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
|
221 | + $result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'], $this->all_flights[$key]['ident'], $this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $this->all_flights[$key]['altitude'], '', $this->all_flights[$key]['ground'], $this->all_flights[$key]['speed'], $this->all_flights[$key]['datetime'], $real_arrival['airport_icao'], $real_arrival['airport_time']); |
|
222 | 222 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
223 | 223 | $this->all_flights[$key]['putinarchive'] = true; |
224 | - $result = $SpotterLive->addLiveSpotterData($this->all_flights[$key]['id'], $this->all_flights[$key]['ident'], $this->all_flights[$key]['aircraft_icao'], $this->all_flights[$key]['departure_airport'], $this->all_flights[$key]['arrival_airport'], $this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $this->all_flights[$key]['waypoints'], $this->all_flights[$key]['altitude'],$this->all_flights[$key]['altitude_real'], $this->all_flights[$key]['heading'], $this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'], $this->all_flights[$key]['departure_airport_time'], $this->all_flights[$key]['arrival_airport_time'], $this->all_flights[$key]['squawk'],$this->all_flights[$key]['route_stop'],$this->all_flights[$key]['hex'],$this->all_flights[$key]['putinarchive'],$this->all_flights[$key]['registration'],$this->all_flights[$key]['pilot_id'],$this->all_flights[$key]['pilot_name'], $this->all_flights[$key]['verticalrate'], $this->all_flights[$key]['noarchive'], $this->all_flights[$key]['ground'],$this->all_flights[$key]['format_source'],$this->all_flights[$key]['source_name'],$this->all_flights[$key]['over_country']); |
|
224 | + $result = $SpotterLive->addLiveSpotterData($this->all_flights[$key]['id'], $this->all_flights[$key]['ident'], $this->all_flights[$key]['aircraft_icao'], $this->all_flights[$key]['departure_airport'], $this->all_flights[$key]['arrival_airport'], $this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $this->all_flights[$key]['waypoints'], $this->all_flights[$key]['altitude'], $this->all_flights[$key]['altitude_real'], $this->all_flights[$key]['heading'], $this->all_flights[$key]['speed'], $this->all_flights[$key]['datetime'], $this->all_flights[$key]['departure_airport_time'], $this->all_flights[$key]['arrival_airport_time'], $this->all_flights[$key]['squawk'], $this->all_flights[$key]['route_stop'], $this->all_flights[$key]['hex'], $this->all_flights[$key]['putinarchive'], $this->all_flights[$key]['registration'], $this->all_flights[$key]['pilot_id'], $this->all_flights[$key]['pilot_name'], $this->all_flights[$key]['verticalrate'], $this->all_flights[$key]['noarchive'], $this->all_flights[$key]['ground'], $this->all_flights[$key]['format_source'], $this->all_flights[$key]['source_name'], $this->all_flights[$key]['over_country']); |
|
225 | 225 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
226 | 226 | } |
227 | 227 | $Spotter->db = null; |
@@ -257,10 +257,10 @@ discard block |
||
257 | 257 | $send = false; |
258 | 258 | |
259 | 259 | // SBS format is CSV format |
260 | - if(is_array($line) && (isset($line['hex']) || isset($line['id']))) { |
|
260 | + if (is_array($line) && (isset($line['hex']) || isset($line['id']))) { |
|
261 | 261 | //print_r($line); |
262 | 262 | if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']); |
263 | - if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && substr($line['hex'],0,1) != '~' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) { |
|
263 | + if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && substr($line['hex'], 0, 1) != '~' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) { |
|
264 | 264 | |
265 | 265 | // Increment message number |
266 | 266 | if (isset($line['sourcestats']) && $line['sourcestats'] === TRUE) { |
@@ -293,25 +293,25 @@ discard block |
||
293 | 293 | if (!isset($this->all_flights[$id])) { |
294 | 294 | if ($globalDebug) echo 'New flight...'."\n"; |
295 | 295 | $this->all_flights[$id] = array(); |
296 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
297 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '','altitude_previous' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => '','coordinates' => 0)); |
|
298 | - if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
296 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0)); |
|
297 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => '', 'departure_airport' => '', 'arrival_airport' => '', 'latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'altitude_real' => '', 'altitude_previous' => '', 'heading' => '', 'departure_airport_time' => '', 'arrival_airport_time' => '', 'squawk' => '', 'route_stop' => '', 'registration' => '', 'pilot_id' => '', 'pilot_name' => '', 'waypoints' => '', 'ground' => '0', 'format_source' => '', 'source_name' => '', 'over_country' => '', 'verticalrate' => '', 'noarchive' => false, 'putinarchive' => true, 'source_type' => '', 'coordinates' => 0)); |
|
298 | + if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('lastupdate' => time())); |
|
299 | 299 | if (!isset($line['id'])) { |
300 | 300 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
301 | 301 | // if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi'))); |
302 | 302 | // if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
303 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
303 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi'))); |
|
304 | 304 | //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
305 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
305 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id'])); |
|
306 | 306 | if ($globalAllFlights !== FALSE) $dataFound = true; |
307 | 307 | } |
308 | 308 | if (isset($line['source_type']) && $line['source_type'] != '') { |
309 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type'])); |
|
309 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('source_type' => $line['source_type'])); |
|
310 | 310 | } |
311 | 311 | |
312 | 312 | //print_r($this->all_flights); |
313 | 313 | if (isset($line['hex']) && !isset($this->all_flights[$id]['hex']) && ctype_xdigit($line['hex'])) { |
314 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex']))); |
|
314 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('hex' => trim($line['hex']))); |
|
315 | 315 | //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
316 | 316 | //$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
317 | 317 | //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
@@ -320,20 +320,20 @@ discard block |
||
320 | 320 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
321 | 321 | $Spotter = new Spotter($this->db); |
322 | 322 | if (isset($this->all_flights[$id]['source_type'])) { |
323 | - $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']),$this->all_flights[$id]['source_type']); |
|
323 | + $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']), $this->all_flights[$id]['source_type']); |
|
324 | 324 | } else { |
325 | 325 | $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex'])); |
326 | 326 | } |
327 | 327 | $Spotter->db = null; |
328 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
329 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
328 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
329 | + if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao)); |
|
330 | 330 | } |
331 | 331 | } |
332 | 332 | if ($globalAllFlights !== FALSE) $dataFound = true; |
333 | 333 | if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n"; |
334 | 334 | } |
335 | 335 | if (isset($line['id']) && !isset($line['hex'])) { |
336 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => '')); |
|
336 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('hex' => '')); |
|
337 | 337 | } |
338 | 338 | if (isset($line['aircraft_icao']) && $line['aircraft_icao'] != '') { |
339 | 339 | $icao = $line['aircraft_icao']; |
@@ -342,14 +342,14 @@ discard block |
||
342 | 342 | if (isset($Spotter->aircraft_correct_icaotype[$icao])) $icao = $Spotter->aircraft_correct_icaotype[$icao]; |
343 | 343 | $Spotter->db = null; |
344 | 344 | } |
345 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $icao)); |
|
345 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $icao)); |
|
346 | 346 | } elseif (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_name'])) { |
347 | 347 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
348 | 348 | // Get aircraft ICAO from aircraft name |
349 | 349 | $Spotter = new Spotter($this->db); |
350 | 350 | $aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']); |
351 | 351 | $Spotter->db = null; |
352 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
352 | + if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao)); |
|
353 | 353 | } |
354 | 354 | } |
355 | 355 | if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_type'])) { |
@@ -357,15 +357,15 @@ discard block |
||
357 | 357 | elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL'; |
358 | 358 | elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE'; |
359 | 359 | elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC'; |
360 | - if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
360 | + if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao)); |
|
361 | 361 | } |
362 | 362 | if (!isset($this->all_flights[$id]['aircraft_icao'])) { |
363 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA')); |
|
363 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => 'NA')); |
|
364 | 364 | } |
365 | 365 | //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
366 | - if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) { |
|
366 | + if (isset($line['datetime']) && strtotime($line['datetime']) > time() - 20*60 && strtotime($line['datetime']) < time() + 20*60) { |
|
367 | 367 | if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
368 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
|
368 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => $line['datetime'])); |
|
369 | 369 | } else { |
370 | 370 | if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
371 | 371 | elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
@@ -376,31 +376,31 @@ discard block |
||
376 | 376 | */ |
377 | 377 | return ''; |
378 | 378 | } |
379 | - } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) { |
|
379 | + } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time() - 20*60) { |
|
380 | 380 | if ($globalDebug) echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n"; |
381 | 381 | return ''; |
382 | - } elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) { |
|
382 | + } elseif (isset($line['datetime']) && strtotime($line['datetime']) > time() + 20*60) { |
|
383 | 383 | if ($globalDebug) echo "!!! Date is in the future ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n"; |
384 | 384 | return ''; |
385 | 385 | } elseif (!isset($line['datetime'])) { |
386 | 386 | date_default_timezone_set('UTC'); |
387 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
387 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => date('Y-m-d H:i:s'))); |
|
388 | 388 | } else { |
389 | 389 | if ($globalDebug) echo "!!! Unknow date error ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!"; |
390 | 390 | return ''; |
391 | 391 | } |
392 | 392 | |
393 | 393 | if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG' && $line['registration'] != 'NA') { |
394 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration'])); |
|
394 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('registration' => $line['registration'])); |
|
395 | 395 | } |
396 | 396 | if (isset($line['waypoints']) && $line['waypoints'] != '') { |
397 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints'])); |
|
397 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('waypoints' => $line['waypoints'])); |
|
398 | 398 | } |
399 | 399 | if (isset($line['pilot_id']) && $line['pilot_id'] != '') { |
400 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => trim($line['pilot_id']))); |
|
400 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_id' => trim($line['pilot_id']))); |
|
401 | 401 | } |
402 | 402 | if (isset($line['pilot_name']) && $line['pilot_name'] != '') { |
403 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => trim($line['pilot_name']))); |
|
403 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_name' => trim($line['pilot_name']))); |
|
404 | 404 | } |
405 | 405 | |
406 | 406 | if (isset($line['ident']) && trim($line['ident']) != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_flights[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9]+$/', $line['ident'])) { |
@@ -408,13 +408,13 @@ discard block |
||
408 | 408 | if ($this->all_flights[$id]['addedSpotter'] == 1) { |
409 | 409 | if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE && $this->all_flights[$id]['lastupdate'] < time() - 800) { |
410 | 410 | if ($globalDebug) echo '---!!!! New ident, reset aircraft data...'."\n"; |
411 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
412 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
|
413 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
414 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
415 | - elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
411 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0)); |
|
412 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1)); |
|
413 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi'))); |
|
414 | + elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id'])); |
|
415 | + elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
416 | 416 | } else { |
417 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
417 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => trim($line['ident']))); |
|
418 | 418 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
419 | 419 | $timeelapsed = microtime(true); |
420 | 420 | $Spotter = new Spotter($this->db); |
@@ -424,13 +424,13 @@ discard block |
||
424 | 424 | elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao'; |
425 | 425 | elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
426 | 426 | elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
427 | - $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource,$this->all_flights[$id]['source_type']); |
|
427 | + $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $fromsource, $this->all_flights[$id]['source_type']); |
|
428 | 428 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
429 | 429 | $Spotter->db = null; |
430 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
430 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
431 | 431 | } |
432 | 432 | } |
433 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
433 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => trim($line['ident']))); |
|
434 | 434 | |
435 | 435 | /* |
436 | 436 | if (!isset($line['id'])) { |
@@ -440,25 +440,25 @@ discard block |
||
440 | 440 | else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
441 | 441 | } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
442 | 442 | */ |
443 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
443 | + if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
444 | 444 | |
445 | 445 | //$putinarchive = true; |
446 | 446 | if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
447 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $line['departure_airport_time'])); |
|
447 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $line['departure_airport_time'])); |
|
448 | 448 | } |
449 | 449 | if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) { |
450 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $line['arrival_airport_time'])); |
|
450 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $line['arrival_airport_time'])); |
|
451 | 451 | } |
452 | 452 | if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) { |
453 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
|
453 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport' => $line['departure_airport_icao'], 'arrival_airport' => $line['arrival_airport_icao'], 'route_stop' => '')); |
|
454 | 454 | } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) { |
455 | 455 | $timeelapsed = microtime(true); |
456 | 456 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
457 | 457 | $Spotter = new Spotter($this->db); |
458 | 458 | $line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']); |
459 | 459 | $line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']); |
460 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
|
461 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
460 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport' => $line['departure_airport_icao'], 'arrival_airport' => $line['arrival_airport_icao'], 'route_stop' => '')); |
|
461 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
462 | 462 | } |
463 | 463 | } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
464 | 464 | $timeelapsed = microtime(true); |
@@ -472,35 +472,35 @@ discard block |
||
472 | 472 | $Translation->db = null; |
473 | 473 | } |
474 | 474 | $Spotter->db = null; |
475 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
475 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
476 | 476 | } |
477 | 477 | if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) { |
478 | 478 | //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
479 | 479 | if ($route['fromairport_icao'] != $route['toairport_icao']) { |
480 | 480 | // $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['FromAirport_ICAO'],'arrival_airport' => $route['ToAirport_ICAO'],'route_stop' => $route['RouteStop'])); |
481 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop'])); |
|
481 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport' => $route['fromairport_icao'], 'arrival_airport' => $route['toairport_icao'], 'route_stop' => $route['routestop'])); |
|
482 | 482 | } |
483 | 483 | } |
484 | 484 | if (!isset($globalFork)) $globalFork = TRUE; |
485 | 485 | if (!$globalVA && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) { |
486 | - if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident'])); |
|
486 | + if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id, trim($line['ident'])); |
|
487 | 487 | } |
488 | 488 | } |
489 | 489 | } |
490 | 490 | |
491 | 491 | if (isset($line['speed']) && $line['speed'] != '' && $line['speed'] != 0) { |
492 | 492 | // $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => $line[12])); |
493 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed']))); |
|
494 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true)); |
|
493 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($line['speed']))); |
|
494 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed_fromsrc' => true)); |
|
495 | 495 | //$dataFound = true; |
496 | 496 | } else if (!isset($this->all_flights[$id]['speed_fromsrc']) && isset($this->all_flights[$id]['time_last_coord']) && $this->all_flights[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) { |
497 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'); |
|
497 | + $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm'); |
|
498 | 498 | if ($distance > 1000 && $distance < 10000) { |
499 | 499 | // use datetime |
500 | 500 | $speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']); |
501 | 501 | $speed = $speed*3.6; |
502 | 502 | if ($speed < 1000) { |
503 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed))); |
|
503 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($speed))); |
|
504 | 504 | if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
505 | 505 | } else { |
506 | 506 | if ($globalDebug) echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
@@ -515,9 +515,9 @@ discard block |
||
515 | 515 | if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n"; |
516 | 516 | return false; |
517 | 517 | } |
518 | - if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
518 | + if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time() - $this->all_flights[$id]['time_last_coord']); |
|
519 | 519 | else unset($timediff); |
520 | - if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']); |
|
520 | + if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time() - $this->all_flights[$id]['time_last_archive_coord']); |
|
521 | 521 | else unset($timediff_archive); |
522 | 522 | if ($this->tmd > 5 |
523 | 523 | || (isset($line['format_source']) |
@@ -542,7 +542,7 @@ discard block |
||
542 | 542 | || (isset($timediff) && $timediff > 30 |
543 | 543 | && isset($this->all_flights[$id]['latitude']) |
544 | 544 | && isset($this->all_flights[$id]['longitude']) |
545 | - && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')) |
|
545 | + && $Common->withinThreshold($timediff, $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')) |
|
546 | 546 | ) |
547 | 547 | ) { |
548 | 548 | |
@@ -554,7 +554,7 @@ discard block |
||
554 | 554 | && isset($this->all_flights[$id]['archive_longitude']) |
555 | 555 | && isset($this->all_flights[$id]['livedb_latitude']) |
556 | 556 | && isset($this->all_flights[$id]['livedb_longitude'])) |
557 | - && !$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude']) |
|
557 | + && !$Common->checkLine($this->all_flights[$id]['archive_latitude'], $this->all_flights[$id]['archive_longitude'], $this->all_flights[$id]['livedb_latitude'], $this->all_flights[$id]['livedb_longitude'], $line['latitude'], $line['longitude']) |
|
558 | 558 | ) |
559 | 559 | ) { |
560 | 560 | $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
@@ -570,11 +570,11 @@ discard block |
||
570 | 570 | $timeelapsed = microtime(true); |
571 | 571 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
572 | 572 | $Spotter = new Spotter($this->db); |
573 | - $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
573 | + $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']); |
|
574 | 574 | if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
575 | 575 | else $this->all_flights[$id]['over_country'] = ''; |
576 | 576 | $Spotter->db = null; |
577 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
577 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
578 | 578 | if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
579 | 579 | } |
580 | 580 | } |
@@ -600,13 +600,13 @@ discard block |
||
600 | 600 | $this->all_flights[$id]['time_last_coord'] = time(); |
601 | 601 | } |
602 | 602 | //if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs' || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > 0.0001)) { |
603 | - if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > 0.0001)) { |
|
603 | + if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude'] - $line['latitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude'] - $line['latitude']) > 0.0001)) { |
|
604 | 604 | $this->all_flights[$id]['livedb_latitude'] = $line['latitude']; |
605 | 605 | $dataFound = true; |
606 | 606 | $this->all_flights[$id]['time_last_coord'] = time(); |
607 | 607 | } |
608 | 608 | // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
609 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('latitude' => $line['latitude'])); |
|
609 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('latitude' => $line['latitude'])); |
|
610 | 610 | /* |
611 | 611 | if (abs($this->all_flights[$id]['archive_latitude']-$this->all_flights[$id]['latitude']) > 0.3) { |
612 | 612 | $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
@@ -628,14 +628,14 @@ discard block |
||
628 | 628 | $this->all_flights[$id]['time_last_coord'] = time(); |
629 | 629 | } |
630 | 630 | //if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs' || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > 0.0001)) { |
631 | - if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > 0.0001)) { |
|
631 | + if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude'] - $line['longitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude'] - $line['longitude']) > 0.0001)) { |
|
632 | 632 | $this->all_flights[$id]['livedb_longitude'] = $line['longitude']; |
633 | 633 | $dataFound = true; |
634 | 634 | $this->all_flights[$id]['coordinates'] += 1; |
635 | 635 | $this->all_flights[$id]['time_last_coord'] = time(); |
636 | 636 | } |
637 | 637 | // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
638 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('longitude' => $line['longitude'])); |
|
638 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('longitude' => $line['longitude'])); |
|
639 | 639 | /* |
640 | 640 | if (abs($this->all_flights[$id]['archive_longitude']-$this->all_flights[$id]['longitude']) > 0.3) { |
641 | 641 | $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
@@ -656,52 +656,52 @@ discard block |
||
656 | 656 | $SpotterArchive->deleteSpotterArchiveTrackDataByID($this->all_flights[$id]['id']); |
657 | 657 | $SpotterArchive->db = null; |
658 | 658 | $Spotter = new Spotter(); |
659 | - $Spotter->updateInitialSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime']); |
|
659 | + $Spotter->updateInitialSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime']); |
|
660 | 660 | $Spotter->db = null; |
661 | 661 | } |
662 | 662 | } else if ($globalDebug && $timediff > 30) { |
663 | 663 | $this->tmd = $this->tmd + 1; |
664 | 664 | echo '!!! Too much distance in short time... for '.$this->all_flights[$id]['ident']."\n"; |
665 | - echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')."m -"; |
|
666 | - echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
|
665 | + echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')."m -"; |
|
666 | + echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - "; |
|
667 | 667 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_flights[$id]['latitude'].' - prev long : '.$this->all_flights[$id]['longitude']." \n"; |
668 | 668 | } |
669 | 669 | } |
670 | 670 | if (isset($line['last_update']) && $line['last_update'] != '') { |
671 | 671 | if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true; |
672 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update'])); |
|
672 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('last_update' => $line['last_update'])); |
|
673 | 673 | } |
674 | 674 | if (isset($line['verticalrate']) && $line['verticalrate'] != '') { |
675 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate'])); |
|
675 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('verticalrate' => $line['verticalrate'])); |
|
676 | 676 | //$dataFound = true; |
677 | 677 | } |
678 | 678 | if (isset($line['format_source']) && $line['format_source'] != '') { |
679 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source'])); |
|
679 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('format_source' => $line['format_source'])); |
|
680 | 680 | } |
681 | 681 | if (isset($line['source_name']) && $line['source_name'] != '') { |
682 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name'])); |
|
682 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('source_name' => $line['source_name'])); |
|
683 | 683 | } |
684 | 684 | if (isset($line['emergency']) && $line['emergency'] != '') { |
685 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency'])); |
|
685 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('emergency' => $line['emergency'])); |
|
686 | 686 | //$dataFound = true; |
687 | 687 | } |
688 | 688 | if (isset($line['ground']) && $line['ground'] != '') { |
689 | 689 | if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) { |
690 | 690 | // Here we force archive of flight because after ground it's a new one (or should be) |
691 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
692 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
|
693 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
694 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
695 | - elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
691 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0)); |
|
692 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1)); |
|
693 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi'))); |
|
694 | + elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id'])); |
|
695 | + elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
696 | 696 | } |
697 | 697 | if ($line['ground'] != 1) $line['ground'] = 0; |
698 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
|
698 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ground' => $line['ground'])); |
|
699 | 699 | //$dataFound = true; |
700 | 700 | } |
701 | 701 | if (isset($line['squawk']) && $line['squawk'] != '') { |
702 | 702 | if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) { |
703 | 703 | if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true; |
704 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
704 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk'])); |
|
705 | 705 | $highlight = ''; |
706 | 706 | if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
707 | 707 | if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
@@ -710,66 +710,66 @@ discard block |
||
710 | 710 | $timeelapsed = microtime(true); |
711 | 711 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
712 | 712 | $Spotter = new Spotter($this->db); |
713 | - $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight); |
|
713 | + $Spotter->setHighlightFlight($this->all_flights[$id]['id'], $highlight); |
|
714 | 714 | $Spotter->db = null; |
715 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
715 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
716 | 716 | } |
717 | 717 | //$putinarchive = true; |
718 | 718 | //$highlight = ''; |
719 | 719 | } |
720 | 720 | |
721 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
721 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk'])); |
|
722 | 722 | //$dataFound = true; |
723 | 723 | } |
724 | 724 | |
725 | 725 | if (isset($line['altitude']) && $line['altitude'] != '' && is_numeric($line['altitude'])) { |
726 | 726 | if (isset($line['altitude_relative']) && isset($GeoidClass) && is_object($GeoidClass)) { |
727 | 727 | if ($line['altitude_relative'] == 'AMSL' || $line['altitude_relative'] == 'MSL') { |
728 | - $geoid = round($GeoidClass->get($this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'])*3.28084,2); |
|
728 | + $geoid = round($GeoidClass->get($this->all_flights[$id]['livedb_latitude'], $this->all_flights[$id]['livedb_longitude'])*3.28084, 2); |
|
729 | 729 | //if ($globalDebug) echo '=> Set altitude to WGS84 Ellipsoid, add '.$geoid.' to '.$line['altitude']."\n"; |
730 | 730 | $line['altitude'] = $line['altitude'] - $geoid; |
731 | 731 | } |
732 | 732 | } |
733 | 733 | //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
734 | - if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true; |
|
735 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100))); |
|
736 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude'])); |
|
734 | + if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100) - $this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true; |
|
735 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude' => round($line['altitude']/100))); |
|
736 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude_real' => $line['altitude'])); |
|
737 | 737 | //$dataFound = true; |
738 | 738 | //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
739 | 739 | if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) { |
740 | 740 | if (isset($this->all_flights[$id]['over_country']) && $this->all_flights[$id]['over_country'] != '' && isset($this->all_flights[$id]['altitude_previous']) && $this->all_flights[$id]['altitude_previous'] != '' && $this->all_flights[$id]['altitude_previous'] < $this->all_flights[$id]['altitude_real'] && isset($this->all_flights[$id]['lastupdate']) && $this->all_flights[$id]['lastupdate'] < time() - 1600) { |
741 | 741 | if ($globalDebug) echo '--- Reset because of altitude'."\n"; |
742 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
743 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
|
744 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
745 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
746 | - elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
742 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0)); |
|
743 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1)); |
|
744 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi'))); |
|
745 | + elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id'])); |
|
746 | + elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
747 | 747 | } |
748 | 748 | } |
749 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude'])); |
|
749 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude_previous' => $line['altitude'])); |
|
750 | 750 | } |
751 | 751 | |
752 | 752 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
753 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true)); |
|
753 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('noarchive' => true)); |
|
754 | 754 | } |
755 | 755 | |
756 | 756 | if (isset($line['heading']) && $line['heading'] != '') { |
757 | - if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
758 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
|
759 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
|
757 | + if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading'] - round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
758 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($line['heading']))); |
|
759 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading_fromsrc' => true)); |
|
760 | 760 | //$dataFound = true; |
761 | 761 | } elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) { |
762 | - $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
763 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
|
764 | - if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
762 | + $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'], $this->all_flights[$id]['archive_longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']); |
|
763 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($heading))); |
|
764 | + if (abs($this->all_flights[$id]['heading'] - round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
765 | 765 | if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
766 | 766 | } elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') { |
767 | 767 | // If not enough messages and ACARS set heading to 0 |
768 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
|
768 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => 0)); |
|
769 | 769 | } |
770 | - if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
|
771 | - elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
|
772 | - elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalAircraftMinUpdate) $dataFound = false; |
|
770 | + if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
|
771 | + elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
|
772 | + elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalAircraftMinUpdate) $dataFound = false; |
|
773 | 773 | |
774 | 774 | // print_r($this->all_flights[$id]); |
775 | 775 | //gets the callsign from the last hour |
@@ -780,7 +780,7 @@ discard block |
||
780 | 780 | if ($dataFound === true && isset($this->all_flights[$id]['id'])) { |
781 | 781 | $this->all_flights[$id]['lastupdate'] = time(); |
782 | 782 | if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) { |
783 | - if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == '' || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
783 | + if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == '' || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
784 | 784 | //print_r($this->all_flights); |
785 | 785 | //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n"; |
786 | 786 | //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
@@ -791,61 +791,61 @@ discard block |
||
791 | 791 | $SpotterLive = new SpotterLive($this->db); |
792 | 792 | if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) { |
793 | 793 | $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']); |
794 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
794 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
795 | 795 | } elseif (isset($line['id'])) { |
796 | 796 | $recent_ident = $SpotterLive->checkIdRecent($line['id']); |
797 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
797 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
798 | 798 | } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') { |
799 | 799 | $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']); |
800 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
800 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
801 | 801 | } else $recent_ident = ''; |
802 | - $SpotterLive->db=null; |
|
802 | + $SpotterLive->db = null; |
|
803 | 803 | if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
804 | 804 | elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
805 | 805 | } else $recent_ident = ''; |
806 | 806 | } else { |
807 | 807 | $recent_ident = ''; |
808 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0)); |
|
808 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 0)); |
|
809 | 809 | } |
810 | 810 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
811 | - if($recent_ident == "") |
|
811 | + if ($recent_ident == "") |
|
812 | 812 | { |
813 | 813 | if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
814 | 814 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
815 | 815 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
816 | 816 | //adds the spotter data for the archive |
817 | 817 | $ignoreImport = false; |
818 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
818 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
819 | 819 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
820 | 820 | $ignoreImport = true; |
821 | 821 | } |
822 | 822 | } |
823 | 823 | if (count($globalAirportAccept) > 0) { |
824 | 824 | $ignoreImport = true; |
825 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
825 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
826 | 826 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
827 | 827 | $ignoreImport = false; |
828 | 828 | } |
829 | 829 | } |
830 | 830 | } |
831 | 831 | if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
832 | - foreach($globalAirlineIgnore as $airlineIgnore) { |
|
833 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) { |
|
832 | + foreach ($globalAirlineIgnore as $airlineIgnore) { |
|
833 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineIgnore)) { |
|
834 | 834 | $ignoreImport = true; |
835 | 835 | } |
836 | 836 | } |
837 | 837 | } |
838 | 838 | if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
839 | 839 | $ignoreImport = true; |
840 | - foreach($globalAirlineAccept as $airlineAccept) { |
|
841 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) { |
|
840 | + foreach ($globalAirlineAccept as $airlineAccept) { |
|
841 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineAccept)) { |
|
842 | 842 | $ignoreImport = false; |
843 | 843 | } |
844 | 844 | } |
845 | 845 | } |
846 | 846 | if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
847 | 847 | $ignoreImport = true; |
848 | - foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
848 | + foreach ($globalPilotIdAccept as $pilotIdAccept) { |
|
849 | 849 | if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
850 | 850 | $ignoreImport = false; |
851 | 851 | } |
@@ -857,12 +857,12 @@ discard block |
||
857 | 857 | if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
858 | 858 | if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
859 | 859 | if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
860 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
860 | + if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
861 | 861 | $timeelapsed = microtime(true); |
862 | 862 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
863 | 863 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
864 | 864 | $Spotter = new Spotter($this->db); |
865 | - $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['source_type']); |
|
865 | + $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'], $this->all_flights[$id]['route_stop'], $highlight, $this->all_flights[$id]['hex'], $this->all_flights[$id]['registration'], $this->all_flights[$id]['pilot_id'], $this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['format_source'], $this->all_flights[$id]['source_name'], $this->all_flights[$id]['source_type']); |
|
866 | 866 | $Spotter->db = null; |
867 | 867 | if ($globalDebug) { |
868 | 868 | if (isset($result['error'])) echo 'Error: '.$result['error']."\n"; |
@@ -875,22 +875,22 @@ discard block |
||
875 | 875 | } |
876 | 876 | } |
877 | 877 | } |
878 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
878 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
879 | 879 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
880 | 880 | |
881 | 881 | // Add source stat in DB |
882 | 882 | $Stats = new Stats($this->db); |
883 | 883 | if (!empty($this->stats)) { |
884 | 884 | if ($globalDebug) echo 'Add source stats : '; |
885 | - foreach($this->stats as $date => $data) { |
|
886 | - foreach($data as $source => $sourced) { |
|
885 | + foreach ($this->stats as $date => $data) { |
|
886 | + foreach ($data as $source => $sourced) { |
|
887 | 887 | //print_r($sourced); |
888 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
889 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
888 | + if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']), $source, 'polar', $date); |
|
889 | + if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']), $source, 'hist', $date); |
|
890 | 890 | if (isset($sourced['msg'])) { |
891 | 891 | if (time() - $sourced['msg']['date'] > 10) { |
892 | 892 | $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
893 | - echo $Stats->addStatSource($nbmsg,$source,'msg',$date); |
|
893 | + echo $Stats->addStatSource($nbmsg, $source, 'msg', $date); |
|
894 | 894 | unset($this->stats[$date][$source]['msg']); |
895 | 895 | } |
896 | 896 | } |
@@ -928,14 +928,14 @@ discard block |
||
928 | 928 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
929 | 929 | $SpotterLive = new SpotterLive($this->db); |
930 | 930 | $SpotterLive->deleteLiveSpotterData(); |
931 | - $SpotterLive->db=null; |
|
931 | + $SpotterLive->db = null; |
|
932 | 932 | } |
933 | 933 | } |
934 | 934 | if ($globalDebug) echo " Done\n"; |
935 | 935 | $this->last_delete = time(); |
936 | 936 | } |
937 | 937 | } else { |
938 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt'|| $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'famaprs' || $line['format_source'] === 'airwhere')) { |
|
938 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'famaprs' || $line['format_source'] === 'airwhere')) { |
|
939 | 939 | $this->all_flights[$id]['id'] = $recent_ident; |
940 | 940 | $this->all_flights[$id]['addedSpotter'] = 1; |
941 | 941 | } |
@@ -943,7 +943,7 @@ discard block |
||
943 | 943 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
944 | 944 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
945 | 945 | $Spotter = new Spotter($this->db); |
946 | - $Spotter->updateLatestSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time']); |
|
946 | + $Spotter->updateLatestSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['arrival_airport_time']); |
|
947 | 947 | $Spotter->db = null; |
948 | 948 | } |
949 | 949 | } |
@@ -969,37 +969,37 @@ discard block |
||
969 | 969 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
970 | 970 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
971 | 971 | |
972 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
972 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
973 | 973 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
974 | 974 | $ignoreImport = true; |
975 | 975 | } |
976 | 976 | } |
977 | 977 | if (count($globalAirportAccept) > 0) { |
978 | 978 | $ignoreImport = true; |
979 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
979 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
980 | 980 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
981 | 981 | $ignoreImport = false; |
982 | 982 | } |
983 | 983 | } |
984 | 984 | } |
985 | 985 | if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
986 | - foreach($globalAirlineIgnore as $airlineIgnore) { |
|
987 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) { |
|
986 | + foreach ($globalAirlineIgnore as $airlineIgnore) { |
|
987 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineIgnore)) { |
|
988 | 988 | $ignoreImport = true; |
989 | 989 | } |
990 | 990 | } |
991 | 991 | } |
992 | 992 | if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
993 | 993 | $ignoreImport = true; |
994 | - foreach($globalAirlineAccept as $airlineAccept) { |
|
995 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) { |
|
994 | + foreach ($globalAirlineAccept as $airlineAccept) { |
|
995 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineAccept)) { |
|
996 | 996 | $ignoreImport = false; |
997 | 997 | } |
998 | 998 | } |
999 | 999 | } |
1000 | 1000 | if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
1001 | 1001 | $ignoreImport = true; |
1002 | - foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
1002 | + foreach ($globalPilotIdAccept as $pilotIdAccept) { |
|
1003 | 1003 | if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
1004 | 1004 | $ignoreImport = false; |
1005 | 1005 | } |
@@ -1007,24 +1007,24 @@ discard block |
||
1007 | 1007 | } |
1008 | 1008 | |
1009 | 1009 | if (!$ignoreImport) { |
1010 | - if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
1011 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
1010 | + if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
1011 | + if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
1012 | 1012 | $timeelapsed = microtime(true); |
1013 | 1013 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
1014 | 1014 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
1015 | 1015 | if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
1016 | 1016 | $SpotterLive = new SpotterLive($this->db); |
1017 | 1017 | //var_dump($this->all_flights[$id]); |
1018 | - $result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']); |
|
1018 | + $result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'], $this->all_flights[$id]['route_stop'], $this->all_flights[$id]['hex'], $this->all_flights[$id]['putinarchive'], $this->all_flights[$id]['registration'], $this->all_flights[$id]['pilot_id'], $this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['format_source'], $this->all_flights[$id]['source_name'], $this->all_flights[$id]['over_country']); |
|
1019 | 1019 | $SpotterLive->db = null; |
1020 | 1020 | if ($globalDebug) echo $result."\n"; |
1021 | 1021 | } |
1022 | 1022 | } |
1023 | 1023 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) { |
1024 | - $APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']); |
|
1024 | + $APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'], $this->all_flights[$id]['route_stop'], $this->all_flights[$id]['hex'], $this->all_flights[$id]['putinarchive'], $this->all_flights[$id]['registration'], $this->all_flights[$id]['pilot_id'], $this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['format_source'], $this->all_flights[$id]['source_name'], $this->all_flights[$id]['over_country']); |
|
1025 | 1025 | } |
1026 | 1026 | $this->all_flights[$id]['putinarchive'] = false; |
1027 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
1027 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
1028 | 1028 | |
1029 | 1029 | // Put statistics in $this->stats variable |
1030 | 1030 | //if ($line['format_source'] != 'aprs') { |
@@ -1043,19 +1043,19 @@ discard block |
||
1043 | 1043 | $latitude = $globalCenterLatitude; |
1044 | 1044 | $longitude = $globalCenterLongitude; |
1045 | 1045 | } |
1046 | - $this->source_location[$source] = array('latitude' => $latitude,'longitude' => $longitude); |
|
1046 | + $this->source_location[$source] = array('latitude' => $latitude, 'longitude' => $longitude); |
|
1047 | 1047 | } else { |
1048 | 1048 | $latitude = $this->source_location[$source]['latitude']; |
1049 | 1049 | $longitude = $this->source_location[$source]['longitude']; |
1050 | 1050 | } |
1051 | - $stats_heading = $Common->getHeading($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
1051 | + $stats_heading = $Common->getHeading($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']); |
|
1052 | 1052 | //$stats_heading = $stats_heading%22.5; |
1053 | 1053 | $stats_heading = round($stats_heading/22.5); |
1054 | - $stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
1054 | + $stats_distance = $Common->distance($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']); |
|
1055 | 1055 | $current_date = date('Y-m-d'); |
1056 | 1056 | if ($stats_heading == 16) $stats_heading = 0; |
1057 | 1057 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
1058 | - for ($i=0;$i<=15;$i++) { |
|
1058 | + for ($i = 0; $i <= 15; $i++) { |
|
1059 | 1059 | $this->stats[$current_date][$source]['polar'][$i] = 0; |
1060 | 1060 | } |
1061 | 1061 | $this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance; |
@@ -1070,9 +1070,9 @@ discard block |
||
1070 | 1070 | if (!isset($this->stats[$current_date][$source]['hist'][$distance])) { |
1071 | 1071 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
1072 | 1072 | end($this->stats[$current_date][$source]['hist']); |
1073 | - $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
1073 | + $mini = key($this->stats[$current_date][$source]['hist']) + 10; |
|
1074 | 1074 | } else $mini = 0; |
1075 | - for ($i=$mini;$i<=$distance;$i+=10) { |
|
1075 | + for ($i = $mini; $i <= $distance; $i += 10) { |
|
1076 | 1076 | $this->stats[$current_date][$source]['hist'][$i] = 0; |
1077 | 1077 | } |
1078 | 1078 | $this->stats[$current_date][$source]['hist'][$distance] = 1; |
@@ -1085,7 +1085,7 @@ discard block |
||
1085 | 1085 | $this->all_flights[$id]['lastupdate'] = time(); |
1086 | 1086 | if ($this->all_flights[$id]['putinarchive']) $send = true; |
1087 | 1087 | //if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
1088 | - } elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
1088 | + } elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude'])."\n"; |
|
1089 | 1089 | //$this->del(); |
1090 | 1090 | |
1091 | 1091 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | $ch = curl_init(); |
27 | 27 | curl_setopt($ch, CURLOPT_URL, $url); |
28 | 28 | if (isset($globalForceIPv4) && $globalForceIPv4) { |
29 | - if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')){ |
|
29 | + if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')) { |
|
30 | 30 | curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); |
31 | 31 | } |
32 | 32 | } |
@@ -44,20 +44,20 @@ discard block |
||
44 | 44 | fclose($fp); |
45 | 45 | } |
46 | 46 | |
47 | - public static function gunzip($in_file,$out_file_name = '') { |
|
47 | + public static function gunzip($in_file, $out_file_name = '') { |
|
48 | 48 | //echo $in_file.' -> '.$out_file_name."\n"; |
49 | 49 | $buffer_size = 4096; // read 4kb at a time |
50 | 50 | if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); |
51 | 51 | if ($in_file != '' && file_exists($in_file)) { |
52 | 52 | // PHP version of Ubuntu use gzopen64 instead of gzopen |
53 | - if (function_exists('gzopen')) $file = gzopen($in_file,'rb'); |
|
54 | - elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb'); |
|
53 | + if (function_exists('gzopen')) $file = gzopen($in_file, 'rb'); |
|
54 | + elseif (function_exists('gzopen64')) $file = gzopen64($in_file, 'rb'); |
|
55 | 55 | else { |
56 | 56 | echo 'gzopen not available'; |
57 | 57 | die; |
58 | 58 | } |
59 | 59 | $out_file = fopen($out_file_name, 'wb'); |
60 | - while(!gzeof($file)) { |
|
60 | + while (!gzeof($file)) { |
|
61 | 61 | fwrite($out_file, gzread($file, $buffer_size)); |
62 | 62 | } |
63 | 63 | fclose($out_file); |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | try { |
82 | 82 | self::$db_sqlite = new PDO('sqlite:'.$database); |
83 | 83 | self::$db_sqlite->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
84 | - } catch(PDOException $e) { |
|
84 | + } catch (PDOException $e) { |
|
85 | 85 | return "error : ".$e->getMessage(); |
86 | 86 | } |
87 | 87 | } |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | //$Connection = new Connection(); |
97 | 97 | $sth = $Connection->db->prepare($query); |
98 | 98 | $sth->execute(array(':source' => $database_file)); |
99 | - } catch(PDOException $e) { |
|
99 | + } catch (PDOException $e) { |
|
100 | 100 | return "error : ".$e->getMessage(); |
101 | 101 | } |
102 | 102 | |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | try { |
108 | 108 | $sth = update_db::$db_sqlite->prepare($query); |
109 | 109 | $sth->execute(); |
110 | - } catch(PDOException $e) { |
|
110 | + } catch (PDOException $e) { |
|
111 | 111 | return "error : ".$e->getMessage(); |
112 | 112 | } |
113 | 113 | //$query_dest = 'INSERT INTO routes (`RouteID`,`CallSign`,`Operator_ICAO`,`FromAirport_ICAO`,`ToAirport_ICAO`,`RouteStop`,`Source`) VALUES (:RouteID, :CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)'; |
@@ -118,11 +118,11 @@ discard block |
||
118 | 118 | if ($globalTransaction) $Connection->db->beginTransaction(); |
119 | 119 | while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
120 | 120 | //$query_dest_values = array(':RouteID' => $values['RouteId'],':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file); |
121 | - $query_dest_values = array(':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file); |
|
121 | + $query_dest_values = array(':CallSign' => $values['Callsign'], ':Operator_ICAO' => $values['operator_icao'], ':FromAirport_ICAO' => $values['FromAirportIcao'], ':ToAirport_ICAO' => $values['ToAirportIcao'], ':routestop' => $values['AllStop'], ':source' => $database_file); |
|
122 | 122 | $sth_dest->execute($query_dest_values); |
123 | 123 | } |
124 | 124 | if ($globalTransaction) $Connection->db->commit(); |
125 | - } catch(PDOException $e) { |
|
125 | + } catch (PDOException $e) { |
|
126 | 126 | if ($globalTransaction) $Connection->db->rollBack(); |
127 | 127 | return "error : ".$e->getMessage(); |
128 | 128 | } |
@@ -138,26 +138,26 @@ discard block |
||
138 | 138 | //$Connection = new Connection(); |
139 | 139 | $sth = $Connection->db->prepare($query); |
140 | 140 | $sth->execute(array(':source' => 'oneworld')); |
141 | - } catch(PDOException $e) { |
|
141 | + } catch (PDOException $e) { |
|
142 | 142 | return "error : ".$e->getMessage(); |
143 | 143 | } |
144 | 144 | |
145 | 145 | if ($globalDebug) echo " - Add routes to DB -"; |
146 | 146 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
147 | 147 | $Spotter = new Spotter(); |
148 | - if ($fh = fopen($database_file,"r")) { |
|
148 | + if ($fh = fopen($database_file, "r")) { |
|
149 | 149 | $query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO,:FromAirport_Time, :ToAirport_ICAO, :ToAirport_Time,:routestop, :source)'; |
150 | 150 | $Connection = new Connection(); |
151 | 151 | $sth_dest = $Connection->db->prepare($query_dest); |
152 | 152 | if ($globalTransaction) $Connection->db->beginTransaction(); |
153 | 153 | while (!feof($fh)) { |
154 | - $line = fgetcsv($fh,9999,','); |
|
154 | + $line = fgetcsv($fh, 9999, ','); |
|
155 | 155 | if ($line[0] != '') { |
156 | 156 | if (($line[2] == '-' || ($line[2] != '-' && (strtotime($line[2]) > time()))) && ($line[3] == '-' || ($line[3] != '-' && (strtotime($line[3]) < time())))) { |
157 | 157 | try { |
158 | - $query_dest_values = array(':CallSign' => str_replace('*','',$line[7]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[5],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[6],':routestop' => '',':source' => 'oneworld'); |
|
158 | + $query_dest_values = array(':CallSign' => str_replace('*', '', $line[7]), ':Operator_ICAO' => '', ':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]), ':FromAirport_Time' => $line[5], ':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]), ':ToAirport_Time' => $line[6], ':routestop' => '', ':source' => 'oneworld'); |
|
159 | 159 | $sth_dest->execute($query_dest_values); |
160 | - } catch(PDOException $e) { |
|
160 | + } catch (PDOException $e) { |
|
161 | 161 | if ($globalTransaction) $Connection->db->rollBack(); |
162 | 162 | return "error : ".$e->getMessage(); |
163 | 163 | } |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | //$Connection = new Connection(); |
180 | 180 | $sth = $Connection->db->prepare($query); |
181 | 181 | $sth->execute(array(':source' => 'skyteam')); |
182 | - } catch(PDOException $e) { |
|
182 | + } catch (PDOException $e) { |
|
183 | 183 | return "error : ".$e->getMessage(); |
184 | 184 | } |
185 | 185 | |
@@ -187,24 +187,24 @@ discard block |
||
187 | 187 | |
188 | 188 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
189 | 189 | $Spotter = new Spotter(); |
190 | - if ($fh = fopen($database_file,"r")) { |
|
190 | + if ($fh = fopen($database_file, "r")) { |
|
191 | 191 | $query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO,:FromAirport_Time, :ToAirport_ICAO, :ToAirport_Time,:routestop, :source)'; |
192 | 192 | $Connection = new Connection(); |
193 | 193 | $sth_dest = $Connection->db->prepare($query_dest); |
194 | 194 | try { |
195 | 195 | if ($globalTransaction) $Connection->db->beginTransaction(); |
196 | 196 | while (!feof($fh)) { |
197 | - $line = fgetcsv($fh,9999,','); |
|
197 | + $line = fgetcsv($fh, 9999, ','); |
|
198 | 198 | if ($line[0] != '') { |
199 | - $datebe = explode(' - ',$line[2]); |
|
199 | + $datebe = explode(' - ', $line[2]); |
|
200 | 200 | if (strtotime($datebe[0]) > time() && strtotime($datebe[1]) < time()) { |
201 | - $query_dest_values = array(':CallSign' => str_replace('*','',$line[6]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[4],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[5],':routestop' => '',':source' => 'skyteam'); |
|
201 | + $query_dest_values = array(':CallSign' => str_replace('*', '', $line[6]), ':Operator_ICAO' => '', ':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]), ':FromAirport_Time' => $line[4], ':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]), ':ToAirport_Time' => $line[5], ':routestop' => '', ':source' => 'skyteam'); |
|
202 | 202 | $sth_dest->execute($query_dest_values); |
203 | 203 | } |
204 | 204 | } |
205 | 205 | } |
206 | 206 | if ($globalTransaction) $Connection->db->commit(); |
207 | - } catch(PDOException $e) { |
|
207 | + } catch (PDOException $e) { |
|
208 | 208 | if ($globalTransaction) $Connection->db->rollBack(); |
209 | 209 | return "error : ".$e->getMessage(); |
210 | 210 | } |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | $Connection = new Connection(); |
220 | 220 | $sth = $Connection->db->prepare($query); |
221 | 221 | $sth->execute(array(':source' => $database_file)); |
222 | - } catch(PDOException $e) { |
|
222 | + } catch (PDOException $e) { |
|
223 | 223 | return "error : ".$e->getMessage(); |
224 | 224 | } |
225 | 225 | $query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source"; |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | $Connection = new Connection(); |
228 | 228 | $sth = $Connection->db->prepare($query); |
229 | 229 | $sth->execute(array(':source' => $database_file)); |
230 | - } catch(PDOException $e) { |
|
230 | + } catch (PDOException $e) { |
|
231 | 231 | return "error : ".$e->getMessage(); |
232 | 232 | } |
233 | 233 | |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | try { |
237 | 237 | $sth = update_db::$db_sqlite->prepare($query); |
238 | 238 | $sth->execute(); |
239 | - } catch(PDOException $e) { |
|
239 | + } catch (PDOException $e) { |
|
240 | 240 | return "error : ".$e->getMessage(); |
241 | 241 | } |
242 | 242 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
@@ -253,15 +253,15 @@ discard block |
||
253 | 253 | //$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']); |
254 | 254 | if ($values['UserString4'] == 'M') $type = 'military'; |
255 | 255 | else $type = null; |
256 | - $query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type); |
|
256 | + $query_dest_values = array(':LastModified' => $values['LastModified'], ':ModeS' => $values['ModeS'], ':ModeSCountry' => $values['ModeSCountry'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file, ':type' => $type); |
|
257 | 257 | $sth_dest->execute($query_dest_values); |
258 | 258 | if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') { |
259 | - $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']); |
|
259 | + $query_dest_owner_values = array(':registration' => $values['Registration'], ':source' => $database_file, ':owner' => $values['RegisteredOwners']); |
|
260 | 260 | $sth_dest_owner->execute($query_dest_owner_values); |
261 | 261 | } |
262 | 262 | } |
263 | 263 | if ($globalTransaction) $Connection->db->commit(); |
264 | - } catch(PDOException $e) { |
|
264 | + } catch (PDOException $e) { |
|
265 | 265 | return "error : ".$e->getMessage(); |
266 | 266 | } |
267 | 267 | |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | $Connection = new Connection(); |
272 | 272 | $sth = $Connection->db->prepare($query); |
273 | 273 | $sth->execute(array(':source' => $database_file)); |
274 | - } catch(PDOException $e) { |
|
274 | + } catch (PDOException $e) { |
|
275 | 275 | return "error : ".$e->getMessage(); |
276 | 276 | } |
277 | 277 | return ''; |
@@ -286,11 +286,11 @@ discard block |
||
286 | 286 | $Connection = new Connection(); |
287 | 287 | $sth = $Connection->db->prepare($query); |
288 | 288 | $sth->execute(array(':source' => $database_file)); |
289 | - } catch(PDOException $e) { |
|
289 | + } catch (PDOException $e) { |
|
290 | 290 | return "error : ".$e->getMessage(); |
291 | 291 | } |
292 | 292 | |
293 | - if ($fh = fopen($database_file,"r")) { |
|
293 | + if ($fh = fopen($database_file, "r")) { |
|
294 | 294 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
295 | 295 | $query_dest = 'INSERT INTO aircraft_modes (ModeS,Registration,ICAOTypeCode,Source,source_type) VALUES (:ModeS,:Registration,:ICAOTypeCode,:source,:source_type)'; |
296 | 296 | |
@@ -300,13 +300,13 @@ discard block |
||
300 | 300 | if ($globalTransaction) $Connection->db->beginTransaction(); |
301 | 301 | while (!feof($fh)) { |
302 | 302 | $values = array(); |
303 | - $line = $Common->hex2str(fgets($fh,9999)); |
|
303 | + $line = $Common->hex2str(fgets($fh, 9999)); |
|
304 | 304 | //FFFFFF RIDEAU VALLEY SOARINGASW-20 C-FBKN MZ 123.400 |
305 | - $values['ModeS'] = substr($line,0,6); |
|
306 | - $values['Registration'] = trim(substr($line,69,6)); |
|
307 | - $aircraft_name = trim(substr($line,48,6)); |
|
305 | + $values['ModeS'] = substr($line, 0, 6); |
|
306 | + $values['Registration'] = trim(substr($line, 69, 6)); |
|
307 | + $aircraft_name = trim(substr($line, 48, 6)); |
|
308 | 308 | // Check if we can find ICAO, else set it to GLID |
309 | - $aircraft_name_split = explode(' ',$aircraft_name); |
|
309 | + $aircraft_name_split = explode(' ', $aircraft_name); |
|
310 | 310 | $search_more = ''; |
311 | 311 | if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
312 | 312 | $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
@@ -318,20 +318,20 @@ discard block |
||
318 | 318 | if (isset($result['icao']) && $result['icao'] != '') { |
319 | 319 | $values['ICAOTypeCode'] = $result['icao']; |
320 | 320 | } |
321 | - } catch(PDOException $e) { |
|
321 | + } catch (PDOException $e) { |
|
322 | 322 | return "error : ".$e->getMessage(); |
323 | 323 | } |
324 | 324 | if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID'; |
325 | 325 | // Add data to db |
326 | 326 | if ($values['Registration'] != '' && $values['Registration'] != '0000') { |
327 | 327 | //$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']); |
328 | - $query_dest_values = array(':ModeS' => $values['ModeS'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':source_type' => 'flarm'); |
|
328 | + $query_dest_values = array(':ModeS' => $values['ModeS'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file, ':source_type' => 'flarm'); |
|
329 | 329 | //print_r($query_dest_values); |
330 | 330 | $sth_dest->execute($query_dest_values); |
331 | 331 | } |
332 | 332 | } |
333 | 333 | if ($globalTransaction) $Connection->db->commit(); |
334 | - } catch(PDOException $e) { |
|
334 | + } catch (PDOException $e) { |
|
335 | 335 | return "error : ".$e->getMessage(); |
336 | 336 | } |
337 | 337 | } |
@@ -341,7 +341,7 @@ discard block |
||
341 | 341 | $Connection = new Connection(); |
342 | 342 | $sth = $Connection->db->prepare($query); |
343 | 343 | $sth->execute(array(':source' => $database_file)); |
344 | - } catch(PDOException $e) { |
|
344 | + } catch (PDOException $e) { |
|
345 | 345 | return "error : ".$e->getMessage(); |
346 | 346 | } |
347 | 347 | return ''; |
@@ -355,11 +355,11 @@ discard block |
||
355 | 355 | $Connection = new Connection(); |
356 | 356 | $sth = $Connection->db->prepare($query); |
357 | 357 | $sth->execute(array(':source' => $database_file)); |
358 | - } catch(PDOException $e) { |
|
358 | + } catch (PDOException $e) { |
|
359 | 359 | return "error : ".$e->getMessage(); |
360 | 360 | } |
361 | 361 | |
362 | - if ($fh = fopen($database_file,"r")) { |
|
362 | + if ($fh = fopen($database_file, "r")) { |
|
363 | 363 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
364 | 364 | $query_dest = 'INSERT INTO aircraft_modes (LastModified,ModeS,Registration,ICAOTypeCode,Source,source_type) VALUES (:lastmodified,:ModeS,:Registration,:ICAOTypeCode,:source,:source_type)'; |
365 | 365 | |
@@ -367,9 +367,9 @@ discard block |
||
367 | 367 | $sth_dest = $Connection->db->prepare($query_dest); |
368 | 368 | try { |
369 | 369 | if ($globalTransaction) $Connection->db->beginTransaction(); |
370 | - $tmp = fgetcsv($fh,9999,',',"'"); |
|
370 | + $tmp = fgetcsv($fh, 9999, ',', "'"); |
|
371 | 371 | while (!feof($fh)) { |
372 | - $line = fgetcsv($fh,9999,',',"'"); |
|
372 | + $line = fgetcsv($fh, 9999, ',', "'"); |
|
373 | 373 | |
374 | 374 | //FFFFFF RIDEAU VALLEY SOARINGASW-20 C-FBKN MZ 123.400 |
375 | 375 | //print_r($line); |
@@ -378,7 +378,7 @@ discard block |
||
378 | 378 | $values['ICAOTypeCode'] = ''; |
379 | 379 | $aircraft_name = $line[2]; |
380 | 380 | // Check if we can find ICAO, else set it to GLID |
381 | - $aircraft_name_split = explode(' ',$aircraft_name); |
|
381 | + $aircraft_name_split = explode(' ', $aircraft_name); |
|
382 | 382 | $search_more = ''; |
383 | 383 | if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
384 | 384 | $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
@@ -387,20 +387,20 @@ discard block |
||
387 | 387 | $sth_search->execute(); |
388 | 388 | $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
389 | 389 | if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao']; |
390 | - } catch(PDOException $e) { |
|
390 | + } catch (PDOException $e) { |
|
391 | 391 | return "error : ".$e->getMessage(); |
392 | 392 | } |
393 | 393 | //if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID'; |
394 | 394 | // Add data to db |
395 | 395 | if ($values['Registration'] != '' && $values['Registration'] != '0000' && $values['ICAOTypeCode'] != '') { |
396 | 396 | //$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']); |
397 | - $query_dest_values = array(':lastmodified' => date('Y-m-d H:m:s'),':ModeS' => $values['ModeS'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':source_type' => 'flarm'); |
|
397 | + $query_dest_values = array(':lastmodified' => date('Y-m-d H:m:s'), ':ModeS' => $values['ModeS'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file, ':source_type' => 'flarm'); |
|
398 | 398 | //print_r($query_dest_values); |
399 | 399 | $sth_dest->execute($query_dest_values); |
400 | 400 | } |
401 | 401 | } |
402 | 402 | if ($globalTransaction) $Connection->db->commit(); |
403 | - } catch(PDOException $e) { |
|
403 | + } catch (PDOException $e) { |
|
404 | 404 | return "error : ".$e->getMessage(); |
405 | 405 | } |
406 | 406 | } |
@@ -410,13 +410,13 @@ discard block |
||
410 | 410 | $Connection = new Connection(); |
411 | 411 | $sth = $Connection->db->prepare($query); |
412 | 412 | $sth->execute(array(':source' => $database_file)); |
413 | - } catch(PDOException $e) { |
|
413 | + } catch (PDOException $e) { |
|
414 | 414 | return "error : ".$e->getMessage(); |
415 | 415 | } |
416 | 416 | return ''; |
417 | 417 | } |
418 | 418 | |
419 | - public static function retrieve_owner($database_file,$country = 'F') { |
|
419 | + public static function retrieve_owner($database_file, $country = 'F') { |
|
420 | 420 | global $globalTransaction, $globalMasterSource; |
421 | 421 | //$query = 'TRUNCATE TABLE aircraft_modes'; |
422 | 422 | $query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source; DELETE FROM aircraft_modes WHERE Source = :source;"; |
@@ -424,12 +424,12 @@ discard block |
||
424 | 424 | $Connection = new Connection(); |
425 | 425 | $sth = $Connection->db->prepare($query); |
426 | 426 | $sth->execute(array(':source' => $database_file)); |
427 | - } catch(PDOException $e) { |
|
427 | + } catch (PDOException $e) { |
|
428 | 428 | return "error : ".$e->getMessage(); |
429 | 429 | } |
430 | 430 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
431 | 431 | $Spotter = new Spotter(); |
432 | - if ($fh = fopen($database_file,"r")) { |
|
432 | + if ($fh = fopen($database_file, "r")) { |
|
433 | 433 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
434 | 434 | $query_dest = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)'; |
435 | 435 | $query_modes = 'INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:modes,:modescountry,:registration,:icaotypecode,:source)'; |
@@ -439,9 +439,9 @@ discard block |
||
439 | 439 | $sth_modes = $Connection->db->prepare($query_modes); |
440 | 440 | try { |
441 | 441 | if ($globalTransaction) $Connection->db->beginTransaction(); |
442 | - $tmp = fgetcsv($fh,9999,',','"'); |
|
442 | + $tmp = fgetcsv($fh, 9999, ',', '"'); |
|
443 | 443 | while (!feof($fh)) { |
444 | - $line = fgetcsv($fh,9999,',','"'); |
|
444 | + $line = fgetcsv($fh, 9999, ',', '"'); |
|
445 | 445 | $values = array(); |
446 | 446 | //print_r($line); |
447 | 447 | if ($country == 'F') { |
@@ -449,7 +449,7 @@ discard block |
||
449 | 449 | $values['base'] = $line[4]; |
450 | 450 | $values['owner'] = $line[5]; |
451 | 451 | if ($line[6] == '') $values['date_first_reg'] = null; |
452 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
452 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[6])); |
|
453 | 453 | $values['cancel'] = $line[7]; |
454 | 454 | } elseif ($country == 'EI') { |
455 | 455 | // TODO : add modeS & reg to aircraft_modes |
@@ -457,7 +457,7 @@ discard block |
||
457 | 457 | $values['base'] = $line[3]; |
458 | 458 | $values['owner'] = $line[2]; |
459 | 459 | if ($line[1] == '') $values['date_first_reg'] = null; |
460 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
460 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[1])); |
|
461 | 461 | $values['cancel'] = ''; |
462 | 462 | $values['modes'] = $line[7]; |
463 | 463 | $values['icao'] = $line[8]; |
@@ -477,7 +477,7 @@ discard block |
||
477 | 477 | $values['base'] = null; |
478 | 478 | $values['owner'] = $line[5]; |
479 | 479 | if ($line[18] == '') $values['date_first_reg'] = null; |
480 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
480 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[18])); |
|
481 | 481 | $values['cancel'] = ''; |
482 | 482 | } elseif ($country == 'VH') { |
483 | 483 | // TODO : add modeS & reg to aircraft_modes |
@@ -485,7 +485,7 @@ discard block |
||
485 | 485 | $values['base'] = null; |
486 | 486 | $values['owner'] = $line[12]; |
487 | 487 | if ($line[28] == '') $values['date_first_reg'] = null; |
488 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
488 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[28])); |
|
489 | 489 | |
490 | 490 | $values['cancel'] = $line[39]; |
491 | 491 | } elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') { |
@@ -505,28 +505,28 @@ discard block |
||
505 | 505 | $values['base'] = null; |
506 | 506 | $values['owner'] = $line[8]; |
507 | 507 | if ($line[7] == '') $values['date_first_reg'] = null; |
508 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
508 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[7])); |
|
509 | 509 | $values['cancel'] = ''; |
510 | 510 | } elseif ($country == 'PP') { |
511 | 511 | $values['registration'] = $line[0]; |
512 | 512 | $values['base'] = null; |
513 | 513 | $values['owner'] = $line[4]; |
514 | 514 | if ($line[6] == '') $values['date_first_reg'] = null; |
515 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
515 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[6])); |
|
516 | 516 | $values['cancel'] = $line[7]; |
517 | 517 | } elseif ($country == 'E7') { |
518 | 518 | $values['registration'] = $line[0]; |
519 | 519 | $values['base'] = null; |
520 | 520 | $values['owner'] = $line[4]; |
521 | 521 | if ($line[5] == '') $values['date_first_reg'] = null; |
522 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
522 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[5])); |
|
523 | 523 | $values['cancel'] = ''; |
524 | 524 | } elseif ($country == '8Q') { |
525 | 525 | $values['registration'] = $line[0]; |
526 | 526 | $values['base'] = null; |
527 | 527 | $values['owner'] = $line[3]; |
528 | 528 | if ($line[7] == '') $values['date_first_reg'] = null; |
529 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
529 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[7])); |
|
530 | 530 | $values['cancel'] = ''; |
531 | 531 | } elseif ($country == 'ZK') { |
532 | 532 | $values['registration'] = $line[0]; |
@@ -540,18 +540,18 @@ discard block |
||
540 | 540 | $values['registration'] = $line[0]; |
541 | 541 | $values['base'] = null; |
542 | 542 | $values['owner'] = $line[6]; |
543 | - $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
544 | - $values['cancel'] = date("Y-m-d",strtotime($line[8])); |
|
543 | + $values['date_first_reg'] = date("Y-m-d", strtotime($line[5])); |
|
544 | + $values['cancel'] = date("Y-m-d", strtotime($line[8])); |
|
545 | 545 | $values['modes'] = $line[4]; |
546 | 546 | $values['icao'] = $line[10]; |
547 | 547 | } elseif ($country == 'OY') { |
548 | 548 | $values['registration'] = $line[0]; |
549 | - $values['date_first_reg'] = date("Y-m-d",strtotime($line[4])); |
|
549 | + $values['date_first_reg'] = date("Y-m-d", strtotime($line[4])); |
|
550 | 550 | $values['modes'] = $line[5]; |
551 | 551 | $values['icao'] = $line[6]; |
552 | 552 | } elseif ($country == 'PH') { |
553 | 553 | $values['registration'] = $line[0]; |
554 | - $values['date_first_reg'] = date("Y-m-d",strtotime($line[3])); |
|
554 | + $values['date_first_reg'] = date("Y-m-d", strtotime($line[3])); |
|
555 | 555 | $values['modes'] = $line[4]; |
556 | 556 | $values['icao'] = $line[5]; |
557 | 557 | } elseif ($country == 'OM' || $country == 'TF') { |
@@ -562,17 +562,17 @@ discard block |
||
562 | 562 | $values['cancel'] = ''; |
563 | 563 | } |
564 | 564 | if (isset($values['cancel']) && $values['cancel'] == '' && $values['registration'] != null && isset($values['owner'])) { |
565 | - $query_dest_values = array(':registration' => $values['registration'],':base' => $values['base'],':date_first_reg' => $values['date_first_reg'],':owner' => $values['owner'],':source' => $database_file); |
|
565 | + $query_dest_values = array(':registration' => $values['registration'], ':base' => $values['base'], ':date_first_reg' => $values['date_first_reg'], ':owner' => $values['owner'], ':source' => $database_file); |
|
566 | 566 | $sth_dest->execute($query_dest_values); |
567 | 567 | } |
568 | 568 | if ($globalMasterSource && $values['registration'] != null && isset($values['modes']) && $values['modes'] != '') { |
569 | 569 | $modescountry = $Spotter->countryFromAircraftRegistration($values['registration']); |
570 | - $query_modes_values = array(':registration' => $values['registration'],':modes' => $values['modes'],':modescountry' => $modescountry,':icaotypecode' => $values['icao'],':source' => $database_file); |
|
570 | + $query_modes_values = array(':registration' => $values['registration'], ':modes' => $values['modes'], ':modescountry' => $modescountry, ':icaotypecode' => $values['icao'], ':source' => $database_file); |
|
571 | 571 | $sth_modes->execute($query_modes_values); |
572 | 572 | } |
573 | 573 | } |
574 | 574 | if ($globalTransaction) $Connection->db->commit(); |
575 | - } catch(PDOException $e) { |
|
575 | + } catch (PDOException $e) { |
|
576 | 576 | return "error : ".$e->getMessage(); |
577 | 577 | } |
578 | 578 | } |
@@ -710,7 +710,7 @@ discard block |
||
710 | 710 | if ($globalTransaction) $Connection->db->beginTransaction(); |
711 | 711 | |
712 | 712 | $i = 0; |
713 | - while($row = sparql_fetch_array($result)) |
|
713 | + while ($row = sparql_fetch_array($result)) |
|
714 | 714 | { |
715 | 715 | if ($i >= 1) { |
716 | 716 | //print_r($row); |
@@ -730,33 +730,33 @@ discard block |
||
730 | 730 | $row['image'] = ''; |
731 | 731 | $row['image_thumb'] = ''; |
732 | 732 | } else { |
733 | - $image = str_replace(' ','_',$row['image']); |
|
733 | + $image = str_replace(' ', '_', $row['image']); |
|
734 | 734 | $digest = md5($image); |
735 | - $folder = $digest[0] . '/' . $digest[0] . $digest[1] . '/' . $image . '/220px-' . $image; |
|
736 | - $row['image_thumb'] = 'http://upload.wikimedia.org/wikipedia/commons/thumb/' . $folder; |
|
737 | - $folder = $digest[0] . '/' . $digest[0] . $digest[1] . '/' . $image; |
|
738 | - $row['image'] = 'http://upload.wikimedia.org/wikipedia/commons/' . $folder; |
|
735 | + $folder = $digest[0].'/'.$digest[0].$digest[1].'/'.$image.'/220px-'.$image; |
|
736 | + $row['image_thumb'] = 'http://upload.wikimedia.org/wikipedia/commons/thumb/'.$folder; |
|
737 | + $folder = $digest[0].'/'.$digest[0].$digest[1].'/'.$image; |
|
738 | + $row['image'] = 'http://upload.wikimedia.org/wikipedia/commons/'.$folder; |
|
739 | 739 | } |
740 | 740 | |
741 | - $country = explode('-',$row['country']); |
|
741 | + $country = explode('-', $row['country']); |
|
742 | 742 | $row['country'] = $country[0]; |
743 | 743 | |
744 | 744 | $row['type'] = trim($row['type']); |
745 | - if ($row['type'] == 'Military: Naval Auxiliary Air Station' || $row['type'] == 'http://dbpedia.org/resource/Naval_air_station' || $row['type'] == 'Military: Naval Air Station' || $row['type'] == 'Military Northern Fleet' || $row['type'] == 'Military and industrial' || $row['type'] == 'Military: Royal Air Force station' || $row['type'] == 'http://dbpedia.org/resource/Military_airbase' || $row['type'] == 'Military: Naval air station' || preg_match('/air base/i',$row['name'])) { |
|
745 | + if ($row['type'] == 'Military: Naval Auxiliary Air Station' || $row['type'] == 'http://dbpedia.org/resource/Naval_air_station' || $row['type'] == 'Military: Naval Air Station' || $row['type'] == 'Military Northern Fleet' || $row['type'] == 'Military and industrial' || $row['type'] == 'Military: Royal Air Force station' || $row['type'] == 'http://dbpedia.org/resource/Military_airbase' || $row['type'] == 'Military: Naval air station' || preg_match('/air base/i', $row['name'])) { |
|
746 | 746 | $row['type'] = 'military'; |
747 | 747 | } elseif ($row['type'] == 'http://dbpedia.org/resource/Airport' || $row['type'] == 'Civil' || $row['type'] == 'Public use' || $row['type'] == 'Public' || $row['type'] == 'http://dbpedia.org/resource/Civilian' || $row['type'] == 'Public, Civilian' || $row['type'] == 'Public / Military' || $row['type'] == 'Private & Civilian' || $row['type'] == 'Civilian and Military' || $row['type'] == 'Public/military' || $row['type'] == 'Active With Few Facilities' || $row['type'] == '?ivilian' || $row['type'] == 'Civil/Military' || $row['type'] == 'NA' || $row['type'] == 'Public/Military') { |
748 | 748 | $row['type'] = 'small_airport'; |
749 | 749 | } |
750 | 750 | |
751 | - $row['city'] = urldecode(str_replace('_',' ',str_replace('http://dbpedia.org/resource/','',$row['city']))); |
|
752 | - $query_dest_values = array(':name' => $row['name'],':iata' => $row['iata'],':icao' => $row['icao'],':latitude' => $row['latitude'],':longitude' => $row['longitude'],':altitude' => round($row['altitude']),':type' => $row['type'],':city' => $row['city'],':country' => $row['country'],':home_link' => $row['homepage'],':wikipedia_link' => $row['wikipedia_page'],':image' => $row['image'],':image_thumb' => $row['image_thumb']); |
|
751 | + $row['city'] = urldecode(str_replace('_', ' ', str_replace('http://dbpedia.org/resource/', '', $row['city']))); |
|
752 | + $query_dest_values = array(':name' => $row['name'], ':iata' => $row['iata'], ':icao' => $row['icao'], ':latitude' => $row['latitude'], ':longitude' => $row['longitude'], ':altitude' => round($row['altitude']), ':type' => $row['type'], ':city' => $row['city'], ':country' => $row['country'], ':home_link' => $row['homepage'], ':wikipedia_link' => $row['wikipedia_page'], ':image' => $row['image'], ':image_thumb' => $row['image_thumb']); |
|
753 | 753 | //print_r($query_dest_values); |
754 | 754 | |
755 | 755 | if ($row['icao'] != '') { |
756 | 756 | try { |
757 | 757 | $sth = $Connection->db->prepare('SELECT COUNT(*) FROM airport WHERE icao = :icao'); |
758 | 758 | $sth->execute(array(':icao' => $row['icao'])); |
759 | - } catch(PDOException $e) { |
|
759 | + } catch (PDOException $e) { |
|
760 | 760 | return "error : ".$e->getMessage(); |
761 | 761 | } |
762 | 762 | if ($sth->fetchColumn() > 0) { |
@@ -764,15 +764,15 @@ discard block |
||
764 | 764 | $query = 'UPDATE airport SET type = :type WHERE icao = :icao'; |
765 | 765 | try { |
766 | 766 | $sth = $Connection->db->prepare($query); |
767 | - $sth->execute(array(':icao' => $row['icao'],':type' => $row['type'])); |
|
768 | - } catch(PDOException $e) { |
|
767 | + $sth->execute(array(':icao' => $row['icao'], ':type' => $row['type'])); |
|
768 | + } catch (PDOException $e) { |
|
769 | 769 | return "error : ".$e->getMessage(); |
770 | 770 | } |
771 | 771 | echo $row['icao'].' : '.$row['type']."\n"; |
772 | 772 | } else { |
773 | 773 | try { |
774 | 774 | $sth_dest->execute($query_dest_values); |
775 | - } catch(PDOException $e) { |
|
775 | + } catch (PDOException $e) { |
|
776 | 776 | return "error : ".$e->getMessage(); |
777 | 777 | } |
778 | 778 | } |
@@ -823,7 +823,7 @@ discard block |
||
823 | 823 | echo "Download data from ourairports.com...\n"; |
824 | 824 | $delimiter = ','; |
825 | 825 | $out_file = $tmp_dir.'airports.csv'; |
826 | - update_db::download('http://ourairports.com/data/airports.csv',$out_file); |
|
826 | + update_db::download('http://ourairports.com/data/airports.csv', $out_file); |
|
827 | 827 | if (!file_exists($out_file) || !is_readable($out_file)) return FALSE; |
828 | 828 | echo "Add data from ourairports.com...\n"; |
829 | 829 | |
@@ -834,33 +834,33 @@ discard block |
||
834 | 834 | //$Connection->db->beginTransaction(); |
835 | 835 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
836 | 836 | { |
837 | - if(!$header) $header = $row; |
|
837 | + if (!$header) $header = $row; |
|
838 | 838 | else { |
839 | 839 | $data = array(); |
840 | 840 | $data = array_combine($header, $row); |
841 | 841 | try { |
842 | 842 | $sth = $Connection->db->prepare('SELECT COUNT(*) FROM airport WHERE icao = :icao'); |
843 | 843 | $sth->execute(array(':icao' => $data['ident'])); |
844 | - } catch(PDOException $e) { |
|
844 | + } catch (PDOException $e) { |
|
845 | 845 | return "error : ".$e->getMessage(); |
846 | 846 | } |
847 | 847 | if ($sth->fetchColumn() > 0) { |
848 | 848 | $query = 'UPDATE airport SET type = :type WHERE icao = :icao'; |
849 | 849 | try { |
850 | 850 | $sth = $Connection->db->prepare($query); |
851 | - $sth->execute(array(':icao' => $data['ident'],':type' => $data['type'])); |
|
852 | - } catch(PDOException $e) { |
|
851 | + $sth->execute(array(':icao' => $data['ident'], ':type' => $data['type'])); |
|
852 | + } catch (PDOException $e) { |
|
853 | 853 | return "error : ".$e->getMessage(); |
854 | 854 | } |
855 | 855 | } else { |
856 | 856 | if ($data['gps_code'] == $data['ident']) { |
857 | 857 | $query = "INSERT INTO airport (name,city,country,iata,icao,latitude,longitude,altitude,type,home_link,wikipedia_link) |
858 | 858 | VALUES (:name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link)"; |
859 | - $query_values = array(':name' => $data['name'],':iata' => $data['iata_code'],':icao' => $data['gps_code'],':latitude' => $data['latitude_deg'],':longitude' => $data['longitude_deg'],':altitude' => round($data['elevation_ft']),':type' => $data['type'],':city' => $data['municipality'],':country' => $data['iso_country'],':home_link' => $data['home_link'],':wikipedia_link' => $data['wikipedia_link']); |
|
859 | + $query_values = array(':name' => $data['name'], ':iata' => $data['iata_code'], ':icao' => $data['gps_code'], ':latitude' => $data['latitude_deg'], ':longitude' => $data['longitude_deg'], ':altitude' => round($data['elevation_ft']), ':type' => $data['type'], ':city' => $data['municipality'], ':country' => $data['iso_country'], ':home_link' => $data['home_link'], ':wikipedia_link' => $data['wikipedia_link']); |
|
860 | 860 | try { |
861 | 861 | $sth = $Connection->db->prepare($query); |
862 | 862 | $sth->execute($query_values); |
863 | - } catch(PDOException $e) { |
|
863 | + } catch (PDOException $e) { |
|
864 | 864 | return "error : ".$e->getMessage(); |
865 | 865 | } |
866 | 866 | $i++; |
@@ -875,7 +875,7 @@ discard block |
||
875 | 875 | |
876 | 876 | echo "Download data from another free database...\n"; |
877 | 877 | $out_file = $tmp_dir.'GlobalAirportDatabase.zip'; |
878 | - update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file); |
|
878 | + update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip', $out_file); |
|
879 | 879 | if (!file_exists($out_file) || !is_readable($out_file)) return FALSE; |
880 | 880 | update_db::unzip($out_file); |
881 | 881 | $header = NULL; |
@@ -887,15 +887,15 @@ discard block |
||
887 | 887 | //$Connection->db->beginTransaction(); |
888 | 888 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
889 | 889 | { |
890 | - if(!$header) $header = $row; |
|
890 | + if (!$header) $header = $row; |
|
891 | 891 | else { |
892 | 892 | $data = $row; |
893 | 893 | |
894 | 894 | $query = 'UPDATE airport SET city = :city, country = :country WHERE icao = :icao'; |
895 | 895 | try { |
896 | 896 | $sth = $Connection->db->prepare($query); |
897 | - $sth->execute(array(':icao' => $data[0],':city' => ucwords(strtolower($data[3])),':country' => ucwords(strtolower($data[4])))); |
|
898 | - } catch(PDOException $e) { |
|
897 | + $sth->execute(array(':icao' => $data[0], ':city' => ucwords(strtolower($data[3])), ':country' => ucwords(strtolower($data[4])))); |
|
898 | + } catch (PDOException $e) { |
|
899 | 899 | return "error : ".$e->getMessage(); |
900 | 900 | } |
901 | 901 | } |
@@ -909,15 +909,15 @@ discard block |
||
909 | 909 | try { |
910 | 910 | $sth = $Connection->db->prepare("SELECT icao FROM airport WHERE name LIKE '%Air Base%'"); |
911 | 911 | $sth->execute(); |
912 | - } catch(PDOException $e) { |
|
912 | + } catch (PDOException $e) { |
|
913 | 913 | return "error : ".$e->getMessage(); |
914 | 914 | } |
915 | 915 | while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
916 | 916 | $query2 = 'UPDATE airport SET type = :type WHERE icao = :icao'; |
917 | 917 | try { |
918 | 918 | $sth2 = $Connection->db->prepare($query2); |
919 | - $sth2->execute(array(':icao' => $row['icao'],':type' => 'military')); |
|
920 | - } catch(PDOException $e) { |
|
919 | + $sth2->execute(array(':icao' => $row['icao'], ':type' => 'military')); |
|
920 | + } catch (PDOException $e) { |
|
921 | 921 | return "error : ".$e->getMessage(); |
922 | 922 | } |
923 | 923 | } |
@@ -938,7 +938,7 @@ discard block |
||
938 | 938 | $Connection = new Connection(); |
939 | 939 | $sth = $Connection->db->prepare($query); |
940 | 940 | $sth->execute(array(':source' => 'translation.csv')); |
941 | - } catch(PDOException $e) { |
|
941 | + } catch (PDOException $e) { |
|
942 | 942 | return "error : ".$e->getMessage(); |
943 | 943 | } |
944 | 944 | |
@@ -955,7 +955,7 @@ discard block |
||
955 | 955 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
956 | 956 | { |
957 | 957 | $i++; |
958 | - if($i > 12) { |
|
958 | + if ($i > 12) { |
|
959 | 959 | $data = $row; |
960 | 960 | $operator = $data[2]; |
961 | 961 | if ($operator != '' && is_numeric(substr(substr($operator, 0, 3), -1, 1))) { |
@@ -963,7 +963,7 @@ discard block |
||
963 | 963 | //echo substr($operator, 0, 2)."\n";; |
964 | 964 | if (count($airline_array) > 0) { |
965 | 965 | //print_r($airline_array); |
966 | - $operator = $airline_array[0]['icao'].substr($operator,2); |
|
966 | + $operator = $airline_array[0]['icao'].substr($operator, 2); |
|
967 | 967 | } |
968 | 968 | } |
969 | 969 | |
@@ -971,14 +971,14 @@ discard block |
||
971 | 971 | if ($operator_correct != '' && is_numeric(substr(substr($operator_correct, 0, 3), -1, 1))) { |
972 | 972 | $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2)); |
973 | 973 | if (count($airline_array) > 0) { |
974 | - $operator_correct = $airline_array[0]['icao'].substr($operator_correct,2); |
|
974 | + $operator_correct = $airline_array[0]['icao'].substr($operator_correct, 2); |
|
975 | 975 | } |
976 | 976 | } |
977 | 977 | $query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)'; |
978 | 978 | try { |
979 | 979 | $sth = $Connection->db->prepare($query); |
980 | - $sth->execute(array(':Reg' => $data[0],':Reg_correct' => $data[1],':Operator' => $operator,':Operator_correct' => $operator_correct, ':source' => 'translation.csv')); |
|
981 | - } catch(PDOException $e) { |
|
980 | + $sth->execute(array(':Reg' => $data[0], ':Reg_correct' => $data[1], ':Operator' => $operator, ':Operator_correct' => $operator_correct, ':source' => 'translation.csv')); |
|
981 | + } catch (PDOException $e) { |
|
982 | 982 | return "error : ".$e->getMessage(); |
983 | 983 | } |
984 | 984 | } |
@@ -996,7 +996,7 @@ discard block |
||
996 | 996 | $Connection = new Connection(); |
997 | 997 | $sth = $Connection->db->prepare($query); |
998 | 998 | $sth->execute(array(':source' => 'website_fam')); |
999 | - } catch(PDOException $e) { |
|
999 | + } catch (PDOException $e) { |
|
1000 | 1000 | return "error : ".$e->getMessage(); |
1001 | 1001 | } |
1002 | 1002 | //update_db::unzip($out_file); |
@@ -1014,8 +1014,8 @@ discard block |
||
1014 | 1014 | $query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)'; |
1015 | 1015 | try { |
1016 | 1016 | $sth = $Connection->db->prepare($query); |
1017 | - $sth->execute(array(':Reg' => $data[0],':Reg_correct' => $data[1],':Operator' => $data[2],':Operator_correct' => $data[3], ':source' => 'website_fam')); |
|
1018 | - } catch(PDOException $e) { |
|
1017 | + $sth->execute(array(':Reg' => $data[0], ':Reg_correct' => $data[1], ':Operator' => $data[2], ':Operator_correct' => $data[3], ':source' => 'website_fam')); |
|
1018 | + } catch (PDOException $e) { |
|
1019 | 1019 | return "error : ".$e->getMessage(); |
1020 | 1020 | } |
1021 | 1021 | } |
@@ -1037,11 +1037,11 @@ discard block |
||
1037 | 1037 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1038 | 1038 | { |
1039 | 1039 | $query = 'UPDATE airport SET diagram_pdf = :diagrampdf, diagram_png = :diagrampng WHERE icao = :icao'; |
1040 | - $icao = str_replace('.pdf','',$data[2]); |
|
1040 | + $icao = str_replace('.pdf', '', $data[2]); |
|
1041 | 1041 | try { |
1042 | 1042 | $sth = $Connection->db->prepare($query); |
1043 | - $sth->execute(array(':icao' => $icao,':diagrampdf' => 'https://data.flightairmap.com/data/diagrams/'.$icao.'.pdf',':diagrampng' => 'https://data.flightairmap.com/data/diagrams/'.$icao.'.png')); |
|
1044 | - } catch(PDOException $e) { |
|
1043 | + $sth->execute(array(':icao' => $icao, ':diagrampdf' => 'https://data.flightairmap.com/data/diagrams/'.$icao.'.pdf', ':diagrampng' => 'https://data.flightairmap.com/data/diagrams/'.$icao.'.png')); |
|
1044 | + } catch (PDOException $e) { |
|
1045 | 1045 | echo "error : ".$e->getMessage(); |
1046 | 1046 | return "error : ".$e->getMessage(); |
1047 | 1047 | } |
@@ -1063,7 +1063,7 @@ discard block |
||
1063 | 1063 | $Connection = new Connection(); |
1064 | 1064 | $sth = $Connection->db->prepare($query); |
1065 | 1065 | $sth->execute(array(':source' => 'website_faa')); |
1066 | - } catch(PDOException $e) { |
|
1066 | + } catch (PDOException $e) { |
|
1067 | 1067 | return "error : ".$e->getMessage(); |
1068 | 1068 | } |
1069 | 1069 | |
@@ -1072,7 +1072,7 @@ discard block |
||
1072 | 1072 | $Connection = new Connection(); |
1073 | 1073 | $sth = $Connection->db->prepare($query); |
1074 | 1074 | $sth->execute(array(':source' => 'website_faa')); |
1075 | - } catch(PDOException $e) { |
|
1075 | + } catch (PDOException $e) { |
|
1076 | 1076 | return "error : ".$e->getMessage(); |
1077 | 1077 | } |
1078 | 1078 | |
@@ -1089,8 +1089,8 @@ discard block |
||
1089 | 1089 | $query_search = 'SELECT icaotypecode FROM aircraft_modes WHERE registration = :registration AND Source <> :source LIMIT 1'; |
1090 | 1090 | try { |
1091 | 1091 | $sths = $Connection->db->prepare($query_search); |
1092 | - $sths->execute(array(':registration' => 'N'.$data[0],':source' => 'website_faa')); |
|
1093 | - } catch(PDOException $e) { |
|
1092 | + $sths->execute(array(':registration' => 'N'.$data[0], ':source' => 'website_faa')); |
|
1093 | + } catch (PDOException $e) { |
|
1094 | 1094 | return "error s : ".$e->getMessage(); |
1095 | 1095 | } |
1096 | 1096 | $result_search = $sths->fetchAll(PDO::FETCH_ASSOC); |
@@ -1103,8 +1103,8 @@ discard block |
||
1103 | 1103 | //} |
1104 | 1104 | try { |
1105 | 1105 | $sthi = $Connection->db->prepare($queryi); |
1106 | - $sthi->execute(array(':mfr' => $data[2],':icao' => $result_search[0]['icaotypecode'])); |
|
1107 | - } catch(PDOException $e) { |
|
1106 | + $sthi->execute(array(':mfr' => $data[2], ':icao' => $result_search[0]['icaotypecode'])); |
|
1107 | + } catch (PDOException $e) { |
|
1108 | 1108 | return "error u : ".$e->getMessage(); |
1109 | 1109 | } |
1110 | 1110 | } else { |
@@ -1112,7 +1112,7 @@ discard block |
||
1112 | 1112 | try { |
1113 | 1113 | $sthsm = $Connection->db->prepare($query_search_mfr); |
1114 | 1114 | $sthsm->execute(array(':mfr' => $data[2])); |
1115 | - } catch(PDOException $e) { |
|
1115 | + } catch (PDOException $e) { |
|
1116 | 1116 | return "error mfr : ".$e->getMessage(); |
1117 | 1117 | } |
1118 | 1118 | $result_search_mfr = $sthsm->fetchAll(PDO::FETCH_ASSOC); |
@@ -1122,8 +1122,8 @@ discard block |
||
1122 | 1122 | $queryf = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:source)'; |
1123 | 1123 | try { |
1124 | 1124 | $sthf = $Connection->db->prepare($queryf); |
1125 | - $sthf->execute(array(':FirstCreated' => $data[16],':LastModified' => $data[15],':ModeS' => $data[33],':ModeSCountry' => $data[14], ':Registration' => 'N'.$data[0],':ICAOTypeCode' => $result_search_mfr[0]['icao'],':source' => 'website_faa')); |
|
1126 | - } catch(PDOException $e) { |
|
1125 | + $sthf->execute(array(':FirstCreated' => $data[16], ':LastModified' => $data[15], ':ModeS' => $data[33], ':ModeSCountry' => $data[14], ':Registration' => 'N'.$data[0], ':ICAOTypeCode' => $result_search_mfr[0]['icao'], ':source' => 'website_faa')); |
|
1126 | + } catch (PDOException $e) { |
|
1127 | 1127 | return "error f : ".$e->getMessage(); |
1128 | 1128 | } |
1129 | 1129 | } |
@@ -1133,13 +1133,13 @@ discard block |
||
1133 | 1133 | $query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)'; |
1134 | 1134 | try { |
1135 | 1135 | $sth = $Connection->db->prepare($query); |
1136 | - $sth->execute(array(':registration' => 'N'.$data[0],':base' => $data[9],':owner' => ucwords(strtolower($data[6])),':date_first_reg' => date('Y-m-d',strtotime($data[23])), ':source' => 'website_faa')); |
|
1137 | - } catch(PDOException $e) { |
|
1136 | + $sth->execute(array(':registration' => 'N'.$data[0], ':base' => $data[9], ':owner' => ucwords(strtolower($data[6])), ':date_first_reg' => date('Y-m-d', strtotime($data[23])), ':source' => 'website_faa')); |
|
1137 | + } catch (PDOException $e) { |
|
1138 | 1138 | return "error i : ".$e->getMessage(); |
1139 | 1139 | } |
1140 | 1140 | } |
1141 | 1141 | } |
1142 | - if ($i % 90 == 0) { |
|
1142 | + if ($i%90 == 0) { |
|
1143 | 1143 | if ($globalTransaction) $Connection->db->commit(); |
1144 | 1144 | if ($globalTransaction) $Connection->db->beginTransaction(); |
1145 | 1145 | } |
@@ -1158,7 +1158,7 @@ discard block |
||
1158 | 1158 | $Connection = new Connection(); |
1159 | 1159 | $sth = $Connection->db->prepare($query); |
1160 | 1160 | $sth->execute(array(':source' => 'website_fam')); |
1161 | - } catch(PDOException $e) { |
|
1161 | + } catch (PDOException $e) { |
|
1162 | 1162 | return "error : ".$e->getMessage(); |
1163 | 1163 | } |
1164 | 1164 | $delimiter = "\t"; |
@@ -1174,8 +1174,8 @@ discard block |
||
1174 | 1174 | $query = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type_flight,:source)'; |
1175 | 1175 | try { |
1176 | 1176 | $sth = $Connection->db->prepare($query); |
1177 | - $sth->execute(array(':FirstCreated' => $data[0],':LastModified' => $data[1],':ModeS' => $data[2],':ModeSCountry' => $data[3], ':Registration' => $data[4],':ICAOTypeCode' => $data[5],':type_flight' => $data[6],':source' => 'website_fam')); |
|
1178 | - } catch(PDOException $e) { |
|
1177 | + $sth->execute(array(':FirstCreated' => $data[0], ':LastModified' => $data[1], ':ModeS' => $data[2], ':ModeSCountry' => $data[3], ':Registration' => $data[4], ':ICAOTypeCode' => $data[5], ':type_flight' => $data[6], ':source' => 'website_fam')); |
|
1178 | + } catch (PDOException $e) { |
|
1179 | 1179 | return "error : ".$e->getMessage(); |
1180 | 1180 | } |
1181 | 1181 | } |
@@ -1207,7 +1207,7 @@ discard block |
||
1207 | 1207 | try { |
1208 | 1208 | $sth = $Connection->db->prepare($query); |
1209 | 1209 | $sth->execute(); |
1210 | - } catch(PDOException $e) { |
|
1210 | + } catch (PDOException $e) { |
|
1211 | 1211 | return "error : ".$e->getMessage(); |
1212 | 1212 | } |
1213 | 1213 | $delimiter = "\t"; |
@@ -1222,8 +1222,8 @@ discard block |
||
1222 | 1222 | $query = 'INSERT INTO airlines (airline_id,name,alias,iata,icao,callsign,country,active,type,home_link,wikipedia_link,alliance,ban_eu) VALUES (0,:name,:alias,:iata,:icao,:callsign,:country,:active,:type,:home,:wikipedia_link,:alliance,:ban_eu)'; |
1223 | 1223 | try { |
1224 | 1224 | $sth = $Connection->db->prepare($query); |
1225 | - $sth->execute(array(':name' => $data[0],':alias' => $data[1],':iata' => $data[2],':icao' => $data[3], ':callsign' => $data[4],':country' => $data[5],':active' => $data[6],':type' => $data[7],':home' => $data[8],':wikipedia_link' => $data[9],':alliance' => $data[10],':ban_eu' => $data[11])); |
|
1226 | - } catch(PDOException $e) { |
|
1225 | + $sth->execute(array(':name' => $data[0], ':alias' => $data[1], ':iata' => $data[2], ':icao' => $data[3], ':callsign' => $data[4], ':country' => $data[5], ':active' => $data[6], ':type' => $data[7], ':home' => $data[8], ':wikipedia_link' => $data[9], ':alliance' => $data[10], ':ban_eu' => $data[11])); |
|
1226 | + } catch (PDOException $e) { |
|
1227 | 1227 | return "error : ".$e->getMessage(); |
1228 | 1228 | } |
1229 | 1229 | } |
@@ -1251,7 +1251,7 @@ discard block |
||
1251 | 1251 | $Connection = new Connection(); |
1252 | 1252 | $sth = $Connection->db->prepare($query); |
1253 | 1253 | $sth->execute(array(':source' => 'website_fam')); |
1254 | - } catch(PDOException $e) { |
|
1254 | + } catch (PDOException $e) { |
|
1255 | 1255 | return "error : ".$e->getMessage(); |
1256 | 1256 | } |
1257 | 1257 | |
@@ -1267,8 +1267,8 @@ discard block |
||
1267 | 1267 | $query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,NULL,:source)'; |
1268 | 1268 | try { |
1269 | 1269 | $sth = $Connection->db->prepare($query); |
1270 | - $sth->execute(array(':registration' => $data[0],':base' => $data[1],':owner' => $data[2], ':source' => 'website_fam')); |
|
1271 | - } catch(PDOException $e) { |
|
1270 | + $sth->execute(array(':registration' => $data[0], ':base' => $data[1], ':owner' => $data[2], ':source' => 'website_fam')); |
|
1271 | + } catch (PDOException $e) { |
|
1272 | 1272 | //print_r($data); |
1273 | 1273 | return "error : ".$e->getMessage(); |
1274 | 1274 | } |
@@ -1288,7 +1288,7 @@ discard block |
||
1288 | 1288 | $Connection = new Connection(); |
1289 | 1289 | $sth = $Connection->db->prepare($query); |
1290 | 1290 | $sth->execute(array(':source' => 'website_fam')); |
1291 | - } catch(PDOException $e) { |
|
1291 | + } catch (PDOException $e) { |
|
1292 | 1292 | return "error : ".$e->getMessage(); |
1293 | 1293 | } |
1294 | 1294 | $delimiter = "\t"; |
@@ -1304,13 +1304,13 @@ discard block |
||
1304 | 1304 | $query = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign,:Operator_ICAO,:FromAirport_ICAO,:FromAirport_Time,:ToAirport_ICAO,:ToAirport_Time,:RouteStop,:source)'; |
1305 | 1305 | try { |
1306 | 1306 | $sth = $Connection->db->prepare($query); |
1307 | - $sth->execute(array(':CallSign' => $data[0],':Operator_ICAO' => $data[1],':FromAirport_ICAO' => $data[2],':FromAirport_Time' => $data[3], ':ToAirport_ICAO' => $data[4],':ToAirport_Time' => $data[5],':RouteStop' => $data[6],':source' => 'website_fam')); |
|
1308 | - } catch(PDOException $e) { |
|
1309 | - if ($globalDebug) echo "error: ".$e->getMessage()." - data: ".implode(',',$data); |
|
1307 | + $sth->execute(array(':CallSign' => $data[0], ':Operator_ICAO' => $data[1], ':FromAirport_ICAO' => $data[2], ':FromAirport_Time' => $data[3], ':ToAirport_ICAO' => $data[4], ':ToAirport_Time' => $data[5], ':RouteStop' => $data[6], ':source' => 'website_fam')); |
|
1308 | + } catch (PDOException $e) { |
|
1309 | + if ($globalDebug) echo "error: ".$e->getMessage()." - data: ".implode(',', $data); |
|
1310 | 1310 | die(); |
1311 | 1311 | } |
1312 | 1312 | } |
1313 | - if ($globalTransaction && $i % 2000 == 0) { |
|
1313 | + if ($globalTransaction && $i%2000 == 0) { |
|
1314 | 1314 | $Connection->db->commit(); |
1315 | 1315 | if ($globalDebug) echo '.'; |
1316 | 1316 | $Connection->db->beginTransaction(); |
@@ -1330,7 +1330,7 @@ discard block |
||
1330 | 1330 | $Connection = new Connection(); |
1331 | 1331 | $sth = $Connection->db->prepare($query); |
1332 | 1332 | $sth->execute(array(':source' => 'website_fam')); |
1333 | - } catch(PDOException $e) { |
|
1333 | + } catch (PDOException $e) { |
|
1334 | 1334 | return "error : ".$e->getMessage(); |
1335 | 1335 | } |
1336 | 1336 | $Connection = new Connection(); |
@@ -1343,12 +1343,12 @@ discard block |
||
1343 | 1343 | $query = 'INSERT INTO aircraft_block (callSign,Source) VALUES (:callSign,:source)'; |
1344 | 1344 | try { |
1345 | 1345 | $sth = $Connection->db->prepare($query); |
1346 | - $sth->execute(array(':callSign' => trim($data),':source' => 'website_fam')); |
|
1347 | - } catch(PDOException $e) { |
|
1346 | + $sth->execute(array(':callSign' => trim($data), ':source' => 'website_fam')); |
|
1347 | + } catch (PDOException $e) { |
|
1348 | 1348 | if ($globalDebug) echo "error: ".$e->getMessage()." - data: ".$data; |
1349 | 1349 | die(); |
1350 | 1350 | } |
1351 | - if ($globalTransaction && $i % 2000 == 0) { |
|
1351 | + if ($globalTransaction && $i%2000 == 0) { |
|
1352 | 1352 | $Connection->db->commit(); |
1353 | 1353 | if ($globalDebug) echo '.'; |
1354 | 1354 | $Connection->db->beginTransaction(); |
@@ -1368,7 +1368,7 @@ discard block |
||
1368 | 1368 | $Connection = new Connection(); |
1369 | 1369 | $sth = $Connection->db->prepare($query); |
1370 | 1370 | $sth->execute(); |
1371 | - } catch(PDOException $e) { |
|
1371 | + } catch (PDOException $e) { |
|
1372 | 1372 | return "error : ".$e->getMessage(); |
1373 | 1373 | } |
1374 | 1374 | |
@@ -1389,8 +1389,8 @@ discard block |
||
1389 | 1389 | $query = 'INSERT INTO marine_identity (mmsi,imo,call_sign,ship_name,length,gross_tonnage,dead_weight,width,country,engine_power,type) VALUES (:mmsi,:imo,:call_sign,:ship_name,:length,:gross_tonnage,:dead_weight,:width,:country,:engine_power,:type)'; |
1390 | 1390 | try { |
1391 | 1391 | $sth = $Connection->db->prepare($query); |
1392 | - $sth->execute(array(':mmsi' => $data[0],':imo' => $data[1],':call_sign' => $data[2],':ship_name' => $data[3], ':length' => $data[4],':gross_tonnage' => $data[5],':dead_weight' => $data[6],':width' => $data[7],':country' => $data[8],':engine_power' => $data[9],':type' => $data[10])); |
|
1393 | - } catch(PDOException $e) { |
|
1392 | + $sth->execute(array(':mmsi' => $data[0], ':imo' => $data[1], ':call_sign' => $data[2], ':ship_name' => $data[3], ':length' => $data[4], ':gross_tonnage' => $data[5], ':dead_weight' => $data[6], ':width' => $data[7], ':country' => $data[8], ':engine_power' => $data[9], ':type' => $data[10])); |
|
1393 | + } catch (PDOException $e) { |
|
1394 | 1394 | return "error : ".$e->getMessage(); |
1395 | 1395 | } |
1396 | 1396 | } |
@@ -1409,7 +1409,7 @@ discard block |
||
1409 | 1409 | $Connection = new Connection(); |
1410 | 1410 | $sth = $Connection->db->prepare($query); |
1411 | 1411 | $sth->execute(); |
1412 | - } catch(PDOException $e) { |
|
1412 | + } catch (PDOException $e) { |
|
1413 | 1413 | return "error : ".$e->getMessage(); |
1414 | 1414 | } |
1415 | 1415 | $delimiter = "\t"; |
@@ -1426,8 +1426,8 @@ discard block |
||
1426 | 1426 | VALUES (:name, :name_alternate, :country_un, :country_owner, :owner, :users, :purpose, :purpose_detailed, :orbit, :type, :longitude_geo, :perigee, :apogee, :eccentricity, :inclination, :period, :launch_mass, :dry_mass, :power, :launch_date, :lifetime, :contractor, :country_contractor, :launch_site, :launch_vehicule, :cospar, :norad, :comments, :source_orbital, :sources)'; |
1427 | 1427 | try { |
1428 | 1428 | $sth = $Connection->db->prepare($query); |
1429 | - $sth->execute(array(':name' => $data[0], ':name_alternate' => $data[1], ':country_un' => $data[2], ':country_owner' => $data[3], ':owner' => $data[4], ':users' => $data[5], ':purpose' => $data[6], ':purpose_detailed' => $data[7], ':orbit' => $data[8], ':type' => $data[9], ':longitude_geo' => $data[10], ':perigee' => !empty($data[11]) ? $data[11] : NULL, ':apogee' => !empty($data[12]) ? $data[12] : NULL, ':eccentricity' => $data[13], ':inclination' => $data[14], ':period' => !empty($data[15]) ? $data[15] : NULL, ':launch_mass' => !empty($data[16]) ? $data[16] : NULL, ':dry_mass' => !empty($data[17]) ? $data[17] : NULL, ':power' => !empty($data[18]) ? $data[18] : NULL, ':launch_date' => $data[19], ':lifetime' => $data[20], ':contractor' => $data[21],':country_contractor' => $data[22], ':launch_site' => $data[23], ':launch_vehicule' => $data[24], ':cospar' => $data[25], ':norad' => $data[26], ':comments' => $data[27], ':source_orbital' => $data[28], ':sources' => $data[29])); |
|
1430 | - } catch(PDOException $e) { |
|
1429 | + $sth->execute(array(':name' => $data[0], ':name_alternate' => $data[1], ':country_un' => $data[2], ':country_owner' => $data[3], ':owner' => $data[4], ':users' => $data[5], ':purpose' => $data[6], ':purpose_detailed' => $data[7], ':orbit' => $data[8], ':type' => $data[9], ':longitude_geo' => $data[10], ':perigee' => !empty($data[11]) ? $data[11] : NULL, ':apogee' => !empty($data[12]) ? $data[12] : NULL, ':eccentricity' => $data[13], ':inclination' => $data[14], ':period' => !empty($data[15]) ? $data[15] : NULL, ':launch_mass' => !empty($data[16]) ? $data[16] : NULL, ':dry_mass' => !empty($data[17]) ? $data[17] : NULL, ':power' => !empty($data[18]) ? $data[18] : NULL, ':launch_date' => $data[19], ':lifetime' => $data[20], ':contractor' => $data[21], ':country_contractor' => $data[22], ':launch_site' => $data[23], ':launch_vehicule' => $data[24], ':cospar' => $data[25], ':norad' => $data[26], ':comments' => $data[27], ':source_orbital' => $data[28], ':sources' => $data[29])); |
|
1430 | + } catch (PDOException $e) { |
|
1431 | 1431 | return "error : ".$e->getMessage(); |
1432 | 1432 | } |
1433 | 1433 | } |
@@ -1446,7 +1446,7 @@ discard block |
||
1446 | 1446 | $Connection = new Connection(); |
1447 | 1447 | $sth = $Connection->db->prepare($query); |
1448 | 1448 | $sth->execute(); |
1449 | - } catch(PDOException $e) { |
|
1449 | + } catch (PDOException $e) { |
|
1450 | 1450 | return "error : ".$e->getMessage(); |
1451 | 1451 | } |
1452 | 1452 | |
@@ -1462,7 +1462,7 @@ discard block |
||
1462 | 1462 | try { |
1463 | 1463 | $sth = $Connection->db->prepare($query); |
1464 | 1464 | $sth->execute(array(':icao' => $icao)); |
1465 | - } catch(PDOException $e) { |
|
1465 | + } catch (PDOException $e) { |
|
1466 | 1466 | return "error : ".$e->getMessage(); |
1467 | 1467 | } |
1468 | 1468 | } |
@@ -1473,7 +1473,7 @@ discard block |
||
1473 | 1473 | return ''; |
1474 | 1474 | } |
1475 | 1475 | |
1476 | - public static function tle($filename,$tletype) { |
|
1476 | + public static function tle($filename, $tletype) { |
|
1477 | 1477 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
1478 | 1478 | global $tmp_dir, $globalTransaction; |
1479 | 1479 | //$Spotter = new Spotter(); |
@@ -1483,7 +1483,7 @@ discard block |
||
1483 | 1483 | $Connection = new Connection(); |
1484 | 1484 | $sth = $Connection->db->prepare($query); |
1485 | 1485 | $sth->execute(array(':source' => $filename)); |
1486 | - } catch(PDOException $e) { |
|
1486 | + } catch (PDOException $e) { |
|
1487 | 1487 | return "error : ".$e->getMessage(); |
1488 | 1488 | } |
1489 | 1489 | |
@@ -1508,8 +1508,8 @@ discard block |
||
1508 | 1508 | $query = 'INSERT INTO tle (tle_name,tle_tle1,tle_tle2,tle_type,tle_source) VALUES (:name, :tle1, :tle2, :type, :source)'; |
1509 | 1509 | try { |
1510 | 1510 | $sth = $Connection->db->prepare($query); |
1511 | - $sth->execute(array(':name' => $dbdata['name'],':tle1' => $dbdata['tle1'],':tle2' => $dbdata['tle2'], ':type' => $tletype,':source' => $filename)); |
|
1512 | - } catch(PDOException $e) { |
|
1511 | + $sth->execute(array(':name' => $dbdata['name'], ':tle1' => $dbdata['tle1'], ':tle2' => $dbdata['tle2'], ':type' => $tletype, ':source' => $filename)); |
|
1512 | + } catch (PDOException $e) { |
|
1513 | 1513 | return "error : ".$e->getMessage(); |
1514 | 1514 | } |
1515 | 1515 | |
@@ -1530,7 +1530,7 @@ discard block |
||
1530 | 1530 | $Connection = new Connection(); |
1531 | 1531 | $sth = $Connection->db->prepare($query); |
1532 | 1532 | $sth->execute(array(':source' => $filename)); |
1533 | - } catch(PDOException $e) { |
|
1533 | + } catch (PDOException $e) { |
|
1534 | 1534 | return "error : ".$e->getMessage(); |
1535 | 1535 | } |
1536 | 1536 | |
@@ -1541,13 +1541,13 @@ discard block |
||
1541 | 1541 | $i = 0; |
1542 | 1542 | //$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE); |
1543 | 1543 | //$Connection->db->beginTransaction(); |
1544 | - while (($data = fgetcsv($handle, 1000,"\t")) !== FALSE) |
|
1544 | + while (($data = fgetcsv($handle, 1000, "\t")) !== FALSE) |
|
1545 | 1545 | { |
1546 | 1546 | if ($i > 0 && $data[0] != '') { |
1547 | 1547 | $sources = trim($data[28].' '.$data[29].' '.$data[30].' '.$data[31].' '.$data[32].' '.$data[33]); |
1548 | - $period = str_replace(',','',$data[14]); |
|
1549 | - if (!empty($period) && strpos($period,'days')) $period = str_replace(' days','',$period)*24*60; |
|
1550 | - if ($data[18] != '') $launch_date = date('Y-m-d',strtotime($data[18])); |
|
1548 | + $period = str_replace(',', '', $data[14]); |
|
1549 | + if (!empty($period) && strpos($period, 'days')) $period = str_replace(' days', '', $period)*24*60; |
|
1550 | + if ($data[18] != '') $launch_date = date('Y-m-d', strtotime($data[18])); |
|
1551 | 1551 | else $launch_date = NULL; |
1552 | 1552 | $data = array_map(function($value) { |
1553 | 1553 | return trim($value) === '' ? null : $value; |
@@ -1557,8 +1557,8 @@ discard block |
||
1557 | 1557 | VALUES (:name, :name_alternate, :country_un, :country_owner, :owner, :users, :purpose, :purpose_detailed, :orbit, :type, :longitude_geo, :perigee, :apogee, :eccentricity, :inclination, :period, :launch_mass, :dry_mass, :power, :launch_date, :lifetime, :contractor, :country_contractor, :launch_site, :launch_vehicule, :cospar, :norad, :comments, :source_orbital, :sources)'; |
1558 | 1558 | try { |
1559 | 1559 | $sth = $Connection->db->prepare($query); |
1560 | - $sth->execute(array(':name' => $data[0], ':name_alternate' => '', ':country_un' => $data[1], ':country_owner' => $data[2], ':owner' => $data[3], ':users' => $data[4], ':purpose' => $data[5], ':purpose_detailed' => $data[6], ':orbit' => $data[7], ':type' => $data[8], ':longitude_geo' => $data[9], ':perigee' => !empty($data[10]) ? str_replace(',','',$data[10]) : NULL, ':apogee' => !empty($data[11]) ? str_replace(',','',$data[11]) : NULL, ':eccentricity' => $data[12], ':inclination' => $data[13], ':period' => !empty($period) ? $period : NULL, ':launch_mass' => !empty($data[15]) ? str_replace(array('+',','),'',$data[15]) : NULL, ':dry_mass' => !empty($data[16]) ? str_replace(array(',','-1900',' (BOL)',' (EOL)'),'',$data[16]) : NULL, ':power' => !empty($data[17]) ? str_replace(array(',',' (BOL)',' (EOL)'),'',$data[17]) : NULL, ':launch_date' => $launch_date, ':lifetime' => $data[19], ':contractor' => $data[20],':country_contractor' => $data[21], ':launch_site' => $data[22], ':launch_vehicule' => $data[23], ':cospar' => $data[24], ':norad' => $data[25], ':comments' => $data[26], ':source_orbital' => $data[27], ':sources' => $sources)); |
|
1561 | - } catch(PDOException $e) { |
|
1560 | + $sth->execute(array(':name' => $data[0], ':name_alternate' => '', ':country_un' => $data[1], ':country_owner' => $data[2], ':owner' => $data[3], ':users' => $data[4], ':purpose' => $data[5], ':purpose_detailed' => $data[6], ':orbit' => $data[7], ':type' => $data[8], ':longitude_geo' => $data[9], ':perigee' => !empty($data[10]) ? str_replace(',', '', $data[10]) : NULL, ':apogee' => !empty($data[11]) ? str_replace(',', '', $data[11]) : NULL, ':eccentricity' => $data[12], ':inclination' => $data[13], ':period' => !empty($period) ? $period : NULL, ':launch_mass' => !empty($data[15]) ? str_replace(array('+', ','), '', $data[15]) : NULL, ':dry_mass' => !empty($data[16]) ? str_replace(array(',', '-1900', ' (BOL)', ' (EOL)'), '', $data[16]) : NULL, ':power' => !empty($data[17]) ? str_replace(array(',', ' (BOL)', ' (EOL)'), '', $data[17]) : NULL, ':launch_date' => $launch_date, ':lifetime' => $data[19], ':contractor' => $data[20], ':country_contractor' => $data[21], ':launch_site' => $data[22], ':launch_vehicule' => $data[23], ':cospar' => $data[24], ':norad' => $data[25], ':comments' => $data[26], ':source_orbital' => $data[27], ':sources' => $sources)); |
|
1561 | + } catch (PDOException $e) { |
|
1562 | 1562 | return "error : ".$e->getMessage(); |
1563 | 1563 | } |
1564 | 1564 | } |
@@ -1598,7 +1598,7 @@ discard block |
||
1598 | 1598 | 'EGYP' => array('country' => 'Egypt', 'owner' => ''), |
1599 | 1599 | 'ESA' => array('country' => 'Multinational', 'owner' => 'European Space Agency'), |
1600 | 1600 | 'ESRO' => array('country' => 'Multinational', 'owner' => 'European Space Research Organization'), |
1601 | - 'EST' => array('country' => 'Estonia','owner' => ''), |
|
1601 | + 'EST' => array('country' => 'Estonia', 'owner' => ''), |
|
1602 | 1602 | 'EUME' => array('country' => 'Multinational', 'owner' => 'EUMETSAT (European Organization for the Exploitation of Meteorological Satellites)'), |
1603 | 1603 | 'EUTE' => array('country' => 'Multinational', 'owner' => 'European Telecommunications Satellite Consortium (EUTELSAT)'), |
1604 | 1604 | 'FGER' => array('country' => 'France/Germany', 'owner' => ''), |
@@ -1722,10 +1722,10 @@ discard block |
||
1722 | 1722 | { |
1723 | 1723 | if ($data != '') { |
1724 | 1724 | $result = array(); |
1725 | - $result['cospar'] = trim(substr($data,0,11)); |
|
1726 | - $result['norad'] = trim(substr($data,13,6)); |
|
1727 | - $result['operational'] = trim(substr($data,21,1)); |
|
1728 | - $result['name'] = trim(substr($data,23,24)); |
|
1725 | + $result['cospar'] = trim(substr($data, 0, 11)); |
|
1726 | + $result['norad'] = trim(substr($data, 13, 6)); |
|
1727 | + $result['operational'] = trim(substr($data, 21, 1)); |
|
1728 | + $result['name'] = trim(substr($data, 23, 24)); |
|
1729 | 1729 | /* |
1730 | 1730 | * R/B(1) = Rocket body, first stage |
1731 | 1731 | * R/B(2) = Rocket body, second stage |
@@ -1737,28 +1737,28 @@ discard block |
||
1737 | 1737 | * An ampersand (&) indicates two or more objects are attached |
1738 | 1738 | */ |
1739 | 1739 | |
1740 | - $owner_code = trim(substr($data,49,5)); |
|
1740 | + $owner_code = trim(substr($data, 49, 5)); |
|
1741 | 1741 | |
1742 | 1742 | if (!isset($satcat_sources[$owner_code]) && $owner_code != 'TBD') { |
1743 | 1743 | if ($globalDebug) echo $data.'owner_code: '.$owner_code."\n"; |
1744 | 1744 | } |
1745 | - if (!isset($satcat_launch_site[trim(substr($data,68,5))])) { |
|
1746 | - if ($globalDebug) echo 'launch_site_code: '.trim(substr($data,68,5))."\n"; |
|
1745 | + if (!isset($satcat_launch_site[trim(substr($data, 68, 5))])) { |
|
1746 | + if ($globalDebug) echo 'launch_site_code: '.trim(substr($data, 68, 5))."\n"; |
|
1747 | 1747 | } |
1748 | 1748 | |
1749 | - if ($owner_code != 'TBD' && isset($satcat_sources[$owner_code]) && isset($satcat_launch_site[trim(substr($data,68,5))])) { |
|
1749 | + if ($owner_code != 'TBD' && isset($satcat_sources[$owner_code]) && isset($satcat_launch_site[trim(substr($data, 68, 5))])) { |
|
1750 | 1750 | $result['country_owner'] = $satcat_sources[$owner_code]['country']; |
1751 | 1751 | $result['owner'] = $satcat_sources[$owner_code]['owner']; |
1752 | - $result['launch_date'] = trim(substr($data,56,10)); |
|
1753 | - $launch_site_code = trim(substr($data,68,5)); |
|
1752 | + $result['launch_date'] = trim(substr($data, 56, 10)); |
|
1753 | + $launch_site_code = trim(substr($data, 68, 5)); |
|
1754 | 1754 | $result['launch_site'] = $satcat_launch_site[$launch_site_code]; |
1755 | - $result['lifetime'] = trim(substr($data,75,10)); |
|
1756 | - $result['period'] = trim(substr($data,87,7)); |
|
1757 | - $result['inclination'] = trim(substr($data,96,5)); |
|
1758 | - $result['apogee'] = trim(substr($data,103,6)); |
|
1759 | - $result['perigee'] = trim(substr($data,111,6)); |
|
1755 | + $result['lifetime'] = trim(substr($data, 75, 10)); |
|
1756 | + $result['period'] = trim(substr($data, 87, 7)); |
|
1757 | + $result['inclination'] = trim(substr($data, 96, 5)); |
|
1758 | + $result['apogee'] = trim(substr($data, 103, 6)); |
|
1759 | + $result['perigee'] = trim(substr($data, 111, 6)); |
|
1760 | 1760 | //$result['radarcross'] = trim(substr($data,119,8)); |
1761 | - $result['status'] = trim(substr($data,129,3)); |
|
1761 | + $result['status'] = trim(substr($data, 129, 3)); |
|
1762 | 1762 | //print_r($result); |
1763 | 1763 | $result = array_map(function($value) { |
1764 | 1764 | return trim($value) === '' ? null : $value; |
@@ -1771,7 +1771,7 @@ discard block |
||
1771 | 1771 | $sth = $Connection->db->prepare($query); |
1772 | 1772 | $sth->execute(array(':cospar' => $result['cospar'])); |
1773 | 1773 | $exist = $sth->fetchAll(PDO::FETCH_ASSOC); |
1774 | - } catch(PDOException $e) { |
|
1774 | + } catch (PDOException $e) { |
|
1775 | 1775 | return "error : ".$e->getMessage(); |
1776 | 1776 | } |
1777 | 1777 | if (empty($exist)) { |
@@ -1783,10 +1783,10 @@ discard block |
||
1783 | 1783 | ':name' => $result['name'], ':name_alternate' => '', ':country_un' => '', ':country_owner' => $result['country_owner'], ':owner' => $result['owner'], ':users' => '', ':purpose' => '', ':purpose_detailed' => '', ':orbit' => $result['status'], |
1784 | 1784 | ':type' => '', ':longitude_geo' => NULL, ':perigee' => !empty($result['perigee']) ? $result['perigee'] : NULL, ':apogee' => !empty($result['apogee']) ? $result['apogee'] : NULL, ':eccentricity' => NULL, ':inclination' => $result['inclination'], |
1785 | 1785 | ':period' => !empty($result['period']) ? $result['period'] : NULL, ':launch_mass' => NULL, ':dry_mass' => NULL, ':power' => NULL, ':launch_date' => $result['launch_date'], ':lifetime' => $result['lifetime'], |
1786 | - ':contractor' => '',':country_contractor' => '', ':launch_site' => $result['launch_site'], ':launch_vehicule' => '', ':cospar' => $result['cospar'], ':norad' => $result['norad'], ':comments' => '', ':source_orbital' => '', ':sources' => '' |
|
1786 | + ':contractor' => '', ':country_contractor' => '', ':launch_site' => $result['launch_site'], ':launch_vehicule' => '', ':cospar' => $result['cospar'], ':norad' => $result['norad'], ':comments' => '', ':source_orbital' => '', ':sources' => '' |
|
1787 | 1787 | ) |
1788 | 1788 | ); |
1789 | - } catch(PDOException $e) { |
|
1789 | + } catch (PDOException $e) { |
|
1790 | 1790 | return "error : ".$e->getMessage(); |
1791 | 1791 | } |
1792 | 1792 | } elseif ($exist[0]['name'] != $result['name'] && $exist[0]['name_alternate'] != $result['name']) { |
@@ -1794,8 +1794,8 @@ discard block |
||
1794 | 1794 | try { |
1795 | 1795 | $Connection = new Connection(); |
1796 | 1796 | $sth = $Connection->db->prepare($query); |
1797 | - $sth->execute(array(':name_alternate' => $result['name'],':cospar' => $result['cospar'])); |
|
1798 | - } catch(PDOException $e) { |
|
1797 | + $sth->execute(array(':name_alternate' => $result['name'], ':cospar' => $result['cospar'])); |
|
1798 | + } catch (PDOException $e) { |
|
1799 | 1799 | return "error : ".$e->getMessage(); |
1800 | 1800 | } |
1801 | 1801 | } |
@@ -1914,13 +1914,13 @@ discard block |
||
1914 | 1914 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1915 | 1915 | { |
1916 | 1916 | $i++; |
1917 | - if($i > 3 && count($row) > 2) { |
|
1917 | + if ($i > 3 && count($row) > 2) { |
|
1918 | 1918 | $data = array_values(array_filter($row)); |
1919 | 1919 | $cntdata = count($data); |
1920 | 1920 | if ($cntdata > 10) { |
1921 | 1921 | $value = $data[9]; |
1922 | 1922 | |
1923 | - for ($i =10;$i < $cntdata;$i++) { |
|
1923 | + for ($i = 10; $i < $cntdata; $i++) { |
|
1924 | 1924 | $value .= ' '.$data[$i]; |
1925 | 1925 | } |
1926 | 1926 | $data[9] = $value; |
@@ -1930,8 +1930,8 @@ discard block |
||
1930 | 1930 | $query = 'INSERT INTO waypoints (name_begin,latitude_begin,longitude_begin,name_end,latitude_end,longitude_end,high,base,top,segment_name) VALUES (:name_begin, :latitude_begin, :longitude_begin, :name_end, :latitude_end, :longitude_end, :high, :base, :top, :segment_name)'; |
1931 | 1931 | try { |
1932 | 1932 | $sth = $Connection->db->prepare($query); |
1933 | - $sth->execute(array(':name_begin' => $data[0],':latitude_begin' => $data[1],':longitude_begin' => $data[2],':name_end' => $data[3], ':latitude_end' => $data[4], ':longitude_end' => $data[5], ':high' => $data[6], ':base' => $data[7], ':top' => $data[8], ':segment_name' => $data[9])); |
|
1934 | - } catch(PDOException $e) { |
|
1933 | + $sth->execute(array(':name_begin' => $data[0], ':latitude_begin' => $data[1], ':longitude_begin' => $data[2], ':name_end' => $data[3], ':latitude_end' => $data[4], ':longitude_end' => $data[5], ':high' => $data[6], ':base' => $data[7], ':top' => $data[8], ':segment_name' => $data[9])); |
|
1934 | + } catch (PDOException $e) { |
|
1935 | 1935 | return "error : ".$e->getMessage(); |
1936 | 1936 | } |
1937 | 1937 | } |
@@ -1948,22 +1948,22 @@ discard block |
||
1948 | 1948 | require_once(dirname(__FILE__).'/../require/class.Source.php'); |
1949 | 1949 | $delimiter = ','; |
1950 | 1950 | $Common = new Common(); |
1951 | - $Common->download('http://firms.modaps.eosdis.nasa.gov/active_fire/viirs/text/VNP14IMGTDL_NRT_Global_24h.csv',$tmp_dir.'fires.csv'); |
|
1951 | + $Common->download('http://firms.modaps.eosdis.nasa.gov/active_fire/viirs/text/VNP14IMGTDL_NRT_Global_24h.csv', $tmp_dir.'fires.csv'); |
|
1952 | 1952 | $Connection = new Connection(); |
1953 | 1953 | $Source = new Source(); |
1954 | 1954 | $Source->deleteLocationByType('fires'); |
1955 | 1955 | $i = 0; |
1956 | - if (($handle = fopen($tmp_dir.'fires.csv','r')) !== false) { |
|
1956 | + if (($handle = fopen($tmp_dir.'fires.csv', 'r')) !== false) { |
|
1957 | 1957 | if ($globalTransaction) $Connection->db->beginTransaction(); |
1958 | - while (($row = fgetcsv($handle,1000)) !== false) { |
|
1958 | + while (($row = fgetcsv($handle, 1000)) !== false) { |
|
1959 | 1959 | if ($i > 0 && $row[0] != '' && $row[8] != 'low') { |
1960 | - $description = array('bright_t14' => $row[2],'scan' => $row[3],'track' => $row[4],'sat' => $row[7],'confidence' => $row[8],'version' => $row[9],'bright_t15' => $row[10],'frp' => $row[11],'daynight' => $row[12]); |
|
1960 | + $description = array('bright_t14' => $row[2], 'scan' => $row[3], 'track' => $row[4], 'sat' => $row[7], 'confidence' => $row[8], 'version' => $row[9], 'bright_t15' => $row[10], 'frp' => $row[11], 'daynight' => $row[12]); |
|
1961 | 1961 | $query = "INSERT INTO source_location (name,latitude,longitude,altitude,country,city,logo,source,type,source_id,last_seen,location_id,description) VALUES (:name,:latitude,:longitude,:altitude,:country,:city,:logo,:source,:type,:source_id,:last_seen,:location_id,:description)"; |
1962 | - $query_values = array(':name' => '',':latitude' => $row[0], ':longitude' => $row[1],':altitude' => null,':city' => '',':country' => '',':logo' => 'fire.png',':source' => 'NASA',':type' => 'fires',':source_id' => 0,':last_seen' => $row[5].' '.substr($row[6],0,2).':'.substr($row[6],2,2),':location_id' => 0,':description' => json_encode($description)); |
|
1962 | + $query_values = array(':name' => '', ':latitude' => $row[0], ':longitude' => $row[1], ':altitude' => null, ':city' => '', ':country' => '', ':logo' => 'fire.png', ':source' => 'NASA', ':type' => 'fires', ':source_id' => 0, ':last_seen' => $row[5].' '.substr($row[6], 0, 2).':'.substr($row[6], 2, 2), ':location_id' => 0, ':description' => json_encode($description)); |
|
1963 | 1963 | try { |
1964 | 1964 | $sth = $Connection->db->prepare($query); |
1965 | 1965 | $sth->execute($query_values); |
1966 | - } catch(PDOException $e) { |
|
1966 | + } catch (PDOException $e) { |
|
1967 | 1967 | echo "error : ".$e->getMessage(); |
1968 | 1968 | } |
1969 | 1969 | } |
@@ -1982,7 +1982,7 @@ discard block |
||
1982 | 1982 | $Connection = new Connection(); |
1983 | 1983 | $sth = $Connection->db->prepare($query); |
1984 | 1984 | $sth->execute(); |
1985 | - } catch(PDOException $e) { |
|
1985 | + } catch (PDOException $e) { |
|
1986 | 1986 | return "error : ".$e->getMessage(); |
1987 | 1987 | } |
1988 | 1988 | $header = NULL; |
@@ -1993,12 +1993,12 @@ discard block |
||
1993 | 1993 | if ($globalTransaction) $Connection->db->beginTransaction(); |
1994 | 1994 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1995 | 1995 | { |
1996 | - if(count($row) > 1) { |
|
1996 | + if (count($row) > 1) { |
|
1997 | 1997 | $query = "INSERT INTO airlines (name,icao,active,forsource) VALUES (:name, :icao, 'Y','ivao')"; |
1998 | 1998 | try { |
1999 | 1999 | $sth = $Connection->db->prepare($query); |
2000 | - $sth->execute(array(':name' => $row[1],':icao' => $row[0])); |
|
2001 | - } catch(PDOException $e) { |
|
2000 | + $sth->execute(array(':name' => $row[1], ':icao' => $row[0])); |
|
2001 | + } catch (PDOException $e) { |
|
2002 | 2002 | return "error : ".$e->getMessage(); |
2003 | 2003 | } |
2004 | 2004 | } |
@@ -2018,21 +2018,21 @@ discard block |
||
2018 | 2018 | try { |
2019 | 2019 | $sth = $Connection->db->prepare($query); |
2020 | 2020 | $sth->execute(); |
2021 | - } catch(PDOException $e) { |
|
2021 | + } catch (PDOException $e) { |
|
2022 | 2022 | return "error : ".$e->getMessage(); |
2023 | 2023 | } |
2024 | 2024 | } |
2025 | 2025 | |
2026 | 2026 | |
2027 | - if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
2027 | + if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz', $tmp_dir.'airspace.sql'); |
|
2028 | 2028 | else { |
2029 | - update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
2029 | + update_db::gunzip('../db/pgsql/airspace.sql.gz', $tmp_dir.'airspace.sql'); |
|
2030 | 2030 | $query = "CREATE EXTENSION postgis"; |
2031 | - $Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']); |
|
2031 | + $Connection = new Connection(null, null, $_SESSION['database_root'], $_SESSION['database_rootpass']); |
|
2032 | 2032 | try { |
2033 | 2033 | $sth = $Connection->db->prepare($query); |
2034 | 2034 | $sth->execute(); |
2035 | - } catch(PDOException $e) { |
|
2035 | + } catch (PDOException $e) { |
|
2036 | 2036 | return "error : ".$e->getMessage(); |
2037 | 2037 | } |
2038 | 2038 | } |
@@ -2045,13 +2045,13 @@ discard block |
||
2045 | 2045 | include_once('class.create_db.php'); |
2046 | 2046 | require_once(dirname(__FILE__).'/../require/class.NOTAM.php'); |
2047 | 2047 | if ($globalDebug) echo "NOTAM from FlightAirMap website : Download..."; |
2048 | - update_db::download('http://data.flightairmap.com/data/notam.txt.gz.md5',$tmp_dir.'notam.txt.gz.md5'); |
|
2048 | + update_db::download('http://data.flightairmap.com/data/notam.txt.gz.md5', $tmp_dir.'notam.txt.gz.md5'); |
|
2049 | 2049 | $error = ''; |
2050 | 2050 | if (file_exists($tmp_dir.'notam.txt.gz.md5')) { |
2051 | - $notam_md5_file = explode(' ',file_get_contents($tmp_dir.'notam.txt.gz.md5')); |
|
2051 | + $notam_md5_file = explode(' ', file_get_contents($tmp_dir.'notam.txt.gz.md5')); |
|
2052 | 2052 | $notam_md5 = $notam_md5_file[0]; |
2053 | 2053 | if (!update_db::check_notam_version($notam_md5)) { |
2054 | - update_db::download('http://data.flightairmap.com/data/notam.txt.gz',$tmp_dir.'notam.txt.gz'); |
|
2054 | + update_db::download('http://data.flightairmap.com/data/notam.txt.gz', $tmp_dir.'notam.txt.gz'); |
|
2055 | 2055 | if (file_exists($tmp_dir.'notam.txt.gz')) { |
2056 | 2056 | if (md5_file($tmp_dir.'notam.txt.gz') == $notam_md5) { |
2057 | 2057 | if ($globalDebug) echo "Gunzip..."; |
@@ -2087,14 +2087,14 @@ discard block |
||
2087 | 2087 | try { |
2088 | 2088 | $sth = $Connection->db->prepare($query); |
2089 | 2089 | $sth->execute(); |
2090 | - } catch(PDOException $e) { |
|
2090 | + } catch (PDOException $e) { |
|
2091 | 2091 | echo "error : ".$e->getMessage(); |
2092 | 2092 | } |
2093 | 2093 | } |
2094 | 2094 | if ($globalDBdriver == 'mysql') { |
2095 | - update_db::gunzip('../db/countries.sql.gz',$tmp_dir.'countries.sql'); |
|
2095 | + update_db::gunzip('../db/countries.sql.gz', $tmp_dir.'countries.sql'); |
|
2096 | 2096 | } else { |
2097 | - update_db::gunzip('../db/pgsql/countries.sql.gz',$tmp_dir.'countries.sql'); |
|
2097 | + update_db::gunzip('../db/pgsql/countries.sql.gz', $tmp_dir.'countries.sql'); |
|
2098 | 2098 | } |
2099 | 2099 | $error = create_db::import_file($tmp_dir.'countries.sql'); |
2100 | 2100 | return $error; |
@@ -2107,7 +2107,7 @@ discard block |
||
2107 | 2107 | // update_db::unzip($tmp_dir.'AptNav.zip'); |
2108 | 2108 | // update_db::download('https://gitorious.org/fg/fgdata/raw/e81f8a15424a175a7b715f8f7eb8f4147b802a27:Navaids/awy.dat.gz',$tmp_dir.'awy.dat.gz'); |
2109 | 2109 | // update_db::download('http://sourceforge.net/p/flightgear/fgdata/ci/next/tree/Navaids/awy.dat.gz?format=raw',$tmp_dir.'awy.dat.gz','http://sourceforge.net'); |
2110 | - update_db::download('http://pkgs.fedoraproject.org/repo/extras/FlightGear-Atlas/awy.dat.gz/f530c9d1c4b31a288ba88dcc8224268b/awy.dat.gz',$tmp_dir.'awy.dat.gz','http://sourceforge.net'); |
|
2110 | + update_db::download('http://pkgs.fedoraproject.org/repo/extras/FlightGear-Atlas/awy.dat.gz/f530c9d1c4b31a288ba88dcc8224268b/awy.dat.gz', $tmp_dir.'awy.dat.gz', 'http://sourceforge.net'); |
|
2111 | 2111 | update_db::gunzip($tmp_dir.'awy.dat.gz'); |
2112 | 2112 | $error = update_db::waypoints($tmp_dir.'awy.dat'); |
2113 | 2113 | return $error; |
@@ -2128,7 +2128,7 @@ discard block |
||
2128 | 2128 | update_db::ivao_airlines($tmp_dir.'data/airlines.dat'); |
2129 | 2129 | if ($globalDebug) echo "Copy airlines logos to airlines images directory..."; |
2130 | 2130 | if (is_writable(dirname(__FILE__).'/../images/airlines')) { |
2131 | - if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo."; |
|
2131 | + if (!$Common->xcopy($tmp_dir.'logos/', dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo."; |
|
2132 | 2132 | } else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable"; |
2133 | 2133 | } else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed."; |
2134 | 2134 | } else $error = "ZIP module not loaded but required for IVAO."; |
@@ -2142,7 +2142,7 @@ discard block |
||
2142 | 2142 | global $tmp_dir, $globalDebug; |
2143 | 2143 | $error = ''; |
2144 | 2144 | if ($globalDebug) echo "Routes : Download..."; |
2145 | - update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz'); |
|
2145 | + update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz', $tmp_dir.'StandingData.sqb.gz'); |
|
2146 | 2146 | if (file_exists($tmp_dir.'StandingData.sqb.gz')) { |
2147 | 2147 | if ($globalDebug) echo "Gunzip..."; |
2148 | 2148 | update_db::gunzip($tmp_dir.'StandingData.sqb.gz'); |
@@ -2158,7 +2158,7 @@ discard block |
||
2158 | 2158 | global $tmp_dir, $globalDebug; |
2159 | 2159 | $error = ''; |
2160 | 2160 | if ($globalDebug) echo "Schedules Oneworld : Download..."; |
2161 | - update_db::download('http://data.flightairmap.com/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz'); |
|
2161 | + update_db::download('http://data.flightairmap.com/data/schedules/oneworld.csv.gz', $tmp_dir.'oneworld.csv.gz'); |
|
2162 | 2162 | if (file_exists($tmp_dir.'oneworld.csv.gz')) { |
2163 | 2163 | if ($globalDebug) echo "Gunzip..."; |
2164 | 2164 | update_db::gunzip($tmp_dir.'oneworld.csv.gz'); |
@@ -2174,7 +2174,7 @@ discard block |
||
2174 | 2174 | global $tmp_dir, $globalDebug; |
2175 | 2175 | $error = ''; |
2176 | 2176 | if ($globalDebug) echo "Schedules Skyteam : Download..."; |
2177 | - update_db::download('http://data.flightairmap.com/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz'); |
|
2177 | + update_db::download('http://data.flightairmap.com/data/schedules/skyteam.csv.gz', $tmp_dir.'skyteam.csv.gz'); |
|
2178 | 2178 | if (file_exists($tmp_dir.'skyteam.csv.gz')) { |
2179 | 2179 | if ($globalDebug) echo "Gunzip..."; |
2180 | 2180 | update_db::gunzip($tmp_dir.'skyteam.csv.gz'); |
@@ -2202,7 +2202,7 @@ discard block |
||
2202 | 2202 | */ |
2203 | 2203 | if ($globalDebug) echo "Modes : Download..."; |
2204 | 2204 | // update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb'); |
2205 | - update_db::download('http://data.flightairmap.com/data/BaseStation.sqb.gz',$tmp_dir.'BaseStation.sqb.gz'); |
|
2205 | + update_db::download('http://data.flightairmap.com/data/BaseStation.sqb.gz', $tmp_dir.'BaseStation.sqb.gz'); |
|
2206 | 2206 | |
2207 | 2207 | // if (file_exists($tmp_dir.'basestation_latest.zip')) { |
2208 | 2208 | if (file_exists($tmp_dir.'BaseStation.sqb.gz')) { |
@@ -2222,7 +2222,7 @@ discard block |
||
2222 | 2222 | public static function update_ModeS_faa() { |
2223 | 2223 | global $tmp_dir, $globalDebug; |
2224 | 2224 | if ($globalDebug) echo "Modes FAA: Download..."; |
2225 | - update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip',$tmp_dir.'ReleasableAircraft.zip'); |
|
2225 | + update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip', $tmp_dir.'ReleasableAircraft.zip'); |
|
2226 | 2226 | if (file_exists($tmp_dir.'ReleasableAircraft.zip')) { |
2227 | 2227 | if ($globalDebug) echo "Unzip..."; |
2228 | 2228 | update_db::unzip($tmp_dir.'ReleasableAircraft.zip'); |
@@ -2238,7 +2238,7 @@ discard block |
||
2238 | 2238 | public static function update_ModeS_flarm() { |
2239 | 2239 | global $tmp_dir, $globalDebug; |
2240 | 2240 | if ($globalDebug) echo "Modes Flarmnet: Download..."; |
2241 | - update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln'); |
|
2241 | + update_db::download('http://flarmnet.org/files/data.fln', $tmp_dir.'data.fln'); |
|
2242 | 2242 | if (file_exists($tmp_dir.'data.fln')) { |
2243 | 2243 | if ($globalDebug) echo "Add to DB..."; |
2244 | 2244 | $error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln'); |
@@ -2252,7 +2252,7 @@ discard block |
||
2252 | 2252 | public static function update_ModeS_ogn() { |
2253 | 2253 | global $tmp_dir, $globalDebug; |
2254 | 2254 | if ($globalDebug) echo "Modes OGN: Download..."; |
2255 | - update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv'); |
|
2255 | + update_db::download('http://ddb.glidernet.org/download/', $tmp_dir.'ogn.csv'); |
|
2256 | 2256 | if (file_exists($tmp_dir.'ogn.csv')) { |
2257 | 2257 | if ($globalDebug) echo "Add to DB..."; |
2258 | 2258 | $error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv'); |
@@ -2267,201 +2267,201 @@ discard block |
||
2267 | 2267 | global $tmp_dir, $globalDebug, $globalMasterSource; |
2268 | 2268 | |
2269 | 2269 | if ($globalDebug) echo "Owner France: Download..."; |
2270 | - update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv'); |
|
2270 | + update_db::download('http://antonakis.co.uk/registers/France.txt', $tmp_dir.'owner_f.csv'); |
|
2271 | 2271 | if (file_exists($tmp_dir.'owner_f.csv')) { |
2272 | 2272 | if ($globalDebug) echo "Add to DB..."; |
2273 | - $error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F'); |
|
2273 | + $error = update_db::retrieve_owner($tmp_dir.'owner_f.csv', 'F'); |
|
2274 | 2274 | } else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed."; |
2275 | 2275 | if ($error != '') { |
2276 | 2276 | return $error; |
2277 | 2277 | } elseif ($globalDebug) echo "Done\n"; |
2278 | 2278 | |
2279 | 2279 | if ($globalDebug) echo "Owner Ireland: Download..."; |
2280 | - update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv'); |
|
2280 | + update_db::download('http://antonakis.co.uk/registers/Ireland.txt', $tmp_dir.'owner_ei.csv'); |
|
2281 | 2281 | if (file_exists($tmp_dir.'owner_ei.csv')) { |
2282 | 2282 | if ($globalDebug) echo "Add to DB..."; |
2283 | - $error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI'); |
|
2283 | + $error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv', 'EI'); |
|
2284 | 2284 | } else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed."; |
2285 | 2285 | if ($error != '') { |
2286 | 2286 | return $error; |
2287 | 2287 | } elseif ($globalDebug) echo "Done\n"; |
2288 | 2288 | if ($globalDebug) echo "Owner Switzerland: Download..."; |
2289 | - update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv'); |
|
2289 | + update_db::download('http://antonakis.co.uk/registers/Switzerland.txt', $tmp_dir.'owner_hb.csv'); |
|
2290 | 2290 | if (file_exists($tmp_dir.'owner_hb.csv')) { |
2291 | 2291 | if ($globalDebug) echo "Add to DB..."; |
2292 | - $error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB'); |
|
2292 | + $error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv', 'HB'); |
|
2293 | 2293 | } else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed."; |
2294 | 2294 | if ($error != '') { |
2295 | 2295 | return $error; |
2296 | 2296 | } elseif ($globalDebug) echo "Done\n"; |
2297 | 2297 | if ($globalDebug) echo "Owner Czech Republic: Download..."; |
2298 | - update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv'); |
|
2298 | + update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt', $tmp_dir.'owner_ok.csv'); |
|
2299 | 2299 | if (file_exists($tmp_dir.'owner_ok.csv')) { |
2300 | 2300 | if ($globalDebug) echo "Add to DB..."; |
2301 | - $error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK'); |
|
2301 | + $error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv', 'OK'); |
|
2302 | 2302 | } else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed."; |
2303 | 2303 | if ($error != '') { |
2304 | 2304 | return $error; |
2305 | 2305 | } elseif ($globalDebug) echo "Done\n"; |
2306 | 2306 | if ($globalDebug) echo "Owner Australia: Download..."; |
2307 | - update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv'); |
|
2307 | + update_db::download('http://antonakis.co.uk/registers/Australia.txt', $tmp_dir.'owner_vh.csv'); |
|
2308 | 2308 | if (file_exists($tmp_dir.'owner_vh.csv')) { |
2309 | 2309 | if ($globalDebug) echo "Add to DB..."; |
2310 | - $error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH'); |
|
2310 | + $error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv', 'VH'); |
|
2311 | 2311 | } else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed."; |
2312 | 2312 | if ($error != '') { |
2313 | 2313 | return $error; |
2314 | 2314 | } elseif ($globalDebug) echo "Done\n"; |
2315 | 2315 | if ($globalDebug) echo "Owner Austria: Download..."; |
2316 | - update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv'); |
|
2316 | + update_db::download('http://antonakis.co.uk/registers/Austria.txt', $tmp_dir.'owner_oe.csv'); |
|
2317 | 2317 | if (file_exists($tmp_dir.'owner_oe.csv')) { |
2318 | 2318 | if ($globalDebug) echo "Add to DB..."; |
2319 | - $error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE'); |
|
2319 | + $error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv', 'OE'); |
|
2320 | 2320 | } else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed."; |
2321 | 2321 | if ($error != '') { |
2322 | 2322 | return $error; |
2323 | 2323 | } elseif ($globalDebug) echo "Done\n"; |
2324 | 2324 | if ($globalDebug) echo "Owner Chile: Download..."; |
2325 | - update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv'); |
|
2325 | + update_db::download('http://antonakis.co.uk/registers/Chile.txt', $tmp_dir.'owner_cc.csv'); |
|
2326 | 2326 | if (file_exists($tmp_dir.'owner_cc.csv')) { |
2327 | 2327 | if ($globalDebug) echo "Add to DB..."; |
2328 | - $error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC'); |
|
2328 | + $error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv', 'CC'); |
|
2329 | 2329 | } else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed."; |
2330 | 2330 | if ($error != '') { |
2331 | 2331 | return $error; |
2332 | 2332 | } elseif ($globalDebug) echo "Done\n"; |
2333 | 2333 | if ($globalDebug) echo "Owner Colombia: Download..."; |
2334 | - update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv'); |
|
2334 | + update_db::download('http://antonakis.co.uk/registers/Colombia.txt', $tmp_dir.'owner_hj.csv'); |
|
2335 | 2335 | if (file_exists($tmp_dir.'owner_hj.csv')) { |
2336 | 2336 | if ($globalDebug) echo "Add to DB..."; |
2337 | - $error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ'); |
|
2337 | + $error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv', 'HJ'); |
|
2338 | 2338 | } else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed."; |
2339 | 2339 | if ($error != '') { |
2340 | 2340 | return $error; |
2341 | 2341 | } elseif ($globalDebug) echo "Done\n"; |
2342 | 2342 | if ($globalDebug) echo "Owner Bosnia Herzegobina: Download..."; |
2343 | - update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv'); |
|
2343 | + update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt', $tmp_dir.'owner_e7.csv'); |
|
2344 | 2344 | if (file_exists($tmp_dir.'owner_e7.csv')) { |
2345 | 2345 | if ($globalDebug) echo "Add to DB..."; |
2346 | - $error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7'); |
|
2346 | + $error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv', 'E7'); |
|
2347 | 2347 | } else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed."; |
2348 | 2348 | if ($error != '') { |
2349 | 2349 | return $error; |
2350 | 2350 | } elseif ($globalDebug) echo "Done\n"; |
2351 | 2351 | if ($globalDebug) echo "Owner Brazil: Download..."; |
2352 | - update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv'); |
|
2352 | + update_db::download('http://antonakis.co.uk/registers/Brazil.txt', $tmp_dir.'owner_pp.csv'); |
|
2353 | 2353 | if (file_exists($tmp_dir.'owner_pp.csv')) { |
2354 | 2354 | if ($globalDebug) echo "Add to DB..."; |
2355 | - $error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP'); |
|
2355 | + $error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv', 'PP'); |
|
2356 | 2356 | } else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed."; |
2357 | 2357 | if ($error != '') { |
2358 | 2358 | return $error; |
2359 | 2359 | } elseif ($globalDebug) echo "Done\n"; |
2360 | 2360 | if ($globalDebug) echo "Owner Cayman Islands: Download..."; |
2361 | - update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv'); |
|
2361 | + update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt', $tmp_dir.'owner_vp.csv'); |
|
2362 | 2362 | if (file_exists($tmp_dir.'owner_vp.csv')) { |
2363 | 2363 | if ($globalDebug) echo "Add to DB..."; |
2364 | - $error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP'); |
|
2364 | + $error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv', 'VP'); |
|
2365 | 2365 | } else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed."; |
2366 | 2366 | if ($error != '') { |
2367 | 2367 | return $error; |
2368 | 2368 | } elseif ($globalDebug) echo "Done\n"; |
2369 | 2369 | if ($globalDebug) echo "Owner Croatia: Download..."; |
2370 | - update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv'); |
|
2370 | + update_db::download('http://antonakis.co.uk/registers/Croatia.txt', $tmp_dir.'owner_9a.csv'); |
|
2371 | 2371 | if (file_exists($tmp_dir.'owner_9a.csv')) { |
2372 | 2372 | if ($globalDebug) echo "Add to DB..."; |
2373 | - $error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A'); |
|
2373 | + $error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv', '9A'); |
|
2374 | 2374 | } else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed."; |
2375 | 2375 | if ($error != '') { |
2376 | 2376 | return $error; |
2377 | 2377 | } elseif ($globalDebug) echo "Done\n"; |
2378 | 2378 | if ($globalDebug) echo "Owner Luxembourg: Download..."; |
2379 | - update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv'); |
|
2379 | + update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt', $tmp_dir.'owner_lx.csv'); |
|
2380 | 2380 | if (file_exists($tmp_dir.'owner_lx.csv')) { |
2381 | 2381 | if ($globalDebug) echo "Add to DB..."; |
2382 | - $error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX'); |
|
2382 | + $error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv', 'LX'); |
|
2383 | 2383 | } else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed."; |
2384 | 2384 | if ($error != '') { |
2385 | 2385 | return $error; |
2386 | 2386 | } elseif ($globalDebug) echo "Done\n"; |
2387 | 2387 | if ($globalDebug) echo "Owner Maldives: Download..."; |
2388 | - update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv'); |
|
2388 | + update_db::download('http://antonakis.co.uk/registers/Maldives.txt', $tmp_dir.'owner_8q.csv'); |
|
2389 | 2389 | if (file_exists($tmp_dir.'owner_8q.csv')) { |
2390 | 2390 | if ($globalDebug) echo "Add to DB..."; |
2391 | - $error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q'); |
|
2391 | + $error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv', '8Q'); |
|
2392 | 2392 | } else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed."; |
2393 | 2393 | if ($error != '') { |
2394 | 2394 | return $error; |
2395 | 2395 | } elseif ($globalDebug) echo "Done\n"; |
2396 | 2396 | if ($globalDebug) echo "Owner New Zealand: Download..."; |
2397 | - update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv'); |
|
2397 | + update_db::download('http://antonakis.co.uk/registers/NewZealand.txt', $tmp_dir.'owner_zk.csv'); |
|
2398 | 2398 | if (file_exists($tmp_dir.'owner_zk.csv')) { |
2399 | 2399 | if ($globalDebug) echo "Add to DB..."; |
2400 | - $error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK'); |
|
2400 | + $error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv', 'ZK'); |
|
2401 | 2401 | } else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed."; |
2402 | 2402 | if ($error != '') { |
2403 | 2403 | return $error; |
2404 | 2404 | } elseif ($globalDebug) echo "Done\n"; |
2405 | 2405 | if ($globalDebug) echo "Owner Papua New Guinea: Download..."; |
2406 | - update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv'); |
|
2406 | + update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt', $tmp_dir.'owner_p2.csv'); |
|
2407 | 2407 | if (file_exists($tmp_dir.'owner_p2.csv')) { |
2408 | 2408 | if ($globalDebug) echo "Add to DB..."; |
2409 | - $error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2'); |
|
2409 | + $error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv', 'P2'); |
|
2410 | 2410 | } else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed."; |
2411 | 2411 | if ($error != '') { |
2412 | 2412 | return $error; |
2413 | 2413 | } elseif ($globalDebug) echo "Done\n"; |
2414 | 2414 | if ($globalDebug) echo "Owner Slovakia: Download..."; |
2415 | - update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv'); |
|
2415 | + update_db::download('http://antonakis.co.uk/registers/Slovakia.txt', $tmp_dir.'owner_om.csv'); |
|
2416 | 2416 | if (file_exists($tmp_dir.'owner_om.csv')) { |
2417 | 2417 | if ($globalDebug) echo "Add to DB..."; |
2418 | - $error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM'); |
|
2418 | + $error = update_db::retrieve_owner($tmp_dir.'owner_om.csv', 'OM'); |
|
2419 | 2419 | } else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed."; |
2420 | 2420 | if ($error != '') { |
2421 | 2421 | return $error; |
2422 | 2422 | } elseif ($globalDebug) echo "Done\n"; |
2423 | 2423 | if ($globalDebug) echo "Owner Ecuador: Download..."; |
2424 | - update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv'); |
|
2424 | + update_db::download('http://antonakis.co.uk/registers/Ecuador.txt', $tmp_dir.'owner_hc.csv'); |
|
2425 | 2425 | if (file_exists($tmp_dir.'owner_hc.csv')) { |
2426 | 2426 | if ($globalDebug) echo "Add to DB..."; |
2427 | - $error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC'); |
|
2427 | + $error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv', 'HC'); |
|
2428 | 2428 | } else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed."; |
2429 | 2429 | if ($error != '') { |
2430 | 2430 | return $error; |
2431 | 2431 | } elseif ($globalDebug) echo "Done\n"; |
2432 | 2432 | if ($globalDebug) echo "Owner Iceland: Download..."; |
2433 | - update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv'); |
|
2433 | + update_db::download('http://antonakis.co.uk/registers/Iceland.txt', $tmp_dir.'owner_tf.csv'); |
|
2434 | 2434 | if (file_exists($tmp_dir.'owner_tf.csv')) { |
2435 | 2435 | if ($globalDebug) echo "Add to DB..."; |
2436 | - $error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF'); |
|
2436 | + $error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv', 'TF'); |
|
2437 | 2437 | } else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed."; |
2438 | 2438 | if ($error != '') { |
2439 | 2439 | return $error; |
2440 | 2440 | } elseif ($globalDebug) echo "Done\n"; |
2441 | 2441 | if ($globalDebug) echo "Owner Isle of Man: Download..."; |
2442 | - update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt',$tmp_dir.'owner_m.csv'); |
|
2442 | + update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt', $tmp_dir.'owner_m.csv'); |
|
2443 | 2443 | if (file_exists($tmp_dir.'owner_m.csv')) { |
2444 | 2444 | if ($globalDebug) echo "Add to DB..."; |
2445 | - $error = update_db::retrieve_owner($tmp_dir.'owner_m.csv','M'); |
|
2445 | + $error = update_db::retrieve_owner($tmp_dir.'owner_m.csv', 'M'); |
|
2446 | 2446 | } else $error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed."; |
2447 | 2447 | if ($error != '') { |
2448 | 2448 | return $error; |
2449 | 2449 | } elseif ($globalDebug) echo "Done\n"; |
2450 | 2450 | if ($globalMasterSource) { |
2451 | 2451 | if ($globalDebug) echo "ModeS Netherlands: Download..."; |
2452 | - update_db::download('http://antonakis.co.uk/registers/Netherlands.txt',$tmp_dir.'owner_ph.csv'); |
|
2452 | + update_db::download('http://antonakis.co.uk/registers/Netherlands.txt', $tmp_dir.'owner_ph.csv'); |
|
2453 | 2453 | if (file_exists($tmp_dir.'owner_ph.csv')) { |
2454 | 2454 | if ($globalDebug) echo "Add to DB..."; |
2455 | - $error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv','PH'); |
|
2455 | + $error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv', 'PH'); |
|
2456 | 2456 | } else $error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed."; |
2457 | 2457 | if ($error != '') { |
2458 | 2458 | return $error; |
2459 | 2459 | } elseif ($globalDebug) echo "Done\n"; |
2460 | 2460 | if ($globalDebug) echo "ModeS Denmark: Download..."; |
2461 | - update_db::download('http://antonakis.co.uk/registers/Denmark.txt',$tmp_dir.'owner_oy.csv'); |
|
2461 | + update_db::download('http://antonakis.co.uk/registers/Denmark.txt', $tmp_dir.'owner_oy.csv'); |
|
2462 | 2462 | if (file_exists($tmp_dir.'owner_oy.csv')) { |
2463 | 2463 | if ($globalDebug) echo "Add to DB..."; |
2464 | - $error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv','OY'); |
|
2464 | + $error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv', 'OY'); |
|
2465 | 2465 | } else $error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed."; |
2466 | 2466 | if ($error != '') { |
2467 | 2467 | return $error; |
@@ -2474,7 +2474,7 @@ discard block |
||
2474 | 2474 | global $tmp_dir, $globalDebug; |
2475 | 2475 | $error = ''; |
2476 | 2476 | if ($globalDebug) echo "Translation : Download..."; |
2477 | - update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip'); |
|
2477 | + update_db::download('http://www.acarsd.org/download/translation.php', $tmp_dir.'translation.zip'); |
|
2478 | 2478 | if (file_exists($tmp_dir.'translation.zip')) { |
2479 | 2479 | if ($globalDebug) echo "Unzip..."; |
2480 | 2480 | update_db::unzip($tmp_dir.'translation.zip'); |
@@ -2491,10 +2491,10 @@ discard block |
||
2491 | 2491 | global $tmp_dir, $globalDebug; |
2492 | 2492 | $error = ''; |
2493 | 2493 | if ($globalDebug) echo "Translation from FlightAirMap website : Download..."; |
2494 | - update_db::download('http://data.flightairmap.com/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz'); |
|
2495 | - update_db::download('http://data.flightairmap.com/data/translation.tsv.gz.md5',$tmp_dir.'translation.tsv.gz.md5'); |
|
2494 | + update_db::download('http://data.flightairmap.com/data/translation.tsv.gz', $tmp_dir.'translation.tsv.gz'); |
|
2495 | + update_db::download('http://data.flightairmap.com/data/translation.tsv.gz.md5', $tmp_dir.'translation.tsv.gz.md5'); |
|
2496 | 2496 | if (file_exists($tmp_dir.'translation.tsv.gz') && file_exists($tmp_dir.'translation.tsv.gz')) { |
2497 | - $translation_md5_file = explode(' ',file_get_contents($tmp_dir.'translation.tsv.gz.md5')); |
|
2497 | + $translation_md5_file = explode(' ', file_get_contents($tmp_dir.'translation.tsv.gz.md5')); |
|
2498 | 2498 | $translation_md5 = $translation_md5_file[0]; |
2499 | 2499 | if (md5_file($tmp_dir.'translation.tsv.gz') == $translation_md5) { |
2500 | 2500 | if ($globalDebug) echo "Gunzip..."; |
@@ -2512,10 +2512,10 @@ discard block |
||
2512 | 2512 | global $tmp_dir, $globalDebug; |
2513 | 2513 | $error = ''; |
2514 | 2514 | if ($globalDebug) echo "ModeS from FlightAirMap website : Download..."; |
2515 | - update_db::download('http://data.flightairmap.com/data/modes.tsv.gz',$tmp_dir.'modes.tsv.gz'); |
|
2516 | - update_db::download('http://data.flightairmap.com/data/modes.tsv.gz.md5',$tmp_dir.'modes.tsv.gz.md5'); |
|
2515 | + update_db::download('http://data.flightairmap.com/data/modes.tsv.gz', $tmp_dir.'modes.tsv.gz'); |
|
2516 | + update_db::download('http://data.flightairmap.com/data/modes.tsv.gz.md5', $tmp_dir.'modes.tsv.gz.md5'); |
|
2517 | 2517 | if (file_exists($tmp_dir.'modes.tsv.gz') && file_exists($tmp_dir.'modes.tsv.gz.md5')) { |
2518 | - $modes_md5_file = explode(' ',file_get_contents($tmp_dir.'modes.tsv.gz.md5')); |
|
2518 | + $modes_md5_file = explode(' ', file_get_contents($tmp_dir.'modes.tsv.gz.md5')); |
|
2519 | 2519 | $modes_md5 = $modes_md5_file[0]; |
2520 | 2520 | if (md5_file($tmp_dir.'modes.tsv.gz') == $modes_md5) { |
2521 | 2521 | if ($globalDebug) echo "Gunzip..."; |
@@ -2534,12 +2534,12 @@ discard block |
||
2534 | 2534 | global $tmp_dir, $globalDebug; |
2535 | 2535 | $error = ''; |
2536 | 2536 | if ($globalDebug) echo "Airlines from FlightAirMap website : Download..."; |
2537 | - update_db::download('http://data.flightairmap.com/data/airlines.tsv.gz.md5',$tmp_dir.'airlines.tsv.gz.md5'); |
|
2537 | + update_db::download('http://data.flightairmap.com/data/airlines.tsv.gz.md5', $tmp_dir.'airlines.tsv.gz.md5'); |
|
2538 | 2538 | if (file_exists($tmp_dir.'airlines.tsv.gz.md5')) { |
2539 | - $airlines_md5_file = explode(' ',file_get_contents($tmp_dir.'airlines.tsv.gz.md5')); |
|
2539 | + $airlines_md5_file = explode(' ', file_get_contents($tmp_dir.'airlines.tsv.gz.md5')); |
|
2540 | 2540 | $airlines_md5 = $airlines_md5_file[0]; |
2541 | 2541 | if (!update_db::check_airlines_version($airlines_md5)) { |
2542 | - update_db::download('http://data.flightairmap.com/data/airlines.tsv.gz',$tmp_dir.'airlines.tsv.gz'); |
|
2542 | + update_db::download('http://data.flightairmap.com/data/airlines.tsv.gz', $tmp_dir.'airlines.tsv.gz'); |
|
2543 | 2543 | if (file_exists($tmp_dir.'airlines.tsv.gz')) { |
2544 | 2544 | if (md5_file($tmp_dir.'airlines.tsv.gz') == $airlines_md5) { |
2545 | 2545 | if ($globalDebug) echo "Gunzip..."; |
@@ -2564,14 +2564,14 @@ discard block |
||
2564 | 2564 | if ($globalDebug) echo "owner from FlightAirMap website : Download..."; |
2565 | 2565 | $error = ''; |
2566 | 2566 | if ($globalOwner === TRUE) { |
2567 | - update_db::download('http://data.flightairmap.com/data/owners_all.tsv.gz',$tmp_dir.'owners.tsv.gz'); |
|
2568 | - update_db::download('http://data.flightairmap.com/data/owners_all.tsv.gz.md5',$tmp_dir.'owners.tsv.gz.md5'); |
|
2567 | + update_db::download('http://data.flightairmap.com/data/owners_all.tsv.gz', $tmp_dir.'owners.tsv.gz'); |
|
2568 | + update_db::download('http://data.flightairmap.com/data/owners_all.tsv.gz.md5', $tmp_dir.'owners.tsv.gz.md5'); |
|
2569 | 2569 | } else { |
2570 | - update_db::download('http://data.flightairmap.com/data/owners.tsv.gz',$tmp_dir.'owners.tsv.gz'); |
|
2571 | - update_db::download('http://data.flightairmap.com/data/owners.tsv.gz.md5',$tmp_dir.'owners.tsv.gz.md5'); |
|
2570 | + update_db::download('http://data.flightairmap.com/data/owners.tsv.gz', $tmp_dir.'owners.tsv.gz'); |
|
2571 | + update_db::download('http://data.flightairmap.com/data/owners.tsv.gz.md5', $tmp_dir.'owners.tsv.gz.md5'); |
|
2572 | 2572 | } |
2573 | 2573 | if (file_exists($tmp_dir.'owners.tsv.gz') && file_exists($tmp_dir.'owners.tsv.gz.md5')) { |
2574 | - $owners_md5_file = explode(' ',file_get_contents($tmp_dir.'owners.tsv.gz.md5')); |
|
2574 | + $owners_md5_file = explode(' ', file_get_contents($tmp_dir.'owners.tsv.gz.md5')); |
|
2575 | 2575 | $owners_md5 = $owners_md5_file[0]; |
2576 | 2576 | if (md5_file($tmp_dir.'owners.tsv.gz') == $owners_md5) { |
2577 | 2577 | if ($globalDebug) echo "Gunzip..."; |
@@ -2588,10 +2588,10 @@ discard block |
||
2588 | 2588 | public static function update_routes_fam() { |
2589 | 2589 | global $tmp_dir, $globalDebug; |
2590 | 2590 | if ($globalDebug) echo "Routes from FlightAirMap website : Download..."; |
2591 | - update_db::download('http://data.flightairmap.com/data/routes.tsv.gz',$tmp_dir.'routes.tsv.gz'); |
|
2592 | - update_db::download('http://data.flightairmap.com/data/routes.tsv.gz.md5',$tmp_dir.'routes.tsv.gz.md5'); |
|
2591 | + update_db::download('http://data.flightairmap.com/data/routes.tsv.gz', $tmp_dir.'routes.tsv.gz'); |
|
2592 | + update_db::download('http://data.flightairmap.com/data/routes.tsv.gz.md5', $tmp_dir.'routes.tsv.gz.md5'); |
|
2593 | 2593 | if (file_exists($tmp_dir.'routes.tsv.gz') && file_exists($tmp_dir.'routes.tsv.gz.md5')) { |
2594 | - $routes_md5_file = explode(' ',file_get_contents($tmp_dir.'routes.tsv.gz.md5')); |
|
2594 | + $routes_md5_file = explode(' ', file_get_contents($tmp_dir.'routes.tsv.gz.md5')); |
|
2595 | 2595 | $routes_md5 = $routes_md5_file[0]; |
2596 | 2596 | if (md5_file($tmp_dir.'routes.tsv.gz') == $routes_md5) { |
2597 | 2597 | if ($globalDebug) echo "Gunzip..."; |
@@ -2608,10 +2608,10 @@ discard block |
||
2608 | 2608 | public static function update_block_fam() { |
2609 | 2609 | global $tmp_dir, $globalDebug; |
2610 | 2610 | if ($globalDebug) echo "Blocked aircraft from FlightAirMap website : Download..."; |
2611 | - update_db::download('http://data.flightairmap.com/data/block.tsv.gz',$tmp_dir.'block.tsv.gz'); |
|
2612 | - update_db::download('http://data.flightairmap.com/data/block.tsv.gz.md5',$tmp_dir.'block.tsv.gz.md5'); |
|
2611 | + update_db::download('http://data.flightairmap.com/data/block.tsv.gz', $tmp_dir.'block.tsv.gz'); |
|
2612 | + update_db::download('http://data.flightairmap.com/data/block.tsv.gz.md5', $tmp_dir.'block.tsv.gz.md5'); |
|
2613 | 2613 | if (file_exists($tmp_dir.'block.tsv.gz') && file_exists($tmp_dir.'block.tsv.gz.md5')) { |
2614 | - $block_md5_file = explode(' ',file_get_contents($tmp_dir.'block.tsv.gz.md5')); |
|
2614 | + $block_md5_file = explode(' ', file_get_contents($tmp_dir.'block.tsv.gz.md5')); |
|
2615 | 2615 | $block_md5 = $block_md5_file[0]; |
2616 | 2616 | if (md5_file($tmp_dir.'block.tsv.gz') == $block_md5) { |
2617 | 2617 | if ($globalDebug) echo "Gunzip..."; |
@@ -2627,13 +2627,13 @@ discard block |
||
2627 | 2627 | } |
2628 | 2628 | public static function update_marine_identity_fam() { |
2629 | 2629 | global $tmp_dir, $globalDebug; |
2630 | - update_db::download('http://data.flightairmap.com/data/marine_identity.tsv.gz.md5',$tmp_dir.'marine_identity.tsv.gz.md5'); |
|
2630 | + update_db::download('http://data.flightairmap.com/data/marine_identity.tsv.gz.md5', $tmp_dir.'marine_identity.tsv.gz.md5'); |
|
2631 | 2631 | if (file_exists($tmp_dir.'marine_identity.tsv.gz.md5')) { |
2632 | - $marine_identity_md5_file = explode(' ',file_get_contents($tmp_dir.'marine_identity.tsv.gz.md5')); |
|
2632 | + $marine_identity_md5_file = explode(' ', file_get_contents($tmp_dir.'marine_identity.tsv.gz.md5')); |
|
2633 | 2633 | $marine_identity_md5 = $marine_identity_md5_file[0]; |
2634 | 2634 | if (!update_db::check_marine_identity_version($marine_identity_md5)) { |
2635 | 2635 | if ($globalDebug) echo "Marine identity from FlightAirMap website : Download..."; |
2636 | - update_db::download('http://data.flightairmap.com/data/marine_identity.tsv.gz',$tmp_dir.'marine_identity.tsv.gz'); |
|
2636 | + update_db::download('http://data.flightairmap.com/data/marine_identity.tsv.gz', $tmp_dir.'marine_identity.tsv.gz'); |
|
2637 | 2637 | if (file_exists($tmp_dir.'marine_identity.tsv.gz')) { |
2638 | 2638 | if (md5_file($tmp_dir.'marine_identity.tsv.gz') == $marine_identity_md5) { |
2639 | 2639 | if ($globalDebug) echo "Gunzip..."; |
@@ -2655,13 +2655,13 @@ discard block |
||
2655 | 2655 | |
2656 | 2656 | public static function update_satellite_fam() { |
2657 | 2657 | global $tmp_dir, $globalDebug; |
2658 | - update_db::download('http://data.flightairmap.com/data/satellite.tsv.gz.md5',$tmp_dir.'satellite.tsv.gz.md5'); |
|
2658 | + update_db::download('http://data.flightairmap.com/data/satellite.tsv.gz.md5', $tmp_dir.'satellite.tsv.gz.md5'); |
|
2659 | 2659 | if (file_exists($tmp_dir.'satellite.tsv.gz.md5')) { |
2660 | - $satellite_md5_file = explode(' ',file_get_contents($tmp_dir.'satellite.tsv.gz.md5')); |
|
2660 | + $satellite_md5_file = explode(' ', file_get_contents($tmp_dir.'satellite.tsv.gz.md5')); |
|
2661 | 2661 | $satellite_md5 = $satellite_md5_file[0]; |
2662 | 2662 | if (!update_db::check_satellite_version($satellite_md5)) { |
2663 | 2663 | if ($globalDebug) echo "Satellite from FlightAirMap website : Download..."; |
2664 | - update_db::download('http://data.flightairmap.com/data/satellite.tsv.gz',$tmp_dir.'satellite.tsv.gz'); |
|
2664 | + update_db::download('http://data.flightairmap.com/data/satellite.tsv.gz', $tmp_dir.'satellite.tsv.gz'); |
|
2665 | 2665 | if (file_exists($tmp_dir.'satellite.tsv.gz')) { |
2666 | 2666 | if (md5_file($tmp_dir.'satellite.tsv.gz') == $satellite_md5) { |
2667 | 2667 | if ($globalDebug) echo "Gunzip..."; |
@@ -2682,13 +2682,13 @@ discard block |
||
2682 | 2682 | } |
2683 | 2683 | public static function update_diagrams_fam() { |
2684 | 2684 | global $tmp_dir, $globalDebug; |
2685 | - update_db::download('http://data.flightairmap.com/data/diagrams/diagramspdf.md5',$tmp_dir.'diagramspdf.md5'); |
|
2685 | + update_db::download('http://data.flightairmap.com/data/diagrams/diagramspdf.md5', $tmp_dir.'diagramspdf.md5'); |
|
2686 | 2686 | if (file_exists($tmp_dir.'diagramspdf.md5')) { |
2687 | - $diagrams_md5_file = explode(' ',file_get_contents($tmp_dir.'diagramspdf.md5')); |
|
2687 | + $diagrams_md5_file = explode(' ', file_get_contents($tmp_dir.'diagramspdf.md5')); |
|
2688 | 2688 | $diagrams_md5 = $diagrams_md5_file[0]; |
2689 | 2689 | if (!update_db::check_diagrams_version($diagrams_md5)) { |
2690 | 2690 | if ($globalDebug) echo "Airports diagrams from FlightAirMap website : Download..."; |
2691 | - update_db::download('http://data.flightairmap.com/data/diagrams/diagramspdf',$tmp_dir.'diagramspdf'); |
|
2691 | + update_db::download('http://data.flightairmap.com/data/diagrams/diagramspdf', $tmp_dir.'diagramspdf'); |
|
2692 | 2692 | if (file_exists($tmp_dir.'diagramspdf')) { |
2693 | 2693 | if (md5_file($tmp_dir.'diagramspdf') == $diagrams_md5) { |
2694 | 2694 | if ($globalDebug) echo "Add to DB..."; |
@@ -2708,7 +2708,7 @@ discard block |
||
2708 | 2708 | public static function update_banned_fam() { |
2709 | 2709 | global $tmp_dir, $globalDebug; |
2710 | 2710 | if ($globalDebug) echo "Banned airlines in Europe from FlightAirMap website : Download..."; |
2711 | - update_db::download('http://data.flightairmap.com/data/ban-eu.csv',$tmp_dir.'ban_eu.csv'); |
|
2711 | + update_db::download('http://data.flightairmap.com/data/ban-eu.csv', $tmp_dir.'ban_eu.csv'); |
|
2712 | 2712 | if (file_exists($tmp_dir.'ban_eu.csv')) { |
2713 | 2713 | //if ($globalDebug) echo "Gunzip..."; |
2714 | 2714 | //update_db::gunzip($tmp_dir.'ban_ue.csv'); |
@@ -2727,18 +2727,18 @@ discard block |
||
2727 | 2727 | $error = ''; |
2728 | 2728 | if ($globalDebug) echo "Airspace from FlightAirMap website : Download..."; |
2729 | 2729 | if ($globalDBdriver == 'mysql') { |
2730 | - update_db::download('http://data.flightairmap.com/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5'); |
|
2730 | + update_db::download('http://data.flightairmap.com/data/airspace_mysql.sql.gz.md5', $tmp_dir.'airspace.sql.gz.md5'); |
|
2731 | 2731 | } else { |
2732 | - update_db::download('http://data.flightairmap.com/data/airspace_pgsql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5'); |
|
2732 | + update_db::download('http://data.flightairmap.com/data/airspace_pgsql.sql.gz.md5', $tmp_dir.'airspace.sql.gz.md5'); |
|
2733 | 2733 | } |
2734 | 2734 | if (file_exists($tmp_dir.'airspace.sql.gz.md5')) { |
2735 | - $airspace_md5_file = explode(' ',file_get_contents($tmp_dir.'airspace.sql.gz.md5')); |
|
2735 | + $airspace_md5_file = explode(' ', file_get_contents($tmp_dir.'airspace.sql.gz.md5')); |
|
2736 | 2736 | $airspace_md5 = $airspace_md5_file[0]; |
2737 | 2737 | if (!update_db::check_airspace_version($airspace_md5)) { |
2738 | 2738 | if ($globalDBdriver == 'mysql') { |
2739 | - update_db::download('http://data.flightairmap.com/data/airspace_mysql.sql.gz',$tmp_dir.'airspace.sql.gz'); |
|
2739 | + update_db::download('http://data.flightairmap.com/data/airspace_mysql.sql.gz', $tmp_dir.'airspace.sql.gz'); |
|
2740 | 2740 | } else { |
2741 | - update_db::download('http://data.flightairmap.com/data/airspace_pgsql.sql.gz',$tmp_dir.'airspace.sql.gz'); |
|
2741 | + update_db::download('http://data.flightairmap.com/data/airspace_pgsql.sql.gz', $tmp_dir.'airspace.sql.gz'); |
|
2742 | 2742 | } |
2743 | 2743 | if (file_exists($tmp_dir.'airspace.sql.gz')) { |
2744 | 2744 | if (md5_file($tmp_dir.'airspace.sql.gz') == $airspace_md5) { |
@@ -2751,7 +2751,7 @@ discard block |
||
2751 | 2751 | try { |
2752 | 2752 | $sth = $Connection->db->prepare($query); |
2753 | 2753 | $sth->execute(); |
2754 | - } catch(PDOException $e) { |
|
2754 | + } catch (PDOException $e) { |
|
2755 | 2755 | return "error : ".$e->getMessage(); |
2756 | 2756 | } |
2757 | 2757 | } |
@@ -2771,16 +2771,16 @@ discard block |
||
2771 | 2771 | global $tmp_dir, $globalDebug, $globalGeoidSource; |
2772 | 2772 | $error = ''; |
2773 | 2773 | if ($globalDebug) echo "Geoid from FlightAirMap website : Download..."; |
2774 | - update_db::download('http://data.flightairmap.com/data/geoid/'.$globalGeoidSource.'.pgm.gz.md5',$tmp_dir.$globalGeoidSource.'.pgm.gz.md5'); |
|
2774 | + update_db::download('http://data.flightairmap.com/data/geoid/'.$globalGeoidSource.'.pgm.gz.md5', $tmp_dir.$globalGeoidSource.'.pgm.gz.md5'); |
|
2775 | 2775 | if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz.md5')) { |
2776 | - $geoid_md5_file = explode(' ',file_get_contents($tmp_dir.$globalGeoidSource.'.pgm.gz.md5')); |
|
2776 | + $geoid_md5_file = explode(' ', file_get_contents($tmp_dir.$globalGeoidSource.'.pgm.gz.md5')); |
|
2777 | 2777 | $geoid_md5 = $geoid_md5_file[0]; |
2778 | 2778 | if (!update_db::check_geoid_version($geoid_md5)) { |
2779 | - update_db::download('http://data.flightairmap.com/data/geoid/'.$globalGeoidSource.'.pgm.gz',$tmp_dir.$globalGeoidSource.'.pgm.gz'); |
|
2779 | + update_db::download('http://data.flightairmap.com/data/geoid/'.$globalGeoidSource.'.pgm.gz', $tmp_dir.$globalGeoidSource.'.pgm.gz'); |
|
2780 | 2780 | if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz')) { |
2781 | 2781 | if (md5_file($tmp_dir.$globalGeoidSource.'.pgm.gz') == $geoid_md5) { |
2782 | 2782 | if ($globalDebug) echo "Gunzip..."; |
2783 | - update_db::gunzip($tmp_dir.$globalGeoidSource.'.pgm.gz',dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm'); |
|
2783 | + update_db::gunzip($tmp_dir.$globalGeoidSource.'.pgm.gz', dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm'); |
|
2784 | 2784 | if (file_exists(dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm')) { |
2785 | 2785 | update_db::insert_geoid_version($geoid_md5); |
2786 | 2786 | } else $error = "File data/".$globalGeoidSource.'.pgm'." doesn't exist. Gunzip failed."; |
@@ -2797,15 +2797,15 @@ discard block |
||
2797 | 2797 | public static function update_tle() { |
2798 | 2798 | global $tmp_dir, $globalDebug; |
2799 | 2799 | if ($globalDebug) echo "Download TLE : Download..."; |
2800 | - $alltle = array('stations.txt','gps-ops.txt','glo-ops.txt','galileo.txt','weather.txt','noaa.txt','goes.txt','resource.txt','dmc.txt','tdrss.txt','geo.txt','intelsat.txt','gorizont.txt', |
|
2801 | - 'raduga.txt','molniya.txt','iridium.txt','orbcomm.txt','globalstar.txt','amateur.txt','x-comm.txt','other-comm.txt','sbas.txt','nnss.txt','musson.txt','science.txt','geodetic.txt', |
|
2802 | - 'engineering.txt','education.txt','military.txt','radar.txt','cubesat.txt','other.txt','tle-new.txt','visual.txt','sarsat.txt','argos.txt','ses.txt','iridium-NEXT.txt','beidou.txt'); |
|
2800 | + $alltle = array('stations.txt', 'gps-ops.txt', 'glo-ops.txt', 'galileo.txt', 'weather.txt', 'noaa.txt', 'goes.txt', 'resource.txt', 'dmc.txt', 'tdrss.txt', 'geo.txt', 'intelsat.txt', 'gorizont.txt', |
|
2801 | + 'raduga.txt', 'molniya.txt', 'iridium.txt', 'orbcomm.txt', 'globalstar.txt', 'amateur.txt', 'x-comm.txt', 'other-comm.txt', 'sbas.txt', 'nnss.txt', 'musson.txt', 'science.txt', 'geodetic.txt', |
|
2802 | + 'engineering.txt', 'education.txt', 'military.txt', 'radar.txt', 'cubesat.txt', 'other.txt', 'tle-new.txt', 'visual.txt', 'sarsat.txt', 'argos.txt', 'ses.txt', 'iridium-NEXT.txt', 'beidou.txt'); |
|
2803 | 2803 | foreach ($alltle as $filename) { |
2804 | 2804 | if ($globalDebug) echo "downloading ".$filename.'...'; |
2805 | - update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename); |
|
2805 | + update_db::download('http://celestrak.com/NORAD/elements/'.$filename, $tmp_dir.$filename); |
|
2806 | 2806 | if (file_exists($tmp_dir.$filename)) { |
2807 | 2807 | if ($globalDebug) echo "Add to DB ".$filename."..."; |
2808 | - $error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename)); |
|
2808 | + $error = update_db::tle($tmp_dir.$filename, str_replace('.txt', '', $filename)); |
|
2809 | 2809 | } else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed."; |
2810 | 2810 | if ($error != '') { |
2811 | 2811 | echo $error."\n"; |
@@ -2817,7 +2817,7 @@ discard block |
||
2817 | 2817 | public static function update_ucsdb() { |
2818 | 2818 | global $tmp_dir, $globalDebug; |
2819 | 2819 | if ($globalDebug) echo "Download UCS DB : Download..."; |
2820 | - update_db::download('https://s3.amazonaws.com/ucs-documents/nuclear-weapons/sat-database/5-9-19-update/UCS_Satellite_Database_officialname_4-1-2019.txt',$tmp_dir.'UCS_Satellite_Database_officialname_4-1-2019.txt'); |
|
2820 | + update_db::download('https://s3.amazonaws.com/ucs-documents/nuclear-weapons/sat-database/5-9-19-update/UCS_Satellite_Database_officialname_4-1-2019.txt', $tmp_dir.'UCS_Satellite_Database_officialname_4-1-2019.txt'); |
|
2821 | 2821 | if (file_exists($tmp_dir.'UCS_Satellite_Database_officialname_4-1-2019.txt')) { |
2822 | 2822 | if ($globalDebug) echo "Add to DB..."; |
2823 | 2823 | $error = update_db::satellite_ucsdb($tmp_dir.'UCS_Satellite_Database_officialname_4-1-2019.txt'); |
@@ -2831,7 +2831,7 @@ discard block |
||
2831 | 2831 | public static function update_celestrak() { |
2832 | 2832 | global $tmp_dir, $globalDebug; |
2833 | 2833 | if ($globalDebug) echo "Download Celestrak DB : Download..."; |
2834 | - update_db::download('http://celestrak.com/pub/satcat.txt',$tmp_dir.'satcat.txt'); |
|
2834 | + update_db::download('http://celestrak.com/pub/satcat.txt', $tmp_dir.'satcat.txt'); |
|
2835 | 2835 | if (file_exists($tmp_dir.'satcat.txt')) { |
2836 | 2836 | if ($globalDebug) echo "Add to DB..."; |
2837 | 2837 | $error = update_db::satellite_celestrak($tmp_dir.'satcat.txt'); |
@@ -2850,62 +2850,62 @@ discard block |
||
2850 | 2850 | if ($globalDebug) echo dirname(__FILE__).'/../models'.' is not writable !'; |
2851 | 2851 | return ''; |
2852 | 2852 | } |
2853 | - update_db::download('http://data.flightairmap.com/data/models/models.md5sum',$tmp_dir.'models.md5sum'); |
|
2853 | + update_db::download('http://data.flightairmap.com/data/models/models.md5sum', $tmp_dir.'models.md5sum'); |
|
2854 | 2854 | if (file_exists($tmp_dir.'models.md5sum')) { |
2855 | 2855 | if ($globalDebug) echo "Check files...\n"; |
2856 | 2856 | $newmodelsdb = array(); |
2857 | - if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) { |
|
2858 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
2857 | + if (($handle = fopen($tmp_dir.'models.md5sum', 'r')) !== FALSE) { |
|
2858 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
2859 | 2859 | $model = trim($row[2]); |
2860 | 2860 | $newmodelsdb[$model] = trim($row[0]); |
2861 | 2861 | } |
2862 | 2862 | } |
2863 | 2863 | $modelsdb = array(); |
2864 | 2864 | if (file_exists(dirname(__FILE__).'/../models/models.md5sum')) { |
2865 | - if (($handle = fopen(dirname(__FILE__).'/../models/models.md5sum','r')) !== FALSE) { |
|
2866 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
2865 | + if (($handle = fopen(dirname(__FILE__).'/../models/models.md5sum', 'r')) !== FALSE) { |
|
2866 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
2867 | 2867 | $model = trim($row[2]); |
2868 | 2868 | $modelsdb[$model] = trim($row[0]); |
2869 | 2869 | } |
2870 | 2870 | } |
2871 | 2871 | } |
2872 | - $diff = array_diff($newmodelsdb,$modelsdb); |
|
2872 | + $diff = array_diff($newmodelsdb, $modelsdb); |
|
2873 | 2873 | foreach ($diff as $key => $value) { |
2874 | 2874 | if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n"; |
2875 | - update_db::download('http://data.flightairmap.com/data/models/'.$key,dirname(__FILE__).'/../models/'.$key); |
|
2875 | + update_db::download('http://data.flightairmap.com/data/models/'.$key, dirname(__FILE__).'/../models/'.$key); |
|
2876 | 2876 | } |
2877 | - update_db::download('http://data.flightairmap.com/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum'); |
|
2877 | + update_db::download('http://data.flightairmap.com/data/models/models.md5sum', dirname(__FILE__).'/../models/models.md5sum'); |
|
2878 | 2878 | } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
2879 | 2879 | if ($error != '') { |
2880 | 2880 | return $error; |
2881 | 2881 | } elseif ($globalDebug) echo "Done\n"; |
2882 | 2882 | if ($globalDebug) echo "glTF 2.0 Models from FlightAirMap website : Download..."; |
2883 | - update_db::download('http://data.flightairmap.com/data/models/gltf2/models.md5sum',$tmp_dir.'modelsgltf2.md5sum'); |
|
2883 | + update_db::download('http://data.flightairmap.com/data/models/gltf2/models.md5sum', $tmp_dir.'modelsgltf2.md5sum'); |
|
2884 | 2884 | if (file_exists($tmp_dir.'modelsgltf2.md5sum')) { |
2885 | 2885 | if ($globalDebug) echo "Check files...\n"; |
2886 | 2886 | $newmodelsdb = array(); |
2887 | - if (($handle = fopen($tmp_dir.'modelsgltf2.md5sum','r')) !== FALSE) { |
|
2888 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
2887 | + if (($handle = fopen($tmp_dir.'modelsgltf2.md5sum', 'r')) !== FALSE) { |
|
2888 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
2889 | 2889 | $model = trim($row[2]); |
2890 | 2890 | $newmodelsdb[$model] = trim($row[0]); |
2891 | 2891 | } |
2892 | 2892 | } |
2893 | 2893 | $modelsdb = array(); |
2894 | 2894 | if (file_exists(dirname(__FILE__).'/../models/gltf2/models.md5sum')) { |
2895 | - if (($handle = fopen(dirname(__FILE__).'/../models/gltf2/models.md5sum','r')) !== FALSE) { |
|
2896 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
2895 | + if (($handle = fopen(dirname(__FILE__).'/../models/gltf2/models.md5sum', 'r')) !== FALSE) { |
|
2896 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
2897 | 2897 | $model = trim($row[2]); |
2898 | 2898 | $modelsdb[$model] = trim($row[0]); |
2899 | 2899 | } |
2900 | 2900 | } |
2901 | 2901 | } |
2902 | - $diff = array_diff($newmodelsdb,$modelsdb); |
|
2902 | + $diff = array_diff($newmodelsdb, $modelsdb); |
|
2903 | 2903 | foreach ($diff as $key => $value) { |
2904 | 2904 | if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n"; |
2905 | - update_db::download('http://data.flightairmap.com/data/models/gltf2/'.$key,dirname(__FILE__).'/../models/gltf2/'.$key); |
|
2905 | + update_db::download('http://data.flightairmap.com/data/models/gltf2/'.$key, dirname(__FILE__).'/../models/gltf2/'.$key); |
|
2906 | 2906 | |
2907 | 2907 | } |
2908 | - update_db::download('http://data.flightairmap.com/data/models/gltf2/models.md5sum',dirname(__FILE__).'/../models/gltf2/models.md5sum'); |
|
2908 | + update_db::download('http://data.flightairmap.com/data/models/gltf2/models.md5sum', dirname(__FILE__).'/../models/gltf2/models.md5sum'); |
|
2909 | 2909 | } else $error = "File ".$tmp_dir.'modelsgltf2.md5sum'." doesn't exist. Download failed."; |
2910 | 2910 | if ($error != '') { |
2911 | 2911 | return $error; |
@@ -2921,32 +2921,32 @@ discard block |
||
2921 | 2921 | return ''; |
2922 | 2922 | } |
2923 | 2923 | if ($globalDebug) echo "Weather Models from FlightAirMap website : Download..."; |
2924 | - update_db::download('http://data.flightairmap.com/data/models/gltf2/weather/models.md5sum',$tmp_dir.'modelsweather.md5sum'); |
|
2924 | + update_db::download('http://data.flightairmap.com/data/models/gltf2/weather/models.md5sum', $tmp_dir.'modelsweather.md5sum'); |
|
2925 | 2925 | if (file_exists($tmp_dir.'modelsweather.md5sum')) { |
2926 | 2926 | if ($globalDebug) echo "Check files...\n"; |
2927 | 2927 | $newmodelsdb = array(); |
2928 | - if (($handle = fopen($tmp_dir.'modelsweather.md5sum','r')) !== FALSE) { |
|
2929 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
2928 | + if (($handle = fopen($tmp_dir.'modelsweather.md5sum', 'r')) !== FALSE) { |
|
2929 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
2930 | 2930 | $model = trim($row[2]); |
2931 | 2931 | $newmodelsdb[$model] = trim($row[0]); |
2932 | 2932 | } |
2933 | 2933 | } |
2934 | 2934 | $modelsdb = array(); |
2935 | 2935 | if (file_exists(dirname(__FILE__).'/../models/gltf2/weather/models.md5sum')) { |
2936 | - if (($handle = fopen(dirname(__FILE__).'/../models/gltf2/weather/models.md5sum','r')) !== FALSE) { |
|
2937 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
2936 | + if (($handle = fopen(dirname(__FILE__).'/../models/gltf2/weather/models.md5sum', 'r')) !== FALSE) { |
|
2937 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
2938 | 2938 | $model = trim($row[2]); |
2939 | 2939 | $modelsdb[$model] = trim($row[0]); |
2940 | 2940 | } |
2941 | 2941 | } |
2942 | 2942 | } |
2943 | - $diff = array_diff($newmodelsdb,$modelsdb); |
|
2943 | + $diff = array_diff($newmodelsdb, $modelsdb); |
|
2944 | 2944 | foreach ($diff as $key => $value) { |
2945 | 2945 | if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n"; |
2946 | - update_db::download('http://data.flightairmap.com/data/models/gltf2/weather/'.$key,dirname(__FILE__).'/../models/gltf2/weather/'.$key); |
|
2946 | + update_db::download('http://data.flightairmap.com/data/models/gltf2/weather/'.$key, dirname(__FILE__).'/../models/gltf2/weather/'.$key); |
|
2947 | 2947 | |
2948 | 2948 | } |
2949 | - update_db::download('http://data.flightairmap.com/data/models/gltf2/weather/models.md5sum',dirname(__FILE__).'/../models/gltf2/weather/models.md5sum'); |
|
2949 | + update_db::download('http://data.flightairmap.com/data/models/gltf2/weather/models.md5sum', dirname(__FILE__).'/../models/gltf2/weather/models.md5sum'); |
|
2950 | 2950 | } else $error = "File ".$tmp_dir.'modelsweather.md5sum'." doesn't exist. Download failed."; |
2951 | 2951 | if ($error != '') { |
2952 | 2952 | return $error; |
@@ -2958,32 +2958,32 @@ discard block |
||
2958 | 2958 | global $tmp_dir, $globalDebug; |
2959 | 2959 | $error = ''; |
2960 | 2960 | if ($globalDebug) echo "Liveries from FlightAirMap website : Download..."; |
2961 | - update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/liveries.md5sum',$tmp_dir.'liveries.md5sum'); |
|
2961 | + update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/liveries.md5sum', $tmp_dir.'liveries.md5sum'); |
|
2962 | 2962 | if (file_exists($tmp_dir.'liveries.md5sum')) { |
2963 | 2963 | if ($globalDebug) echo "Check files...\n"; |
2964 | 2964 | $newmodelsdb = array(); |
2965 | - if (($handle = fopen($tmp_dir.'liveries.md5sum','r')) !== FALSE) { |
|
2966 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
2965 | + if (($handle = fopen($tmp_dir.'liveries.md5sum', 'r')) !== FALSE) { |
|
2966 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
2967 | 2967 | $model = trim($row[2]); |
2968 | 2968 | $newmodelsdb[$model] = trim($row[0]); |
2969 | 2969 | } |
2970 | 2970 | } |
2971 | 2971 | $modelsdb = array(); |
2972 | 2972 | if (file_exists(dirname(__FILE__).'/../models/gltf2/liveries/liveries.md5sum')) { |
2973 | - if (($handle = fopen(dirname(__FILE__).'/../models/gltf2/liveries/liveries.md5sum','r')) !== FALSE) { |
|
2974 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
2973 | + if (($handle = fopen(dirname(__FILE__).'/../models/gltf2/liveries/liveries.md5sum', 'r')) !== FALSE) { |
|
2974 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
2975 | 2975 | $model = trim($row[2]); |
2976 | 2976 | $modelsdb[$model] = trim($row[0]); |
2977 | 2977 | } |
2978 | 2978 | } |
2979 | 2979 | } |
2980 | - $diff = array_diff($newmodelsdb,$modelsdb); |
|
2980 | + $diff = array_diff($newmodelsdb, $modelsdb); |
|
2981 | 2981 | foreach ($diff as $key => $value) { |
2982 | 2982 | if ($globalDebug) echo 'Downloading liveries '.$key.' ...'."\n"; |
2983 | - update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/'.$key,dirname(__FILE__).'/../models/gltf2/liveries/'.$key); |
|
2983 | + update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/'.$key, dirname(__FILE__).'/../models/gltf2/liveries/'.$key); |
|
2984 | 2984 | |
2985 | 2985 | } |
2986 | - update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/liveries.md5sum',dirname(__FILE__).'/../models/gltf2/liveries/liveries.md5sum'); |
|
2986 | + update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/liveries.md5sum', dirname(__FILE__).'/../models/gltf2/liveries/liveries.md5sum'); |
|
2987 | 2987 | } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
2988 | 2988 | if ($error != '') { |
2989 | 2989 | return $error; |
@@ -2999,32 +2999,32 @@ discard block |
||
2999 | 2999 | return ''; |
3000 | 3000 | } |
3001 | 3001 | if ($globalDebug) echo "Space models from FlightAirMap website : Download..."; |
3002 | - update_db::download('http://data.flightairmap.com/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum'); |
|
3002 | + update_db::download('http://data.flightairmap.com/data/models/space/space_models.md5sum', $tmp_dir.'space_models.md5sum'); |
|
3003 | 3003 | if (file_exists($tmp_dir.'space_models.md5sum')) { |
3004 | 3004 | if ($globalDebug) echo "Check files...\n"; |
3005 | 3005 | $newmodelsdb = array(); |
3006 | - if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) { |
|
3007 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
3006 | + if (($handle = fopen($tmp_dir.'space_models.md5sum', 'r')) !== FALSE) { |
|
3007 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
3008 | 3008 | $model = trim($row[2]); |
3009 | 3009 | $newmodelsdb[$model] = trim($row[0]); |
3010 | 3010 | } |
3011 | 3011 | } |
3012 | 3012 | $modelsdb = array(); |
3013 | 3013 | if (file_exists(dirname(__FILE__).'/../models/space/space_models.md5sum')) { |
3014 | - if (($handle = fopen(dirname(__FILE__).'/../models/space/space_models.md5sum','r')) !== FALSE) { |
|
3015 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
3014 | + if (($handle = fopen(dirname(__FILE__).'/../models/space/space_models.md5sum', 'r')) !== FALSE) { |
|
3015 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
3016 | 3016 | $model = trim($row[2]); |
3017 | 3017 | $modelsdb[$model] = trim($row[0]); |
3018 | 3018 | } |
3019 | 3019 | } |
3020 | 3020 | } |
3021 | - $diff = array_diff($newmodelsdb,$modelsdb); |
|
3021 | + $diff = array_diff($newmodelsdb, $modelsdb); |
|
3022 | 3022 | foreach ($diff as $key => $value) { |
3023 | 3023 | if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n"; |
3024 | - update_db::download('http://data.flightairmap.com/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key); |
|
3024 | + update_db::download('http://data.flightairmap.com/data/models/space/'.$key, dirname(__FILE__).'/../models/space/'.$key); |
|
3025 | 3025 | |
3026 | 3026 | } |
3027 | - update_db::download('http://data.flightairmap.com/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum'); |
|
3027 | + update_db::download('http://data.flightairmap.com/data/models/space/space_models.md5sum', dirname(__FILE__).'/../models/space/space_models.md5sum'); |
|
3028 | 3028 | } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
3029 | 3029 | if ($error != '') { |
3030 | 3030 | return $error; |
@@ -3040,32 +3040,32 @@ discard block |
||
3040 | 3040 | return ''; |
3041 | 3041 | } |
3042 | 3042 | if ($globalDebug) echo "Vehicules models from FlightAirMap website : Download..."; |
3043 | - update_db::download('http://data.flightairmap.com/data/models/vehicules/vehicules_models.md5sum',$tmp_dir.'vehicules_models.md5sum'); |
|
3043 | + update_db::download('http://data.flightairmap.com/data/models/vehicules/vehicules_models.md5sum', $tmp_dir.'vehicules_models.md5sum'); |
|
3044 | 3044 | if (file_exists($tmp_dir.'vehicules_models.md5sum')) { |
3045 | 3045 | if ($globalDebug) echo "Check files...\n"; |
3046 | 3046 | $newmodelsdb = array(); |
3047 | - if (($handle = fopen($tmp_dir.'vehicules_models.md5sum','r')) !== FALSE) { |
|
3048 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
3047 | + if (($handle = fopen($tmp_dir.'vehicules_models.md5sum', 'r')) !== FALSE) { |
|
3048 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
3049 | 3049 | $model = trim($row[2]); |
3050 | 3050 | $newmodelsdb[$model] = trim($row[0]); |
3051 | 3051 | } |
3052 | 3052 | } |
3053 | 3053 | $modelsdb = array(); |
3054 | 3054 | if (file_exists(dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum')) { |
3055 | - if (($handle = fopen(dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum','r')) !== FALSE) { |
|
3056 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
3055 | + if (($handle = fopen(dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum', 'r')) !== FALSE) { |
|
3056 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
3057 | 3057 | $model = trim($row[2]); |
3058 | 3058 | $modelsdb[$model] = trim($row[0]); |
3059 | 3059 | } |
3060 | 3060 | } |
3061 | 3061 | } |
3062 | - $diff = array_diff($newmodelsdb,$modelsdb); |
|
3062 | + $diff = array_diff($newmodelsdb, $modelsdb); |
|
3063 | 3063 | foreach ($diff as $key => $value) { |
3064 | 3064 | if ($globalDebug) echo 'Downloading vehicules model '.$key.' ...'."\n"; |
3065 | - update_db::download('http://data.flightairmap.com/data/models/vehicules/'.$key,dirname(__FILE__).'/../models/vehicules/'.$key); |
|
3065 | + update_db::download('http://data.flightairmap.com/data/models/vehicules/'.$key, dirname(__FILE__).'/../models/vehicules/'.$key); |
|
3066 | 3066 | |
3067 | 3067 | } |
3068 | - update_db::download('http://data.flightairmap.com/data/models/vehicules/vehicules_models.md5sum',dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum'); |
|
3068 | + update_db::download('http://data.flightairmap.com/data/models/vehicules/vehicules_models.md5sum', dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum'); |
|
3069 | 3069 | } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
3070 | 3070 | if ($error != '') { |
3071 | 3071 | return $error; |
@@ -3077,8 +3077,8 @@ discard block |
||
3077 | 3077 | global $tmp_dir, $globalDebug; |
3078 | 3078 | date_default_timezone_set('UTC'); |
3079 | 3079 | $Common = new Common(); |
3080 | - $data = $Common->getData('https://www4.icao.int/doc8643/External/AircraftTypes','post',array('X-Requested-With: XMLHttpRequest','Accept: application/json, text/javascript, */*; q=0.01','Host: www4.icao.int','Origin: https://www.icao.int','Content-Length: 0'),'','','https://www.icao.int/publications/DOC8643/Pages/Search.aspx',60); |
|
3081 | - $all = json_decode($data,true); |
|
3080 | + $data = $Common->getData('https://www4.icao.int/doc8643/External/AircraftTypes', 'post', array('X-Requested-With: XMLHttpRequest', 'Accept: application/json, text/javascript, */*; q=0.01', 'Host: www4.icao.int', 'Origin: https://www.icao.int', 'Content-Length: 0'), '', '', 'https://www.icao.int/publications/DOC8643/Pages/Search.aspx', 60); |
|
3081 | + $all = json_decode($data, true); |
|
3082 | 3082 | $Connection = new Connection(); |
3083 | 3083 | $querychk = "SELECT COUNT(1) as nb FROM aircraft WHERE icao = :icao"; |
3084 | 3084 | $sth = $Connection->db->prepare($querychk); |
@@ -3090,8 +3090,8 @@ discard block |
||
3090 | 3090 | foreach ($all as $model) { |
3091 | 3091 | $icao = $model['Designator']; |
3092 | 3092 | if (!isset($allicao[$icao])) { |
3093 | - $aircraft_shadow = 'generic_'.substr($model['EngineType'],0,1).$model['EngineCount'].$model['WTC'].'.png'; |
|
3094 | - $allicao[$icao] = array(':icao' => $icao,':type' => $model['ModelFullName'],':manufacturer' => $model['ManufacturerCode'],':aircraft_shadow' => $aircraft_shadow,':aircraft_description' => $model['AircraftDescription'],':engine_type' => $model['EngineType'],':engine_count' => $model['EngineCount'],':wake_category' => $model['WTC']); |
|
3093 | + $aircraft_shadow = 'generic_'.substr($model['EngineType'], 0, 1).$model['EngineCount'].$model['WTC'].'.png'; |
|
3094 | + $allicao[$icao] = array(':icao' => $icao, ':type' => $model['ModelFullName'], ':manufacturer' => $model['ManufacturerCode'], ':aircraft_shadow' => $aircraft_shadow, ':aircraft_description' => $model['AircraftDescription'], ':engine_type' => $model['EngineType'], ':engine_count' => $model['EngineCount'], ':wake_category' => $model['WTC']); |
|
3095 | 3095 | } else { |
3096 | 3096 | $allicao[$icao][':type'] = $allicao[$icao][':type'].'/'.$model['ModelFullName']; |
3097 | 3097 | } |
@@ -3103,9 +3103,9 @@ discard block |
||
3103 | 3103 | if ($exist[0]['nb'] == 0) { |
3104 | 3104 | $sthins->execute($airdata); |
3105 | 3105 | } else { |
3106 | - $sthup->execute(array(':type' => $airdata[':type'],':icao' => $icao)); |
|
3106 | + $sthup->execute(array(':type' => $airdata[':type'], ':icao' => $icao)); |
|
3107 | 3107 | } |
3108 | - } catch(PDOException $e) { |
|
3108 | + } catch (PDOException $e) { |
|
3109 | 3109 | return "error : ".$e->getMessage(); |
3110 | 3110 | } |
3111 | 3111 | } |
@@ -3137,23 +3137,23 @@ discard block |
||
3137 | 3137 | $Connection = new Connection(); |
3138 | 3138 | $sth = $Connection->db->prepare($query); |
3139 | 3139 | $sth->execute(); |
3140 | - } catch(PDOException $e) { |
|
3140 | + } catch (PDOException $e) { |
|
3141 | 3141 | return "error : ".$e->getMessage(); |
3142 | 3142 | } |
3143 | 3143 | |
3144 | 3144 | $error = ''; |
3145 | 3145 | if ($globalDebug) echo "Notam : Download..."; |
3146 | - update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss'); |
|
3146 | + update_db::download($globalNOTAMSource, $tmp_dir.'notam.rss'); |
|
3147 | 3147 | if (file_exists($tmp_dir.'notam.rss')) { |
3148 | - $notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true); |
|
3148 | + $notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')), true); |
|
3149 | 3149 | foreach ($notams['channel']['item'] as $notam) { |
3150 | - $title = explode(':',$notam['title']); |
|
3150 | + $title = explode(':', $notam['title']); |
|
3151 | 3151 | $data['ref'] = trim($title[0]); |
3152 | 3152 | unset($title[0]); |
3153 | - $data['title'] = trim(implode(':',$title)); |
|
3154 | - $description = strip_tags($notam['description'],'<pre>'); |
|
3155 | - preg_match(':^(.*?)<pre>:',$description,$match); |
|
3156 | - $q = explode('/',$match[1]); |
|
3153 | + $data['title'] = trim(implode(':', $title)); |
|
3154 | + $description = strip_tags($notam['description'], '<pre>'); |
|
3155 | + preg_match(':^(.*?)<pre>:', $description, $match); |
|
3156 | + $q = explode('/', $match[1]); |
|
3157 | 3157 | $data['fir'] = $q[0]; |
3158 | 3158 | $data['code'] = $q[1]; |
3159 | 3159 | $ifrvfr = $q[2]; |
@@ -3169,30 +3169,30 @@ discard block |
||
3169 | 3169 | $data['lower_limit'] = $q[5]; |
3170 | 3170 | $data['upper_limit'] = $q[6]; |
3171 | 3171 | $latlonrad = $q[7]; |
3172 | - sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius); |
|
3173 | - $latitude = $Common->convertDec($las,'latitude'); |
|
3174 | - $longitude = $Common->convertDec($lns,'longitude'); |
|
3172 | + sscanf($latlonrad, '%4c%c%5c%c%3d', $las, $lac, $lns, $lnc, $radius); |
|
3173 | + $latitude = $Common->convertDec($las, 'latitude'); |
|
3174 | + $longitude = $Common->convertDec($lns, 'longitude'); |
|
3175 | 3175 | if ($lac == 'S') $latitude = '-'.$latitude; |
3176 | 3176 | if ($lnc == 'W') $longitude = '-'.$longitude; |
3177 | 3177 | $data['center_latitude'] = $latitude; |
3178 | 3178 | $data['center_longitude'] = $longitude; |
3179 | 3179 | $data['radius'] = intval($radius); |
3180 | 3180 | |
3181 | - preg_match(':<pre>(.*?)</pre>:',$description,$match); |
|
3181 | + preg_match(':<pre>(.*?)</pre>:', $description, $match); |
|
3182 | 3182 | $data['text'] = $match[1]; |
3183 | - preg_match(':</pre>(.*?)$:',$description,$match); |
|
3183 | + preg_match(':</pre>(.*?)$:', $description, $match); |
|
3184 | 3184 | $fromto = $match[1]; |
3185 | - preg_match('#FROM:(.*?)TO:#',$fromto,$match); |
|
3185 | + preg_match('#FROM:(.*?)TO:#', $fromto, $match); |
|
3186 | 3186 | $fromall = trim($match[1]); |
3187 | - preg_match('#^(.*?) \((.*?)\)$#',$fromall,$match); |
|
3187 | + preg_match('#^(.*?) \((.*?)\)$#', $fromall, $match); |
|
3188 | 3188 | $from = trim($match[1]); |
3189 | - $data['date_begin'] = date("Y-m-d H:i:s",strtotime($from)); |
|
3190 | - preg_match('#TO:(.*?)$#',$fromto,$match); |
|
3189 | + $data['date_begin'] = date("Y-m-d H:i:s", strtotime($from)); |
|
3190 | + preg_match('#TO:(.*?)$#', $fromto, $match); |
|
3191 | 3191 | $toall = trim($match[1]); |
3192 | - if (!preg_match(':Permanent:',$toall)) { |
|
3193 | - preg_match('#^(.*?) \((.*?)\)#',$toall,$match); |
|
3192 | + if (!preg_match(':Permanent:', $toall)) { |
|
3193 | + preg_match('#^(.*?) \((.*?)\)#', $toall, $match); |
|
3194 | 3194 | $to = trim($match[1]); |
3195 | - $data['date_end'] = date("Y-m-d H:i:s",strtotime($to)); |
|
3195 | + $data['date_end'] = date("Y-m-d H:i:s", strtotime($to)); |
|
3196 | 3196 | $data['permanent'] = 0; |
3197 | 3197 | } else { |
3198 | 3198 | $data['date_end'] = NULL; |
@@ -3200,7 +3200,7 @@ discard block |
||
3200 | 3200 | } |
3201 | 3201 | $data['full_notam'] = $notam['title'].'<br>'.$notam['description']; |
3202 | 3202 | $NOTAM = new NOTAM(); |
3203 | - $NOTAM->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['center_latitude'],$data['center_longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']); |
|
3203 | + $NOTAM->addNOTAM($data['ref'], $data['title'], '', $data['fir'], $data['code'], '', $data['scope'], $data['lower_limit'], $data['upper_limit'], $data['center_latitude'], $data['center_longitude'], $data['radius'], $data['date_begin'], $data['date_end'], $data['permanent'], $data['text'], $data['full_notam']); |
|
3204 | 3204 | unset($data); |
3205 | 3205 | } |
3206 | 3206 | } else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed."; |
@@ -3223,16 +3223,16 @@ discard block |
||
3223 | 3223 | $Connection = new Connection(); |
3224 | 3224 | $sth = $Connection->db->prepare($query); |
3225 | 3225 | $sth->execute(); |
3226 | - } catch(PDOException $e) { |
|
3226 | + } catch (PDOException $e) { |
|
3227 | 3227 | return "error : ".$e->getMessage(); |
3228 | 3228 | } |
3229 | 3229 | } |
3230 | 3230 | $Common = new Common(); |
3231 | 3231 | $airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json'); |
3232 | - $airspace_json = json_decode($airspace_lst,true); |
|
3232 | + $airspace_json = json_decode($airspace_lst, true); |
|
3233 | 3233 | foreach ($airspace_json['records'] as $airspace) { |
3234 | 3234 | if ($globalDebug) echo $airspace['name']."...\n"; |
3235 | - update_db::download($airspace['uri'],$tmp_dir.$airspace['name']); |
|
3235 | + update_db::download($airspace['uri'], $tmp_dir.$airspace['name']); |
|
3236 | 3236 | if (file_exists($tmp_dir.$airspace['name'])) { |
3237 | 3237 | file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name']))); |
3238 | 3238 | //system('recode l9..utf8 '.$tmp_dir.$airspace['name']); |
@@ -3254,7 +3254,7 @@ discard block |
||
3254 | 3254 | $Connection = new Connection(); |
3255 | 3255 | $sth = $Connection->db->prepare($query); |
3256 | 3256 | $sth->execute(array(':new' => $new, ':old' => $old)); |
3257 | - } catch(PDOException $e) { |
|
3257 | + } catch (PDOException $e) { |
|
3258 | 3258 | return "error : ".$e->getMessage(); |
3259 | 3259 | } |
3260 | 3260 | } |
@@ -3271,7 +3271,7 @@ discard block |
||
3271 | 3271 | $Connection = new Connection(); |
3272 | 3272 | $sth = $Connection->db->prepare($query); |
3273 | 3273 | $sth->execute(); |
3274 | - } catch(PDOException $e) { |
|
3274 | + } catch (PDOException $e) { |
|
3275 | 3275 | return "error : ".$e->getMessage(); |
3276 | 3276 | } |
3277 | 3277 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -3286,7 +3286,7 @@ discard block |
||
3286 | 3286 | $Connection = new Connection(); |
3287 | 3287 | $sth = $Connection->db->prepare($query); |
3288 | 3288 | $sth->execute(); |
3289 | - } catch(PDOException $e) { |
|
3289 | + } catch (PDOException $e) { |
|
3290 | 3290 | return "error : ".$e->getMessage(); |
3291 | 3291 | } |
3292 | 3292 | } |
@@ -3297,7 +3297,7 @@ discard block |
||
3297 | 3297 | $Connection = new Connection(); |
3298 | 3298 | $sth = $Connection->db->prepare($query); |
3299 | 3299 | $sth->execute(array(':version' => $version)); |
3300 | - } catch(PDOException $e) { |
|
3300 | + } catch (PDOException $e) { |
|
3301 | 3301 | return "error : ".$e->getMessage(); |
3302 | 3302 | } |
3303 | 3303 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -3311,7 +3311,7 @@ discard block |
||
3311 | 3311 | $Connection = new Connection(); |
3312 | 3312 | $sth = $Connection->db->prepare($query); |
3313 | 3313 | $sth->execute(array(':version' => $version)); |
3314 | - } catch(PDOException $e) { |
|
3314 | + } catch (PDOException $e) { |
|
3315 | 3315 | return "error : ".$e->getMessage(); |
3316 | 3316 | } |
3317 | 3317 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -3325,7 +3325,7 @@ discard block |
||
3325 | 3325 | $Connection = new Connection(); |
3326 | 3326 | $sth = $Connection->db->prepare($query); |
3327 | 3327 | $sth->execute(array(':version' => $version)); |
3328 | - } catch(PDOException $e) { |
|
3328 | + } catch (PDOException $e) { |
|
3329 | 3329 | return "error : ".$e->getMessage(); |
3330 | 3330 | } |
3331 | 3331 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -3339,7 +3339,7 @@ discard block |
||
3339 | 3339 | $Connection = new Connection(); |
3340 | 3340 | $sth = $Connection->db->prepare($query); |
3341 | 3341 | $sth->execute(array(':version' => $version)); |
3342 | - } catch(PDOException $e) { |
|
3342 | + } catch (PDOException $e) { |
|
3343 | 3343 | return "error : ".$e->getMessage(); |
3344 | 3344 | } |
3345 | 3345 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -3352,7 +3352,7 @@ discard block |
||
3352 | 3352 | $Connection = new Connection(); |
3353 | 3353 | $sth = $Connection->db->prepare($query); |
3354 | 3354 | $sth->execute(array(':version' => $version)); |
3355 | - } catch(PDOException $e) { |
|
3355 | + } catch (PDOException $e) { |
|
3356 | 3356 | return "error : ".$e->getMessage(); |
3357 | 3357 | } |
3358 | 3358 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -3366,7 +3366,7 @@ discard block |
||
3366 | 3366 | $Connection = new Connection(); |
3367 | 3367 | $sth = $Connection->db->prepare($query); |
3368 | 3368 | $sth->execute(array(':version' => $version)); |
3369 | - } catch(PDOException $e) { |
|
3369 | + } catch (PDOException $e) { |
|
3370 | 3370 | return "error : ".$e->getMessage(); |
3371 | 3371 | } |
3372 | 3372 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -3380,7 +3380,7 @@ discard block |
||
3380 | 3380 | $Connection = new Connection(); |
3381 | 3381 | $sth = $Connection->db->prepare($query); |
3382 | 3382 | $sth->execute(array(':version' => $version)); |
3383 | - } catch(PDOException $e) { |
|
3383 | + } catch (PDOException $e) { |
|
3384 | 3384 | return "error : ".$e->getMessage(); |
3385 | 3385 | } |
3386 | 3386 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -3395,7 +3395,7 @@ discard block |
||
3395 | 3395 | $Connection = new Connection(); |
3396 | 3396 | $sth = $Connection->db->prepare($query); |
3397 | 3397 | $sth->execute(array(':version' => $version)); |
3398 | - } catch(PDOException $e) { |
|
3398 | + } catch (PDOException $e) { |
|
3399 | 3399 | return "error : ".$e->getMessage(); |
3400 | 3400 | } |
3401 | 3401 | } |
@@ -3407,7 +3407,7 @@ discard block |
||
3407 | 3407 | $Connection = new Connection(); |
3408 | 3408 | $sth = $Connection->db->prepare($query); |
3409 | 3409 | $sth->execute(array(':version' => $version)); |
3410 | - } catch(PDOException $e) { |
|
3410 | + } catch (PDOException $e) { |
|
3411 | 3411 | return "error : ".$e->getMessage(); |
3412 | 3412 | } |
3413 | 3413 | } |
@@ -3419,7 +3419,7 @@ discard block |
||
3419 | 3419 | $Connection = new Connection(); |
3420 | 3420 | $sth = $Connection->db->prepare($query); |
3421 | 3421 | $sth->execute(array(':version' => $version)); |
3422 | - } catch(PDOException $e) { |
|
3422 | + } catch (PDOException $e) { |
|
3423 | 3423 | return "error : ".$e->getMessage(); |
3424 | 3424 | } |
3425 | 3425 | } |
@@ -3431,7 +3431,7 @@ discard block |
||
3431 | 3431 | $Connection = new Connection(); |
3432 | 3432 | $sth = $Connection->db->prepare($query); |
3433 | 3433 | $sth->execute(array(':version' => $version)); |
3434 | - } catch(PDOException $e) { |
|
3434 | + } catch (PDOException $e) { |
|
3435 | 3435 | return "error : ".$e->getMessage(); |
3436 | 3436 | } |
3437 | 3437 | } |
@@ -3443,7 +3443,7 @@ discard block |
||
3443 | 3443 | $Connection = new Connection(); |
3444 | 3444 | $sth = $Connection->db->prepare($query); |
3445 | 3445 | $sth->execute(array(':version' => $version)); |
3446 | - } catch(PDOException $e) { |
|
3446 | + } catch (PDOException $e) { |
|
3447 | 3447 | return "error : ".$e->getMessage(); |
3448 | 3448 | } |
3449 | 3449 | } |
@@ -3455,7 +3455,7 @@ discard block |
||
3455 | 3455 | $Connection = new Connection(); |
3456 | 3456 | $sth = $Connection->db->prepare($query); |
3457 | 3457 | $sth->execute(array(':version' => $version)); |
3458 | - } catch(PDOException $e) { |
|
3458 | + } catch (PDOException $e) { |
|
3459 | 3459 | return "error : ".$e->getMessage(); |
3460 | 3460 | } |
3461 | 3461 | } |
@@ -3466,7 +3466,7 @@ discard block |
||
3466 | 3466 | $Connection = new Connection(); |
3467 | 3467 | $sth = $Connection->db->prepare($query); |
3468 | 3468 | $sth->execute(array(':version' => $version)); |
3469 | - } catch(PDOException $e) { |
|
3469 | + } catch (PDOException $e) { |
|
3470 | 3470 | return "error : ".$e->getMessage(); |
3471 | 3471 | } |
3472 | 3472 | } |
@@ -3482,7 +3482,7 @@ discard block |
||
3482 | 3482 | $Connection = new Connection(); |
3483 | 3483 | $sth = $Connection->db->prepare($query); |
3484 | 3484 | $sth->execute(); |
3485 | - } catch(PDOException $e) { |
|
3485 | + } catch (PDOException $e) { |
|
3486 | 3486 | return "error : ".$e->getMessage(); |
3487 | 3487 | } |
3488 | 3488 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -3497,7 +3497,7 @@ discard block |
||
3497 | 3497 | $Connection = new Connection(); |
3498 | 3498 | $sth = $Connection->db->prepare($query); |
3499 | 3499 | $sth->execute(); |
3500 | - } catch(PDOException $e) { |
|
3500 | + } catch (PDOException $e) { |
|
3501 | 3501 | return "error : ".$e->getMessage(); |
3502 | 3502 | } |
3503 | 3503 | } |
@@ -3513,7 +3513,7 @@ discard block |
||
3513 | 3513 | $Connection = new Connection(); |
3514 | 3514 | $sth = $Connection->db->prepare($query); |
3515 | 3515 | $sth->execute(); |
3516 | - } catch(PDOException $e) { |
|
3516 | + } catch (PDOException $e) { |
|
3517 | 3517 | return "error : ".$e->getMessage(); |
3518 | 3518 | } |
3519 | 3519 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -3528,7 +3528,7 @@ discard block |
||
3528 | 3528 | $Connection = new Connection(); |
3529 | 3529 | $sth = $Connection->db->prepare($query); |
3530 | 3530 | $sth->execute(); |
3531 | - } catch(PDOException $e) { |
|
3531 | + } catch (PDOException $e) { |
|
3532 | 3532 | return "error : ".$e->getMessage(); |
3533 | 3533 | } |
3534 | 3534 | } |
@@ -3544,7 +3544,7 @@ discard block |
||
3544 | 3544 | $Connection = new Connection(); |
3545 | 3545 | $sth = $Connection->db->prepare($query); |
3546 | 3546 | $sth->execute(); |
3547 | - } catch(PDOException $e) { |
|
3547 | + } catch (PDOException $e) { |
|
3548 | 3548 | return "error : ".$e->getMessage(); |
3549 | 3549 | } |
3550 | 3550 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -3559,7 +3559,7 @@ discard block |
||
3559 | 3559 | $Connection = new Connection(); |
3560 | 3560 | $sth = $Connection->db->prepare($query); |
3561 | 3561 | $sth->execute(); |
3562 | - } catch(PDOException $e) { |
|
3562 | + } catch (PDOException $e) { |
|
3563 | 3563 | return "error : ".$e->getMessage(); |
3564 | 3564 | } |
3565 | 3565 | } |
@@ -3575,7 +3575,7 @@ discard block |
||
3575 | 3575 | $Connection = new Connection(); |
3576 | 3576 | $sth = $Connection->db->prepare($query); |
3577 | 3577 | $sth->execute(); |
3578 | - } catch(PDOException $e) { |
|
3578 | + } catch (PDOException $e) { |
|
3579 | 3579 | return "error : ".$e->getMessage(); |
3580 | 3580 | } |
3581 | 3581 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -3590,7 +3590,7 @@ discard block |
||
3590 | 3590 | $Connection = new Connection(); |
3591 | 3591 | $sth = $Connection->db->prepare($query); |
3592 | 3592 | $sth->execute(); |
3593 | - } catch(PDOException $e) { |
|
3593 | + } catch (PDOException $e) { |
|
3594 | 3594 | return "error : ".$e->getMessage(); |
3595 | 3595 | } |
3596 | 3596 | } |
@@ -3606,7 +3606,7 @@ discard block |
||
3606 | 3606 | $Connection = new Connection(); |
3607 | 3607 | $sth = $Connection->db->prepare($query); |
3608 | 3608 | $sth->execute(); |
3609 | - } catch(PDOException $e) { |
|
3609 | + } catch (PDOException $e) { |
|
3610 | 3610 | return "error : ".$e->getMessage(); |
3611 | 3611 | } |
3612 | 3612 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -3621,7 +3621,7 @@ discard block |
||
3621 | 3621 | $Connection = new Connection(); |
3622 | 3622 | $sth = $Connection->db->prepare($query); |
3623 | 3623 | $sth->execute(); |
3624 | - } catch(PDOException $e) { |
|
3624 | + } catch (PDOException $e) { |
|
3625 | 3625 | return "error : ".$e->getMessage(); |
3626 | 3626 | } |
3627 | 3627 | } |
@@ -3637,7 +3637,7 @@ discard block |
||
3637 | 3637 | $Connection = new Connection(); |
3638 | 3638 | $sth = $Connection->db->prepare($query); |
3639 | 3639 | $sth->execute(); |
3640 | - } catch(PDOException $e) { |
|
3640 | + } catch (PDOException $e) { |
|
3641 | 3641 | return "error : ".$e->getMessage(); |
3642 | 3642 | } |
3643 | 3643 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -3652,7 +3652,7 @@ discard block |
||
3652 | 3652 | $Connection = new Connection(); |
3653 | 3653 | $sth = $Connection->db->prepare($query); |
3654 | 3654 | $sth->execute(); |
3655 | - } catch(PDOException $e) { |
|
3655 | + } catch (PDOException $e) { |
|
3656 | 3656 | return "error : ".$e->getMessage(); |
3657 | 3657 | } |
3658 | 3658 | } |
@@ -3668,7 +3668,7 @@ discard block |
||
3668 | 3668 | $Connection = new Connection(); |
3669 | 3669 | $sth = $Connection->db->prepare($query); |
3670 | 3670 | $sth->execute(); |
3671 | - } catch(PDOException $e) { |
|
3671 | + } catch (PDOException $e) { |
|
3672 | 3672 | return "error : ".$e->getMessage(); |
3673 | 3673 | } |
3674 | 3674 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -3683,7 +3683,7 @@ discard block |
||
3683 | 3683 | $Connection = new Connection(); |
3684 | 3684 | $sth = $Connection->db->prepare($query); |
3685 | 3685 | $sth->execute(); |
3686 | - } catch(PDOException $e) { |
|
3686 | + } catch (PDOException $e) { |
|
3687 | 3687 | return "error : ".$e->getMessage(); |
3688 | 3688 | } |
3689 | 3689 | } |
@@ -3699,7 +3699,7 @@ discard block |
||
3699 | 3699 | $Connection = new Connection(); |
3700 | 3700 | $sth = $Connection->db->prepare($query); |
3701 | 3701 | $sth->execute(); |
3702 | - } catch(PDOException $e) { |
|
3702 | + } catch (PDOException $e) { |
|
3703 | 3703 | return "error : ".$e->getMessage(); |
3704 | 3704 | } |
3705 | 3705 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -3714,7 +3714,7 @@ discard block |
||
3714 | 3714 | $Connection = new Connection(); |
3715 | 3715 | $sth = $Connection->db->prepare($query); |
3716 | 3716 | $sth->execute(); |
3717 | - } catch(PDOException $e) { |
|
3717 | + } catch (PDOException $e) { |
|
3718 | 3718 | return "error : ".$e->getMessage(); |
3719 | 3719 | } |
3720 | 3720 | } |
@@ -3730,7 +3730,7 @@ discard block |
||
3730 | 3730 | $Connection = new Connection(); |
3731 | 3731 | $sth = $Connection->db->prepare($query); |
3732 | 3732 | $sth->execute(); |
3733 | - } catch(PDOException $e) { |
|
3733 | + } catch (PDOException $e) { |
|
3734 | 3734 | return "error : ".$e->getMessage(); |
3735 | 3735 | } |
3736 | 3736 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -3745,7 +3745,7 @@ discard block |
||
3745 | 3745 | $Connection = new Connection(); |
3746 | 3746 | $sth = $Connection->db->prepare($query); |
3747 | 3747 | $sth->execute(); |
3748 | - } catch(PDOException $e) { |
|
3748 | + } catch (PDOException $e) { |
|
3749 | 3749 | return "error : ".$e->getMessage(); |
3750 | 3750 | } |
3751 | 3751 | } |
@@ -3761,7 +3761,7 @@ discard block |
||
3761 | 3761 | $Connection = new Connection(); |
3762 | 3762 | $sth = $Connection->db->prepare($query); |
3763 | 3763 | $sth->execute(); |
3764 | - } catch(PDOException $e) { |
|
3764 | + } catch (PDOException $e) { |
|
3765 | 3765 | return "error : ".$e->getMessage(); |
3766 | 3766 | } |
3767 | 3767 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -3776,7 +3776,7 @@ discard block |
||
3776 | 3776 | $Connection = new Connection(); |
3777 | 3777 | $sth = $Connection->db->prepare($query); |
3778 | 3778 | $sth->execute(); |
3779 | - } catch(PDOException $e) { |
|
3779 | + } catch (PDOException $e) { |
|
3780 | 3780 | return "error : ".$e->getMessage(); |
3781 | 3781 | } |
3782 | 3782 | } |
@@ -3792,7 +3792,7 @@ discard block |
||
3792 | 3792 | $Connection = new Connection(); |
3793 | 3793 | $sth = $Connection->db->prepare($query); |
3794 | 3794 | $sth->execute(); |
3795 | - } catch(PDOException $e) { |
|
3795 | + } catch (PDOException $e) { |
|
3796 | 3796 | return "error : ".$e->getMessage(); |
3797 | 3797 | } |
3798 | 3798 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -3811,7 +3811,7 @@ discard block |
||
3811 | 3811 | $Connection = new Connection(); |
3812 | 3812 | $sth = $Connection->db->prepare($query); |
3813 | 3813 | $sth->execute(); |
3814 | - } catch(PDOException $e) { |
|
3814 | + } catch (PDOException $e) { |
|
3815 | 3815 | return "error : ".$e->getMessage(); |
3816 | 3816 | } |
3817 | 3817 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -3826,7 +3826,7 @@ discard block |
||
3826 | 3826 | $Connection = new Connection(); |
3827 | 3827 | $sth = $Connection->db->prepare($query); |
3828 | 3828 | $sth->execute(); |
3829 | - } catch(PDOException $e) { |
|
3829 | + } catch (PDOException $e) { |
|
3830 | 3830 | return "error : ".$e->getMessage(); |
3831 | 3831 | } |
3832 | 3832 | } |
@@ -3838,7 +3838,7 @@ discard block |
||
3838 | 3838 | $Connection = new Connection(); |
3839 | 3839 | $sth = $Connection->db->prepare($query); |
3840 | 3840 | $sth->execute(); |
3841 | - } catch(PDOException $e) { |
|
3841 | + } catch (PDOException $e) { |
|
3842 | 3842 | return "error : ".$e->getMessage(); |
3843 | 3843 | } |
3844 | 3844 | } |
@@ -3854,7 +3854,7 @@ discard block |
||
3854 | 3854 | $Connection = new Connection(); |
3855 | 3855 | $sth = $Connection->db->prepare($query); |
3856 | 3856 | $sth->execute(); |
3857 | - } catch(PDOException $e) { |
|
3857 | + } catch (PDOException $e) { |
|
3858 | 3858 | return "error : ".$e->getMessage(); |
3859 | 3859 | } |
3860 | 3860 | } |
@@ -3869,7 +3869,7 @@ discard block |
||
3869 | 3869 | $Connection = new Connection(); |
3870 | 3870 | $sth = $Connection->db->prepare($query); |
3871 | 3871 | $sth->execute(); |
3872 | - } catch(PDOException $e) { |
|
3872 | + } catch (PDOException $e) { |
|
3873 | 3873 | return "error : ".$e->getMessage(); |
3874 | 3874 | } |
3875 | 3875 | } |
@@ -18,30 +18,30 @@ discard block |
||
18 | 18 | public function parse($buffer) { |
19 | 19 | // Not yet finished, no CRC checks |
20 | 20 | $data = array(); |
21 | - $typehex = substr($buffer,0,1); |
|
21 | + $typehex = substr($buffer, 0, 1); |
|
22 | 22 | if ($typehex == '*' || $typehex == ':') { |
23 | - $hex = substr($buffer,1); |
|
24 | - if(substr($hex,-1,1)==";") { |
|
25 | - $hex=substr($hex,0,-1); |
|
23 | + $hex = substr($buffer, 1); |
|
24 | + if (substr($hex, -1, 1) == ";") { |
|
25 | + $hex = substr($hex, 0, -1); |
|
26 | 26 | } |
27 | 27 | } |
28 | 28 | //elseif ($typehex == '@' || $typehex == '%') $hex = substr($buffer,13,-13); |
29 | - elseif ($typehex == '@' || $typehex == '%') $hex = substr($buffer,13,-1); |
|
30 | - else $hex = substr($buffer,1,-1); |
|
31 | - $bin = gmp_strval( gmp_init($hex,16), 2); |
|
29 | + elseif ($typehex == '@' || $typehex == '%') $hex = substr($buffer, 13, -1); |
|
30 | + else $hex = substr($buffer, 1, -1); |
|
31 | + $bin = gmp_strval(gmp_init($hex, 16), 2); |
|
32 | 32 | //if (strlen($hex) == 28 && $this->parityCheck($hex,$bin)) { |
33 | 33 | //if (strlen($hex) == 28) { |
34 | 34 | //echo strlen($hex); |
35 | 35 | //echo $hex; |
36 | 36 | if (strlen($hex) == 28 || strlen($hex) == 16) { |
37 | - $df = intval(substr($bin,0,5),2); |
|
37 | + $df = intval(substr($bin, 0, 5), 2); |
|
38 | 38 | //$ca = intval(substr($bin,5,3),2); |
39 | 39 | // Only support DF17 for now |
40 | 40 | //if ($df == 17 || ($df == 18 && ($ca == 0 || $ca == 1 || $ca == 6))) { |
41 | - if (($df == 17 || $df == 18) && ($this->parityCheck($hex,$bin) || $typehex == '@')) { |
|
42 | - $icao = substr($hex,2,6); |
|
41 | + if (($df == 17 || $df == 18) && ($this->parityCheck($hex, $bin) || $typehex == '@')) { |
|
42 | + $icao = substr($hex, 2, 6); |
|
43 | 43 | $data['hex'] = $icao; |
44 | - $tc = intval(substr($bin,32,5),2); |
|
44 | + $tc = intval(substr($bin, 32, 5), 2); |
|
45 | 45 | if ($tc >= 1 && $tc <= 4) { |
46 | 46 | // Category: |
47 | 47 | // 1 = light aircraft <= 7000 kg |
@@ -64,67 +64,67 @@ discard block |
||
64 | 64 | // 22 = fixed ground or tethered obstruction |
65 | 65 | // 23 to 24 = reserved |
66 | 66 | //$data['category'] = intval(substr($bin,5,3),2); |
67 | - $data['category'] = intval(substr($bin,37,3),2); |
|
67 | + $data['category'] = intval(substr($bin, 37, 3), 2); |
|
68 | 68 | //callsign |
69 | - $csbin = substr($bin,40,56); |
|
69 | + $csbin = substr($bin, 40, 56); |
|
70 | 70 | $charset = str_split('#ABCDEFGHIJKLMNOPQRSTUVWXYZ#####_###############0123456789######'); |
71 | 71 | $cs = ''; |
72 | - $cs .= $charset[intval(substr($csbin,0,6),2)]; |
|
73 | - $cs .= $charset[intval(substr($csbin,6,6),2)]; |
|
74 | - $cs .= $charset[intval(substr($csbin,12,6),2)]; |
|
75 | - $cs .= $charset[intval(substr($csbin,18,6),2)]; |
|
76 | - $cs .= $charset[intval(substr($csbin,24,6),2)]; |
|
77 | - $cs .= $charset[intval(substr($csbin,30,6),2)]; |
|
78 | - $cs .= $charset[intval(substr($csbin,36,6),2)]; |
|
79 | - $cs .= $charset[intval(substr($csbin,42,6),2)]; |
|
80 | - $cs = str_replace('_','',$cs); |
|
81 | - $cs = str_replace('#','',$cs); |
|
72 | + $cs .= $charset[intval(substr($csbin, 0, 6), 2)]; |
|
73 | + $cs .= $charset[intval(substr($csbin, 6, 6), 2)]; |
|
74 | + $cs .= $charset[intval(substr($csbin, 12, 6), 2)]; |
|
75 | + $cs .= $charset[intval(substr($csbin, 18, 6), 2)]; |
|
76 | + $cs .= $charset[intval(substr($csbin, 24, 6), 2)]; |
|
77 | + $cs .= $charset[intval(substr($csbin, 30, 6), 2)]; |
|
78 | + $cs .= $charset[intval(substr($csbin, 36, 6), 2)]; |
|
79 | + $cs .= $charset[intval(substr($csbin, 42, 6), 2)]; |
|
80 | + $cs = str_replace('_', '', $cs); |
|
81 | + $cs = str_replace('#', '', $cs); |
|
82 | 82 | $callsign = $cs; |
83 | 83 | $data['ident'] = $callsign; |
84 | 84 | } elseif ($tc >= 9 && $tc <= 18) { |
85 | 85 | // Check Q-bit |
86 | - $q = substr($bin,47,1); |
|
86 | + $q = substr($bin, 47, 1); |
|
87 | 87 | if ($q) { |
88 | - $n = intval(substr($bin,40,7).substr($bin,48,4),2); |
|
89 | - $alt = $n*25-1000; |
|
88 | + $n = intval(substr($bin, 40, 7).substr($bin, 48, 4), 2); |
|
89 | + $alt = $n*25 - 1000; |
|
90 | 90 | $data['altitude'] = $alt; |
91 | 91 | } |
92 | 92 | // Check odd/even flag |
93 | - $oe = substr($bin,53,1); |
|
93 | + $oe = substr($bin, 53, 1); |
|
94 | 94 | //if ($oe) => odd else even |
95 | 95 | // 131072 is 2^17 since CPR latitude and longitude are encoded in 17 bits. |
96 | - $cprlat = intval(substr($bin,54,17),2)/131072.0; |
|
97 | - $cprlon = intval(substr($bin,71,17),2)/131072.0; |
|
98 | - if ($oe == 0) $this::$latlon[$icao] = array('latitude' => $cprlat,'longitude' => $cprlon,'created' => time()); |
|
96 | + $cprlat = intval(substr($bin, 54, 17), 2)/131072.0; |
|
97 | + $cprlon = intval(substr($bin, 71, 17), 2)/131072.0; |
|
98 | + if ($oe == 0) $this::$latlon[$icao] = array('latitude' => $cprlat, 'longitude' => $cprlon, 'created' => time()); |
|
99 | 99 | elseif (isset($this::$latlon[$icao]) && (time() - $this::$latlon[$icao]['created']) < 10) { |
100 | 100 | $cprlat_odd = $cprlat; |
101 | 101 | $cprlon_odd = $cprlon; |
102 | 102 | $cprlat_even = $this::$latlon[$icao]['latitude']; |
103 | 103 | $cprlon_even = $this::$latlon[$icao]['longitude']; |
104 | - $j = 59*$cprlat_even-60*$cprlat_odd+0.5; |
|
105 | - $lat_even = (360.0/60)*($j%60+$cprlat_even); |
|
106 | - $lat_odd = (360.0/59)*($j%59+$cprlat_odd); |
|
104 | + $j = 59*$cprlat_even - 60*$cprlat_odd + 0.5; |
|
105 | + $lat_even = (360.0/60)*($j%60 + $cprlat_even); |
|
106 | + $lat_odd = (360.0/59)*($j%59 + $cprlat_odd); |
|
107 | 107 | if ($lat_even >= 270) $lat_even = $lat_even - 360; |
108 | 108 | if ($lat_odd >= 270) $lat_odd = $lat_odd - 360; |
109 | 109 | // check latitude zone |
110 | 110 | if ($this->cprNL($lat_even) == $this->cprNL($lat_odd)) { |
111 | 111 | if ($this::$latlon[$icao]['created'] > time()) { |
112 | - $ni = $this->cprN($lat_even,0); |
|
113 | - $m = floor($cprlon_even*($this->cprNL($lat_even)-1) - $cprlon_odd * $this->cprNL($lat_even)+0.5); |
|
114 | - $lon = (360.0/$ni)*($m%$ni+$cprlon_even); |
|
112 | + $ni = $this->cprN($lat_even, 0); |
|
113 | + $m = floor($cprlon_even*($this->cprNL($lat_even) - 1) - $cprlon_odd*$this->cprNL($lat_even) + 0.5); |
|
114 | + $lon = (360.0/$ni)*($m%$ni + $cprlon_even); |
|
115 | 115 | $lat = $lat_even; |
116 | - if ($lon > 180) $lon = $lon -360; |
|
116 | + if ($lon > 180) $lon = $lon - 360; |
|
117 | 117 | if ($lat > -91 && $lat < 91 && $lon > -181 && $lon < 181) { |
118 | 118 | //if ($globalDebug) echo 'cs : '.$cs.' - hex : '.$hex.' - lat : '.$lat.' - lon : '.$lon; |
119 | 119 | $data['latitude'] = $lat; |
120 | 120 | $data['longitude'] = $lon; |
121 | 121 | } |
122 | 122 | } else { |
123 | - $ni = $this->cprN($lat_odd,1); |
|
124 | - $m = floor($cprlon_even*($this->cprNL($lat_odd)-1) - $cprlon_odd * $this->cprNL($lat_odd)+0.5); |
|
125 | - $lon = (360.0/$ni)*($m%$ni+$cprlon_odd); |
|
123 | + $ni = $this->cprN($lat_odd, 1); |
|
124 | + $m = floor($cprlon_even*($this->cprNL($lat_odd) - 1) - $cprlon_odd*$this->cprNL($lat_odd) + 0.5); |
|
125 | + $lon = (360.0/$ni)*($m%$ni + $cprlon_odd); |
|
126 | 126 | $lat = $lat_odd; |
127 | - if ($lon > 180) $lon = $lon -360; |
|
127 | + if ($lon > 180) $lon = $lon - 360; |
|
128 | 128 | if ($lat > -91 && $lat < 91 && $lon > -181 && $lon < 181) { |
129 | 129 | //if ($globalDebug) echo 'icao : '.$icao.' - hex : '.$hex.' - lat : '.$lat.' - lon : '.$lon.' second'."\n"; |
130 | 130 | $data['latitude'] = $lat; |
@@ -136,15 +136,15 @@ discard block |
||
136 | 136 | } |
137 | 137 | } elseif ($tc == 19) { |
138 | 138 | // speed & heading |
139 | - $v_ew_dir = intval(substr($bin,45,1)); |
|
140 | - $v_ew = intval(substr($bin,46,10),2); |
|
141 | - $v_ns_dir = intval(substr($bin,56,1)); |
|
142 | - $v_ns = intval(substr($bin,57,10),2); |
|
139 | + $v_ew_dir = intval(substr($bin, 45, 1)); |
|
140 | + $v_ew = intval(substr($bin, 46, 10), 2); |
|
141 | + $v_ns_dir = intval(substr($bin, 56, 1)); |
|
142 | + $v_ns = intval(substr($bin, 57, 10), 2); |
|
143 | 143 | if ($v_ew_dir) $v_ew = -1*$v_ew; |
144 | 144 | if ($v_ns_dir) $v_ns = -1*$v_ns; |
145 | - $speed = sqrt($v_ns*$v_ns+$v_ew*$v_ew); |
|
146 | - $heading = atan2($v_ew,$v_ns)*360.0/(2*pi()); |
|
147 | - if ($heading <0) $heading = $heading+360; |
|
145 | + $speed = sqrt($v_ns*$v_ns + $v_ew*$v_ew); |
|
146 | + $heading = atan2($v_ew, $v_ns)*360.0/(2*pi()); |
|
147 | + if ($heading < 0) $heading = $heading + 360; |
|
148 | 148 | $data['speed'] = $speed; |
149 | 149 | $data['heading'] = $heading; |
150 | 150 | } |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | * Lookup table to convert the latitude to index. |
160 | 160 | */ |
161 | 161 | private function cprNL($lat) { |
162 | - if ($lat < 0) $lat = -$lat; // Table is simmetric about the equator. |
|
162 | + if ($lat < 0) $lat = -$lat; // Table is simmetric about the equator. |
|
163 | 163 | if ($lat < 10.47047130) return 59; |
164 | 164 | if ($lat < 14.82817437) return 58; |
165 | 165 | if ($lat < 18.18626357) return 57; |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | return 1; |
222 | 222 | } |
223 | 223 | |
224 | - private function cprN($lat,$isodd) { |
|
224 | + private function cprN($lat, $isodd) { |
|
225 | 225 | $nl = $this->cprNL($lat) - $isodd; |
226 | 226 | if ($nl > 1) return $nl; |
227 | 227 | else return 1; |
@@ -245,9 +245,9 @@ discard block |
||
245 | 245 | 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000 |
246 | 246 | ); |
247 | 247 | $crc = 0; |
248 | - $checksum = intval(substr($msg,22,6),16); |
|
248 | + $checksum = intval(substr($msg, 22, 6), 16); |
|
249 | 249 | for ($j = 0; $j < strlen($bin); $j++) { |
250 | - if ($bin[$j]) $crc = $crc^intval($modes_checksum_table[$j],0); |
|
250 | + if ($bin[$j]) $crc = $crc^intval($modes_checksum_table[$j], 0); |
|
251 | 251 | } |
252 | 252 | if ($crc == $checksum) return true; |
253 | 253 | else { |
@@ -269,10 +269,10 @@ discard block |
||
269 | 269 | $msg['aircraftid'] = hexdec($data['address']); |
270 | 270 | $msg['hex'] = $data['address']; |
271 | 271 | $msg['flightid'] = hexdec($data['address']); |
272 | - $msg['date_gen'] = date('Y/m/d',$data['timestamp']); |
|
273 | - $msg['time_gen'] = date('H:i:s',$data['timestamp']).'.180'; |
|
274 | - $msg['date_log'] = date('Y/m/d',$data['timestamp']); |
|
275 | - $msg['time_log'] = date('H:i:s',$data['timestamp']).'.180'; |
|
272 | + $msg['date_gen'] = date('Y/m/d', $data['timestamp']); |
|
273 | + $msg['time_gen'] = date('H:i:s', $data['timestamp']).'.180'; |
|
274 | + $msg['date_log'] = date('Y/m/d', $data['timestamp']); |
|
275 | + $msg['time_log'] = date('H:i:s', $data['timestamp']).'.180'; |
|
276 | 276 | $msg['callsign'] = $data['ident']; |
277 | 277 | $msg['altitude'] = ''; |
278 | 278 | $msg['speed'] = ''; |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | $msg['emergency'] = ''; |
286 | 286 | $msg['SPI'] = ''; |
287 | 287 | $msg['ground'] = ''; |
288 | - $result[] = implode(',',$msg); |
|
288 | + $result[] = implode(',', $msg); |
|
289 | 289 | } |
290 | 290 | if (isset($data['latitude']) && $data['latitude'] != 0) { |
291 | 291 | $msg = array(); |
@@ -295,10 +295,10 @@ discard block |
||
295 | 295 | $msg['aircraftid'] = hexdec($data['address']); |
296 | 296 | $msg['hex'] = $data['address']; |
297 | 297 | $msg['flightid'] = hexdec($data['address']); |
298 | - $msg['date_gen'] = date('Y/m/d',$data['timestamp']); |
|
299 | - $msg['time_gen'] = date('H:i:s',$data['timestamp']).'.180'; |
|
300 | - $msg['date_log'] = date('Y/m/d',$data['timestamp']); |
|
301 | - $msg['time_log'] = date('H:i:s',$data['timestamp']).'.180'; |
|
298 | + $msg['date_gen'] = date('Y/m/d', $data['timestamp']); |
|
299 | + $msg['time_gen'] = date('H:i:s', $data['timestamp']).'.180'; |
|
300 | + $msg['date_log'] = date('Y/m/d', $data['timestamp']); |
|
301 | + $msg['time_log'] = date('H:i:s', $data['timestamp']).'.180'; |
|
302 | 302 | $msg['callsign'] = ''; |
303 | 303 | if (isset($data['altitude'])) $msg['altitude'] = $data['altitude']; |
304 | 304 | else $msg['altitude'] = ''; |
@@ -316,7 +316,7 @@ discard block |
||
316 | 316 | $msg['SPI'] = 0; |
317 | 317 | if (isset($data['ground'])) $msg['ground'] = 1; |
318 | 318 | else $msg['ground'] = 0; |
319 | - $result[] = implode(',',$msg); |
|
319 | + $result[] = implode(',', $msg); |
|
320 | 320 | } |
321 | 321 | return $result; |
322 | 322 | } |
@@ -11,12 +11,12 @@ discard block |
||
11 | 11 | public function buildcloudlayer($metar) { |
12 | 12 | //print_r($metar); |
13 | 13 | $result = array(); |
14 | - foreach($metar['cloud'] as $key => $data) { |
|
14 | + foreach ($metar['cloud'] as $key => $data) { |
|
15 | 15 | $alt_m = $metar['cloud'][$key]['level']; |
16 | 16 | $alt_ft = $alt_m*3.28084; |
17 | 17 | $pressure = $metar['QNH']; |
18 | - $cumulus_base = 122.0 * ($metar['temperature'] - $metar['dew']); |
|
19 | - $stratus_base = 100.0 * (100.0 * $metar['rh'])*0.3048; |
|
18 | + $cumulus_base = 122.0*($metar['temperature'] - $metar['dew']); |
|
19 | + $stratus_base = 100.0*(100.0*$metar['rh'])*0.3048; |
|
20 | 20 | $coverage_norm = 0.0; |
21 | 21 | if ($metar['cloud'][$key]['type'] == 'Few') { |
22 | 22 | $coverage_norm = 2.0/8.0; |
@@ -38,9 +38,9 @@ discard block |
||
38 | 38 | $layer_type = 'ns'; |
39 | 39 | } |
40 | 40 | } else { |
41 | - if ($cumulus_base * 0.80 < $alt_m && $cumulus_base * 1.20 > $alt_m) { |
|
41 | + if ($cumulus_base*0.80 < $alt_m && $cumulus_base*1.20 > $alt_m) { |
|
42 | 42 | $layer_type = 'cu'; |
43 | - } elseif ($stratus_base * 0.80 < $alt_m && $stratus_base * 1.40 > $alt_m) { |
|
43 | + } elseif ($stratus_base*0.80 < $alt_m && $stratus_base*1.40 > $alt_m) { |
|
44 | 44 | $layer_type = 'st'; |
45 | 45 | } else { |
46 | 46 | if ($alt_ft < 2000) { |
@@ -53,25 +53,25 @@ discard block |
||
53 | 53 | } |
54 | 54 | } |
55 | 55 | //echo 'coverage norm : '.$coverage_norm.' - layer_type: '.$layer_type."\n"; |
56 | - $result[] = array('cov' => $coverage_norm, 'type' => $layer_type,'alt' => $alt_m,'rh' => $metar['rh']); |
|
56 | + $result[] = array('cov' => $coverage_norm, 'type' => $layer_type, 'alt' => $alt_m, 'rh' => $metar['rh']); |
|
57 | 57 | } |
58 | 58 | if (count($result) < 2 && $metar['rh'] > 60) { |
59 | - $result[] = array('cov' => 0.75, 'type' => 'ci','alt' => 4000,'rh' => $metar['rh']); |
|
59 | + $result[] = array('cov' => 0.75, 'type' => 'ci', 'alt' => 4000, 'rh' => $metar['rh']); |
|
60 | 60 | } |
61 | 61 | return $result; |
62 | 62 | } |
63 | 63 | |
64 | - public function openweathermap($latitude,$longitude) { |
|
64 | + public function openweathermap($latitude, $longitude) { |
|
65 | 65 | global $globalOpenWeatherMapKey; |
66 | 66 | if ($globalOpenWeatherMapKey == '') return array(); |
67 | 67 | $Common = new Common(); |
68 | 68 | $url = 'http://api.openweathermap.org/data/2.5/weather?lat='.$latitude.'&lon='.$longitude.'&units=metric&appid='.$globalOpenWeatherMapKey; |
69 | 69 | //echo $url."\n"; |
70 | - $weatherdata = json_decode($Common->getData($url),true); |
|
71 | - if (!isset($weatherdata['main']['temp']) || !isset($weatherdata['weather'][0]['id'])) return array('clouds' => array(),'rain' => array()); |
|
72 | - $dew = $weatherdata['main']['temp'] - ((100-$weatherdata['main']['humidity'])/5); |
|
73 | - $cumulus_base = 122.0 * ($weatherdata['main']['temp'] - $dew); |
|
74 | - $stratus_base = 100.0 * (100.0 * $weatherdata['main']['humidity'])*0.3048; |
|
70 | + $weatherdata = json_decode($Common->getData($url), true); |
|
71 | + if (!isset($weatherdata['main']['temp']) || !isset($weatherdata['weather'][0]['id'])) return array('clouds' => array(), 'rain' => array()); |
|
72 | + $dew = $weatherdata['main']['temp'] - ((100 - $weatherdata['main']['humidity'])/5); |
|
73 | + $cumulus_base = 122.0*($weatherdata['main']['temp'] - $dew); |
|
74 | + $stratus_base = 100.0*(100.0*$weatherdata['main']['humidity'])*0.3048; |
|
75 | 75 | $coverage_norm = 0.0; |
76 | 76 | if ($weatherdata['weather'][0]['id'] == 801) { |
77 | 77 | // few clouds |
@@ -87,19 +87,19 @@ discard block |
||
87 | 87 | $coverage_norm = 8.0/8.0; |
88 | 88 | } |
89 | 89 | $alt_m = 1000; |
90 | - if ($cumulus_base * 0.80 < $alt_m && $cumulus_base * 1.20 > $alt_m) { |
|
90 | + if ($cumulus_base*0.80 < $alt_m && $cumulus_base*1.20 > $alt_m) { |
|
91 | 91 | $layer_type = 'cu'; |
92 | - } elseif ($stratus_base * 0.80 < $alt_m && $stratus_base * 1.40 > $alt_m) { |
|
92 | + } elseif ($stratus_base*0.80 < $alt_m && $stratus_base*1.40 > $alt_m) { |
|
93 | 93 | $layer_type = 'st'; |
94 | 94 | } else { |
95 | 95 | $layer_type = 'st'; |
96 | 96 | } |
97 | 97 | $result = array(); |
98 | - $result[] = array('cov' => $coverage_norm, 'type' => $layer_type,'alt' => $alt_m,'rh' => $weatherdata['main']['humidity']); |
|
98 | + $result[] = array('cov' => $coverage_norm, 'type' => $layer_type, 'alt' => $alt_m, 'rh' => $weatherdata['main']['humidity']); |
|
99 | 99 | if ($weatherdata['main']['humidity'] > 60) { |
100 | - $result[] = array('cov' => 0.75, 'type' => 'ci','alt' => 4000,'rh' => $weatherdata['main']['humidity']); |
|
100 | + $result[] = array('cov' => 0.75, 'type' => 'ci', 'alt' => 4000, 'rh' => $weatherdata['main']['humidity']); |
|
101 | 101 | } |
102 | - return array('clouds' => $result,'rain' => array('tmp' => $weatherdata['main']['temp'],'rh' => $weatherdata['main']['humidity'])); |
|
102 | + return array('clouds' => $result, 'rain' => array('tmp' => $weatherdata['main']['temp'], 'rh' => $weatherdata['main']['humidity'])); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | public function nomad_wind($hour = '') { |
@@ -117,8 +117,8 @@ discard block |
||
117 | 117 | |
118 | 118 | // http://nomads.ncep.noaa.gov/cgi-bin/filter_gfs_0p50.pl?file=gfs.t05z.pgrb2full.0p50.f000&lev_10_m_above_ground=on&lev_surface=on&var_TMP=on&var_UGRD=on&var_VGRD=on&leftlon=0&rightlon=360&toplat=90&bottomlat=-90&dir=/gfs.2017111717 |
119 | 119 | $resolution = '0.5'; |
120 | - $baseurl = 'http://nomads.ncep.noaa.gov/cgi-bin/filter_gfs_'.($resolution === '1' ? '1p00':'0p50').'.pl'; |
|
121 | - $get = array('file' => 'gfs.t'.sprintf('%02d',(6*floor($hour/6))).($resolution === '1' ? 'z.pgrb2.1p00.f000' : 'z.pgrb2full.0p50.f000'), |
|
120 | + $baseurl = 'http://nomads.ncep.noaa.gov/cgi-bin/filter_gfs_'.($resolution === '1' ? '1p00' : '0p50').'.pl'; |
|
121 | + $get = array('file' => 'gfs.t'.sprintf('%02d', (6*floor($hour/6))).($resolution === '1' ? 'z.pgrb2.1p00.f000' : 'z.pgrb2full.0p50.f000'), |
|
122 | 122 | 'lev_10_m_above_ground' => 'on', |
123 | 123 | 'lev_surface' => 'on', |
124 | 124 | 'var_TMP' => 'on', |
@@ -128,26 +128,26 @@ discard block |
||
128 | 128 | 'rightlon' => 360, |
129 | 129 | 'toplat' => 90, |
130 | 130 | 'bottomlat' => -90, |
131 | - 'dir' => '/gfs.'.date('Ymd').sprintf('%02d',(6*floor($hour/6))) |
|
131 | + 'dir' => '/gfs.'.date('Ymd').sprintf('%02d', (6*floor($hour/6))) |
|
132 | 132 | ); |
133 | 133 | $url = $baseurl.'?'.http_build_query($get); |
134 | 134 | //echo $url; |
135 | 135 | $Common = new Common(); |
136 | - $Common->download($url,$windpathsrc); |
|
136 | + $Common->download($url, $windpathsrc); |
|
137 | 137 | // Check if the downloaded file is in GRIB format |
138 | - $file = fopen($windpathsrc,"r"); |
|
138 | + $file = fopen($windpathsrc, "r"); |
|
139 | 139 | $firc = fgetc($file); |
140 | 140 | fclose($file); |
141 | 141 | if ($firc == 'G') { |
142 | 142 | system($grib2json.' --data --output '.$windpathdest.' --names --compact '.$windpathsrc); |
143 | 143 | } else { |
144 | 144 | // if not try previous run |
145 | - if ($hour == date('G')) $this->nomad_wind(date('G')-6); |
|
145 | + if ($hour == date('G')) $this->nomad_wind(date('G') - 6); |
|
146 | 146 | } |
147 | 147 | } |
148 | 148 | |
149 | 149 | public function oscar_wave() { |
150 | - global $globalWavesPath, $globalPODACCuser,$globalPODACCpass; |
|
150 | + global $globalWavesPath, $globalPODACCuser, $globalPODACCpass; |
|
151 | 151 | if ($globalPODACCuser == '' && $globalPODACCpass == '') return; |
152 | 152 | if (isset($globalWavesPath) && $globalWavesPath != '') { |
153 | 153 | $grib2json = $globalWavesPath['grib2json']; |
@@ -163,10 +163,10 @@ discard block |
||
163 | 163 | $Common = new Common(); |
164 | 164 | $auth = base64_encode("$globalPODACCuser:$globalPODACCpass"); |
165 | 165 | $oscarlst = $Common->getData($url); |
166 | - $oscarlst_xml = json_decode(json_encode(simplexml_load_string($oscarlst)),true); |
|
166 | + $oscarlst_xml = json_decode(json_encode(simplexml_load_string($oscarlst)), true); |
|
167 | 167 | foreach ($oscarlst_xml['entry']['link'] as $oscarlnk) { |
168 | 168 | if ($oscarlnk['@attributes']['type'] == 'application/x-netcdf') { |
169 | - $Common->download($oscarlnk['@attributes']['href'],$wavepathsrc.'.gz','',array("Authorization: BASIC $auth")); |
|
169 | + $Common->download($oscarlnk['@attributes']['href'], $wavepathsrc.'.gz', '', array("Authorization: BASIC $auth")); |
|
170 | 170 | break; |
171 | 171 | } |
172 | 172 | } |
@@ -21,12 +21,12 @@ discard block |
||
21 | 21 | * @param array $headers header to submit with the form |
22 | 22 | * @return String the result |
23 | 23 | */ |
24 | - public function getData($url, $type = 'get', $data = '', $headers = '',$cookie = '',$referer = '',$timeout = '',$useragent = '', $sizelimit = false, $async = false, $getheaders = false) { |
|
24 | + public function getData($url, $type = 'get', $data = '', $headers = '', $cookie = '', $referer = '', $timeout = '', $useragent = '', $sizelimit = false, $async = false, $getheaders = false) { |
|
25 | 25 | global $globalProxy, $globalForceIPv4; |
26 | 26 | $ch = curl_init(); |
27 | 27 | curl_setopt($ch, CURLOPT_URL, $url); |
28 | 28 | if (isset($globalForceIPv4) && $globalForceIPv4) { |
29 | - if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')){ |
|
29 | + if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')) { |
|
30 | 30 | curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); |
31 | 31 | } |
32 | 32 | } |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
38 | 38 | curl_setopt($ch, CURLINFO_HEADER_OUT, true); |
39 | 39 | if ($getheaders) curl_setopt($ch, CURLOPT_HEADER, 1); |
40 | - curl_setopt($ch,CURLOPT_ENCODING , "gzip"); |
|
40 | + curl_setopt($ch, CURLOPT_ENCODING, "gzip"); |
|
41 | 41 | //curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5'); |
42 | 42 | // curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (X11; Linux x86_64; rv:42.0) Gecko/20100101 Firefox/42.0'); |
43 | 43 | if ($useragent == '') { |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | if (is_array($data)) { |
54 | 54 | curl_setopt($ch, CURLOPT_POST, count($data)); |
55 | 55 | $data_string = ''; |
56 | - foreach($data as $key=>$value) { $data_string .= $key.'='.$value.'&'; } |
|
56 | + foreach ($data as $key=>$value) { $data_string .= $key.'='.$value.'&'; } |
|
57 | 57 | rtrim($data_string, '&'); |
58 | 58 | curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string); |
59 | 59 | } else { |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | } |
66 | 66 | if ($cookie != '') { |
67 | 67 | if (is_array($cookie)) { |
68 | - curl_setopt($ch, CURLOPT_COOKIE, implode($cookie,';')); |
|
68 | + curl_setopt($ch, CURLOPT_COOKIE, implode($cookie, ';')); |
|
69 | 69 | } else { |
70 | 70 | curl_setopt($ch, CURLOPT_COOKIE, $cookie); |
71 | 71 | } |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | if ($sizelimit === true) { |
77 | 77 | curl_setopt($ch, CURLOPT_BUFFERSIZE, 128); |
78 | 78 | curl_setopt($ch, CURLOPT_NOPROGRESS, false); |
79 | - curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, function($curlr,$downloadsize, $downloaded, $uploadsize, $uploaded){ |
|
79 | + curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, function($curlr, $downloadsize, $downloaded, $uploadsize, $uploaded) { |
|
80 | 80 | return ($downloaded > (3*1024)) ? 1 : 0; |
81 | 81 | }); |
82 | 82 | } |
@@ -88,13 +88,13 @@ discard block |
||
88 | 88 | $info = curl_getinfo($ch); |
89 | 89 | //var_dump($info); |
90 | 90 | curl_close($ch); |
91 | - if ($info['http_code'] == '503' && strstr($result,'DDoS protection by CloudFlare')) { |
|
91 | + if ($info['http_code'] == '503' && strstr($result, 'DDoS protection by CloudFlare')) { |
|
92 | 92 | echo "Cloudflare Detected\n"; |
93 | 93 | require_once(dirname(__FILE__).'/libs/cloudflare-bypass/libraries/cloudflareClass.php'); |
94 | 94 | $useragent = UAgent::random(); |
95 | 95 | cloudflare::useUserAgent($useragent); |
96 | 96 | if ($clearanceCookie = cloudflare::bypass($url)) { |
97 | - return $this->getData($url,'get',$data,$headers,$clearanceCookie,$referer,$timeout,$useragent); |
|
97 | + return $this->getData($url, 'get', $data, $headers, $clearanceCookie, $referer, $timeout, $useragent); |
|
98 | 98 | } |
99 | 99 | } else { |
100 | 100 | return $result; |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | curl_setopt($ch, CURLOPT_COOKIEFILE, ''); |
121 | 121 | if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer); |
122 | 122 | if (isset($globalForceIPv4) && $globalForceIPv4) { |
123 | - if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')){ |
|
123 | + if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')) { |
|
124 | 124 | curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); |
125 | 125 | } |
126 | 126 | } |
@@ -138,20 +138,20 @@ discard block |
||
138 | 138 | fclose($fp); |
139 | 139 | } |
140 | 140 | |
141 | - public static function gunzip($in_file,$out_file_name = '') { |
|
141 | + public static function gunzip($in_file, $out_file_name = '') { |
|
142 | 142 | //echo $in_file.' -> '.$out_file_name."\n"; |
143 | 143 | $buffer_size = 4096; // read 4kb at a time |
144 | 144 | if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); |
145 | 145 | if ($in_file != '' && file_exists($in_file)) { |
146 | 146 | // PHP version of Ubuntu use gzopen64 instead of gzopen |
147 | - if (function_exists('gzopen')) $file = gzopen($in_file,'rb'); |
|
148 | - elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb'); |
|
147 | + if (function_exists('gzopen')) $file = gzopen($in_file, 'rb'); |
|
148 | + elseif (function_exists('gzopen64')) $file = gzopen64($in_file, 'rb'); |
|
149 | 149 | else { |
150 | 150 | echo 'gzopen not available'; |
151 | 151 | die; |
152 | 152 | } |
153 | 153 | $out_file = fopen($out_file_name, 'wb'); |
154 | - while(!gzeof($file)) { |
|
154 | + while (!gzeof($file)) { |
|
155 | 155 | fwrite($out_file, gzread($file, $buffer_size)); |
156 | 156 | } |
157 | 157 | fclose($out_file); |
@@ -159,19 +159,19 @@ discard block |
||
159 | 159 | } |
160 | 160 | } |
161 | 161 | |
162 | - public static function bunzip2($in_file,$out_file_name = '') { |
|
162 | + public static function bunzip2($in_file, $out_file_name = '') { |
|
163 | 163 | //echo $in_file.' -> '.$out_file_name."\n"; |
164 | 164 | $buffer_size = 4096; // read 4kb at a time |
165 | 165 | if ($out_file_name == '') $out_file_name = str_replace('.bz2', '', $in_file); |
166 | 166 | if ($in_file != '' && file_exists($in_file)) { |
167 | 167 | // PHP version of Ubuntu use gzopen64 instead of gzopen |
168 | - if (function_exists('bzopen')) $file = bzopen($in_file,'rb'); |
|
168 | + if (function_exists('bzopen')) $file = bzopen($in_file, 'rb'); |
|
169 | 169 | else { |
170 | 170 | echo 'bzopen not available'; |
171 | 171 | die; |
172 | 172 | } |
173 | 173 | $out_file = fopen($out_file_name, 'wb'); |
174 | - while(!feof($file)) { |
|
174 | + while (!feof($file)) { |
|
175 | 175 | fwrite($out_file, bzread($file, $buffer_size)); |
176 | 176 | } |
177 | 177 | fclose($out_file); |
@@ -189,27 +189,27 @@ discard block |
||
189 | 189 | if ($data == '') return array(); |
190 | 190 | $html = str_get_html($data); |
191 | 191 | if ($html === false) return array(); |
192 | - $tabledata=array(); |
|
193 | - foreach($html->find('tr') as $element) |
|
192 | + $tabledata = array(); |
|
193 | + foreach ($html->find('tr') as $element) |
|
194 | 194 | { |
195 | 195 | $td = array(); |
196 | - foreach( $element->find('th') as $row) |
|
196 | + foreach ($element->find('th') as $row) |
|
197 | 197 | { |
198 | 198 | $td [] = trim($row->plaintext); |
199 | 199 | } |
200 | - $td=array_filter($td); |
|
200 | + $td = array_filter($td); |
|
201 | 201 | $tabledata[] = $td; |
202 | 202 | |
203 | 203 | $td = array(); |
204 | 204 | $tdi = array(); |
205 | - foreach( $element->find('td') as $row) |
|
205 | + foreach ($element->find('td') as $row) |
|
206 | 206 | { |
207 | 207 | $td [] = trim($row->plaintext); |
208 | 208 | $tdi [] = trim($row->innertext); |
209 | 209 | } |
210 | - $td=array_filter($td); |
|
211 | - $tdi=array_filter($tdi); |
|
212 | - $tabledata[]=array_merge($td,$tdi); |
|
210 | + $td = array_filter($td); |
|
211 | + $tdi = array_filter($tdi); |
|
212 | + $tabledata[] = array_merge($td, $tdi); |
|
213 | 213 | } |
214 | 214 | $html->clear(); |
215 | 215 | unset($html); |
@@ -224,8 +224,8 @@ discard block |
||
224 | 224 | public function text2array($data) { |
225 | 225 | $html = str_get_html($data); |
226 | 226 | if ($html === false) return array(); |
227 | - $tabledata=array(); |
|
228 | - foreach($html->find('p') as $element) |
|
227 | + $tabledata = array(); |
|
228 | + foreach ($html->find('p') as $element) |
|
229 | 229 | { |
230 | 230 | $tabledata [] = trim($element->plaintext); |
231 | 231 | } |
@@ -245,11 +245,11 @@ discard block |
||
245 | 245 | */ |
246 | 246 | public function distance($lat, $lon, $latc, $lonc, $unit = 'km') { |
247 | 247 | if ($lat == $latc && $lon == $lonc) return 0; |
248 | - $dist = rad2deg(acos(sin(deg2rad(floatval($lat)))*sin(deg2rad(floatval($latc)))+ cos(deg2rad(floatval($lat)))*cos(deg2rad(floatval($latc)))*cos(deg2rad(floatval($lon)-floatval($lonc)))))*60*1.1515; |
|
248 | + $dist = rad2deg(acos(sin(deg2rad(floatval($lat)))*sin(deg2rad(floatval($latc))) + cos(deg2rad(floatval($lat)))*cos(deg2rad(floatval($latc)))*cos(deg2rad(floatval($lon) - floatval($lonc)))))*60*1.1515; |
|
249 | 249 | if ($unit == "km") { |
250 | - return round($dist * 1.609344); |
|
250 | + return round($dist*1.609344); |
|
251 | 251 | } elseif ($unit == "m") { |
252 | - return round($dist * 1.609344 * 1000); |
|
252 | + return round($dist*1.609344*1000); |
|
253 | 253 | } elseif ($unit == "mile" || $unit == "mi") { |
254 | 254 | return round($dist); |
255 | 255 | } elseif ($unit == "nm") { |
@@ -266,8 +266,8 @@ discard block |
||
266 | 266 | * @param String $distance distance between two points in m |
267 | 267 | * @return Float plunge |
268 | 268 | */ |
269 | - public function plunge($initial_altitude,$final_altitude,$distance) { |
|
270 | - $plunge = rad2deg(asin(($final_altitude-$initial_altitude)/$distance)); |
|
269 | + public function plunge($initial_altitude, $final_altitude, $distance) { |
|
270 | + $plunge = rad2deg(asin(($final_altitude - $initial_altitude)/$distance)); |
|
271 | 271 | /* |
272 | 272 | $siter = 6378137.0 + $initial_altitude; |
273 | 273 | $planer = 6378137.0 + $final_altitude; |
@@ -289,8 +289,8 @@ discard block |
||
289 | 289 | public function azimuth($lat, $lon, $latc, $lonc) { |
290 | 290 | $dX = $latc - $lat; |
291 | 291 | $dY = $lonc - $lon; |
292 | - $azimuth = rad2deg(atan2($dY,$dX)); |
|
293 | - if ($azimuth < 0) return $azimuth+360; |
|
292 | + $azimuth = rad2deg(atan2($dY, $dX)); |
|
293 | + if ($azimuth < 0) return $azimuth + 360; |
|
294 | 294 | return $azimuth; |
295 | 295 | } |
296 | 296 | |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | * @param float $distance distance covered |
302 | 302 | * @return bool whether distance is realistic |
303 | 303 | */ |
304 | - public function withinThreshold ($timeDifference, $distance) { |
|
304 | + public function withinThreshold($timeDifference, $distance) { |
|
305 | 305 | $x = abs($timeDifference); |
306 | 306 | $d = abs($distance); |
307 | 307 | if ($x == 0 || $d == 0) return true; |
@@ -317,13 +317,13 @@ discard block |
||
317 | 317 | return ($array !== array_values($array)); |
318 | 318 | } |
319 | 319 | |
320 | - public function isInteger($input){ |
|
320 | + public function isInteger($input) { |
|
321 | 321 | //return(ctype_digit(strval($input))); |
322 | - return preg_match('/^-?[0-9]+$/', (string)$input) ? true : false; |
|
322 | + return preg_match('/^-?[0-9]+$/', (string) $input) ? true : false; |
|
323 | 323 | } |
324 | 324 | |
325 | 325 | |
326 | - public function convertDec($dms,$latlong) { |
|
326 | + public function convertDec($dms, $latlong) { |
|
327 | 327 | if ($latlong == 'latitude') { |
328 | 328 | $deg = substr($dms, 0, 2); |
329 | 329 | $min = substr($dms, 2, 4); |
@@ -331,33 +331,33 @@ discard block |
||
331 | 331 | $deg = substr($dms, 0, 3); |
332 | 332 | $min = substr($dms, 3, 5); |
333 | 333 | } |
334 | - return $deg+(($min*60)/3600); |
|
334 | + return $deg + (($min*60)/3600); |
|
335 | 335 | } |
336 | 336 | |
337 | 337 | public function convertDecLatLong($coord) { |
338 | 338 | //N43°36.763' W5°46.845' |
339 | - $coords = explode(' ',$coord); |
|
339 | + $coords = explode(' ', $coord); |
|
340 | 340 | $latitude = ''; |
341 | 341 | $longitude = ''; |
342 | 342 | foreach ($coords as $latlong) { |
343 | - $type = substr($latlong,0,1); |
|
344 | - $degmin = explode('°',substr($latlong,1,-1)); |
|
343 | + $type = substr($latlong, 0, 1); |
|
344 | + $degmin = explode('°', substr($latlong, 1, -1)); |
|
345 | 345 | $deg = $degmin[0]; |
346 | 346 | $min = $degmin[1]; |
347 | 347 | if ($type == 'N') { |
348 | - $latitude = $deg+(($min*60)/3600); |
|
348 | + $latitude = $deg + (($min*60)/3600); |
|
349 | 349 | } elseif ($type == 'S') { |
350 | - $latitude = -($deg+(($min*60)/3600)); |
|
350 | + $latitude = -($deg + (($min*60)/3600)); |
|
351 | 351 | } elseif ($type == 'E') { |
352 | - $longitude = ($deg+(($min*60)/3600)); |
|
352 | + $longitude = ($deg + (($min*60)/3600)); |
|
353 | 353 | } elseif ($type == 'W') { |
354 | - $longitude = -($deg+(($min*60)/3600)); |
|
354 | + $longitude = -($deg + (($min*60)/3600)); |
|
355 | 355 | } |
356 | 356 | } |
357 | - return array('latitude' => round($latitude,5),'longitude' => round($longitude,5)); |
|
357 | + return array('latitude' => round($latitude, 5), 'longitude' => round($longitude, 5)); |
|
358 | 358 | } |
359 | 359 | |
360 | - public function convertDM($coord,$latlong) { |
|
360 | + public function convertDM($coord, $latlong) { |
|
361 | 361 | if ($latlong == 'latitude') { |
362 | 362 | if ($coord < 0) $NSEW = 'S'; |
363 | 363 | else $NSEW = 'N'; |
@@ -367,11 +367,11 @@ discard block |
||
367 | 367 | } |
368 | 368 | $coord = abs($coord); |
369 | 369 | $deg = floor($coord); |
370 | - $coord = ($coord-$deg)*60; |
|
370 | + $coord = ($coord - $deg)*60; |
|
371 | 371 | $min = $coord; |
372 | - return array('deg' => $deg,'min' => $min,'NSEW' => $NSEW); |
|
372 | + return array('deg' => $deg, 'min' => $min, 'NSEW' => $NSEW); |
|
373 | 373 | } |
374 | - public function convertDMS($coord,$latlong) { |
|
374 | + public function convertDMS($coord, $latlong) { |
|
375 | 375 | if ($latlong == 'latitude') { |
376 | 376 | if ($coord < 0) $NSEW = 'S'; |
377 | 377 | else $NSEW = 'N'; |
@@ -381,10 +381,10 @@ discard block |
||
381 | 381 | } |
382 | 382 | $coord = abs($coord); |
383 | 383 | $deg = floor($coord); |
384 | - $coord = ($coord-$deg)*60; |
|
384 | + $coord = ($coord - $deg)*60; |
|
385 | 385 | $min = floor($coord); |
386 | - $sec = round(($coord-$min)*60); |
|
387 | - return array('deg' => $deg,'min' => $min,'sec' => $sec,'NSEW' => $NSEW); |
|
386 | + $sec = round(($coord - $min)*60); |
|
387 | + return array('deg' => $deg, 'min' => $min, 'sec' => $sec, 'NSEW' => $NSEW); |
|
388 | 388 | } |
389 | 389 | |
390 | 390 | /** |
@@ -396,8 +396,8 @@ discard block |
||
396 | 396 | public function xcopy($source, $dest) |
397 | 397 | { |
398 | 398 | $files = glob($source.'*.*'); |
399 | - foreach($files as $file){ |
|
400 | - $file_to_go = str_replace($source,$dest,$file); |
|
399 | + foreach ($files as $file) { |
|
400 | + $file_to_go = str_replace($source, $dest, $file); |
|
401 | 401 | copy($file, $file_to_go); |
402 | 402 | } |
403 | 403 | return true; |
@@ -408,9 +408,9 @@ discard block |
||
408 | 408 | * @param String $url url to check |
409 | 409 | * @return bool Return true on succes false on failure |
410 | 410 | */ |
411 | - public function urlexist($url){ |
|
412 | - $headers=get_headers($url); |
|
413 | - return stripos($headers[0],"200 OK")?true:false; |
|
411 | + public function urlexist($url) { |
|
412 | + $headers = get_headers($url); |
|
413 | + return stripos($headers[0], "200 OK") ?true:false; |
|
414 | 414 | } |
415 | 415 | |
416 | 416 | /** |
@@ -421,7 +421,7 @@ discard block |
||
421 | 421 | public function hex2str($hex) { |
422 | 422 | $str = ''; |
423 | 423 | $hexln = strlen($hex); |
424 | - for($i=0;$i<$hexln;$i+=2) $str .= chr(hexdec(substr($hex,$i,2))); |
|
424 | + for ($i = 0; $i < $hexln; $i += 2) $str .= chr(hexdec(substr($hex, $i, 2))); |
|
425 | 425 | return $str; |
426 | 426 | } |
427 | 427 | |
@@ -431,7 +431,7 @@ discard block |
||
431 | 431 | * @return String Return result |
432 | 432 | */ |
433 | 433 | public function hex2rgb($hex) { |
434 | - $hex = str_replace('#','',$hex); |
|
434 | + $hex = str_replace('#', '', $hex); |
|
435 | 435 | return sscanf($hex, "%02x%02x%02x"); |
436 | 436 | } |
437 | 437 | |
@@ -439,33 +439,33 @@ discard block |
||
439 | 439 | //difference in longitudinal coordinates |
440 | 440 | $dLon = deg2rad($lon2) - deg2rad($lon1); |
441 | 441 | //difference in the phi of latitudinal coordinates |
442 | - $dPhi = log(tan(deg2rad($lat2) / 2 + M_PI / 4) / tan(deg2rad($lat1) / 2 + M_PI / 4)); |
|
442 | + $dPhi = log(tan(deg2rad($lat2)/2 + M_PI/4)/tan(deg2rad($lat1)/2 + M_PI/4)); |
|
443 | 443 | //we need to recalculate $dLon if it is greater than pi |
444 | - if(abs($dLon) > M_PI) { |
|
445 | - if($dLon > 0) { |
|
446 | - $dLon = (2 * M_PI - $dLon) * -1; |
|
444 | + if (abs($dLon) > M_PI) { |
|
445 | + if ($dLon > 0) { |
|
446 | + $dLon = (2*M_PI - $dLon)*-1; |
|
447 | 447 | } else { |
448 | - $dLon = 2 * M_PI + $dLon; |
|
448 | + $dLon = 2*M_PI + $dLon; |
|
449 | 449 | } |
450 | 450 | } |
451 | 451 | //return the angle, normalized |
452 | - return (rad2deg(atan2($dLon, $dPhi)) + 360) % 360; |
|
452 | + return (rad2deg(atan2($dLon, $dPhi)) + 360)%360; |
|
453 | 453 | } |
454 | 454 | |
455 | - public function checkLine($lat1,$lon1,$lat2,$lon2,$lat3,$lon3,$approx = 0.15) { |
|
455 | + public function checkLine($lat1, $lon1, $lat2, $lon2, $lat3, $lon3, $approx = 0.15) { |
|
456 | 456 | //$a = ($lon2-$lon1)*$lat3+($lat2-$lat1)*$lon3+($lat1*$lon2+$lat2*$lon1); |
457 | - $a = -($lon2-$lon1); |
|
457 | + $a = -($lon2 - $lon1); |
|
458 | 458 | $b = $lat2 - $lat1; |
459 | - $c = -($a*$lat1+$b*$lon1); |
|
460 | - $d = $a*$lat3+$b*$lon3+$c; |
|
459 | + $c = -($a*$lat1 + $b*$lon1); |
|
460 | + $d = $a*$lat3 + $b*$lon3 + $c; |
|
461 | 461 | if ($d > -$approx && $d < $approx) return true; |
462 | 462 | else return false; |
463 | 463 | } |
464 | 464 | |
465 | 465 | public function array_merge_noappend() { |
466 | 466 | $output = array(); |
467 | - foreach(func_get_args() as $array) { |
|
468 | - foreach($array as $key => $value) { |
|
467 | + foreach (func_get_args() as $array) { |
|
468 | + foreach ($array as $key => $value) { |
|
469 | 469 | $output[$key] = isset($output[$key]) ? |
470 | 470 | array_merge($output[$key], $value) : $value; |
471 | 471 | } |
@@ -529,7 +529,7 @@ discard block |
||
529 | 529 | return $result; |
530 | 530 | } |
531 | 531 | |
532 | - public function nextcoord($latitude, $longitude, $speed, $heading, $archivespeed = 1, $seconds = ''){ |
|
532 | + public function nextcoord($latitude, $longitude, $speed, $heading, $archivespeed = 1, $seconds = '') { |
|
533 | 533 | global $globalMapRefresh; |
534 | 534 | if ($seconds == '') { |
535 | 535 | $distance = ($speed*0.514444*$globalMapRefresh*$archivespeed)/1000; |
@@ -540,27 +540,27 @@ discard block |
||
540 | 540 | $latitude = deg2rad($latitude); |
541 | 541 | $longitude = deg2rad($longitude); |
542 | 542 | $bearing = deg2rad($heading); |
543 | - $latitude2 = asin( (sin($latitude) * cos($distance/$r)) + (cos($latitude) * sin($distance/$r) * cos($bearing)) ); |
|
544 | - $longitude2 = $longitude + atan2( sin($bearing)*sin($distance/$r)*cos($latitude), cos($distance/$r)-(sin($latitude)*sin($latitude2)) ); |
|
545 | - return array('latitude' => number_format(rad2deg($latitude2),5,'.',''),'longitude' => number_format(rad2deg($longitude2),5,'.','')); |
|
543 | + $latitude2 = asin((sin($latitude)*cos($distance/$r)) + (cos($latitude)*sin($distance/$r)*cos($bearing))); |
|
544 | + $longitude2 = $longitude + atan2(sin($bearing)*sin($distance/$r)*cos($latitude), cos($distance/$r) - (sin($latitude)*sin($latitude2))); |
|
545 | + return array('latitude' => number_format(rad2deg($latitude2), 5, '.', ''), 'longitude' => number_format(rad2deg($longitude2), 5, '.', '')); |
|
546 | 546 | } |
547 | 547 | |
548 | - public function getCoordfromDistanceBearing($latitude,$longitude,$bearing,$distance) { |
|
548 | + public function getCoordfromDistanceBearing($latitude, $longitude, $bearing, $distance) { |
|
549 | 549 | // distance in meter |
550 | 550 | $R = 6378.14; |
551 | - $latitude1 = $latitude * (M_PI/180); |
|
552 | - $longitude1 = $longitude * (M_PI/180); |
|
553 | - $brng = $bearing * (M_PI/180); |
|
551 | + $latitude1 = $latitude*(M_PI/180); |
|
552 | + $longitude1 = $longitude*(M_PI/180); |
|
553 | + $brng = $bearing*(M_PI/180); |
|
554 | 554 | $d = $distance; |
555 | 555 | |
556 | 556 | $latitude2 = asin(sin($latitude1)*cos($d/$R) + cos($latitude1)*sin($d/$R)*cos($brng)); |
557 | - $longitude2 = $longitude1 + atan2(sin($brng)*sin($d/$R)*cos($latitude1),cos($d/$R)-sin($latitude1)*sin($latitude2)); |
|
557 | + $longitude2 = $longitude1 + atan2(sin($brng)*sin($d/$R)*cos($latitude1), cos($d/$R) - sin($latitude1)*sin($latitude2)); |
|
558 | 558 | |
559 | - $latitude2 = $latitude2 * (180/M_PI); |
|
560 | - $longitude2 = $longitude2 * (180/M_PI); |
|
559 | + $latitude2 = $latitude2*(180/M_PI); |
|
560 | + $longitude2 = $longitude2*(180/M_PI); |
|
561 | 561 | |
562 | - $flat = round ($latitude2,6); |
|
563 | - $flong = round ($longitude2,6); |
|
562 | + $flat = round($latitude2, 6); |
|
563 | + $flong = round($longitude2, 6); |
|
564 | 564 | /* |
565 | 565 | $dx = $distance*cos($bearing); |
566 | 566 | $dy = $distance*sin($bearing); |
@@ -569,7 +569,7 @@ discard block |
||
569 | 569 | $flong = $longitude + $dlong; |
570 | 570 | $flat = $latitude + $dlat; |
571 | 571 | */ |
572 | - return array('latitude' => $flat,'longitude' => $flong); |
|
572 | + return array('latitude' => $flat, 'longitude' => $flong); |
|
573 | 573 | } |
574 | 574 | |
575 | 575 | /** |
@@ -583,14 +583,14 @@ discard block |
||
583 | 583 | * @param integer $level GZIP compression level (default: 9) |
584 | 584 | * @return string New filename (with .gz appended) if success, or false if operation fails |
585 | 585 | */ |
586 | - public function gzCompressFile($source, $level = 9){ |
|
587 | - $dest = $source . '.gz'; |
|
588 | - $mode = 'wb' . $level; |
|
586 | + public function gzCompressFile($source, $level = 9) { |
|
587 | + $dest = $source.'.gz'; |
|
588 | + $mode = 'wb'.$level; |
|
589 | 589 | $error = false; |
590 | 590 | if ($fp_out = gzopen($dest, $mode)) { |
591 | - if ($fp_in = fopen($source,'rb')) { |
|
591 | + if ($fp_in = fopen($source, 'rb')) { |
|
592 | 592 | while (!feof($fp_in)) |
593 | - gzwrite($fp_out, fread($fp_in, 1024 * 512)); |
|
593 | + gzwrite($fp_out, fread($fp_in, 1024*512)); |
|
594 | 594 | fclose($fp_in); |
595 | 595 | } else { |
596 | 596 | $error = true; |
@@ -606,7 +606,7 @@ discard block |
||
606 | 606 | } |
607 | 607 | |
608 | 608 | public function remove_accents($string) { |
609 | - if ( !preg_match('/[\x80-\xff]/', $string) ) return $string; |
|
609 | + if (!preg_match('/[\x80-\xff]/', $string)) return $string; |
|
610 | 610 | $chars = array( |
611 | 611 | // Decompositions for Latin-1 Supplement |
612 | 612 | chr(195).chr(128) => 'A', chr(195).chr(129) => 'A', |
@@ -663,7 +663,7 @@ discard block |
||
663 | 663 | chr(196).chr(172) => 'I', chr(196).chr(173) => 'i', |
664 | 664 | chr(196).chr(174) => 'I', chr(196).chr(175) => 'i', |
665 | 665 | chr(196).chr(176) => 'I', chr(196).chr(177) => 'i', |
666 | - chr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij', |
|
666 | + chr(196).chr(178) => 'IJ', chr(196).chr(179) => 'ij', |
|
667 | 667 | chr(196).chr(180) => 'J', chr(196).chr(181) => 'j', |
668 | 668 | chr(196).chr(182) => 'K', chr(196).chr(183) => 'k', |
669 | 669 | chr(196).chr(184) => 'k', chr(196).chr(185) => 'L', |
@@ -679,13 +679,13 @@ discard block |
||
679 | 679 | chr(197).chr(140) => 'O', chr(197).chr(141) => 'o', |
680 | 680 | chr(197).chr(142) => 'O', chr(197).chr(143) => 'o', |
681 | 681 | chr(197).chr(144) => 'O', chr(197).chr(145) => 'o', |
682 | - chr(197).chr(146) => 'OE',chr(197).chr(147) => 'oe', |
|
683 | - chr(197).chr(148) => 'R',chr(197).chr(149) => 'r', |
|
684 | - chr(197).chr(150) => 'R',chr(197).chr(151) => 'r', |
|
685 | - chr(197).chr(152) => 'R',chr(197).chr(153) => 'r', |
|
686 | - chr(197).chr(154) => 'S',chr(197).chr(155) => 's', |
|
687 | - chr(197).chr(156) => 'S',chr(197).chr(157) => 's', |
|
688 | - chr(197).chr(158) => 'S',chr(197).chr(159) => 's', |
|
682 | + chr(197).chr(146) => 'OE', chr(197).chr(147) => 'oe', |
|
683 | + chr(197).chr(148) => 'R', chr(197).chr(149) => 'r', |
|
684 | + chr(197).chr(150) => 'R', chr(197).chr(151) => 'r', |
|
685 | + chr(197).chr(152) => 'R', chr(197).chr(153) => 'r', |
|
686 | + chr(197).chr(154) => 'S', chr(197).chr(155) => 's', |
|
687 | + chr(197).chr(156) => 'S', chr(197).chr(157) => 's', |
|
688 | + chr(197).chr(158) => 'S', chr(197).chr(159) => 's', |
|
689 | 689 | chr(197).chr(160) => 'S', chr(197).chr(161) => 's', |
690 | 690 | chr(197).chr(162) => 'T', chr(197).chr(163) => 't', |
691 | 691 | chr(197).chr(164) => 'T', chr(197).chr(165) => 't', |
@@ -719,7 +719,7 @@ discard block |
||
719 | 719 | for ($i = 0, $int = '', $concat_flag = true; $i < $length; $i++) { |
720 | 720 | if (is_numeric($string[$i]) && $concat_flag) { |
721 | 721 | $int .= $string[$i]; |
722 | - } elseif(!$concat && $concat_flag && strlen($int) > 0) { |
|
722 | + } elseif (!$concat && $concat_flag && strlen($int) > 0) { |
|
723 | 723 | $concat_flag = false; |
724 | 724 | } |
725 | 725 | } |
@@ -765,7 +765,7 @@ discard block |
||
765 | 765 | $slice = array_slice($arr, $offset + 1, $length); |
766 | 766 | return implode("", $slice); |
767 | 767 | } else { |
768 | - return mb_substr($string,$offset,$length,'UTF-8'); |
|
768 | + return mb_substr($string, $offset, $length, 'UTF-8'); |
|
769 | 769 | } |
770 | 770 | } |
771 | 771 | |
@@ -775,14 +775,14 @@ discard block |
||
775 | 775 | //NOTE: use a trailing slash for folders!!! |
776 | 776 | //see http://bugs.php.net/bug.php?id=27609 |
777 | 777 | //see http://bugs.php.net/bug.php?id=30931 |
778 | - if ($path{strlen($path)-1}=='/') // recursively return a temporary file path |
|
778 | + if ($path{strlen($path) - 1} == '/') // recursively return a temporary file path |
|
779 | 779 | return $this->is__writable($path.uniqid(mt_rand()).'.tmp'); |
780 | 780 | else if (is_dir($path)) |
781 | 781 | return $this->is__writable($path.'/'.uniqid(mt_rand()).'.tmp'); |
782 | 782 | // check tmp file for read/write capabilities |
783 | 783 | $rm = file_exists($path); |
784 | 784 | $f = @fopen($path, 'a'); |
785 | - if ($f===false) |
|
785 | + if ($f === false) |
|
786 | 786 | return false; |
787 | 787 | fclose($f); |
788 | 788 | if (!$rm) |
@@ -801,29 +801,29 @@ discard block |
||
801 | 801 | * @param Integer $offset Controls the likelyhood that lines will be split which cross the dateline |
802 | 802 | * @return Array Coordinate of the route |
803 | 803 | */ |
804 | - public function greatcircle($begin_lat,$begin_lon,$end_lat,$end_lon,$nbpts = 20, $offset = 10) { |
|
805 | - if ($nbpts <= 2) return array(array($begin_lon,$begin_lat),array($end_lon,$end_lat)); |
|
804 | + public function greatcircle($begin_lat, $begin_lon, $end_lat, $end_lon, $nbpts = 20, $offset = 10) { |
|
805 | + if ($nbpts <= 2) return array(array($begin_lon, $begin_lat), array($end_lon, $end_lat)); |
|
806 | 806 | $sx = deg2rad($begin_lon); |
807 | 807 | $sy = deg2rad($begin_lat); |
808 | 808 | $ex = deg2rad($end_lon); |
809 | 809 | $ey = deg2rad($end_lat); |
810 | 810 | $w = $sx - $ex; |
811 | 811 | $h = $sy - $ey; |
812 | - $z = pow(sin($h/2.0),2) + cos($sy)*cos($ey)*pow(sin($w/2.0),2); |
|
812 | + $z = pow(sin($h/2.0), 2) + cos($sy)*cos($ey)*pow(sin($w/2.0), 2); |
|
813 | 813 | $g = 2.0*asin(sqrt($z)); |
814 | - if ($g == M_PI || is_nan($g)) return array(array($begin_lon,$begin_lat),array($end_lon,$end_lat)); |
|
814 | + if ($g == M_PI || is_nan($g)) return array(array($begin_lon, $begin_lat), array($end_lon, $end_lat)); |
|
815 | 815 | $first_pass = array(); |
816 | - $delta = 1.0/($nbpts-1); |
|
817 | - for ($i =0; $i < $nbpts; ++$i) { |
|
816 | + $delta = 1.0/($nbpts - 1); |
|
817 | + for ($i = 0; $i < $nbpts; ++$i) { |
|
818 | 818 | $step = $delta*$i; |
819 | - $A = sin((1 - $step) * $g) / sin($g); |
|
820 | - $B = sin($step * $g) / sin($g); |
|
821 | - $x = $A * cos($sy) * cos($sx) + $B * cos($ey) * cos($ex); |
|
822 | - $y = $A * cos($sy) * sin($sx) + $B * cos($ey) * sin($ex); |
|
823 | - $z = $A * sin($sy) + $B * sin($ey); |
|
819 | + $A = sin((1 - $step)*$g)/sin($g); |
|
820 | + $B = sin($step*$g)/sin($g); |
|
821 | + $x = $A*cos($sy)*cos($sx) + $B*cos($ey)*cos($ex); |
|
822 | + $y = $A*cos($sy)*sin($sx) + $B*cos($ey)*sin($ex); |
|
823 | + $z = $A*sin($sy) + $B*sin($ey); |
|
824 | 824 | $lat = rad2deg(atan2($z, sqrt(pow($x, 2) + pow($y, 2)))); |
825 | 825 | $lon = rad2deg(atan2($y, $x)); |
826 | - $first_pass[] = array($lon,$lat); |
|
826 | + $first_pass[] = array($lon, $lat); |
|
827 | 827 | } |
828 | 828 | $bHasBigDiff = false; |
829 | 829 | $dfMaxSmallDiffLong = 0; |
@@ -838,7 +838,7 @@ discard block |
||
838 | 838 | // https://github.com/OSGeo/gdal/blob/7bfb9c452a59aac958bff0c8386b891edf8154ca/gdal/ogr/ogrgeometryfactory.cpp#L2342 |
839 | 839 | $first_pass_ln = count($first_pass); |
840 | 840 | for ($j = 1; $j < $first_pass_ln; ++$j) { |
841 | - $dfPrevX = $first_pass[$j-1][0]; |
|
841 | + $dfPrevX = $first_pass[$j - 1][0]; |
|
842 | 842 | $dfX = $first_pass[$j][0]; |
843 | 843 | $dfDiffLong = abs($dfX - $dfPrevX); |
844 | 844 | if ($dfDiffLong > $dfDiffSpace && |
@@ -856,14 +856,14 @@ discard block |
||
856 | 856 | //$poMulti[] = $poNewLS; |
857 | 857 | for ($k = 0; $k < $first_pass_ln; ++$k) { |
858 | 858 | $dfX0 = floatval($first_pass[$k][0]); |
859 | - if ($k > 0 && abs($dfX0 - $first_pass[$k-1][0]) > $dfDiffSpace) { |
|
860 | - $dfX1 = floatval($first_pass[$k-1][0]); |
|
861 | - $dfY1 = floatval($first_pass[$k-1][1]); |
|
859 | + if ($k > 0 && abs($dfX0 - $first_pass[$k - 1][0]) > $dfDiffSpace) { |
|
860 | + $dfX1 = floatval($first_pass[$k - 1][0]); |
|
861 | + $dfY1 = floatval($first_pass[$k - 1][1]); |
|
862 | 862 | $dfX2 = floatval($first_pass[$k][0]); |
863 | 863 | $dfY2 = floatval($first_pass[$k][1]); |
864 | 864 | if ($dfX1 > -180 && $dfX1 < $dfRightBorderX && $dfX2 == 180 && |
865 | - $k+1 < count($first_pass) && |
|
866 | - $first_pass[$k-1][0] > -180 && $first_pass[$k-1][0] < $dfRightBorderX) |
|
865 | + $k + 1 < count($first_pass) && |
|
866 | + $first_pass[$k - 1][0] > -180 && $first_pass[$k - 1][0] < $dfRightBorderX) |
|
867 | 867 | { |
868 | 868 | $poNewLS[] = array(-180, $first_pass[$k][1]); |
869 | 869 | $k++; |
@@ -871,8 +871,8 @@ discard block |
||
871 | 871 | $poNewLS[] = array($first_pass[$k][0], $first_pass[$k][1]); |
872 | 872 | continue; |
873 | 873 | } else if ($dfX1 > $dfLeftBorderX && $dfX1 < 180 && $dfX2 == -180 && |
874 | - $k+1 < $first_pass_ln && |
|
875 | - $first_pass[$k-1][0] > $dfLeftBorderX && $first_pass[$k-1][0] < 180) |
|
874 | + $k + 1 < $first_pass_ln && |
|
875 | + $first_pass[$k - 1][0] > $dfLeftBorderX && $first_pass[$k - 1][0] < 180) |
|
876 | 876 | { |
877 | 877 | $poNewLS[] = array(180, $first_pass[$k][1]); |
878 | 878 | $k++; |
@@ -895,12 +895,12 @@ discard block |
||
895 | 895 | } |
896 | 896 | if ($dfX1 <= 180 && $dfX2 >= 180 && $dfX1 < $dfX2) |
897 | 897 | { |
898 | - $dfRatio = (180 - $dfX1) / ($dfX2 - $dfX1); |
|
899 | - $dfY = $dfRatio * $dfY2 + (1 - $dfRatio) * $dfY1; |
|
900 | - $poNewLS[] = array($first_pass[$k-1][0] > $dfLeftBorderX ? 180 : -180, $dfY); |
|
898 | + $dfRatio = (180 - $dfX1)/($dfX2 - $dfX1); |
|
899 | + $dfY = $dfRatio*$dfY2 + (1 - $dfRatio)*$dfY1; |
|
900 | + $poNewLS[] = array($first_pass[$k - 1][0] > $dfLeftBorderX ? 180 : -180, $dfY); |
|
901 | 901 | $poMulti[] = $poNewLS; |
902 | 902 | $poNewLS = array(); |
903 | - $poNewLS[] = array($first_pass[$k-1][0] > $dfLeftBorderX ? -180 : 180, $dfY); |
|
903 | + $poNewLS[] = array($first_pass[$k - 1][0] > $dfLeftBorderX ? -180 : 180, $dfY); |
|
904 | 904 | //$poMulti[] = $poNewLS; |
905 | 905 | } else { |
906 | 906 | //$poNewLS[] = array(); |
@@ -918,7 +918,7 @@ discard block |
||
918 | 918 | $poNewLS0 = array(); |
919 | 919 | //$poMulti[] = $poNewLS0; |
920 | 920 | for ($l = 0; $l < $first_pass_ln; ++$l) { |
921 | - $poNewLS0[] = array($first_pass[$l][0],$first_pass[$l][1]); |
|
921 | + $poNewLS0[] = array($first_pass[$l][0], $first_pass[$l][1]); |
|
922 | 922 | } |
923 | 923 | $poMulti[] = $poNewLS0; |
924 | 924 | } |