@@ -22,7 +22,9 @@ discard block |
||
| 22 | 22 | require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | -if (!isset($globalDebug)) $globalDebug = FALSE; |
|
| 25 | +if (!isset($globalDebug)) { |
|
| 26 | + $globalDebug = FALSE; |
|
| 27 | +} |
|
| 26 | 28 | |
| 27 | 29 | if ($globalInstalled === FALSE) { |
| 28 | 30 | echo "This script MUST be run after install script. Use your web browser to run install/index.php"; |
@@ -68,66 +70,107 @@ discard block |
||
| 68 | 70 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
| 69 | 71 | if (isset($options['s'])) { |
| 70 | 72 | $globalSources = array(); |
| 71 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
| 72 | - else $globalSources[] = array('host' => $options['s']); |
|
| 73 | -} elseif (isset($options['source'])) { |
|
| 73 | + if (isset($options['format'])) { |
|
| 74 | + $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
| 75 | + } else { |
|
| 76 | + $globalSources[] = array('host' => $options['s']); |
|
| 77 | + } |
|
| 78 | + } elseif (isset($options['source'])) { |
|
| 74 | 79 | $globalSources = array(); |
| 75 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
| 76 | - else $globalSources[] = array('host' => $options['source']); |
|
| 77 | -} |
|
| 80 | + if (isset($options['format'])) { |
|
| 81 | + $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
| 82 | + } else { |
|
| 83 | + $globalSources[] = array('host' => $options['source']); |
|
| 84 | + } |
|
| 85 | + } |
|
| 78 | 86 | if (isset($options['aprsserverhost'])) { |
| 79 | 87 | $globalServerAPRS = TRUE; |
| 80 | 88 | $globalServerAPRShost = $options['aprsserverhost']; |
| 81 | 89 | } |
| 82 | -if (isset($options['aprsserverport'])) $globalServerAPRSport = $options['aprsserverport']; |
|
| 83 | -if (isset($options['aprsserverssid'])) $globalServerAPRSssid = $options['aprsserverssid']; |
|
| 84 | -if (isset($options['aprsserverpass'])) $globalServerAPRSpass = $options['aprsserverpass']; |
|
| 85 | -if (isset($options['noaprsserver'])) $globalServerAPRS = FALSE; |
|
| 90 | +if (isset($options['aprsserverport'])) { |
|
| 91 | + $globalServerAPRSport = $options['aprsserverport']; |
|
| 92 | +} |
|
| 93 | +if (isset($options['aprsserverssid'])) { |
|
| 94 | + $globalServerAPRSssid = $options['aprsserverssid']; |
|
| 95 | +} |
|
| 96 | +if (isset($options['aprsserverpass'])) { |
|
| 97 | + $globalServerAPRSpass = $options['aprsserverpass']; |
|
| 98 | +} |
|
| 99 | +if (isset($options['noaprsserver'])) { |
|
| 100 | + $globalServerAPRS = FALSE; |
|
| 101 | +} |
|
| 86 | 102 | if (isset($options['enable-aircraft'])) { |
| 87 | - if ($globalDebug) echo 'Enable Aircraft mode'."\n"; |
|
| 103 | + if ($globalDebug) { |
|
| 104 | + echo 'Enable Aircraft mode'."\n"; |
|
| 105 | + } |
|
| 88 | 106 | $globalAircraft = TRUE; |
| 89 | 107 | } |
| 90 | 108 | if (isset($options['disable-aircraft'])) { |
| 91 | - if ($globalDebug) echo 'Disable Aircraft mode'."\n"; |
|
| 109 | + if ($globalDebug) { |
|
| 110 | + echo 'Disable Aircraft mode'."\n"; |
|
| 111 | + } |
|
| 92 | 112 | $globalAircraft = FALSE; |
| 93 | 113 | } |
| 94 | 114 | if (isset($options['enable-tracker'])) { |
| 95 | - if ($globalDebug) echo 'Enable Tracker mode'."\n"; |
|
| 115 | + if ($globalDebug) { |
|
| 116 | + echo 'Enable Tracker mode'."\n"; |
|
| 117 | + } |
|
| 96 | 118 | $globalTracker = TRUE; |
| 97 | 119 | } |
| 98 | 120 | if (isset($options['disable-tracker'])) { |
| 99 | - if ($globalDebug) echo 'Disable Tracker mode'."\n"; |
|
| 121 | + if ($globalDebug) { |
|
| 122 | + echo 'Disable Tracker mode'."\n"; |
|
| 123 | + } |
|
| 100 | 124 | $globalTracker = FALSE; |
| 101 | 125 | } |
| 102 | 126 | if (isset($options['enable-marine'])) { |
| 103 | - if ($globalDebug) echo 'Enable Marine mode'."\n"; |
|
| 127 | + if ($globalDebug) { |
|
| 128 | + echo 'Enable Marine mode'."\n"; |
|
| 129 | + } |
|
| 104 | 130 | $globalMarine = TRUE; |
| 105 | 131 | } |
| 106 | 132 | if (isset($options['disable-marine'])) { |
| 107 | - if ($globalDebug) echo 'Disable Marine mode'."\n"; |
|
| 133 | + if ($globalDebug) { |
|
| 134 | + echo 'Disable Marine mode'."\n"; |
|
| 135 | + } |
|
| 108 | 136 | $globalMarine = FALSE; |
| 109 | 137 | } |
| 110 | -if (isset($options['nodaemon'])) $globalDaemon = FALSE; |
|
| 111 | -if (isset($options['server'])) $globalServer = TRUE; |
|
| 112 | -if (isset($options['idsource'])) $id_source = $options['idsource']; |
|
| 113 | -else $id_source = 1; |
|
| 138 | +if (isset($options['nodaemon'])) { |
|
| 139 | + $globalDaemon = FALSE; |
|
| 140 | +} |
|
| 141 | +if (isset($options['server'])) { |
|
| 142 | + $globalServer = TRUE; |
|
| 143 | +} |
|
| 144 | +if (isset($options['idsource'])) { |
|
| 145 | + $id_source = $options['idsource']; |
|
| 146 | +} else { |
|
| 147 | + $id_source = 1; |
|
| 148 | +} |
|
| 114 | 149 | if (isset($globalServer) && $globalServer) { |
| 115 | - if ($globalDebug) echo "Using Server Mode\n"; |
|
| 150 | + if ($globalDebug) { |
|
| 151 | + echo "Using Server Mode\n"; |
|
| 152 | + } |
|
| 116 | 153 | $SI=new SpotterServer(); |
| 117 | 154 | /* |
| 118 | 155 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
| 119 | 156 | $SI = new adsb2aprs(); |
| 120 | 157 | $SI->connect(); |
| 121 | 158 | */ |
| 122 | -} else $SI=new SpotterImport($Connection->db); |
|
| 159 | +} else { |
|
| 160 | + $SI=new SpotterImport($Connection->db); |
|
| 161 | +} |
|
| 123 | 162 | |
| 124 | -if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
| 163 | +if (isset($globalTracker) && $globalTracker) { |
|
| 164 | + require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
| 165 | +} |
|
| 125 | 166 | if (isset($globalMarine) && $globalMarine) { |
| 126 | 167 | require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
| 127 | 168 | require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
| 128 | 169 | } |
| 129 | 170 | |
| 130 | -if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db); |
|
| 171 | +if (isset($globalTracker) && $globalTracker) { |
|
| 172 | + $TI = new TrackerImport($Connection->db); |
|
| 173 | +} |
|
| 131 | 174 | if (isset($globalMarine) && $globalMarine) { |
| 132 | 175 | $AIS = new AIS(); |
| 133 | 176 | $MI = new MarineImport($Connection->db); |
@@ -152,7 +195,9 @@ discard block |
||
| 152 | 195 | } |
| 153 | 196 | |
| 154 | 197 | // let's try and connect |
| 155 | -if ($globalDebug) echo "Connecting...\n"; |
|
| 198 | +if ($globalDebug) { |
|
| 199 | + echo "Connecting...\n"; |
|
| 200 | +} |
|
| 156 | 201 | $use_aprs = false; |
| 157 | 202 | $aprs_full = false; |
| 158 | 203 | $reset = 0; |
@@ -161,7 +206,9 @@ discard block |
||
| 161 | 206 | //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
| 162 | 207 | global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
| 163 | 208 | $reset++; |
| 164 | - if ($globalDebug) echo 'Connect to all...'."\n"; |
|
| 209 | + if ($globalDebug) { |
|
| 210 | + echo 'Connect to all...'."\n"; |
|
| 211 | + } |
|
| 165 | 212 | foreach ($hosts as $id => $value) { |
| 166 | 213 | $host = $value['host']; |
| 167 | 214 | $udp = false; |
@@ -172,32 +219,44 @@ discard block |
||
| 172 | 219 | //$formats[$id] = 'deltadbtxt'; |
| 173 | 220 | $globalSources[$id]['format'] = 'deltadbtxt'; |
| 174 | 221 | //$last_exec['deltadbtxt'] = 0; |
| 175 | - if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
| 222 | + if ($globalDebug) { |
|
| 223 | + echo "Connect to deltadb source (".$host.")...\n"; |
|
| 224 | + } |
|
| 176 | 225 | } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
| 177 | 226 | //$formats[$id] = 'vatsimtxt'; |
| 178 | 227 | $globalSources[$id]['format'] = 'vatsimtxt'; |
| 179 | 228 | //$last_exec['vatsimtxt'] = 0; |
| 180 | - if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
| 229 | + if ($globalDebug) { |
|
| 230 | + echo "Connect to vatsim source (".$host.")...\n"; |
|
| 231 | + } |
|
| 181 | 232 | } else if (preg_match('/aircraftlist.json$/i',$host)) { |
| 182 | 233 | //$formats[$id] = 'aircraftlistjson'; |
| 183 | 234 | $globalSources[$id]['format'] = 'aircraftlistjson'; |
| 184 | 235 | //$last_exec['aircraftlistjson'] = 0; |
| 185 | - if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
| 236 | + if ($globalDebug) { |
|
| 237 | + echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
| 238 | + } |
|
| 186 | 239 | } else if (preg_match('/aircraft.json$/i',$host)) { |
| 187 | 240 | //$formats[$id] = 'aircraftjson'; |
| 188 | 241 | $globalSources[$id]['format'] = 'aircraftjson'; |
| 189 | 242 | //$last_exec['aircraftlistjson'] = 0; |
| 190 | - if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n"; |
|
| 243 | + if ($globalDebug) { |
|
| 244 | + echo "Connect to aircraft.json source (".$host.")...\n"; |
|
| 245 | + } |
|
| 191 | 246 | } else if (preg_match('/aircraft$/i',$host)) { |
| 192 | 247 | //$formats[$id] = 'planefinderclient'; |
| 193 | 248 | $globalSources[$id]['format'] = 'planefinderclient'; |
| 194 | 249 | //$last_exec['aircraftlistjson'] = 0; |
| 195 | - if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n"; |
|
| 250 | + if ($globalDebug) { |
|
| 251 | + echo "Connect to planefinderclient source (".$host.")...\n"; |
|
| 252 | + } |
|
| 196 | 253 | } else if (preg_match('/opensky/i',$host)) { |
| 197 | 254 | //$formats[$id] = 'aircraftlistjson'; |
| 198 | 255 | $globalSources[$id]['format'] = 'opensky'; |
| 199 | 256 | //$last_exec['aircraftlistjson'] = 0; |
| 200 | - if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
| 257 | + if ($globalDebug) { |
|
| 258 | + echo "Connect to opensky source (".$host.")...\n"; |
|
| 259 | + } |
|
| 201 | 260 | /* |
| 202 | 261 | // Disabled for now, site change source format |
| 203 | 262 | } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) { |
@@ -214,7 +273,9 @@ discard block |
||
| 214 | 273 | //$formats[$id] = 'planeupdatefaa'; |
| 215 | 274 | $globalSources[$id]['format'] = 'planeupdatefaa'; |
| 216 | 275 | //$last_exec['planeupdatefaa'] = 0; |
| 217 | - if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
| 276 | + if ($globalDebug) { |
|
| 277 | + echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
| 278 | + } |
|
| 218 | 279 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
| 219 | 280 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
| 220 | 281 | exit(0); |
@@ -223,37 +284,53 @@ discard block |
||
| 223 | 284 | //$formats[$id] = 'phpvmacars'; |
| 224 | 285 | $globalSources[$id]['format'] = 'phpvmacars'; |
| 225 | 286 | //$last_exec['phpvmacars'] = 0; |
| 226 | - if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
| 287 | + if ($globalDebug) { |
|
| 288 | + echo "Connect to phpvmacars source (".$host.")...\n"; |
|
| 289 | + } |
|
| 227 | 290 | } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) { |
| 228 | 291 | //$formats[$id] = 'phpvmacars'; |
| 229 | 292 | $globalSources[$id]['format'] = 'vaos'; |
| 230 | 293 | //$last_exec['phpvmacars'] = 0; |
| 231 | - if ($globalDebug) echo "Connect to vaos source (".$host.")...\n"; |
|
| 294 | + if ($globalDebug) { |
|
| 295 | + echo "Connect to vaos source (".$host.")...\n"; |
|
| 296 | + } |
|
| 232 | 297 | } else if (preg_match('/VAM-json.php$/i',$host)) { |
| 233 | 298 | //$formats[$id] = 'phpvmacars'; |
| 234 | 299 | $globalSources[$id]['format'] = 'vam'; |
| 235 | - if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
| 300 | + if ($globalDebug) { |
|
| 301 | + echo "Connect to Vam source (".$host.")...\n"; |
|
| 302 | + } |
|
| 236 | 303 | } else if (preg_match('/whazzup/i',$host)) { |
| 237 | 304 | //$formats[$id] = 'whazzup'; |
| 238 | 305 | $globalSources[$id]['format'] = 'whazzup'; |
| 239 | 306 | //$last_exec['whazzup'] = 0; |
| 240 | - if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
| 307 | + if ($globalDebug) { |
|
| 308 | + echo "Connect to whazzup source (".$host.")...\n"; |
|
| 309 | + } |
|
| 241 | 310 | } else if (preg_match('/blitzortung/i',$host)) { |
| 242 | 311 | $globalSources[$id]['format'] = 'blitzortung'; |
| 243 | - if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n"; |
|
| 312 | + if ($globalDebug) { |
|
| 313 | + echo "Connect to blitzortung source (".$host.")...\n"; |
|
| 314 | + } |
|
| 244 | 315 | } else if (preg_match('/airwhere/i',$host)) { |
| 245 | 316 | $globalSources[$id]['format'] = 'airwhere'; |
| 246 | - if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
|
| 317 | + if ($globalDebug) { |
|
| 318 | + echo "Connect to airwhere source (".$host.")...\n"; |
|
| 319 | + } |
|
| 247 | 320 | } else if (preg_match('/recentpireps/i',$host)) { |
| 248 | 321 | //$formats[$id] = 'pirepsjson'; |
| 249 | 322 | $globalSources[$id]['format'] = 'pirepsjson'; |
| 250 | 323 | //$last_exec['pirepsjson'] = 0; |
| 251 | - if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
| 324 | + if ($globalDebug) { |
|
| 325 | + echo "Connect to pirepsjson source (".$host.")...\n"; |
|
| 326 | + } |
|
| 252 | 327 | } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
| 253 | 328 | //$formats[$id] = 'fr24json'; |
| 254 | 329 | $globalSources[$id]['format'] = 'fr24json'; |
| 255 | 330 | //$last_exec['fr24json'] = 0; |
| 256 | - if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
| 331 | + if ($globalDebug) { |
|
| 332 | + echo "Connect to fr24 source (".$host.")...\n"; |
|
| 333 | + } |
|
| 257 | 334 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
| 258 | 335 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
| 259 | 336 | exit(0); |
@@ -262,7 +339,9 @@ discard block |
||
| 262 | 339 | //$formats[$id] = 'fr24json'; |
| 263 | 340 | $globalSources[$id]['format'] = 'myshiptracking'; |
| 264 | 341 | //$last_exec['fr24json'] = 0; |
| 265 | - if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
| 342 | + if ($globalDebug) { |
|
| 343 | + echo "Connect to myshiptracking source (".$host.")...\n"; |
|
| 344 | + } |
|
| 266 | 345 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
| 267 | 346 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
| 268 | 347 | exit(0); |
@@ -271,18 +350,28 @@ discard block |
||
| 271 | 350 | } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
| 272 | 351 | //$formats[$id] = 'tsv'; |
| 273 | 352 | $globalSources[$id]['format'] = 'tsv'; |
| 274 | - if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
| 353 | + if ($globalDebug) { |
|
| 354 | + echo "Connect to tsv source (".$host.")...\n"; |
|
| 355 | + } |
|
| 275 | 356 | } |
| 276 | 357 | } 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 | 358 | if ($globalSources[$id]['format'] == 'aisnmeahttp' || $globalSources[$id]['format'] == 'acarsjson') { |
| 278 | 359 | $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
| 279 | 360 | if ($idf !== false) { |
| 280 | 361 | $httpfeeds[$id] = $idf; |
| 281 | - if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 282 | - } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
| 283 | - } elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n"; |
|
| 284 | - elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailawayfull') echo "Connect to ".$globalSources[$id]['format']." source (sailawayfull)...\n"; |
|
| 285 | - elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 362 | + if ($globalDebug) { |
|
| 363 | + echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 364 | + } |
|
| 365 | + } elseif ($globalDebug) { |
|
| 366 | + echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
| 367 | + } |
|
| 368 | + } elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') { |
|
| 369 | + echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n"; |
|
| 370 | + } elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailawayfull') { |
|
| 371 | + echo "Connect to ".$globalSources[$id]['format']." source (sailawayfull)...\n"; |
|
| 372 | + } elseif ($globalDebug) { |
|
| 373 | + echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 374 | + } |
|
| 286 | 375 | } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
| 287 | 376 | $hostport = explode(':',$host); |
| 288 | 377 | if (isset($hostport[1])) { |
@@ -323,20 +412,29 @@ discard block |
||
| 323 | 412 | //$formats[$id] = 'beast'; |
| 324 | 413 | $globalSources[$id]['format'] = 'beast'; |
| 325 | 414 | //} else $formats[$id] = 'sbs'; |
| 326 | - } else $globalSources[$id]['format'] = 'sbs'; |
|
| 415 | + } else { |
|
| 416 | + $globalSources[$id]['format'] = 'sbs'; |
|
| 417 | + } |
|
| 327 | 418 | //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
| 328 | 419 | } |
| 329 | - if ($globalDebug && $udp) echo 'Listening in UDP from '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
|
| 330 | - elseif ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
|
| 420 | + if ($globalDebug && $udp) { |
|
| 421 | + echo 'Listening in UDP from '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
|
| 422 | + } elseif ($globalDebug) { |
|
| 423 | + echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
|
| 424 | + } |
|
| 331 | 425 | } else { |
| 332 | - if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
|
| 426 | + if ($globalDebug) { |
|
| 427 | + echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
|
| 428 | + } |
|
| 333 | 429 | sleep(10); |
| 334 | 430 | connect_all($hosts); |
| 335 | 431 | } |
| 336 | 432 | } |
| 337 | 433 | } |
| 338 | 434 | } |
| 339 | -if (!isset($globalMinFetch)) $globalMinFetch = 15; |
|
| 435 | +if (!isset($globalMinFetch)) { |
|
| 436 | + $globalMinFetch = 15; |
|
| 437 | +} |
|
| 340 | 438 | |
| 341 | 439 | // Initialize all |
| 342 | 440 | $status = array(); |
@@ -345,13 +443,19 @@ discard block |
||
| 345 | 443 | $formats = array(); |
| 346 | 444 | $last_exec = array(); |
| 347 | 445 | $time = time(); |
| 348 | -if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut; |
|
| 349 | -else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut; |
|
| 350 | -else $timeout = 20; |
|
| 446 | +if (isset($globalSourcesTimeout)) { |
|
| 447 | + $timeout = $globalSourcesTimeOut; |
|
| 448 | +} else if (isset($globalSBS1TimeOut)) { |
|
| 449 | + $timeout = $globalSBS1TimeOut; |
|
| 450 | +} else { |
|
| 451 | + $timeout = 20; |
|
| 452 | +} |
|
| 351 | 453 | $errno = ''; |
| 352 | 454 | $errstr=''; |
| 353 | 455 | |
| 354 | -if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
| 456 | +if (!isset($globalDaemon)) { |
|
| 457 | + $globalDaemon = TRUE; |
|
| 458 | +} |
|
| 355 | 459 | /* Initiate connections to all the hosts simultaneously */ |
| 356 | 460 | //connect_all($hosts); |
| 357 | 461 | //connect_all($globalSources); |
@@ -380,7 +484,9 @@ discard block |
||
| 380 | 484 | if (isset($source['format']) && $source['format'] == 'aprs') { |
| 381 | 485 | $aprs_connect = 0; |
| 382 | 486 | $use_aprs = true; |
| 383 | - if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true; |
|
| 487 | + if (isset($source['port']) && $source['port'] == '10152') { |
|
| 488 | + $aprs_full = true; |
|
| 489 | + } |
|
| 384 | 490 | break; |
| 385 | 491 | } |
| 386 | 492 | } |
@@ -391,25 +497,46 @@ discard block |
||
| 391 | 497 | $aprs_connect = 0; |
| 392 | 498 | $aprs_keep = 120; |
| 393 | 499 | $aprs_last_tx = time(); |
| 394 | - if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; |
|
| 395 | - else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
| 396 | - if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid; |
|
| 397 | - else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
| 398 | - if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter; |
|
| 399 | - else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
| 400 | - if ($aprs_full) $aprs_filter = ''; |
|
| 401 | - if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass; |
|
| 402 | - else $aprs_pass = '-1'; |
|
| 500 | + if (isset($globalAPRSversion)) { |
|
| 501 | + $aprs_version = $globalAPRSversion; |
|
| 502 | + } else { |
|
| 503 | + $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
| 504 | + } |
|
| 505 | + if (isset($globalAPRSssid)) { |
|
| 506 | + $aprs_ssid = $globalAPRSssid; |
|
| 507 | + } else { |
|
| 508 | + $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
| 509 | + } |
|
| 510 | + if (isset($globalAPRSfilter)) { |
|
| 511 | + $aprs_filter = $globalAPRSfilter; |
|
| 512 | + } else { |
|
| 513 | + $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
| 514 | + } |
|
| 515 | + if ($aprs_full) { |
|
| 516 | + $aprs_filter = ''; |
|
| 517 | + } |
|
| 518 | + if (isset($globalAPRSpass)) { |
|
| 519 | + $aprs_pass = $globalAPRSpass; |
|
| 520 | + } else { |
|
| 521 | + $aprs_pass = '-1'; |
|
| 522 | + } |
|
| 403 | 523 | |
| 404 | - if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n"; |
|
| 405 | - else $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; |
|
| 406 | -} |
|
| 524 | + if ($aprs_filter != '') { |
|
| 525 | + $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n"; |
|
| 526 | + } else { |
|
| 527 | + $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; |
|
| 528 | + } |
|
| 529 | + } |
|
| 407 | 530 | |
| 408 | 531 | // connected - lets do some work |
| 409 | 532 | //if ($globalDebug) echo "Connected!\n"; |
| 410 | 533 | sleep(1); |
| 411 | -if ($globalDebug) echo "SCAN MODE \n\n"; |
|
| 412 | -if (!isset($globalCronEnd)) $globalCronEnd = 60; |
|
| 534 | +if ($globalDebug) { |
|
| 535 | + echo "SCAN MODE \n\n"; |
|
| 536 | +} |
|
| 537 | +if (!isset($globalCronEnd)) { |
|
| 538 | + $globalCronEnd = 60; |
|
| 539 | +} |
|
| 413 | 540 | $endtime = time()+$globalCronEnd; |
| 414 | 541 | $i = 1; |
| 415 | 542 | $tt = array(); |
@@ -423,22 +550,32 @@ discard block |
||
| 423 | 550 | |
| 424 | 551 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
| 425 | 552 | while ($i > 0) { |
| 426 | - if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
| 553 | + if (function_exists('pcntl_fork')) { |
|
| 554 | + pcntl_signal_dispatch(); |
|
| 555 | + } |
|
| 427 | 556 | |
| 428 | - if (!$globalDaemon) $i = $endtime-time(); |
|
| 557 | + if (!$globalDaemon) { |
|
| 558 | + $i = $endtime-time(); |
|
| 559 | + } |
|
| 429 | 560 | // Delete old ATC |
| 430 | 561 | if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
| 431 | - if ($globalDebug) echo 'Delete old ATC...'."\n"; |
|
| 562 | + if ($globalDebug) { |
|
| 563 | + echo 'Delete old ATC...'."\n"; |
|
| 564 | + } |
|
| 432 | 565 | $ATC->deleteOldATC(); |
| 433 | 566 | } |
| 434 | 567 | |
| 435 | 568 | if (count($last_exec) == count($globalSources)) { |
| 436 | 569 | $max = $globalMinFetch; |
| 437 | 570 | foreach ($last_exec as $last) { |
| 438 | - if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
| 571 | + if ((time() - $last['last']) < $max) { |
|
| 572 | + $max = time() - $last['last']; |
|
| 573 | + } |
|
| 439 | 574 | } |
| 440 | 575 | if ($max < $globalMinFetch) { |
| 441 | - if ($globalDebug) echo 'Sleeping...'."\n"; |
|
| 576 | + if ($globalDebug) { |
|
| 577 | + echo 'Sleeping...'."\n"; |
|
| 578 | + } |
|
| 442 | 579 | sleep($globalMinFetch-$max+2); |
| 443 | 580 | } |
| 444 | 581 | } |
@@ -448,7 +585,9 @@ discard block |
||
| 448 | 585 | foreach ($globalSources as $id => $value) { |
| 449 | 586 | date_default_timezone_set('UTC'); |
| 450 | 587 | //if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n"; |
| 451 | - if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0; |
|
| 588 | + if (!isset($last_exec[$id]['last'])) { |
|
| 589 | + $last_exec[$id]['last'] = 0; |
|
| 590 | + } |
|
| 452 | 591 | if ($value['format'] === 'deltadbtxt' && |
| 453 | 592 | ( |
| 454 | 593 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
@@ -457,7 +596,9 @@ discard block |
||
| 457 | 596 | ) { |
| 458 | 597 | //$buffer = $Common->getData($hosts[$id]); |
| 459 | 598 | $buffer = $Common->getData($value['host']); |
| 460 | - if ($buffer != '') $reset = 0; |
|
| 599 | + if ($buffer != '') { |
|
| 600 | + $reset = 0; |
|
| 601 | + } |
|
| 461 | 602 | $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
| 462 | 603 | $buffer = explode('\n', $buffer); |
| 463 | 604 | foreach ($buffer as $line) { |
@@ -466,20 +607,41 @@ discard block |
||
| 466 | 607 | $data = array(); |
| 467 | 608 | $data['hex'] = $line[1]; // hex |
| 468 | 609 | $data['ident'] = $line[2]; // ident |
| 469 | - if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
| 470 | - if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
| 471 | - if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
| 472 | - if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
| 473 | - if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
| 610 | + if (isset($line[3])) { |
|
| 611 | + $data['altitude'] = $line[3]; |
|
| 612 | + } |
|
| 613 | + // altitude |
|
| 614 | + if (isset($line[4])) { |
|
| 615 | + $data['speed'] = $line[4]; |
|
| 616 | + } |
|
| 617 | + // speed |
|
| 618 | + if (isset($line[5])) { |
|
| 619 | + $data['heading'] = $line[5]; |
|
| 620 | + } |
|
| 621 | + // heading |
|
| 622 | + if (isset($line[6])) { |
|
| 623 | + $data['latitude'] = $line[6]; |
|
| 624 | + } |
|
| 625 | + // lat |
|
| 626 | + if (isset($line[7])) { |
|
| 627 | + $data['longitude'] = $line[7]; |
|
| 628 | + } |
|
| 629 | + // long |
|
| 474 | 630 | $data['verticalrate'] = ''; // vertical rate |
| 475 | 631 | //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
| 476 | 632 | $data['emergency'] = ''; // emergency |
| 477 | 633 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 478 | 634 | $data['format_source'] = 'deltadbtxt'; |
| 479 | 635 | $data['id_source'] = $id_source; |
| 480 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 481 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 482 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
| 636 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 637 | + $data['source_name'] = $value['name']; |
|
| 638 | + } |
|
| 639 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 640 | + $data['noarchive'] = true; |
|
| 641 | + } |
|
| 642 | + if (isset($value['sourcestats'])) { |
|
| 643 | + $data['sourcestats'] = $value['sourcestats']; |
|
| 644 | + } |
|
| 483 | 645 | $SI->add($data); |
| 484 | 646 | unset($data); |
| 485 | 647 | } |
@@ -514,11 +676,20 @@ discard block |
||
| 514 | 676 | $data['format_source'] = 'radarcapejson'; |
| 515 | 677 | $data['id_source'] = $id_source; |
| 516 | 678 | if (isset($value['name']) && $value['name'] != '') { |
| 517 | - if (isset($line['src']) && !$line['src'] == 'M') $data['source_name'] = $value['name'].'_MLAT'; |
|
| 518 | - else $data['source_name'] = $value['name']; |
|
| 519 | - } elseif (isset($line['src']) && $line['src'] == 'M') $data['source_name'] = 'MLAT'; |
|
| 520 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 521 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
| 679 | + if (isset($line['src']) && !$line['src'] == 'M') { |
|
| 680 | + $data['source_name'] = $value['name'].'_MLAT'; |
|
| 681 | + } else { |
|
| 682 | + $data['source_name'] = $value['name']; |
|
| 683 | + } |
|
| 684 | + } elseif (isset($line['src']) && $line['src'] == 'M') { |
|
| 685 | + $data['source_name'] = 'MLAT'; |
|
| 686 | + } |
|
| 687 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 688 | + $data['noarchive'] = true; |
|
| 689 | + } |
|
| 690 | + if (isset($value['sourcestats'])) { |
|
| 691 | + $data['sourcestats'] = $value['sourcestats']; |
|
| 692 | + } |
|
| 522 | 693 | |
| 523 | 694 | $SI->add($data); |
| 524 | 695 | unset($data); |
@@ -534,7 +705,9 @@ discard block |
||
| 534 | 705 | date_default_timezone_set('CET'); |
| 535 | 706 | $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
| 536 | 707 | date_default_timezone_set('UTC'); |
| 537 | - if ($buffer != '') $reset = 0; |
|
| 708 | + if ($buffer != '') { |
|
| 709 | + $reset = 0; |
|
| 710 | + } |
|
| 538 | 711 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
| 539 | 712 | $buffer = explode('\n',$buffer); |
| 540 | 713 | foreach ($buffer as $line) { |
@@ -543,18 +716,42 @@ discard block |
||
| 543 | 716 | $add = false; |
| 544 | 717 | $ais_data = $AIS->parse_line(trim($line)); |
| 545 | 718 | $data = array(); |
| 546 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 547 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
| 548 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 549 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 550 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 551 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 552 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 553 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
| 554 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 555 | - if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid']; |
|
| 556 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 557 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 719 | + if (isset($ais_data['ident'])) { |
|
| 720 | + $data['ident'] = $ais_data['ident']; |
|
| 721 | + } |
|
| 722 | + if (isset($ais_data['mmsi'])) { |
|
| 723 | + $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
| 724 | + } |
|
| 725 | + if (isset($ais_data['speed'])) { |
|
| 726 | + $data['speed'] = $ais_data['speed']; |
|
| 727 | + } |
|
| 728 | + if (isset($ais_data['heading'])) { |
|
| 729 | + $data['heading'] = $ais_data['heading']; |
|
| 730 | + } |
|
| 731 | + if (isset($ais_data['latitude'])) { |
|
| 732 | + $data['latitude'] = $ais_data['latitude']; |
|
| 733 | + } |
|
| 734 | + if (isset($ais_data['longitude'])) { |
|
| 735 | + $data['longitude'] = $ais_data['longitude']; |
|
| 736 | + } |
|
| 737 | + if (isset($ais_data['status'])) { |
|
| 738 | + $data['status'] = $ais_data['status']; |
|
| 739 | + } |
|
| 740 | + if (isset($ais_data['statusid'])) { |
|
| 741 | + $data['status_id'] = $ais_data['statusid']; |
|
| 742 | + } |
|
| 743 | + if (isset($ais_data['type'])) { |
|
| 744 | + $data['type'] = $ais_data['type']; |
|
| 745 | + } |
|
| 746 | + if (isset($ais_data['typeid'])) { |
|
| 747 | + $data['type_id'] = $ais_data['typeid']; |
|
| 748 | + } |
|
| 749 | + if (isset($ais_data['imo'])) { |
|
| 750 | + $data['imo'] = $ais_data['imo']; |
|
| 751 | + } |
|
| 752 | + if (isset($ais_data['callsign'])) { |
|
| 753 | + $data['callsign'] = $ais_data['callsign']; |
|
| 754 | + } |
|
| 558 | 755 | if (isset($ais_data['timestamp'])) { |
| 559 | 756 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
| 560 | 757 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
@@ -568,8 +765,12 @@ discard block |
||
| 568 | 765 | $data['format_source'] = 'aisnmeatxt'; |
| 569 | 766 | $data['id_source'] = $id_source; |
| 570 | 767 | //print_r($data); |
| 571 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 572 | - if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
| 768 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 769 | + $data['noarchive'] = true; |
|
| 770 | + } |
|
| 771 | + if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') { |
|
| 772 | + $MI->add($data); |
|
| 773 | + } |
|
| 573 | 774 | unset($data); |
| 574 | 775 | } |
| 575 | 776 | } |
@@ -592,20 +793,48 @@ discard block |
||
| 592 | 793 | if ($line != '') { |
| 593 | 794 | $ais_data = $AIS->parse_line(trim($line)); |
| 594 | 795 | $data = array(); |
| 595 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 596 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
| 597 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 598 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 599 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 600 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 601 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 602 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
| 603 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 604 | - if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid']; |
|
| 605 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 606 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 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']); |
|
| 796 | + if (isset($ais_data['ident'])) { |
|
| 797 | + $data['ident'] = $ais_data['ident']; |
|
| 798 | + } |
|
| 799 | + if (isset($ais_data['mmsi'])) { |
|
| 800 | + $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
| 801 | + } |
|
| 802 | + if (isset($ais_data['speed'])) { |
|
| 803 | + $data['speed'] = $ais_data['speed']; |
|
| 804 | + } |
|
| 805 | + if (isset($ais_data['heading'])) { |
|
| 806 | + $data['heading'] = $ais_data['heading']; |
|
| 807 | + } |
|
| 808 | + if (isset($ais_data['latitude'])) { |
|
| 809 | + $data['latitude'] = $ais_data['latitude']; |
|
| 810 | + } |
|
| 811 | + if (isset($ais_data['longitude'])) { |
|
| 812 | + $data['longitude'] = $ais_data['longitude']; |
|
| 813 | + } |
|
| 814 | + if (isset($ais_data['status'])) { |
|
| 815 | + $data['status'] = $ais_data['status']; |
|
| 816 | + } |
|
| 817 | + if (isset($ais_data['statusid'])) { |
|
| 818 | + $data['status_id'] = $ais_data['statusid']; |
|
| 819 | + } |
|
| 820 | + if (isset($ais_data['type'])) { |
|
| 821 | + $data['type'] = $ais_data['type']; |
|
| 822 | + } |
|
| 823 | + if (isset($ais_data['typeid'])) { |
|
| 824 | + $data['type_id'] = $ais_data['typeid']; |
|
| 825 | + } |
|
| 826 | + if (isset($ais_data['imo'])) { |
|
| 827 | + $data['imo'] = $ais_data['imo']; |
|
| 828 | + } |
|
| 829 | + if (isset($ais_data['callsign'])) { |
|
| 830 | + $data['callsign'] = $ais_data['callsign']; |
|
| 831 | + } |
|
| 832 | + if (isset($ais_data['destination'])) { |
|
| 833 | + $data['arrival_code'] = $ais_data['destination']; |
|
| 834 | + } |
|
| 835 | + if (isset($ais_data['eta_ts'])) { |
|
| 836 | + $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 837 | + } |
|
| 609 | 838 | if (isset($ais_data['timestamp'])) { |
| 610 | 839 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
| 611 | 840 | } else { |
@@ -613,18 +842,27 @@ discard block |
||
| 613 | 842 | } |
| 614 | 843 | $data['format_source'] = 'aisnmeahttp'; |
| 615 | 844 | $data['id_source'] = $id_source; |
| 616 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 617 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
| 845 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 846 | + $data['noarchive'] = true; |
|
| 847 | + } |
|
| 848 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') { |
|
| 849 | + $MI->add($data); |
|
| 850 | + } |
|
| 618 | 851 | unset($data); |
| 619 | 852 | } |
| 620 | 853 | } |
| 621 | 854 | } |
| 622 | 855 | } else { |
| 623 | 856 | $format = $value['format']; |
| 624 | - if (isset($tt[$format])) $tt[$format]++; |
|
| 625 | - else $tt[$format] = 0; |
|
| 857 | + if (isset($tt[$format])) { |
|
| 858 | + $tt[$format]++; |
|
| 859 | + } else { |
|
| 860 | + $tt[$format] = 0; |
|
| 861 | + } |
|
| 626 | 862 | if ($tt[$format] > 30) { |
| 627 | - if ($globalDebug) echo 'Reconnect...'."\n"; |
|
| 863 | + if ($globalDebug) { |
|
| 864 | + echo 'Reconnect...'."\n"; |
|
| 865 | + } |
|
| 628 | 866 | sleep(2); |
| 629 | 867 | //$sourceeen[] = $value; |
| 630 | 868 | //connect_all($sourceeen); |
@@ -660,12 +898,18 @@ discard block |
||
| 660 | 898 | // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
| 661 | 899 | //$data['type_id'] = $line['TYPE']; |
| 662 | 900 | $data['imo'] = $line['IMO']; |
| 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'])); |
|
| 901 | + if ($line['DEST'] != '') { |
|
| 902 | + $data['arrival_code'] = $line['DEST']; |
|
| 903 | + } |
|
| 904 | + if ($line['ARV'] != '') { |
|
| 905 | + $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV'])); |
|
| 906 | + } |
|
| 665 | 907 | $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
| 666 | 908 | $data['format_source'] = 'myshiptracking'; |
| 667 | 909 | $data['id_source'] = $id_source; |
| 668 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 910 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 911 | + $data['noarchive'] = true; |
|
| 912 | + } |
|
| 669 | 913 | $MI->add($data); |
| 670 | 914 | unset($data); |
| 671 | 915 | } |
@@ -690,7 +934,9 @@ discard block |
||
| 690 | 934 | $data['callsign'] = $line['callsign']; |
| 691 | 935 | $data['mmsi'] = substr($line['mmsi'],-9); |
| 692 | 936 | $data['speed'] = $line['sog']; |
| 693 | - if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
| 937 | + if ($line['heading'] != '511') { |
|
| 938 | + $data['heading'] = $line['heading']; |
|
| 939 | + } |
|
| 694 | 940 | $data['latitude'] = $line['latitude']; |
| 695 | 941 | $data['longitude'] = $line['longitude']; |
| 696 | 942 | $data['type_id'] = $line['shiptype']; |
@@ -698,7 +944,9 @@ discard block |
||
| 698 | 944 | $data['datetime'] = $line['time']; |
| 699 | 945 | $data['format_source'] = 'boatbeaconapp'; |
| 700 | 946 | $data['id_source'] = $id_source; |
| 701 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 947 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 948 | + $data['noarchive'] = true; |
|
| 949 | + } |
|
| 702 | 950 | $MI->add($data); |
| 703 | 951 | unset($data); |
| 704 | 952 | } |
@@ -720,22 +968,44 @@ discard block |
||
| 720 | 968 | foreach ($all_data['features'] as $line) { |
| 721 | 969 | print_r($line); |
| 722 | 970 | $data = array(); |
| 723 | - if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name']; |
|
| 724 | - if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign']; |
|
| 725 | - if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'],-9); |
|
| 726 | - if (isset($line['properties']['imo'])) $data['imo'] = $line['properties']['imo']; |
|
| 727 | - if (isset($line['properties']['speed'])) $data['speed'] = $line['properties']['speed']; |
|
| 728 | - if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) $data['heading'] = $line['properties']['heading']; |
|
| 971 | + if (isset($line['properties']['name'])) { |
|
| 972 | + $data['ident'] = $line['properties']['name']; |
|
| 973 | + } |
|
| 974 | + if (isset($line['properties']['callsign'])) { |
|
| 975 | + $data['callsign'] = $line['properties']['callsign']; |
|
| 976 | + } |
|
| 977 | + if (isset($line['properties']['mmsi'])) { |
|
| 978 | + $data['mmsi'] = substr($line['properties']['mmsi'],-9); |
|
| 979 | + } |
|
| 980 | + if (isset($line['properties']['imo'])) { |
|
| 981 | + $data['imo'] = $line['properties']['imo']; |
|
| 982 | + } |
|
| 983 | + if (isset($line['properties']['speed'])) { |
|
| 984 | + $data['speed'] = $line['properties']['speed']; |
|
| 985 | + } |
|
| 986 | + if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) { |
|
| 987 | + $data['heading'] = $line['properties']['heading']; |
|
| 988 | + } |
|
| 729 | 989 | $data['latitude'] = $line['geometry']['coordinates'][1]; |
| 730 | 990 | $data['longitude'] = $line['geometry']['coordinates'][0]; |
| 731 | - if (isset($line['properties']['vesselType'])) $data['type'] = $line['properties']['vesselType']; |
|
| 732 | - if (isset($line['properties']['destination'])) $data['arrival_code'] = $line['properties']['destination']; |
|
| 733 | - if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') $data['arrival_date'] = $line['properties']['eta']; |
|
| 991 | + if (isset($line['properties']['vesselType'])) { |
|
| 992 | + $data['type'] = $line['properties']['vesselType']; |
|
| 993 | + } |
|
| 994 | + if (isset($line['properties']['destination'])) { |
|
| 995 | + $data['arrival_code'] = $line['properties']['destination']; |
|
| 996 | + } |
|
| 997 | + if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') { |
|
| 998 | + $data['arrival_date'] = $line['properties']['eta']; |
|
| 999 | + } |
|
| 734 | 1000 | $data['format_source'] = 'boatnerd'; |
| 735 | 1001 | $data['id_source'] = $id_source; |
| 736 | 1002 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 737 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 738 | - if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data); |
|
| 1003 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1004 | + $data['noarchive'] = true; |
|
| 1005 | + } |
|
| 1006 | + if ($line['properties']['vesselType'] != 'Navigation Aid') { |
|
| 1007 | + $MI->add($data); |
|
| 1008 | + } |
|
| 739 | 1009 | unset($data); |
| 740 | 1010 | } |
| 741 | 1011 | } |
@@ -748,11 +1018,17 @@ discard block |
||
| 748 | 1018 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
| 749 | 1019 | ) |
| 750 | 1020 | ) { |
| 751 | - if ($globalDebug) echo 'download...'; |
|
| 1021 | + if ($globalDebug) { |
|
| 1022 | + echo 'download...'; |
|
| 1023 | + } |
|
| 752 | 1024 | $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
| 753 | - if ($globalDebug) echo 'done !'."\n"; |
|
| 1025 | + if ($globalDebug) { |
|
| 1026 | + echo 'done !'."\n"; |
|
| 1027 | + } |
|
| 754 | 1028 | // FIXME: Need more work |
| 755 | - if ($buffer != '') $reset = 0; |
|
| 1029 | + if ($buffer != '') { |
|
| 1030 | + $reset = 0; |
|
| 1031 | + } |
|
| 756 | 1032 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
| 757 | 1033 | $buffer = explode('\n',$buffer); |
| 758 | 1034 | foreach ($buffer as $line) { |
@@ -778,7 +1054,9 @@ discard block |
||
| 778 | 1054 | //$data['etaTime'] = substr($line,135,5); |
| 779 | 1055 | $data['format_source'] = 'shipplotter'; |
| 780 | 1056 | $data['id_source'] = $id_source; |
| 781 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1057 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1058 | + $data['noarchive'] = true; |
|
| 1059 | + } |
|
| 782 | 1060 | //print_r($data); |
| 783 | 1061 | //echo 'Add...'."\n"; |
| 784 | 1062 | $MI->add($data); |
@@ -800,11 +1078,17 @@ discard block |
||
| 800 | 1078 | } |
| 801 | 1079 | } |
| 802 | 1080 | |
| 803 | - if ($globalDebug) echo '! Download... '; |
|
| 1081 | + if ($globalDebug) { |
|
| 1082 | + echo '! Download... '; |
|
| 1083 | + } |
|
| 804 | 1084 | for ($i =0; $i <= 1; $i++) { |
| 805 | - if ($globalDebug) echo 'Racetype: '.$i.' '; |
|
| 1085 | + if ($globalDebug) { |
|
| 1086 | + echo 'Racetype: '.$i.' '; |
|
| 1087 | + } |
|
| 806 | 1088 | $buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/GetMissions.pl?race=1&tutorial=0&hist=1&racetype='.$i); |
| 807 | - if ($globalDebug) echo 'done'."\n"; |
|
| 1089 | + if ($globalDebug) { |
|
| 1090 | + echo 'done'."\n"; |
|
| 1091 | + } |
|
| 808 | 1092 | if ($buffer != '') { |
| 809 | 1093 | $all_data = json_decode($buffer,true); |
| 810 | 1094 | if (isset($all_data['missions'])) { |
@@ -815,7 +1099,9 @@ discard block |
||
| 815 | 1099 | if (isset($sailaway_authcookie) && $sailaway_authcookie != '') { |
| 816 | 1100 | $racebuffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/GetMission.pl?misnr='.$mission['misnr'],'get','','',$sailaway_authcookie); |
| 817 | 1101 | sleep(30); |
| 818 | - } else $racebuffer = ''; |
|
| 1102 | + } else { |
|
| 1103 | + $racebuffer = ''; |
|
| 1104 | + } |
|
| 819 | 1105 | $bufferm = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/GetLeaderboard.pl?misnr='.$mission['misnr']); |
| 820 | 1106 | } else { |
| 821 | 1107 | $bufferm = ''; |
@@ -879,7 +1165,9 @@ discard block |
||
| 879 | 1165 | $data['captain_id'] = $sail['usrnr']; |
| 880 | 1166 | $data['captain_name'] = $sail['usrname']; |
| 881 | 1167 | $data['race_id'] = $sail['misnr']; |
| 882 | - if ($sail['rank'] != 'DNF') $data['race_rank'] = $sail['rank']; |
|
| 1168 | + if ($sail['rank'] != 'DNF') { |
|
| 1169 | + $data['race_rank'] = $sail['rank']; |
|
| 1170 | + } |
|
| 883 | 1171 | $data['race_time'] = $sail['racetime']; |
| 884 | 1172 | if ($mission_user != '') { |
| 885 | 1173 | $data['race_name'] = $mission_name.' ('.$mission_user.')'; |
@@ -889,7 +1177,9 @@ discard block |
||
| 889 | 1177 | //$data['callsign'] = trim(substr($line,100,7); |
| 890 | 1178 | $data['format_source'] = 'sailawayfull'; |
| 891 | 1179 | $data['id_source'] = $id_source; |
| 892 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1180 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1181 | + $data['noarchive'] = true; |
|
| 1182 | + } |
|
| 893 | 1183 | //print_r($data); |
| 894 | 1184 | //if ($data['race_id'] == '48') print_r($data); |
| 895 | 1185 | //echo 'Add...'."\n"; |
@@ -927,7 +1217,9 @@ discard block |
||
| 927 | 1217 | echo 'Sailaway API key MUST be defined'; |
| 928 | 1218 | exit(0); |
| 929 | 1219 | } |
| 930 | - if ($globalDebug) echo '! Download... '; |
|
| 1220 | + if ($globalDebug) { |
|
| 1221 | + echo '! Download... '; |
|
| 1222 | + } |
|
| 931 | 1223 | $buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/TrackAllBoats.pl?key='.$globalSailaway['key']); |
| 932 | 1224 | if ($buffer != '') { |
| 933 | 1225 | $data = json_decode($buffer,true); |
@@ -946,7 +1238,9 @@ discard block |
||
| 946 | 1238 | $data['captain_name'] = $sail['usrname']; |
| 947 | 1239 | $data['format_source'] = 'sailaway'; |
| 948 | 1240 | $data['id_source'] = $id_source; |
| 949 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1241 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1242 | + $data['noarchive'] = true; |
|
| 1243 | + } |
|
| 950 | 1244 | $MI->add($data); |
| 951 | 1245 | unset($data); |
| 952 | 1246 | } |
@@ -979,16 +1273,28 @@ discard block |
||
| 979 | 1273 | $line = explode(':', $line); |
| 980 | 1274 | if (count($line) > 30 && $line[0] != 'callsign') { |
| 981 | 1275 | $data = array(); |
| 982 | - if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
|
| 983 | - else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
|
| 1276 | + if (isset($line[37]) && $line[37] != '') { |
|
| 1277 | + $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
|
| 1278 | + } else { |
|
| 1279 | + $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
|
| 1280 | + } |
|
| 984 | 1281 | $data['pilot_id'] = $line[1]; |
| 985 | 1282 | $data['pilot_name'] = $line[2]; |
| 986 | 1283 | $data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT); |
| 987 | 1284 | $data['ident'] = $line[0]; // ident |
| 988 | - if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude |
|
| 1285 | + if ($line[7] != '' && $line[7] != 0) { |
|
| 1286 | + $data['altitude'] = $line[7]; |
|
| 1287 | + } |
|
| 1288 | + // altitude |
|
| 989 | 1289 | $data['speed'] = $line[8]; // speed |
| 990 | - if (isset($line[45])) $data['heading'] = $line[45]; // heading |
|
| 991 | - elseif (isset($line[38])) $data['heading'] = $line[38]; // heading |
|
| 1290 | + if (isset($line[45])) { |
|
| 1291 | + $data['heading'] = $line[45]; |
|
| 1292 | + } |
|
| 1293 | + // heading |
|
| 1294 | + elseif (isset($line[38])) { |
|
| 1295 | + $data['heading'] = $line[38]; |
|
| 1296 | + } |
|
| 1297 | + // heading |
|
| 992 | 1298 | $data['latitude'] = $line[5]; // lat |
| 993 | 1299 | $data['longitude'] = $line[6]; // long |
| 994 | 1300 | $data['verticalrate'] = ''; // vertical rate |
@@ -1004,7 +1310,9 @@ discard block |
||
| 1004 | 1310 | $data['frequency'] = $line[4]; |
| 1005 | 1311 | $data['type'] = $line[18]; |
| 1006 | 1312 | $data['range'] = $line[19]; |
| 1007 | - if (isset($line[35])) $data['info'] = $line[35]; |
|
| 1313 | + if (isset($line[35])) { |
|
| 1314 | + $data['info'] = $line[35]; |
|
| 1315 | + } |
|
| 1008 | 1316 | $data['id_source'] = $id_source; |
| 1009 | 1317 | //$data['arrival_airport_time'] = ; |
| 1010 | 1318 | if ($line[9] != '') { |
@@ -1018,27 +1326,47 @@ discard block |
||
| 1018 | 1326 | elseif ($value === 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; |
| 1019 | 1327 | */ |
| 1020 | 1328 | $data['format_source'] = $value['format']; |
| 1021 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1022 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1023 | - if ($line[3] === 'PILOT') $SI->add($data); |
|
| 1024 | - elseif ($line[3] === 'ATC') { |
|
| 1329 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1330 | + $data['noarchive'] = true; |
|
| 1331 | + } |
|
| 1332 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1333 | + $data['source_name'] = $value['name']; |
|
| 1334 | + } |
|
| 1335 | + if ($line[3] === 'PILOT') { |
|
| 1336 | + $SI->add($data); |
|
| 1337 | + } elseif ($line[3] === 'ATC') { |
|
| 1025 | 1338 | //print_r($data); |
| 1026 | 1339 | $data['info'] = str_replace('^§','<br />',$data['info']); |
| 1027 | 1340 | $data['info'] = str_replace('&sect;','',$data['info']); |
| 1028 | 1341 | $typec = substr($data['ident'],-3); |
| 1029 | - if ($typec === 'APP') $data['type'] = 'Approach'; |
|
| 1030 | - elseif ($typec === 'TWR') $data['type'] = 'Tower'; |
|
| 1031 | - elseif ($typec === 'OBS') $data['type'] = 'Observer'; |
|
| 1032 | - elseif ($typec === 'GND') $data['type'] = 'Ground'; |
|
| 1033 | - elseif ($typec === 'DEL') $data['type'] = 'Delivery'; |
|
| 1034 | - elseif ($typec === 'DEP') $data['type'] = 'Departure'; |
|
| 1035 | - elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station'; |
|
| 1036 | - elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre'; |
|
| 1037 | - elseif ($data['type'] === '') $data['type'] = 'Observer'; |
|
| 1038 | - if (!isset($data['source_name'])) $data['source_name'] = ''; |
|
| 1342 | + if ($typec === 'APP') { |
|
| 1343 | + $data['type'] = 'Approach'; |
|
| 1344 | + } elseif ($typec === 'TWR') { |
|
| 1345 | + $data['type'] = 'Tower'; |
|
| 1346 | + } elseif ($typec === 'OBS') { |
|
| 1347 | + $data['type'] = 'Observer'; |
|
| 1348 | + } elseif ($typec === 'GND') { |
|
| 1349 | + $data['type'] = 'Ground'; |
|
| 1350 | + } elseif ($typec === 'DEL') { |
|
| 1351 | + $data['type'] = 'Delivery'; |
|
| 1352 | + } elseif ($typec === 'DEP') { |
|
| 1353 | + $data['type'] = 'Departure'; |
|
| 1354 | + } elseif ($typec === 'FSS') { |
|
| 1355 | + $data['type'] = 'Flight Service Station'; |
|
| 1356 | + } elseif ($typec === 'CTR') { |
|
| 1357 | + $data['type'] = 'Control Radar or Centre'; |
|
| 1358 | + } elseif ($data['type'] === '') { |
|
| 1359 | + $data['type'] = 'Observer'; |
|
| 1360 | + } |
|
| 1361 | + if (!isset($data['source_name'])) { |
|
| 1362 | + $data['source_name'] = ''; |
|
| 1363 | + } |
|
| 1039 | 1364 | if (isset($ATC)) { |
| 1040 | - 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']); |
|
| 1041 | - 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']); |
|
| 1365 | + if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) { |
|
| 1366 | + 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']); |
|
| 1367 | + } else { |
|
| 1368 | + 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']); |
|
| 1369 | + } |
|
| 1042 | 1370 | } |
| 1043 | 1371 | } |
| 1044 | 1372 | unset($data); |
@@ -1065,14 +1393,20 @@ discard block |
||
| 1065 | 1393 | $data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST')); |
| 1066 | 1394 | $data['latitude'] = (float)$line['pktLatitude']; |
| 1067 | 1395 | $data['longitude'] = (float)$line['pktLongitude']; |
| 1068 | - if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack']; |
|
| 1069 | - if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed']; |
|
| 1396 | + if ((float)$line['pktTrack'] != 0) { |
|
| 1397 | + $data['heading'] = (float)$line['pktTrack']; |
|
| 1398 | + } |
|
| 1399 | + if ((int)$line['pktSpeed'] != 0) { |
|
| 1400 | + $data['speed'] = (int)$line['pktSpeed']; |
|
| 1401 | + } |
|
| 1070 | 1402 | $data['altitude'] = round((int)$line['pktAltitude']*3.28084); |
| 1071 | 1403 | $data['altitude_relative'] = 'AMSL'; |
| 1072 | 1404 | $data['pilot_id'] = (int)$line['pktPilotID']; |
| 1073 | 1405 | $data['aircraft_icao'] = 'PARAGLIDER'; |
| 1074 | 1406 | $pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id'])); |
| 1075 | - if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4]; |
|
| 1407 | + if (isset($pilot_data[4])) { |
|
| 1408 | + $data['pilot_name'] = $pilot_data[4]; |
|
| 1409 | + } |
|
| 1076 | 1410 | $data['format_source'] = $value['format']; |
| 1077 | 1411 | $SI->add($data); |
| 1078 | 1412 | unset($data); |
@@ -1120,25 +1454,59 @@ discard block |
||
| 1120 | 1454 | foreach ($all_data['acList'] as $line) { |
| 1121 | 1455 | $data = array(); |
| 1122 | 1456 | $data['hex'] = $line['Icao']; // hex |
| 1123 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
| 1124 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
| 1125 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
| 1126 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
| 1127 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
| 1128 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
| 1457 | + if (isset($line['Call'])) { |
|
| 1458 | + $data['ident'] = $line['Call']; |
|
| 1459 | + } |
|
| 1460 | + // ident |
|
| 1461 | + if (isset($line['Alt'])) { |
|
| 1462 | + $data['altitude'] = $line['Alt']; |
|
| 1463 | + } |
|
| 1464 | + // altitude |
|
| 1465 | + if (isset($line['Spd'])) { |
|
| 1466 | + $data['speed'] = $line['Spd']; |
|
| 1467 | + } |
|
| 1468 | + // speed |
|
| 1469 | + if (isset($line['Trak'])) { |
|
| 1470 | + $data['heading'] = $line['Trak']; |
|
| 1471 | + } |
|
| 1472 | + // heading |
|
| 1473 | + if (isset($line['Lat'])) { |
|
| 1474 | + $data['latitude'] = $line['Lat']; |
|
| 1475 | + } |
|
| 1476 | + // lat |
|
| 1477 | + if (isset($line['Long'])) { |
|
| 1478 | + $data['longitude'] = $line['Long']; |
|
| 1479 | + } |
|
| 1480 | + // long |
|
| 1129 | 1481 | //$data['verticalrate'] = $line['']; // verticale rate |
| 1130 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
| 1482 | + if (isset($line['Sqk'])) { |
|
| 1483 | + $data['squawk'] = $line['Sqk']; |
|
| 1484 | + } |
|
| 1485 | + // squawk |
|
| 1131 | 1486 | $data['emergency'] = ''; // emergency |
| 1132 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
| 1133 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
| 1134 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1487 | + if (isset($line['Reg'])) { |
|
| 1488 | + $data['registration'] = $line['Reg']; |
|
| 1489 | + } |
|
| 1490 | + if (isset($line['PosTime'])) { |
|
| 1491 | + $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
| 1492 | + } else { |
|
| 1493 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1494 | + } |
|
| 1135 | 1495 | //$data['datetime'] = date('Y-m-d H:i:s'); |
| 1136 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
| 1496 | + if (isset($line['Type'])) { |
|
| 1497 | + $data['aircraft_icao'] = $line['Type']; |
|
| 1498 | + } |
|
| 1137 | 1499 | $data['format_source'] = 'aircraftlistjson'; |
| 1138 | 1500 | $data['id_source'] = $id_source; |
| 1139 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1140 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1141 | - if (isset($data['latitude'])) $SI->add($data); |
|
| 1501 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1502 | + $data['source_name'] = $value['name']; |
|
| 1503 | + } |
|
| 1504 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1505 | + $data['noarchive'] = true; |
|
| 1506 | + } |
|
| 1507 | + if (isset($data['latitude'])) { |
|
| 1508 | + $SI->add($data); |
|
| 1509 | + } |
|
| 1142 | 1510 | unset($data); |
| 1143 | 1511 | } |
| 1144 | 1512 | } elseif (is_array($all_data)) { |
@@ -1155,17 +1523,26 @@ discard block |
||
| 1155 | 1523 | $data['verticalrate'] = $line['vrt']; // verticale rate |
| 1156 | 1524 | $data['squawk'] = $line['squawk']; // squawk |
| 1157 | 1525 | $data['emergency'] = ''; // emergency |
| 1158 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
| 1159 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1526 | + if (isset($line['PosTime'])) { |
|
| 1527 | + $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
| 1528 | + } else { |
|
| 1529 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1530 | + } |
|
| 1160 | 1531 | $data['format_source'] = 'aircraftlistjson'; |
| 1161 | 1532 | $data['id_source'] = $id_source; |
| 1162 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1163 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1533 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1534 | + $data['noarchive'] = true; |
|
| 1535 | + } |
|
| 1536 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1537 | + $data['source_name'] = $value['name']; |
|
| 1538 | + } |
|
| 1164 | 1539 | $SI->add($data); |
| 1165 | 1540 | unset($data); |
| 1166 | 1541 | } |
| 1167 | 1542 | } |
| 1168 | - } elseif ($globalDebug) echo 'No data'."\n"; |
|
| 1543 | + } elseif ($globalDebug) { |
|
| 1544 | + echo 'No data'."\n"; |
|
| 1545 | + } |
|
| 1169 | 1546 | //$last_exec['aircraftlistjson'] = time(); |
| 1170 | 1547 | $last_exec[$id]['last'] = time(); |
| 1171 | 1548 | //} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
@@ -1201,8 +1578,12 @@ discard block |
||
| 1201 | 1578 | $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
| 1202 | 1579 | $data['format_source'] = 'planeupdatefaa'; |
| 1203 | 1580 | $data['id_source'] = $id_source; |
| 1204 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1205 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1581 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1582 | + $data['noarchive'] = true; |
|
| 1583 | + } |
|
| 1584 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1585 | + $data['source_name'] = $value['name']; |
|
| 1586 | + } |
|
| 1206 | 1587 | $SI->add($data); |
| 1207 | 1588 | unset($data); |
| 1208 | 1589 | } |
@@ -1236,7 +1617,9 @@ discard block |
||
| 1236 | 1617 | $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
| 1237 | 1618 | $data['format_source'] = 'opensky'; |
| 1238 | 1619 | $data['id_source'] = $id_source; |
| 1239 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1620 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1621 | + $data['noarchive'] = true; |
|
| 1622 | + } |
|
| 1240 | 1623 | $SI->add($data); |
| 1241 | 1624 | unset($data); |
| 1242 | 1625 | } |
@@ -1256,15 +1639,42 @@ discard block |
||
| 1256 | 1639 | foreach ($all_data['aircraft'] as $key => $line) { |
| 1257 | 1640 | $data = array(); |
| 1258 | 1641 | // add support for ground vehicule with ~ in front of hex |
| 1259 | - if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex |
|
| 1260 | - if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident |
|
| 1261 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude |
|
| 1262 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed |
|
| 1263 | - if (isset($line['track'])) $data['heading'] = $line['track']; // heading |
|
| 1264 | - if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat |
|
| 1265 | - if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long |
|
| 1266 | - if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate |
|
| 1267 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk |
|
| 1642 | + if (isset($line['hex'])) { |
|
| 1643 | + $data['hex'] = $line['hex']; |
|
| 1644 | + } |
|
| 1645 | + // hex |
|
| 1646 | + if (isset($line['flight'])) { |
|
| 1647 | + $data['ident'] = trim($line['flight']); |
|
| 1648 | + } |
|
| 1649 | + // ident |
|
| 1650 | + if (isset($line['altitude'])) { |
|
| 1651 | + $data['altitude'] = $line['altitude']; |
|
| 1652 | + } |
|
| 1653 | + // altitude |
|
| 1654 | + if (isset($line['speed'])) { |
|
| 1655 | + $data['speed'] = $line['speed']; |
|
| 1656 | + } |
|
| 1657 | + // speed |
|
| 1658 | + if (isset($line['track'])) { |
|
| 1659 | + $data['heading'] = $line['track']; |
|
| 1660 | + } |
|
| 1661 | + // heading |
|
| 1662 | + if (isset($line['lat'])) { |
|
| 1663 | + $data['latitude'] = $line['lat']; |
|
| 1664 | + } |
|
| 1665 | + // lat |
|
| 1666 | + if (isset($line['lon'])) { |
|
| 1667 | + $data['longitude'] = $line['lon']; |
|
| 1668 | + } |
|
| 1669 | + // long |
|
| 1670 | + if (isset($line['vert_rate'])) { |
|
| 1671 | + $data['verticalrate'] = $line['vert_rate']; |
|
| 1672 | + } |
|
| 1673 | + // verticale rate |
|
| 1674 | + if (isset($line['squawk'])) { |
|
| 1675 | + $data['squawk'] = $line['squawk']; |
|
| 1676 | + } |
|
| 1677 | + // squawk |
|
| 1268 | 1678 | //$data['emergency'] = ''; // emergency |
| 1269 | 1679 | //$data['registration'] = $line[2]; |
| 1270 | 1680 | //$data['aircraft_icao'] = $line[0]; |
@@ -1272,10 +1682,17 @@ discard block |
||
| 1272 | 1682 | $data['format_source'] = 'aircraftjson'; |
| 1273 | 1683 | $data['id_source'] = $id_source; |
| 1274 | 1684 | if (isset($value['name']) && $value['name'] != '') { |
| 1275 | - if (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = $value['name'].'_MLAT'; |
|
| 1276 | - else $data['source_name'] = $value['name']; |
|
| 1277 | - } elseif (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = 'MLAT'; |
|
| 1278 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1685 | + if (isset($line['mlat']) && !empty($line['mlat'])) { |
|
| 1686 | + $data['source_name'] = $value['name'].'_MLAT'; |
|
| 1687 | + } else { |
|
| 1688 | + $data['source_name'] = $value['name']; |
|
| 1689 | + } |
|
| 1690 | + } elseif (isset($line['mlat']) && !empty($line['mlat'])) { |
|
| 1691 | + $data['source_name'] = 'MLAT'; |
|
| 1692 | + } |
|
| 1693 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1694 | + $data['noarchive'] = true; |
|
| 1695 | + } |
|
| 1279 | 1696 | $SI->add($data); |
| 1280 | 1697 | unset($data); |
| 1281 | 1698 | } |
@@ -1295,22 +1712,54 @@ discard block |
||
| 1295 | 1712 | foreach ($all_data['aircraft'] as $key => $line) { |
| 1296 | 1713 | $data = array(); |
| 1297 | 1714 | $data['hex'] = $key; // hex |
| 1298 | - if (isset($line['callsign'])) $data['ident'] = trim($line['callsign']); // ident |
|
| 1299 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude |
|
| 1300 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed |
|
| 1301 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
| 1302 | - if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat |
|
| 1303 | - if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long |
|
| 1304 | - if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate |
|
| 1305 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk |
|
| 1715 | + if (isset($line['callsign'])) { |
|
| 1716 | + $data['ident'] = trim($line['callsign']); |
|
| 1717 | + } |
|
| 1718 | + // ident |
|
| 1719 | + if (isset($line['altitude'])) { |
|
| 1720 | + $data['altitude'] = $line['altitude']; |
|
| 1721 | + } |
|
| 1722 | + // altitude |
|
| 1723 | + if (isset($line['speed'])) { |
|
| 1724 | + $data['speed'] = $line['speed']; |
|
| 1725 | + } |
|
| 1726 | + // speed |
|
| 1727 | + if (isset($line['heading'])) { |
|
| 1728 | + $data['heading'] = $line['heading']; |
|
| 1729 | + } |
|
| 1730 | + // heading |
|
| 1731 | + if (isset($line['lat'])) { |
|
| 1732 | + $data['latitude'] = $line['lat']; |
|
| 1733 | + } |
|
| 1734 | + // lat |
|
| 1735 | + if (isset($line['lon'])) { |
|
| 1736 | + $data['longitude'] = $line['lon']; |
|
| 1737 | + } |
|
| 1738 | + // long |
|
| 1739 | + if (isset($line['vert_rate'])) { |
|
| 1740 | + $data['verticalrate'] = $line['vert_rate']; |
|
| 1741 | + } |
|
| 1742 | + // verticale rate |
|
| 1743 | + if (isset($line['squawk'])) { |
|
| 1744 | + $data['squawk'] = $line['squawk']; |
|
| 1745 | + } |
|
| 1746 | + // squawk |
|
| 1306 | 1747 | //$data['emergency'] = ''; // emergency |
| 1307 | - if (isset($line['reg'])) $data['registration'] = $line['reg']; |
|
| 1308 | - if (isset($line['type'])) $data['aircraft_icao'] = $line['type']; |
|
| 1748 | + if (isset($line['reg'])) { |
|
| 1749 | + $data['registration'] = $line['reg']; |
|
| 1750 | + } |
|
| 1751 | + if (isset($line['type'])) { |
|
| 1752 | + $data['aircraft_icao'] = $line['type']; |
|
| 1753 | + } |
|
| 1309 | 1754 | $data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']); |
| 1310 | 1755 | $data['format_source'] = 'planefinderclient'; |
| 1311 | 1756 | $data['id_source'] = $id_source; |
| 1312 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1313 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1757 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1758 | + $data['source_name'] = $value['name']; |
|
| 1759 | + } |
|
| 1760 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1761 | + $data['noarchive'] = true; |
|
| 1762 | + } |
|
| 1314 | 1763 | $SI->add($data); |
| 1315 | 1764 | unset($data); |
| 1316 | 1765 | } |
@@ -1326,7 +1775,9 @@ discard block |
||
| 1326 | 1775 | //$buffer = $Common->getData($hosts[$id]); |
| 1327 | 1776 | $buffer = $Common->getData($value['host']); |
| 1328 | 1777 | $all_data = json_decode($buffer,true); |
| 1329 | - if (!empty($all_data)) $reset = 0; |
|
| 1778 | + if (!empty($all_data)) { |
|
| 1779 | + $reset = 0; |
|
| 1780 | + } |
|
| 1330 | 1781 | foreach ($all_data as $key => $line) { |
| 1331 | 1782 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
| 1332 | 1783 | $data = array(); |
@@ -1347,8 +1798,12 @@ discard block |
||
| 1347 | 1798 | $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
| 1348 | 1799 | $data['format_source'] = 'fr24json'; |
| 1349 | 1800 | $data['id_source'] = $id_source; |
| 1350 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1351 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1801 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1802 | + $data['noarchive'] = true; |
|
| 1803 | + } |
|
| 1804 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1805 | + $data['source_name'] = $value['name']; |
|
| 1806 | + } |
|
| 1352 | 1807 | $SI->add($data); |
| 1353 | 1808 | unset($data); |
| 1354 | 1809 | } |
@@ -1377,24 +1832,42 @@ discard block |
||
| 1377 | 1832 | if (isset($line['inf'])) { |
| 1378 | 1833 | $data = array(); |
| 1379 | 1834 | $data['hex'] = $line['inf']['ia']; |
| 1380 | - if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] |
|
| 1835 | + if (isset($line['inf']['cs'])) { |
|
| 1836 | + $data['ident'] = $line['inf']['cs']; |
|
| 1837 | + } |
|
| 1838 | + //$line[13] |
|
| 1381 | 1839 | $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
| 1382 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
| 1383 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
| 1840 | + if (isset($line['inf']['gs'])) { |
|
| 1841 | + $data['speed'] = round($line['inf']['gs']*0.539957); |
|
| 1842 | + } |
|
| 1843 | + // speed |
|
| 1844 | + if (isset($line['inf']['tr'])) { |
|
| 1845 | + $data['heading'] = $line['inf']['tr']; |
|
| 1846 | + } |
|
| 1847 | + // heading |
|
| 1384 | 1848 | $data['latitude'] = $line['pt'][0]; // lat |
| 1385 | 1849 | $data['longitude'] = $line['pt'][1]; // long |
| 1386 | 1850 | //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
| 1387 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
| 1851 | + if (isset($line['inf']['sq'])) { |
|
| 1852 | + $data['squawk'] = $line['inf']['sq']; |
|
| 1853 | + } |
|
| 1854 | + // squawk |
|
| 1388 | 1855 | //$data['aircraft_icao'] = $line[8]; |
| 1389 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
| 1856 | + if (isset($line['inf']['rc'])) { |
|
| 1857 | + $data['registration'] = $line['inf']['rc']; |
|
| 1858 | + } |
|
| 1390 | 1859 | //$data['departure_airport_iata'] = $line[11]; |
| 1391 | 1860 | //$data['arrival_airport_iata'] = $line[12]; |
| 1392 | 1861 | //$data['emergency'] = ''; // emergency |
| 1393 | 1862 | $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
| 1394 | 1863 | $data['format_source'] = 'radarvirtueljson'; |
| 1395 | 1864 | $data['id_source'] = $id_source; |
| 1396 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1397 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1865 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1866 | + $data['noarchive'] = true; |
|
| 1867 | + } |
|
| 1868 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1869 | + $data['source_name'] = $value['name']; |
|
| 1870 | + } |
|
| 1398 | 1871 | $SI->add($data); |
| 1399 | 1872 | unset($data); |
| 1400 | 1873 | } |
@@ -1420,30 +1893,65 @@ discard block |
||
| 1420 | 1893 | $data['id'] = $line['id']; |
| 1421 | 1894 | $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
| 1422 | 1895 | $data['ident'] = $line['callsign']; // ident |
| 1423 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
| 1424 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
| 1425 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
| 1426 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
| 1427 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
| 1428 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1896 | + if (isset($line['pilotid'])) { |
|
| 1897 | + $data['pilot_id'] = $line['pilotid']; |
|
| 1898 | + } |
|
| 1899 | + // pilot id |
|
| 1900 | + if (isset($line['name'])) { |
|
| 1901 | + $data['pilot_name'] = $line['name']; |
|
| 1902 | + } |
|
| 1903 | + // pilot name |
|
| 1904 | + if (isset($line['alt'])) { |
|
| 1905 | + $data['altitude'] = $line['alt']; |
|
| 1906 | + } |
|
| 1907 | + // altitude |
|
| 1908 | + if (isset($line['gs'])) { |
|
| 1909 | + $data['speed'] = $line['gs']; |
|
| 1910 | + } |
|
| 1911 | + // speed |
|
| 1912 | + if (isset($line['heading'])) { |
|
| 1913 | + $data['heading'] = $line['heading']; |
|
| 1914 | + } |
|
| 1915 | + // heading |
|
| 1916 | + if (isset($line['route'])) { |
|
| 1917 | + $data['waypoints'] = $line['route']; |
|
| 1918 | + } |
|
| 1919 | + // route |
|
| 1429 | 1920 | $data['latitude'] = $line['lat']; // lat |
| 1430 | 1921 | $data['longitude'] = $line['lon']; // long |
| 1431 | 1922 | //$data['verticalrate'] = $line['vrt']; // verticale rate |
| 1432 | 1923 | //$data['squawk'] = $line['squawk']; // squawk |
| 1433 | 1924 | //$data['emergency'] = ''; // emergency |
| 1434 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
| 1435 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
| 1436 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
| 1925 | + if (isset($line['depicao'])) { |
|
| 1926 | + $data['departure_airport_icao'] = $line['depicao']; |
|
| 1927 | + } |
|
| 1928 | + if (isset($line['deptime'])) { |
|
| 1929 | + $data['departure_airport_time'] = $line['deptime']; |
|
| 1930 | + } |
|
| 1931 | + if (isset($line['arricao'])) { |
|
| 1932 | + $data['arrival_airport_icao'] = $line['arricao']; |
|
| 1933 | + } |
|
| 1437 | 1934 | //$data['arrival_airport_time'] = $line['arrtime']; |
| 1438 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
| 1439 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
| 1440 | - if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
| 1441 | - else $data['info'] = ''; |
|
| 1935 | + if (isset($line['aircraft'])) { |
|
| 1936 | + $data['aircraft_icao'] = $line['aircraft']; |
|
| 1937 | + } |
|
| 1938 | + if (isset($line['transponder'])) { |
|
| 1939 | + $data['squawk'] = $line['transponder']; |
|
| 1940 | + } |
|
| 1941 | + if (isset($line['atis'])) { |
|
| 1942 | + $data['info'] = $line['atis']; |
|
| 1943 | + } else { |
|
| 1944 | + $data['info'] = ''; |
|
| 1945 | + } |
|
| 1442 | 1946 | $data['format_source'] = 'pireps'; |
| 1443 | 1947 | $data['id_source'] = $id_source; |
| 1444 | 1948 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1445 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1446 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1949 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1950 | + $data['noarchive'] = true; |
|
| 1951 | + } |
|
| 1952 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1953 | + $data['source_name'] = $value['name']; |
|
| 1954 | + } |
|
| 1447 | 1955 | if ($line['icon'] === 'plane') { |
| 1448 | 1956 | $SI->add($data); |
| 1449 | 1957 | // print_r($data); |
@@ -1452,16 +1960,28 @@ discard block |
||
| 1452 | 1960 | $data['info'] = str_replace('&sect;','',$data['info']); |
| 1453 | 1961 | $typec = substr($data['ident'],-3); |
| 1454 | 1962 | $data['type'] = ''; |
| 1455 | - if ($typec === 'APP') $data['type'] = 'Approach'; |
|
| 1456 | - elseif ($typec === 'TWR') $data['type'] = 'Tower'; |
|
| 1457 | - elseif ($typec === 'OBS') $data['type'] = 'Observer'; |
|
| 1458 | - elseif ($typec === 'GND') $data['type'] = 'Ground'; |
|
| 1459 | - elseif ($typec === 'DEL') $data['type'] = 'Delivery'; |
|
| 1460 | - elseif ($typec === 'DEP') $data['type'] = 'Departure'; |
|
| 1461 | - elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station'; |
|
| 1462 | - elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre'; |
|
| 1463 | - else $data['type'] = 'Observer'; |
|
| 1464 | - 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']); |
|
| 1963 | + if ($typec === 'APP') { |
|
| 1964 | + $data['type'] = 'Approach'; |
|
| 1965 | + } elseif ($typec === 'TWR') { |
|
| 1966 | + $data['type'] = 'Tower'; |
|
| 1967 | + } elseif ($typec === 'OBS') { |
|
| 1968 | + $data['type'] = 'Observer'; |
|
| 1969 | + } elseif ($typec === 'GND') { |
|
| 1970 | + $data['type'] = 'Ground'; |
|
| 1971 | + } elseif ($typec === 'DEL') { |
|
| 1972 | + $data['type'] = 'Delivery'; |
|
| 1973 | + } elseif ($typec === 'DEP') { |
|
| 1974 | + $data['type'] = 'Departure'; |
|
| 1975 | + } elseif ($typec === 'FSS') { |
|
| 1976 | + $data['type'] = 'Flight Service Station'; |
|
| 1977 | + } elseif ($typec === 'CTR') { |
|
| 1978 | + $data['type'] = 'Control Radar or Centre'; |
|
| 1979 | + } else { |
|
| 1980 | + $data['type'] = 'Observer'; |
|
| 1981 | + } |
|
| 1982 | + if (isset($ATC)) { |
|
| 1983 | + 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']); |
|
| 1984 | + } |
|
| 1465 | 1985 | } |
| 1466 | 1986 | unset($data); |
| 1467 | 1987 | } |
@@ -1476,7 +1996,9 @@ discard block |
||
| 1476 | 1996 | ) |
| 1477 | 1997 | ) { |
| 1478 | 1998 | //$buffer = $Common->getData($hosts[$id]); |
| 1479 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 1999 | + if ($globalDebug) { |
|
| 2000 | + echo 'Get Data...'."\n"; |
|
| 2001 | + } |
|
| 1480 | 2002 | $buffer = $Common->getData($value['host']); |
| 1481 | 2003 | $all_data = json_decode($buffer,true); |
| 1482 | 2004 | if ($buffer != '' && is_array($all_data)) { |
@@ -1484,10 +2006,16 @@ discard block |
||
| 1484 | 2006 | foreach ($all_data as $line) { |
| 1485 | 2007 | $data = array(); |
| 1486 | 2008 | //$data['id'] = $line['id']; // id not usable |
| 1487 | - if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
| 2009 | + if (isset($line['pilotid'])) { |
|
| 2010 | + $data['id'] = $line['pilotid'].$line['flightnum']; |
|
| 2011 | + } |
|
| 1488 | 2012 | $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
| 1489 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
| 1490 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
| 2013 | + if (isset($line['pilotname'])) { |
|
| 2014 | + $data['pilot_name'] = $line['pilotname']; |
|
| 2015 | + } |
|
| 2016 | + if (isset($line['pilotid'])) { |
|
| 2017 | + $data['pilot_id'] = $line['pilotid']; |
|
| 2018 | + } |
|
| 1491 | 2019 | $data['ident'] = $line['flightnum']; // ident |
| 1492 | 2020 | $data['altitude'] = $line['alt']; // altitude |
| 1493 | 2021 | $data['speed'] = $line['gs']; // speed |
@@ -1503,7 +2031,9 @@ discard block |
||
| 1503 | 2031 | $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
| 1504 | 2032 | $datetime->setTimeZone(new DateTimeZone('UTC')); |
| 1505 | 2033 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
| 1506 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 2034 | + } else { |
|
| 2035 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 2036 | + } |
|
| 1507 | 2037 | $data['departure_airport_icao'] = $line['depicao']; |
| 1508 | 2038 | $data['departure_airport_time'] = $line['deptime']; |
| 1509 | 2039 | $data['arrival_airport_icao'] = $line['arricao']; |
@@ -1511,29 +2041,47 @@ discard block |
||
| 1511 | 2041 | if (isset($line['registration'])) { |
| 1512 | 2042 | $data['registration'] = $line['registration']; |
| 1513 | 2043 | //if (isset($line['aircraft'])) $data['id'] = $line['aircraft']; |
| 1514 | - } else $data['registration'] = $line['aircraft']; |
|
| 1515 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1516 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 2044 | + } else { |
|
| 2045 | + $data['registration'] = $line['aircraft']; |
|
| 2046 | + } |
|
| 2047 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 2048 | + $data['noarchive'] = true; |
|
| 2049 | + } |
|
| 2050 | + if (isset($line['route'])) { |
|
| 2051 | + $data['waypoints'] = $line['route']; |
|
| 2052 | + } |
|
| 2053 | + // route |
|
| 1517 | 2054 | if (isset($line['aircraftname'])) { |
| 1518 | 2055 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
| 1519 | 2056 | $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
| 1520 | 2057 | $aircraft_data = explode('-',$line['aircraftname']); |
| 1521 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
| 1522 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 1523 | - else { |
|
| 2058 | + if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) { |
|
| 2059 | + $data['aircraft_icao'] = $aircraft_data[0]; |
|
| 2060 | + } elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) { |
|
| 2061 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 2062 | + } else { |
|
| 1524 | 2063 | $aircraft_data = explode(' ',$line['aircraftname']); |
| 1525 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
| 1526 | - else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
| 2064 | + if (isset($aircraft_data[1])) { |
|
| 2065 | + $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
| 2066 | + } else { |
|
| 2067 | + $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
| 2068 | + } |
|
| 1527 | 2069 | } |
| 1528 | 2070 | } |
| 1529 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
| 2071 | + if (isset($line['route'])) { |
|
| 2072 | + $data['waypoints'] = $line['route']; |
|
| 2073 | + } |
|
| 1530 | 2074 | $data['id_source'] = $id_source; |
| 1531 | 2075 | $data['format_source'] = 'phpvmacars'; |
| 1532 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 2076 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 2077 | + $data['source_name'] = $value['name']; |
|
| 2078 | + } |
|
| 1533 | 2079 | $SI->add($data); |
| 1534 | 2080 | unset($data); |
| 1535 | 2081 | } |
| 1536 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
| 2082 | + if ($globalDebug) { |
|
| 2083 | + echo 'No more data...'."\n"; |
|
| 2084 | + } |
|
| 1537 | 2085 | unset($buffer); |
| 1538 | 2086 | unset($all_data); |
| 1539 | 2087 | } |
@@ -1546,7 +2094,9 @@ discard block |
||
| 1546 | 2094 | ) |
| 1547 | 2095 | ) { |
| 1548 | 2096 | //$buffer = $Common->getData($hosts[$id]); |
| 1549 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 2097 | + if ($globalDebug) { |
|
| 2098 | + echo 'Get Data...'."\n"; |
|
| 2099 | + } |
|
| 1550 | 2100 | $buffer = $Common->getData($value['host']); |
| 1551 | 2101 | $all_data = json_decode($buffer,true); |
| 1552 | 2102 | if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) { |
@@ -1557,10 +2107,16 @@ discard block |
||
| 1557 | 2107 | //$data['id'] = $line['id']; // id not usable |
| 1558 | 2108 | $data['id'] = $line['id']; |
| 1559 | 2109 | //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
| 1560 | - if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username']; |
|
| 1561 | - if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id']; |
|
| 2110 | + if (isset($line['user']['username'])) { |
|
| 2111 | + $data['pilot_name'] = $line['user']['username']; |
|
| 2112 | + } |
|
| 2113 | + if (isset($line['user_id'])) { |
|
| 2114 | + $data['pilot_id'] = $line['user_id']; |
|
| 2115 | + } |
|
| 1562 | 2116 | $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident |
| 1563 | - if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident']; |
|
| 2117 | + if (is_numeric($data['ident'])) { |
|
| 2118 | + $data['ident'] = $line['bid']['airline']['icao'].$data['ident']; |
|
| 2119 | + } |
|
| 1564 | 2120 | $data['altitude'] = $line['altitude']; // altitude |
| 1565 | 2121 | $data['speed'] = $line['groundspeed']; // speed |
| 1566 | 2122 | $data['heading'] = $line['heading']; // heading |
@@ -1573,7 +2129,9 @@ discard block |
||
| 1573 | 2129 | $datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone'])); |
| 1574 | 2130 | $datetime->setTimeZone(new DateTimeZone('UTC')); |
| 1575 | 2131 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
| 1576 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 2132 | + } else { |
|
| 2133 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 2134 | + } |
|
| 1577 | 2135 | |
| 1578 | 2136 | $data['departure_airport_icao'] = $line['bid']['depapt']['icao']; |
| 1579 | 2137 | $data['departure_airport_time'] = $line['bid']['deptime']; |
@@ -1581,17 +2139,26 @@ discard block |
||
| 1581 | 2139 | $data['arrival_airport_time'] = $line['bid']['arrtime']; |
| 1582 | 2140 | $data['registration'] = $line['bid']['aircraft']['registration']; |
| 1583 | 2141 | |
| 1584 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1585 | - if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route |
|
| 2142 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 2143 | + $data['noarchive'] = true; |
|
| 2144 | + } |
|
| 2145 | + if (isset($line['bid']['route']) && $line['bid']['route'] != '') { |
|
| 2146 | + $data['waypoints'] = $line['bid']['route']; |
|
| 2147 | + } |
|
| 2148 | + // route |
|
| 1586 | 2149 | $data['aircraft_icao'] = $line['bid']['aircraft']['icao']; |
| 1587 | 2150 | |
| 1588 | 2151 | $data['id_source'] = $id_source; |
| 1589 | 2152 | $data['format_source'] = 'vaos'; |
| 1590 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 2153 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 2154 | + $data['source_name'] = $value['name']; |
|
| 2155 | + } |
|
| 1591 | 2156 | $SI->add($data); |
| 1592 | 2157 | unset($data); |
| 1593 | 2158 | } |
| 1594 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
| 2159 | + if ($globalDebug) { |
|
| 2160 | + echo 'No more data...'."\n"; |
|
| 2161 | + } |
|
| 1595 | 2162 | unset($buffer); |
| 1596 | 2163 | unset($all_data); |
| 1597 | 2164 | } |
@@ -1604,7 +2171,9 @@ discard block |
||
| 1604 | 2171 | ) |
| 1605 | 2172 | ) { |
| 1606 | 2173 | //$buffer = $Common->getData($hosts[$id]); |
| 1607 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 2174 | + if ($globalDebug) { |
|
| 2175 | + echo 'Get Data...'."\n"; |
|
| 2176 | + } |
|
| 1608 | 2177 | $buffer = $Common->getData($value['host']); |
| 1609 | 2178 | $all_data = json_decode($buffer,true); |
| 1610 | 2179 | if ($buffer != '' && is_array($all_data)) { |
@@ -1633,16 +2202,25 @@ discard block |
||
| 1633 | 2202 | $data['arrival_airport_icao'] = $line['arrival']; |
| 1634 | 2203 | //$data['arrival_airport_time'] = $line['arrival_time']; |
| 1635 | 2204 | //$data['registration'] = $line['aircraft']; |
| 1636 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 2205 | + if (isset($line['route'])) { |
|
| 2206 | + $data['waypoints'] = $line['route']; |
|
| 2207 | + } |
|
| 2208 | + // route |
|
| 1637 | 2209 | $data['aircraft_icao'] = $line['plane_type']; |
| 1638 | 2210 | $data['id_source'] = $id_source; |
| 1639 | 2211 | $data['format_source'] = 'vam'; |
| 1640 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1641 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 2212 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 2213 | + $data['noarchive'] = true; |
|
| 2214 | + } |
|
| 2215 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 2216 | + $data['source_name'] = $value['name']; |
|
| 2217 | + } |
|
| 1642 | 2218 | $SI->add($data); |
| 1643 | 2219 | unset($data); |
| 1644 | 2220 | } |
| 1645 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
| 2221 | + if ($globalDebug) { |
|
| 2222 | + echo 'No more data...'."\n"; |
|
| 2223 | + } |
|
| 1646 | 2224 | unset($buffer); |
| 1647 | 2225 | unset($all_data); |
| 1648 | 2226 | } |
@@ -1655,7 +2233,9 @@ discard block |
||
| 1655 | 2233 | ) |
| 1656 | 2234 | ) { |
| 1657 | 2235 | //$buffer = $Common->getData($hosts[$id]); |
| 1658 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 2236 | + if ($globalDebug) { |
|
| 2237 | + echo 'Get Data...'."\n"; |
|
| 2238 | + } |
|
| 1659 | 2239 | $buffer = $Common->getData($value['host']); |
| 1660 | 2240 | $all_data = json_decode($buffer,true); |
| 1661 | 2241 | if ($buffer != '') { |
@@ -1673,12 +2253,16 @@ discard block |
||
| 1673 | 2253 | $data['id_source'] = $id_source; |
| 1674 | 2254 | $data['format_source'] = 'blitzortung'; |
| 1675 | 2255 | $SI->add($data); |
| 1676 | - if ($globalDebug) echo '☈ Lightning added'."\n"; |
|
| 2256 | + if ($globalDebug) { |
|
| 2257 | + echo '☈ Lightning added'."\n"; |
|
| 2258 | + } |
|
| 1677 | 2259 | $Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']); |
| 1678 | 2260 | unset($data); |
| 1679 | 2261 | } |
| 1680 | 2262 | } |
| 1681 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
| 2263 | + if ($globalDebug) { |
|
| 2264 | + echo 'No more data...'."\n"; |
|
| 2265 | + } |
|
| 1682 | 2266 | unset($buffer); |
| 1683 | 2267 | } |
| 1684 | 2268 | $last_exec[$id]['last'] = time(); |
@@ -1707,10 +2291,15 @@ discard block |
||
| 1707 | 2291 | } |
| 1708 | 2292 | } else { |
| 1709 | 2293 | $format = $value['format']; |
| 1710 | - if (isset($tt[$format])) $tt[$format]++; |
|
| 1711 | - else $tt[$format] = 0; |
|
| 2294 | + if (isset($tt[$format])) { |
|
| 2295 | + $tt[$format]++; |
|
| 2296 | + } else { |
|
| 2297 | + $tt[$format] = 0; |
|
| 2298 | + } |
|
| 1712 | 2299 | if ($tt[$format] > 30) { |
| 1713 | - if ($globalDebug) echo 'Reconnect...'."\n"; |
|
| 2300 | + if ($globalDebug) { |
|
| 2301 | + echo 'Reconnect...'."\n"; |
|
| 2302 | + } |
|
| 1714 | 2303 | sleep(2); |
| 1715 | 2304 | //$sourceeen[] = $value; |
| 1716 | 2305 | //connect_all($sourceeen); |
@@ -1727,7 +2316,9 @@ discard block |
||
| 1727 | 2316 | $write = NULL; |
| 1728 | 2317 | $e = NULL; |
| 1729 | 2318 | $n = socket_select($read, $write, $e, $timeout); |
| 1730 | - if ($e != NULL) var_dump($e); |
|
| 2319 | + if ($e != NULL) { |
|
| 2320 | + var_dump($e); |
|
| 2321 | + } |
|
| 1731 | 2322 | if ($n > 0) { |
| 1732 | 2323 | $reset = 0; |
| 1733 | 2324 | foreach ($read as $nb => $r) { |
@@ -1749,13 +2340,17 @@ discard block |
||
| 1749 | 2340 | if ($buffer !== FALSE) { |
| 1750 | 2341 | if ($format === 'vrstcp') { |
| 1751 | 2342 | $buffer = explode('},{',$buffer); |
| 1752 | - } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
| 2343 | + } else { |
|
| 2344 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
| 2345 | + } |
|
| 1753 | 2346 | } |
| 1754 | 2347 | // SBS format is CSV format |
| 1755 | 2348 | if ($buffer !== FALSE && $buffer !== '') { |
| 1756 | 2349 | $tt[$format] = 0; |
| 1757 | 2350 | if ($format === 'acarssbs3') { |
| 1758 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 2351 | + if ($globalDebug) { |
|
| 2352 | + echo 'ACARS : '.$buffer."\n"; |
|
| 2353 | + } |
|
| 1759 | 2354 | $ACARS->add(trim($buffer)); |
| 1760 | 2355 | $ACARS->deleteLiveAcarsData(); |
| 1761 | 2356 | } elseif ($format === 'raw') { |
@@ -1765,9 +2360,15 @@ discard block |
||
| 1765 | 2360 | //if (!empty($data)) print_r($data); |
| 1766 | 2361 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1767 | 2362 | $data['format_source'] = 'raw'; |
| 1768 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1769 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1770 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 2363 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
| 2364 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
| 2365 | + } |
|
| 2366 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
| 2367 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 2368 | + } |
|
| 2369 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 2370 | + $data['noarchive'] = true; |
|
| 2371 | + } |
|
| 1771 | 2372 | //if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
| 1772 | 2373 | $SI->add($data); |
| 1773 | 2374 | unset($data); |
@@ -1775,22 +2376,54 @@ discard block |
||
| 1775 | 2376 | } elseif ($format === 'ais') { |
| 1776 | 2377 | $ais_data = $AIS->parse_line(trim($buffer)); |
| 1777 | 2378 | $data = array(); |
| 1778 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 1779 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
| 1780 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 1781 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 1782 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 1783 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 1784 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 1785 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
| 1786 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 1787 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 1788 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 1789 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
| 1790 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 1791 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1792 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1793 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 2379 | + if (isset($ais_data['ident'])) { |
|
| 2380 | + $data['ident'] = $ais_data['ident']; |
|
| 2381 | + } |
|
| 2382 | + if (isset($ais_data['mmsi'])) { |
|
| 2383 | + $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
| 2384 | + } |
|
| 2385 | + if (isset($ais_data['speed'])) { |
|
| 2386 | + $data['speed'] = $ais_data['speed']; |
|
| 2387 | + } |
|
| 2388 | + if (isset($ais_data['heading'])) { |
|
| 2389 | + $data['heading'] = $ais_data['heading']; |
|
| 2390 | + } |
|
| 2391 | + if (isset($ais_data['latitude'])) { |
|
| 2392 | + $data['latitude'] = $ais_data['latitude']; |
|
| 2393 | + } |
|
| 2394 | + if (isset($ais_data['longitude'])) { |
|
| 2395 | + $data['longitude'] = $ais_data['longitude']; |
|
| 2396 | + } |
|
| 2397 | + if (isset($ais_data['status'])) { |
|
| 2398 | + $data['status'] = $ais_data['status']; |
|
| 2399 | + } |
|
| 2400 | + if (isset($ais_data['statusid'])) { |
|
| 2401 | + $data['status_id'] = $ais_data['statusid']; |
|
| 2402 | + } |
|
| 2403 | + if (isset($ais_data['type'])) { |
|
| 2404 | + $data['type'] = $ais_data['type']; |
|
| 2405 | + } |
|
| 2406 | + if (isset($ais_data['imo'])) { |
|
| 2407 | + $data['imo'] = $ais_data['imo']; |
|
| 2408 | + } |
|
| 2409 | + if (isset($ais_data['callsign'])) { |
|
| 2410 | + $data['callsign'] = $ais_data['callsign']; |
|
| 2411 | + } |
|
| 2412 | + if (isset($ais_data['destination'])) { |
|
| 2413 | + $data['arrival_code'] = $ais_data['destination']; |
|
| 2414 | + } |
|
| 2415 | + if (isset($ais_data['eta_ts'])) { |
|
| 2416 | + $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 2417 | + } |
|
| 2418 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 2419 | + $data['noarchive'] = true; |
|
| 2420 | + } |
|
| 2421 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
| 2422 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
| 2423 | + } |
|
| 2424 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
| 2425 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 2426 | + } |
|
| 1794 | 2427 | |
| 1795 | 2428 | if (isset($ais_data['timestamp'])) { |
| 1796 | 2429 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
@@ -1799,7 +2432,9 @@ discard block |
||
| 1799 | 2432 | } |
| 1800 | 2433 | $data['format_source'] = 'aisnmea'; |
| 1801 | 2434 | $data['id_source'] = $id_source; |
| 1802 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
| 2435 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') { |
|
| 2436 | + $MI->add($data); |
|
| 2437 | + } |
|
| 1803 | 2438 | unset($data); |
| 1804 | 2439 | } elseif ($format === 'flightgearsp') { |
| 1805 | 2440 | //echo $buffer."\n"; |
@@ -1817,17 +2452,25 @@ discard block |
||
| 1817 | 2452 | $data['speed'] = round($line[5]*1.94384); |
| 1818 | 2453 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1819 | 2454 | $data['format_source'] = 'flightgearsp'; |
| 1820 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1821 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 2455 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 2456 | + $data['noarchive'] = true; |
|
| 2457 | + } |
|
| 2458 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 2459 | + $SI->add($data); |
|
| 2460 | + } |
|
| 1822 | 2461 | //$send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
| 1823 | 2462 | } |
| 1824 | 2463 | } elseif ($format === 'acars') { |
| 1825 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 2464 | + if ($globalDebug) { |
|
| 2465 | + echo 'ACARS : '.$buffer."\n"; |
|
| 2466 | + } |
|
| 1826 | 2467 | $ACARS->add(trim($buffer)); |
| 1827 | 2468 | socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
| 1828 | 2469 | $ACARS->deleteLiveAcarsData(); |
| 1829 | 2470 | } elseif ($format === 'acarsjsonudp') { |
| 1830 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 2471 | + if ($globalDebug) { |
|
| 2472 | + echo 'ACARS : '.$buffer."\n"; |
|
| 2473 | + } |
|
| 1831 | 2474 | $line = json_decode(trim($buffer), true); |
| 1832 | 2475 | if (!empty($line)) { |
| 1833 | 2476 | $line = array_merge(array('text' => '','tail' => '','label' => '','block_id' => '','flight' => '','msgno' => ''),$line); |
@@ -1852,8 +2495,12 @@ discard block |
||
| 1852 | 2495 | $aircraft_type = $line[10]; |
| 1853 | 2496 | $aircraft_type = preg_split(':/:',$aircraft_type); |
| 1854 | 2497 | $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
| 1855 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1856 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 2498 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 2499 | + $data['noarchive'] = true; |
|
| 2500 | + } |
|
| 2501 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 2502 | + $SI->add($data); |
|
| 2503 | + } |
|
| 1857 | 2504 | } |
| 1858 | 2505 | } |
| 1859 | 2506 | } elseif ($format === 'beast') { |
@@ -1863,28 +2510,62 @@ discard block |
||
| 1863 | 2510 | foreach($buffer as $all_data) { |
| 1864 | 2511 | $line = json_decode('{'.$all_data.'}',true); |
| 1865 | 2512 | $data = array(); |
| 1866 | - if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
|
| 1867 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
| 1868 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
| 1869 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
| 1870 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
| 1871 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
| 1872 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
| 2513 | + if (isset($line['Icao'])) { |
|
| 2514 | + $data['hex'] = $line['Icao']; |
|
| 2515 | + } |
|
| 2516 | + // hex |
|
| 2517 | + if (isset($line['Call'])) { |
|
| 2518 | + $data['ident'] = $line['Call']; |
|
| 2519 | + } |
|
| 2520 | + // ident |
|
| 2521 | + if (isset($line['Alt'])) { |
|
| 2522 | + $data['altitude'] = $line['Alt']; |
|
| 2523 | + } |
|
| 2524 | + // altitude |
|
| 2525 | + if (isset($line['Spd'])) { |
|
| 2526 | + $data['speed'] = $line['Spd']; |
|
| 2527 | + } |
|
| 2528 | + // speed |
|
| 2529 | + if (isset($line['Trak'])) { |
|
| 2530 | + $data['heading'] = $line['Trak']; |
|
| 2531 | + } |
|
| 2532 | + // heading |
|
| 2533 | + if (isset($line['Lat'])) { |
|
| 2534 | + $data['latitude'] = $line['Lat']; |
|
| 2535 | + } |
|
| 2536 | + // lat |
|
| 2537 | + if (isset($line['Long'])) { |
|
| 2538 | + $data['longitude'] = $line['Long']; |
|
| 2539 | + } |
|
| 2540 | + // long |
|
| 1873 | 2541 | //$data['verticalrate'] = $line['']; // verticale rate |
| 1874 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
| 2542 | + if (isset($line['Sqk'])) { |
|
| 2543 | + $data['squawk'] = $line['Sqk']; |
|
| 2544 | + } |
|
| 2545 | + // squawk |
|
| 1875 | 2546 | $data['emergency'] = ''; // emergency |
| 1876 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
| 2547 | + if (isset($line['Reg'])) { |
|
| 2548 | + $data['registration'] = $line['Reg']; |
|
| 2549 | + } |
|
| 1877 | 2550 | /* |
| 1878 | 2551 | if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000); |
| 1879 | 2552 | else $data['datetime'] = date('Y-m-d H:i:s'); |
| 1880 | 2553 | */ |
| 1881 | 2554 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1882 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
| 2555 | + if (isset($line['Type'])) { |
|
| 2556 | + $data['aircraft_icao'] = $line['Type']; |
|
| 2557 | + } |
|
| 1883 | 2558 | $data['format_source'] = 'vrstcp'; |
| 1884 | 2559 | $data['id_source'] = $id_source; |
| 1885 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1886 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1887 | - if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
|
| 2560 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 2561 | + $data['noarchive'] = true; |
|
| 2562 | + } |
|
| 2563 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 2564 | + $data['source_name'] = $value['name']; |
|
| 2565 | + } |
|
| 2566 | + if (isset($data['latitude']) && isset($data['hex'])) { |
|
| 2567 | + $SI->add($data); |
|
| 2568 | + } |
|
| 1888 | 2569 | unset($data); |
| 1889 | 2570 | } |
| 1890 | 2571 | } elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') { |
@@ -1897,22 +2578,46 @@ discard block |
||
| 1897 | 2578 | $data['hex'] = $lined['hexid']; |
| 1898 | 2579 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
| 1899 | 2580 | $data['datetime'] = date('Y-m-d H:i:s');; |
| 1900 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
| 1901 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
| 1902 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
| 1903 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
| 1904 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
| 1905 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
| 1906 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
| 2581 | + if (isset($lined['ident'])) { |
|
| 2582 | + $data['ident'] = $lined['ident']; |
|
| 2583 | + } |
|
| 2584 | + if (isset($lined['lat'])) { |
|
| 2585 | + $data['latitude'] = $lined['lat']; |
|
| 2586 | + } |
|
| 2587 | + if (isset($lined['lon'])) { |
|
| 2588 | + $data['longitude'] = $lined['lon']; |
|
| 2589 | + } |
|
| 2590 | + if (isset($lined['speed'])) { |
|
| 2591 | + $data['speed'] = $lined['speed']; |
|
| 2592 | + } |
|
| 2593 | + if (isset($lined['squawk'])) { |
|
| 2594 | + $data['squawk'] = $lined['squawk']; |
|
| 2595 | + } |
|
| 2596 | + if (isset($lined['alt'])) { |
|
| 2597 | + $data['altitude'] = $lined['alt']; |
|
| 2598 | + } |
|
| 2599 | + if (isset($lined['heading'])) { |
|
| 2600 | + $data['heading'] = $lined['heading']; |
|
| 2601 | + } |
|
| 1907 | 2602 | $data['id_source'] = $id_source; |
| 1908 | 2603 | $data['format_source'] = 'tsv'; |
| 1909 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1910 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1911 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1912 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 2604 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
| 2605 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
| 2606 | + } |
|
| 2607 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
| 2608 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 2609 | + } |
|
| 2610 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 2611 | + $data['noarchive'] = true; |
|
| 2612 | + } |
|
| 2613 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 2614 | + $SI->add($data); |
|
| 2615 | + } |
|
| 1913 | 2616 | unset($lined); |
| 1914 | 2617 | unset($data); |
| 1915 | - } else $error = true; |
|
| 2618 | + } else { |
|
| 2619 | + $error = true; |
|
| 2620 | + } |
|
| 1916 | 2621 | } elseif ($format === 'aprs' && $use_aprs) { |
| 1917 | 2622 | if ($aprs_connect === 0) { |
| 1918 | 2623 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
@@ -1938,47 +2643,96 @@ discard block |
||
| 1938 | 2643 | $aprs_last_tx = time(); |
| 1939 | 2644 | $data = array(); |
| 1940 | 2645 | //print_r($line); |
| 1941 | - if (isset($line['address'])) $data['hex'] = $line['address']; |
|
| 1942 | - if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
| 1943 | - if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
| 1944 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
| 1945 | - if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code']; |
|
| 1946 | - if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date']; |
|
| 1947 | - if (isset($line['typeid'])) $data['type_id'] = $line['typeid']; |
|
| 1948 | - if (isset($line['statusid'])) $data['status_id'] = $line['statusid']; |
|
| 1949 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
| 1950 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 2646 | + if (isset($line['address'])) { |
|
| 2647 | + $data['hex'] = $line['address']; |
|
| 2648 | + } |
|
| 2649 | + if (isset($line['mmsi'])) { |
|
| 2650 | + $data['mmsi'] = $line['mmsi']; |
|
| 2651 | + } |
|
| 2652 | + if (isset($line['imo'])) { |
|
| 2653 | + $data['imo'] = $line['imo']; |
|
| 2654 | + } |
|
| 2655 | + if (isset($line['squawk'])) { |
|
| 2656 | + $data['squawk'] = $line['squawk']; |
|
| 2657 | + } |
|
| 2658 | + if (isset($line['arrival_code'])) { |
|
| 2659 | + $data['arrival_code'] = $line['arrival_code']; |
|
| 2660 | + } |
|
| 2661 | + if (isset($line['arrival_date'])) { |
|
| 2662 | + $data['arrival_date'] = $line['arrival_date']; |
|
| 2663 | + } |
|
| 2664 | + if (isset($line['typeid'])) { |
|
| 2665 | + $data['type_id'] = $line['typeid']; |
|
| 2666 | + } |
|
| 2667 | + if (isset($line['statusid'])) { |
|
| 2668 | + $data['status_id'] = $line['statusid']; |
|
| 2669 | + } |
|
| 2670 | + if (isset($line['timestamp'])) { |
|
| 2671 | + $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
| 2672 | + } else { |
|
| 2673 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 2674 | + } |
|
| 1951 | 2675 | //$data['datetime'] = date('Y-m-d H:i:s'); |
| 1952 | - if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
| 2676 | + if (isset($line['ident'])) { |
|
| 2677 | + $data['ident'] = $line['ident']; |
|
| 2678 | + } |
|
| 1953 | 2679 | $data['latitude'] = $line['latitude']; |
| 1954 | 2680 | $data['longitude'] = $line['longitude']; |
| 1955 | 2681 | //$data['verticalrate'] = $line[16]; |
| 1956 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
| 2682 | + if (isset($line['speed'])) { |
|
| 2683 | + $data['speed'] = $line['speed']; |
|
| 2684 | + } |
|
| 1957 | 2685 | //else $data['speed'] = 0; |
| 1958 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
| 1959 | - if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
| 1960 | - if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
| 2686 | + if (isset($line['altitude'])) { |
|
| 2687 | + $data['altitude'] = $line['altitude']; |
|
| 2688 | + } |
|
| 2689 | + if (isset($line['comment'])) { |
|
| 2690 | + $data['comment'] = $line['comment']; |
|
| 2691 | + } |
|
| 2692 | + if (isset($line['symbol'])) { |
|
| 2693 | + $data['type'] = $line['symbol']; |
|
| 2694 | + } |
|
| 1961 | 2695 | //if (isset($line['heading'])) $data['heading'] = $line['heading']; |
| 1962 | 2696 | |
| 1963 | - if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading']; |
|
| 2697 | + if (isset($line['heading']) && isset($line['format_source'])) { |
|
| 2698 | + $data['heading'] = $line['heading']; |
|
| 2699 | + } |
|
| 1964 | 2700 | //else echo 'No heading...'."\n"; |
| 1965 | 2701 | //else $data['heading'] = 0; |
| 1966 | - if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
| 2702 | + if (isset($line['stealth'])) { |
|
| 2703 | + $data['aircraft_type'] = $line['stealth']; |
|
| 2704 | + } |
|
| 1967 | 2705 | //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
| 1968 | - if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true; |
|
| 1969 | - elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false; |
|
| 1970 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1971 | - elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
| 2706 | + if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) { |
|
| 2707 | + $data['noarchive'] = true; |
|
| 2708 | + } elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) { |
|
| 2709 | + $data['noarchive'] = false; |
|
| 2710 | + } |
|
| 2711 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 2712 | + $data['noarchive'] = true; |
|
| 2713 | + } elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) { |
|
| 2714 | + $data['noarchive'] = false; |
|
| 2715 | + } |
|
| 1972 | 2716 | $data['id_source'] = $id_source; |
| 1973 | - if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
| 1974 | - else $data['format_source'] = 'aprs'; |
|
| 2717 | + if (isset($line['format_source'])) { |
|
| 2718 | + $data['format_source'] = $line['format_source']; |
|
| 2719 | + } else { |
|
| 2720 | + $data['format_source'] = 'aprs'; |
|
| 2721 | + } |
|
| 1975 | 2722 | $data['source_name'] = $line['source']; |
| 1976 | - if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
| 1977 | - else $data['source_type'] = 'flarm'; |
|
| 1978 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 2723 | + if (isset($line['source_type'])) { |
|
| 2724 | + $data['source_type'] = $line['source_type']; |
|
| 2725 | + } else { |
|
| 2726 | + $data['source_type'] = 'flarm'; |
|
| 2727 | + } |
|
| 2728 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
| 2729 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 2730 | + } |
|
| 1979 | 2731 | $currentdate = date('Y-m-d H:i:s'); |
| 1980 | 2732 | $aprsdate = strtotime($data['datetime']); |
| 1981 | - if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL'; |
|
| 2733 | + if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') { |
|
| 2734 | + $data['altitude_relative'] = 'AMSL'; |
|
| 2735 | + } |
|
| 1982 | 2736 | // Accept data if time <= system time + 20s |
| 1983 | 2737 | //if (($data['source_type'] === 'modes') || isset($line['stealth']) && ($line['stealth'] === 0 || $line['stealth'] === '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
| 1984 | 2738 | if ( |
@@ -1990,7 +2744,9 @@ discard block |
||
| 1990 | 2744 | $send = $SI->add($data); |
| 1991 | 2745 | } elseif ($data['source_type'] === 'ais') { |
| 1992 | 2746 | $data['type'] = ''; |
| 1993 | - if (isset($globalMarine) && $globalMarine) $send = $MI->add($data); |
|
| 2747 | + if (isset($globalMarine) && $globalMarine) { |
|
| 2748 | + $send = $MI->add($data); |
|
| 2749 | + } |
|
| 1994 | 2750 | } elseif (isset($line['stealth']) && $line['stealth'] != 0) { |
| 1995 | 2751 | echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
| 1996 | 2752 | } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
@@ -1998,8 +2754,12 @@ discard block |
||
| 1998 | 2754 | $line['symbol'] === 'Glider' || |
| 1999 | 2755 | $line['symbol'] === 'No. Plane' || |
| 2000 | 2756 | $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) { |
| 2001 | - if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL'; |
|
| 2002 | - if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER'; |
|
| 2757 | + if ($line['symbol'] === 'Ballon') { |
|
| 2758 | + $data['aircraft_icao'] = 'BALL'; |
|
| 2759 | + } |
|
| 2760 | + if ($line['symbol'] === 'Glider') { |
|
| 2761 | + $data['aircraft_icao'] = 'PARAGLIDER'; |
|
| 2762 | + } |
|
| 2003 | 2763 | $send = $SI->add($data); |
| 2004 | 2764 | } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
| 2005 | 2765 | $line['symbol'] === 'Yacht (Sail)' || |
@@ -2030,9 +2790,13 @@ discard block |
||
| 2030 | 2790 | //} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && isset($line['speed']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') { |
| 2031 | 2791 | // } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') { |
| 2032 | 2792 | //echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n"; |
| 2033 | - if (isset($globalTracker) && $globalTracker) $send = $TI->add($data); |
|
| 2793 | + if (isset($globalTracker) && $globalTracker) { |
|
| 2794 | + $send = $TI->add($data); |
|
| 2795 | + } |
|
| 2034 | 2796 | } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
| 2035 | - if (!isset($data['altitude'])) $data['altitude'] = 0; |
|
| 2797 | + if (!isset($data['altitude'])) { |
|
| 2798 | + $data['altitude'] = 0; |
|
| 2799 | + } |
|
| 2036 | 2800 | $Source->deleteOldLocationByType('gs'); |
| 2037 | 2801 | if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) { |
| 2038 | 2802 | $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
@@ -2041,7 +2805,9 @@ discard block |
||
| 2041 | 2805 | } |
| 2042 | 2806 | } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') { |
| 2043 | 2807 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
| 2044 | - if ($globalDebug) echo '# Weather Station added'."\n"; |
|
| 2808 | + if ($globalDebug) { |
|
| 2809 | + echo '# Weather Station added'."\n"; |
|
| 2810 | + } |
|
| 2045 | 2811 | $Source->deleteOldLocationByType('wx'); |
| 2046 | 2812 | $weather_data = json_encode($line); |
| 2047 | 2813 | if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) { |
@@ -2051,7 +2817,9 @@ discard block |
||
| 2051 | 2817 | } |
| 2052 | 2818 | } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) { |
| 2053 | 2819 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
| 2054 | - if ($globalDebug) echo '☈ Lightning added'."\n"; |
|
| 2820 | + if ($globalDebug) { |
|
| 2821 | + echo '☈ Lightning added'."\n"; |
|
| 2822 | + } |
|
| 2055 | 2823 | $Source->deleteOldLocationByType('lightning'); |
| 2056 | 2824 | if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) { |
| 2057 | 2825 | $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']); |
@@ -2063,8 +2831,7 @@ discard block |
||
| 2063 | 2831 | print_r($line); |
| 2064 | 2832 | } |
| 2065 | 2833 | unset($data); |
| 2066 | - } |
|
| 2067 | - elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
|
| 2834 | + } elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
|
| 2068 | 2835 | $Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']); |
| 2069 | 2836 | } |
| 2070 | 2837 | /* |
@@ -2073,7 +2840,9 @@ discard block |
||
| 2073 | 2840 | } |
| 2074 | 2841 | */ |
| 2075 | 2842 | //elseif ($line === false && $globalDebug) echo 'Ignored ('.$buffer.")\n"; |
| 2076 | - elseif ($line === true && $globalDebug) echo '!! Failed : '.$buffer."!!\n"; |
|
| 2843 | + elseif ($line === true && $globalDebug) { |
|
| 2844 | + echo '!! Failed : '.$buffer."!!\n"; |
|
| 2845 | + } |
|
| 2077 | 2846 | if (isset($Source) && isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) { |
| 2078 | 2847 | $Source->deleteOldLocationByType('lightning'); |
| 2079 | 2848 | $Source->deleteOldLocationByType('wx'); |
@@ -2110,27 +2879,47 @@ discard block |
||
| 2110 | 2879 | $data['ground'] = $line[21]; |
| 2111 | 2880 | $data['emergency'] = $line[19]; |
| 2112 | 2881 | $data['format_source'] = 'sbs'; |
| 2113 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 2114 | - elseif ($line[0] == 'MLAT') $data['source_name'] = 'MLAT'; |
|
| 2115 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 2116 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 2882 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
| 2883 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
| 2884 | + } elseif ($line[0] == 'MLAT') { |
|
| 2885 | + $data['source_name'] = 'MLAT'; |
|
| 2886 | + } |
|
| 2887 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
| 2888 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 2889 | + } |
|
| 2890 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 2891 | + $data['noarchive'] = true; |
|
| 2892 | + } |
|
| 2117 | 2893 | $data['id_source'] = $id_source; |
| 2118 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
| 2119 | - else $error = true; |
|
| 2894 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 2895 | + $send = $SI->add($data); |
|
| 2896 | + } else { |
|
| 2897 | + $error = true; |
|
| 2898 | + } |
|
| 2120 | 2899 | unset($data); |
| 2121 | - } else $error = true; |
|
| 2900 | + } else { |
|
| 2901 | + $error = true; |
|
| 2902 | + } |
|
| 2122 | 2903 | if ($error) { |
| 2123 | 2904 | if (count($line) > 1 && ($line[0] === 'STA' || $line[0] === 'AIR' || $line[0] === 'SEL' || $line[0] === 'ID' || $line[0] === 'CLK')) { |
| 2124 | - if ($globalDebug) echo "Not a message. Ignoring... \n"; |
|
| 2905 | + if ($globalDebug) { |
|
| 2906 | + echo "Not a message. Ignoring... \n"; |
|
| 2907 | + } |
|
| 2125 | 2908 | } else { |
| 2126 | - if ($globalDebug) echo "Wrong line format. Ignoring... \n"; |
|
| 2909 | + if ($globalDebug) { |
|
| 2910 | + echo "Wrong line format. Ignoring... \n"; |
|
| 2911 | + } |
|
| 2127 | 2912 | if ($globalDebug) { |
| 2128 | 2913 | echo $buffer; |
| 2129 | 2914 | //print_r($line); |
| 2130 | 2915 | } |
| 2131 | 2916 | //socket_close($r); |
| 2132 | - if ($globalDebug) echo "Reconnect after an error...\n"; |
|
| 2133 | - if ($format === 'aprs') $aprs_connect = 0; |
|
| 2917 | + if ($globalDebug) { |
|
| 2918 | + echo "Reconnect after an error...\n"; |
|
| 2919 | + } |
|
| 2920 | + if ($format === 'aprs') { |
|
| 2921 | + $aprs_connect = 0; |
|
| 2922 | + } |
|
| 2134 | 2923 | $sourceer[$nb] = $globalSources[$nb]; |
| 2135 | 2924 | connect_all($sourceer); |
| 2136 | 2925 | $sourceer = array(); |
@@ -2138,10 +2927,14 @@ discard block |
||
| 2138 | 2927 | } |
| 2139 | 2928 | } |
| 2140 | 2929 | // Sleep for xxx microseconds |
| 2141 | - if (isset($globalSBSSleep)) usleep($globalSBSSleep); |
|
| 2930 | + if (isset($globalSBSSleep)) { |
|
| 2931 | + usleep($globalSBSSleep); |
|
| 2932 | + } |
|
| 2142 | 2933 | } else { |
| 2143 | 2934 | if ($format === 'flightgearmp') { |
| 2144 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
| 2935 | + if ($globalDebug) { |
|
| 2936 | + echo "Reconnect FlightGear MP..."; |
|
| 2937 | + } |
|
| 2145 | 2938 | //@socket_close($r); |
| 2146 | 2939 | sleep($globalMinFetch); |
| 2147 | 2940 | $sourcefg[$nb] = $globalSources[$nb]; |
@@ -2150,10 +2943,15 @@ discard block |
||
| 2150 | 2943 | break; |
| 2151 | 2944 | |
| 2152 | 2945 | } elseif ($format != 'acars' && $format != 'flightgearsp') { |
| 2153 | - if (isset($tt[$format])) $tt[$format]++; |
|
| 2154 | - else $tt[$format] = 0; |
|
| 2946 | + if (isset($tt[$format])) { |
|
| 2947 | + $tt[$format]++; |
|
| 2948 | + } else { |
|
| 2949 | + $tt[$format] = 0; |
|
| 2950 | + } |
|
| 2155 | 2951 | if ($tt[$format] > 30 || $buffer === FALSE) { |
| 2156 | - if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; |
|
| 2952 | + if ($globalDebug) { |
|
| 2953 | + echo "ERROR : Reconnect ".$format."..."; |
|
| 2954 | + } |
|
| 2157 | 2955 | //@socket_close($r); |
| 2158 | 2956 | sleep(2); |
| 2159 | 2957 | $aprs_connect = 0; |
@@ -2171,11 +2969,17 @@ discard block |
||
| 2171 | 2969 | } else { |
| 2172 | 2970 | $error = socket_strerror(socket_last_error()); |
| 2173 | 2971 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
| 2174 | - if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
|
| 2175 | - if (isset($globalDebug)) echo "Restarting...\n"; |
|
| 2972 | + if ($globalDebug) { |
|
| 2973 | + echo "ERROR : socket_select give this error ".$error . "\n"; |
|
| 2974 | + } |
|
| 2975 | + if (isset($globalDebug)) { |
|
| 2976 | + echo "Restarting...\n"; |
|
| 2977 | + } |
|
| 2176 | 2978 | // Restart the script if possible |
| 2177 | 2979 | if (is_array($sockets)) { |
| 2178 | - if ($globalDebug) echo "Shutdown all sockets..."; |
|
| 2980 | + if ($globalDebug) { |
|
| 2981 | + echo "Shutdown all sockets..."; |
|
| 2982 | + } |
|
| 2179 | 2983 | |
| 2180 | 2984 | foreach ($sockets as $sock) { |
| 2181 | 2985 | @socket_shutdown($sock,2); |
@@ -2183,25 +2987,45 @@ discard block |
||
| 2183 | 2987 | } |
| 2184 | 2988 | |
| 2185 | 2989 | } |
| 2186 | - if ($globalDebug) echo "Waiting..."; |
|
| 2990 | + if ($globalDebug) { |
|
| 2991 | + echo "Waiting..."; |
|
| 2992 | + } |
|
| 2187 | 2993 | sleep(2); |
| 2188 | 2994 | $time = time(); |
| 2189 | 2995 | //connect_all($hosts); |
| 2190 | 2996 | $aprs_connect = 0; |
| 2191 | - if ($reset%5 === 0) sleep(20); |
|
| 2192 | - if ($reset%10 === 0) sleep(100); |
|
| 2193 | - if ($reset%20 === 0) sleep(200); |
|
| 2194 | - if ($reset > 100) exit('Too many attempts...'); |
|
| 2195 | - if ($globalDebug) echo "Restart all connections..."; |
|
| 2997 | + if ($reset%5 === 0) { |
|
| 2998 | + sleep(20); |
|
| 2999 | + } |
|
| 3000 | + if ($reset%10 === 0) { |
|
| 3001 | + sleep(100); |
|
| 3002 | + } |
|
| 3003 | + if ($reset%20 === 0) { |
|
| 3004 | + sleep(200); |
|
| 3005 | + } |
|
| 3006 | + if ($reset > 100) { |
|
| 3007 | + exit('Too many attempts...'); |
|
| 3008 | + } |
|
| 3009 | + if ($globalDebug) { |
|
| 3010 | + echo "Restart all connections..."; |
|
| 3011 | + } |
|
| 2196 | 3012 | connect_all($globalSources); |
| 2197 | 3013 | } |
| 2198 | 3014 | } |
| 2199 | 3015 | } |
| 2200 | 3016 | if ($globalDaemon === false) { |
| 2201 | - if ($globalDebug) echo 'Check all...'."\n"; |
|
| 2202 | - if (isset($SI)) $SI->checkAll(); |
|
| 2203 | - if (isset($TI)) $TI->checkAll(); |
|
| 2204 | - if (isset($MI)) $MI->checkAll(); |
|
| 3017 | + if ($globalDebug) { |
|
| 3018 | + echo 'Check all...'."\n"; |
|
| 3019 | + } |
|
| 3020 | + if (isset($SI)) { |
|
| 3021 | + $SI->checkAll(); |
|
| 3022 | + } |
|
| 3023 | + if (isset($TI)) { |
|
| 3024 | + $TI->checkAll(); |
|
| 3025 | + } |
|
| 3026 | + if (isset($MI)) { |
|
| 3027 | + $MI->checkAll(); |
|
| 3028 | + } |
|
| 2205 | 3029 | } |
| 2206 | 3030 | } |
| 2207 | 3031 | } |
@@ -4,12 +4,22 @@ discard block |
||
| 4 | 4 | if (isset($_SESSION['error'])) { |
| 5 | 5 | header('Content-Encoding: none;'); |
| 6 | 6 | echo 'Error : '.$_SESSION['error'].' - Resetting install... You need to fix the problem and run install again.'; |
| 7 | - if (isset($_SESSION['error'])) unset($_SESSION['error']); |
|
| 8 | - if (isset($_SESSION['errorlst'])) unset($_SESSION['errorlst']); |
|
| 9 | - if (isset($_SESSION['next'])) unset($_SESSION['next']); |
|
| 10 | - if (isset($_SESSION['install'])) unset($_SESSION['install']); |
|
| 11 | - if (isset($_SESSION['identitied'])) unset($_SESSION['identified']); |
|
| 12 | -} |
|
| 7 | + if (isset($_SESSION['error'])) { |
|
| 8 | + unset($_SESSION['error']); |
|
| 9 | + } |
|
| 10 | + if (isset($_SESSION['errorlst'])) { |
|
| 11 | + unset($_SESSION['errorlst']); |
|
| 12 | + } |
|
| 13 | + if (isset($_SESSION['next'])) { |
|
| 14 | + unset($_SESSION['next']); |
|
| 15 | + } |
|
| 16 | + if (isset($_SESSION['install'])) { |
|
| 17 | + unset($_SESSION['install']); |
|
| 18 | + } |
|
| 19 | + if (isset($_SESSION['identitied'])) { |
|
| 20 | + unset($_SESSION['identified']); |
|
| 21 | + } |
|
| 22 | + } |
|
| 13 | 23 | /* |
| 14 | 24 | if (isset($_SESSION['errorlst'])) { |
| 15 | 25 | header('Content-Encoding: none;'); |
@@ -131,7 +141,9 @@ discard block |
||
| 131 | 141 | if (count($alllng) != count($availablelng)) { |
| 132 | 142 | $notavailable = array(); |
| 133 | 143 | foreach($alllng as $lng) { |
| 134 | - if (!isset($availablelng[$lng])) $notavailable[] = $lng; |
|
| 144 | + if (!isset($availablelng[$lng])) { |
|
| 145 | + $notavailable[] = $lng; |
|
| 146 | + } |
|
| 135 | 147 | } |
| 136 | 148 | print '<div class="alert alert-warning">The following translation can\'t be used on your system: '.implode(', ',$notavailable).'. You need to add the system locales: <a href="https://github.com/Ysurac/FlightAirMap/wiki/Translation">documentation</a>.</div>'; |
| 137 | 149 | } |
@@ -170,7 +182,10 @@ discard block |
||
| 170 | 182 | <legend>Install script configuration</legend> |
| 171 | 183 | <p> |
| 172 | 184 | <label for="installpass">Install password</label> |
| 173 | - <input type="password" name="installpass" id="installpass" value="<?php if (isset($globalInstallPassword)) print $globalInstallPassword; ?>" /> |
|
| 185 | + <input type="password" name="installpass" id="installpass" value="<?php if (isset($globalInstallPassword)) { |
|
| 186 | + print $globalInstallPassword; |
|
| 187 | +} |
|
| 188 | +?>" /> |
|
| 174 | 189 | </p> |
| 175 | 190 | <p class="help-block">Password needed to access this install script. If empty, to access this script, you will need to change the $globalInstalled setting in require/settings.php to FALSE</p> |
| 176 | 191 | </fieldset> |
@@ -200,31 +215,49 @@ discard block |
||
| 200 | 215 | </div> |
| 201 | 216 | <p> |
| 202 | 217 | <label for="dbhost">Database hostname</label> |
| 203 | - <input type="text" name="dbhost" id="dbhost" value="<?php if (isset($globalDBhost)) print $globalDBhost; ?>" /> |
|
| 218 | + <input type="text" name="dbhost" id="dbhost" value="<?php if (isset($globalDBhost)) { |
|
| 219 | + print $globalDBhost; |
|
| 220 | +} |
|
| 221 | +?>" /> |
|
| 204 | 222 | </p> |
| 205 | 223 | <p> |
| 206 | 224 | <label for="dbport">Database port</label> |
| 207 | - <input type="text" name="dbport" id="dbport" value="<?php if (isset($globalDBport)) print $globalDBport; ?>" /> |
|
| 225 | + <input type="text" name="dbport" id="dbport" value="<?php if (isset($globalDBport)) { |
|
| 226 | + print $globalDBport; |
|
| 227 | +} |
|
| 228 | +?>" /> |
|
| 208 | 229 | <p class="help-block">Default is 3306 for MariaDB/MySQL, 5432 for PostgreSQL</p> |
| 209 | 230 | </p> |
| 210 | 231 | <p> |
| 211 | 232 | <label for="dbname">Database name</label> |
| 212 | - <input type="text" name="dbname" id="dbname" value="<?php if (isset($globalDBname)) print $globalDBname; ?>" /> |
|
| 233 | + <input type="text" name="dbname" id="dbname" value="<?php if (isset($globalDBname)) { |
|
| 234 | + print $globalDBname; |
|
| 235 | +} |
|
| 236 | +?>" /> |
|
| 213 | 237 | </p> |
| 214 | 238 | <p> |
| 215 | 239 | <label for="dbuser">Database user</label> |
| 216 | - <input type="text" name="dbuser" id="dbuser" value="<?php if (isset($globalDBuser)) print $globalDBuser; ?>" /> |
|
| 240 | + <input type="text" name="dbuser" id="dbuser" value="<?php if (isset($globalDBuser)) { |
|
| 241 | + print $globalDBuser; |
|
| 242 | +} |
|
| 243 | +?>" /> |
|
| 217 | 244 | </p> |
| 218 | 245 | <p> |
| 219 | 246 | <label for="dbuserpass">Database user password</label> |
| 220 | - <input type="password" name="dbuserpass" id="dbuserpass" value="<?php if (isset($globalDBpass)) print $globalDBpass; ?>" /> |
|
| 247 | + <input type="password" name="dbuserpass" id="dbuserpass" value="<?php if (isset($globalDBpass)) { |
|
| 248 | + print $globalDBpass; |
|
| 249 | +} |
|
| 250 | +?>" /> |
|
| 221 | 251 | </p> |
| 222 | 252 | </fieldset> |
| 223 | 253 | <fieldset id="site"> |
| 224 | 254 | <legend>Site configuration</legend> |
| 225 | 255 | <p> |
| 226 | 256 | <label for="sitename">Site name</label> |
| 227 | - <input type="text" name="sitename" id="sitename" value="<?php if (isset($globalName)) print $globalName; ?>" /> |
|
| 257 | + <input type="text" name="sitename" id="sitename" value="<?php if (isset($globalName)) { |
|
| 258 | + print $globalName; |
|
| 259 | +} |
|
| 260 | +?>" /> |
|
| 228 | 261 | </p> |
| 229 | 262 | <p> |
| 230 | 263 | <label for="siteurl">Site directory</label> |
@@ -237,18 +270,27 @@ discard block |
||
| 237 | 270 | } |
| 238 | 271 | } |
| 239 | 272 | ?> |
| 240 | - <input type="text" name="siteurl" id="siteurl" value="<?php if (isset($globalURL)) print $globalURL; ?>" /> |
|
| 273 | + <input type="text" name="siteurl" id="siteurl" value="<?php if (isset($globalURL)) { |
|
| 274 | + print $globalURL; |
|
| 275 | +} |
|
| 276 | +?>" /> |
|
| 241 | 277 | <p class="help-block">ex : <i>/flightairmap</i> if complete URL is <i>http://toto.com/flightairmap</i></p> |
| 242 | 278 | <p class="help-block">Can be empty</p> |
| 243 | 279 | </p> |
| 244 | 280 | <p> |
| 245 | 281 | <label for="timezone">Timezone</label> |
| 246 | - <input type="text" name="timezone" id="timezone" value="<?php if (isset($globalTimezone)) print $globalTimezone; ?>" /> |
|
| 282 | + <input type="text" name="timezone" id="timezone" value="<?php if (isset($globalTimezone)) { |
|
| 283 | + print $globalTimezone; |
|
| 284 | +} |
|
| 285 | +?>" /> |
|
| 247 | 286 | <p class="help-block">ex : UTC, Europe/Paris,...</p> |
| 248 | 287 | </p> |
| 249 | 288 | <p> |
| 250 | 289 | <label for="language">Language</label> |
| 251 | - <input type="text" name="language" id="language" value="<?php if (isset($globalLanguage)) print $globalLanguage; ?>" /> |
|
| 290 | + <input type="text" name="language" id="language" value="<?php if (isset($globalLanguage)) { |
|
| 291 | + print $globalLanguage; |
|
| 292 | +} |
|
| 293 | +?>" /> |
|
| 252 | 294 | <p class="help-block">Used only when link to wikipedia for now. Can be EN,DE,FR,...</p> |
| 253 | 295 | </p> |
| 254 | 296 | </fieldset> |
@@ -268,11 +310,17 @@ discard block |
||
| 268 | 310 | <div id="mapbox_data"> |
| 269 | 311 | <p> |
| 270 | 312 | <label for="mapboxid">Mapbox id</label> |
| 271 | - <input type="text" name="mapboxid" id="mapboxid" value="<?php if (isset($globalMapboxId)) print $globalMapboxId; ?>" /> |
|
| 313 | + <input type="text" name="mapboxid" id="mapboxid" value="<?php if (isset($globalMapboxId)) { |
|
| 314 | + print $globalMapboxId; |
|
| 315 | +} |
|
| 316 | +?>" /> |
|
| 272 | 317 | </p> |
| 273 | 318 | <p> |
| 274 | 319 | <label for="mapboxtoken">Mapbox token</label> |
| 275 | - <input type="text" name="mapboxtoken" id="mapboxtoken" value="<?php if (isset($globalMapboxToken)) print $globalMapboxToken; ?>" /> |
|
| 320 | + <input type="text" name="mapboxtoken" id="mapboxtoken" value="<?php if (isset($globalMapboxToken)) { |
|
| 321 | + print $globalMapboxToken; |
|
| 322 | +} |
|
| 323 | +?>" /> |
|
| 276 | 324 | </p> |
| 277 | 325 | <p class="help-block">Get a key <a href="https://www.mapbox.com/developers/">here</a></p> |
| 278 | 326 | </div> |
@@ -280,7 +328,10 @@ discard block |
||
| 280 | 328 | <div id="google_data"> |
| 281 | 329 | <p> |
| 282 | 330 | <label for="googlekey">Google API key</label> |
| 283 | - <input type="text" name="googlekey" id="googlekey" value="<?php if (isset($globalGoogleAPIKey)) print $globalGoogleAPIKey; ?>" /> |
|
| 331 | + <input type="text" name="googlekey" id="googlekey" value="<?php if (isset($globalGoogleAPIKey)) { |
|
| 332 | + print $globalGoogleAPIKey; |
|
| 333 | +} |
|
| 334 | +?>" /> |
|
| 284 | 335 | <p class="help-block">Get a key <a href="https://developers.google.com/maps/documentation/javascript/get-api-key#get-an-api-key">here</a></p> |
| 285 | 336 | </p> |
| 286 | 337 | </div> |
@@ -288,7 +339,10 @@ discard block |
||
| 288 | 339 | <div id="bing_data"> |
| 289 | 340 | <p> |
| 290 | 341 | <label for="bingkey">Bing Map key</label> |
| 291 | - <input type="text" name="bingkey" id="bingkey" value="<?php if (isset($globalBingMapKey)) print $globalBingMapKey; ?>" /> |
|
| 342 | + <input type="text" name="bingkey" id="bingkey" value="<?php if (isset($globalBingMapKey)) { |
|
| 343 | + print $globalBingMapKey; |
|
| 344 | +} |
|
| 345 | +?>" /> |
|
| 292 | 346 | <p class="help-block">Get a key <a href="https://www.bingmapsportal.com/">here</a></p> |
| 293 | 347 | </p> |
| 294 | 348 | </div> |
@@ -296,7 +350,10 @@ discard block |
||
| 296 | 350 | <div id="mapquest_data"> |
| 297 | 351 | <p> |
| 298 | 352 | <label for="mapquestkey">MapQuest key</label> |
| 299 | - <input type="text" name="mapquestkey" id="mapquestkey" value="<?php if (isset($globalMapQuestKey)) print $globalMapQuestKey; ?>" /> |
|
| 353 | + <input type="text" name="mapquestkey" id="mapquestkey" value="<?php if (isset($globalMapQuestKey)) { |
|
| 354 | + print $globalMapQuestKey; |
|
| 355 | +} |
|
| 356 | +?>" /> |
|
| 300 | 357 | <p class="help-block">Get a key <a href="https://developer.mapquest.com/user/me/apps">here</a></p> |
| 301 | 358 | </p> |
| 302 | 359 | </div> |
@@ -304,11 +361,17 @@ discard block |
||
| 304 | 361 | <div id="here_data"> |
| 305 | 362 | <p> |
| 306 | 363 | <label for="hereappid">Here App_Id</label> |
| 307 | - <input type="text" name="hereappid" id="hereappid" value="<?php if (isset($globalHereappId)) print $globalHereappId; ?>" /> |
|
| 364 | + <input type="text" name="hereappid" id="hereappid" value="<?php if (isset($globalHereappId)) { |
|
| 365 | + print $globalHereappId; |
|
| 366 | +} |
|
| 367 | +?>" /> |
|
| 308 | 368 | </p> |
| 309 | 369 | <p> |
| 310 | 370 | <label for="hereappcode">Here App_Code</label> |
| 311 | - <input type="text" name="hereappcode" id="hereappcode" value="<?php if (isset($globalHereappCode)) print $globalHereappCode; ?>" /> |
|
| 371 | + <input type="text" name="hereappcode" id="hereappcode" value="<?php if (isset($globalHereappCode)) { |
|
| 372 | + print $globalHereappCode; |
|
| 373 | +} |
|
| 374 | +?>" /> |
|
| 312 | 375 | </p> |
| 313 | 376 | <p class="help-block">Get a key <a href="https://developer.here.com/rest-apis/documentation/enterprise-map-tile/topics/quick-start.html">here</a></p> |
| 314 | 377 | </div> |
@@ -316,7 +379,10 @@ discard block |
||
| 316 | 379 | <div id="openweathermap_data"> |
| 317 | 380 | <p> |
| 318 | 381 | <label for="openweathermapkey">OpenWeatherMap key (weather layer)</label> |
| 319 | - <input type="text" name="openweathermapkey" id="openweathermapkey" value="<?php if (isset($globalOpenWeatherMapKey)) print $globalOpenWeatherMapKey; ?>" /> |
|
| 382 | + <input type="text" name="openweathermapkey" id="openweathermapkey" value="<?php if (isset($globalOpenWeatherMapKey)) { |
|
| 383 | + print $globalOpenWeatherMapKey; |
|
| 384 | +} |
|
| 385 | +?>" /> |
|
| 320 | 386 | <p class="help-block">Get a key <a href="https://openweathermap.org/">here</a></p> |
| 321 | 387 | </p> |
| 322 | 388 | </div> |
@@ -345,42 +411,86 @@ discard block |
||
| 345 | 411 | <legend>Coverage area</legend> |
| 346 | 412 | <p> |
| 347 | 413 | <label for="latitudemax">The maximum latitude (north)</label> |
| 348 | - <input type="text" name="latitudemax" id="latitudemax" value="<?php if (isset($globalLatitudeMax)) print $globalLatitudeMax; ?>" /> |
|
| 414 | + <input type="text" name="latitudemax" id="latitudemax" value="<?php if (isset($globalLatitudeMax)) { |
|
| 415 | + print $globalLatitudeMax; |
|
| 416 | +} |
|
| 417 | +?>" /> |
|
| 349 | 418 | </p> |
| 350 | 419 | <p> |
| 351 | 420 | <label for="latitudemin">The minimum latitude (south)</label> |
| 352 | - <input type="text" name="latitudemin" id="latitudemin" value="<?php if (isset($globalLatitudeMin)) print $globalLatitudeMin; ?>" /> |
|
| 421 | + <input type="text" name="latitudemin" id="latitudemin" value="<?php if (isset($globalLatitudeMin)) { |
|
| 422 | + print $globalLatitudeMin; |
|
| 423 | +} |
|
| 424 | +?>" /> |
|
| 353 | 425 | </p> |
| 354 | 426 | <p> |
| 355 | 427 | <label for="longitudemax">The maximum longitude (west)</label> |
| 356 | - <input type="text" name="longitudemax" id="longitudemax" value="<?php if (isset($globalLongitudeMax)) print $globalLongitudeMax; ?>" /> |
|
| 428 | + <input type="text" name="longitudemax" id="longitudemax" value="<?php if (isset($globalLongitudeMax)) { |
|
| 429 | + print $globalLongitudeMax; |
|
| 430 | +} |
|
| 431 | +?>" /> |
|
| 357 | 432 | </p> |
| 358 | 433 | <p> |
| 359 | 434 | <label for="longitudemin">The minimum longitude (east)</label> |
| 360 | - <input type="text" name="longitudemin" id="longitudemin" value="<?php if (isset($globalLongitudeMin)) print $globalLongitudeMin; ?>" /> |
|
| 435 | + <input type="text" name="longitudemin" id="longitudemin" value="<?php if (isset($globalLongitudeMin)) { |
|
| 436 | + print $globalLongitudeMin; |
|
| 437 | +} |
|
| 438 | +?>" /> |
|
| 361 | 439 | </p> |
| 362 | 440 | <p> |
| 363 | 441 | <label for="latitudecenter">The latitude center</label> |
| 364 | - <input type="text" name="latitudecenter" id="latitudecenter" value="<?php if (isset($globalCenterLatitude)) print $globalCenterLatitude; ?>" /> |
|
| 442 | + <input type="text" name="latitudecenter" id="latitudecenter" value="<?php if (isset($globalCenterLatitude)) { |
|
| 443 | + print $globalCenterLatitude; |
|
| 444 | +} |
|
| 445 | +?>" /> |
|
| 365 | 446 | </p> |
| 366 | 447 | <p> |
| 367 | 448 | <label for="longitudecenter">The longitude center</label> |
| 368 | - <input type="text" name="longitudecenter" id="longitudecenter" value="<?php if (isset($globalCenterLongitude)) print $globalCenterLongitude; ?>" /> |
|
| 449 | + <input type="text" name="longitudecenter" id="longitudecenter" value="<?php if (isset($globalCenterLongitude)) { |
|
| 450 | + print $globalCenterLongitude; |
|
| 451 | +} |
|
| 452 | +?>" /> |
|
| 369 | 453 | </p> |
| 370 | 454 | <p> |
| 371 | 455 | <label for="livezoom">Default Zoom on live map</label> |
| 372 | - <input type="number" name="livezoom" id="livezoom" value="<?php if (isset($globalLiveZoom)) print $globalLiveZoom; else print '9'; ?>" /> |
|
| 456 | + <input type="number" name="livezoom" id="livezoom" value="<?php if (isset($globalLiveZoom)) { |
|
| 457 | + print $globalLiveZoom; |
|
| 458 | +} else { |
|
| 459 | + print '9'; |
|
| 460 | +} |
|
| 461 | +?>" /> |
|
| 373 | 462 | </p> |
| 374 | 463 | <p> |
| 375 | 464 | <label for="squawk_country">Country for squawk usage</label> |
| 376 | 465 | <select name="squawk_country" id="squawk_country"> |
| 377 | - <option value="UK"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'UK') print ' selected '; ?>>UK</option> |
|
| 378 | - <option value="NZ"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NZ') print ' selected '; ?>>NZ</option> |
|
| 379 | - <option value="US"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'US') print ' selected '; ?>>US</option> |
|
| 380 | - <option value="AU"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'AU') print ' selected '; ?>>AU</option> |
|
| 381 | - <option value="NL"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NL') print ' selected '; ?>>NL</option> |
|
| 382 | - <option value="FR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'FR') print ' selected '; ?>>FR</option> |
|
| 383 | - <option value="TR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'TR') print ' selected '; ?>>TR</option> |
|
| 466 | + <option value="UK"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'UK') { |
|
| 467 | + print ' selected '; |
|
| 468 | +} |
|
| 469 | +?>>UK</option> |
|
| 470 | + <option value="NZ"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NZ') { |
|
| 471 | + print ' selected '; |
|
| 472 | +} |
|
| 473 | +?>>NZ</option> |
|
| 474 | + <option value="US"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'US') { |
|
| 475 | + print ' selected '; |
|
| 476 | +} |
|
| 477 | +?>>US</option> |
|
| 478 | + <option value="AU"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'AU') { |
|
| 479 | + print ' selected '; |
|
| 480 | +} |
|
| 481 | +?>>AU</option> |
|
| 482 | + <option value="NL"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NL') { |
|
| 483 | + print ' selected '; |
|
| 484 | +} |
|
| 485 | +?>>NL</option> |
|
| 486 | + <option value="FR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'FR') { |
|
| 487 | + print ' selected '; |
|
| 488 | +} |
|
| 489 | +?>>FR</option> |
|
| 490 | + <option value="TR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'TR') { |
|
| 491 | + print ' selected '; |
|
| 492 | +} |
|
| 493 | +?>>TR</option> |
|
| 384 | 494 | </select> |
| 385 | 495 | </p> |
| 386 | 496 | </fieldset> |
@@ -389,15 +499,24 @@ discard block |
||
| 389 | 499 | <p><i>Only put in DB flights that are inside a circle</i></p> |
| 390 | 500 | <p> |
| 391 | 501 | <label for="latitude">Center latitude</label> |
| 392 | - <input type="text" name="zoilatitude" id="latitude" value="<?php if (isset($globalDistanceIgnore['latitude'])) echo $globalDistanceIgnore['latitude']; ?>" /> |
|
| 502 | + <input type="text" name="zoilatitude" id="latitude" value="<?php if (isset($globalDistanceIgnore['latitude'])) { |
|
| 503 | + echo $globalDistanceIgnore['latitude']; |
|
| 504 | +} |
|
| 505 | +?>" /> |
|
| 393 | 506 | </p> |
| 394 | 507 | <p> |
| 395 | 508 | <label for="longitude">Center longitude</label> |
| 396 | - <input type="text" name="zoilongitude" id="longitude" value="<?php if (isset($globalDistanceIgnore['longitude'])) echo $globalDistanceIgnore['longitude']; ?>" /> |
|
| 509 | + <input type="text" name="zoilongitude" id="longitude" value="<?php if (isset($globalDistanceIgnore['longitude'])) { |
|
| 510 | + echo $globalDistanceIgnore['longitude']; |
|
| 511 | +} |
|
| 512 | +?>" /> |
|
| 397 | 513 | </p> |
| 398 | 514 | <p> |
| 399 | 515 | <label for="Distance">Distance (in km)</label> |
| 400 | - <input type="text" name="zoidistance" id="distance" value="<?php if (isset($globalDistanceIgnore['distance'])) echo $globalDistanceIgnore['distance']; ?>" /> |
|
| 516 | + <input type="text" name="zoidistance" id="distance" value="<?php if (isset($globalDistanceIgnore['distance'])) { |
|
| 517 | + echo $globalDistanceIgnore['distance']; |
|
| 518 | +} |
|
| 519 | +?>" /> |
|
| 401 | 520 | </p> |
| 402 | 521 | </fieldset> |
| 403 | 522 | <fieldset id="sourceloc"> |
@@ -523,28 +642,43 @@ discard block |
||
| 523 | 642 | <div id="flightaware_data"> |
| 524 | 643 | <p> |
| 525 | 644 | <label for="flightawareusername">FlightAware username</label> |
| 526 | - <input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) print $globalFlightAwareUsername; ?>" /> |
|
| 645 | + <input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) { |
|
| 646 | + print $globalFlightAwareUsername; |
|
| 647 | +} |
|
| 648 | +?>" /> |
|
| 527 | 649 | </p> |
| 528 | 650 | <p> |
| 529 | 651 | <label for="flightawarepassword">FlightAware password/API key</label> |
| 530 | - <input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) print $globalFlightAwarePassword; ?>" /> |
|
| 652 | + <input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) { |
|
| 653 | + print $globalFlightAwarePassword; |
|
| 654 | +} |
|
| 655 | +?>" /> |
|
| 531 | 656 | </p> |
| 532 | 657 | </div> |
| 533 | 658 | --> |
| 534 | 659 | <div id="sailaway_data"> |
| 535 | 660 | <p> |
| 536 | 661 | <label for="sailawayemail">Sailaway email</label> |
| 537 | - <input type="text" name="sailawayemail" id="sailawayemail" value="<?php if (isset($globalSailaway['email'])) print $globalSailaway['email']; ?>" /> |
|
| 662 | + <input type="text" name="sailawayemail" id="sailawayemail" value="<?php if (isset($globalSailaway['email'])) { |
|
| 663 | + print $globalSailaway['email']; |
|
| 664 | +} |
|
| 665 | +?>" /> |
|
| 538 | 666 | <p class="help-block">Only needed for Sailaway full format</p> |
| 539 | 667 | </p> |
| 540 | 668 | <p> |
| 541 | 669 | <label for="sailawaypassword">Sailaway password</label> |
| 542 | - <input type="text" name="sailawaypassword" id="sailawaypassword" value="<?php if (isset($globalSailaway['password'])) print $globalSailaway['password']; ?>" /> |
|
| 670 | + <input type="text" name="sailawaypassword" id="sailawaypassword" value="<?php if (isset($globalSailaway['password'])) { |
|
| 671 | + print $globalSailaway['password']; |
|
| 672 | +} |
|
| 673 | +?>" /> |
|
| 543 | 674 | <p class="help-block">Only needed for Sailaway full format</p> |
| 544 | 675 | </p> |
| 545 | 676 | <p> |
| 546 | 677 | <label for="sailawaykey">Sailaway API key</label> |
| 547 | - <input type="text" name="sailawaykey" id="sailawaykey" value="<?php if (isset($globalSailaway['key'])) print $globalSailaway['key']; ?>" /> |
|
| 678 | + <input type="text" name="sailawaykey" id="sailawaykey" value="<?php if (isset($globalSailaway['key'])) { |
|
| 679 | + print $globalSailaway['key']; |
|
| 680 | +} |
|
| 681 | +?>" /> |
|
| 548 | 682 | </p> |
| 549 | 683 | </div> |
| 550 | 684 | |
@@ -586,7 +720,10 @@ discard block |
||
| 586 | 720 | if (filter_var($source['host'],FILTER_VALIDATE_URL)) { |
| 587 | 721 | ?> |
| 588 | 722 | <td><input type="text" name="host[]" value="<?php print $source['host']; ?>" /></td> |
| 589 | - <td><input type="text" name="port[]" class="col-xs-2" value="<?php if (isset($source['port'])) print $source['port']; ?>" /></td> |
|
| 723 | + <td><input type="text" name="port[]" class="col-xs-2" value="<?php if (isset($source['port'])) { |
|
| 724 | + print $source['port']; |
|
| 725 | +} |
|
| 726 | +?>" /></td> |
|
| 590 | 727 | <?php |
| 591 | 728 | } else { |
| 592 | 729 | $hostport = explode(':',$source['host']); |
@@ -605,41 +742,134 @@ discard block |
||
| 605 | 742 | ?> |
| 606 | 743 | <td> |
| 607 | 744 | <select name="format[]"> |
| 608 | - <option value="auto" <?php if (!isset($source['format'])) print 'selected'; ?>>Auto</option> |
|
| 609 | - <option value="sbs" <?php if (isset($source['format']) && $source['format'] == 'sbs') print 'selected'; ?>>SBS</option> |
|
| 610 | - <option value="tsv" <?php if (isset($source['format']) && $source['format'] == 'tsv') print 'selected'; ?>>TSV</option> |
|
| 611 | - <option value="raw" <?php if (isset($source['format']) && $source['format'] == 'raw') print 'selected'; ?>>Raw</option> |
|
| 612 | - <option value="aircraftjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftjson') print 'selected'; ?>>Dump1090 aircraft.json</option> |
|
| 613 | - <option value="planefinderclient" <?php if (isset($source['format']) && $source['format'] == 'planefinderclient') print 'selected'; ?>>Planefinder client</option> |
|
| 614 | - <option value="aprs" <?php if (isset($source['format']) && $source['format'] == 'aprs') print 'selected'; ?>>APRS</option> |
|
| 615 | - <option value="deltadbtxt" <?php if (isset($source['format']) && $source['format'] == 'deltadbtxt') print 'selected'; ?>>Radarcape deltadb.txt</option> |
|
| 616 | - <option value="radarcapejson" <?php if (isset($source['format']) && $source['format'] == 'radarcapejson') print 'selected'; ?>>Radarcape json</option> |
|
| 617 | - <option value="vatsimtxt" <?php if (isset($source['format']) && $source['format'] == 'vatsimtxt') print 'selected'; ?>>Vatsim</option> |
|
| 618 | - <option value="aircraftlistjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftlistjson') print 'selected'; ?>>Virtual Radar Server AircraftList.json</option> |
|
| 619 | - <option value="vrstcp" <?php if (isset($source['format']) && $source['format'] == 'vrstcp') print 'selected'; ?>>Virtual Radar Server TCP</option> |
|
| 620 | - <option value="phpvmacars" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') print 'selected'; ?>>phpVMS</option> |
|
| 621 | - <option value="vaos" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') print 'selected'; ?>>Virtual Airline Operations System (VAOS)</option> |
|
| 622 | - <option value="vam" <?php if (isset($source['format']) && $source['format'] == 'vam') print 'selected'; ?>>Virtual Airlines Manager</option> |
|
| 623 | - <option value="whazzup" <?php if (isset($source['format']) && $source['format'] == 'whazzup') print 'selected'; ?>>IVAO</option> |
|
| 624 | - <option value="flightgearmp" <?php if (isset($source['format']) && $source['format'] == 'flightgearmp') print 'selected'; ?>>FlightGear Multiplayer</option> |
|
| 625 | - <option value="flightgearsp" <?php if (isset($source['format']) && $source['format'] == 'flightgearsp') print 'selected'; ?>>FlightGear Singleplayer</option> |
|
| 626 | - <option value="acars" <?php if (isset($source['format']) && $source['format'] == 'acars') print 'selected'; ?>>ACARS from acarsdec/acarsdeco2 over UDP</option> |
|
| 627 | - <option value="acarssbs3" <?php if (isset($source['format']) && $source['format'] == 'acarssbs3') print 'selected'; ?>>ACARS SBS-3 over TCP</option> |
|
| 628 | - <option value="acarsjson" <?php if (isset($source['format']) && $source['format'] == 'acarsjson') print 'selected'; ?>>ACARS from acarsdec json and vdlm2dec</option> |
|
| 629 | - <option value="acarsjsonudp" <?php if (isset($source['format']) && $source['format'] == 'acarsjsonudp') print 'selected'; ?>>ACARS from acarsdec json and vdlm2dec over UDP</option> |
|
| 630 | - <option value="ais" <?php if (isset($source['format']) && $source['format'] == 'ais') print 'selected'; ?>>NMEA AIS over TCP</option> |
|
| 631 | - <option value="airwhere" <?php if (isset($source['format']) && $source['format'] == 'airwhere') print 'selected'; ?>>AirWhere website</option> |
|
| 632 | - <option value="hidnseek_callback" <?php if (isset($source['format']) && $source['format'] == 'hidnseek_callback') print 'selected'; ?>>HidnSeek Callback</option> |
|
| 633 | - <option value="blitzortung" <?php if (isset($source['format']) && $source['format'] == 'blitzortung') print 'selected'; ?>>Blitzortung</option> |
|
| 634 | - <option value="sailaway" <?php if (isset($source['format']) && $source['format'] == 'sailaway') print 'selected'; ?>>Sailaway</option> |
|
| 635 | - <option value="sailawayfull" <?php if (isset($source['format']) && $source['format'] == 'sailawayfull') print 'selected'; ?>>Sailaway with missions, races,...</option> |
|
| 745 | + <option value="auto" <?php if (!isset($source['format'])) { |
|
| 746 | + print 'selected'; |
|
| 747 | +} |
|
| 748 | +?>>Auto</option> |
|
| 749 | + <option value="sbs" <?php if (isset($source['format']) && $source['format'] == 'sbs') { |
|
| 750 | + print 'selected'; |
|
| 751 | +} |
|
| 752 | +?>>SBS</option> |
|
| 753 | + <option value="tsv" <?php if (isset($source['format']) && $source['format'] == 'tsv') { |
|
| 754 | + print 'selected'; |
|
| 755 | +} |
|
| 756 | +?>>TSV</option> |
|
| 757 | + <option value="raw" <?php if (isset($source['format']) && $source['format'] == 'raw') { |
|
| 758 | + print 'selected'; |
|
| 759 | +} |
|
| 760 | +?>>Raw</option> |
|
| 761 | + <option value="aircraftjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftjson') { |
|
| 762 | + print 'selected'; |
|
| 763 | +} |
|
| 764 | +?>>Dump1090 aircraft.json</option> |
|
| 765 | + <option value="planefinderclient" <?php if (isset($source['format']) && $source['format'] == 'planefinderclient') { |
|
| 766 | + print 'selected'; |
|
| 767 | +} |
|
| 768 | +?>>Planefinder client</option> |
|
| 769 | + <option value="aprs" <?php if (isset($source['format']) && $source['format'] == 'aprs') { |
|
| 770 | + print 'selected'; |
|
| 771 | +} |
|
| 772 | +?>>APRS</option> |
|
| 773 | + <option value="deltadbtxt" <?php if (isset($source['format']) && $source['format'] == 'deltadbtxt') { |
|
| 774 | + print 'selected'; |
|
| 775 | +} |
|
| 776 | +?>>Radarcape deltadb.txt</option> |
|
| 777 | + <option value="radarcapejson" <?php if (isset($source['format']) && $source['format'] == 'radarcapejson') { |
|
| 778 | + print 'selected'; |
|
| 779 | +} |
|
| 780 | +?>>Radarcape json</option> |
|
| 781 | + <option value="vatsimtxt" <?php if (isset($source['format']) && $source['format'] == 'vatsimtxt') { |
|
| 782 | + print 'selected'; |
|
| 783 | +} |
|
| 784 | +?>>Vatsim</option> |
|
| 785 | + <option value="aircraftlistjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftlistjson') { |
|
| 786 | + print 'selected'; |
|
| 787 | +} |
|
| 788 | +?>>Virtual Radar Server AircraftList.json</option> |
|
| 789 | + <option value="vrstcp" <?php if (isset($source['format']) && $source['format'] == 'vrstcp') { |
|
| 790 | + print 'selected'; |
|
| 791 | +} |
|
| 792 | +?>>Virtual Radar Server TCP</option> |
|
| 793 | + <option value="phpvmacars" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') { |
|
| 794 | + print 'selected'; |
|
| 795 | +} |
|
| 796 | +?>>phpVMS</option> |
|
| 797 | + <option value="vaos" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') { |
|
| 798 | + print 'selected'; |
|
| 799 | +} |
|
| 800 | +?>>Virtual Airline Operations System (VAOS)</option> |
|
| 801 | + <option value="vam" <?php if (isset($source['format']) && $source['format'] == 'vam') { |
|
| 802 | + print 'selected'; |
|
| 803 | +} |
|
| 804 | +?>>Virtual Airlines Manager</option> |
|
| 805 | + <option value="whazzup" <?php if (isset($source['format']) && $source['format'] == 'whazzup') { |
|
| 806 | + print 'selected'; |
|
| 807 | +} |
|
| 808 | +?>>IVAO</option> |
|
| 809 | + <option value="flightgearmp" <?php if (isset($source['format']) && $source['format'] == 'flightgearmp') { |
|
| 810 | + print 'selected'; |
|
| 811 | +} |
|
| 812 | +?>>FlightGear Multiplayer</option> |
|
| 813 | + <option value="flightgearsp" <?php if (isset($source['format']) && $source['format'] == 'flightgearsp') { |
|
| 814 | + print 'selected'; |
|
| 815 | +} |
|
| 816 | +?>>FlightGear Singleplayer</option> |
|
| 817 | + <option value="acars" <?php if (isset($source['format']) && $source['format'] == 'acars') { |
|
| 818 | + print 'selected'; |
|
| 819 | +} |
|
| 820 | +?>>ACARS from acarsdec/acarsdeco2 over UDP</option> |
|
| 821 | + <option value="acarssbs3" <?php if (isset($source['format']) && $source['format'] == 'acarssbs3') { |
|
| 822 | + print 'selected'; |
|
| 823 | +} |
|
| 824 | +?>>ACARS SBS-3 over TCP</option> |
|
| 825 | + <option value="acarsjson" <?php if (isset($source['format']) && $source['format'] == 'acarsjson') { |
|
| 826 | + print 'selected'; |
|
| 827 | +} |
|
| 828 | +?>>ACARS from acarsdec json and vdlm2dec</option> |
|
| 829 | + <option value="acarsjsonudp" <?php if (isset($source['format']) && $source['format'] == 'acarsjsonudp') { |
|
| 830 | + print 'selected'; |
|
| 831 | +} |
|
| 832 | +?>>ACARS from acarsdec json and vdlm2dec over UDP</option> |
|
| 833 | + <option value="ais" <?php if (isset($source['format']) && $source['format'] == 'ais') { |
|
| 834 | + print 'selected'; |
|
| 835 | +} |
|
| 836 | +?>>NMEA AIS over TCP</option> |
|
| 837 | + <option value="airwhere" <?php if (isset($source['format']) && $source['format'] == 'airwhere') { |
|
| 838 | + print 'selected'; |
|
| 839 | +} |
|
| 840 | +?>>AirWhere website</option> |
|
| 841 | + <option value="hidnseek_callback" <?php if (isset($source['format']) && $source['format'] == 'hidnseek_callback') { |
|
| 842 | + print 'selected'; |
|
| 843 | +} |
|
| 844 | +?>>HidnSeek Callback</option> |
|
| 845 | + <option value="blitzortung" <?php if (isset($source['format']) && $source['format'] == 'blitzortung') { |
|
| 846 | + print 'selected'; |
|
| 847 | +} |
|
| 848 | +?>>Blitzortung</option> |
|
| 849 | + <option value="sailaway" <?php if (isset($source['format']) && $source['format'] == 'sailaway') { |
|
| 850 | + print 'selected'; |
|
| 851 | +} |
|
| 852 | +?>>Sailaway</option> |
|
| 853 | + <option value="sailawayfull" <?php if (isset($source['format']) && $source['format'] == 'sailawayfull') { |
|
| 854 | + print 'selected'; |
|
| 855 | +} |
|
| 856 | +?>>Sailaway with missions, races,...</option> |
|
| 636 | 857 | </select> |
| 637 | 858 | </td> |
| 638 | 859 | <td> |
| 639 | - <input type="text" name="name[]" value="<?php if (isset($source['name'])) print $source['name']; ?>" /> |
|
| 860 | + <input type="text" name="name[]" value="<?php if (isset($source['name'])) { |
|
| 861 | + print $source['name']; |
|
| 862 | +} |
|
| 863 | +?>" /> |
|
| 640 | 864 | </td> |
| 641 | - <td><input type="checkbox" name="sourcestats[]" title="Create statistics for the source like number of messages, distance,..." value="1" <?php if (isset($source['sourcestats']) && $source['sourcestats']) print 'checked'; ?> /></td> |
|
| 642 | - <td><input type="checkbox" name="noarchive[]" title="Don't archive this source" value="1" <?php if (isset($source['noarchive']) && $source['noarchive']) print 'checked'; ?> /></td> |
|
| 865 | + <td><input type="checkbox" name="sourcestats[]" title="Create statistics for the source like number of messages, distance,..." value="1" <?php if (isset($source['sourcestats']) && $source['sourcestats']) { |
|
| 866 | + print 'checked'; |
|
| 867 | +} |
|
| 868 | +?> /></td> |
|
| 869 | + <td><input type="checkbox" name="noarchive[]" title="Don't archive this source" value="1" <?php if (isset($source['noarchive']) && $source['noarchive']) { |
|
| 870 | + print 'checked'; |
|
| 871 | +} |
|
| 872 | +?> /></td> |
|
| 643 | 873 | <td> |
| 644 | 874 | <select name="timezones[]"> |
| 645 | 875 | <?php |
@@ -649,7 +879,9 @@ discard block |
||
| 649 | 879 | print '<option selected>'.$timezones.'</option>'; |
| 650 | 880 | } elseif (!isset($source['timezone']) && $timezones == 'UTC') { |
| 651 | 881 | print '<option selected>'.$timezones.'</option>'; |
| 652 | - } else print '<option>'.$timezones.'</option>'; |
|
| 882 | + } else { |
|
| 883 | + print '<option>'.$timezones.'</option>'; |
|
| 884 | + } |
|
| 653 | 885 | } |
| 654 | 886 | ?> |
| 655 | 887 | </select> |
@@ -707,7 +939,9 @@ discard block |
||
| 707 | 939 | foreach($timezonelist as $timezones){ |
| 708 | 940 | if ($timezones == 'UTC') { |
| 709 | 941 | print '<option selected>'.$timezones.'</option>'; |
| 710 | - } else print '<option>'.$timezones.'</option>'; |
|
| 942 | + } else { |
|
| 943 | + print '<option>'.$timezones.'</option>'; |
|
| 944 | + } |
|
| 711 | 945 | } |
| 712 | 946 | ?> |
| 713 | 947 | </select> |
@@ -732,11 +966,17 @@ discard block |
||
| 732 | 966 | <p>Listen UDP server for acarsdec/acarsdeco2/... with <i>daemon-acars.php</i> script</p> |
| 733 | 967 | <p> |
| 734 | 968 | <label for="acarshost">ACARS UDP host</label> |
| 735 | - <input type="text" name="acarshost" id="acarshost" value="<?php if (isset($globalACARSHost)) print $globalACARSHost; ?>" /> |
|
| 969 | + <input type="text" name="acarshost" id="acarshost" value="<?php if (isset($globalACARSHost)) { |
|
| 970 | + print $globalACARSHost; |
|
| 971 | +} |
|
| 972 | +?>" /> |
|
| 736 | 973 | </p> |
| 737 | 974 | <p> |
| 738 | 975 | <label for="acarsport">ACARS UDP port</label> |
| 739 | - <input type="number" name="acarsport" id="acarsport" value="<?php if (isset($globalACARSPort)) print $globalACARSPort; ?>" /> |
|
| 976 | + <input type="number" name="acarsport" id="acarsport" value="<?php if (isset($globalACARSPort)) { |
|
| 977 | + print $globalACARSPort; |
|
| 978 | +} |
|
| 979 | +?>" /> |
|
| 740 | 980 | </p> |
| 741 | 981 | <p class="help-block"><i>daemon-acars.php</i> can only be run as daemon. It's an alternate script for ACARS data, <i>daemon-spotter.php</i> may be better.</p> |
| 742 | 982 | </fieldset> |
@@ -763,17 +1003,38 @@ discard block |
||
| 763 | 1003 | <td><input type="url" name="newsurl[]" value="<?php print $feed; ?>"/></td> |
| 764 | 1004 | <td> |
| 765 | 1005 | <select name="newslang[]"> |
| 766 | - <option value="en"<?php if ($lng == 'en') print ' selected'; ?>>English</option> |
|
| 767 | - <option value="fr"<?php if ($lng == 'fr') print ' selected'; ?>>French</option> |
|
| 1006 | + <option value="en"<?php if ($lng == 'en') { |
|
| 1007 | + print ' selected'; |
|
| 1008 | +} |
|
| 1009 | +?>>English</option> |
|
| 1010 | + <option value="fr"<?php if ($lng == 'fr') { |
|
| 1011 | + print ' selected'; |
|
| 1012 | +} |
|
| 1013 | +?>>French</option> |
|
| 768 | 1014 | </select> |
| 769 | 1015 | </td> |
| 770 | 1016 | <td> |
| 771 | 1017 | <select name="newstype[]"> |
| 772 | - <option value="global"<?php if ($type == 'global') print ' selected'; ?>>Global</option> |
|
| 773 | - <option value="aircraft"<?php if ($type == 'aircraft') print ' selected'; ?>>Aircraft</option> |
|
| 774 | - <option value="marine"<?php if ($type == 'marine') print ' selected'; ?>>Marine</option> |
|
| 775 | - <option value="tracker"<?php if ($type == 'tracker') print ' selected'; ?>>Tracker</option> |
|
| 776 | - <option value="satellite"<?php if ($type == 'Satellite') print ' selected'; ?>>Satellite</option> |
|
| 1018 | + <option value="global"<?php if ($type == 'global') { |
|
| 1019 | + print ' selected'; |
|
| 1020 | +} |
|
| 1021 | +?>>Global</option> |
|
| 1022 | + <option value="aircraft"<?php if ($type == 'aircraft') { |
|
| 1023 | + print ' selected'; |
|
| 1024 | +} |
|
| 1025 | +?>>Aircraft</option> |
|
| 1026 | + <option value="marine"<?php if ($type == 'marine') { |
|
| 1027 | + print ' selected'; |
|
| 1028 | +} |
|
| 1029 | +?>>Marine</option> |
|
| 1030 | + <option value="tracker"<?php if ($type == 'tracker') { |
|
| 1031 | + print ' selected'; |
|
| 1032 | +} |
|
| 1033 | +?>>Tracker</option> |
|
| 1034 | + <option value="satellite"<?php if ($type == 'Satellite') { |
|
| 1035 | + print ' selected'; |
|
| 1036 | +} |
|
| 1037 | +?>>Satellite</option> |
|
| 777 | 1038 | </select> |
| 778 | 1039 | </td> |
| 779 | 1040 | <td><input type="button" value="Delete" onclick="deleteRowNews(this)" /> <input type="button" value="Add" onclick="insRowNews()" /></td> |
@@ -857,7 +1118,10 @@ discard block |
||
| 857 | 1118 | </p> |
| 858 | 1119 | <p> |
| 859 | 1120 | <label for="corsproxy">CORS proxy</label> |
| 860 | - <input type="text" name="corsproxy" id="corsproxy" value="<?php if (isset($globalCORSproxy)) print $globalCORSproxy; else print 'https://galvanize-cors-proxy.herokuapp.com/' ?>" /> |
|
| 1121 | + <input type="text" name="corsproxy" id="corsproxy" value="<?php if (isset($globalCORSproxy)) { |
|
| 1122 | + print $globalCORSproxy; |
|
| 1123 | +} else { |
|
| 1124 | + print 'https://galvanize-cors-proxy.herokuapp.com/' ?>" /> |
|
| 861 | 1125 | <p class="help-block">CORS proxy used for some WMS servers</p> |
| 862 | 1126 | </p> |
| 863 | 1127 | <!-- |
@@ -920,13 +1184,18 @@ discard block |
||
| 920 | 1184 | <div id="schedules_options"> |
| 921 | 1185 | <p> |
| 922 | 1186 | <label for="britishairways">British Airways API Key</label> |
| 923 | - <input type="text" name="britishairways" id="britishairways" value="<?php if (isset($globalBritishAirwaysKey)) print $globalBritishAirwaysKey; ?>" /> |
|
| 1187 | + <input type="text" name="britishairways" id="britishairways" value="<?php if (isset($globalBritishAirwaysKey)) print $globalBritishAirwaysKey; |
|
| 1188 | +} |
|
| 1189 | +?>" /> |
|
| 924 | 1190 | <p class="help-block">Register an account on <a href="https://developer.ba.com/">https://developer.ba.com/</a></p> |
| 925 | 1191 | </p> |
| 926 | 1192 | <!-- |
| 927 | 1193 | <p> |
| 928 | 1194 | <label for="transavia">Transavia Test API Consumer Key</label> |
| 929 | - <input type="text" name="transavia" id="transavia" value="<?php if (isset($globalTransaviaKey)) print $globalTransaviaKey; ?>" /> |
|
| 1195 | + <input type="text" name="transavia" id="transavia" value="<?php if (isset($globalTransaviaKey)) { |
|
| 1196 | + print $globalTransaviaKey; |
|
| 1197 | +} |
|
| 1198 | +?>" /> |
|
| 930 | 1199 | <p class="help-block">Register an account on <a href="https://developer.transavia.com">https://developer.transavia.com</a></p> |
| 931 | 1200 | </p> |
| 932 | 1201 | --> |
@@ -935,10 +1204,16 @@ discard block |
||
| 935 | 1204 | <b>Lufthansa API Key</b> |
| 936 | 1205 | <p> |
| 937 | 1206 | <label for="lufthansakey">Key</label> |
| 938 | - <input type="text" name="lufthansakey" id="lufthansakey" value="<?php if (isset($globalLufthansaKey['key'])) print $globalLufthansaKey['key']; ?>" /> |
|
| 1207 | + <input type="text" name="lufthansakey" id="lufthansakey" value="<?php if (isset($globalLufthansaKey['key'])) { |
|
| 1208 | + print $globalLufthansaKey['key']; |
|
| 1209 | +} |
|
| 1210 | +?>" /> |
|
| 939 | 1211 | </p><p> |
| 940 | 1212 | <label for="lufthansasecret">Secret</label> |
| 941 | - <input type="text" name="lufthansasecret" id="lufthansasecret" value="<?php if (isset($globalLufthansaKey['secret'])) print $globalLufthansaKey['secret']; ?>" /> |
|
| 1213 | + <input type="text" name="lufthansasecret" id="lufthansasecret" value="<?php if (isset($globalLufthansaKey['secret'])) { |
|
| 1214 | + print $globalLufthansaKey['secret']; |
|
| 1215 | +} |
|
| 1216 | +?>" /> |
|
| 942 | 1217 | </p> |
| 943 | 1218 | </div> |
| 944 | 1219 | <p class="help-block">Register an account on <a href="https://developer.lufthansa.com/page">https://developer.lufthansa.com/page</a></p> |
@@ -948,11 +1223,17 @@ discard block |
||
| 948 | 1223 | <b>FlightAware API Key</b> |
| 949 | 1224 | <p> |
| 950 | 1225 | <label for="flightawareusername">Username</label> |
| 951 | - <input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) print $globalFlightAwareUsername; ?>" /> |
|
| 1226 | + <input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) { |
|
| 1227 | + print $globalFlightAwareUsername; |
|
| 1228 | +} |
|
| 1229 | +?>" /> |
|
| 952 | 1230 | </p> |
| 953 | 1231 | <p> |
| 954 | 1232 | <label for="flightawarepassword">API key</label> |
| 955 | - <input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) print $globalFlightAwarePassword; ?>" /> |
|
| 1233 | + <input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) { |
|
| 1234 | + print $globalFlightAwarePassword; |
|
| 1235 | +} |
|
| 1236 | +?>" /> |
|
| 956 | 1237 | </p> |
| 957 | 1238 | </div> |
| 958 | 1239 | <p class="help-block">Register an account on <a href="https://www.flightaware.com/">https://www.flightaware.com/</a></p> |
@@ -969,10 +1250,22 @@ discard block |
||
| 969 | 1250 | <p> |
| 970 | 1251 | <label for="mapmatchingsource">Map Matching source</label> |
| 971 | 1252 | <select name="mapmatchingsource" id="mapmatchingsource"> |
| 972 | - <option value="fam" <?php if ((isset($globalMapMatchingSource) && $globalMapMatchingSource == 'fam') || !isset($globalMatchingSource)) print 'selected="selected" '; ?>>FlightAirMap Map Matching</option> |
|
| 973 | - <option value="graphhopper" <?php if (isset($globalMapMatchingSource) && $globalMapMatchingSource == 'graphhopper') print 'selected="selected" '; ?>>GraphHopper</option> |
|
| 974 | - <option value="osmr" <?php if (isset($globalMapMatchingSource) && $globalMapMatchingSource == 'osmr') print 'selected="selected" '; ?>>OSMR</option> |
|
| 975 | - <option value="mapbox" <?php if (isset($globalMapMatchingSource) && $globalMapMatchingSource == 'mapbox') print 'selected="selected" '; ?>>Mapbox</option> |
|
| 1253 | + <option value="fam" <?php if ((isset($globalMapMatchingSource) && $globalMapMatchingSource == 'fam') || !isset($globalMatchingSource)) { |
|
| 1254 | + print 'selected="selected" '; |
|
| 1255 | +} |
|
| 1256 | +?>>FlightAirMap Map Matching</option> |
|
| 1257 | + <option value="graphhopper" <?php if (isset($globalMapMatchingSource) && $globalMapMatchingSource == 'graphhopper') { |
|
| 1258 | + print 'selected="selected" '; |
|
| 1259 | +} |
|
| 1260 | +?>>GraphHopper</option> |
|
| 1261 | + <option value="osmr" <?php if (isset($globalMapMatchingSource) && $globalMapMatchingSource == 'osmr') { |
|
| 1262 | + print 'selected="selected" '; |
|
| 1263 | +} |
|
| 1264 | +?>>OSMR</option> |
|
| 1265 | + <option value="mapbox" <?php if (isset($globalMapMatchingSource) && $globalMapMatchingSource == 'mapbox') { |
|
| 1266 | + print 'selected="selected" '; |
|
| 1267 | +} |
|
| 1268 | +?>>Mapbox</option> |
|
| 976 | 1269 | </select> |
| 977 | 1270 | <p class="help-block">Mapbox need the API Key defined in map section.</p> |
| 978 | 1271 | <p class="help-block">FlightAirMap Map Matching is free, without API key but limited to about 100 input points to keep fast results.</p> |
@@ -980,7 +1273,10 @@ discard block |
||
| 980 | 1273 | <br /> |
| 981 | 1274 | <p> |
| 982 | 1275 | <label for="graphhopper">GraphHopper API Key</label> |
| 983 | - <input type="text" name="graphhopper" id="graphhopper" value="<?php if (isset($globalGraphHopperKey)) print $globalGraphHopperKey; ?>" /> |
|
| 1276 | + <input type="text" name="graphhopper" id="graphhopper" value="<?php if (isset($globalGraphHopperKey)) { |
|
| 1277 | + print $globalGraphHopperKey; |
|
| 1278 | +} |
|
| 1279 | +?>" /> |
|
| 984 | 1280 | <p class="help-block">Register an account on <a href="https://www.graphhopper.com/">https://www.graphhopper.com/</a></p> |
| 985 | 1281 | </p> |
| 986 | 1282 | </div> |
@@ -998,7 +1294,10 @@ discard block |
||
| 998 | 1294 | </p> |
| 999 | 1295 | <p> |
| 1000 | 1296 | <label for="notamsource">URL of your feed from notaminfo.com</label> |
| 1001 | - <input type="text" name="notamsource" id="notamsource" value="<?php if (isset($globalNOTAMSource)) print $globalNOTAMSource; ?>" /> |
|
| 1297 | + <input type="text" name="notamsource" id="notamsource" value="<?php if (isset($globalNOTAMSource)) { |
|
| 1298 | + print $globalNOTAMSource; |
|
| 1299 | +} |
|
| 1300 | +?>" /> |
|
| 1002 | 1301 | <p class="help-block">If you want to use world NOTAM from FlightAirMap website, leave it blank</p> |
| 1003 | 1302 | </p> |
| 1004 | 1303 | <br /> |
@@ -1014,14 +1313,20 @@ discard block |
||
| 1014 | 1313 | <div id="metarsrc"> |
| 1015 | 1314 | <p> |
| 1016 | 1315 | <label for="metarsource">URL of your METAR source</label> |
| 1017 | - <input type="text" name="metarsource" id="metarsource" value="<?php if (isset($globalMETARurl)) print $globalMETARurl; ?>" /> |
|
| 1316 | + <input type="text" name="metarsource" id="metarsource" value="<?php if (isset($globalMETARurl)) { |
|
| 1317 | + print $globalMETARurl; |
|
| 1318 | +} |
|
| 1319 | +?>" /> |
|
| 1018 | 1320 | <p class="help-block">Use {icao} to specify where we replace by airport icao. ex : http://metar.vatsim.net/metar.php?id={icao}</p> |
| 1019 | 1321 | </p> |
| 1020 | 1322 | </div> |
| 1021 | 1323 | <br /> |
| 1022 | 1324 | <p> |
| 1023 | 1325 | <label for="bitly">Bit.ly access token api (used in search page)</label> |
| 1024 | - <input type="text" name="bitly" id="bitly" value="<?php if (isset($globalBitlyAccessToken)) print $globalBitlyAccessToken; ?>" /> |
|
| 1326 | + <input type="text" name="bitly" id="bitly" value="<?php if (isset($globalBitlyAccessToken)) { |
|
| 1327 | + print $globalBitlyAccessToken; |
|
| 1328 | +} |
|
| 1329 | +?>" /> |
|
| 1025 | 1330 | </p> |
| 1026 | 1331 | <br /> |
| 1027 | 1332 | <p> |
@@ -1037,11 +1342,26 @@ discard block |
||
| 1037 | 1342 | <p> |
| 1038 | 1343 | <label for="geoid_source">Geoid Source</label> |
| 1039 | 1344 | <select name="geoid_source" id="geoid_source"> |
| 1040 | - <option value="egm96-15"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-15') print ' selected="selected"'; ?>>EGM96 15' (2.1MB)</option> |
|
| 1041 | - <option value="egm96-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-5') print ' selected="selected"'; ?>>EGM96 5' (19MB)</option> |
|
| 1042 | - <option value="egm2008-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-5') print ' selected="selected"'; ?>>EGM2008 5' (19MB)</option> |
|
| 1043 | - <option value="egm2008-2_5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-2_5') print ' selected="selected"'; ?>>EGM2008 2.5' (75MB)</option> |
|
| 1044 | - <option value="egm2008-1"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-1') print ' selected="selected"'; ?>>EGM2008 1' (470MB)</option> |
|
| 1345 | + <option value="egm96-15"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-15') { |
|
| 1346 | + print ' selected="selected"'; |
|
| 1347 | +} |
|
| 1348 | +?>>EGM96 15' (2.1MB)</option> |
|
| 1349 | + <option value="egm96-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-5') { |
|
| 1350 | + print ' selected="selected"'; |
|
| 1351 | +} |
|
| 1352 | +?>>EGM96 5' (19MB)</option> |
|
| 1353 | + <option value="egm2008-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-5') { |
|
| 1354 | + print ' selected="selected"'; |
|
| 1355 | +} |
|
| 1356 | +?>>EGM2008 5' (19MB)</option> |
|
| 1357 | + <option value="egm2008-2_5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-2_5') { |
|
| 1358 | + print ' selected="selected"'; |
|
| 1359 | +} |
|
| 1360 | +?>>EGM2008 2.5' (75MB)</option> |
|
| 1361 | + <option value="egm2008-1"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-1') { |
|
| 1362 | + print ' selected="selected"'; |
|
| 1363 | +} |
|
| 1364 | +?>>EGM2008 1' (470MB)</option> |
|
| 1045 | 1365 | </select> |
| 1046 | 1366 | <p class="help-block">The geoid is approximated by an "earth gravity model" (EGM).</p> |
| 1047 | 1367 | </p> |
@@ -1063,7 +1383,12 @@ discard block |
||
| 1063 | 1383 | </p> |
| 1064 | 1384 | <p> |
| 1065 | 1385 | <label for="archivemonths">Generate statistics, delete or put in archive flights older than xx months</label> |
| 1066 | - <input type="number" name="archivemonths" id="archivemonths" value="<?php if (isset($globalArchiveMonths)) print $globalArchiveMonths; else echo '1'; ?>" /> |
|
| 1386 | + <input type="number" name="archivemonths" id="archivemonths" value="<?php if (isset($globalArchiveMonths)) { |
|
| 1387 | + print $globalArchiveMonths; |
|
| 1388 | +} else { |
|
| 1389 | + echo '1'; |
|
| 1390 | +} |
|
| 1391 | +?>" /> |
|
| 1067 | 1392 | <p class="help-block">0 to disable, delete old flight if <i>Archive all flights data</i> is disabled</p> |
| 1068 | 1393 | </p> |
| 1069 | 1394 | <p> |
@@ -1073,12 +1398,22 @@ discard block |
||
| 1073 | 1398 | </p> |
| 1074 | 1399 | <p> |
| 1075 | 1400 | <label for="archivekeepmonths">Keep flights data for xx months in archive</label> |
| 1076 | - <input type="number" name="archivekeepmonths" id="archivekeepmonths" value="<?php if (isset($globalArchiveKeepMonths)) print $globalArchiveKeepMonths; else echo '1'; ?>" /> |
|
| 1401 | + <input type="number" name="archivekeepmonths" id="archivekeepmonths" value="<?php if (isset($globalArchiveKeepMonths)) { |
|
| 1402 | + print $globalArchiveKeepMonths; |
|
| 1403 | +} else { |
|
| 1404 | + echo '1'; |
|
| 1405 | +} |
|
| 1406 | +?>" /> |
|
| 1077 | 1407 | <p class="help-block">0 to disable</p> |
| 1078 | 1408 | </p> |
| 1079 | 1409 | <p> |
| 1080 | 1410 | <label for="archivekeeptrackmonths">Keep flights track data for xx months in archive</label> |
| 1081 | - <input type="number" name="archivekeeptrackmonths" id="archivekeeptrackmonths" value="<?php if (isset($globalArchiveKeepTrackMonths)) print $globalArchiveKeepTrackMonths; else echo '1'; ?>" /> |
|
| 1411 | + <input type="number" name="archivekeeptrackmonths" id="archivekeeptrackmonths" value="<?php if (isset($globalArchiveKeepTrackMonths)) { |
|
| 1412 | + print $globalArchiveKeepTrackMonths; |
|
| 1413 | +} else { |
|
| 1414 | + echo '1'; |
|
| 1415 | +} |
|
| 1416 | +?>" /> |
|
| 1082 | 1417 | <p class="help-block">0 to disable, should be less or egal to <i>Keep flights data</i> value</p> |
| 1083 | 1418 | </p> |
| 1084 | 1419 | <br /> |
@@ -1088,7 +1423,12 @@ discard block |
||
| 1088 | 1423 | <p class="help-block">Uncheck if the script is running as cron job. You should always run it as daemon when it's possible.</p> |
| 1089 | 1424 | <div id="cronends"> |
| 1090 | 1425 | <label for="cronend">Run script for xx seconds</label> |
| 1091 | - <input type="number" name="cronend" id="cronend" value="<?php if (isset($globalCronEnd)) print $globalCronEnd; else print '0'; ?>" /> |
|
| 1426 | + <input type="number" name="cronend" id="cronend" value="<?php if (isset($globalCronEnd)) { |
|
| 1427 | + print $globalCronEnd; |
|
| 1428 | +} else { |
|
| 1429 | + print '0'; |
|
| 1430 | +} |
|
| 1431 | +?>" /> |
|
| 1092 | 1432 | <p class="help-block">Set to 0 to disable. Should be disabled if source is URL.</p> |
| 1093 | 1433 | </div> |
| 1094 | 1434 | </p> |
@@ -1147,20 +1487,40 @@ discard block |
||
| 1147 | 1487 | <br /> |
| 1148 | 1488 | <p> |
| 1149 | 1489 | <label for="refresh">Show flights detected since xxx seconds</label> |
| 1150 | - <input type="number" name="refresh" id="refresh" value="<?php if (isset($globalLiveInterval)) echo $globalLiveInterval; else echo '200'; ?>" /> |
|
| 1490 | + <input type="number" name="refresh" id="refresh" value="<?php if (isset($globalLiveInterval)) { |
|
| 1491 | + echo $globalLiveInterval; |
|
| 1492 | +} else { |
|
| 1493 | + echo '200'; |
|
| 1494 | +} |
|
| 1495 | +?>" /> |
|
| 1151 | 1496 | </p> |
| 1152 | 1497 | <p> |
| 1153 | 1498 | <label for="maprefresh">Live map refresh (in seconds)</label> |
| 1154 | - <input type="number" name="maprefresh" id="maprefresh" value="<?php if (isset($globalMapRefresh)) echo $globalMapRefresh; else echo '30'; ?>" /> |
|
| 1499 | + <input type="number" name="maprefresh" id="maprefresh" value="<?php if (isset($globalMapRefresh)) { |
|
| 1500 | + echo $globalMapRefresh; |
|
| 1501 | +} else { |
|
| 1502 | + echo '30'; |
|
| 1503 | +} |
|
| 1504 | +?>" /> |
|
| 1155 | 1505 | </p> |
| 1156 | 1506 | <p> |
| 1157 | 1507 | <label for="mapidle">Map idle timeout (in minutes)</label> |
| 1158 | - <input type="number" name="mapidle" id="mapidle" value="<?php if (isset($globalMapIdleTimeout)) echo $globalMapIdleTimeout; else echo '30'; ?>" /> |
|
| 1508 | + <input type="number" name="mapidle" id="mapidle" value="<?php if (isset($globalMapIdleTimeout)) { |
|
| 1509 | + echo $globalMapIdleTimeout; |
|
| 1510 | +} else { |
|
| 1511 | + echo '30'; |
|
| 1512 | +} |
|
| 1513 | +?>" /> |
|
| 1159 | 1514 | <p class="help-block">0 to disable</p> |
| 1160 | 1515 | </p> |
| 1161 | 1516 | <p> |
| 1162 | 1517 | <label for="minfetch">HTTP/file source fetch every xxx seconds</label> |
| 1163 | - <input type="number" name="minfetch" id="minfetch" value="<?php if (isset($globalMinFetch)) echo $globalMinFetch; else echo '20'; ?>" /> |
|
| 1518 | + <input type="number" name="minfetch" id="minfetch" value="<?php if (isset($globalMinFetch)) { |
|
| 1519 | + echo $globalMinFetch; |
|
| 1520 | +} else { |
|
| 1521 | + echo '20'; |
|
| 1522 | +} |
|
| 1523 | +?>" /> |
|
| 1164 | 1524 | </p> |
| 1165 | 1525 | <p> |
| 1166 | 1526 | <label for="bbox">Only display flights that we can see on screen (bounding box)</label> |
@@ -1179,12 +1539,20 @@ discard block |
||
| 1179 | 1539 | <br /> |
| 1180 | 1540 | <p> |
| 1181 | 1541 | <label for="closestmindist">Distance to airport set as arrival (in km)</label> |
| 1182 | - <input type="number" name="closestmindist" id="closestmindist" value="<?php if (isset($globalClosestMinDist)) echo $globalClosestMinDist; else echo '50'; ?>" /> |
|
| 1542 | + <input type="number" name="closestmindist" id="closestmindist" value="<?php if (isset($globalClosestMinDist)) { |
|
| 1543 | + echo $globalClosestMinDist; |
|
| 1544 | +} else { |
|
| 1545 | + echo '50'; |
|
| 1546 | +} |
|
| 1547 | +?>" /> |
|
| 1183 | 1548 | </p> |
| 1184 | 1549 | <br /> |
| 1185 | 1550 | <p> |
| 1186 | 1551 | <label for="aircraftsize">Size of aircraft icon on map (default to 30px if zoom > 7 else 15px), empty to default</label> |
| 1187 | - <input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) echo $globalAircraftSize;?>" /> |
|
| 1552 | + <input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) { |
|
| 1553 | + echo $globalAircraftSize; |
|
| 1554 | +} |
|
| 1555 | +?>" /> |
|
| 1188 | 1556 | </p> |
| 1189 | 1557 | <br /> |
| 1190 | 1558 | <p> |
@@ -1203,22 +1571,42 @@ discard block |
||
| 1203 | 1571 | <br /> |
| 1204 | 1572 | <p> |
| 1205 | 1573 | <label for="aircrafticoncolor">Color of aircraft icon on map</label> |
| 1206 | - <input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) echo $globalAircraftIconColor; else echo '1a3151'; ?>" /> |
|
| 1574 | + <input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) { |
|
| 1575 | + echo $globalAircraftIconColor; |
|
| 1576 | +} else { |
|
| 1577 | + echo '1a3151'; |
|
| 1578 | +} |
|
| 1579 | +?>" /> |
|
| 1207 | 1580 | </p> |
| 1208 | 1581 | <br /> |
| 1209 | 1582 | <p> |
| 1210 | 1583 | <label for="marineiconcolor">Color of marine icon on map</label> |
| 1211 | - <input type="color" name="marineiconcolor" id="marineiconcolor" value="#<?php if (isset($globalMarineIconColor)) echo $globalMarineIconColor; else echo '43d1d8'; ?>" /> |
|
| 1584 | + <input type="color" name="marineiconcolor" id="marineiconcolor" value="#<?php if (isset($globalMarineIconColor)) { |
|
| 1585 | + echo $globalMarineIconColor; |
|
| 1586 | +} else { |
|
| 1587 | + echo '43d1d8'; |
|
| 1588 | +} |
|
| 1589 | +?>" /> |
|
| 1212 | 1590 | </p> |
| 1213 | 1591 | <br /> |
| 1214 | 1592 | <p> |
| 1215 | 1593 | <label for="trackericoncolor">Color of tracker icon on map</label> |
| 1216 | - <input type="color" name="trackericoncolor" id="trackericoncolor" value="#<?php if (isset($globalTrackerIconColor)) echo $globalTrackerIconColor; else echo '1a3151'; ?>" /> |
|
| 1594 | + <input type="color" name="trackericoncolor" id="trackericoncolor" value="#<?php if (isset($globalTrackerIconColor)) { |
|
| 1595 | + echo $globalTrackerIconColor; |
|
| 1596 | +} else { |
|
| 1597 | + echo '1a3151'; |
|
| 1598 | +} |
|
| 1599 | +?>" /> |
|
| 1217 | 1600 | </p> |
| 1218 | 1601 | <br /> |
| 1219 | 1602 | <p> |
| 1220 | 1603 | <label for="satelliteiconcolor">Color of satellite icon on map</label> |
| 1221 | - <input type="color" name="satelliteiconcolor" id="satelliteiconcolor" value="#<?php if (isset($globalSatelliteIconColor)) echo $globalSatelliteIconColor; else echo '1a3151'; ?>" /> |
|
| 1604 | + <input type="color" name="satelliteiconcolor" id="satelliteiconcolor" value="#<?php if (isset($globalSatelliteIconColor)) { |
|
| 1605 | + echo $globalSatelliteIconColor; |
|
| 1606 | +} else { |
|
| 1607 | + echo '1a3151'; |
|
| 1608 | +} |
|
| 1609 | +?>" /> |
|
| 1222 | 1610 | </p> |
| 1223 | 1611 | <?php |
| 1224 | 1612 | if (!is_writable('../cache')) { |
@@ -1242,14 +1630,27 @@ discard block |
||
| 1242 | 1630 | <p> |
| 1243 | 1631 | <label for="airportzoom">Zoom level minimum to see airports icons</label> |
| 1244 | 1632 | <div class="range"> |
| 1245 | - <input type="range" name="airportzoom" id="airportzoom" value="<?php if (isset($globalAirportZoom)) echo $globalAirportZoom; else echo '7'; ?>" /> |
|
| 1246 | - <output id="range"><?php if (isset($globalAirportZoom)) echo $globalAirportZoom; else echo '7'; ?></output> |
|
| 1633 | + <input type="range" name="airportzoom" id="airportzoom" value="<?php if (isset($globalAirportZoom)) { |
|
| 1634 | + echo $globalAirportZoom; |
|
| 1635 | +} else { |
|
| 1636 | + echo '7'; |
|
| 1637 | +} |
|
| 1638 | +?>" /> |
|
| 1639 | + <output id="range"><?php if (isset($globalAirportZoom)) { |
|
| 1640 | + echo $globalAirportZoom; |
|
| 1641 | +} else { |
|
| 1642 | + echo '7'; |
|
| 1643 | +} |
|
| 1644 | +?></output> |
|
| 1247 | 1645 | </div> |
| 1248 | 1646 | </p> |
| 1249 | 1647 | <br /> |
| 1250 | 1648 | <p> |
| 1251 | 1649 | <label for="customcss">Custom CSS web path</label> |
| 1252 | - <input type="text" name="customcss" id="customcss" value="<?php if (isset($globalCustomCSS)) echo $globalCustomCSS; ?>" /> |
|
| 1650 | + <input type="text" name="customcss" id="customcss" value="<?php if (isset($globalCustomCSS)) { |
|
| 1651 | + echo $globalCustomCSS; |
|
| 1652 | +} |
|
| 1653 | +?>" /> |
|
| 1253 | 1654 | </p> |
| 1254 | 1655 | </fieldset> |
| 1255 | 1656 | <input type="submit" name="submit" value="Create/Update database & write setup" /> |
@@ -1279,8 +1680,12 @@ discard block |
||
| 1279 | 1680 | $dbhost = filter_input(INPUT_POST,'dbhost',FILTER_SANITIZE_STRING); |
| 1280 | 1681 | $dbport = filter_input(INPUT_POST,'dbport',FILTER_SANITIZE_STRING); |
| 1281 | 1682 | |
| 1282 | - if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) $error .= 'Mysql driver for PDO must be loaded'; |
|
| 1283 | - if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) $error .= 'PosgreSQL driver for PDO must be loaded'; |
|
| 1683 | + if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) { |
|
| 1684 | + $error .= 'Mysql driver for PDO must be loaded'; |
|
| 1685 | + } |
|
| 1686 | + if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) { |
|
| 1687 | + $error .= 'PosgreSQL driver for PDO must be loaded'; |
|
| 1688 | + } |
|
| 1284 | 1689 | |
| 1285 | 1690 | $_SESSION['database_root'] = $dbroot; |
| 1286 | 1691 | $_SESSION['database_rootpass'] = $dbrootpass; |
@@ -1359,15 +1764,23 @@ discard block |
||
| 1359 | 1764 | $source_city = $_POST['source_city']; |
| 1360 | 1765 | $source_country = $_POST['source_country']; |
| 1361 | 1766 | $source_ref = $_POST['source_ref']; |
| 1362 | - if (isset($source_id)) $source_id = $_POST['source_id']; |
|
| 1363 | - else $source_id = array(); |
|
| 1767 | + if (isset($source_id)) { |
|
| 1768 | + $source_id = $_POST['source_id']; |
|
| 1769 | + } else { |
|
| 1770 | + $source_id = array(); |
|
| 1771 | + } |
|
| 1364 | 1772 | |
| 1365 | 1773 | $sources = array(); |
| 1366 | 1774 | foreach ($source_name as $keys => $name) { |
| 1367 | - if (isset($source_id[$keys])) $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]); |
|
| 1368 | - else $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]); |
|
| 1775 | + if (isset($source_id[$keys])) { |
|
| 1776 | + $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]); |
|
| 1777 | + } else { |
|
| 1778 | + $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]); |
|
| 1779 | + } |
|
| 1780 | + } |
|
| 1781 | + if (count($sources) > 0) { |
|
| 1782 | + $_SESSION['sources'] = $sources; |
|
| 1369 | 1783 | } |
| 1370 | - if (count($sources) > 0) $_SESSION['sources'] = $sources; |
|
| 1371 | 1784 | |
| 1372 | 1785 | $newsurl = $_POST['newsurl']; |
| 1373 | 1786 | $newslng = $_POST['newslang']; |
@@ -1380,7 +1793,9 @@ discard block |
||
| 1380 | 1793 | $lng = $newslng[$newskey]; |
| 1381 | 1794 | if (isset($newsfeeds[$type][$lng])) { |
| 1382 | 1795 | $newsfeeds[$type][$lng] = array_merge($newsfeeds[$type][$lng],array($url)); |
| 1383 | - } else $newsfeeds[$type][$lng] = array($url); |
|
| 1796 | + } else { |
|
| 1797 | + $newsfeeds[$type][$lng] = array($url); |
|
| 1798 | + } |
|
| 1384 | 1799 | } |
| 1385 | 1800 | } |
| 1386 | 1801 | $settings = array_merge($settings,array('globalNewsFeeds' => $newsfeeds)); |
@@ -1405,17 +1820,29 @@ discard block |
||
| 1405 | 1820 | $datasource = filter_input(INPUT_POST,'datasource',FILTER_SANITIZE_STRING); |
| 1406 | 1821 | |
| 1407 | 1822 | $globalaircraft = filter_input(INPUT_POST,'globalaircraft',FILTER_SANITIZE_STRING); |
| 1408 | - if ($globalaircraft == 'aircraft') $settings = array_merge($settings,array('globalAircraft' => 'TRUE')); |
|
| 1409 | - else $settings = array_merge($settings,array('globalAircraft' => 'FALSE')); |
|
| 1823 | + if ($globalaircraft == 'aircraft') { |
|
| 1824 | + $settings = array_merge($settings,array('globalAircraft' => 'TRUE')); |
|
| 1825 | + } else { |
|
| 1826 | + $settings = array_merge($settings,array('globalAircraft' => 'FALSE')); |
|
| 1827 | + } |
|
| 1410 | 1828 | $globaltracker = filter_input(INPUT_POST,'globaltracker',FILTER_SANITIZE_STRING); |
| 1411 | - if ($globaltracker == 'tracker') $settings = array_merge($settings,array('globalTracker' => 'TRUE')); |
|
| 1412 | - else $settings = array_merge($settings,array('globalTracker' => 'FALSE')); |
|
| 1829 | + if ($globaltracker == 'tracker') { |
|
| 1830 | + $settings = array_merge($settings,array('globalTracker' => 'TRUE')); |
|
| 1831 | + } else { |
|
| 1832 | + $settings = array_merge($settings,array('globalTracker' => 'FALSE')); |
|
| 1833 | + } |
|
| 1413 | 1834 | $globalmarine = filter_input(INPUT_POST,'globalmarine',FILTER_SANITIZE_STRING); |
| 1414 | - if ($globalmarine == 'marine') $settings = array_merge($settings,array('globalMarine' => 'TRUE')); |
|
| 1415 | - else $settings = array_merge($settings,array('globalMarine' => 'FALSE')); |
|
| 1835 | + if ($globalmarine == 'marine') { |
|
| 1836 | + $settings = array_merge($settings,array('globalMarine' => 'TRUE')); |
|
| 1837 | + } else { |
|
| 1838 | + $settings = array_merge($settings,array('globalMarine' => 'FALSE')); |
|
| 1839 | + } |
|
| 1416 | 1840 | $globalsatellite = filter_input(INPUT_POST,'globalsatellite',FILTER_SANITIZE_STRING); |
| 1417 | - if ($globalsatellite == 'satellite') $settings = array_merge($settings,array('globalSatellite' => 'TRUE')); |
|
| 1418 | - else $settings = array_merge($settings,array('globalSatellite' => 'FALSE')); |
|
| 1841 | + if ($globalsatellite == 'satellite') { |
|
| 1842 | + $settings = array_merge($settings,array('globalSatellite' => 'TRUE')); |
|
| 1843 | + } else { |
|
| 1844 | + $settings = array_merge($settings,array('globalSatellite' => 'FALSE')); |
|
| 1845 | + } |
|
| 1419 | 1846 | |
| 1420 | 1847 | /* |
| 1421 | 1848 | $globalSBS1Hosts = array(); |
@@ -1437,23 +1864,37 @@ discard block |
||
| 1437 | 1864 | $name = $_POST['name']; |
| 1438 | 1865 | $format = $_POST['format']; |
| 1439 | 1866 | $timezones = $_POST['timezones']; |
| 1440 | - if (isset($_POST['sourcestats'])) $sourcestats = $_POST['sourcestats']; |
|
| 1441 | - else $sourcestats = array(); |
|
| 1442 | - if (isset($_POST['noarchive'])) $noarchive = $_POST['noarchive']; |
|
| 1443 | - else $noarchive = array(); |
|
| 1867 | + if (isset($_POST['sourcestats'])) { |
|
| 1868 | + $sourcestats = $_POST['sourcestats']; |
|
| 1869 | + } else { |
|
| 1870 | + $sourcestats = array(); |
|
| 1871 | + } |
|
| 1872 | + if (isset($_POST['noarchive'])) { |
|
| 1873 | + $noarchive = $_POST['noarchive']; |
|
| 1874 | + } else { |
|
| 1875 | + $noarchive = array(); |
|
| 1876 | + } |
|
| 1444 | 1877 | $gSources = array(); |
| 1445 | 1878 | $forcepilots = false; |
| 1446 | 1879 | foreach ($host as $key => $h) { |
| 1447 | - if (isset($sourcestats[$key]) && $sourcestats[$key] == 1) $cov = 'TRUE'; |
|
| 1448 | - else $cov = 'FALSE'; |
|
| 1449 | - if (isset($noarchive[$key]) && $noarchive[$key] == 1) $arch = 'TRUE'; |
|
| 1450 | - else $arch = 'FALSE'; |
|
| 1880 | + if (isset($sourcestats[$key]) && $sourcestats[$key] == 1) { |
|
| 1881 | + $cov = 'TRUE'; |
|
| 1882 | + } else { |
|
| 1883 | + $cov = 'FALSE'; |
|
| 1884 | + } |
|
| 1885 | + if (isset($noarchive[$key]) && $noarchive[$key] == 1) { |
|
| 1886 | + $arch = 'TRUE'; |
|
| 1887 | + } else { |
|
| 1888 | + $arch = 'FALSE'; |
|
| 1889 | + } |
|
| 1451 | 1890 | if (strpos($format[$key],'_callback')) { |
| 1452 | 1891 | $gSources[] = array('host' => $h, 'pass' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov,'noarchive' => $arch,'timezone' => $timezones[$key],'callback' => 'TRUE'); |
| 1453 | 1892 | } elseif ($format[$key] != 'auto' || ($h != '' || $name[$key] != '')) { |
| 1454 | 1893 | $gSources[] = array('host' => $h, 'port' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov,'noarchive' => $arch,'timezone' => $timezones[$key],'callback' => 'FALSE'); |
| 1455 | 1894 | } |
| 1456 | - if ($format[$key] == 'airwhere') $forcepilots = true; |
|
| 1895 | + if ($format[$key] == 'airwhere') { |
|
| 1896 | + $forcepilots = true; |
|
| 1897 | + } |
|
| 1457 | 1898 | } |
| 1458 | 1899 | $settings = array_merge($settings,array('globalSources' => $gSources)); |
| 1459 | 1900 | |
@@ -1484,7 +1925,9 @@ discard block |
||
| 1484 | 1925 | $zoidistance = filter_input(INPUT_POST,'zoidistance',FILTER_SANITIZE_NUMBER_INT); |
| 1485 | 1926 | if ($zoilatitude != '' && $zoilongitude != '' && $zoidistance != '') { |
| 1486 | 1927 | $settings = array_merge($settings,array('globalDistanceIgnore' => array('latitude' => $zoilatitude,'longitude' => $zoilongitude,'distance' => $zoidistance))); |
| 1487 | - } else $settings = array_merge($settings,array('globalDistanceIgnore' => array())); |
|
| 1928 | + } else { |
|
| 1929 | + $settings = array_merge($settings,array('globalDistanceIgnore' => array())); |
|
| 1930 | + } |
|
| 1488 | 1931 | |
| 1489 | 1932 | $refresh = filter_input(INPUT_POST,'refresh',FILTER_SANITIZE_NUMBER_INT); |
| 1490 | 1933 | $settings = array_merge($settings,array('globalLiveInterval' => $refresh)); |
@@ -1525,7 +1968,9 @@ discard block |
||
| 1525 | 1968 | |
| 1526 | 1969 | // Create in settings.php keys not yet configurable if not already here |
| 1527 | 1970 | //if (!isset($globalImageBingKey)) $settings = array_merge($settings,array('globalImageBingKey' => '')); |
| 1528 | - if (!isset($globalDebug)) $settings = array_merge($settings,array('globalDebug' => 'TRUE')); |
|
| 1971 | + if (!isset($globalDebug)) { |
|
| 1972 | + $settings = array_merge($settings,array('globalDebug' => 'TRUE')); |
|
| 1973 | + } |
|
| 1529 | 1974 | |
| 1530 | 1975 | $resetyearstats = filter_input(INPUT_POST,'resetyearstats',FILTER_SANITIZE_STRING); |
| 1531 | 1976 | if ($resetyearstats == 'resetyearstats') { |
@@ -1568,37 +2013,56 @@ discard block |
||
| 1568 | 2013 | } |
| 1569 | 2014 | */ |
| 1570 | 2015 | $settings = array_merge($settings,array('globalFlightAware' => 'FALSE')); |
| 1571 | - if ($globalsbs == 'sbs') $settings = array_merge($settings,array('globalSBS1' => 'TRUE')); |
|
| 1572 | - else $settings = array_merge($settings,array('globalSBS1' => 'FALSE')); |
|
| 1573 | - if ($globalaprs == 'aprs') $settings = array_merge($settings,array('globalAPRS' => 'TRUE')); |
|
| 1574 | - else $settings = array_merge($settings,array('globalAPRS' => 'FALSE')); |
|
| 2016 | + if ($globalsbs == 'sbs') { |
|
| 2017 | + $settings = array_merge($settings,array('globalSBS1' => 'TRUE')); |
|
| 2018 | + } else { |
|
| 2019 | + $settings = array_merge($settings,array('globalSBS1' => 'FALSE')); |
|
| 2020 | + } |
|
| 2021 | + if ($globalaprs == 'aprs') { |
|
| 2022 | + $settings = array_merge($settings,array('globalAPRS' => 'TRUE')); |
|
| 2023 | + } else { |
|
| 2024 | + $settings = array_merge($settings,array('globalAPRS' => 'FALSE')); |
|
| 2025 | + } |
|
| 1575 | 2026 | $va = false; |
| 1576 | 2027 | if ($globalivao == 'ivao') { |
| 1577 | 2028 | $settings = array_merge($settings,array('globalIVAO' => 'TRUE')); |
| 1578 | 2029 | $va = true; |
| 1579 | - } else $settings = array_merge($settings,array('globalIVAO' => 'FALSE')); |
|
| 2030 | + } else { |
|
| 2031 | + $settings = array_merge($settings,array('globalIVAO' => 'FALSE')); |
|
| 2032 | + } |
|
| 1580 | 2033 | if ($globalvatsim == 'vatsim') { |
| 1581 | 2034 | $settings = array_merge($settings,array('globalVATSIM' => 'TRUE')); |
| 1582 | 2035 | $va = true; |
| 1583 | - } else $settings = array_merge($settings,array('globalVATSIM' => 'FALSE')); |
|
| 2036 | + } else { |
|
| 2037 | + $settings = array_merge($settings,array('globalVATSIM' => 'FALSE')); |
|
| 2038 | + } |
|
| 1584 | 2039 | if ($globalphpvms == 'phpvms') { |
| 1585 | 2040 | $settings = array_merge($settings,array('globalphpVMS' => 'TRUE')); |
| 1586 | 2041 | $va = true; |
| 1587 | - } else $settings = array_merge($settings,array('globalphpVMS' => 'FALSE')); |
|
| 2042 | + } else { |
|
| 2043 | + $settings = array_merge($settings,array('globalphpVMS' => 'FALSE')); |
|
| 2044 | + } |
|
| 1588 | 2045 | if ($globalvam == 'vam') { |
| 1589 | 2046 | $settings = array_merge($settings,array('globalVAM' => 'TRUE')); |
| 1590 | 2047 | $va = true; |
| 1591 | - } else $settings = array_merge($settings,array('globalVAM' => 'FALSE')); |
|
| 2048 | + } else { |
|
| 2049 | + $settings = array_merge($settings,array('globalVAM' => 'FALSE')); |
|
| 2050 | + } |
|
| 1592 | 2051 | if ($va) { |
| 1593 | 2052 | $settings = array_merge($settings,array('globalSchedulesFetch' => 'FALSE','globalTranslationFetch' => 'FALSE')); |
| 1594 | - } else $settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE')); |
|
| 2053 | + } else { |
|
| 2054 | + $settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE')); |
|
| 2055 | + } |
|
| 1595 | 2056 | if ($globalva == 'va' || $va) { |
| 1596 | 2057 | $settings = array_merge($settings,array('globalVA' => 'TRUE')); |
| 1597 | 2058 | $settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE')); |
| 1598 | 2059 | } else { |
| 1599 | 2060 | $settings = array_merge($settings,array('globalVA' => 'FALSE')); |
| 1600 | - if ($forcepilots) $settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE')); |
|
| 1601 | - else $settings = array_merge($settings,array('globalUsePilot' => 'FALSE','globalUseOwner' => 'TRUE')); |
|
| 2061 | + if ($forcepilots) { |
|
| 2062 | + $settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE')); |
|
| 2063 | + } else { |
|
| 2064 | + $settings = array_merge($settings,array('globalUsePilot' => 'FALSE','globalUseOwner' => 'TRUE')); |
|
| 2065 | + } |
|
| 1602 | 2066 | } |
| 1603 | 2067 | if ($globalvm == 'vm') { |
| 1604 | 2068 | $settings = array_merge($settings,array('globalVM' => 'TRUE')); |
@@ -1858,7 +2322,9 @@ discard block |
||
| 1858 | 2322 | $graphhopper = filter_input(INPUT_POST,'graphhopper',FILTER_SANITIZE_STRING); |
| 1859 | 2323 | $settings = array_merge($settings,array('globalGraphHopperKey' => $graphhopper)); |
| 1860 | 2324 | |
| 1861 | - if (!isset($globalTransaction)) $settings = array_merge($settings,array('globalTransaction' => 'TRUE')); |
|
| 2325 | + if (!isset($globalTransaction)) { |
|
| 2326 | + $settings = array_merge($settings,array('globalTransaction' => 'TRUE')); |
|
| 2327 | + } |
|
| 1862 | 2328 | |
| 1863 | 2329 | // Set some defaults values... |
| 1864 | 2330 | if (!isset($globalAircraftImageSources)) { |
@@ -1873,15 +2339,23 @@ discard block |
||
| 1873 | 2339 | |
| 1874 | 2340 | $settings = array_merge($settings,array('globalInstalled' => 'TRUE')); |
| 1875 | 2341 | |
| 1876 | - if ($error == '') settings::modify_settings($settings); |
|
| 1877 | - if ($error == '') settings::comment_settings($settings_comment); |
|
| 2342 | + if ($error == '') { |
|
| 2343 | + settings::modify_settings($settings); |
|
| 2344 | + } |
|
| 2345 | + if ($error == '') { |
|
| 2346 | + settings::comment_settings($settings_comment); |
|
| 2347 | + } |
|
| 1878 | 2348 | if ($error != '') { |
| 1879 | 2349 | print '<div class="info column">'.$error.'</div>'; |
| 1880 | 2350 | require('../footer.php'); |
| 1881 | 2351 | exit; |
| 1882 | 2352 | } else { |
| 1883 | - if (isset($_POST['waypoints']) && $_POST['waypoints'] == 'waypoints') $_SESSION['waypoints'] = 1; |
|
| 1884 | - if (isset($_POST['owner']) && $_POST['owner'] == 'owner') $_SESSION['owner'] = 1; |
|
| 2353 | + if (isset($_POST['waypoints']) && $_POST['waypoints'] == 'waypoints') { |
|
| 2354 | + $_SESSION['waypoints'] = 1; |
|
| 2355 | + } |
|
| 2356 | + if (isset($_POST['owner']) && $_POST['owner'] == 'owner') { |
|
| 2357 | + $_SESSION['owner'] = 1; |
|
| 2358 | + } |
|
| 1885 | 2359 | if (isset($_POST['createdb'])) { |
| 1886 | 2360 | $_SESSION['install'] = 'database_create'; |
| 1887 | 2361 | } else { |
@@ -1918,10 +2392,18 @@ discard block |
||
| 1918 | 2392 | $popw = false; |
| 1919 | 2393 | foreach ($_SESSION['done'] as $done) { |
| 1920 | 2394 | print '<li>'.$done.'....<strong>SUCCESS</strong></li>'; |
| 1921 | - if ($done == 'Create database') $pop = true; |
|
| 1922 | - if ($_SESSION['install'] == 'database_create') $pop = true; |
|
| 1923 | - if ($_SESSION['install'] == 'database_import') $popi = true; |
|
| 1924 | - if ($_SESSION['install'] == 'waypoints') $popw = true; |
|
| 2395 | + if ($done == 'Create database') { |
|
| 2396 | + $pop = true; |
|
| 2397 | + } |
|
| 2398 | + if ($_SESSION['install'] == 'database_create') { |
|
| 2399 | + $pop = true; |
|
| 2400 | + } |
|
| 2401 | + if ($_SESSION['install'] == 'database_import') { |
|
| 2402 | + $popi = true; |
|
| 2403 | + } |
|
| 2404 | + if ($_SESSION['install'] == 'waypoints') { |
|
| 2405 | + $popw = true; |
|
| 2406 | + } |
|
| 1925 | 2407 | } |
| 1926 | 2408 | if ($pop) { |
| 1927 | 2409 | sleep(5); |
@@ -1932,7 +2414,9 @@ discard block |
||
| 1932 | 2414 | } else if ($popw) { |
| 1933 | 2415 | sleep(5); |
| 1934 | 2416 | print '<li>Populate waypoints database....<img src="../images/loading.gif" /></li>'; |
| 1935 | - } else print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>'; |
|
| 2417 | + } else { |
|
| 2418 | + print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>'; |
|
| 2419 | + } |
|
| 1936 | 2420 | print '</div></ul>'; |
| 1937 | 2421 | print '<div id="error"></div>'; |
| 1938 | 2422 | /* foreach ($_SESSION['done'] as $done) { |
@@ -16,7 +16,9 @@ discard block |
||
| 16 | 16 | public function __construct($dbc = null) { |
| 17 | 17 | $Connection = new Connection($dbc); |
| 18 | 18 | $this->db = $Connection->db(); |
| 19 | - if ($this->db === null) die('Error: No DB connection. (MarineLive)'); |
|
| 19 | + if ($this->db === null) { |
|
| 20 | + die('Error: No DB connection. (MarineLive)'); |
|
| 21 | + } |
|
| 20 | 22 | } |
| 21 | 23 | |
| 22 | 24 | |
@@ -40,7 +42,9 @@ discard block |
||
| 40 | 42 | if (isset($filter[0]['source'])) { |
| 41 | 43 | $filters = array_merge($filters,$filter); |
| 42 | 44 | } |
| 43 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 45 | + if (is_array($globalFilter)) { |
|
| 46 | + $filter = array_merge($filter,$globalFilter); |
|
| 47 | + } |
|
| 44 | 48 | $filter_query_join = ''; |
| 45 | 49 | $filter_query_where = ''; |
| 46 | 50 | foreach($filters as $flt) { |
@@ -96,8 +100,11 @@ discard block |
||
| 96 | 100 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 97 | 101 | $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
| 98 | 102 | } |
| 99 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
| 100 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
| 103 | + if ($filter_query_where == '' && $where) { |
|
| 104 | + $filter_query_where = ' WHERE'; |
|
| 105 | + } elseif ($filter_query_where != '' && $and) { |
|
| 106 | + $filter_query_where .= ' AND'; |
|
| 107 | + } |
|
| 101 | 108 | if ($filter_query_where != '') { |
| 102 | 109 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
| 103 | 110 | } |
@@ -140,9 +147,13 @@ discard block |
||
| 140 | 147 | $orderby_query = ' '.$search_orderby_array[$sort]['sql']; |
| 141 | 148 | } |
| 142 | 149 | } |
| 143 | - if ($orderby_query == '') $orderby_query= ' ORDER BY date DESC'; |
|
| 150 | + if ($orderby_query == '') { |
|
| 151 | + $orderby_query= ' ORDER BY date DESC'; |
|
| 152 | + } |
|
| 144 | 153 | |
| 145 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 154 | + if (!isset($globalLiveInterval)) { |
|
| 155 | + $globalLiveInterval = '200'; |
|
| 156 | + } |
|
| 146 | 157 | if ($globalDBdriver == 'mysql') { |
| 147 | 158 | //$query = "SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate"; |
| 148 | 159 | $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate'.$filter_query.$orderby_query; |
@@ -167,7 +178,9 @@ discard block |
||
| 167 | 178 | |
| 168 | 179 | $filter_query = $this->getFilter($filter,true,true); |
| 169 | 180 | |
| 170 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 181 | + if (!isset($globalLiveInterval)) { |
|
| 182 | + $globalLiveInterval = '200'; |
|
| 183 | + } |
|
| 171 | 184 | if ($globalDBdriver == 'mysql') { |
| 172 | 185 | $query = 'SELECT marine_live.mmsi, marine_live.ident, marine_live.type,marine_live.fammarine_id, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name, marine_live.race_id, marine_live.race_rank, marine_live.race_name |
| 173 | 186 | FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate'.$filter_query." marine_live.latitude <> 0 AND marine_live.longitude <> 0 ORDER BY marine_live.race_rank"; |
@@ -212,58 +225,96 @@ discard block |
||
| 212 | 225 | $id = filter_var($id,FILTER_SANITIZE_STRING); |
| 213 | 226 | $filter_query = $this->getFilter($filter,true,true); |
| 214 | 227 | |
| 215 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 216 | - if (!isset($globalMap3DMarinesLimit) || $globalMap3DMarinesLimit == '') $globalMap3DMarinesLimit = '300'; |
|
| 228 | + if (!isset($globalLiveInterval)) { |
|
| 229 | + $globalLiveInterval = '200'; |
|
| 230 | + } |
|
| 231 | + if (!isset($globalMap3DMarinesLimit) || $globalMap3DMarinesLimit == '') { |
|
| 232 | + $globalMap3DMarinesLimit = '300'; |
|
| 233 | + } |
|
| 217 | 234 | if ($globalDBdriver == 'mysql') { |
| 218 | 235 | if (isset($globalArchive) && $globalArchive === TRUE) { |
| 219 | 236 | $query = 'SELECT * FROM (SELECT marine_archive.ident, marine_archive.fammarine_id,marine_archive.type_id,marine_archive.type, marine_archive.latitude, marine_archive.longitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.date, marine_archive.format_source, marine_archive.captain_name, marine_archive.race_id, marine_archive.race_rank, marine_archive.race_name |
| 220 | 237 | FROM marine_archive INNER JOIN (SELECT fammarine_id FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date) l ON l.fammarine_id = marine_archive.fammarine_id "; |
| 221 | - if ($usecoord) $query .= "AND marine_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
| 222 | - if ($id != '') $query .= "OR marine_archive.fammarine_id = :id "; |
|
| 238 | + if ($usecoord) { |
|
| 239 | + $query .= "AND marine_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
| 240 | + } |
|
| 241 | + if ($id != '') { |
|
| 242 | + $query .= "OR marine_archive.fammarine_id = :id "; |
|
| 243 | + } |
|
| 223 | 244 | $query .= "UNION |
| 224 | 245 | SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name, marine_live.race_id, marine_live.race_rank, marine_live.race_name |
| 225 | 246 | FROM marine_live".$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date"; |
| 226 | - if ($usecoord) $query .= " AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong; |
|
| 227 | - if ($id != '') $query .= "OR marine_live.fammarine_id = :id "; |
|
| 247 | + if ($usecoord) { |
|
| 248 | + $query .= " AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong; |
|
| 249 | + } |
|
| 250 | + if ($id != '') { |
|
| 251 | + $query .= "OR marine_live.fammarine_id = :id "; |
|
| 252 | + } |
|
| 228 | 253 | $query .= ") AS marine |
| 229 | 254 | WHERE latitude <> '0' AND longitude <> '0' |
| 230 | 255 | ORDER BY fammarine_id, date"; |
| 231 | - if ($limit) $query .= " LIMIT ".$globalMap3DMarinesLimit; |
|
| 256 | + if ($limit) { |
|
| 257 | + $query .= " LIMIT ".$globalMap3DMarinesLimit; |
|
| 258 | + } |
|
| 232 | 259 | } else { |
| 233 | 260 | $query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name, marine_live.race_id, marine_live.race_rank, marine_live.race_name |
| 234 | 261 | FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date "; |
| 235 | - if ($usecoord) $query .= "AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
| 236 | - if ($id != '') $query .= "OR marine_live.fammarine_id = :id "; |
|
| 262 | + if ($usecoord) { |
|
| 263 | + $query .= "AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
| 264 | + } |
|
| 265 | + if ($id != '') { |
|
| 266 | + $query .= "OR marine_live.fammarine_id = :id "; |
|
| 267 | + } |
|
| 237 | 268 | $query .= "AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' |
| 238 | 269 | ORDER BY marine_live.fammarine_id, marine_live.date"; |
| 239 | - if ($limit) $query .= " LIMIT ".$globalMap3DMarinesLimit; |
|
| 270 | + if ($limit) { |
|
| 271 | + $query .= " LIMIT ".$globalMap3DMarinesLimit; |
|
| 272 | + } |
|
| 240 | 273 | } |
| 241 | 274 | } else { |
| 242 | 275 | if (isset($globalArchive) && $globalArchive === TRUE) { |
| 243 | 276 | $query = "SELECT * FROM (SELECT marine_archive.ident, marine_archive.fammarine_id, marine_archive.type_id, marine_archive.type,marine_archive.latitude, marine_archive.longitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.date, marine_archive.format_source, marine_archive.captain_name, marine_archive.race_id, marine_archive.race_rank, marine_archive.race_name |
| 244 | 277 | FROM marine_archive INNER JOIN (SELECT fammarine_id FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date) l ON l.fammarine_id = marine_archive.fammarine_id "; |
| 245 | - if ($usecoord) $query .= "AND (marine_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_archive.longitude BETWEEN ".$minlong." AND ".$maxlong.") "; |
|
| 246 | - if ($id != '') $query .= "OR marine_archive.fammarine_id = :id "; |
|
| 278 | + if ($usecoord) { |
|
| 279 | + $query .= "AND (marine_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_archive.longitude BETWEEN ".$minlong." AND ".$maxlong.") "; |
|
| 280 | + } |
|
| 281 | + if ($id != '') { |
|
| 282 | + $query .= "OR marine_archive.fammarine_id = :id "; |
|
| 283 | + } |
|
| 247 | 284 | $query .= "UNION |
| 248 | 285 | SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name, marine_live.race_id, marine_live.race_rank, marine_live.race_name |
| 249 | 286 | FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date"; |
| 250 | - if ($usecoord) $query .= " AND (marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong.")"; |
|
| 251 | - if ($id != '') $query .= " OR marine_live.fammarine_id = :id"; |
|
| 287 | + if ($usecoord) { |
|
| 288 | + $query .= " AND (marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong.")"; |
|
| 289 | + } |
|
| 290 | + if ($id != '') { |
|
| 291 | + $query .= " OR marine_live.fammarine_id = :id"; |
|
| 292 | + } |
|
| 252 | 293 | $query .= ") AS marine WHERE latitude <> '0' AND longitude <> '0' "; |
| 253 | 294 | $query .= "ORDER BY fammarine_id, date"; |
| 254 | - if ($limit) $query .= " LIMIT ".$globalMap3DMarinesLimit; |
|
| 295 | + if ($limit) { |
|
| 296 | + $query .= " LIMIT ".$globalMap3DMarinesLimit; |
|
| 297 | + } |
|
| 255 | 298 | } else { |
| 256 | 299 | $query = "SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name, marine_live.race_id, marine_live.race_rank, marine_live.race_name |
| 257 | 300 | FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date "; |
| 258 | - if ($usecoord) $query .= "AND (marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong.") "; |
|
| 259 | - if ($id != '') $query .= "OR marine_live.fammarine_id = :id "; |
|
| 301 | + if ($usecoord) { |
|
| 302 | + $query .= "AND (marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong.") "; |
|
| 303 | + } |
|
| 304 | + if ($id != '') { |
|
| 305 | + $query .= "OR marine_live.fammarine_id = :id "; |
|
| 306 | + } |
|
| 260 | 307 | $query .= "AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' |
| 261 | 308 | ORDER BY marine_live.fammarine_id, marine_live.date"; |
| 262 | - if ($limit) $query .= " LIMIT ".$globalMap3DMarinesLimit; |
|
| 309 | + if ($limit) { |
|
| 310 | + $query .= " LIMIT ".$globalMap3DMarinesLimit; |
|
| 311 | + } |
|
| 263 | 312 | } |
| 264 | 313 | } |
| 265 | 314 | $query_values = array(); |
| 266 | - if ($id != '') $query_values = array(':id' => $id); |
|
| 315 | + if ($id != '') { |
|
| 316 | + $query_values = array(':id' => $id); |
|
| 317 | + } |
|
| 267 | 318 | try { |
| 268 | 319 | $sth = $this->db->prepare($query); |
| 269 | 320 | $sth->execute($query_values); |
@@ -290,8 +341,12 @@ discard block |
||
| 290 | 341 | $id = filter_var($id,FILTER_SANITIZE_STRING); |
| 291 | 342 | $filter_query = $this->getFilter($filter,true,true); |
| 292 | 343 | |
| 293 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 294 | - if (!isset($globalMap3DMarinesLimit) || $globalMap3DMarinesLimit == '') $globalMap3DMarinesLimit = '300'; |
|
| 344 | + if (!isset($globalLiveInterval)) { |
|
| 345 | + $globalLiveInterval = '200'; |
|
| 346 | + } |
|
| 347 | + if (!isset($globalMap3DMarinesLimit) || $globalMap3DMarinesLimit == '') { |
|
| 348 | + $globalMap3DMarinesLimit = '300'; |
|
| 349 | + } |
|
| 295 | 350 | if ($globalDBdriver == 'mysql') { |
| 296 | 351 | if (isset($globalArchive) && $globalArchive === TRUE) { |
| 297 | 352 | $query = 'SELECT * FROM (SELECT marine_archive.ident, marine_archive.fammarine_id,marine_archive.type_id,marine_archive.type, marine_archive.latitude, marine_archive.longitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.date, marine_archive.format_source, marine_archive.captain_name, marine_archive.race_id, marine_archive.race_rank, marine_archive.race_name |
@@ -302,13 +357,17 @@ discard block |
||
| 302 | 357 | $query .= ") AS marine |
| 303 | 358 | WHERE latitude <> '0' AND longitude <> '0' |
| 304 | 359 | ORDER BY fammarine_id, date"; |
| 305 | - if ($limit) $query .= " LIMIT ".$globalMap3DMarinesLimit; |
|
| 360 | + if ($limit) { |
|
| 361 | + $query .= " LIMIT ".$globalMap3DMarinesLimit; |
|
| 362 | + } |
|
| 306 | 363 | } else { |
| 307 | 364 | $query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name, marine_live.race_id, marine_live.race_rank, marine_live.race_name |
| 308 | 365 | FROM marine_live'.$filter_query.' marine_live.fammarine_id = :id '; |
| 309 | 366 | $query .= "AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' |
| 310 | 367 | ORDER BY marine_live.fammarine_id, marine_live.date"; |
| 311 | - if ($limit) $query .= " LIMIT ".$globalMap3DMarinesLimit; |
|
| 368 | + if ($limit) { |
|
| 369 | + $query .= " LIMIT ".$globalMap3DMarinesLimit; |
|
| 370 | + } |
|
| 312 | 371 | } |
| 313 | 372 | } else { |
| 314 | 373 | if (isset($globalArchive) && $globalArchive === TRUE) { |
@@ -320,13 +379,17 @@ discard block |
||
| 320 | 379 | $query .= ") AS marine |
| 321 | 380 | WHERE latitude <> '0' AND longitude <> '0' |
| 322 | 381 | ORDER BY fammarine_id, date"; |
| 323 | - if ($limit) $query .= " LIMIT ".$globalMap3DMarinesLimit; |
|
| 382 | + if ($limit) { |
|
| 383 | + $query .= " LIMIT ".$globalMap3DMarinesLimit; |
|
| 384 | + } |
|
| 324 | 385 | } else { |
| 325 | 386 | $query = "SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name, marine_live.race_id, marine_live.race_rank, marine_live.race_name |
| 326 | 387 | FROM marine_live".$filter_query." marine_live.fammarine_id = :id "; |
| 327 | 388 | $query .= "AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' |
| 328 | 389 | ORDER BY marine_live.fammarine_id, marine_live.date"; |
| 329 | - if ($limit) $query .= " LIMIT ".$globalMap3DMarinesLimit; |
|
| 390 | + if ($limit) { |
|
| 391 | + $query .= " LIMIT ".$globalMap3DMarinesLimit; |
|
| 392 | + } |
|
| 330 | 393 | } |
| 331 | 394 | } |
| 332 | 395 | $query_values = array(':id' => $id); |
@@ -352,7 +415,9 @@ discard block |
||
| 352 | 415 | global $globalDBdriver, $globalLiveInterval; |
| 353 | 416 | $filter_query = $this->getFilter($filter,true,true); |
| 354 | 417 | |
| 355 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 418 | + if (!isset($globalLiveInterval)) { |
|
| 419 | + $globalLiveInterval = '200'; |
|
| 420 | + } |
|
| 356 | 421 | if ($globalDBdriver == 'mysql') { |
| 357 | 422 | $query = 'SELECT COUNT(DISTINCT marine_live.fammarine_id) as nb FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
| 358 | 423 | } else { |
@@ -381,7 +446,9 @@ discard block |
||
| 381 | 446 | { |
| 382 | 447 | global $globalDBdriver, $globalLiveInterval; |
| 383 | 448 | $Marine = new Marine($this->db); |
| 384 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 449 | + if (!isset($globalLiveInterval)) { |
|
| 450 | + $globalLiveInterval = '200'; |
|
| 451 | + } |
|
| 385 | 452 | $filter_query = $this->getFilter($filter); |
| 386 | 453 | |
| 387 | 454 | if (is_array($coord)) { |
@@ -389,7 +456,9 @@ discard block |
||
| 389 | 456 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 390 | 457 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 391 | 458 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 392 | - } else return array(); |
|
| 459 | + } else { |
|
| 460 | + return array(); |
|
| 461 | + } |
|
| 393 | 462 | if ($globalDBdriver == 'mysql') { |
| 394 | 463 | $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND marine_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY marine_live.fammarine_id ORDER BY date DESC'.$filter_query; |
| 395 | 464 | } else { |
@@ -410,7 +479,9 @@ discard block |
||
| 410 | 479 | { |
| 411 | 480 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
| 412 | 481 | $Marine = new Marine($this->db); |
| 413 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 482 | + if (!isset($globalLiveInterval)) { |
|
| 483 | + $globalLiveInterval = '200'; |
|
| 484 | + } |
|
| 414 | 485 | $filter_query = $this->getFilter($filter,true,true); |
| 415 | 486 | |
| 416 | 487 | if (is_array($coord)) { |
@@ -418,7 +489,9 @@ discard block |
||
| 418 | 489 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 419 | 490 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 420 | 491 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 421 | - } else return array(); |
|
| 492 | + } else { |
|
| 493 | + return array(); |
|
| 494 | + } |
|
| 422 | 495 | /* |
| 423 | 496 | if ($globalDBdriver == 'mysql') { |
| 424 | 497 | $query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
@@ -648,11 +721,15 @@ discard block |
||
| 648 | 721 | //$query = self::$global_query.' WHERE marine_live.fammarine_id = :id ORDER BY date'; |
| 649 | 722 | if ($globalDBdriver == 'mysql') { |
| 650 | 723 | $query = 'SELECT marine_live.* FROM marine_live WHERE marine_live.fammarine_id = :id'; |
| 651 | - if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
| 724 | + if ($liveinterval) { |
|
| 725 | + $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
| 726 | + } |
|
| 652 | 727 | $query .= ' ORDER BY date'; |
| 653 | 728 | } else { |
| 654 | 729 | $query = 'SELECT marine_live.* FROM marine_live WHERE marine_live.fammarine_id = :id'; |
| 655 | - if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
| 730 | + if ($liveinterval) { |
|
| 731 | + $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
| 732 | + } |
|
| 656 | 733 | $query .= ' ORDER BY date'; |
| 657 | 734 | } |
| 658 | 735 | |
@@ -747,7 +824,9 @@ discard block |
||
| 747 | 824 | $i++; |
| 748 | 825 | $j++; |
| 749 | 826 | if ($j == 30) { |
| 750 | - if ($globalDebug) echo "."; |
|
| 827 | + if ($globalDebug) { |
|
| 828 | + echo "."; |
|
| 829 | + } |
|
| 751 | 830 | try { |
| 752 | 831 | |
| 753 | 832 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
@@ -1064,7 +1143,9 @@ discard block |
||
| 1064 | 1143 | { |
| 1065 | 1144 | return false; |
| 1066 | 1145 | } |
| 1067 | - } else return ''; |
|
| 1146 | + } else { |
|
| 1147 | + return ''; |
|
| 1148 | + } |
|
| 1068 | 1149 | |
| 1069 | 1150 | if ($longitude != '') |
| 1070 | 1151 | { |
@@ -1072,7 +1153,9 @@ discard block |
||
| 1072 | 1153 | { |
| 1073 | 1154 | return false; |
| 1074 | 1155 | } |
| 1075 | - } else return ''; |
|
| 1156 | + } else { |
|
| 1157 | + return ''; |
|
| 1158 | + } |
|
| 1076 | 1159 | |
| 1077 | 1160 | |
| 1078 | 1161 | if ($heading != '') |
@@ -1081,7 +1164,9 @@ discard block |
||
| 1081 | 1164 | { |
| 1082 | 1165 | return false; |
| 1083 | 1166 | } |
| 1084 | - } else $heading = 0; |
|
| 1167 | + } else { |
|
| 1168 | + $heading = 0; |
|
| 1169 | + } |
|
| 1085 | 1170 | |
| 1086 | 1171 | if ($groundspeed != '') |
| 1087 | 1172 | { |
@@ -1089,9 +1174,13 @@ discard block |
||
| 1089 | 1174 | { |
| 1090 | 1175 | return false; |
| 1091 | 1176 | } |
| 1092 | - } else $groundspeed = 0; |
|
| 1177 | + } else { |
|
| 1178 | + $groundspeed = 0; |
|
| 1179 | + } |
|
| 1093 | 1180 | date_default_timezone_set('UTC'); |
| 1094 | - if ($date == '') $date = date("Y-m-d H:i:s", time()); |
|
| 1181 | + if ($date == '') { |
|
| 1182 | + $date = date("Y-m-d H:i:s", time()); |
|
| 1183 | + } |
|
| 1095 | 1184 | |
| 1096 | 1185 | |
| 1097 | 1186 | $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
@@ -1118,19 +1207,35 @@ discard block |
||
| 1118 | 1207 | $race_id = filter_var($race_id,FILTER_SANITIZE_STRING); |
| 1119 | 1208 | $race_name = filter_var($race_name,FILTER_SANITIZE_STRING); |
| 1120 | 1209 | $race_rank = filter_var($race_rank,FILTER_SANITIZE_NUMBER_INT); |
| 1121 | - if ($race_rank == '') $race_rank = NULL; |
|
| 1210 | + if ($race_rank == '') { |
|
| 1211 | + $race_rank = NULL; |
|
| 1212 | + } |
|
| 1122 | 1213 | $race_time = filter_var($race_time,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 1123 | - if ($race_time == '') $race_time = NULL; |
|
| 1124 | - if ($typeid == '') $typeid = NULL; |
|
| 1125 | - if ($statusid == '') $statusid = NULL; |
|
| 1126 | - if ($distance == '') $distance = NULL; |
|
| 1214 | + if ($race_time == '') { |
|
| 1215 | + $race_time = NULL; |
|
| 1216 | + } |
|
| 1217 | + if ($typeid == '') { |
|
| 1218 | + $typeid = NULL; |
|
| 1219 | + } |
|
| 1220 | + if ($statusid == '') { |
|
| 1221 | + $statusid = NULL; |
|
| 1222 | + } |
|
| 1223 | + if ($distance == '') { |
|
| 1224 | + $distance = NULL; |
|
| 1225 | + } |
|
| 1127 | 1226 | |
| 1128 | 1227 | //if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
| 1129 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
| 1130 | - if ($arrival_date == '') $arrival_date = NULL; |
|
| 1228 | + if ($heading == '' || $Common->isInteger($heading) === false ) { |
|
| 1229 | + $heading = 0; |
|
| 1230 | + } |
|
| 1231 | + if ($arrival_date == '') { |
|
| 1232 | + $arrival_date = NULL; |
|
| 1233 | + } |
|
| 1131 | 1234 | $query = ''; |
| 1132 | 1235 | if ($globalArchive) { |
| 1133 | - if ($globalDebug) echo '-- Delete previous data -- '; |
|
| 1236 | + if ($globalDebug) { |
|
| 1237 | + echo '-- Delete previous data -- '; |
|
| 1238 | + } |
|
| 1134 | 1239 | $query .= 'DELETE FROM marine_live WHERE fammarine_id = :fammarine_id;'; |
| 1135 | 1240 | } |
| 1136 | 1241 | $query .= 'INSERT INTO marine_live (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,type_id,status,status_id,imo,arrival_port_name,arrival_port_date,captain_id,captain_name,race_id,race_name,distance,race_rank,race_time) |
@@ -1145,10 +1250,14 @@ discard block |
||
| 1145 | 1250 | } |
| 1146 | 1251 | |
| 1147 | 1252 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
| 1148 | - if ($globalDebug) echo '(Add to Marine archive : '; |
|
| 1253 | + if ($globalDebug) { |
|
| 1254 | + echo '(Add to Marine archive : '; |
|
| 1255 | + } |
|
| 1149 | 1256 | $MarineArchive = new MarineArchive($this->db); |
| 1150 | 1257 | $result = $MarineArchive->addMarineArchiveData($fammarine_id, $ident, $latitude, $longitude, $heading, $groundspeed, $date, $putinarchive, $mmsi,$type,$typeid,$imo, $callsign,$arrival_code,$arrival_date,$status,$statusid,$noarchive,$format_source, $source_name, $over_country,$captain_id,$captain_name,$race_id,$race_name,$distance,$race_rank,$race_time); |
| 1151 | - if ($globalDebug) echo $result.')'; |
|
| 1258 | + if ($globalDebug) { |
|
| 1259 | + echo $result.')'; |
|
| 1260 | + } |
|
| 1152 | 1261 | } |
| 1153 | 1262 | return "success"; |
| 1154 | 1263 | } |
@@ -61,7 +61,9 @@ discard block |
||
| 61 | 61 | public function checkAll() { |
| 62 | 62 | global $globalDebug, $globalNoDB, $globalVM; |
| 63 | 63 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 64 | - if ($globalDebug) echo "Update last seen tracked data...\n"; |
|
| 64 | + if ($globalDebug) { |
|
| 65 | + echo "Update last seen tracked data...\n"; |
|
| 66 | + } |
|
| 65 | 67 | foreach ($this->all_tracked as $key => $flight) { |
| 66 | 68 | if (isset($this->all_tracked[$key]['id'])) { |
| 67 | 69 | //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].' '.$this->all_tracked[$key]['longitude']."\n"; |
@@ -71,8 +73,11 @@ discard block |
||
| 71 | 73 | $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime'],$this->all_tracked[$key]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status'],$this->all_tracked[$key]['race_begin']); |
| 72 | 74 | } else { |
| 73 | 75 | $timerace = (strtotime($this->all_tracked[$key]['race_begin'])+$this->all_tracked[$key]['race_time']); |
| 74 | - if ($timerace > time()) $finaldatetime = NULL; |
|
| 75 | - else $finaldatetime = date('Y-m-d H:i:s',$timerace); |
|
| 76 | + if ($timerace > time()) { |
|
| 77 | + $finaldatetime = NULL; |
|
| 78 | + } else { |
|
| 79 | + $finaldatetime = date('Y-m-d H:i:s',$timerace); |
|
| 80 | + } |
|
| 76 | 81 | $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$finaldatetime,$this->all_tracked[$key]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status'],$this->all_tracked[$key]['race_begin']); |
| 77 | 82 | } |
| 78 | 83 | } else { |
@@ -86,13 +91,17 @@ discard block |
||
| 86 | 91 | public function del() { |
| 87 | 92 | global $globalDebug, $globalNoDB, $globalNoImport; |
| 88 | 93 | // Delete old infos |
| 89 | - if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
|
| 94 | + if ($globalDebug) { |
|
| 95 | + echo 'Delete old values and update latest data...'."\n"; |
|
| 96 | + } |
|
| 90 | 97 | foreach ($this->all_tracked as $key => $flight) { |
| 91 | 98 | if (isset($flight['lastupdate'])) { |
| 92 | 99 | if ($flight['lastupdate'] < (time()-3000)) { |
| 93 | 100 | if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
| 94 | 101 | if (isset($this->all_tracked[$key]['id'])) { |
| 95 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
| 102 | + if ($globalDebug) { |
|
| 103 | + echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
| 104 | + } |
|
| 96 | 105 | /* |
| 97 | 106 | $MarineLive = new MarineLive(); |
| 98 | 107 | $MarineLive->deleteLiveMarineDataById($this->all_tracked[$key]['id']); |
@@ -106,14 +115,19 @@ discard block |
||
| 106 | 115 | $result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime'],$this->all_tracked[$key]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status'],$this->all_tracked[$key]['race_begin']); |
| 107 | 116 | } else { |
| 108 | 117 | $timerace = strtotime($this->all_tracked[$key]['race_begin'])+$this->all_tracked[$key]['race_time']; |
| 109 | - if ($timerace > time()) $finaldatetime = NULL; |
|
| 110 | - else $finaldatetime = date('Y-m-d H:i:s',$timerace); |
|
| 118 | + if ($timerace > time()) { |
|
| 119 | + $finaldatetime = NULL; |
|
| 120 | + } else { |
|
| 121 | + $finaldatetime = date('Y-m-d H:i:s',$timerace); |
|
| 122 | + } |
|
| 111 | 123 | $result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$finaldatetime,$this->all_tracked[$key]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status'],$this->all_tracked[$key]['race_begin']); |
| 112 | 124 | } |
| 113 | 125 | } else { |
| 114 | 126 | $result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime'],$this->all_tracked[$key]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status'],$this->all_tracked[$key]['race_begin']); |
| 115 | 127 | } |
| 116 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
| 128 | + if ($globalDebug && $result != 'success') { |
|
| 129 | + echo '!!! ERROR : '.$result."\n"; |
|
| 130 | + } |
|
| 117 | 131 | } |
| 118 | 132 | // Put in archive |
| 119 | 133 | // $Marine->db = null; |
@@ -127,7 +141,9 @@ discard block |
||
| 127 | 141 | |
| 128 | 142 | public function add($line) { |
| 129 | 143 | global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS,$APRSMarine, $globalLiveInterval, $globalVM; |
| 130 | - if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
|
| 144 | + if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') { |
|
| 145 | + $globalCoordMinChange = '0.02'; |
|
| 146 | + } |
|
| 131 | 147 | date_default_timezone_set('UTC'); |
| 132 | 148 | $dataFound = false; |
| 133 | 149 | $send = false; |
@@ -141,20 +157,30 @@ discard block |
||
| 141 | 157 | // Increment message number |
| 142 | 158 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) { |
| 143 | 159 | $current_date = date('Y-m-d'); |
| 144 | - if (isset($line['source_name'])) $source = $line['source_name']; |
|
| 145 | - else $source = ''; |
|
| 146 | - if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
| 160 | + if (isset($line['source_name'])) { |
|
| 161 | + $source = $line['source_name']; |
|
| 162 | + } else { |
|
| 163 | + $source = ''; |
|
| 164 | + } |
|
| 165 | + if ($source == '' || $line['format_source'] == 'aprs') { |
|
| 166 | + $source = $line['format_source']; |
|
| 167 | + } |
|
| 147 | 168 | if (!isset($this->stats[$current_date][$source]['msg'])) { |
| 148 | 169 | $this->stats[$current_date][$source]['msg']['date'] = time(); |
| 149 | 170 | $this->stats[$current_date][$source]['msg']['nb'] = 1; |
| 150 | - } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
| 171 | + } else { |
|
| 172 | + $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
| 173 | + } |
|
| 151 | 174 | } |
| 152 | 175 | |
| 153 | 176 | |
| 154 | 177 | $Common = new Common(); |
| 155 | 178 | $AIS = new AIS(); |
| 156 | - if (!isset($line['id'])) $id = trim($line['mmsi']); |
|
| 157 | - else $id = trim($line['id']); |
|
| 179 | + if (!isset($line['id'])) { |
|
| 180 | + $id = trim($line['mmsi']); |
|
| 181 | + } else { |
|
| 182 | + $id = trim($line['id']); |
|
| 183 | + } |
|
| 158 | 184 | |
| 159 | 185 | if (!isset($this->all_tracked[$id])) { |
| 160 | 186 | $this->all_tracked[$id] = array(); |
@@ -162,10 +188,16 @@ discard block |
||
| 162 | 188 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '0', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','status_id' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '','mmsi_type' => '','captain_id' => '','captain_name' => '','race_id' => '','race_name' => '','distance' => NULL,'race_rank' => NULL,'race_time' => NULL,'race_begin' => '')); |
| 163 | 189 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
| 164 | 190 | if (!isset($line['id'])) { |
| 165 | - if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
| 191 | + if (!isset($globalDaemon)) { |
|
| 192 | + $globalDaemon = TRUE; |
|
| 193 | + } |
|
| 166 | 194 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi'))); |
| 167 | - } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
| 168 | - if ($globalAllTracked !== FALSE) $dataFound = true; |
|
| 195 | + } else { |
|
| 196 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
| 197 | + } |
|
| 198 | + if ($globalAllTracked !== FALSE) { |
|
| 199 | + $dataFound = true; |
|
| 200 | + } |
|
| 169 | 201 | } |
| 170 | 202 | |
| 171 | 203 | if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) { |
@@ -222,7 +254,9 @@ discard block |
||
| 222 | 254 | if (isset($line['arrival_code']) && $line['arrival_code'] != '') { |
| 223 | 255 | if (!isset($this->all_tracked[$id]['arrival_code'])) { |
| 224 | 256 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code'])); |
| 225 | - if ($globalDebug) echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n"; |
|
| 257 | + if ($globalDebug) { |
|
| 258 | + echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n"; |
|
| 259 | + } |
|
| 226 | 260 | if ($this->all_tracked[$id]['addedMarine'] != 0) { |
| 227 | 261 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
| 228 | 262 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
@@ -235,7 +269,9 @@ discard block |
||
| 235 | 269 | } |
| 236 | 270 | } elseif ($this->all_tracked[$id]['arrival_code'] != $line['arrival_code']) { |
| 237 | 271 | $this->all_tracked[$id]['arrival_code'] = $line['arrival_code']; |
| 238 | - if ($globalDebug) echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n"; |
|
| 272 | + if ($globalDebug) { |
|
| 273 | + echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n"; |
|
| 274 | + } |
|
| 239 | 275 | if (!isset($line['id'])) { |
| 240 | 276 | $this->all_tracked[$id]['id'] = $id.'-'.date('YmdHi'); |
| 241 | 277 | $this->all_tracked[$id]['forcenew'] = 1; |
@@ -244,7 +280,9 @@ discard block |
||
| 244 | 280 | } |
| 245 | 281 | } |
| 246 | 282 | if (isset($line['arrival_date']) && $line['arrival_date'] != '') { |
| 247 | - if (strtotime($line['arrival_date']) > time()) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date'])); |
|
| 283 | + if (strtotime($line['arrival_date']) > time()) { |
|
| 284 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date'])); |
|
| 285 | + } |
|
| 248 | 286 | } |
| 249 | 287 | if (isset($line['captain_id']) && $line['captain_id'] != '') { |
| 250 | 288 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('captain_id' => $line['captain_id'])); |
@@ -289,34 +327,49 @@ discard block |
||
| 289 | 327 | $Marine = new Marine($this->db); |
| 290 | 328 | $fromsource = NULL; |
| 291 | 329 | $result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource); |
| 292 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
| 330 | + if ($globalDebug && $result != 'success') { |
|
| 331 | + echo '!!! ERROR : '.$result."\n"; |
|
| 332 | + } |
|
| 293 | 333 | $Marine->db = null; |
| 294 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 334 | + if ($globalDebugTimeElapsed) { |
|
| 335 | + echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 336 | + } |
|
| 295 | 337 | } |
| 296 | 338 | } |
| 297 | 339 | } |
| 298 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
| 340 | + if (!isset($this->all_tracked[$id]['id'])) { |
|
| 341 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
| 342 | + } |
|
| 299 | 343 | } |
| 300 | 344 | |
| 301 | 345 | if (isset($line['datetime']) && strtotime($line['datetime']) > time()-30*60 && strtotime($line['datetime']) < time()+20*60) { |
| 302 | 346 | if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) { |
| 303 | 347 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
| 304 | 348 | } else { |
| 305 | - if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n"; |
|
| 306 | - elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
| 349 | + if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) { |
|
| 350 | + echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n"; |
|
| 351 | + } elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) { |
|
| 352 | + echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
| 353 | + } |
|
| 307 | 354 | return ''; |
| 308 | 355 | } |
| 309 | 356 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) <= time()-30*60) { |
| 310 | - if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n"; |
|
| 357 | + if ($globalDebug) { |
|
| 358 | + echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n"; |
|
| 359 | + } |
|
| 311 | 360 | return ''; |
| 312 | 361 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) >= time()+20*60) { |
| 313 | - if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n"; |
|
| 362 | + if ($globalDebug) { |
|
| 363 | + echo "!!! Date is in the future ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n"; |
|
| 364 | + } |
|
| 314 | 365 | return ''; |
| 315 | 366 | } elseif (!isset($line['datetime'])) { |
| 316 | 367 | date_default_timezone_set('UTC'); |
| 317 | 368 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s'))); |
| 318 | 369 | } else { |
| 319 | - if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['mmsi']." date: ".$line['datetime']." - format : ".$line['format_source']."!!!\n"; |
|
| 370 | + if ($globalDebug) { |
|
| 371 | + echo "!!! Unknow date error ".$this->all_tracked[$id]['mmsi']." date: ".$line['datetime']." - format : ".$line['format_source']."!!!\n"; |
|
| 372 | + } |
|
| 320 | 373 | return ''; |
| 321 | 374 | } |
| 322 | 375 | |
@@ -329,14 +382,21 @@ discard block |
||
| 329 | 382 | if ($distance > 1000 && $distance < 10000) { |
| 330 | 383 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
| 331 | 384 | $speed = $speed*3.6; |
| 332 | - if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed,2))); |
|
| 333 | - if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['id']." : ".$speed." - distance : ".$distance."\n"; |
|
| 385 | + if ($speed < 1000) { |
|
| 386 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed,2))); |
|
| 387 | + } |
|
| 388 | + if ($globalDebug) { |
|
| 389 | + echo "ø Calculated Speed for ".$this->all_tracked[$id]['id']." : ".$speed." - distance : ".$distance."\n"; |
|
| 390 | + } |
|
| 334 | 391 | } |
| 335 | 392 | } |
| 336 | 393 | |
| 337 | 394 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
| 338 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
| 339 | - else unset($timediff); |
|
| 395 | + if (isset($this->all_tracked[$id]['time_last_coord'])) { |
|
| 396 | + $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
| 397 | + } else { |
|
| 398 | + unset($timediff); |
|
| 399 | + } |
|
| 340 | 400 | if ($this->tmd > 5 || |
| 341 | 401 | !isset($timediff) || |
| 342 | 402 | $timediff > $globalLiveInterval || |
@@ -353,22 +413,32 @@ discard block |
||
| 353 | 413 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
| 354 | 414 | $this->all_tracked[$id]['putinarchive'] = true; |
| 355 | 415 | |
| 356 | - if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
| 416 | + if ($globalDebug) { |
|
| 417 | + echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
| 418 | + } |
|
| 357 | 419 | $timeelapsed = microtime(true); |
| 358 | 420 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 359 | 421 | $Marine = new Marine($this->db); |
| 360 | 422 | $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
| 361 | - if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
| 423 | + if (!empty($all_country)) { |
|
| 424 | + $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
| 425 | + } |
|
| 362 | 426 | $Marine->db = null; |
| 363 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 427 | + if ($globalDebugTimeElapsed) { |
|
| 428 | + echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 429 | + } |
|
| 364 | 430 | } |
| 365 | 431 | $this->tmd = 0; |
| 366 | - if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
|
| 432 | + if ($globalDebug) { |
|
| 433 | + echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
|
| 434 | + } |
|
| 367 | 435 | } |
| 368 | 436 | } |
| 369 | 437 | |
| 370 | 438 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
| 371 | - if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
|
| 439 | + if (!isset($this->all_tracked[$id]['archive_latitude'])) { |
|
| 440 | + $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
|
| 441 | + } |
|
| 372 | 442 | if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
| 373 | 443 | $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
| 374 | 444 | $dataFound = true; |
@@ -377,8 +447,12 @@ discard block |
||
| 377 | 447 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
| 378 | 448 | } |
| 379 | 449 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
| 380 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
| 381 | - if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
|
| 450 | + if ($line['longitude'] > 180) { |
|
| 451 | + $line['longitude'] = $line['longitude'] - 360; |
|
| 452 | + } |
|
| 453 | + if (!isset($this->all_tracked[$id]['archive_longitude'])) { |
|
| 454 | + $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
|
| 455 | + } |
|
| 382 | 456 | if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
| 383 | 457 | $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
| 384 | 458 | $dataFound = true; |
@@ -396,7 +470,9 @@ discard block |
||
| 396 | 470 | } |
| 397 | 471 | } |
| 398 | 472 | if (isset($line['last_update']) && $line['last_update'] != '') { |
| 399 | - if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
| 473 | + if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) { |
|
| 474 | + $dataFound = true; |
|
| 475 | + } |
|
| 400 | 476 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
| 401 | 477 | } |
| 402 | 478 | if (isset($line['format_source']) && $line['format_source'] != '') { |
@@ -410,15 +486,21 @@ discard block |
||
| 410 | 486 | } |
| 411 | 487 | |
| 412 | 488 | if (isset($line['heading']) && $line['heading'] != '') { |
| 413 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 489 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) { |
|
| 490 | + $this->all_tracked[$id]['putinarchive'] = true; |
|
| 491 | + } |
|
| 414 | 492 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
| 415 | 493 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
| 416 | 494 | //$dataFound = true; |
| 417 | 495 | } elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) { |
| 418 | 496 | $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
| 419 | 497 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
| 420 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 421 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
| 498 | + if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) { |
|
| 499 | + $this->all_tracked[$id]['putinarchive'] = true; |
|
| 500 | + } |
|
| 501 | + if ($globalDebug) { |
|
| 502 | + echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
| 503 | + } |
|
| 422 | 504 | } |
| 423 | 505 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
| 424 | 506 | |
@@ -430,28 +512,45 @@ discard block |
||
| 430 | 512 | if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
| 431 | 513 | if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
| 432 | 514 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 433 | - if ($globalDebug) echo "Check if vessel is already in DB..."; |
|
| 515 | + if ($globalDebug) { |
|
| 516 | + echo "Check if vessel is already in DB..."; |
|
| 517 | + } |
|
| 434 | 518 | $timeelapsed = microtime(true); |
| 435 | 519 | $MarineLive = new MarineLive($this->db); |
| 436 | 520 | if (isset($line['id']) && isset($globalVM) && $globalVM) { |
| 437 | 521 | $Marine = new Marine($this->db); |
| 438 | 522 | $recent_ident = $Marine->checkId($line['id']); |
| 439 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkId : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 523 | + if ($globalDebugTimeElapsed) { |
|
| 524 | + echo 'Time elapsed for update checkId : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 525 | + } |
|
| 440 | 526 | $Marine->db=null; |
| 441 | 527 | } elseif (isset($line['id'])) { |
| 442 | 528 | $recent_ident = $MarineLive->checkIdRecent($line['id']); |
| 443 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 529 | + if ($globalDebugTimeElapsed) { |
|
| 530 | + echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 531 | + } |
|
| 444 | 532 | } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') { |
| 445 | 533 | $recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']); |
| 446 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 534 | + if ($globalDebugTimeElapsed) { |
|
| 535 | + echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 536 | + } |
|
| 447 | 537 | } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
| 448 | 538 | $recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
| 449 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 450 | - } else $recent_ident = ''; |
|
| 539 | + if ($globalDebugTimeElapsed) { |
|
| 540 | + echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 541 | + } |
|
| 542 | + } else { |
|
| 543 | + $recent_ident = ''; |
|
| 544 | + } |
|
| 451 | 545 | $MarineLive->db=null; |
| 452 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
| 453 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
| 454 | - } else $recent_ident = ''; |
|
| 546 | + if ($globalDebug && $recent_ident == '') { |
|
| 547 | + echo " Not in DB.\n"; |
|
| 548 | + } elseif ($globalDebug && $recent_ident != '') { |
|
| 549 | + echo " Already in DB.\n"; |
|
| 550 | + } |
|
| 551 | + } else { |
|
| 552 | + $recent_ident = ''; |
|
| 553 | + } |
|
| 455 | 554 | } else { |
| 456 | 555 | $recent_ident = ''; |
| 457 | 556 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
@@ -460,12 +559,17 @@ discard block |
||
| 460 | 559 | if($recent_ident == "" && (($this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') || (isset($globalVM) && $globalVM))) |
| 461 | 560 | { |
| 462 | 561 | if ($globalDebug) { |
| 463 | - if ($this->all_tracked[$id]['mmsi'] != '') echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
|
| 464 | - else echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : "; |
|
| 562 | + if ($this->all_tracked[$id]['mmsi'] != '') { |
|
| 563 | + echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
|
| 564 | + } else { |
|
| 565 | + echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : "; |
|
| 566 | + } |
|
| 465 | 567 | } |
| 466 | 568 | //adds the spotter data for the archive |
| 467 | 569 | $highlight = ''; |
| 468 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi'))); |
|
| 570 | + if (!isset($this->all_tracked[$id]['id'])) { |
|
| 571 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi'))); |
|
| 572 | + } |
|
| 469 | 573 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
| 470 | 574 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 471 | 575 | $timeelapsed = microtime(true); |
@@ -476,20 +580,30 @@ discard block |
||
| 476 | 580 | $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['captain_id'],$this->all_tracked[$id]['captain_name'],$this->all_tracked[$id]['race_id'],$this->all_tracked[$id]['race_name'],$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time']); |
| 477 | 581 | } |
| 478 | 582 | $Marine->db = null; |
| 479 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
| 480 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 583 | + if ($globalDebug && isset($result)) { |
|
| 584 | + echo $result."\n"; |
|
| 585 | + } |
|
| 586 | + if ($globalDebugTimeElapsed) { |
|
| 587 | + echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 588 | + } |
|
| 481 | 589 | } |
| 482 | 590 | } |
| 483 | 591 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
| 484 | 592 | // Add source stat in DB |
| 485 | 593 | $Stats = new Stats($this->db); |
| 486 | 594 | if (!empty($this->stats)) { |
| 487 | - if ($globalDebug) echo 'Add source stats : '; |
|
| 595 | + if ($globalDebug) { |
|
| 596 | + echo 'Add source stats : '; |
|
| 597 | + } |
|
| 488 | 598 | foreach($this->stats as $date => $data) { |
| 489 | 599 | foreach($data as $source => $sourced) { |
| 490 | 600 | //print_r($sourced); |
| 491 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date); |
|
| 492 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date); |
|
| 601 | + if (isset($sourced['polar'])) { |
|
| 602 | + echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date); |
|
| 603 | + } |
|
| 604 | + if (isset($sourced['hist'])) { |
|
| 605 | + echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date); |
|
| 606 | + } |
|
| 493 | 607 | if (isset($sourced['msg'])) { |
| 494 | 608 | if (time() - $sourced['msg']['date'] > 10) { |
| 495 | 609 | $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
@@ -502,7 +616,9 @@ discard block |
||
| 502 | 616 | unset($this->stats[$date]); |
| 503 | 617 | } |
| 504 | 618 | } |
| 505 | - if ($globalDebug) echo 'Done'."\n"; |
|
| 619 | + if ($globalDebug) { |
|
| 620 | + echo 'Done'."\n"; |
|
| 621 | + } |
|
| 506 | 622 | } |
| 507 | 623 | $Stats->db = null; |
| 508 | 624 | } |
@@ -512,13 +628,17 @@ discard block |
||
| 512 | 628 | $this->all_tracked[$id]['addedMarine'] = 1; |
| 513 | 629 | //print_r($this->all_tracked[$id]); |
| 514 | 630 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
| 515 | - if ($globalDebug) echo "---- Deleting Live Marine data older than 12 hours..."; |
|
| 631 | + if ($globalDebug) { |
|
| 632 | + echo "---- Deleting Live Marine data older than 12 hours..."; |
|
| 633 | + } |
|
| 516 | 634 | //MarineLive->deleteLiveMarineDataNotUpdated(); |
| 517 | 635 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 518 | 636 | $MarineLive = new MarineLive($this->db); |
| 519 | 637 | $MarineLive->deleteLiveMarineData(); |
| 520 | 638 | $MarineLive->db=null; |
| 521 | - if ($globalDebug) echo " Done\n"; |
|
| 639 | + if ($globalDebug) { |
|
| 640 | + echo " Done\n"; |
|
| 641 | + } |
|
| 522 | 642 | } |
| 523 | 643 | $this->last_delete = time(); |
| 524 | 644 | } |
@@ -534,8 +654,11 @@ discard block |
||
| 534 | 654 | } else { |
| 535 | 655 | //$finaldatetime = date('Y-m-d H:i:s',strtotime($this->all_tracked[$id]['race_begin'])+$this->all_tracked[$id]['race_time']); |
| 536 | 656 | $timerace = (strtotime($this->all_tracked[$id]['race_begin'])+$this->all_tracked[$id]['race_time']); |
| 537 | - if ($timerace > time()) $finaldatetime = NULL; |
|
| 538 | - else $finaldatetime = date('Y-m-d H:i:s',$timerace); |
|
| 657 | + if ($timerace > time()) { |
|
| 658 | + $finaldatetime = NULL; |
|
| 659 | + } else { |
|
| 660 | + $finaldatetime = date('Y-m-d H:i:s',$timerace); |
|
| 661 | + } |
|
| 539 | 662 | |
| 540 | 663 | $Marine->updateLatestMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$this->all_tracked[$id]['speed'],$finaldatetime,$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['race_begin']); |
| 541 | 664 | } |
@@ -554,18 +677,26 @@ discard block |
||
| 554 | 677 | echo 'DATA : ident : '.$this->all_tracked[$id]['ident'].' - type : '.$this->all_tracked[$id]['type'].' - Latitude : '.$this->all_tracked[$id]['latitude'].' - Longitude : '.$this->all_tracked[$id]['longitude'].' - Heading : '.$this->all_tracked[$id]['heading'].' - Speed : '.$this->all_tracked[$id]['speed']."\n"; |
| 555 | 678 | } |
| 556 | 679 | $ignoreImport = false; |
| 557 | - if ((isset($globalVM) && $globalVM) && $this->all_tracked[$id]['status'] == 'sailawayfull' && $this->all_tracked[$id]['status'] != 'Racing') $ignoreImport = true; |
|
| 680 | + if ((isset($globalVM) && $globalVM) && $this->all_tracked[$id]['status'] == 'sailawayfull' && $this->all_tracked[$id]['status'] != 'Racing') { |
|
| 681 | + $ignoreImport = true; |
|
| 682 | + } |
|
| 558 | 683 | if (!$ignoreImport) { |
| 559 | 684 | if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
| 560 | - if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
|
| 685 | + if ($globalDebug) { |
|
| 686 | + echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
|
| 687 | + } |
|
| 561 | 688 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
| 562 | 689 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 563 | 690 | $timeelapsed = microtime(true); |
| 564 | 691 | $MarineLive = new MarineLive($this->db); |
| 565 | 692 | $result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country'],$this->all_tracked[$id]['captain_id'],$this->all_tracked[$id]['captain_name'],$this->all_tracked[$id]['race_id'],$this->all_tracked[$id]['race_name'],$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time']); |
| 566 | 693 | $MarineLive->db = null; |
| 567 | - if ($globalDebug) echo $result."\n"; |
|
| 568 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 694 | + if ($globalDebug) { |
|
| 695 | + echo $result."\n"; |
|
| 696 | + } |
|
| 697 | + if ($globalDebugTimeElapsed) { |
|
| 698 | + echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 699 | + } |
|
| 569 | 700 | } |
| 570 | 701 | } |
| 571 | 702 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) { |
@@ -577,7 +708,9 @@ discard block |
||
| 577 | 708 | |
| 578 | 709 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $line['format_source'] != 'aprs' && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
| 579 | 710 | $source = $this->all_tracked[$id]['source_name']; |
| 580 | - if ($source == '') $source = $this->all_tracked[$id]['format_source']; |
|
| 711 | + if ($source == '') { |
|
| 712 | + $source = $this->all_tracked[$id]['format_source']; |
|
| 713 | + } |
|
| 581 | 714 | if (!isset($this->source_location[$source])) { |
| 582 | 715 | $Location = new Source($this->db); |
| 583 | 716 | $coord = $Location->getLocationInfobySourceName($source); |
@@ -598,7 +731,9 @@ discard block |
||
| 598 | 731 | $stats_heading = round($stats_heading/22.5); |
| 599 | 732 | $stats_distance = $Common->distance($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
| 600 | 733 | $current_date = date('Y-m-d'); |
| 601 | - if ($stats_heading == 16) $stats_heading = 0; |
|
| 734 | + if ($stats_heading == 16) { |
|
| 735 | + $stats_heading = 0; |
|
| 736 | + } |
|
| 602 | 737 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
| 603 | 738 | for ($i=0;$i<=15;$i++) { |
| 604 | 739 | $this->stats[$current_date][$source]['polar'][$i] = 0; |
@@ -616,7 +751,9 @@ discard block |
||
| 616 | 751 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
| 617 | 752 | end($this->stats[$current_date][$source]['hist']); |
| 618 | 753 | $mini = key($this->stats[$current_date][$source]['hist'])+10; |
| 619 | - } else $mini = 0; |
|
| 754 | + } else { |
|
| 755 | + $mini = 0; |
|
| 756 | + } |
|
| 620 | 757 | for ($i=$mini;$i<=$distance;$i+=10) { |
| 621 | 758 | $this->stats[$current_date][$source]['hist'][$i] = 0; |
| 622 | 759 | } |
@@ -628,19 +765,27 @@ discard block |
||
| 628 | 765 | |
| 629 | 766 | |
| 630 | 767 | $this->all_tracked[$id]['lastupdate'] = time(); |
| 631 | - if ($this->all_tracked[$id]['putinarchive']) $send = true; |
|
| 632 | - } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
| 768 | + if ($this->all_tracked[$id]['putinarchive']) { |
|
| 769 | + $send = true; |
|
| 770 | + } |
|
| 771 | + } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) { |
|
| 772 | + echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
| 773 | + } |
|
| 633 | 774 | //$this->del(); |
| 634 | 775 | |
| 635 | 776 | |
| 636 | 777 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
| 637 | 778 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 638 | - if ($globalDebug) echo "---- Deleting Live Marine data Not updated since 2 hour..."; |
|
| 779 | + if ($globalDebug) { |
|
| 780 | + echo "---- Deleting Live Marine data Not updated since 2 hour..."; |
|
| 781 | + } |
|
| 639 | 782 | $MarineLive = new MarineLive($this->db); |
| 640 | 783 | $MarineLive->deleteLiveMarineDataNotUpdated(); |
| 641 | 784 | $MarineLive->db = null; |
| 642 | 785 | //MarineLive->deleteLiveMarineData(); |
| 643 | - if ($globalDebug) echo " Done\n"; |
|
| 786 | + if ($globalDebug) { |
|
| 787 | + echo " Done\n"; |
|
| 788 | + } |
|
| 644 | 789 | } |
| 645 | 790 | $this->last_delete_hourly = time(); |
| 646 | 791 | } |
@@ -649,7 +794,9 @@ discard block |
||
| 649 | 794 | //$ignoreImport = false; |
| 650 | 795 | } |
| 651 | 796 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
| 652 | - if ($send) return $this->all_tracked[$id]; |
|
| 797 | + if ($send) { |
|
| 798 | + return $this->all_tracked[$id]; |
|
| 799 | + } |
|
| 653 | 800 | } |
| 654 | 801 | } |
| 655 | 802 | } |