| @@ -59,20 +59,20 @@ discard block | ||
| 59 | 59 | die; | 
| 60 | 60 | } | 
| 61 | 61 | //$hosts = array($globalSBS1Host.':'.$globalSBS1Port); | 
| 62 | -	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port); | |
| 62 | +	$globalSources[] = array('host' => $globalSBS1Host, 'port' => $globalSBS1Port); | |
| 63 | 63 | } | 
| 64 | 64 | } | 
| 65 | 65 | |
| 66 | -$options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver','enable-aircraft','disable-aircraft','enable-tracker','disable-tracker','enable-marine','disable-marine')); | |
| 66 | +$options = getopt('s::', array('source::', 'server', 'nodaemon', 'idsource::', 'aprsserverssid::', 'aprsserverpass::', 'aprsserverhost::', 'aprsserverport::', 'format::', 'noaprsserver', 'enable-aircraft', 'disable-aircraft', 'enable-tracker', 'disable-tracker', 'enable-marine', 'disable-marine')); | |
| 67 | 67 | //if (isset($options['s'])) $hosts = array($options['s']); | 
| 68 | 68 | //elseif (isset($options['source'])) $hosts = array($options['source']); | 
| 69 | 69 |  if (isset($options['s'])) { | 
| 70 | 70 | $globalSources = array(); | 
| 71 | -    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); | |
| 71 | +    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'], 'format' => $options['format']); | |
| 72 | 72 |      else $globalSources[] = array('host' => $options['s']); | 
| 73 | 73 |  } elseif (isset($options['source'])) { | 
| 74 | 74 | $globalSources = array(); | 
| 75 | -    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); | |
| 75 | +    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'], 'format' => $options['format']); | |
| 76 | 76 |      else $globalSources[] = array('host' => $options['source']); | 
| 77 | 77 | } | 
| 78 | 78 |  if (isset($options['aprsserverhost'])) { | 
| @@ -113,13 +113,13 @@ discard block | ||
| 113 | 113 | else $id_source = 1; | 
| 114 | 114 |  if (isset($globalServer) && $globalServer) { | 
| 115 | 115 | if ($globalDebug) echo "Using Server Mode\n"; | 
| 116 | - $SI=new SpotterServer(); | |
| 116 | + $SI = new SpotterServer(); | |
| 117 | 117 | /* | 
| 118 | 118 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); | 
| 119 | 119 | $SI = new adsb2aprs(); | 
| 120 | 120 | $SI->connect(); | 
| 121 | 121 | */ | 
| 122 | -} else $SI=new SpotterImport($Connection->db); | |
| 122 | +} else $SI = new SpotterImport($Connection->db); | |
| 123 | 123 | |
| 124 | 124 | if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); | 
| 125 | 125 |  if (isset($globalMarine) && $globalMarine) { | 
| @@ -133,17 +133,17 @@ discard block | ||
| 133 | 133 | $MI = new MarineImport($Connection->db); | 
| 134 | 134 | } | 
| 135 | 135 | //$APRS=new APRS($Connection->db); | 
| 136 | -$SBS=new SBS(); | |
| 136 | +$SBS = new SBS(); | |
| 137 | 137 |  if (!isset($globalNoDB) || $globalNoDB !== TRUE) { | 
| 138 | - $ACARS=new ACARS($Connection->db,true); | |
| 139 | - $Source=new Source($Connection->db); | |
| 138 | + $ACARS = new ACARS($Connection->db, true); | |
| 139 | + $Source = new Source($Connection->db); | |
| 140 | 140 | } | 
| 141 | -$Common=new Common(); | |
| 141 | +$Common = new Common(); | |
| 142 | 142 |  date_default_timezone_set('UTC'); | 
| 143 | 143 |  //$servertz = system('date +%Z'); | 
| 144 | 144 | // signal handler - playing nice with sockets and dump1090 | 
| 145 | 145 |  if (function_exists('pcntl_fork')) { | 
| 146 | -    pcntl_signal(SIGINT,  function() { | |
| 146 | +    pcntl_signal(SIGINT, function() { | |
| 147 | 147 | global $sockets; | 
| 148 | 148 | echo "\n\nctrl-c or kill signal received. Tidying up ... "; | 
| 149 | 149 |          die("Bye!\n"); | 
| @@ -159,7 +159,7 @@ discard block | ||
| 159 | 159 | |
| 160 | 160 |  function connect_all($hosts) { | 
| 161 | 161 | //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; | 
| 162 | - global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; | |
| 162 | + global $sockets, $httpfeeds, $globalSources, $globalDebug, $aprs_connect, $last_exec, $globalSourcesRights, $use_aprs, $reset, $context; | |
| 163 | 163 | $reset++; | 
| 164 | 164 | if ($globalDebug) echo 'Connect to all...'."\n"; | 
| 165 | 165 |      foreach ($hosts as $id => $value) { | 
| @@ -167,33 +167,33 @@ discard block | ||
| 167 | 167 | $udp = false; | 
| 168 | 168 | $globalSources[$id]['last_exec'] = 0; | 
| 169 | 169 | // Here we check type of source(s) | 
| 170 | -	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { | |
| 171 | -            if (preg_match('/deltadb.txt$/i',$host)) { | |
| 170 | +	if (filter_var($host, FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { | |
| 171 | +            if (preg_match('/deltadb.txt$/i', $host)) { | |
| 172 | 172 | //$formats[$id] = 'deltadbtxt'; | 
| 173 | 173 | $globalSources[$id]['format'] = 'deltadbtxt'; | 
| 174 | 174 | //$last_exec['deltadbtxt'] = 0; | 
| 175 | 175 |          	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; | 
| 176 | -            } else if (preg_match('/vatsim-data.txt$/i',$host)) { | |
| 176 | +            } else if (preg_match('/vatsim-data.txt$/i', $host)) { | |
| 177 | 177 | //$formats[$id] = 'vatsimtxt'; | 
| 178 | 178 | $globalSources[$id]['format'] = 'vatsimtxt'; | 
| 179 | 179 | //$last_exec['vatsimtxt'] = 0; | 
| 180 | 180 |          	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; | 
| 181 | -    	    } else if (preg_match('/aircraftlist.json$/i',$host)) { | |
| 181 | +    	    } else if (preg_match('/aircraftlist.json$/i', $host)) { | |
| 182 | 182 | //$formats[$id] = 'aircraftlistjson'; | 
| 183 | 183 | $globalSources[$id]['format'] = 'aircraftlistjson'; | 
| 184 | 184 | //$last_exec['aircraftlistjson'] = 0; | 
| 185 | 185 |          	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; | 
| 186 | -    	    } else if (preg_match('/aircraft.json$/i',$host)) { | |
| 186 | +    	    } else if (preg_match('/aircraft.json$/i', $host)) { | |
| 187 | 187 | //$formats[$id] = 'aircraftjson'; | 
| 188 | 188 | $globalSources[$id]['format'] = 'aircraftjson'; | 
| 189 | 189 | //$last_exec['aircraftlistjson'] = 0; | 
| 190 | 190 |          	if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n"; | 
| 191 | -    	    } else if (preg_match('/aircraft$/i',$host)) { | |
| 191 | +    	    } else if (preg_match('/aircraft$/i', $host)) { | |
| 192 | 192 | //$formats[$id] = 'planefinderclient'; | 
| 193 | 193 | $globalSources[$id]['format'] = 'planefinderclient'; | 
| 194 | 194 | //$last_exec['aircraftlistjson'] = 0; | 
| 195 | 195 |          	if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n"; | 
| 196 | -    	    } else if (preg_match('/opensky/i',$host)) { | |
| 196 | +    	    } else if (preg_match('/opensky/i', $host)) { | |
| 197 | 197 | //$formats[$id] = 'aircraftlistjson'; | 
| 198 | 198 | $globalSources[$id]['format'] = 'opensky'; | 
| 199 | 199 | //$last_exec['aircraftlistjson'] = 0; | 
| @@ -210,7 +210,7 @@ discard block | ||
| 210 | 210 | exit(0); | 
| 211 | 211 | } | 
| 212 | 212 | */ | 
| 213 | -    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { | |
| 213 | +    	    } else if (preg_match('/planeUpdateFAA.php$/i', $host)) { | |
| 214 | 214 | //$formats[$id] = 'planeupdatefaa'; | 
| 215 | 215 | $globalSources[$id]['format'] = 'planeupdatefaa'; | 
| 216 | 216 | //$last_exec['planeupdatefaa'] = 0; | 
| @@ -219,37 +219,37 @@ discard block | ||
| 219 | 219 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; | 
| 220 | 220 | exit(0); | 
| 221 | 221 | } | 
| 222 | -            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { | |
| 222 | +            } else if (preg_match('/\/action.php\/acars\/data$/i', $host)) { | |
| 223 | 223 | //$formats[$id] = 'phpvmacars'; | 
| 224 | 224 | $globalSources[$id]['format'] = 'phpvmacars'; | 
| 225 | 225 | //$last_exec['phpvmacars'] = 0; | 
| 226 | 226 |          	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; | 
| 227 | -            } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) { | |
| 227 | +            } else if (preg_match('/\/api\/v1\/acars\/data$/i', $host)) { | |
| 228 | 228 | //$formats[$id] = 'phpvmacars'; | 
| 229 | 229 | $globalSources[$id]['format'] = 'vaos'; | 
| 230 | 230 | //$last_exec['phpvmacars'] = 0; | 
| 231 | 231 |          	if ($globalDebug) echo "Connect to vaos source (".$host.")...\n"; | 
| 232 | -            } else if (preg_match('/VAM-json.php$/i',$host)) { | |
| 232 | +            } else if (preg_match('/VAM-json.php$/i', $host)) { | |
| 233 | 233 | //$formats[$id] = 'phpvmacars'; | 
| 234 | 234 | $globalSources[$id]['format'] = 'vam'; | 
| 235 | 235 |          	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; | 
| 236 | -            } else if (preg_match('/whazzup/i',$host)) { | |
| 236 | +            } else if (preg_match('/whazzup/i', $host)) { | |
| 237 | 237 | //$formats[$id] = 'whazzup'; | 
| 238 | 238 | $globalSources[$id]['format'] = 'whazzup'; | 
| 239 | 239 | //$last_exec['whazzup'] = 0; | 
| 240 | 240 |          	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; | 
| 241 | -            } else if (preg_match('/blitzortung/i',$host)) { | |
| 241 | +            } else if (preg_match('/blitzortung/i', $host)) { | |
| 242 | 242 | $globalSources[$id]['format'] = 'blitzortung'; | 
| 243 | 243 |          	if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n"; | 
| 244 | -            } else if (preg_match('/airwhere/i',$host)) { | |
| 244 | +            } else if (preg_match('/airwhere/i', $host)) { | |
| 245 | 245 | $globalSources[$id]['format'] = 'airwhere'; | 
| 246 | 246 |          	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; | 
| 247 | -            } else if (preg_match('/recentpireps/i',$host)) { | |
| 247 | +            } else if (preg_match('/recentpireps/i', $host)) { | |
| 248 | 248 | //$formats[$id] = 'pirepsjson'; | 
| 249 | 249 | $globalSources[$id]['format'] = 'pirepsjson'; | 
| 250 | 250 | //$last_exec['pirepsjson'] = 0; | 
| 251 | 251 |          	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; | 
| 252 | -            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { | |
| 252 | +            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i', $host)) { | |
| 253 | 253 | //$formats[$id] = 'fr24json'; | 
| 254 | 254 | $globalSources[$id]['format'] = 'fr24json'; | 
| 255 | 255 | //$last_exec['fr24json'] = 0; | 
| @@ -258,7 +258,7 @@ discard block | ||
| 258 | 258 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; | 
| 259 | 259 | exit(0); | 
| 260 | 260 | } | 
| 261 | -            } else if (preg_match(':myshiptracking.com/:i',$host)) { | |
| 261 | +            } else if (preg_match(':myshiptracking.com/:i', $host)) { | |
| 262 | 262 | //$formats[$id] = 'fr24json'; | 
| 263 | 263 | $globalSources[$id]['format'] = 'myshiptracking'; | 
| 264 | 264 | //$last_exec['fr24json'] = 0; | 
| @@ -268,22 +268,22 @@ discard block | ||
| 268 | 268 | exit(0); | 
| 269 | 269 | } | 
| 270 | 270 |              //} else if (preg_match('/10001/',$host)) { | 
| 271 | -            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { | |
| 271 | +            } else if (preg_match('/10001/', $host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { | |
| 272 | 272 | //$formats[$id] = 'tsv'; | 
| 273 | 273 | $globalSources[$id]['format'] = 'tsv'; | 
| 274 | 274 |          	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; | 
| 275 | 275 | } | 
| 276 | -        } elseif (filter_var($host,FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'acarsjson')) { | |
| 276 | +        } elseif (filter_var($host, FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'acarsjson')) { | |
| 277 | 277 |      		if ($globalSources[$id]['format'] == 'aisnmeahttp' || $globalSources[$id]['format'] == 'acarsjson') { | 
| 278 | - $idf = fopen($globalSources[$id]['host'],'r',false,$context); | |
| 278 | + $idf = fopen($globalSources[$id]['host'], 'r', false, $context); | |
| 279 | 279 |      		    if ($idf !== false) { | 
| 280 | 280 | $httpfeeds[$id] = $idf; | 
| 281 | 281 |          		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; | 
| 282 | 282 | } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; | 
| 283 | 283 | } elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n"; | 
| 284 | 284 |      		elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; | 
| 285 | -        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { | |
| 286 | -	    $hostport = explode(':',$host); | |
| 285 | +        } elseif (!filter_var($host, FILTER_VALIDATE_URL)) { | |
| 286 | +	    $hostport = explode(':', $host); | |
| 287 | 287 |  	    if (isset($hostport[1])) { | 
| 288 | 288 | $port = $hostport[1]; | 
| 289 | 289 | $hostn = $hostport[0]; | 
| @@ -293,20 +293,20 @@ discard block | ||
| 293 | 293 | } | 
| 294 | 294 | $Common = new Common(); | 
| 295 | 295 |  	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acarsjsonudp' && $globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { | 
| 296 | - $s = $Common->create_socket($hostn,$port, $errno, $errstr); | |
| 296 | + $s = $Common->create_socket($hostn, $port, $errno, $errstr); | |
| 297 | 297 |      	    } else { | 
| 298 | 298 | $udp = true; | 
| 299 | - $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); | |
| 299 | + $s = $Common->create_socket_udp($hostn, $port, $errno, $errstr); | |
| 300 | 300 | } | 
| 301 | 301 |  	    if ($s) { | 
| 302 | 302 | $sockets[$id] = $s; | 
| 303 | 303 |      	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { | 
| 304 | -		    if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { | |
| 304 | +		    if (preg_match('/aprs/', $hostn) || $port == '10152' || $port == '14580') { | |
| 305 | 305 | //$formats[$id] = 'aprs'; | 
| 306 | 306 | $globalSources[$id]['format'] = 'aprs'; | 
| 307 | 307 | //$aprs_connect = 0; | 
| 308 | 308 | //$use_aprs = true; | 
| 309 | -		    } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { | |
| 309 | +		    } elseif (preg_match('/pub-vrs/', $hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { | |
| 310 | 310 | $globalSources[$id]['format'] = 'vrstcp'; | 
| 311 | 311 |      		    } elseif ($port == '10001') { | 
| 312 | 312 | //$formats[$id] = 'tsv'; | 
| @@ -348,7 +348,7 @@ discard block | ||
| 348 | 348 | else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut; | 
| 349 | 349 | else $timeout = 20; | 
| 350 | 350 | $errno = ''; | 
| 351 | -$errstr=''; | |
| 351 | +$errstr = ''; | |
| 352 | 352 | |
| 353 | 353 | if (!isset($globalDaemon)) $globalDaemon = TRUE; | 
| 354 | 354 | /* Initiate connections to all the hosts simultaneously */ | 
| @@ -356,7 +356,7 @@ discard block | ||
| 356 | 356 | //connect_all($globalSources); | 
| 357 | 357 | |
| 358 | 358 |  if (isset($globalProxy) && $globalProxy) { | 
| 359 | -    $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); | |
| 359 | +    $context = stream_context_create(array('http' => array('timeout' => $timeout, 'proxy' => $globalProxy, 'request_fulluri' => true))); | |
| 360 | 360 |  } else { | 
| 361 | 361 |      $context = stream_context_create(array('http' => array('timeout' => $timeout))); | 
| 362 | 362 | } | 
| @@ -386,16 +386,16 @@ discard block | ||
| 386 | 386 | |
| 387 | 387 |  if ($use_aprs) { | 
| 388 | 388 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); | 
| 389 | - $APRS=new APRS(); | |
| 389 | + $APRS = new APRS(); | |
| 390 | 390 | $aprs_connect = 0; | 
| 391 | 391 | $aprs_keep = 120; | 
| 392 | 392 | $aprs_last_tx = time(); | 
| 393 | 393 | if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; | 
| 394 | -	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); | |
| 394 | +	else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName); | |
| 395 | 395 | if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid; | 
| 396 | -	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); | |
| 396 | +	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8); | |
| 397 | 397 | if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter; | 
| 398 | - else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; | |
| 398 | + else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; | |
| 399 | 399 | if ($aprs_full) $aprs_filter = ''; | 
| 400 | 400 | if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass; | 
| 401 | 401 | else $aprs_pass = '-1'; | 
| @@ -409,12 +409,12 @@ discard block | ||
| 409 | 409 | sleep(1); | 
| 410 | 410 | if ($globalDebug) echo "SCAN MODE \n\n"; | 
| 411 | 411 | if (!isset($globalCronEnd)) $globalCronEnd = 60; | 
| 412 | -$endtime = time()+$globalCronEnd; | |
| 412 | +$endtime = time() + $globalCronEnd; | |
| 413 | 413 | $i = 1; | 
| 414 | 414 | $tt = array(); | 
| 415 | 415 | // Delete all ATC | 
| 416 | 416 |  if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) { | 
| 417 | - $ATC=new ATC($Connection->db); | |
| 417 | + $ATC = new ATC($Connection->db); | |
| 418 | 418 | } | 
| 419 | 419 |  if (!$globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { | 
| 420 | 420 | $ATC->deleteAll(); | 
| @@ -424,7 +424,7 @@ discard block | ||
| 424 | 424 |  while ($i > 0) { | 
| 425 | 425 |      if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); | 
| 426 | 426 | |
| 427 | - if (!$globalDaemon) $i = $endtime-time(); | |
| 427 | + if (!$globalDaemon) $i = $endtime - time(); | |
| 428 | 428 | // Delete old ATC | 
| 429 | 429 |      if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { | 
| 430 | 430 | if ($globalDebug) echo 'Delete old ATC...'."\n"; | 
| @@ -438,7 +438,7 @@ discard block | ||
| 438 | 438 | } | 
| 439 | 439 |  	if ($max < $globalMinFetch) { | 
| 440 | 440 | if ($globalDebug) echo 'Sleeping...'."\n"; | 
| 441 | - sleep($globalMinFetch-$max+2); | |
| 441 | + sleep($globalMinFetch - $max + 2); | |
| 442 | 442 | } | 
| 443 | 443 | } | 
| 444 | 444 | |
| @@ -493,10 +493,10 @@ discard block | ||
| 493 | 493 | //$buffer = $Common->getData($hosts[$id]); | 
| 494 | 494 | $buffer = $Common->getData($value['host']); | 
| 495 | 495 |              if ($buffer != '') { | 
| 496 | - $all_data = json_decode($buffer,true); | |
| 496 | + $all_data = json_decode($buffer, true); | |
| 497 | 497 |                  foreach ($all_data as $line) { | 
| 498 | 498 | $data = array(); | 
| 499 | -                    $data['datetime'] = date('Y-m-d H:i:s',$line['uti']); | |
| 499 | +                    $data['datetime'] = date('Y-m-d H:i:s', $line['uti']); | |
| 500 | 500 | $data['hex'] = $line['hex']; // hex | 
| 501 | 501 | $data['ident'] = $line['fli']; // ident | 
| 502 | 502 | $data['altitude'] = $line['alt']; // altitude | 
| @@ -531,11 +531,11 @@ discard block | ||
| 531 | 531 | ) | 
| 532 | 532 |  	) { | 
| 533 | 533 |  	    date_default_timezone_set('CET'); | 
| 534 | -	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); | |
| 534 | +	    $buffer = $Common->getData(str_replace('{date}', date('Ymd'), $value['host'])); | |
| 535 | 535 |  	    date_default_timezone_set('UTC'); | 
| 536 | 536 | if ($buffer != '') $reset = 0; | 
| 537 | -    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); | |
| 538 | -	    $buffer = explode('\n',$buffer); | |
| 537 | +    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); | |
| 538 | +	    $buffer = explode('\n', $buffer); | |
| 539 | 539 |  	    foreach ($buffer as $line) { | 
| 540 | 540 |  		if ($line != '') { | 
| 541 | 541 | //echo "'".$line."'\n"; | 
| @@ -543,7 +543,7 @@ discard block | ||
| 543 | 543 | $ais_data = $AIS->parse_line(trim($line)); | 
| 544 | 544 | $data = array(); | 
| 545 | 545 | if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; | 
| 546 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); | |
| 546 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'], -9); | |
| 547 | 547 | if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; | 
| 548 | 548 | if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; | 
| 549 | 549 | if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; | 
| @@ -555,7 +555,7 @@ discard block | ||
| 555 | 555 | if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; | 
| 556 | 556 | if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; | 
| 557 | 557 |  		    if (isset($ais_data['timestamp'])) { | 
| 558 | -			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); | |
| 558 | +			$data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); | |
| 559 | 559 |  			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { | 
| 560 | 560 | $last_exec[$id]['timestamp'] = $ais_data['timestamp']; | 
| 561 | 561 | $add = true; | 
| @@ -578,21 +578,21 @@ discard block | ||
| 578 | 578 | $w = $e = null; | 
| 579 | 579 | |
| 580 | 580 |  	    if (isset($arr[$id])) { | 
| 581 | - $nn = stream_select($arr,$w,$e,$timeout); | |
| 581 | + $nn = stream_select($arr, $w, $e, $timeout); | |
| 582 | 582 |  		if ($nn > 0) { | 
| 583 | 583 |  		    foreach ($httpfeeds as $feed) { | 
| 584 | - $buffer = stream_get_line($feed,2000,"\n"); | |
| 584 | + $buffer = stream_get_line($feed, 2000, "\n"); | |
| 585 | 585 |  			if ($buffer === FALSE) { | 
| 586 | 586 | connect_all($globalSources); | 
| 587 | 587 | } | 
| 588 | -			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); | |
| 589 | -			$buffer = explode('\n',$buffer); | |
| 588 | +			$buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); | |
| 589 | +			$buffer = explode('\n', $buffer); | |
| 590 | 590 |  			foreach ($buffer as $line) { | 
| 591 | 591 |  			    if ($line != '') { | 
| 592 | 592 | $ais_data = $AIS->parse_line(trim($line)); | 
| 593 | 593 | $data = array(); | 
| 594 | 594 | if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; | 
| 595 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); | |
| 595 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'], -9); | |
| 596 | 596 | if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; | 
| 597 | 597 | if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; | 
| 598 | 598 | if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; | 
| @@ -604,9 +604,9 @@ discard block | ||
| 604 | 604 | if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; | 
| 605 | 605 | if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; | 
| 606 | 606 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; | 
| 607 | -				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); | |
| 607 | +				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']); | |
| 608 | 608 |  				if (isset($ais_data['timestamp'])) { | 
| 609 | -				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); | |
| 609 | +				    $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); | |
| 610 | 610 |  				} else { | 
| 611 | 611 |  				    $data['datetime'] = date('Y-m-d H:i:s'); | 
| 612 | 612 | } | 
| @@ -638,10 +638,10 @@ discard block | ||
| 638 | 638 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) | 
| 639 | 639 | ) | 
| 640 | 640 |  	) { | 
| 641 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); | |
| 641 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20'); | |
| 642 | 642 |  	    if ($buffer != '') { | 
| 643 | 643 | //echo $buffer; | 
| 644 | - $all_data = json_decode($buffer,true); | |
| 644 | + $all_data = json_decode($buffer, true); | |
| 645 | 645 | //print_r($all_data); | 
| 646 | 646 |  		if (isset($all_data[0]['DATA'])) { | 
| 647 | 647 |  		    foreach ($all_data[0]['DATA'] as $line) { | 
| @@ -650,7 +650,7 @@ discard block | ||
| 650 | 650 | $data['ident'] = $line['NAME']; | 
| 651 | 651 | $data['mmsi'] = $line['MMSI']; | 
| 652 | 652 |  			    if (strlen($data['mmsi']) > 9) { | 
| 653 | - $data['mmsi'] = substr($data['mmsi'],-9); | |
| 653 | + $data['mmsi'] = substr($data['mmsi'], -9); | |
| 654 | 654 | } | 
| 655 | 655 | $data['speed'] = $line['SOG']; | 
| 656 | 656 | $data['heading'] = $line['COG']; | 
| @@ -660,8 +660,8 @@ discard block | ||
| 660 | 660 | //$data['type_id'] = $line['TYPE']; | 
| 661 | 661 | $data['imo'] = $line['IMO']; | 
| 662 | 662 | if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST']; | 
| 663 | -			    if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV'])); | |
| 664 | -			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']); | |
| 663 | +			    if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s', strtotime($line['ARV'])); | |
| 664 | +			    $data['datetime'] = date('Y-m-d H:i:s', $line['T']); | |
| 665 | 665 | $data['format_source'] = 'myshiptracking'; | 
| 666 | 666 | $data['id_source'] = $id_source; | 
| 667 | 667 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | 
| @@ -678,16 +678,16 @@ discard block | ||
| 678 | 678 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) | 
| 679 | 679 | ) | 
| 680 | 680 |  	) { | 
| 681 | -	    $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); | |
| 681 | +	    $buffer = $Common->getData(str_replace('{timestamp}', time(), $value['host'])); | |
| 682 | 682 |  	    if ($buffer != '') { | 
| 683 | - $all_data = json_decode($buffer,true); | |
| 683 | + $all_data = json_decode($buffer, true); | |
| 684 | 684 |  		if (isset($all_data[0]['mmsi'])) { | 
| 685 | 685 |  		    foreach ($all_data as $line) { | 
| 686 | 686 |  			if ($line != '') { | 
| 687 | 687 | $data = array(); | 
| 688 | 688 | $data['ident'] = $line['shipname']; | 
| 689 | 689 | $data['callsign'] = $line['callsign']; | 
| 690 | - $data['mmsi'] = substr($line['mmsi'],-9); | |
| 690 | + $data['mmsi'] = substr($line['mmsi'], -9); | |
| 691 | 691 | $data['speed'] = $line['sog']; | 
| 692 | 692 | if ($line['heading'] != '511') $data['heading'] = $line['heading']; | 
| 693 | 693 | $data['latitude'] = $line['latitude']; | 
| @@ -714,14 +714,14 @@ discard block | ||
| 714 | 714 |  	) { | 
| 715 | 715 | $buffer = $Common->getData($value['host']); | 
| 716 | 716 |  	    if ($buffer != '') { | 
| 717 | - $all_data = json_decode($buffer,true); | |
| 717 | + $all_data = json_decode($buffer, true); | |
| 718 | 718 |  		if (isset($all_data['features'][0]['id'])) { | 
| 719 | 719 |  		    foreach ($all_data['features'] as $line) { | 
| 720 | 720 | print_r($line); | 
| 721 | 721 | $data = array(); | 
| 722 | 722 | if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name']; | 
| 723 | 723 | if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign']; | 
| 724 | - if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'],-9); | |
| 724 | + if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'], -9); | |
| 725 | 725 | if (isset($line['properties']['imo'])) $data['imo'] = $line['properties']['imo']; | 
| 726 | 726 | if (isset($line['properties']['speed'])) $data['speed'] = $line['properties']['speed']; | 
| 727 | 727 | if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) $data['heading'] = $line['properties']['heading']; | 
| @@ -748,31 +748,31 @@ discard block | ||
| 748 | 748 | ) | 
| 749 | 749 |  	) { | 
| 750 | 750 | if ($globalDebug) echo 'download...'; | 
| 751 | - $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); | |
| 751 | + $buffer = $Common->getData($value['host'], 'post', $value['post'], '', '', '', '', 'ShipPlotter'); | |
| 752 | 752 | if ($globalDebug) echo 'done !'."\n"; | 
| 753 | 753 | // FIXME: Need more work | 
| 754 | 754 | if ($buffer != '') $reset = 0; | 
| 755 | -    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); | |
| 756 | -	    $buffer = explode('\n',$buffer); | |
| 755 | +    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); | |
| 756 | +	    $buffer = explode('\n', $buffer); | |
| 757 | 757 |  	    foreach ($buffer as $line) { | 
| 758 | 758 |  		if ($line != '') { | 
| 759 | 759 | $data = array(); | 
| 760 | 760 | //echo $line."\n"; | 
| 761 | - $data['mmsi'] = (int)substr($line,0,9); | |
| 762 | -		    $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); | |
| 763 | - $data['status_id'] = substr($line,21,2); | |
| 764 | - $data['type_id'] = substr($line,24,3); | |
| 765 | - $data['latitude'] = substr($line,29,9); | |
| 766 | - $data['longitude'] = substr($line,41,9); | |
| 767 | - $data['speed'] = round(substr($line,51,5)); | |
| 761 | + $data['mmsi'] = (int) substr($line, 0, 9); | |
| 762 | +		    $data['datetime'] = date('Y-m-d H:i:s', substr($line, 10, 10)); | |
| 763 | + $data['status_id'] = substr($line, 21, 2); | |
| 764 | + $data['type_id'] = substr($line, 24, 3); | |
| 765 | + $data['latitude'] = substr($line, 29, 9); | |
| 766 | + $data['longitude'] = substr($line, 41, 9); | |
| 767 | + $data['speed'] = round(substr($line, 51, 5)); | |
| 768 | 768 | //$data['course'] = substr($line,57,5); | 
| 769 | - $data['heading'] = round(substr($line,63,3)); | |
| 769 | + $data['heading'] = round(substr($line, 63, 3)); | |
| 770 | 770 | //$data['draft'] = substr($line,67,4); | 
| 771 | 771 | //$data['length'] = substr($line,72,3); | 
| 772 | 772 | //$data['beam'] = substr($line,76,2); | 
| 773 | - $data['ident'] = trim(utf8_encode(substr($line,78,20))); | |
| 773 | + $data['ident'] = trim(utf8_encode(substr($line, 78, 20))); | |
| 774 | 774 | //$data['callsign'] = trim(substr($line,100,7); | 
| 775 | - $data['arrival_code'] = substr($line,108,20); | |
| 775 | + $data['arrival_code'] = substr($line, 108, 20); | |
| 776 | 776 | //$data['etaDate'] = substr($line,129,5); | 
| 777 | 777 | //$data['etaTime'] = substr($line,135,5); | 
| 778 | 778 | $data['format_source'] = 'shipplotter'; | 
| @@ -791,7 +791,7 @@ discard block | ||
| 791 | 791 | ) | 
| 792 | 792 |  	) { | 
| 793 | 793 |  	    if (isset($globalSailaway['email']) && $globalSailaway['email'] != '' && isset($globalSailaway['password']) && $globalSailaway['password'] != '') { | 
| 794 | -		$authsailaway = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/weblogin.pl','post',array('submitlogin' => 'Login','email' => $globalSailaway['email'],'pwd' => $globalSailaway['password'], 'page' => 'http://sailaway.world/cgi-bin/sailaway/missions.pl'),'','','','','',false,false,true); | |
| 794 | +		$authsailaway = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/weblogin.pl', 'post', array('submitlogin' => 'Login', 'email' => $globalSailaway['email'], 'pwd' => $globalSailaway['password'], 'page' => 'http://sailaway.world/cgi-bin/sailaway/missions.pl'), '', '', '', '', '', false, false, true); | |
| 795 | 795 | //echo $authsailaway; | 
| 796 | 796 |  		preg_match_all('/^Set-Cookie:\s*([^;]*)/mi', $authsailaway, $setcookie); | 
| 797 | 797 |  		if (isset($setcookie[1][0])) { | 
| @@ -800,19 +800,19 @@ discard block | ||
| 800 | 800 | } | 
| 801 | 801 | |
| 802 | 802 | if ($globalDebug) echo '! Download... '; | 
| 803 | -	    for ($i =0; $i <= 1; $i++) { | |
| 803 | +	    for ($i = 0; $i <= 1; $i++) { | |
| 804 | 804 | if ($globalDebug) echo 'Racetype: '.$i.' '; | 
| 805 | 805 |  		$buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/GetMissions.pl?race=1&tutorial=0&hist=1&racetype='.$i); | 
| 806 | 806 | if ($globalDebug) echo 'done'."\n"; | 
| 807 | 807 |  	    if ($buffer != '') { | 
| 808 | - $all_data = json_decode($buffer,true); | |
| 808 | + $all_data = json_decode($buffer, true); | |
| 809 | 809 |  		if (isset($all_data['missions'])) { | 
| 810 | 810 |  			foreach ($all_data['missions'] as $mission) { | 
| 811 | 811 | $mission_user = $mission['usrname']; | 
| 812 | -				$mission_name = preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($mission['mistitle'])); | |
| 813 | -				if (!isset($globalFilter['sailway']['race']) || (isset($globalFilter['sailway']['race']) && in_array($mission['misnr'],$globalFilter['sailway']['race']))) { | |
| 812 | +				$mission_name = preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $Common->remove_accents($mission['mistitle'])); | |
| 813 | +				if (!isset($globalFilter['sailway']['race']) || (isset($globalFilter['sailway']['race']) && in_array($mission['misnr'], $globalFilter['sailway']['race']))) { | |
| 814 | 814 |  					if (isset($sailaway_authcookie) && $sailaway_authcookie != '') { | 
| 815 | -						$racebuffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/GetMission.pl?misnr='.$mission['misnr'],'get','','',$sailaway_authcookie); | |
| 815 | +						$racebuffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/GetMission.pl?misnr='.$mission['misnr'], 'get', '', '', $sailaway_authcookie); | |
| 816 | 816 | sleep(10); | 
| 817 | 817 | } else $racebuffer = ''; | 
| 818 | 818 |  					$bufferm = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/GetLeaderboard.pl?misnr='.$mission['misnr']); | 
| @@ -821,19 +821,19 @@ discard block | ||
| 821 | 821 | $racebuffer = ''; | 
| 822 | 822 | } | 
| 823 | 823 |  				if ($racebuffer != '') { | 
| 824 | - $race_data = json_decode($racebuffer,true); | |
| 824 | + $race_data = json_decode($racebuffer, true); | |
| 825 | 825 | //print_r($race_data); | 
| 826 | 826 | unset($racebuffer); | 
| 827 | 827 |  					if (isset($race_data['mission'])) { | 
| 828 | 828 | $datar = array(); | 
| 829 | 829 | $datar['id'] = $mission['misnr']; | 
| 830 | 830 | $datar['desc'] = $race_data['mission']['misdescr']; | 
| 831 | -					    $datar['creator'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($race_data['mission']['usrname']))); | |
| 832 | -					    $datar['name'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($race_data['mission']['mistitle']))); | |
| 831 | +					    $datar['creator'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $Common->remove_accents($race_data['mission']['usrname']))); | |
| 832 | +					    $datar['name'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $Common->remove_accents($race_data['mission']['mistitle']))); | |
| 833 | 833 | $datar['startdate'] = $race_data['mission']['misstartdatetime']; | 
| 834 | 834 | $markers = array(); | 
| 835 | 835 |  					    foreach ($race_data['mission']['course'] as $course) { | 
| 836 | -						$markers[] = array('lat' => $course['miclat'],'lon' => $course['miclon'],'name' => $course['micname'],'type' => $course['mictype']); | |
| 836 | +						$markers[] = array('lat' => $course['miclat'], 'lon' => $course['miclon'], 'name' => $course['micname'], 'type' => $course['mictype']); | |
| 837 | 837 | } | 
| 838 | 838 | $datar['markers'] = json_encode($markers); | 
| 839 | 839 | //print_r($datar); | 
| @@ -841,7 +841,7 @@ discard block | ||
| 841 | 841 | } | 
| 842 | 842 | } | 
| 843 | 843 |  				if ($bufferm != '') { | 
| 844 | - $mission_data = json_decode($bufferm,true); | |
| 844 | + $mission_data = json_decode($bufferm, true); | |
| 845 | 845 | unset($bufferm); | 
| 846 | 846 |  					if (isset($mission_data['leaderboard'][0]['results'])) { | 
| 847 | 847 |  						foreach ($mission_data['leaderboard'][0]['results'] as $sail) { | 
| @@ -854,7 +854,7 @@ discard block | ||
| 854 | 854 | //$data['id'] = $sail['misnr'].'-'.$sail['usrnr'].'-'.$sail['ubtnr']; | 
| 855 | 855 | $data['id'] = $sail['misnr'].'-'.$sail['usrnr']; | 
| 856 | 856 |  								$data['datetime'] = date('Y-m-d H:i:s'); | 
| 857 | -								$data['race_begin'] = date('Y-m-d H:i:s',strtotime($mission_data['leaderboard'][0]['misstart'])); | |
| 857 | +								$data['race_begin'] = date('Y-m-d H:i:s', strtotime($mission_data['leaderboard'][0]['misstart'])); | |
| 858 | 858 |  								$data['last_update'] = date('Y-m-d H:i:s'); | 
| 859 | 859 | $data['status'] = $sail['status']; | 
| 860 | 860 | $data['type'] = $sail['btptype']; | 
| @@ -865,16 +865,16 @@ discard block | ||
| 865 | 865 | $data['longitude'] = $pos['longitude']; | 
| 866 | 866 | } | 
| 867 | 867 |  								if ($sail['status'] == 'Racing' && $sail['resultdescr'] != '-') { | 
| 868 | -									$resultdescr = explode(',',$sail['resultdescr']); | |
| 868 | +									$resultdescr = explode(',', $sail['resultdescr']); | |
| 869 | 869 |  									if (count($resultdescr) > 2) { | 
| 870 | -										$data['speed'] = round(str_replace(array('Spd: ','kn.'),'',trim($resultdescr[2]))*1.852,2); | |
| 871 | -										$data['heading'] = str_replace(array('Hdg: ','°'),'',trim($resultdescr[1])); | |
| 870 | +										$data['speed'] = round(str_replace(array('Spd: ', 'kn.'), '', trim($resultdescr[2]))*1.852, 2); | |
| 871 | +										$data['heading'] = str_replace(array('Hdg: ', '°'), '', trim($resultdescr[1])); | |
| 872 | 872 |  										if (isset($resultdescr[3])) { | 
| 873 | -											$data['distance'] = round(str_replace('nm.','',trim(explode(' ',$resultdescr[3])[1]))*1.852,3); | |
| 873 | +											$data['distance'] = round(str_replace('nm.', '', trim(explode(' ', $resultdescr[3])[1]))*1.852, 3); | |
| 874 | 874 | } | 
| 875 | 875 | } | 
| 876 | 876 | } | 
| 877 | -								$data['ident'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($sail['ubtname']))); | |
| 877 | +								$data['ident'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $Common->remove_accents($sail['ubtname']))); | |
| 878 | 878 | $data['captain_id'] = $sail['usrnr']; | 
| 879 | 879 | $data['captain_name'] = $sail['usrname']; | 
| 880 | 880 | $data['race_id'] = $sail['misnr']; | 
| @@ -924,8 +924,8 @@ discard block | ||
| 924 | 924 |  	) { | 
| 925 | 925 | //$buffer = $Common->getData($hosts[$id]); | 
| 926 | 926 | $buffer = $Common->getData($value['host']); | 
| 927 | -    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); | |
| 928 | -	    $buffer = explode('\n',$buffer); | |
| 927 | +    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); | |
| 928 | +	    $buffer = explode('\n', $buffer); | |
| 929 | 929 | $reset = 0; | 
| 930 | 930 |  	    foreach ($buffer as $line) { | 
| 931 | 931 |      		if ($line != '') { | 
| @@ -936,7 +936,7 @@ discard block | ||
| 936 | 936 | else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; | 
| 937 | 937 | $data['pilot_id'] = $line[1]; | 
| 938 | 938 | $data['pilot_name'] = $line[2]; | 
| 939 | - $data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT); | |
| 939 | + $data['hex'] = str_pad(dechex($Common->str2int($line[1])), 6, '000000', STR_PAD_LEFT); | |
| 940 | 940 | $data['ident'] = $line[0]; // ident | 
| 941 | 941 | if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude | 
| 942 | 942 | $data['speed'] = $line[8]; // speed | 
| @@ -952,7 +952,7 @@ discard block | ||
| 952 | 952 |  			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); | 
| 953 | 953 | //if (isset($line[37])) $data['last_update'] = $line[37]; | 
| 954 | 954 | $data['departure_airport_icao'] = $line[11]; | 
| 955 | - $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); | |
| 955 | + $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':'); | |
| 956 | 956 | $data['arrival_airport_icao'] = $line[13]; | 
| 957 | 957 | $data['frequency'] = $line[4]; | 
| 958 | 958 | $data['type'] = $line[18]; | 
| @@ -961,7 +961,7 @@ discard block | ||
| 961 | 961 | $data['id_source'] = $id_source; | 
| 962 | 962 | //$data['arrival_airport_time'] = ; | 
| 963 | 963 |  	    		if ($line[9] != '') { | 
| 964 | -	    		    $aircraft_data = explode('/',$line[9]); | |
| 964 | +	    		    $aircraft_data = explode('/', $line[9]); | |
| 965 | 965 |  	    		    if (isset($aircraft_data[1])) { | 
| 966 | 966 | $data['aircraft_icao'] = $aircraft_data[1]; | 
| 967 | 967 | } | 
| @@ -976,9 +976,9 @@ discard block | ||
| 976 | 976 | if ($line[3] === 'PILOT') $SI->add($data); | 
| 977 | 977 |  			elseif ($line[3] === 'ATC') { | 
| 978 | 978 | //print_r($data); | 
| 979 | -				$data['info'] = str_replace('^§','<br />',$data['info']); | |
| 980 | -				$data['info'] = str_replace('&sect;','',$data['info']); | |
| 981 | - $typec = substr($data['ident'],-3); | |
| 979 | +				$data['info'] = str_replace('^§', '<br />', $data['info']); | |
| 980 | +				$data['info'] = str_replace('&sect;', '', $data['info']); | |
| 981 | + $typec = substr($data['ident'], -3); | |
| 982 | 982 | if ($typec === 'APP') $data['type'] = 'Approach'; | 
| 983 | 983 | elseif ($typec === 'TWR') $data['type'] = 'Tower'; | 
| 984 | 984 | elseif ($typec === 'OBS') $data['type'] = 'Observer'; | 
| @@ -990,8 +990,8 @@ discard block | ||
| 990 | 990 | elseif ($data['type'] === '') $data['type'] = 'Observer'; | 
| 991 | 991 | if (!isset($data['source_name'])) $data['source_name'] = ''; | 
| 992 | 992 |  				if (isset($ATC)) { | 
| 993 | - 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']); | |
| 994 | - 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']); | |
| 993 | + 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']); | |
| 994 | + 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']); | |
| 995 | 995 | } | 
| 996 | 996 | } | 
| 997 | 997 | unset($data); | 
| @@ -1007,24 +1007,24 @@ discard block | ||
| 1007 | 1007 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) | 
| 1008 | 1008 | ) | 
| 1009 | 1009 |      	) { | 
| 1010 | -	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20'); | |
| 1010 | +	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php', 'get', '', '', '', '', '20'); | |
| 1011 | 1011 |  	    if ($buffer != '') { | 
| 1012 | 1012 | $all_data = simplexml_load_string($buffer); | 
| 1013 | -		foreach($all_data->children() as $childdata) { | |
| 1013 | +		foreach ($all_data->children() as $childdata) { | |
| 1014 | 1014 | $data = array(); | 
| 1015 | 1015 | $line = $childdata; | 
| 1016 | 1016 | //$data['hex'] = str_pad(dechex((int)$line['pktPilotID']),6,'000000',STR_PAD_LEFT); | 
| 1017 | -			$data['id'] = date('Ymd').(int)$line['pktPilotID']; | |
| 1018 | -			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST')); | |
| 1019 | - $data['latitude'] = (float)$line['pktLatitude']; | |
| 1020 | - $data['longitude'] = (float)$line['pktLongitude']; | |
| 1021 | - if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack']; | |
| 1022 | - if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed']; | |
| 1023 | - $data['altitude'] = round((int)$line['pktAltitude']*3.28084); | |
| 1017 | +			$data['id'] = date('Ymd').(int) $line['pktPilotID']; | |
| 1018 | +			$data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['entryTime'].' BST')); | |
| 1019 | + $data['latitude'] = (float) $line['pktLatitude']; | |
| 1020 | + $data['longitude'] = (float) $line['pktLongitude']; | |
| 1021 | + if ((float) $line['pktTrack'] != 0) $data['heading'] = (float) $line['pktTrack']; | |
| 1022 | + if ((int) $line['pktSpeed'] != 0) $data['speed'] = (int) $line['pktSpeed']; | |
| 1023 | + $data['altitude'] = round((int) $line['pktAltitude']*3.28084); | |
| 1024 | 1024 | $data['altitude_relative'] = 'AMSL'; | 
| 1025 | - $data['pilot_id'] = (int)$line['pktPilotID']; | |
| 1025 | + $data['pilot_id'] = (int) $line['pktPilotID']; | |
| 1026 | 1026 | $data['aircraft_icao'] = 'PARAGLIDER'; | 
| 1027 | -			$pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id'])); | |
| 1027 | +			$pilot_data = explode(',', $Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id'])); | |
| 1028 | 1028 | if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4]; | 
| 1029 | 1029 | $data['format_source'] = $value['format']; | 
| 1030 | 1030 | $SI->add($data); | 
| @@ -1032,22 +1032,22 @@ discard block | ||
| 1032 | 1032 | } | 
| 1033 | 1033 | } | 
| 1034 | 1034 |  	    $Source->deleteOldLocationByType('gs'); | 
| 1035 | -	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20'); | |
| 1035 | +	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php', 'get', '', '', '', '', '20'); | |
| 1036 | 1036 |  	    if ($buffer != '') { | 
| 1037 | 1037 | $all_data = simplexml_load_string($buffer); | 
| 1038 | -		foreach($all_data->children() as $childdata) { | |
| 1038 | +		foreach ($all_data->children() as $childdata) { | |
| 1039 | 1039 | $data = array(); | 
| 1040 | 1040 | $line = $childdata; | 
| 1041 | - $data['id'] = (int)$line['gsID']; | |
| 1042 | - $data['latitude'] = (float)$line['gsLatitude']; | |
| 1043 | - $data['longitude'] = (float)$line['gsLongitude']; | |
| 1044 | - $data['altitude'] = round((int)$line['gsHeight']*3.28084); | |
| 1041 | + $data['id'] = (int) $line['gsID']; | |
| 1042 | + $data['latitude'] = (float) $line['gsLatitude']; | |
| 1043 | + $data['longitude'] = (float) $line['gsLongitude']; | |
| 1044 | + $data['altitude'] = round((int) $line['gsHeight']*3.28084); | |
| 1045 | 1045 | $data['altitude_relative'] = 'AMSL'; | 
| 1046 | -			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['gsLastUpdate'].' BST')); | |
| 1046 | +			$data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['gsLastUpdate'].' BST')); | |
| 1047 | 1047 |  			if (count($Source->getLocationInfoByLocationID($data['id'])) > 0) { | 
| 1048 | -				$Source->updateLocationByLocationID('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']); | |
| 1048 | +				$Source->updateLocationByLocationID('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']); | |
| 1049 | 1049 |  			} else { | 
| 1050 | -				$Source->addLocation('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']); | |
| 1050 | +				$Source->addLocation('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']); | |
| 1051 | 1051 | } | 
| 1052 | 1052 | unset($data); | 
| 1053 | 1053 | } | 
| @@ -1065,9 +1065,9 @@ discard block | ||
| 1065 | 1065 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) | 
| 1066 | 1066 | ) | 
| 1067 | 1067 |  	) { | 
| 1068 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); | |
| 1068 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20'); | |
| 1069 | 1069 |  	    if ($buffer != '') { | 
| 1070 | - $all_data = json_decode($buffer,true); | |
| 1070 | + $all_data = json_decode($buffer, true); | |
| 1071 | 1071 |  		if (isset($all_data['acList'])) { | 
| 1072 | 1072 | $reset = 0; | 
| 1073 | 1073 |  		    foreach ($all_data['acList'] as $line) { | 
| @@ -1083,7 +1083,7 @@ discard block | ||
| 1083 | 1083 | if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk | 
| 1084 | 1084 | $data['emergency'] = ''; // emergency | 
| 1085 | 1085 | if (isset($line['Reg'])) $data['registration'] = $line['Reg']; | 
| 1086 | -			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); | |
| 1086 | +			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000)); | |
| 1087 | 1087 |  			else $data['datetime'] = date('Y-m-d H:i:s'); | 
| 1088 | 1088 |  			//$data['datetime'] = date('Y-m-d H:i:s'); | 
| 1089 | 1089 | if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; | 
| @@ -1108,7 +1108,7 @@ discard block | ||
| 1108 | 1108 | $data['verticalrate'] = $line['vrt']; // verticale rate | 
| 1109 | 1109 | $data['squawk'] = $line['squawk']; // squawk | 
| 1110 | 1110 | $data['emergency'] = ''; // emergency | 
| 1111 | -			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); | |
| 1111 | +			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000)); | |
| 1112 | 1112 |  			else $data['datetime'] = date('Y-m-d H:i:s'); | 
| 1113 | 1113 | $data['format_source'] = 'aircraftlistjson'; | 
| 1114 | 1114 | $data['id_source'] = $id_source; | 
| @@ -1129,7 +1129,7 @@ discard block | ||
| 1129 | 1129 | ) | 
| 1130 | 1130 |      	) { | 
| 1131 | 1131 | $buffer = $Common->getData($value['host']); | 
| 1132 | - $all_data = json_decode($buffer,true); | |
| 1132 | + $all_data = json_decode($buffer, true); | |
| 1133 | 1133 |  	    if (isset($all_data['planes'])) { | 
| 1134 | 1134 | $reset = 0; | 
| 1135 | 1135 |  		foreach ($all_data['planes'] as $key => $line) { | 
| @@ -1146,12 +1146,12 @@ discard block | ||
| 1146 | 1146 | $data['emergency'] = ''; // emergency | 
| 1147 | 1147 | $data['registration'] = $line[2]; | 
| 1148 | 1148 | $data['aircraft_icao'] = $line[0]; | 
| 1149 | -		    $deparr = explode('-',$line[1]); | |
| 1149 | +		    $deparr = explode('-', $line[1]); | |
| 1150 | 1150 |  		    if (count($deparr) === 2) { | 
| 1151 | 1151 | $data['departure_airport_icao'] = $deparr[0]; | 
| 1152 | 1152 | $data['arrival_airport_icao'] = $deparr[1]; | 
| 1153 | 1153 | } | 
| 1154 | -		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]); | |
| 1154 | +		    $data['datetime'] = date('Y-m-d H:i:s', $line[9]); | |
| 1155 | 1155 | $data['format_source'] = 'planeupdatefaa'; | 
| 1156 | 1156 | $data['id_source'] = $id_source; | 
| 1157 | 1157 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | 
| @@ -1169,7 +1169,7 @@ discard block | ||
| 1169 | 1169 | ) | 
| 1170 | 1170 |  	) { | 
| 1171 | 1171 | $buffer = $Common->getData($value['host']); | 
| 1172 | - $all_data = json_decode($buffer,true); | |
| 1172 | + $all_data = json_decode($buffer, true); | |
| 1173 | 1173 |  	    if (isset($all_data['states'])) { | 
| 1174 | 1174 | $reset = 0; | 
| 1175 | 1175 |  		foreach ($all_data['states'] as $key => $line) { | 
| @@ -1186,7 +1186,7 @@ discard block | ||
| 1186 | 1186 | //$data['emergency'] = ''; // emergency | 
| 1187 | 1187 | //$data['registration'] = $line[2]; | 
| 1188 | 1188 | //$data['aircraft_icao'] = $line[0]; | 
| 1189 | -		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]); | |
| 1189 | +		    $data['datetime'] = date('Y-m-d H:i:s', $line[3]); | |
| 1190 | 1190 | $data['format_source'] = 'opensky'; | 
| 1191 | 1191 | $data['id_source'] = $id_source; | 
| 1192 | 1192 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | 
| @@ -1203,8 +1203,8 @@ discard block | ||
| 1203 | 1203 | ) | 
| 1204 | 1204 |  	) { | 
| 1205 | 1205 | $buffer = $Common->getData($value['host']); | 
| 1206 | - $all_data = json_decode($buffer,true); | |
| 1207 | -	    if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time()-1800) { | |
| 1206 | + $all_data = json_decode($buffer, true); | |
| 1207 | +	    if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time() - 1800) { | |
| 1208 | 1208 | $reset = 0; | 
| 1209 | 1209 |  		foreach ($all_data['aircraft'] as $key => $line) { | 
| 1210 | 1210 | $data = array(); | 
| @@ -1242,7 +1242,7 @@ discard block | ||
| 1242 | 1242 | ) | 
| 1243 | 1243 |  	) { | 
| 1244 | 1244 | $buffer = $Common->getData($value['host']); | 
| 1245 | - $all_data = json_decode($buffer,true); | |
| 1245 | + $all_data = json_decode($buffer, true); | |
| 1246 | 1246 |  	    if (isset($all_data['aircraft'])) { | 
| 1247 | 1247 | $reset = 0; | 
| 1248 | 1248 |  		foreach ($all_data['aircraft'] as $key => $line) { | 
| @@ -1259,7 +1259,7 @@ discard block | ||
| 1259 | 1259 | //$data['emergency'] = ''; // emergency | 
| 1260 | 1260 | if (isset($line['reg'])) $data['registration'] = $line['reg']; | 
| 1261 | 1261 | if (isset($line['type'])) $data['aircraft_icao'] = $line['type']; | 
| 1262 | -		    $data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']); | |
| 1262 | +		    $data['datetime'] = date('Y-m-d H:i:s', $line['pos_update_time']); | |
| 1263 | 1263 | $data['format_source'] = 'planefinderclient'; | 
| 1264 | 1264 | $data['id_source'] = $id_source; | 
| 1265 | 1265 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; | 
| @@ -1278,7 +1278,7 @@ discard block | ||
| 1278 | 1278 |  	) { | 
| 1279 | 1279 | //$buffer = $Common->getData($hosts[$id]); | 
| 1280 | 1280 | $buffer = $Common->getData($value['host']); | 
| 1281 | - $all_data = json_decode($buffer,true); | |
| 1281 | + $all_data = json_decode($buffer, true); | |
| 1282 | 1282 | if (!empty($all_data)) $reset = 0; | 
| 1283 | 1283 |  	    foreach ($all_data as $key => $line) { | 
| 1284 | 1284 |  		if ($key != 'full_count' && $key != 'version' && $key != 'stats') { | 
| @@ -1316,11 +1316,11 @@ discard block | ||
| 1316 | 1316 | ) | 
| 1317 | 1317 |  	) { | 
| 1318 | 1318 | //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); | 
| 1319 | - $buffer = $Common->getData($value['host'],'get','','','','','150'); | |
| 1319 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150'); | |
| 1320 | 1320 | //echo $buffer; | 
| 1321 | -	    $buffer = str_replace(array("\n","\r"),"",$buffer); | |
| 1322 | -	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer); | |
| 1323 | - $all_data = json_decode($buffer,true); | |
| 1321 | +	    $buffer = str_replace(array("\n", "\r"), "", $buffer); | |
| 1322 | +	    $buffer = preg_replace('/,"num":(.+)/', '}', $buffer); | |
| 1323 | + $all_data = json_decode($buffer, true); | |
| 1324 | 1324 |  	    if (json_last_error() != JSON_ERROR_NONE) { | 
| 1325 | 1325 | die(json_last_error_msg()); | 
| 1326 | 1326 | } | 
| @@ -1343,7 +1343,7 @@ discard block | ||
| 1343 | 1343 | //$data['departure_airport_iata'] = $line[11]; | 
| 1344 | 1344 | //$data['arrival_airport_iata'] = $line[12]; | 
| 1345 | 1345 | //$data['emergency'] = ''; // emergency | 
| 1346 | -			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] | |
| 1346 | +			$data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10] | |
| 1347 | 1347 | $data['format_source'] = 'radarvirtueljson'; | 
| 1348 | 1348 | $data['id_source'] = $id_source; | 
| 1349 | 1349 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | 
| @@ -1364,14 +1364,14 @@ discard block | ||
| 1364 | 1364 |  	) { | 
| 1365 | 1365 | //$buffer = $Common->getData($hosts[$id]); | 
| 1366 | 1366 | $buffer = $Common->getData($value['host'].'?'.time()); | 
| 1367 | - $all_data = json_decode(utf8_encode($buffer),true); | |
| 1367 | + $all_data = json_decode(utf8_encode($buffer), true); | |
| 1368 | 1368 | |
| 1369 | 1369 |  	    if (isset($all_data['pireps'])) { | 
| 1370 | 1370 | $reset = 0; | 
| 1371 | 1371 |  	        foreach ($all_data['pireps'] as $line) { | 
| 1372 | 1372 | $data = array(); | 
| 1373 | 1373 | $data['id'] = $line['id']; | 
| 1374 | - $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); | |
| 1374 | + $data['hex'] = substr(str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT), 0, 6); | |
| 1375 | 1375 | $data['ident'] = $line['callsign']; // ident | 
| 1376 | 1376 | if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id | 
| 1377 | 1377 | if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name | 
| @@ -1401,9 +1401,9 @@ discard block | ||
| 1401 | 1401 | $SI->add($data); | 
| 1402 | 1402 | // print_r($data); | 
| 1403 | 1403 |      		    } elseif ($line['icon'] === 'ct') { | 
| 1404 | -			$data['info'] = str_replace('^§','<br />',$data['info']); | |
| 1405 | -			$data['info'] = str_replace('&sect;','',$data['info']); | |
| 1406 | - $typec = substr($data['ident'],-3); | |
| 1404 | +			$data['info'] = str_replace('^§', '<br />', $data['info']); | |
| 1405 | +			$data['info'] = str_replace('&sect;', '', $data['info']); | |
| 1406 | + $typec = substr($data['ident'], -3); | |
| 1407 | 1407 | $data['type'] = ''; | 
| 1408 | 1408 | if ($typec === 'APP') $data['type'] = 'Approach'; | 
| 1409 | 1409 | elseif ($typec === 'TWR') $data['type'] = 'Tower'; | 
| @@ -1414,7 +1414,7 @@ discard block | ||
| 1414 | 1414 | elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station'; | 
| 1415 | 1415 | elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre'; | 
| 1416 | 1416 | else $data['type'] = 'Observer'; | 
| 1417 | - 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']); | |
| 1417 | + 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']); | |
| 1418 | 1418 | } | 
| 1419 | 1419 | unset($data); | 
| 1420 | 1420 | } | 
| @@ -1431,14 +1431,14 @@ discard block | ||
| 1431 | 1431 | //$buffer = $Common->getData($hosts[$id]); | 
| 1432 | 1432 | if ($globalDebug) echo 'Get Data...'."\n"; | 
| 1433 | 1433 | $buffer = $Common->getData($value['host']); | 
| 1434 | - $all_data = json_decode($buffer,true); | |
| 1434 | + $all_data = json_decode($buffer, true); | |
| 1435 | 1435 |  	    if ($buffer != '' && is_array($all_data)) { | 
| 1436 | 1436 | $reset = 0; | 
| 1437 | 1437 |  		foreach ($all_data as $line) { | 
| 1438 | 1438 | $data = array(); | 
| 1439 | 1439 | //$data['id'] = $line['id']; // id not usable | 
| 1440 | 1440 | if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; | 
| 1441 | - $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex | |
| 1441 | + $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex | |
| 1442 | 1442 | if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; | 
| 1443 | 1443 | if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; | 
| 1444 | 1444 | $data['ident'] = $line['flightnum']; // ident | 
| @@ -1453,7 +1453,7 @@ discard block | ||
| 1453 | 1453 | //$data['datetime'] = $line['lastupdate']; | 
| 1454 | 1454 | //$data['last_update'] = $line['lastupdate']; | 
| 1455 | 1455 |  	    	    if (isset($value['timezone'])) { | 
| 1456 | - $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); | |
| 1456 | + $datetime = new DateTime($line['lastupdate'], new DateTimeZone($value['timezone'])); | |
| 1457 | 1457 |  	    		$datetime->setTimeZone(new DateTimeZone('UTC')); | 
| 1458 | 1458 |  	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s'); | 
| 1459 | 1459 |  	    	    } else $data['datetime'] = date('Y-m-d H:i:s'); | 
| @@ -1469,14 +1469,14 @@ discard block | ||
| 1469 | 1469 | if (isset($line['route'])) $data['waypoints'] = $line['route']; // route | 
| 1470 | 1470 |  		    if (isset($line['aircraftname'])) { | 
| 1471 | 1471 | $line['aircraftname'] = strtoupper($line['aircraftname']); | 
| 1472 | -			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); | |
| 1473 | -	    		$aircraft_data = explode('-',$line['aircraftname']); | |
| 1472 | +			$line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']); | |
| 1473 | +	    		$aircraft_data = explode('-', $line['aircraftname']); | |
| 1474 | 1474 | if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; | 
| 1475 | 1475 | elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; | 
| 1476 | 1476 |  	    		else { | 
| 1477 | -	    		    $aircraft_data = explode(' ',$line['aircraftname']); | |
| 1478 | -	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); | |
| 1479 | -	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); | |
| 1477 | +	    		    $aircraft_data = explode(' ', $line['aircraftname']); | |
| 1478 | +	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-', '', $aircraft_data[1]); | |
| 1479 | +	    		    else $data['aircraft_icao'] = str_replace('-', '', $line['aircraftname']); | |
| 1480 | 1480 | } | 
| 1481 | 1481 | } | 
| 1482 | 1482 | if (isset($line['route'])) $data['waypoints'] = $line['route']; | 
| @@ -1501,7 +1501,7 @@ discard block | ||
| 1501 | 1501 | //$buffer = $Common->getData($hosts[$id]); | 
| 1502 | 1502 | if ($globalDebug) echo 'Get Data...'."\n"; | 
| 1503 | 1503 | $buffer = $Common->getData($value['host']); | 
| 1504 | - $all_data = json_decode($buffer,true); | |
| 1504 | + $all_data = json_decode($buffer, true); | |
| 1505 | 1505 |  	    if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) { | 
| 1506 | 1506 | $reset = 0; | 
| 1507 | 1507 |  		foreach ($all_data['ACARSData'] as $line) { | 
| @@ -1512,7 +1512,7 @@ discard block | ||
| 1512 | 1512 | //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex | 
| 1513 | 1513 | if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username']; | 
| 1514 | 1514 | if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id']; | 
| 1515 | -	    	    $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident | |
| 1515 | +	    	    $data['ident'] = str_replace(' ', '', $line['bid']['flightnum']); // ident | |
| 1516 | 1516 | if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident']; | 
| 1517 | 1517 | $data['altitude'] = $line['altitude']; // altitude | 
| 1518 | 1518 | $data['speed'] = $line['groundspeed']; // speed | 
| @@ -1523,7 +1523,7 @@ discard block | ||
| 1523 | 1523 | //$data['squawk'] = ''; // squawk | 
| 1524 | 1524 | //$data['emergency'] = ''; // emergency | 
| 1525 | 1525 |  	    	    if (isset($value['timezone'])) { | 
| 1526 | - $datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone'])); | |
| 1526 | + $datetime = new DateTime($line['updated_at'], new DateTimeZone($value['timezone'])); | |
| 1527 | 1527 |  	    		$datetime->setTimeZone(new DateTimeZone('UTC')); | 
| 1528 | 1528 |  	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s'); | 
| 1529 | 1529 |  	    	    } else $data['datetime'] = date('Y-m-d H:i:s'); | 
| @@ -1559,14 +1559,14 @@ discard block | ||
| 1559 | 1559 | //$buffer = $Common->getData($hosts[$id]); | 
| 1560 | 1560 | if ($globalDebug) echo 'Get Data...'."\n"; | 
| 1561 | 1561 | $buffer = $Common->getData($value['host']); | 
| 1562 | - $all_data = json_decode($buffer,true); | |
| 1562 | + $all_data = json_decode($buffer, true); | |
| 1563 | 1563 |  	    if ($buffer != '' && is_array($all_data)) { | 
| 1564 | 1564 | $reset = 0; | 
| 1565 | 1565 |  		foreach ($all_data as $line) { | 
| 1566 | 1566 | $data = array(); | 
| 1567 | 1567 | //$data['id'] = $line['id']; // id not usable | 
| 1568 | 1568 | $data['id'] = trim($line['flight_id']); | 
| 1569 | - $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex | |
| 1569 | + $data['hex'] = substr(str_pad(bin2hex($line['callsign']), 6, '000000', STR_PAD_LEFT), -6); // hex | |
| 1570 | 1570 | $data['pilot_name'] = $line['pilot_name']; | 
| 1571 | 1571 | $data['pilot_id'] = $line['pilot_id']; | 
| 1572 | 1572 | $data['ident'] = trim($line['callsign']); // ident | 
| @@ -1610,24 +1610,24 @@ discard block | ||
| 1610 | 1610 | //$buffer = $Common->getData($hosts[$id]); | 
| 1611 | 1611 | if ($globalDebug) echo 'Get Data...'."\n"; | 
| 1612 | 1612 | $buffer = $Common->getData($value['host']); | 
| 1613 | - $all_data = json_decode($buffer,true); | |
| 1613 | + $all_data = json_decode($buffer, true); | |
| 1614 | 1614 |  	    if ($buffer != '') { | 
| 1615 | 1615 |  		$Source->deleteLocationBySource('blitzortung'); | 
| 1616 | -		$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); | |
| 1617 | -		$buffer = explode('\n',$buffer); | |
| 1616 | +		$buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); | |
| 1617 | +		$buffer = explode('\n', $buffer); | |
| 1618 | 1618 |  		foreach ($buffer as $buffer_line) { | 
| 1619 | - $line = json_decode($buffer_line,true); | |
| 1619 | + $line = json_decode($buffer_line, true); | |
| 1620 | 1620 |  		    if (isset($line['time'])) { | 
| 1621 | 1621 | $data = array(); | 
| 1622 | 1622 | $data['altitude'] = $line['alt']; // altitude | 
| 1623 | 1623 | $data['latitude'] = $line['lat']; // lat | 
| 1624 | 1624 | $data['longitude'] = $line['lon']; // long | 
| 1625 | -			$data['datetime'] = date('Y-m-d H:i:s',substr($line['time'],0,10)); | |
| 1625 | +			$data['datetime'] = date('Y-m-d H:i:s', substr($line['time'], 0, 10)); | |
| 1626 | 1626 | $data['id_source'] = $id_source; | 
| 1627 | 1627 | $data['format_source'] = 'blitzortung'; | 
| 1628 | 1628 | $SI->add($data); | 
| 1629 | 1629 | if ($globalDebug) echo '☈ Lightning added'."\n"; | 
| 1630 | -			$Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']); | |
| 1630 | +			$Source->addLocation('', $data['latitude'], $data['longitude'], 0, '', '', 'blitzortung', 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime']); | |
| 1631 | 1631 | unset($data); | 
| 1632 | 1632 | } | 
| 1633 | 1633 | } | 
| @@ -1639,15 +1639,15 @@ discard block | ||
| 1639 | 1639 | $arr = $httpfeeds; | 
| 1640 | 1640 | $w = $e = null; | 
| 1641 | 1641 |          if (isset($arr[$id])) { | 
| 1642 | - $nn = stream_select($arr,$w,$e,$timeout); | |
| 1642 | + $nn = stream_select($arr, $w, $e, $timeout); | |
| 1643 | 1643 |              if ($nn > 0) { | 
| 1644 | 1644 |                  foreach ($httpfeeds as $feed) { | 
| 1645 | - $buffer = stream_get_line($feed,2000,"\n"); | |
| 1645 | + $buffer = stream_get_line($feed, 2000, "\n"); | |
| 1646 | 1646 |                      if ($buffer === FALSE) { | 
| 1647 | 1647 | connect_all($globalSources); | 
| 1648 | 1648 | } | 
| 1649 | -                    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); | |
| 1650 | -                    $buffer = explode('\n',$buffer); | |
| 1649 | +                    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); | |
| 1650 | +                    $buffer = explode('\n', $buffer); | |
| 1651 | 1651 |                      foreach ($buffer as $line) { | 
| 1652 | 1652 |                          if ($line != '') { | 
| 1653 | 1653 | $line = json_decode($line, true); | 
| @@ -1687,11 +1687,11 @@ discard block | ||
| 1687 | 1687 | //$value = $formats[$nb]; | 
| 1688 | 1688 | $format = $globalSources[$nb]['format']; | 
| 1689 | 1689 |  		    if ($format === 'sbs' || $format === 'aprs' || $format === 'famaprs' || $format === 'raw' || $format === 'tsv' || $format === 'acarssbs3') { | 
| 1690 | - $buffer = @socket_read($r, 6000,PHP_NORMAL_READ); | |
| 1690 | + $buffer = @socket_read($r, 6000, PHP_NORMAL_READ); | |
| 1691 | 1691 |  		    } elseif ($format === 'vrstcp') { | 
| 1692 | 1692 | $buffer = @socket_read($r, 6000); | 
| 1693 | 1693 |  		    } else { | 
| 1694 | - $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); | |
| 1694 | + $az = socket_recvfrom($r, $buffer, 6000, 0, $remote_ip, $remote_port); | |
| 1695 | 1695 | } | 
| 1696 | 1696 | //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); | 
| 1697 | 1697 | //echo $buffer."\n"; | 
| @@ -1701,8 +1701,8 @@ discard block | ||
| 1701 | 1701 | //$SI::del(); | 
| 1702 | 1702 |  		    if ($buffer !== FALSE) { | 
| 1703 | 1703 |  			if ($format === 'vrstcp') { | 
| 1704 | -			    $buffer = explode('},{',$buffer); | |
| 1705 | -			} else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); | |
| 1704 | +			    $buffer = explode('},{', $buffer); | |
| 1705 | +			} else $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer)); | |
| 1706 | 1706 | } | 
| 1707 | 1707 | // SBS format is CSV format | 
| 1708 | 1708 |  		    if ($buffer !== FALSE && $buffer !== '') { | 
| @@ -1729,7 +1729,7 @@ discard block | ||
| 1729 | 1729 | $ais_data = $AIS->parse_line(trim($buffer)); | 
| 1730 | 1730 | $data = array(); | 
| 1731 | 1731 | if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; | 
| 1732 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); | |
| 1732 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'], -9); | |
| 1733 | 1733 | if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; | 
| 1734 | 1734 | if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; | 
| 1735 | 1735 | if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; | 
| @@ -1740,13 +1740,13 @@ discard block | ||
| 1740 | 1740 | if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; | 
| 1741 | 1741 | if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; | 
| 1742 | 1742 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; | 
| 1743 | -			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); | |
| 1743 | +			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']); | |
| 1744 | 1744 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; | 
| 1745 | 1745 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; | 
| 1746 | 1746 | if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; | 
| 1747 | 1747 | |
| 1748 | 1748 |  			    if (isset($ais_data['timestamp'])) { | 
| 1749 | -				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); | |
| 1749 | +				$data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); | |
| 1750 | 1750 |  			    } else { | 
| 1751 | 1751 |  				$data['datetime'] = date('Y-m-d H:i:s'); | 
| 1752 | 1752 | } | 
| @@ -1757,10 +1757,10 @@ discard block | ||
| 1757 | 1757 |                          } elseif ($format === 'flightgearsp') { | 
| 1758 | 1758 | //echo $buffer."\n"; | 
| 1759 | 1759 |                      	    if (strlen($buffer) > 5) { | 
| 1760 | -				$line = explode(',',$buffer); | |
| 1760 | +				$line = explode(',', $buffer); | |
| 1761 | 1761 | $data = array(); | 
| 1762 | 1762 | //XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p | 
| 1763 | - $data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]),6,'000000',STR_PAD_LEFT),0,6); | |
| 1763 | + $data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]), 6, '000000', STR_PAD_LEFT), 0, 6); | |
| 1764 | 1764 | $data['ident'] = $line[6]; | 
| 1765 | 1765 | $data['aircraft_name'] = $line[7]; | 
| 1766 | 1766 | $data['longitude'] = $line[1]; | 
| @@ -1777,25 +1777,25 @@ discard block | ||
| 1777 | 1777 |                          } elseif ($format === 'acars') { | 
| 1778 | 1778 | if ($globalDebug) echo 'ACARS : '.$buffer."\n"; | 
| 1779 | 1779 | $ACARS->add(trim($buffer)); | 
| 1780 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); | |
| 1780 | + socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port); | |
| 1781 | 1781 | $ACARS->deleteLiveAcarsData(); | 
| 1782 | 1782 |  			} elseif ($format === 'acarsjsonudp') { | 
| 1783 | 1783 | if ($globalDebug) echo 'ACARS : '.$buffer."\n"; | 
| 1784 | 1784 | $line = json_decode(trim($buffer), true); | 
| 1785 | 1785 |                              if (!empty($line)) { | 
| 1786 | -				$line = array_merge(array('text' => '','tail' => '','label' => '','block_id' => '','flight' => '','msgno' => ''),$line); | |
| 1786 | +				$line = array_merge(array('text' => '', 'tail' => '', 'label' => '', 'block_id' => '', 'flight' => '', 'msgno' => ''), $line); | |
| 1787 | 1787 |                                  $ACARS->add(isset($line['text']) ? $line['text'] : '', array('registration' => str_replace('.', '', $line['tail']), 'ident' => $line['flight'], 'label' => $line['label'], 'block_id' => $line['block_id'], 'msg_no' => $line['msgno'], 'message' => (isset($line['text']) ? $line['text'] : ''))); | 
| 1788 | 1788 | $ACARS->deleteLiveAcarsData(); | 
| 1789 | 1789 | } | 
| 1790 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); | |
| 1790 | + socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port); | |
| 1791 | 1791 |  			} elseif ($format === 'flightgearmp') { | 
| 1792 | -			    if (substr($buffer,0,1) != '#') { | |
| 1792 | +			    if (substr($buffer, 0, 1) != '#') { | |
| 1793 | 1793 | $data = array(); | 
| 1794 | 1794 | //echo $buffer."\n"; | 
| 1795 | -				$line = explode(' ',$buffer); | |
| 1795 | +				$line = explode(' ', $buffer); | |
| 1796 | 1796 |  				if (count($line) === 11) { | 
| 1797 | -				    $userserver = explode('@',$line[0]); | |
| 1798 | - $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex | |
| 1797 | +				    $userserver = explode('@', $line[0]); | |
| 1798 | + $data['hex'] = substr(str_pad(bin2hex($line[0]), 6, '000000', STR_PAD_LEFT), 0, 6); // hex | |
| 1799 | 1799 | $data['ident'] = $userserver[0]; | 
| 1800 | 1800 | $data['registration'] = $userserver[0]; | 
| 1801 | 1801 | $data['latitude'] = $line[4]; | 
| @@ -1803,8 +1803,8 @@ discard block | ||
| 1803 | 1803 | $data['altitude'] = $line[6]; | 
| 1804 | 1804 |  				    $data['datetime'] = date('Y-m-d H:i:s'); | 
| 1805 | 1805 | $aircraft_type = $line[10]; | 
| 1806 | -				    $aircraft_type = preg_split(':/:',$aircraft_type); | |
| 1807 | - $data['aircraft_name'] = substr(end($aircraft_type),0,-4); | |
| 1806 | +				    $aircraft_type = preg_split(':/:', $aircraft_type); | |
| 1807 | + $data['aircraft_name'] = substr(end($aircraft_type), 0, -4); | |
| 1808 | 1808 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; | 
| 1809 | 1809 | if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); | 
| 1810 | 1810 | } | 
| @@ -1813,8 +1813,8 @@ discard block | ||
| 1813 | 1813 | echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; | 
| 1814 | 1814 | die; | 
| 1815 | 1815 |  			} elseif ($format === 'vrstcp') { | 
| 1816 | -			    foreach($buffer as $all_data) { | |
| 1817 | -				$line = json_decode('{'.$all_data.'}',true); | |
| 1816 | +			    foreach ($buffer as $all_data) { | |
| 1817 | +				$line = json_decode('{'.$all_data.'}', true); | |
| 1818 | 1818 | $data = array(); | 
| 1819 | 1819 | if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex | 
| 1820 | 1820 | if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident | 
| @@ -1840,16 +1840,16 @@ discard block | ||
| 1840 | 1840 | if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); | 
| 1841 | 1841 | unset($data); | 
| 1842 | 1842 | } | 
| 1843 | -			} elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') { | |
| 1843 | +			} elseif ($format === 'tsv' || substr($buffer, 0, 4) === 'clock') { | |
| 1844 | 1844 |  			    $line = explode("\t", $buffer); | 
| 1845 | -			    for($k = 0; $k < count($line); $k=$k+2) { | |
| 1845 | +			    for ($k = 0; $k < count($line); $k = $k + 2) { | |
| 1846 | 1846 | $key = $line[$k]; | 
| 1847 | - $lined[$key] = $line[$k+1]; | |
| 1847 | + $lined[$key] = $line[$k + 1]; | |
| 1848 | 1848 | } | 
| 1849 | 1849 |      			    if (count($lined) > 3) { | 
| 1850 | 1850 | $data['hex'] = $lined['hexid']; | 
| 1851 | 1851 |      				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; | 
| 1852 | -    				$data['datetime'] = date('Y-m-d H:i:s');; | |
| 1852 | +    				$data['datetime'] = date('Y-m-d H:i:s'); ; | |
| 1853 | 1853 | if (isset($lined['ident'])) $data['ident'] = $lined['ident']; | 
| 1854 | 1854 | if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; | 
| 1855 | 1855 | if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; | 
| @@ -1868,23 +1868,23 @@ discard block | ||
| 1868 | 1868 | } else $error = true; | 
| 1869 | 1869 |  			} elseif ($format === 'aprs' && $use_aprs) { | 
| 1870 | 1870 |  			    if ($aprs_connect === 0) { | 
| 1871 | - $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); | |
| 1871 | + $send = @ socket_send($r, $aprs_login, strlen($aprs_login), 0); | |
| 1872 | 1872 | $aprs_connect = 1; | 
| 1873 | 1873 | } | 
| 1874 | 1874 | |
| 1875 | -			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { | |
| 1875 | +			    if ($aprs_keep > 60 && time() - $aprs_last_tx > $aprs_keep) { | |
| 1876 | 1876 | $aprs_last_tx = time(); | 
| 1877 | 1877 | $data_aprs = "# Keep alive"; | 
| 1878 | - $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); | |
| 1878 | + $send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0); | |
| 1879 | 1879 | } | 
| 1880 | 1880 | |
| 1881 | 1881 | //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; | 
| 1882 | 1882 | //echo 'APRS data : '.$buffer."\n"; | 
| 1883 | -			    $buffer = str_replace('APRS <- ','',$buffer); | |
| 1884 | -			    $buffer = str_replace('APRS -> ','',$buffer); | |
| 1883 | +			    $buffer = str_replace('APRS <- ', '', $buffer); | |
| 1884 | +			    $buffer = str_replace('APRS -> ', '', $buffer); | |
| 1885 | 1885 | //echo $buffer."\n"; | 
| 1886 | 1886 |  			    date_default_timezone_set('UTC'); | 
| 1887 | -			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { | |
| 1887 | +			    if (substr($buffer, 0, 1) != '#' && substr($buffer, 0, 1) != '@' && substr($buffer, 0, 5) != 'APRS ') { | |
| 1888 | 1888 | $line = $APRS->parse($buffer); | 
| 1889 | 1889 |  				//if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) { | 
| 1890 | 1890 |  				if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) { | 
| @@ -1899,7 +1899,7 @@ discard block | ||
| 1899 | 1899 | if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date']; | 
| 1900 | 1900 | if (isset($line['typeid'])) $data['type_id'] = $line['typeid']; | 
| 1901 | 1901 | if (isset($line['statusid'])) $data['status_id'] = $line['statusid']; | 
| 1902 | -				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); | |
| 1902 | +				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']); | |
| 1903 | 1903 |  				    else $data['datetime'] = date('Y-m-d H:i:s'); | 
| 1904 | 1904 |  				    //$data['datetime'] = date('Y-m-d H:i:s'); | 
| 1905 | 1905 | if (isset($line['ident'])) $data['ident'] = $line['ident']; | 
| @@ -1987,29 +1987,29 @@ discard block | ||
| 1987 | 1987 |  				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { | 
| 1988 | 1988 | if (!isset($data['altitude'])) $data['altitude'] = 0; | 
| 1989 | 1989 |  					$Source->deleteOldLocationByType('gs'); | 
| 1990 | -					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) { | |
| 1991 | - $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); | |
| 1990 | +					if (count($Source->getLocationInfoByNameType($data['ident'], 'gs')) > 0) { | |
| 1991 | + $Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']); | |
| 1992 | 1992 |  					} else { | 
| 1993 | - $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); | |
| 1993 | + $Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']); | |
| 1994 | 1994 | } | 
| 1995 | 1995 |  				    } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') { | 
| 1996 | 1996 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; | 
| 1997 | 1997 | if ($globalDebug) echo '# Weather Station added'."\n"; | 
| 1998 | 1998 |  					$Source->deleteOldLocationByType('wx'); | 
| 1999 | 1999 | $weather_data = json_encode($line); | 
| 2000 | -					if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) { | |
| 2001 | - $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data); | |
| 2000 | +					if (count($Source->getLocationInfoByNameType($data['ident'], 'wx')) > 0) { | |
| 2001 | + $Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data); | |
| 2002 | 2002 |  					} else { | 
| 2003 | - $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data); | |
| 2003 | + $Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data); | |
| 2004 | 2004 | } | 
| 2005 | 2005 |  				    } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) { | 
| 2006 | 2006 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; | 
| 2007 | 2007 | if ($globalDebug) echo '☈ Lightning added'."\n"; | 
| 2008 | 2008 |  					$Source->deleteOldLocationByType('lightning'); | 
| 2009 | -					if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) { | |
| 2010 | - $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']); | |
| 2009 | +					if (count($Source->getLocationInfoByNameType($data['ident'], 'lightning')) > 0) { | |
| 2010 | + $Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']); | |
| 2011 | 2011 |  					} else { | 
| 2012 | - $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']); | |
| 2012 | + $Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']); | |
| 2013 | 2013 | } | 
| 2014 | 2014 |  				    } elseif ($globalDebug) { | 
| 2015 | 2015 | echo '/!\ Not added: '.$buffer."\n"; | 
| @@ -2018,7 +2018,7 @@ discard block | ||
| 2018 | 2018 | unset($data); | 
| 2019 | 2019 | } | 
| 2020 | 2020 |  				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { | 
| 2021 | - $Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']); | |
| 2021 | + $Source->updateLocationDescByName($line['ident'], $line['source'], $id, $line['comment']); | |
| 2022 | 2022 | } | 
| 2023 | 2023 | /* | 
| 2024 | 2024 |  				elseif (is_array($line) && $globalDebug && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] === 'Car' || $line['symbol'] === 'Ambulance' || $line['symbol'] === 'Van' || $line['symbol'] === 'Truck' || $line['symbol'] === 'Truck (18 Wheeler)' || $line['symbol'] === 'Motorcycle')) { | 
| @@ -2027,7 +2027,7 @@ discard block | ||
| 2027 | 2027 | */ | 
| 2028 | 2028 |  				//elseif ($line === false && $globalDebug) echo 'Ignored ('.$buffer.")\n"; | 
| 2029 | 2029 | elseif ($line === true && $globalDebug) echo '!! Failed : '.$buffer."!!\n"; | 
| 2030 | -				if (isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) { | |
| 2030 | +				if (isset($globalSources[$nb]['last_weather_clean']) && time() - $globalSources[$nb]['last_weather_clean'] > 60*5) { | |
| 2031 | 2031 |  					$Source->deleteOldLocationByType('lightning'); | 
| 2032 | 2032 |  					$Source->deleteOldLocationByType('wx'); | 
| 2033 | 2033 | $globalSources[$nb]['last_weather_clean'] = time(); | 
| @@ -2114,7 +2114,7 @@ discard block | ||
| 2114 | 2114 | connect_all($sourceee); | 
| 2115 | 2115 | $sourceee = array(); | 
| 2116 | 2116 | //connect_all($globalSources); | 
| 2117 | - $tt[$format]=0; | |
| 2117 | + $tt[$format] = 0; | |
| 2118 | 2118 | break; | 
| 2119 | 2119 | } | 
| 2120 | 2120 |  			    //else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."..."; | 
| @@ -2124,14 +2124,14 @@ discard block | ||
| 2124 | 2124 |  	    } else { | 
| 2125 | 2125 | $error = socket_strerror(socket_last_error()); | 
| 2126 | 2126 |  		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { | 
| 2127 | - if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; | |
| 2127 | + if ($globalDebug) echo "ERROR : socket_select give this error ".$error."\n"; | |
| 2128 | 2128 | if (isset($globalDebug)) echo "Restarting...\n"; | 
| 2129 | 2129 | // Restart the script if possible | 
| 2130 | 2130 |  			if (is_array($sockets)) { | 
| 2131 | 2131 | if ($globalDebug) echo "Shutdown all sockets..."; | 
| 2132 | 2132 | |
| 2133 | 2133 |  			    foreach ($sockets as $sock) { | 
| 2134 | - @socket_shutdown($sock,2); | |
| 2134 | + @socket_shutdown($sock, 2); | |
| 2135 | 2135 | @socket_close($sock); | 
| 2136 | 2136 | } | 
| 2137 | 2137 | |
| @@ -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,17 +350,26 @@ 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'] == '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) 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) { | |
| 371 | +    			echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; | |
| 372 | + } | |
| 285 | 373 |          } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { | 
| 286 | 374 |  	    $hostport = explode(':',$host); | 
| 287 | 375 |  	    if (isset($hostport[1])) { | 
| @@ -322,20 +410,29 @@ discard block | ||
| 322 | 410 | //$formats[$id] = 'beast'; | 
| 323 | 411 | $globalSources[$id]['format'] = 'beast'; | 
| 324 | 412 | //} else $formats[$id] = 'sbs'; | 
| 325 | - } else $globalSources[$id]['format'] = 'sbs'; | |
| 413 | +		    } else { | |
| 414 | + $globalSources[$id]['format'] = 'sbs'; | |
| 415 | + } | |
| 326 | 416 |  		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; | 
| 327 | 417 | } | 
| 328 | -		if ($globalDebug && $udp) echo 'Listening in UDP from '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; | |
| 329 | -		elseif ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; | |
| 418 | +		if ($globalDebug && $udp) { | |
| 419 | +			echo 'Listening in UDP from '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; | |
| 420 | +		} elseif ($globalDebug) { | |
| 421 | +			echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; | |
| 422 | + } | |
| 330 | 423 |              } else { | 
| 331 | - if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; | |
| 424 | +		if ($globalDebug) { | |
| 425 | + echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; | |
| 426 | + } | |
| 332 | 427 | sleep(10); | 
| 333 | 428 | connect_all($hosts); | 
| 334 | 429 | } | 
| 335 | 430 | } | 
| 336 | 431 | } | 
| 337 | 432 | } | 
| 338 | -if (!isset($globalMinFetch)) $globalMinFetch = 15; | |
| 433 | +if (!isset($globalMinFetch)) { | |
| 434 | + $globalMinFetch = 15; | |
| 435 | +} | |
| 339 | 436 | |
| 340 | 437 | // Initialize all | 
| 341 | 438 | $status = array(); | 
| @@ -344,13 +441,19 @@ discard block | ||
| 344 | 441 | $formats = array(); | 
| 345 | 442 | $last_exec = array(); | 
| 346 | 443 | $time = time(); | 
| 347 | -if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut; | |
| 348 | -else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut; | |
| 349 | -else $timeout = 20; | |
| 444 | +if (isset($globalSourcesTimeout)) { | |
| 445 | + $timeout = $globalSourcesTimeOut; | |
| 446 | +} else if (isset($globalSBS1TimeOut)) { | |
| 447 | + $timeout = $globalSBS1TimeOut; | |
| 448 | +} else { | |
| 449 | + $timeout = 20; | |
| 450 | +} | |
| 350 | 451 | $errno = ''; | 
| 351 | 452 | $errstr=''; | 
| 352 | 453 | |
| 353 | -if (!isset($globalDaemon)) $globalDaemon = TRUE; | |
| 454 | +if (!isset($globalDaemon)) { | |
| 455 | + $globalDaemon = TRUE; | |
| 456 | +} | |
| 354 | 457 | /* Initiate connections to all the hosts simultaneously */ | 
| 355 | 458 | //connect_all($hosts); | 
| 356 | 459 | //connect_all($globalSources); | 
| @@ -379,7 +482,9 @@ discard block | ||
| 379 | 482 |      if (isset($source['format']) && $source['format'] == 'aprs') { | 
| 380 | 483 | $aprs_connect = 0; | 
| 381 | 484 | $use_aprs = true; | 
| 382 | - if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true; | |
| 485 | +	if (isset($source['port']) && $source['port'] == '10152') { | |
| 486 | + $aprs_full = true; | |
| 487 | + } | |
| 383 | 488 | break; | 
| 384 | 489 | } | 
| 385 | 490 | } | 
| @@ -390,25 +495,46 @@ discard block | ||
| 390 | 495 | $aprs_connect = 0; | 
| 391 | 496 | $aprs_keep = 120; | 
| 392 | 497 | $aprs_last_tx = time(); | 
| 393 | - if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; | |
| 394 | -	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); | |
| 395 | - if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid; | |
| 396 | -	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); | |
| 397 | - if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter; | |
| 398 | - else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; | |
| 399 | - if ($aprs_full) $aprs_filter = ''; | |
| 400 | - if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass; | |
| 401 | - else $aprs_pass = '-1'; | |
| 498 | +	if (isset($globalAPRSversion)) { | |
| 499 | + $aprs_version = $globalAPRSversion; | |
| 500 | +	} else { | |
| 501 | +		$aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); | |
| 502 | + } | |
| 503 | +	if (isset($globalAPRSssid)) { | |
| 504 | + $aprs_ssid = $globalAPRSssid; | |
| 505 | +	} else { | |
| 506 | +		$aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); | |
| 507 | + } | |
| 508 | +	if (isset($globalAPRSfilter)) { | |
| 509 | + $aprs_filter = $globalAPRSfilter; | |
| 510 | +	} else { | |
| 511 | + $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; | |
| 512 | + } | |
| 513 | +	if ($aprs_full) { | |
| 514 | + $aprs_filter = ''; | |
| 515 | + } | |
| 516 | +	if (isset($globalAPRSpass)) { | |
| 517 | + $aprs_pass = $globalAPRSpass; | |
| 518 | +	} else { | |
| 519 | + $aprs_pass = '-1'; | |
| 520 | + } | |
| 402 | 521 | |
| 403 | -	if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n"; | |
| 404 | -	else $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; | |
| 405 | -} | |
| 522 | +	if ($aprs_filter != '') { | |
| 523 | +		$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n"; | |
| 524 | +	} else { | |
| 525 | +		$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; | |
| 526 | + } | |
| 527 | + } | |
| 406 | 528 | |
| 407 | 529 | // connected - lets do some work | 
| 408 | 530 | //if ($globalDebug) echo "Connected!\n"; | 
| 409 | 531 | sleep(1); | 
| 410 | -if ($globalDebug) echo "SCAN MODE \n\n"; | |
| 411 | -if (!isset($globalCronEnd)) $globalCronEnd = 60; | |
| 532 | +if ($globalDebug) { | |
| 533 | + echo "SCAN MODE \n\n"; | |
| 534 | +} | |
| 535 | +if (!isset($globalCronEnd)) { | |
| 536 | + $globalCronEnd = 60; | |
| 537 | +} | |
| 412 | 538 | $endtime = time()+$globalCronEnd; | 
| 413 | 539 | $i = 1; | 
| 414 | 540 | $tt = array(); | 
| @@ -422,22 +548,32 @@ discard block | ||
| 422 | 548 | |
| 423 | 549 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. | 
| 424 | 550 |  while ($i > 0) { | 
| 425 | -    if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); | |
| 551 | +    if (function_exists('pcntl_fork')) { | |
| 552 | + pcntl_signal_dispatch(); | |
| 553 | + } | |
| 426 | 554 | |
| 427 | - if (!$globalDaemon) $i = $endtime-time(); | |
| 555 | +    if (!$globalDaemon) { | |
| 556 | + $i = $endtime-time(); | |
| 557 | + } | |
| 428 | 558 | // Delete old ATC | 
| 429 | 559 |      if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { | 
| 430 | - if ($globalDebug) echo 'Delete old ATC...'."\n"; | |
| 560 | +	if ($globalDebug) { | |
| 561 | + echo 'Delete old ATC...'."\n"; | |
| 562 | + } | |
| 431 | 563 | $ATC->deleteOldATC(); | 
| 432 | 564 | } | 
| 433 | 565 | |
| 434 | 566 |      if (count($last_exec) == count($globalSources)) { | 
| 435 | 567 | $max = $globalMinFetch; | 
| 436 | 568 |  	foreach ($last_exec as $last) { | 
| 437 | - if ((time() - $last['last']) < $max) $max = time() - $last['last']; | |
| 569 | +	    if ((time() - $last['last']) < $max) { | |
| 570 | + $max = time() - $last['last']; | |
| 571 | + } | |
| 438 | 572 | } | 
| 439 | 573 |  	if ($max < $globalMinFetch) { | 
| 440 | - if ($globalDebug) echo 'Sleeping...'."\n"; | |
| 574 | +	    if ($globalDebug) { | |
| 575 | + echo 'Sleeping...'."\n"; | |
| 576 | + } | |
| 441 | 577 | sleep($globalMinFetch-$max+2); | 
| 442 | 578 | } | 
| 443 | 579 | } | 
| @@ -447,7 +583,9 @@ discard block | ||
| 447 | 583 |      foreach ($globalSources as $id => $value) { | 
| 448 | 584 |  	date_default_timezone_set('UTC'); | 
| 449 | 585 | //if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n"; | 
| 450 | - if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0; | |
| 586 | +	if (!isset($last_exec[$id]['last'])) { | |
| 587 | + $last_exec[$id]['last'] = 0; | |
| 588 | + } | |
| 451 | 589 | if ($value['format'] === 'deltadbtxt' && | 
| 452 | 590 | ( | 
| 453 | 591 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || | 
| @@ -456,7 +594,9 @@ discard block | ||
| 456 | 594 |  	) { | 
| 457 | 595 | //$buffer = $Common->getData($hosts[$id]); | 
| 458 | 596 | $buffer = $Common->getData($value['host']); | 
| 459 | - if ($buffer != '') $reset = 0; | |
| 597 | +        if ($buffer != '') { | |
| 598 | + $reset = 0; | |
| 599 | + } | |
| 460 | 600 |          $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); | 
| 461 | 601 |          $buffer = explode('\n', $buffer); | 
| 462 | 602 |          foreach ($buffer as $line) { | 
| @@ -465,20 +605,41 @@ discard block | ||
| 465 | 605 | $data = array(); | 
| 466 | 606 | $data['hex'] = $line[1]; // hex | 
| 467 | 607 | $data['ident'] = $line[2]; // ident | 
| 468 | - if (isset($line[3])) $data['altitude'] = $line[3]; // altitude | |
| 469 | - if (isset($line[4])) $data['speed'] = $line[4]; // speed | |
| 470 | - if (isset($line[5])) $data['heading'] = $line[5]; // heading | |
| 471 | - if (isset($line[6])) $data['latitude'] = $line[6]; // lat | |
| 472 | - if (isset($line[7])) $data['longitude'] = $line[7]; // long | |
| 608 | +                if (isset($line[3])) { | |
| 609 | + $data['altitude'] = $line[3]; | |
| 610 | + } | |
| 611 | + // altitude | |
| 612 | +                if (isset($line[4])) { | |
| 613 | + $data['speed'] = $line[4]; | |
| 614 | + } | |
| 615 | + // speed | |
| 616 | +                if (isset($line[5])) { | |
| 617 | + $data['heading'] = $line[5]; | |
| 618 | + } | |
| 619 | + // heading | |
| 620 | +                if (isset($line[6])) { | |
| 621 | + $data['latitude'] = $line[6]; | |
| 622 | + } | |
| 623 | + // lat | |
| 624 | +                if (isset($line[7])) { | |
| 625 | + $data['longitude'] = $line[7]; | |
| 626 | + } | |
| 627 | + // long | |
| 473 | 628 | $data['verticalrate'] = ''; // vertical rate | 
| 474 | 629 | //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk | 
| 475 | 630 | $data['emergency'] = ''; // emergency | 
| 476 | 631 |                  $data['datetime'] = date('Y-m-d H:i:s'); | 
| 477 | 632 | $data['format_source'] = 'deltadbtxt'; | 
| 478 | 633 | $data['id_source'] = $id_source; | 
| 479 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; | |
| 480 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 481 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; | |
| 634 | +                if (isset($value['name']) && $value['name'] != '') { | |
| 635 | + $data['source_name'] = $value['name']; | |
| 636 | + } | |
| 637 | +                if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { | |
| 638 | + $data['noarchive'] = true; | |
| 639 | + } | |
| 640 | +                if (isset($value['sourcestats'])) { | |
| 641 | + $data['sourcestats'] = $value['sourcestats']; | |
| 642 | + } | |
| 482 | 643 | $SI->add($data); | 
| 483 | 644 | unset($data); | 
| 484 | 645 | } | 
| @@ -513,11 +674,20 @@ discard block | ||
| 513 | 674 | $data['format_source'] = 'radarcapejson'; | 
| 514 | 675 | $data['id_source'] = $id_source; | 
| 515 | 676 |                      if (isset($value['name']) && $value['name'] != '') { | 
| 516 | - if (isset($line['src']) && !$line['src'] == 'M') $data['source_name'] = $value['name'].'_MLAT'; | |
| 517 | - else $data['source_name'] = $value['name']; | |
| 518 | - } elseif (isset($line['src']) && $line['src'] == 'M') $data['source_name'] = 'MLAT'; | |
| 519 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 520 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; | |
| 677 | +                        if (isset($line['src']) && !$line['src'] == 'M') { | |
| 678 | + $data['source_name'] = $value['name'].'_MLAT'; | |
| 679 | +                        } else { | |
| 680 | + $data['source_name'] = $value['name']; | |
| 681 | + } | |
| 682 | +                    } elseif (isset($line['src']) && $line['src'] == 'M') { | |
| 683 | + $data['source_name'] = 'MLAT'; | |
| 684 | + } | |
| 685 | +                    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { | |
| 686 | + $data['noarchive'] = true; | |
| 687 | + } | |
| 688 | +                    if (isset($value['sourcestats'])) { | |
| 689 | + $data['sourcestats'] = $value['sourcestats']; | |
| 690 | + } | |
| 521 | 691 | |
| 522 | 692 | $SI->add($data); | 
| 523 | 693 | unset($data); | 
| @@ -533,7 +703,9 @@ discard block | ||
| 533 | 703 |  	    date_default_timezone_set('CET'); | 
| 534 | 704 |  	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); | 
| 535 | 705 |  	    date_default_timezone_set('UTC'); | 
| 536 | - if ($buffer != '') $reset = 0; | |
| 706 | +	    if ($buffer != '') { | |
| 707 | + $reset = 0; | |
| 708 | + } | |
| 537 | 709 |      	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); | 
| 538 | 710 |  	    $buffer = explode('\n',$buffer); | 
| 539 | 711 |  	    foreach ($buffer as $line) { | 
| @@ -542,18 +714,42 @@ discard block | ||
| 542 | 714 | $add = false; | 
| 543 | 715 | $ais_data = $AIS->parse_line(trim($line)); | 
| 544 | 716 | $data = array(); | 
| 545 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; | |
| 546 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); | |
| 547 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; | |
| 548 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; | |
| 549 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; | |
| 550 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; | |
| 551 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; | |
| 552 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; | |
| 553 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; | |
| 554 | - if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid']; | |
| 555 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; | |
| 556 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; | |
| 717 | +		    if (isset($ais_data['ident'])) { | |
| 718 | + $data['ident'] = $ais_data['ident']; | |
| 719 | + } | |
| 720 | +		    if (isset($ais_data['mmsi'])) { | |
| 721 | + $data['mmsi'] = substr($ais_data['mmsi'],-9); | |
| 722 | + } | |
| 723 | +		    if (isset($ais_data['speed'])) { | |
| 724 | + $data['speed'] = $ais_data['speed']; | |
| 725 | + } | |
| 726 | +		    if (isset($ais_data['heading'])) { | |
| 727 | + $data['heading'] = $ais_data['heading']; | |
| 728 | + } | |
| 729 | +		    if (isset($ais_data['latitude'])) { | |
| 730 | + $data['latitude'] = $ais_data['latitude']; | |
| 731 | + } | |
| 732 | +		    if (isset($ais_data['longitude'])) { | |
| 733 | + $data['longitude'] = $ais_data['longitude']; | |
| 734 | + } | |
| 735 | +		    if (isset($ais_data['status'])) { | |
| 736 | + $data['status'] = $ais_data['status']; | |
| 737 | + } | |
| 738 | +		    if (isset($ais_data['statusid'])) { | |
| 739 | + $data['status_id'] = $ais_data['statusid']; | |
| 740 | + } | |
| 741 | +		    if (isset($ais_data['type'])) { | |
| 742 | + $data['type'] = $ais_data['type']; | |
| 743 | + } | |
| 744 | +		    if (isset($ais_data['typeid'])) { | |
| 745 | + $data['type_id'] = $ais_data['typeid']; | |
| 746 | + } | |
| 747 | +		    if (isset($ais_data['imo'])) { | |
| 748 | + $data['imo'] = $ais_data['imo']; | |
| 749 | + } | |
| 750 | +		    if (isset($ais_data['callsign'])) { | |
| 751 | + $data['callsign'] = $ais_data['callsign']; | |
| 752 | + } | |
| 557 | 753 |  		    if (isset($ais_data['timestamp'])) { | 
| 558 | 754 |  			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); | 
| 559 | 755 |  			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { | 
| @@ -567,8 +763,12 @@ discard block | ||
| 567 | 763 | $data['format_source'] = 'aisnmeatxt'; | 
| 568 | 764 | $data['id_source'] = $id_source; | 
| 569 | 765 | //print_r($data); | 
| 570 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 571 | - if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); | |
| 766 | +		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { | |
| 767 | + $data['noarchive'] = true; | |
| 768 | + } | |
| 769 | +		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') { | |
| 770 | + $MI->add($data); | |
| 771 | + } | |
| 572 | 772 | unset($data); | 
| 573 | 773 | } | 
| 574 | 774 | } | 
| @@ -591,20 +791,48 @@ discard block | ||
| 591 | 791 |  			    if ($line != '') { | 
| 592 | 792 | $ais_data = $AIS->parse_line(trim($line)); | 
| 593 | 793 | $data = array(); | 
| 594 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; | |
| 595 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); | |
| 596 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; | |
| 597 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; | |
| 598 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; | |
| 599 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; | |
| 600 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; | |
| 601 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; | |
| 602 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; | |
| 603 | - if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid']; | |
| 604 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; | |
| 605 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; | |
| 606 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; | |
| 607 | -				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); | |
| 794 | +				if (isset($ais_data['ident'])) { | |
| 795 | + $data['ident'] = $ais_data['ident']; | |
| 796 | + } | |
| 797 | +				if (isset($ais_data['mmsi'])) { | |
| 798 | + $data['mmsi'] = substr($ais_data['mmsi'],-9); | |
| 799 | + } | |
| 800 | +				if (isset($ais_data['speed'])) { | |
| 801 | + $data['speed'] = $ais_data['speed']; | |
| 802 | + } | |
| 803 | +				if (isset($ais_data['heading'])) { | |
| 804 | + $data['heading'] = $ais_data['heading']; | |
| 805 | + } | |
| 806 | +				if (isset($ais_data['latitude'])) { | |
| 807 | + $data['latitude'] = $ais_data['latitude']; | |
| 808 | + } | |
| 809 | +				if (isset($ais_data['longitude'])) { | |
| 810 | + $data['longitude'] = $ais_data['longitude']; | |
| 811 | + } | |
| 812 | +				if (isset($ais_data['status'])) { | |
| 813 | + $data['status'] = $ais_data['status']; | |
| 814 | + } | |
| 815 | +				if (isset($ais_data['statusid'])) { | |
| 816 | + $data['status_id'] = $ais_data['statusid']; | |
| 817 | + } | |
| 818 | +				if (isset($ais_data['type'])) { | |
| 819 | + $data['type'] = $ais_data['type']; | |
| 820 | + } | |
| 821 | +				if (isset($ais_data['typeid'])) { | |
| 822 | + $data['type_id'] = $ais_data['typeid']; | |
| 823 | + } | |
| 824 | +				if (isset($ais_data['imo'])) { | |
| 825 | + $data['imo'] = $ais_data['imo']; | |
| 826 | + } | |
| 827 | +				if (isset($ais_data['callsign'])) { | |
| 828 | + $data['callsign'] = $ais_data['callsign']; | |
| 829 | + } | |
| 830 | +				if (isset($ais_data['destination'])) { | |
| 831 | + $data['arrival_code'] = $ais_data['destination']; | |
| 832 | + } | |
| 833 | +				if (isset($ais_data['eta_ts'])) { | |
| 834 | +					$data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); | |
| 835 | + } | |
| 608 | 836 |  				if (isset($ais_data['timestamp'])) { | 
| 609 | 837 |  				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); | 
| 610 | 838 |  				} else { | 
| @@ -612,18 +840,27 @@ discard block | ||
| 612 | 840 | } | 
| 613 | 841 | $data['format_source'] = 'aisnmeahttp'; | 
| 614 | 842 | $data['id_source'] = $id_source; | 
| 615 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 616 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); | |
| 843 | +				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { | |
| 844 | + $data['noarchive'] = true; | |
| 845 | + } | |
| 846 | +				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') { | |
| 847 | + $MI->add($data); | |
| 848 | + } | |
| 617 | 849 | unset($data); | 
| 618 | 850 | } | 
| 619 | 851 | } | 
| 620 | 852 | } | 
| 621 | 853 |  		} else { | 
| 622 | 854 | $format = $value['format']; | 
| 623 | - if (isset($tt[$format])) $tt[$format]++; | |
| 624 | - else $tt[$format] = 0; | |
| 855 | +		    if (isset($tt[$format])) { | |
| 856 | + $tt[$format]++; | |
| 857 | +		    } else { | |
| 858 | + $tt[$format] = 0; | |
| 859 | + } | |
| 625 | 860 |  		    if ($tt[$format] > 30) { | 
| 626 | - if ($globalDebug) echo 'Reconnect...'."\n"; | |
| 861 | +			if ($globalDebug) { | |
| 862 | + echo 'Reconnect...'."\n"; | |
| 863 | + } | |
| 627 | 864 | sleep(2); | 
| 628 | 865 | //$sourceeen[] = $value; | 
| 629 | 866 | //connect_all($sourceeen); | 
| @@ -659,12 +896,18 @@ discard block | ||
| 659 | 896 | // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; | 
| 660 | 897 | //$data['type_id'] = $line['TYPE']; | 
| 661 | 898 | $data['imo'] = $line['IMO']; | 
| 662 | - if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST']; | |
| 663 | -			    if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV'])); | |
| 899 | +			    if ($line['DEST'] != '') { | |
| 900 | + $data['arrival_code'] = $line['DEST']; | |
| 901 | + } | |
| 902 | +			    if ($line['ARV'] != '') { | |
| 903 | +			    	$data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV'])); | |
| 904 | + } | |
| 664 | 905 |  			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']); | 
| 665 | 906 | $data['format_source'] = 'myshiptracking'; | 
| 666 | 907 | $data['id_source'] = $id_source; | 
| 667 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 908 | +			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { | |
| 909 | + $data['noarchive'] = true; | |
| 910 | + } | |
| 668 | 911 | $MI->add($data); | 
| 669 | 912 | unset($data); | 
| 670 | 913 | } | 
| @@ -689,7 +932,9 @@ discard block | ||
| 689 | 932 | $data['callsign'] = $line['callsign']; | 
| 690 | 933 | $data['mmsi'] = substr($line['mmsi'],-9); | 
| 691 | 934 | $data['speed'] = $line['sog']; | 
| 692 | - if ($line['heading'] != '511') $data['heading'] = $line['heading']; | |
| 935 | +			    if ($line['heading'] != '511') { | |
| 936 | + $data['heading'] = $line['heading']; | |
| 937 | + } | |
| 693 | 938 | $data['latitude'] = $line['latitude']; | 
| 694 | 939 | $data['longitude'] = $line['longitude']; | 
| 695 | 940 | $data['type_id'] = $line['shiptype']; | 
| @@ -697,7 +942,9 @@ discard block | ||
| 697 | 942 | $data['datetime'] = $line['time']; | 
| 698 | 943 | $data['format_source'] = 'boatbeaconapp'; | 
| 699 | 944 | $data['id_source'] = $id_source; | 
| 700 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 945 | +			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { | |
| 946 | + $data['noarchive'] = true; | |
| 947 | + } | |
| 701 | 948 | $MI->add($data); | 
| 702 | 949 | unset($data); | 
| 703 | 950 | } | 
| @@ -719,22 +966,44 @@ discard block | ||
| 719 | 966 |  		    foreach ($all_data['features'] as $line) { | 
| 720 | 967 | print_r($line); | 
| 721 | 968 | $data = array(); | 
| 722 | - if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name']; | |
| 723 | - if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign']; | |
| 724 | - if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'],-9); | |
| 725 | - if (isset($line['properties']['imo'])) $data['imo'] = $line['properties']['imo']; | |
| 726 | - if (isset($line['properties']['speed'])) $data['speed'] = $line['properties']['speed']; | |
| 727 | - if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) $data['heading'] = $line['properties']['heading']; | |
| 969 | +			if (isset($line['properties']['name'])) { | |
| 970 | + $data['ident'] = $line['properties']['name']; | |
| 971 | + } | |
| 972 | +			if (isset($line['properties']['callsign'])) { | |
| 973 | + $data['callsign'] = $line['properties']['callsign']; | |
| 974 | + } | |
| 975 | +			if (isset($line['properties']['mmsi'])) { | |
| 976 | + $data['mmsi'] = substr($line['properties']['mmsi'],-9); | |
| 977 | + } | |
| 978 | +			if (isset($line['properties']['imo'])) { | |
| 979 | + $data['imo'] = $line['properties']['imo']; | |
| 980 | + } | |
| 981 | +			if (isset($line['properties']['speed'])) { | |
| 982 | + $data['speed'] = $line['properties']['speed']; | |
| 983 | + } | |
| 984 | +			if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) { | |
| 985 | + $data['heading'] = $line['properties']['heading']; | |
| 986 | + } | |
| 728 | 987 | $data['latitude'] = $line['geometry']['coordinates'][1]; | 
| 729 | 988 | $data['longitude'] = $line['geometry']['coordinates'][0]; | 
| 730 | - if (isset($line['properties']['vesselType'])) $data['type'] = $line['properties']['vesselType']; | |
| 731 | - if (isset($line['properties']['destination'])) $data['arrival_code'] = $line['properties']['destination']; | |
| 732 | - if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') $data['arrival_date'] = $line['properties']['eta']; | |
| 989 | +			if (isset($line['properties']['vesselType'])) { | |
| 990 | + $data['type'] = $line['properties']['vesselType']; | |
| 991 | + } | |
| 992 | +			if (isset($line['properties']['destination'])) { | |
| 993 | + $data['arrival_code'] = $line['properties']['destination']; | |
| 994 | + } | |
| 995 | +			if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') { | |
| 996 | + $data['arrival_date'] = $line['properties']['eta']; | |
| 997 | + } | |
| 733 | 998 | $data['format_source'] = 'boatnerd'; | 
| 734 | 999 | $data['id_source'] = $id_source; | 
| 735 | 1000 |  			$data['datetime'] = date('Y-m-d H:i:s'); | 
| 736 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 737 | - if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data); | |
| 1001 | +			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { | |
| 1002 | + $data['noarchive'] = true; | |
| 1003 | + } | |
| 1004 | +			if ($line['properties']['vesselType'] != 'Navigation Aid') { | |
| 1005 | + $MI->add($data); | |
| 1006 | + } | |
| 738 | 1007 | unset($data); | 
| 739 | 1008 | } | 
| 740 | 1009 | } | 
| @@ -747,11 +1016,17 @@ discard block | ||
| 747 | 1016 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) | 
| 748 | 1017 | ) | 
| 749 | 1018 |  	) { | 
| 750 | - if ($globalDebug) echo 'download...'; | |
| 1019 | +	    if ($globalDebug) { | |
| 1020 | + echo 'download...'; | |
| 1021 | + } | |
| 751 | 1022 | $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); | 
| 752 | - if ($globalDebug) echo 'done !'."\n"; | |
| 1023 | +	    if ($globalDebug) { | |
| 1024 | + echo 'done !'."\n"; | |
| 1025 | + } | |
| 753 | 1026 | // FIXME: Need more work | 
| 754 | - if ($buffer != '') $reset = 0; | |
| 1027 | +	    if ($buffer != '') { | |
| 1028 | + $reset = 0; | |
| 1029 | + } | |
| 755 | 1030 |      	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); | 
| 756 | 1031 |  	    $buffer = explode('\n',$buffer); | 
| 757 | 1032 |  	    foreach ($buffer as $line) { | 
| @@ -777,7 +1052,9 @@ discard block | ||
| 777 | 1052 | //$data['etaTime'] = substr($line,135,5); | 
| 778 | 1053 | $data['format_source'] = 'shipplotter'; | 
| 779 | 1054 | $data['id_source'] = $id_source; | 
| 780 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 1055 | +		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { | |
| 1056 | + $data['noarchive'] = true; | |
| 1057 | + } | |
| 781 | 1058 | //print_r($data); | 
| 782 | 1059 | //echo 'Add...'."\n"; | 
| 783 | 1060 | $MI->add($data); | 
| @@ -799,11 +1076,17 @@ discard block | ||
| 799 | 1076 | } | 
| 800 | 1077 | } | 
| 801 | 1078 | |
| 802 | - if ($globalDebug) echo '! Download... '; | |
| 1079 | +	    if ($globalDebug) { | |
| 1080 | + echo '! Download... '; | |
| 1081 | + } | |
| 803 | 1082 |  	    for ($i =0; $i <= 1; $i++) { | 
| 804 | - if ($globalDebug) echo 'Racetype: '.$i.' '; | |
| 1083 | +		if ($globalDebug) { | |
| 1084 | + echo 'Racetype: '.$i.' '; | |
| 1085 | + } | |
| 805 | 1086 |  		$buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/GetMissions.pl?race=1&tutorial=0&hist=1&racetype='.$i); | 
| 806 | - if ($globalDebug) echo 'done'."\n"; | |
| 1087 | +	    if ($globalDebug) { | |
| 1088 | + echo 'done'."\n"; | |
| 1089 | + } | |
| 807 | 1090 |  	    if ($buffer != '') { | 
| 808 | 1091 | $all_data = json_decode($buffer,true); | 
| 809 | 1092 |  		if (isset($all_data['missions'])) { | 
| @@ -814,7 +1097,9 @@ discard block | ||
| 814 | 1097 |  					if (isset($sailaway_authcookie) && $sailaway_authcookie != '') { | 
| 815 | 1098 |  						$racebuffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/GetMission.pl?misnr='.$mission['misnr'],'get','','',$sailaway_authcookie); | 
| 816 | 1099 | sleep(10); | 
| 817 | - } else $racebuffer = ''; | |
| 1100 | +					} else { | |
| 1101 | + $racebuffer = ''; | |
| 1102 | + } | |
| 818 | 1103 |  					$bufferm = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/GetLeaderboard.pl?misnr='.$mission['misnr']); | 
| 819 | 1104 |  				} else { | 
| 820 | 1105 | $bufferm = ''; | 
| @@ -878,7 +1163,9 @@ discard block | ||
| 878 | 1163 | $data['captain_id'] = $sail['usrnr']; | 
| 879 | 1164 | $data['captain_name'] = $sail['usrname']; | 
| 880 | 1165 | $data['race_id'] = $sail['misnr']; | 
| 881 | - if ($sail['rank'] != 'DNF') $data['race_rank'] = $sail['rank']; | |
| 1166 | +								if ($sail['rank'] != 'DNF') { | |
| 1167 | + $data['race_rank'] = $sail['rank']; | |
| 1168 | + } | |
| 882 | 1169 | $data['race_time'] = $sail['racetime']; | 
| 883 | 1170 |  								if ($mission_user != '') { | 
| 884 | 1171 |  									$data['race_name'] = $mission_name.' ('.$mission_user.')'; | 
| @@ -888,7 +1175,9 @@ discard block | ||
| 888 | 1175 | //$data['callsign'] = trim(substr($line,100,7); | 
| 889 | 1176 | $data['format_source'] = 'sailaway'; | 
| 890 | 1177 | $data['id_source'] = $id_source; | 
| 891 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 1178 | +								if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { | |
| 1179 | + $data['noarchive'] = true; | |
| 1180 | + } | |
| 892 | 1181 | //print_r($data); | 
| 893 | 1182 | //if ($data['race_id'] == '48') print_r($data); | 
| 894 | 1183 | //echo 'Add...'."\n"; | 
| @@ -932,16 +1221,28 @@ discard block | ||
| 932 | 1221 |      		    $line = explode(':', $line); | 
| 933 | 1222 |      		    if (count($line) > 30 && $line[0] != 'callsign') { | 
| 934 | 1223 | $data = array(); | 
| 935 | - if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; | |
| 936 | - else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; | |
| 1224 | +			if (isset($line[37]) && $line[37] != '') { | |
| 1225 | + $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; | |
| 1226 | +			} else { | |
| 1227 | + $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; | |
| 1228 | + } | |
| 937 | 1229 | $data['pilot_id'] = $line[1]; | 
| 938 | 1230 | $data['pilot_name'] = $line[2]; | 
| 939 | 1231 | $data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT); | 
| 940 | 1232 | $data['ident'] = $line[0]; // ident | 
| 941 | - if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude | |
| 1233 | +			if ($line[7] != '' && $line[7] != 0) { | |
| 1234 | + $data['altitude'] = $line[7]; | |
| 1235 | + } | |
| 1236 | + // altitude | |
| 942 | 1237 | $data['speed'] = $line[8]; // speed | 
| 943 | - if (isset($line[45])) $data['heading'] = $line[45]; // heading | |
| 944 | - elseif (isset($line[38])) $data['heading'] = $line[38]; // heading | |
| 1238 | +			if (isset($line[45])) { | |
| 1239 | + $data['heading'] = $line[45]; | |
| 1240 | + } | |
| 1241 | + // heading | |
| 1242 | +			elseif (isset($line[38])) { | |
| 1243 | + $data['heading'] = $line[38]; | |
| 1244 | + } | |
| 1245 | + // heading | |
| 945 | 1246 | $data['latitude'] = $line[5]; // lat | 
| 946 | 1247 | $data['longitude'] = $line[6]; // long | 
| 947 | 1248 | $data['verticalrate'] = ''; // vertical rate | 
| @@ -957,7 +1258,9 @@ discard block | ||
| 957 | 1258 | $data['frequency'] = $line[4]; | 
| 958 | 1259 | $data['type'] = $line[18]; | 
| 959 | 1260 | $data['range'] = $line[19]; | 
| 960 | - if (isset($line[35])) $data['info'] = $line[35]; | |
| 1261 | +			if (isset($line[35])) { | |
| 1262 | + $data['info'] = $line[35]; | |
| 1263 | + } | |
| 961 | 1264 | $data['id_source'] = $id_source; | 
| 962 | 1265 | //$data['arrival_airport_time'] = ; | 
| 963 | 1266 |  	    		if ($line[9] != '') { | 
| @@ -971,27 +1274,47 @@ discard block | ||
| 971 | 1274 | elseif ($value === 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; | 
| 972 | 1275 | */ | 
| 973 | 1276 | $data['format_source'] = $value['format']; | 
| 974 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 975 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; | |
| 976 | - if ($line[3] === 'PILOT') $SI->add($data); | |
| 977 | -			elseif ($line[3] === 'ATC') { | |
| 1277 | +			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { | |
| 1278 | + $data['noarchive'] = true; | |
| 1279 | + } | |
| 1280 | +			if (isset($value['name']) && $value['name'] != '') { | |
| 1281 | + $data['source_name'] = $value['name']; | |
| 1282 | + } | |
| 1283 | +    			if ($line[3] === 'PILOT') { | |
| 1284 | + $SI->add($data); | |
| 1285 | +    			} elseif ($line[3] === 'ATC') { | |
| 978 | 1286 | //print_r($data); | 
| 979 | 1287 |  				$data['info'] = str_replace('^§','<br />',$data['info']); | 
| 980 | 1288 |  				$data['info'] = str_replace('&sect;','',$data['info']); | 
| 981 | 1289 | $typec = substr($data['ident'],-3); | 
| 982 | - if ($typec === 'APP') $data['type'] = 'Approach'; | |
| 983 | - elseif ($typec === 'TWR') $data['type'] = 'Tower'; | |
| 984 | - elseif ($typec === 'OBS') $data['type'] = 'Observer'; | |
| 985 | - elseif ($typec === 'GND') $data['type'] = 'Ground'; | |
| 986 | - elseif ($typec === 'DEL') $data['type'] = 'Delivery'; | |
| 987 | - elseif ($typec === 'DEP') $data['type'] = 'Departure'; | |
| 988 | - elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station'; | |
| 989 | - elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre'; | |
| 990 | - elseif ($data['type'] === '') $data['type'] = 'Observer'; | |
| 991 | - if (!isset($data['source_name'])) $data['source_name'] = ''; | |
| 1290 | +				if ($typec === 'APP') { | |
| 1291 | + $data['type'] = 'Approach'; | |
| 1292 | +				} elseif ($typec === 'TWR') { | |
| 1293 | + $data['type'] = 'Tower'; | |
| 1294 | +				} elseif ($typec === 'OBS') { | |
| 1295 | + $data['type'] = 'Observer'; | |
| 1296 | +				} elseif ($typec === 'GND') { | |
| 1297 | + $data['type'] = 'Ground'; | |
| 1298 | +				} elseif ($typec === 'DEL') { | |
| 1299 | + $data['type'] = 'Delivery'; | |
| 1300 | +				} elseif ($typec === 'DEP') { | |
| 1301 | + $data['type'] = 'Departure'; | |
| 1302 | +				} elseif ($typec === 'FSS') { | |
| 1303 | + $data['type'] = 'Flight Service Station'; | |
| 1304 | +				} elseif ($typec === 'CTR') { | |
| 1305 | + $data['type'] = 'Control Radar or Centre'; | |
| 1306 | +				} elseif ($data['type'] === '') { | |
| 1307 | + $data['type'] = 'Observer'; | |
| 1308 | + } | |
| 1309 | +				if (!isset($data['source_name'])) { | |
| 1310 | + $data['source_name'] = ''; | |
| 1311 | + } | |
| 992 | 1312 |  				if (isset($ATC)) { | 
| 993 | - 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']); | |
| 994 | - 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']); | |
| 1313 | +					if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) { | |
| 1314 | + 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']); | |
| 1315 | +					} else { | |
| 1316 | + 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']); | |
| 1317 | + } | |
| 995 | 1318 | } | 
| 996 | 1319 | } | 
| 997 | 1320 | unset($data); | 
| @@ -1018,14 +1341,20 @@ discard block | ||
| 1018 | 1341 |  			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST')); | 
| 1019 | 1342 | $data['latitude'] = (float)$line['pktLatitude']; | 
| 1020 | 1343 | $data['longitude'] = (float)$line['pktLongitude']; | 
| 1021 | - if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack']; | |
| 1022 | - if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed']; | |
| 1344 | +			if ((float)$line['pktTrack'] != 0) { | |
| 1345 | + $data['heading'] = (float)$line['pktTrack']; | |
| 1346 | + } | |
| 1347 | +			if ((int)$line['pktSpeed'] != 0) { | |
| 1348 | + $data['speed'] = (int)$line['pktSpeed']; | |
| 1349 | + } | |
| 1023 | 1350 | $data['altitude'] = round((int)$line['pktAltitude']*3.28084); | 
| 1024 | 1351 | $data['altitude_relative'] = 'AMSL'; | 
| 1025 | 1352 | $data['pilot_id'] = (int)$line['pktPilotID']; | 
| 1026 | 1353 | $data['aircraft_icao'] = 'PARAGLIDER'; | 
| 1027 | 1354 |  			$pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id'])); | 
| 1028 | - if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4]; | |
| 1355 | +			if (isset($pilot_data[4])) { | |
| 1356 | + $data['pilot_name'] = $pilot_data[4]; | |
| 1357 | + } | |
| 1029 | 1358 | $data['format_source'] = $value['format']; | 
| 1030 | 1359 | $SI->add($data); | 
| 1031 | 1360 | unset($data); | 
| @@ -1073,25 +1402,59 @@ discard block | ||
| 1073 | 1402 |  		    foreach ($all_data['acList'] as $line) { | 
| 1074 | 1403 | $data = array(); | 
| 1075 | 1404 | $data['hex'] = $line['Icao']; // hex | 
| 1076 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident | |
| 1077 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude | |
| 1078 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed | |
| 1079 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading | |
| 1080 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat | |
| 1081 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long | |
| 1405 | +			if (isset($line['Call'])) { | |
| 1406 | + $data['ident'] = $line['Call']; | |
| 1407 | + } | |
| 1408 | + // ident | |
| 1409 | +			if (isset($line['Alt'])) { | |
| 1410 | + $data['altitude'] = $line['Alt']; | |
| 1411 | + } | |
| 1412 | + // altitude | |
| 1413 | +			if (isset($line['Spd'])) { | |
| 1414 | + $data['speed'] = $line['Spd']; | |
| 1415 | + } | |
| 1416 | + // speed | |
| 1417 | +			if (isset($line['Trak'])) { | |
| 1418 | + $data['heading'] = $line['Trak']; | |
| 1419 | + } | |
| 1420 | + // heading | |
| 1421 | +			if (isset($line['Lat'])) { | |
| 1422 | + $data['latitude'] = $line['Lat']; | |
| 1423 | + } | |
| 1424 | + // lat | |
| 1425 | +			if (isset($line['Long'])) { | |
| 1426 | + $data['longitude'] = $line['Long']; | |
| 1427 | + } | |
| 1428 | + // long | |
| 1082 | 1429 | //$data['verticalrate'] = $line['']; // verticale rate | 
| 1083 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk | |
| 1430 | +			if (isset($line['Sqk'])) { | |
| 1431 | + $data['squawk'] = $line['Sqk']; | |
| 1432 | + } | |
| 1433 | + // squawk | |
| 1084 | 1434 | $data['emergency'] = ''; // emergency | 
| 1085 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; | |
| 1086 | -			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); | |
| 1087 | -			else $data['datetime'] = date('Y-m-d H:i:s'); | |
| 1435 | +			if (isset($line['Reg'])) { | |
| 1436 | + $data['registration'] = $line['Reg']; | |
| 1437 | + } | |
| 1438 | +			if (isset($line['PosTime'])) { | |
| 1439 | +				$data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); | |
| 1440 | +			} else { | |
| 1441 | +				$data['datetime'] = date('Y-m-d H:i:s'); | |
| 1442 | + } | |
| 1088 | 1443 |  			//$data['datetime'] = date('Y-m-d H:i:s'); | 
| 1089 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; | |
| 1444 | +			if (isset($line['Type'])) { | |
| 1445 | + $data['aircraft_icao'] = $line['Type']; | |
| 1446 | + } | |
| 1090 | 1447 | $data['format_source'] = 'aircraftlistjson'; | 
| 1091 | 1448 | $data['id_source'] = $id_source; | 
| 1092 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; | |
| 1093 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 1094 | - if (isset($data['latitude'])) $SI->add($data); | |
| 1449 | +			if (isset($value['name']) && $value['name'] != '') { | |
| 1450 | + $data['source_name'] = $value['name']; | |
| 1451 | + } | |
| 1452 | +			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { | |
| 1453 | + $data['noarchive'] = true; | |
| 1454 | + } | |
| 1455 | +			if (isset($data['latitude'])) { | |
| 1456 | + $SI->add($data); | |
| 1457 | + } | |
| 1095 | 1458 | unset($data); | 
| 1096 | 1459 | } | 
| 1097 | 1460 |  		} elseif (is_array($all_data)) { | 
| @@ -1108,17 +1471,26 @@ discard block | ||
| 1108 | 1471 | $data['verticalrate'] = $line['vrt']; // verticale rate | 
| 1109 | 1472 | $data['squawk'] = $line['squawk']; // squawk | 
| 1110 | 1473 | $data['emergency'] = ''; // emergency | 
| 1111 | -			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); | |
| 1112 | -			else $data['datetime'] = date('Y-m-d H:i:s'); | |
| 1474 | +			if (isset($line['PosTime'])) { | |
| 1475 | +				$data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); | |
| 1476 | +			} else { | |
| 1477 | +				$data['datetime'] = date('Y-m-d H:i:s'); | |
| 1478 | + } | |
| 1113 | 1479 | $data['format_source'] = 'aircraftlistjson'; | 
| 1114 | 1480 | $data['id_source'] = $id_source; | 
| 1115 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 1116 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; | |
| 1481 | +			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { | |
| 1482 | + $data['noarchive'] = true; | |
| 1483 | + } | |
| 1484 | +			if (isset($value['name']) && $value['name'] != '') { | |
| 1485 | + $data['source_name'] = $value['name']; | |
| 1486 | + } | |
| 1117 | 1487 | $SI->add($data); | 
| 1118 | 1488 | unset($data); | 
| 1119 | 1489 | } | 
| 1120 | 1490 | } | 
| 1121 | - } elseif ($globalDebug) echo 'No data'."\n"; | |
| 1491 | +	    } elseif ($globalDebug) { | |
| 1492 | + echo 'No data'."\n"; | |
| 1493 | + } | |
| 1122 | 1494 | //$last_exec['aircraftlistjson'] = time(); | 
| 1123 | 1495 | $last_exec[$id]['last'] = time(); | 
| 1124 | 1496 |      	//} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { | 
| @@ -1154,8 +1526,12 @@ discard block | ||
| 1154 | 1526 |  		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]); | 
| 1155 | 1527 | $data['format_source'] = 'planeupdatefaa'; | 
| 1156 | 1528 | $data['id_source'] = $id_source; | 
| 1157 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 1158 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; | |
| 1529 | +		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { | |
| 1530 | + $data['noarchive'] = true; | |
| 1531 | + } | |
| 1532 | +		    if (isset($value['name']) && $value['name'] != '') { | |
| 1533 | + $data['source_name'] = $value['name']; | |
| 1534 | + } | |
| 1159 | 1535 | $SI->add($data); | 
| 1160 | 1536 | unset($data); | 
| 1161 | 1537 | } | 
| @@ -1189,7 +1565,9 @@ discard block | ||
| 1189 | 1565 |  		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]); | 
| 1190 | 1566 | $data['format_source'] = 'opensky'; | 
| 1191 | 1567 | $data['id_source'] = $id_source; | 
| 1192 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 1568 | +		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { | |
| 1569 | + $data['noarchive'] = true; | |
| 1570 | + } | |
| 1193 | 1571 | $SI->add($data); | 
| 1194 | 1572 | unset($data); | 
| 1195 | 1573 | } | 
| @@ -1209,15 +1587,42 @@ discard block | ||
| 1209 | 1587 |  		foreach ($all_data['aircraft'] as $key => $line) { | 
| 1210 | 1588 | $data = array(); | 
| 1211 | 1589 | // add support for ground vehicule with ~ in front of hex | 
| 1212 | - if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex | |
| 1213 | - if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident | |
| 1214 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude | |
| 1215 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed | |
| 1216 | - if (isset($line['track'])) $data['heading'] = $line['track']; // heading | |
| 1217 | - if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat | |
| 1218 | - if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long | |
| 1219 | - if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate | |
| 1220 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk | |
| 1590 | +		    if (isset($line['hex'])) { | |
| 1591 | + $data['hex'] = $line['hex']; | |
| 1592 | + } | |
| 1593 | + // hex | |
| 1594 | +		    if (isset($line['flight'])) { | |
| 1595 | + $data['ident'] = trim($line['flight']); | |
| 1596 | + } | |
| 1597 | + // ident | |
| 1598 | +		    if (isset($line['altitude'])) { | |
| 1599 | + $data['altitude'] = $line['altitude']; | |
| 1600 | + } | |
| 1601 | + // altitude | |
| 1602 | +		    if (isset($line['speed'])) { | |
| 1603 | + $data['speed'] = $line['speed']; | |
| 1604 | + } | |
| 1605 | + // speed | |
| 1606 | +		    if (isset($line['track'])) { | |
| 1607 | + $data['heading'] = $line['track']; | |
| 1608 | + } | |
| 1609 | + // heading | |
| 1610 | +		    if (isset($line['lat'])) { | |
| 1611 | + $data['latitude'] = $line['lat']; | |
| 1612 | + } | |
| 1613 | + // lat | |
| 1614 | +		    if (isset($line['lon'])) { | |
| 1615 | + $data['longitude'] = $line['lon']; | |
| 1616 | + } | |
| 1617 | + // long | |
| 1618 | +		    if (isset($line['vert_rate'])) { | |
| 1619 | + $data['verticalrate'] = $line['vert_rate']; | |
| 1620 | + } | |
| 1621 | + // verticale rate | |
| 1622 | +		    if (isset($line['squawk'])) { | |
| 1623 | + $data['squawk'] = $line['squawk']; | |
| 1624 | + } | |
| 1625 | + // squawk | |
| 1221 | 1626 | //$data['emergency'] = ''; // emergency | 
| 1222 | 1627 | //$data['registration'] = $line[2]; | 
| 1223 | 1628 | //$data['aircraft_icao'] = $line[0]; | 
| @@ -1225,10 +1630,17 @@ discard block | ||
| 1225 | 1630 | $data['format_source'] = 'aircraftjson'; | 
| 1226 | 1631 | $data['id_source'] = $id_source; | 
| 1227 | 1632 |  		    if (isset($value['name']) && $value['name'] != '') { | 
| 1228 | - if (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = $value['name'].'_MLAT'; | |
| 1229 | - else $data['source_name'] = $value['name']; | |
| 1230 | - } elseif (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = 'MLAT'; | |
| 1231 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 1633 | +			    if (isset($line['mlat']) && !empty($line['mlat'])) { | |
| 1634 | + $data['source_name'] = $value['name'].'_MLAT'; | |
| 1635 | +			    } else { | |
| 1636 | + $data['source_name'] = $value['name']; | |
| 1637 | + } | |
| 1638 | +		    } elseif (isset($line['mlat']) && !empty($line['mlat'])) { | |
| 1639 | + $data['source_name'] = 'MLAT'; | |
| 1640 | + } | |
| 1641 | +		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { | |
| 1642 | + $data['noarchive'] = true; | |
| 1643 | + } | |
| 1232 | 1644 | $SI->add($data); | 
| 1233 | 1645 | unset($data); | 
| 1234 | 1646 | } | 
| @@ -1248,22 +1660,54 @@ discard block | ||
| 1248 | 1660 |  		foreach ($all_data['aircraft'] as $key => $line) { | 
| 1249 | 1661 | $data = array(); | 
| 1250 | 1662 | $data['hex'] = $key; // hex | 
| 1251 | - if (isset($line['callsign'])) $data['ident'] = trim($line['callsign']); // ident | |
| 1252 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude | |
| 1253 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed | |
| 1254 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading | |
| 1255 | - if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat | |
| 1256 | - if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long | |
| 1257 | - if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate | |
| 1258 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk | |
| 1663 | +		    if (isset($line['callsign'])) { | |
| 1664 | + $data['ident'] = trim($line['callsign']); | |
| 1665 | + } | |
| 1666 | + // ident | |
| 1667 | +		    if (isset($line['altitude'])) { | |
| 1668 | + $data['altitude'] = $line['altitude']; | |
| 1669 | + } | |
| 1670 | + // altitude | |
| 1671 | +		    if (isset($line['speed'])) { | |
| 1672 | + $data['speed'] = $line['speed']; | |
| 1673 | + } | |
| 1674 | + // speed | |
| 1675 | +		    if (isset($line['heading'])) { | |
| 1676 | + $data['heading'] = $line['heading']; | |
| 1677 | + } | |
| 1678 | + // heading | |
| 1679 | +		    if (isset($line['lat'])) { | |
| 1680 | + $data['latitude'] = $line['lat']; | |
| 1681 | + } | |
| 1682 | + // lat | |
| 1683 | +		    if (isset($line['lon'])) { | |
| 1684 | + $data['longitude'] = $line['lon']; | |
| 1685 | + } | |
| 1686 | + // long | |
| 1687 | +		    if (isset($line['vert_rate'])) { | |
| 1688 | + $data['verticalrate'] = $line['vert_rate']; | |
| 1689 | + } | |
| 1690 | + // verticale rate | |
| 1691 | +		    if (isset($line['squawk'])) { | |
| 1692 | + $data['squawk'] = $line['squawk']; | |
| 1693 | + } | |
| 1694 | + // squawk | |
| 1259 | 1695 | //$data['emergency'] = ''; // emergency | 
| 1260 | - if (isset($line['reg'])) $data['registration'] = $line['reg']; | |
| 1261 | - if (isset($line['type'])) $data['aircraft_icao'] = $line['type']; | |
| 1696 | +		    if (isset($line['reg'])) { | |
| 1697 | + $data['registration'] = $line['reg']; | |
| 1698 | + } | |
| 1699 | +		    if (isset($line['type'])) { | |
| 1700 | + $data['aircraft_icao'] = $line['type']; | |
| 1701 | + } | |
| 1262 | 1702 |  		    $data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']); | 
| 1263 | 1703 | $data['format_source'] = 'planefinderclient'; | 
| 1264 | 1704 | $data['id_source'] = $id_source; | 
| 1265 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; | |
| 1266 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 1705 | +		    if (isset($value['name']) && $value['name'] != '') { | |
| 1706 | + $data['source_name'] = $value['name']; | |
| 1707 | + } | |
| 1708 | +		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { | |
| 1709 | + $data['noarchive'] = true; | |
| 1710 | + } | |
| 1267 | 1711 | $SI->add($data); | 
| 1268 | 1712 | unset($data); | 
| 1269 | 1713 | } | 
| @@ -1279,7 +1723,9 @@ discard block | ||
| 1279 | 1723 | //$buffer = $Common->getData($hosts[$id]); | 
| 1280 | 1724 | $buffer = $Common->getData($value['host']); | 
| 1281 | 1725 | $all_data = json_decode($buffer,true); | 
| 1282 | - if (!empty($all_data)) $reset = 0; | |
| 1726 | +	    if (!empty($all_data)) { | |
| 1727 | + $reset = 0; | |
| 1728 | + } | |
| 1283 | 1729 |  	    foreach ($all_data as $key => $line) { | 
| 1284 | 1730 |  		if ($key != 'full_count' && $key != 'version' && $key != 'stats') { | 
| 1285 | 1731 | $data = array(); | 
| @@ -1300,8 +1746,12 @@ discard block | ||
| 1300 | 1746 |  		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] | 
| 1301 | 1747 | $data['format_source'] = 'fr24json'; | 
| 1302 | 1748 | $data['id_source'] = $id_source; | 
| 1303 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 1304 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; | |
| 1749 | +		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { | |
| 1750 | + $data['noarchive'] = true; | |
| 1751 | + } | |
| 1752 | +		    if (isset($value['name']) && $value['name'] != '') { | |
| 1753 | + $data['source_name'] = $value['name']; | |
| 1754 | + } | |
| 1305 | 1755 | $SI->add($data); | 
| 1306 | 1756 | unset($data); | 
| 1307 | 1757 | } | 
| @@ -1330,24 +1780,42 @@ discard block | ||
| 1330 | 1780 |  		    if (isset($line['inf'])) { | 
| 1331 | 1781 | $data = array(); | 
| 1332 | 1782 | $data['hex'] = $line['inf']['ia']; | 
| 1333 | - if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] | |
| 1783 | +			if (isset($line['inf']['cs'])) { | |
| 1784 | + $data['ident'] = $line['inf']['cs']; | |
| 1785 | + } | |
| 1786 | + //$line[13] | |
| 1334 | 1787 | $data['altitude'] = round($line['inf']['al']*3.28084); // altitude | 
| 1335 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed | |
| 1336 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading | |
| 1788 | +	    		if (isset($line['inf']['gs'])) { | |
| 1789 | + $data['speed'] = round($line['inf']['gs']*0.539957); | |
| 1790 | + } | |
| 1791 | + // speed | |
| 1792 | +	    		if (isset($line['inf']['tr'])) { | |
| 1793 | + $data['heading'] = $line['inf']['tr']; | |
| 1794 | + } | |
| 1795 | + // heading | |
| 1337 | 1796 | $data['latitude'] = $line['pt'][0]; // lat | 
| 1338 | 1797 | $data['longitude'] = $line['pt'][1]; // long | 
| 1339 | 1798 | //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate | 
| 1340 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk | |
| 1799 | +	    		if (isset($line['inf']['sq'])) { | |
| 1800 | + $data['squawk'] = $line['inf']['sq']; | |
| 1801 | + } | |
| 1802 | + // squawk | |
| 1341 | 1803 | //$data['aircraft_icao'] = $line[8]; | 
| 1342 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; | |
| 1804 | +	    		if (isset($line['inf']['rc'])) { | |
| 1805 | + $data['registration'] = $line['inf']['rc']; | |
| 1806 | + } | |
| 1343 | 1807 | //$data['departure_airport_iata'] = $line[11]; | 
| 1344 | 1808 | //$data['arrival_airport_iata'] = $line[12]; | 
| 1345 | 1809 | //$data['emergency'] = ''; // emergency | 
| 1346 | 1810 |  			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] | 
| 1347 | 1811 | $data['format_source'] = 'radarvirtueljson'; | 
| 1348 | 1812 | $data['id_source'] = $id_source; | 
| 1349 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 1350 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; | |
| 1813 | +			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { | |
| 1814 | + $data['noarchive'] = true; | |
| 1815 | + } | |
| 1816 | +			if (isset($value['name']) && $value['name'] != '') { | |
| 1817 | + $data['source_name'] = $value['name']; | |
| 1818 | + } | |
| 1351 | 1819 | $SI->add($data); | 
| 1352 | 1820 | unset($data); | 
| 1353 | 1821 | } | 
| @@ -1373,30 +1841,65 @@ discard block | ||
| 1373 | 1841 | $data['id'] = $line['id']; | 
| 1374 | 1842 | $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); | 
| 1375 | 1843 | $data['ident'] = $line['callsign']; // ident | 
| 1376 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id | |
| 1377 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name | |
| 1378 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude | |
| 1379 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed | |
| 1380 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading | |
| 1381 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route | |
| 1844 | +		    if (isset($line['pilotid'])) { | |
| 1845 | + $data['pilot_id'] = $line['pilotid']; | |
| 1846 | + } | |
| 1847 | + // pilot id | |
| 1848 | +		    if (isset($line['name'])) { | |
| 1849 | + $data['pilot_name'] = $line['name']; | |
| 1850 | + } | |
| 1851 | + // pilot name | |
| 1852 | +		    if (isset($line['alt'])) { | |
| 1853 | + $data['altitude'] = $line['alt']; | |
| 1854 | + } | |
| 1855 | + // altitude | |
| 1856 | +		    if (isset($line['gs'])) { | |
| 1857 | + $data['speed'] = $line['gs']; | |
| 1858 | + } | |
| 1859 | + // speed | |
| 1860 | +		    if (isset($line['heading'])) { | |
| 1861 | + $data['heading'] = $line['heading']; | |
| 1862 | + } | |
| 1863 | + // heading | |
| 1864 | +		    if (isset($line['route'])) { | |
| 1865 | + $data['waypoints'] = $line['route']; | |
| 1866 | + } | |
| 1867 | + // route | |
| 1382 | 1868 | $data['latitude'] = $line['lat']; // lat | 
| 1383 | 1869 | $data['longitude'] = $line['lon']; // long | 
| 1384 | 1870 | //$data['verticalrate'] = $line['vrt']; // verticale rate | 
| 1385 | 1871 | //$data['squawk'] = $line['squawk']; // squawk | 
| 1386 | 1872 | //$data['emergency'] = ''; // emergency | 
| 1387 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; | |
| 1388 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; | |
| 1389 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; | |
| 1873 | +		    if (isset($line['depicao'])) { | |
| 1874 | + $data['departure_airport_icao'] = $line['depicao']; | |
| 1875 | + } | |
| 1876 | +		    if (isset($line['deptime'])) { | |
| 1877 | + $data['departure_airport_time'] = $line['deptime']; | |
| 1878 | + } | |
| 1879 | +		    if (isset($line['arricao'])) { | |
| 1880 | + $data['arrival_airport_icao'] = $line['arricao']; | |
| 1881 | + } | |
| 1390 | 1882 | //$data['arrival_airport_time'] = $line['arrtime']; | 
| 1391 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; | |
| 1392 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; | |
| 1393 | - if (isset($line['atis'])) $data['info'] = $line['atis']; | |
| 1394 | - else $data['info'] = ''; | |
| 1883 | +		    if (isset($line['aircraft'])) { | |
| 1884 | + $data['aircraft_icao'] = $line['aircraft']; | |
| 1885 | + } | |
| 1886 | +		    if (isset($line['transponder'])) { | |
| 1887 | + $data['squawk'] = $line['transponder']; | |
| 1888 | + } | |
| 1889 | +		    if (isset($line['atis'])) { | |
| 1890 | + $data['info'] = $line['atis']; | |
| 1891 | +		    } else { | |
| 1892 | + $data['info'] = ''; | |
| 1893 | + } | |
| 1395 | 1894 | $data['format_source'] = 'pireps'; | 
| 1396 | 1895 | $data['id_source'] = $id_source; | 
| 1397 | 1896 |  		    $data['datetime'] = date('Y-m-d H:i:s'); | 
| 1398 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 1399 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; | |
| 1897 | +		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { | |
| 1898 | + $data['noarchive'] = true; | |
| 1899 | + } | |
| 1900 | +		    if (isset($value['name']) && $value['name'] != '') { | |
| 1901 | + $data['source_name'] = $value['name']; | |
| 1902 | + } | |
| 1400 | 1903 |  		    if ($line['icon'] === 'plane') { | 
| 1401 | 1904 | $SI->add($data); | 
| 1402 | 1905 | // print_r($data); | 
| @@ -1405,16 +1908,28 @@ discard block | ||
| 1405 | 1908 |  			$data['info'] = str_replace('&sect;','',$data['info']); | 
| 1406 | 1909 | $typec = substr($data['ident'],-3); | 
| 1407 | 1910 | $data['type'] = ''; | 
| 1408 | - if ($typec === 'APP') $data['type'] = 'Approach'; | |
| 1409 | - elseif ($typec === 'TWR') $data['type'] = 'Tower'; | |
| 1410 | - elseif ($typec === 'OBS') $data['type'] = 'Observer'; | |
| 1411 | - elseif ($typec === 'GND') $data['type'] = 'Ground'; | |
| 1412 | - elseif ($typec === 'DEL') $data['type'] = 'Delivery'; | |
| 1413 | - elseif ($typec === 'DEP') $data['type'] = 'Departure'; | |
| 1414 | - elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station'; | |
| 1415 | - elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre'; | |
| 1416 | - else $data['type'] = 'Observer'; | |
| 1417 | - 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']); | |
| 1911 | +			if ($typec === 'APP') { | |
| 1912 | + $data['type'] = 'Approach'; | |
| 1913 | +			} elseif ($typec === 'TWR') { | |
| 1914 | + $data['type'] = 'Tower'; | |
| 1915 | +			} elseif ($typec === 'OBS') { | |
| 1916 | + $data['type'] = 'Observer'; | |
| 1917 | +			} elseif ($typec === 'GND') { | |
| 1918 | + $data['type'] = 'Ground'; | |
| 1919 | +			} elseif ($typec === 'DEL') { | |
| 1920 | + $data['type'] = 'Delivery'; | |
| 1921 | +			} elseif ($typec === 'DEP') { | |
| 1922 | + $data['type'] = 'Departure'; | |
| 1923 | +			} elseif ($typec === 'FSS') { | |
| 1924 | + $data['type'] = 'Flight Service Station'; | |
| 1925 | +			} elseif ($typec === 'CTR') { | |
| 1926 | + $data['type'] = 'Control Radar or Centre'; | |
| 1927 | +			} else { | |
| 1928 | + $data['type'] = 'Observer'; | |
| 1929 | + } | |
| 1930 | +			if (isset($ATC)) { | |
| 1931 | + 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']); | |
| 1932 | + } | |
| 1418 | 1933 | } | 
| 1419 | 1934 | unset($data); | 
| 1420 | 1935 | } | 
| @@ -1429,7 +1944,9 @@ discard block | ||
| 1429 | 1944 | ) | 
| 1430 | 1945 |  	) { | 
| 1431 | 1946 | //$buffer = $Common->getData($hosts[$id]); | 
| 1432 | - if ($globalDebug) echo 'Get Data...'."\n"; | |
| 1947 | +	    if ($globalDebug) { | |
| 1948 | + echo 'Get Data...'."\n"; | |
| 1949 | + } | |
| 1433 | 1950 | $buffer = $Common->getData($value['host']); | 
| 1434 | 1951 | $all_data = json_decode($buffer,true); | 
| 1435 | 1952 |  	    if ($buffer != '' && is_array($all_data)) { | 
| @@ -1437,10 +1954,16 @@ discard block | ||
| 1437 | 1954 |  		foreach ($all_data as $line) { | 
| 1438 | 1955 | $data = array(); | 
| 1439 | 1956 | //$data['id'] = $line['id']; // id not usable | 
| 1440 | - if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; | |
| 1957 | +	    	    if (isset($line['pilotid'])) { | |
| 1958 | + $data['id'] = $line['pilotid'].$line['flightnum']; | |
| 1959 | + } | |
| 1441 | 1960 | $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex | 
| 1442 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; | |
| 1443 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; | |
| 1961 | +	    	    if (isset($line['pilotname'])) { | |
| 1962 | + $data['pilot_name'] = $line['pilotname']; | |
| 1963 | + } | |
| 1964 | +	    	    if (isset($line['pilotid'])) { | |
| 1965 | + $data['pilot_id'] = $line['pilotid']; | |
| 1966 | + } | |
| 1444 | 1967 | $data['ident'] = $line['flightnum']; // ident | 
| 1445 | 1968 | $data['altitude'] = $line['alt']; // altitude | 
| 1446 | 1969 | $data['speed'] = $line['gs']; // speed | 
| @@ -1456,7 +1979,9 @@ discard block | ||
| 1456 | 1979 | $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); | 
| 1457 | 1980 |  	    		$datetime->setTimeZone(new DateTimeZone('UTC')); | 
| 1458 | 1981 |  	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s'); | 
| 1459 | -	    	    } else $data['datetime'] = date('Y-m-d H:i:s'); | |
| 1982 | +	    	    } else { | |
| 1983 | +	    	    	$data['datetime'] = date('Y-m-d H:i:s'); | |
| 1984 | + } | |
| 1460 | 1985 | $data['departure_airport_icao'] = $line['depicao']; | 
| 1461 | 1986 | $data['departure_airport_time'] = $line['deptime']; | 
| 1462 | 1987 | $data['arrival_airport_icao'] = $line['arricao']; | 
| @@ -1464,29 +1989,47 @@ discard block | ||
| 1464 | 1989 |      		    if (isset($line['registration'])) { | 
| 1465 | 1990 | $data['registration'] = $line['registration']; | 
| 1466 | 1991 | //if (isset($line['aircraft'])) $data['id'] = $line['aircraft']; | 
| 1467 | - } else $data['registration'] = $line['aircraft']; | |
| 1468 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 1469 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route | |
| 1992 | +    		    } else { | |
| 1993 | + $data['registration'] = $line['aircraft']; | |
| 1994 | + } | |
| 1995 | +		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { | |
| 1996 | + $data['noarchive'] = true; | |
| 1997 | + } | |
| 1998 | +		    if (isset($line['route'])) { | |
| 1999 | + $data['waypoints'] = $line['route']; | |
| 2000 | + } | |
| 2001 | + // route | |
| 1470 | 2002 |  		    if (isset($line['aircraftname'])) { | 
| 1471 | 2003 | $line['aircraftname'] = strtoupper($line['aircraftname']); | 
| 1472 | 2004 |  			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); | 
| 1473 | 2005 |  	    		$aircraft_data = explode('-',$line['aircraftname']); | 
| 1474 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; | |
| 1475 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; | |
| 1476 | -	    		else { | |
| 2006 | +	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) { | |
| 2007 | + $data['aircraft_icao'] = $aircraft_data[0]; | |
| 2008 | +	    		} elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) { | |
| 2009 | + $data['aircraft_icao'] = $aircraft_data[1]; | |
| 2010 | +	    		} else { | |
| 1477 | 2011 |  	    		    $aircraft_data = explode(' ',$line['aircraftname']); | 
| 1478 | -	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); | |
| 1479 | -	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); | |
| 2012 | +	    		    if (isset($aircraft_data[1])) { | |
| 2013 | +	    		    	$data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); | |
| 2014 | +	    		    } else { | |
| 2015 | +	    		    	$data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); | |
| 2016 | + } | |
| 1480 | 2017 | } | 
| 1481 | 2018 | } | 
| 1482 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; | |
| 2019 | +    		    if (isset($line['route'])) { | |
| 2020 | + $data['waypoints'] = $line['route']; | |
| 2021 | + } | |
| 1483 | 2022 | $data['id_source'] = $id_source; | 
| 1484 | 2023 | $data['format_source'] = 'phpvmacars'; | 
| 1485 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; | |
| 2024 | +		    if (isset($value['name']) && $value['name'] != '') { | |
| 2025 | + $data['source_name'] = $value['name']; | |
| 2026 | + } | |
| 1486 | 2027 | $SI->add($data); | 
| 1487 | 2028 | unset($data); | 
| 1488 | 2029 | } | 
| 1489 | - if ($globalDebug) echo 'No more data...'."\n"; | |
| 2030 | +		if ($globalDebug) { | |
| 2031 | + echo 'No more data...'."\n"; | |
| 2032 | + } | |
| 1490 | 2033 | unset($buffer); | 
| 1491 | 2034 | unset($all_data); | 
| 1492 | 2035 | } | 
| @@ -1499,7 +2042,9 @@ discard block | ||
| 1499 | 2042 | ) | 
| 1500 | 2043 |  	) { | 
| 1501 | 2044 | //$buffer = $Common->getData($hosts[$id]); | 
| 1502 | - if ($globalDebug) echo 'Get Data...'."\n"; | |
| 2045 | +	    if ($globalDebug) { | |
| 2046 | + echo 'Get Data...'."\n"; | |
| 2047 | + } | |
| 1503 | 2048 | $buffer = $Common->getData($value['host']); | 
| 1504 | 2049 | $all_data = json_decode($buffer,true); | 
| 1505 | 2050 |  	    if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) { | 
| @@ -1510,10 +2055,16 @@ discard block | ||
| 1510 | 2055 | //$data['id'] = $line['id']; // id not usable | 
| 1511 | 2056 | $data['id'] = $line['id']; | 
| 1512 | 2057 | //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex | 
| 1513 | - if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username']; | |
| 1514 | - if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id']; | |
| 2058 | +	    	    if (isset($line['user']['username'])) { | |
| 2059 | + $data['pilot_name'] = $line['user']['username']; | |
| 2060 | + } | |
| 2061 | +	    	    if (isset($line['user_id'])) { | |
| 2062 | + $data['pilot_id'] = $line['user_id']; | |
| 2063 | + } | |
| 1515 | 2064 |  	    	    $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident | 
| 1516 | - if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident']; | |
| 2065 | +	    	    if (is_numeric($data['ident'])) { | |
| 2066 | + $data['ident'] = $line['bid']['airline']['icao'].$data['ident']; | |
| 2067 | + } | |
| 1517 | 2068 | $data['altitude'] = $line['altitude']; // altitude | 
| 1518 | 2069 | $data['speed'] = $line['groundspeed']; // speed | 
| 1519 | 2070 | $data['heading'] = $line['heading']; // heading | 
| @@ -1526,7 +2077,9 @@ discard block | ||
| 1526 | 2077 | $datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone'])); | 
| 1527 | 2078 |  	    		$datetime->setTimeZone(new DateTimeZone('UTC')); | 
| 1528 | 2079 |  	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s'); | 
| 1529 | -	    	    } else $data['datetime'] = date('Y-m-d H:i:s'); | |
| 2080 | +	    	    } else { | |
| 2081 | +	    	    	$data['datetime'] = date('Y-m-d H:i:s'); | |
| 2082 | + } | |
| 1530 | 2083 | |
| 1531 | 2084 | $data['departure_airport_icao'] = $line['bid']['depapt']['icao']; | 
| 1532 | 2085 | $data['departure_airport_time'] = $line['bid']['deptime']; | 
| @@ -1534,17 +2087,26 @@ discard block | ||
| 1534 | 2087 | $data['arrival_airport_time'] = $line['bid']['arrtime']; | 
| 1535 | 2088 | $data['registration'] = $line['bid']['aircraft']['registration']; | 
| 1536 | 2089 | |
| 1537 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 1538 | - if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route | |
| 2090 | +		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { | |
| 2091 | + $data['noarchive'] = true; | |
| 2092 | + } | |
| 2093 | +		    if (isset($line['bid']['route']) && $line['bid']['route'] != '') { | |
| 2094 | + $data['waypoints'] = $line['bid']['route']; | |
| 2095 | + } | |
| 2096 | + // route | |
| 1539 | 2097 | $data['aircraft_icao'] = $line['bid']['aircraft']['icao']; | 
| 1540 | 2098 | |
| 1541 | 2099 | $data['id_source'] = $id_source; | 
| 1542 | 2100 | $data['format_source'] = 'vaos'; | 
| 1543 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; | |
| 2101 | +		    if (isset($value['name']) && $value['name'] != '') { | |
| 2102 | + $data['source_name'] = $value['name']; | |
| 2103 | + } | |
| 1544 | 2104 | $SI->add($data); | 
| 1545 | 2105 | unset($data); | 
| 1546 | 2106 | } | 
| 1547 | - if ($globalDebug) echo 'No more data...'."\n"; | |
| 2107 | +		if ($globalDebug) { | |
| 2108 | + echo 'No more data...'."\n"; | |
| 2109 | + } | |
| 1548 | 2110 | unset($buffer); | 
| 1549 | 2111 | unset($all_data); | 
| 1550 | 2112 | } | 
| @@ -1557,7 +2119,9 @@ discard block | ||
| 1557 | 2119 | ) | 
| 1558 | 2120 |  	) { | 
| 1559 | 2121 | //$buffer = $Common->getData($hosts[$id]); | 
| 1560 | - if ($globalDebug) echo 'Get Data...'."\n"; | |
| 2122 | +	    if ($globalDebug) { | |
| 2123 | + echo 'Get Data...'."\n"; | |
| 2124 | + } | |
| 1561 | 2125 | $buffer = $Common->getData($value['host']); | 
| 1562 | 2126 | $all_data = json_decode($buffer,true); | 
| 1563 | 2127 |  	    if ($buffer != '' && is_array($all_data)) { | 
| @@ -1586,16 +2150,25 @@ discard block | ||
| 1586 | 2150 | $data['arrival_airport_icao'] = $line['arrival']; | 
| 1587 | 2151 | //$data['arrival_airport_time'] = $line['arrival_time']; | 
| 1588 | 2152 | //$data['registration'] = $line['aircraft']; | 
| 1589 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route | |
| 2153 | +		    if (isset($line['route'])) { | |
| 2154 | + $data['waypoints'] = $line['route']; | |
| 2155 | + } | |
| 2156 | + // route | |
| 1590 | 2157 | $data['aircraft_icao'] = $line['plane_type']; | 
| 1591 | 2158 | $data['id_source'] = $id_source; | 
| 1592 | 2159 | $data['format_source'] = 'vam'; | 
| 1593 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 1594 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; | |
| 2160 | +		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { | |
| 2161 | + $data['noarchive'] = true; | |
| 2162 | + } | |
| 2163 | +		    if (isset($value['name']) && $value['name'] != '') { | |
| 2164 | + $data['source_name'] = $value['name']; | |
| 2165 | + } | |
| 1595 | 2166 | $SI->add($data); | 
| 1596 | 2167 | unset($data); | 
| 1597 | 2168 | } | 
| 1598 | - if ($globalDebug) echo 'No more data...'."\n"; | |
| 2169 | +		if ($globalDebug) { | |
| 2170 | + echo 'No more data...'."\n"; | |
| 2171 | + } | |
| 1599 | 2172 | unset($buffer); | 
| 1600 | 2173 | unset($all_data); | 
| 1601 | 2174 | } | 
| @@ -1608,7 +2181,9 @@ discard block | ||
| 1608 | 2181 | ) | 
| 1609 | 2182 |  	) { | 
| 1610 | 2183 | //$buffer = $Common->getData($hosts[$id]); | 
| 1611 | - if ($globalDebug) echo 'Get Data...'."\n"; | |
| 2184 | +	    if ($globalDebug) { | |
| 2185 | + echo 'Get Data...'."\n"; | |
| 2186 | + } | |
| 1612 | 2187 | $buffer = $Common->getData($value['host']); | 
| 1613 | 2188 | $all_data = json_decode($buffer,true); | 
| 1614 | 2189 |  	    if ($buffer != '') { | 
| @@ -1626,12 +2201,16 @@ discard block | ||
| 1626 | 2201 | $data['id_source'] = $id_source; | 
| 1627 | 2202 | $data['format_source'] = 'blitzortung'; | 
| 1628 | 2203 | $SI->add($data); | 
| 1629 | - if ($globalDebug) echo '☈ Lightning added'."\n"; | |
| 2204 | +			if ($globalDebug) { | |
| 2205 | + echo '☈ Lightning added'."\n"; | |
| 2206 | + } | |
| 1630 | 2207 |  			$Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']); | 
| 1631 | 2208 | unset($data); | 
| 1632 | 2209 | } | 
| 1633 | 2210 | } | 
| 1634 | - if ($globalDebug) echo 'No more data...'."\n"; | |
| 2211 | +		if ($globalDebug) { | |
| 2212 | + echo 'No more data...'."\n"; | |
| 2213 | + } | |
| 1635 | 2214 | unset($buffer); | 
| 1636 | 2215 | } | 
| 1637 | 2216 | $last_exec[$id]['last'] = time(); | 
| @@ -1660,10 +2239,15 @@ discard block | ||
| 1660 | 2239 | } | 
| 1661 | 2240 |              } else { | 
| 1662 | 2241 | $format = $value['format']; | 
| 1663 | - if (isset($tt[$format])) $tt[$format]++; | |
| 1664 | - else $tt[$format] = 0; | |
| 2242 | +                if (isset($tt[$format])) { | |
| 2243 | + $tt[$format]++; | |
| 2244 | +                } else { | |
| 2245 | + $tt[$format] = 0; | |
| 2246 | + } | |
| 1665 | 2247 |                  if ($tt[$format] > 30) { | 
| 1666 | - if ($globalDebug) echo 'Reconnect...'."\n"; | |
| 2248 | +                    if ($globalDebug) { | |
| 2249 | + echo 'Reconnect...'."\n"; | |
| 2250 | + } | |
| 1667 | 2251 | sleep(2); | 
| 1668 | 2252 | //$sourceeen[] = $value; | 
| 1669 | 2253 | //connect_all($sourceeen); | 
| @@ -1680,7 +2264,9 @@ discard block | ||
| 1680 | 2264 | $write = NULL; | 
| 1681 | 2265 | $e = NULL; | 
| 1682 | 2266 | $n = socket_select($read, $write, $e, $timeout); | 
| 1683 | - if ($e != NULL) var_dump($e); | |
| 2267 | +	    if ($e != NULL) { | |
| 2268 | + var_dump($e); | |
| 2269 | + } | |
| 1684 | 2270 |  	    if ($n > 0) { | 
| 1685 | 2271 | $reset = 0; | 
| 1686 | 2272 |  		foreach ($read as $nb => $r) { | 
| @@ -1702,13 +2288,17 @@ discard block | ||
| 1702 | 2288 |  		    if ($buffer !== FALSE) { | 
| 1703 | 2289 |  			if ($format === 'vrstcp') { | 
| 1704 | 2290 |  			    $buffer = explode('},{',$buffer); | 
| 1705 | -			} else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); | |
| 2291 | +			} else { | |
| 2292 | +				$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); | |
| 2293 | + } | |
| 1706 | 2294 | } | 
| 1707 | 2295 | // SBS format is CSV format | 
| 1708 | 2296 |  		    if ($buffer !== FALSE && $buffer !== '') { | 
| 1709 | 2297 | $tt[$format] = 0; | 
| 1710 | 2298 |  			if ($format === 'acarssbs3') { | 
| 1711 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; | |
| 2299 | +			    if ($globalDebug) { | |
| 2300 | + echo 'ACARS : '.$buffer."\n"; | |
| 2301 | + } | |
| 1712 | 2302 | $ACARS->add(trim($buffer)); | 
| 1713 | 2303 | $ACARS->deleteLiveAcarsData(); | 
| 1714 | 2304 |  			} elseif ($format === 'raw') { | 
| @@ -1718,9 +2308,15 @@ discard block | ||
| 1718 | 2308 | //if (!empty($data)) print_r($data); | 
| 1719 | 2309 |  				$data['datetime'] = date('Y-m-d H:i:s'); | 
| 1720 | 2310 | $data['format_source'] = 'raw'; | 
| 1721 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; | |
| 1722 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; | |
| 1723 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 2311 | +				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { | |
| 2312 | + $data['source_name'] = $globalSources[$nb]['name']; | |
| 2313 | + } | |
| 2314 | +				if (isset($globalSources[$nb]['sourcestats'])) { | |
| 2315 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; | |
| 2316 | + } | |
| 2317 | +				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { | |
| 2318 | + $data['noarchive'] = true; | |
| 2319 | + } | |
| 1724 | 2320 | //if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); | 
| 1725 | 2321 | $SI->add($data); | 
| 1726 | 2322 | unset($data); | 
| @@ -1728,22 +2324,54 @@ discard block | ||
| 1728 | 2324 |  			} elseif ($format === 'ais') { | 
| 1729 | 2325 | $ais_data = $AIS->parse_line(trim($buffer)); | 
| 1730 | 2326 | $data = array(); | 
| 1731 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; | |
| 1732 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); | |
| 1733 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; | |
| 1734 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; | |
| 1735 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; | |
| 1736 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; | |
| 1737 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; | |
| 1738 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; | |
| 1739 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; | |
| 1740 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; | |
| 1741 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; | |
| 1742 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; | |
| 1743 | -			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); | |
| 1744 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 1745 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; | |
| 1746 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; | |
| 2327 | +			    if (isset($ais_data['ident'])) { | |
| 2328 | + $data['ident'] = $ais_data['ident']; | |
| 2329 | + } | |
| 2330 | +			    if (isset($ais_data['mmsi'])) { | |
| 2331 | + $data['mmsi'] = substr($ais_data['mmsi'],-9); | |
| 2332 | + } | |
| 2333 | +			    if (isset($ais_data['speed'])) { | |
| 2334 | + $data['speed'] = $ais_data['speed']; | |
| 2335 | + } | |
| 2336 | +			    if (isset($ais_data['heading'])) { | |
| 2337 | + $data['heading'] = $ais_data['heading']; | |
| 2338 | + } | |
| 2339 | +			    if (isset($ais_data['latitude'])) { | |
| 2340 | + $data['latitude'] = $ais_data['latitude']; | |
| 2341 | + } | |
| 2342 | +			    if (isset($ais_data['longitude'])) { | |
| 2343 | + $data['longitude'] = $ais_data['longitude']; | |
| 2344 | + } | |
| 2345 | +			    if (isset($ais_data['status'])) { | |
| 2346 | + $data['status'] = $ais_data['status']; | |
| 2347 | + } | |
| 2348 | +			    if (isset($ais_data['statusid'])) { | |
| 2349 | + $data['status_id'] = $ais_data['statusid']; | |
| 2350 | + } | |
| 2351 | +			    if (isset($ais_data['type'])) { | |
| 2352 | + $data['type'] = $ais_data['type']; | |
| 2353 | + } | |
| 2354 | +			    if (isset($ais_data['imo'])) { | |
| 2355 | + $data['imo'] = $ais_data['imo']; | |
| 2356 | + } | |
| 2357 | +			    if (isset($ais_data['callsign'])) { | |
| 2358 | + $data['callsign'] = $ais_data['callsign']; | |
| 2359 | + } | |
| 2360 | +			    if (isset($ais_data['destination'])) { | |
| 2361 | + $data['arrival_code'] = $ais_data['destination']; | |
| 2362 | + } | |
| 2363 | +			    if (isset($ais_data['eta_ts'])) { | |
| 2364 | +			    	$data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); | |
| 2365 | + } | |
| 2366 | +			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { | |
| 2367 | + $data['noarchive'] = true; | |
| 2368 | + } | |
| 2369 | +			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { | |
| 2370 | + $data['source_name'] = $globalSources[$nb]['name']; | |
| 2371 | + } | |
| 2372 | +			    if (isset($globalSources[$nb]['sourcestats'])) { | |
| 2373 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; | |
| 2374 | + } | |
| 1747 | 2375 | |
| 1748 | 2376 |  			    if (isset($ais_data['timestamp'])) { | 
| 1749 | 2377 |  				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); | 
| @@ -1752,7 +2380,9 @@ discard block | ||
| 1752 | 2380 | } | 
| 1753 | 2381 | $data['format_source'] = 'aisnmea'; | 
| 1754 | 2382 | $data['id_source'] = $id_source; | 
| 1755 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); | |
| 2383 | +			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') { | |
| 2384 | + $MI->add($data); | |
| 2385 | + } | |
| 1756 | 2386 | unset($data); | 
| 1757 | 2387 |                          } elseif ($format === 'flightgearsp') { | 
| 1758 | 2388 | //echo $buffer."\n"; | 
| @@ -1770,17 +2400,25 @@ discard block | ||
| 1770 | 2400 | $data['speed'] = round($line[5]*1.94384); | 
| 1771 | 2401 |  				$data['datetime'] = date('Y-m-d H:i:s'); | 
| 1772 | 2402 | $data['format_source'] = 'flightgearsp'; | 
| 1773 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 1774 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); | |
| 2403 | +				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { | |
| 2404 | + $data['noarchive'] = true; | |
| 2405 | + } | |
| 2406 | +				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { | |
| 2407 | + $SI->add($data); | |
| 2408 | + } | |
| 1775 | 2409 | //$send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); | 
| 1776 | 2410 | } | 
| 1777 | 2411 |                          } elseif ($format === 'acars') { | 
| 1778 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; | |
| 2412 | +                    	    if ($globalDebug) { | |
| 2413 | + echo 'ACARS : '.$buffer."\n"; | |
| 2414 | + } | |
| 1779 | 2415 | $ACARS->add(trim($buffer)); | 
| 1780 | 2416 | socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); | 
| 1781 | 2417 | $ACARS->deleteLiveAcarsData(); | 
| 1782 | 2418 |  			} elseif ($format === 'acarsjsonudp') { | 
| 1783 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; | |
| 2419 | +			    if ($globalDebug) { | |
| 2420 | + echo 'ACARS : '.$buffer."\n"; | |
| 2421 | + } | |
| 1784 | 2422 | $line = json_decode(trim($buffer), true); | 
| 1785 | 2423 |                              if (!empty($line)) { | 
| 1786 | 2424 |  				$line = array_merge(array('text' => '','tail' => '','label' => '','block_id' => '','flight' => '','msgno' => ''),$line); | 
| @@ -1805,8 +2443,12 @@ discard block | ||
| 1805 | 2443 | $aircraft_type = $line[10]; | 
| 1806 | 2444 |  				    $aircraft_type = preg_split(':/:',$aircraft_type); | 
| 1807 | 2445 | $data['aircraft_name'] = substr(end($aircraft_type),0,-4); | 
| 1808 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 1809 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); | |
| 2446 | +				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { | |
| 2447 | + $data['noarchive'] = true; | |
| 2448 | + } | |
| 2449 | +				    if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { | |
| 2450 | + $SI->add($data); | |
| 2451 | + } | |
| 1810 | 2452 | } | 
| 1811 | 2453 | } | 
| 1812 | 2454 |  			} elseif ($format === 'beast') { | 
| @@ -1816,28 +2458,62 @@ discard block | ||
| 1816 | 2458 |  			    foreach($buffer as $all_data) { | 
| 1817 | 2459 |  				$line = json_decode('{'.$all_data.'}',true); | 
| 1818 | 2460 | $data = array(); | 
| 1819 | - if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex | |
| 1820 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident | |
| 1821 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude | |
| 1822 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed | |
| 1823 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading | |
| 1824 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat | |
| 1825 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long | |
| 2461 | +				if (isset($line['Icao'])) { | |
| 2462 | + $data['hex'] = $line['Icao']; | |
| 2463 | + } | |
| 2464 | + // hex | |
| 2465 | +				if (isset($line['Call'])) { | |
| 2466 | + $data['ident'] = $line['Call']; | |
| 2467 | + } | |
| 2468 | + // ident | |
| 2469 | +				if (isset($line['Alt'])) { | |
| 2470 | + $data['altitude'] = $line['Alt']; | |
| 2471 | + } | |
| 2472 | + // altitude | |
| 2473 | +				if (isset($line['Spd'])) { | |
| 2474 | + $data['speed'] = $line['Spd']; | |
| 2475 | + } | |
| 2476 | + // speed | |
| 2477 | +				if (isset($line['Trak'])) { | |
| 2478 | + $data['heading'] = $line['Trak']; | |
| 2479 | + } | |
| 2480 | + // heading | |
| 2481 | +				if (isset($line['Lat'])) { | |
| 2482 | + $data['latitude'] = $line['Lat']; | |
| 2483 | + } | |
| 2484 | + // lat | |
| 2485 | +				if (isset($line['Long'])) { | |
| 2486 | + $data['longitude'] = $line['Long']; | |
| 2487 | + } | |
| 2488 | + // long | |
| 1826 | 2489 | //$data['verticalrate'] = $line['']; // verticale rate | 
| 1827 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk | |
| 2490 | +				if (isset($line['Sqk'])) { | |
| 2491 | + $data['squawk'] = $line['Sqk']; | |
| 2492 | + } | |
| 2493 | + // squawk | |
| 1828 | 2494 | $data['emergency'] = ''; // emergency | 
| 1829 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; | |
| 2495 | +				if (isset($line['Reg'])) { | |
| 2496 | + $data['registration'] = $line['Reg']; | |
| 2497 | + } | |
| 1830 | 2498 | /* | 
| 1831 | 2499 |  				if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000); | 
| 1832 | 2500 |  				else $data['datetime'] = date('Y-m-d H:i:s'); | 
| 1833 | 2501 | */ | 
| 1834 | 2502 |  				$data['datetime'] = date('Y-m-d H:i:s'); | 
| 1835 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; | |
| 2503 | +				if (isset($line['Type'])) { | |
| 2504 | + $data['aircraft_icao'] = $line['Type']; | |
| 2505 | + } | |
| 1836 | 2506 | $data['format_source'] = 'vrstcp'; | 
| 1837 | 2507 | $data['id_source'] = $id_source; | 
| 1838 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 1839 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; | |
| 1840 | - if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); | |
| 2508 | +				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { | |
| 2509 | + $data['noarchive'] = true; | |
| 2510 | + } | |
| 2511 | +				if (isset($value['name']) && $value['name'] != '') { | |
| 2512 | + $data['source_name'] = $value['name']; | |
| 2513 | + } | |
| 2514 | +				if (isset($data['latitude']) && isset($data['hex'])) { | |
| 2515 | + $SI->add($data); | |
| 2516 | + } | |
| 1841 | 2517 | unset($data); | 
| 1842 | 2518 | } | 
| 1843 | 2519 |  			} elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') { | 
| @@ -1850,22 +2526,46 @@ discard block | ||
| 1850 | 2526 | $data['hex'] = $lined['hexid']; | 
| 1851 | 2527 |      				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; | 
| 1852 | 2528 |      				$data['datetime'] = date('Y-m-d H:i:s');; | 
| 1853 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; | |
| 1854 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; | |
| 1855 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; | |
| 1856 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; | |
| 1857 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; | |
| 1858 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; | |
| 1859 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; | |
| 2529 | +    				if (isset($lined['ident'])) { | |
| 2530 | + $data['ident'] = $lined['ident']; | |
| 2531 | + } | |
| 2532 | +    				if (isset($lined['lat'])) { | |
| 2533 | + $data['latitude'] = $lined['lat']; | |
| 2534 | + } | |
| 2535 | +    				if (isset($lined['lon'])) { | |
| 2536 | + $data['longitude'] = $lined['lon']; | |
| 2537 | + } | |
| 2538 | +    				if (isset($lined['speed'])) { | |
| 2539 | + $data['speed'] = $lined['speed']; | |
| 2540 | + } | |
| 2541 | +    				if (isset($lined['squawk'])) { | |
| 2542 | + $data['squawk'] = $lined['squawk']; | |
| 2543 | + } | |
| 2544 | +    				if (isset($lined['alt'])) { | |
| 2545 | + $data['altitude'] = $lined['alt']; | |
| 2546 | + } | |
| 2547 | +    				if (isset($lined['heading'])) { | |
| 2548 | + $data['heading'] = $lined['heading']; | |
| 2549 | + } | |
| 1860 | 2550 | $data['id_source'] = $id_source; | 
| 1861 | 2551 | $data['format_source'] = 'tsv'; | 
| 1862 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; | |
| 1863 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; | |
| 1864 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 1865 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); | |
| 2552 | +    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { | |
| 2553 | + $data['source_name'] = $globalSources[$nb]['name']; | |
| 2554 | + } | |
| 2555 | +    				if (isset($globalSources[$nb]['sourcestats'])) { | |
| 2556 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; | |
| 2557 | + } | |
| 2558 | +				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { | |
| 2559 | + $data['noarchive'] = true; | |
| 2560 | + } | |
| 2561 | +    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { | |
| 2562 | + $SI->add($data); | |
| 2563 | + } | |
| 1866 | 2564 | unset($lined); | 
| 1867 | 2565 | unset($data); | 
| 1868 | - } else $error = true; | |
| 2566 | +    			    } else { | |
| 2567 | + $error = true; | |
| 2568 | + } | |
| 1869 | 2569 |  			} elseif ($format === 'aprs' && $use_aprs) { | 
| 1870 | 2570 |  			    if ($aprs_connect === 0) { | 
| 1871 | 2571 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); | 
| @@ -1891,47 +2591,96 @@ discard block | ||
| 1891 | 2591 | $aprs_last_tx = time(); | 
| 1892 | 2592 | $data = array(); | 
| 1893 | 2593 | //print_r($line); | 
| 1894 | - if (isset($line['address'])) $data['hex'] = $line['address']; | |
| 1895 | - if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; | |
| 1896 | - if (isset($line['imo'])) $data['imo'] = $line['imo']; | |
| 1897 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; | |
| 1898 | - if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code']; | |
| 1899 | - if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date']; | |
| 1900 | - if (isset($line['typeid'])) $data['type_id'] = $line['typeid']; | |
| 1901 | - if (isset($line['statusid'])) $data['status_id'] = $line['statusid']; | |
| 1902 | -				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); | |
| 1903 | -				    else $data['datetime'] = date('Y-m-d H:i:s'); | |
| 2594 | +				    if (isset($line['address'])) { | |
| 2595 | + $data['hex'] = $line['address']; | |
| 2596 | + } | |
| 2597 | +				    if (isset($line['mmsi'])) { | |
| 2598 | + $data['mmsi'] = $line['mmsi']; | |
| 2599 | + } | |
| 2600 | +				    if (isset($line['imo'])) { | |
| 2601 | + $data['imo'] = $line['imo']; | |
| 2602 | + } | |
| 2603 | +				    if (isset($line['squawk'])) { | |
| 2604 | + $data['squawk'] = $line['squawk']; | |
| 2605 | + } | |
| 2606 | +				    if (isset($line['arrival_code'])) { | |
| 2607 | + $data['arrival_code'] = $line['arrival_code']; | |
| 2608 | + } | |
| 2609 | +				    if (isset($line['arrival_date'])) { | |
| 2610 | + $data['arrival_date'] = $line['arrival_date']; | |
| 2611 | + } | |
| 2612 | +				    if (isset($line['typeid'])) { | |
| 2613 | + $data['type_id'] = $line['typeid']; | |
| 2614 | + } | |
| 2615 | +				    if (isset($line['statusid'])) { | |
| 2616 | + $data['status_id'] = $line['statusid']; | |
| 2617 | + } | |
| 2618 | +				    if (isset($line['timestamp'])) { | |
| 2619 | +				    	$data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); | |
| 2620 | +				    } else { | |
| 2621 | +				    	$data['datetime'] = date('Y-m-d H:i:s'); | |
| 2622 | + } | |
| 1904 | 2623 |  				    //$data['datetime'] = date('Y-m-d H:i:s'); | 
| 1905 | - if (isset($line['ident'])) $data['ident'] = $line['ident']; | |
| 2624 | +				    if (isset($line['ident'])) { | |
| 2625 | + $data['ident'] = $line['ident']; | |
| 2626 | + } | |
| 1906 | 2627 | $data['latitude'] = $line['latitude']; | 
| 1907 | 2628 | $data['longitude'] = $line['longitude']; | 
| 1908 | 2629 | //$data['verticalrate'] = $line[16]; | 
| 1909 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; | |
| 2630 | +				    if (isset($line['speed'])) { | |
| 2631 | + $data['speed'] = $line['speed']; | |
| 2632 | + } | |
| 1910 | 2633 | //else $data['speed'] = 0; | 
| 1911 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; | |
| 1912 | - if (isset($line['comment'])) $data['comment'] = $line['comment']; | |
| 1913 | - if (isset($line['symbol'])) $data['type'] = $line['symbol']; | |
| 2634 | +				    if (isset($line['altitude'])) { | |
| 2635 | + $data['altitude'] = $line['altitude']; | |
| 2636 | + } | |
| 2637 | +				    if (isset($line['comment'])) { | |
| 2638 | + $data['comment'] = $line['comment']; | |
| 2639 | + } | |
| 2640 | +				    if (isset($line['symbol'])) { | |
| 2641 | + $data['type'] = $line['symbol']; | |
| 2642 | + } | |
| 1914 | 2643 | //if (isset($line['heading'])) $data['heading'] = $line['heading']; | 
| 1915 | 2644 | |
| 1916 | - if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading']; | |
| 2645 | +				    if (isset($line['heading']) && isset($line['format_source'])) { | |
| 2646 | + $data['heading'] = $line['heading']; | |
| 2647 | + } | |
| 1917 | 2648 | //else echo 'No heading...'."\n"; | 
| 1918 | 2649 | //else $data['heading'] = 0; | 
| 1919 | - if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; | |
| 2650 | +				    if (isset($line['stealth'])) { | |
| 2651 | + $data['aircraft_type'] = $line['stealth']; | |
| 2652 | + } | |
| 1920 | 2653 | //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; | 
| 1921 | - if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true; | |
| 1922 | - elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false; | |
| 1923 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 1924 | - elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; | |
| 2654 | +				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) { | |
| 2655 | + $data['noarchive'] = true; | |
| 2656 | +				    } elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) { | |
| 2657 | + $data['noarchive'] = false; | |
| 2658 | + } | |
| 2659 | +				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { | |
| 2660 | + $data['noarchive'] = true; | |
| 2661 | +				    } elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) { | |
| 2662 | + $data['noarchive'] = false; | |
| 2663 | + } | |
| 1925 | 2664 | $data['id_source'] = $id_source; | 
| 1926 | - if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; | |
| 1927 | - else $data['format_source'] = 'aprs'; | |
| 2665 | +    				    if (isset($line['format_source'])) { | |
| 2666 | + $data['format_source'] = $line['format_source']; | |
| 2667 | +    				    } else { | |
| 2668 | + $data['format_source'] = 'aprs'; | |
| 2669 | + } | |
| 1928 | 2670 | $data['source_name'] = $line['source']; | 
| 1929 | - if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; | |
| 1930 | - else $data['source_type'] = 'flarm'; | |
| 1931 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; | |
| 2671 | +				    if (isset($line['source_type'])) { | |
| 2672 | + $data['source_type'] = $line['source_type']; | |
| 2673 | +				    } else { | |
| 2674 | + $data['source_type'] = 'flarm'; | |
| 2675 | + } | |
| 2676 | +    				    if (isset($globalSources[$nb]['sourcestats'])) { | |
| 2677 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; | |
| 2678 | + } | |
| 1932 | 2679 |  				    $currentdate = date('Y-m-d H:i:s'); | 
| 1933 | 2680 | $aprsdate = strtotime($data['datetime']); | 
| 1934 | - if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL'; | |
| 2681 | +				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') { | |
| 2682 | + $data['altitude_relative'] = 'AMSL'; | |
| 2683 | + } | |
| 1935 | 2684 | // Accept data if time <= system time + 20s | 
| 1936 | 2685 |  				    //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'])))) { | 
| 1937 | 2686 | if ( | 
| @@ -1943,7 +2692,9 @@ discard block | ||
| 1943 | 2692 | $send = $SI->add($data); | 
| 1944 | 2693 |  				    } elseif ($data['source_type'] === 'ais') { | 
| 1945 | 2694 | $data['type'] = ''; | 
| 1946 | - if (isset($globalMarine) && $globalMarine) $send = $MI->add($data); | |
| 2695 | +					if (isset($globalMarine) && $globalMarine) { | |
| 2696 | + $send = $MI->add($data); | |
| 2697 | + } | |
| 1947 | 2698 |  				    } elseif (isset($line['stealth']) && $line['stealth'] != 0) { | 
| 1948 | 2699 | echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; | 
| 1949 | 2700 | } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( | 
| @@ -1951,8 +2702,12 @@ discard block | ||
| 1951 | 2702 | $line['symbol'] === 'Glider' || | 
| 1952 | 2703 | $line['symbol'] === 'No. Plane' || | 
| 1953 | 2704 |  					    $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) { | 
| 1954 | - if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL'; | |
| 1955 | - if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER'; | |
| 2705 | +					    if ($line['symbol'] === 'Ballon') { | |
| 2706 | + $data['aircraft_icao'] = 'BALL'; | |
| 2707 | + } | |
| 2708 | +					    if ($line['symbol'] === 'Glider') { | |
| 2709 | + $data['aircraft_icao'] = 'PARAGLIDER'; | |
| 2710 | + } | |
| 1956 | 2711 | $send = $SI->add($data); | 
| 1957 | 2712 | } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( | 
| 1958 | 2713 | $line['symbol'] === 'Yacht (Sail)' || | 
| @@ -1983,9 +2738,13 @@ discard block | ||
| 1983 | 2738 |  				    //} 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') { | 
| 1984 | 2739 |  				//    } 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') { | 
| 1985 | 2740 | //echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n"; | 
| 1986 | - if (isset($globalTracker) && $globalTracker) $send = $TI->add($data); | |
| 2741 | +					if (isset($globalTracker) && $globalTracker) { | |
| 2742 | + $send = $TI->add($data); | |
| 2743 | + } | |
| 1987 | 2744 |  				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { | 
| 1988 | - if (!isset($data['altitude'])) $data['altitude'] = 0; | |
| 2745 | +					if (!isset($data['altitude'])) { | |
| 2746 | + $data['altitude'] = 0; | |
| 2747 | + } | |
| 1989 | 2748 |  					$Source->deleteOldLocationByType('gs'); | 
| 1990 | 2749 |  					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) { | 
| 1991 | 2750 | $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); | 
| @@ -1994,7 +2753,9 @@ discard block | ||
| 1994 | 2753 | } | 
| 1995 | 2754 |  				    } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') { | 
| 1996 | 2755 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; | 
| 1997 | - if ($globalDebug) echo '# Weather Station added'."\n"; | |
| 2756 | +					if ($globalDebug) { | |
| 2757 | + echo '# Weather Station added'."\n"; | |
| 2758 | + } | |
| 1998 | 2759 |  					$Source->deleteOldLocationByType('wx'); | 
| 1999 | 2760 | $weather_data = json_encode($line); | 
| 2000 | 2761 |  					if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) { | 
| @@ -2004,7 +2765,9 @@ discard block | ||
| 2004 | 2765 | } | 
| 2005 | 2766 |  				    } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) { | 
| 2006 | 2767 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; | 
| 2007 | - if ($globalDebug) echo '☈ Lightning added'."\n"; | |
| 2768 | +					if ($globalDebug) { | |
| 2769 | + echo '☈ Lightning added'."\n"; | |
| 2770 | + } | |
| 2008 | 2771 |  					$Source->deleteOldLocationByType('lightning'); | 
| 2009 | 2772 |  					if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) { | 
| 2010 | 2773 | $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']); | 
| @@ -2016,8 +2779,7 @@ discard block | ||
| 2016 | 2779 | print_r($line); | 
| 2017 | 2780 | } | 
| 2018 | 2781 | unset($data); | 
| 2019 | - } | |
| 2020 | -				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { | |
| 2782 | +				} elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { | |
| 2021 | 2783 | $Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']); | 
| 2022 | 2784 | } | 
| 2023 | 2785 | /* | 
| @@ -2026,7 +2788,9 @@ discard block | ||
| 2026 | 2788 | } | 
| 2027 | 2789 | */ | 
| 2028 | 2790 |  				//elseif ($line === false && $globalDebug) echo 'Ignored ('.$buffer.")\n"; | 
| 2029 | - elseif ($line === true && $globalDebug) echo '!! Failed : '.$buffer."!!\n"; | |
| 2791 | +				elseif ($line === true && $globalDebug) { | |
| 2792 | + echo '!! Failed : '.$buffer."!!\n"; | |
| 2793 | + } | |
| 2030 | 2794 |  				if (isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) { | 
| 2031 | 2795 |  					$Source->deleteOldLocationByType('lightning'); | 
| 2032 | 2796 |  					$Source->deleteOldLocationByType('wx'); | 
| @@ -2063,27 +2827,47 @@ discard block | ||
| 2063 | 2827 | $data['ground'] = $line[21]; | 
| 2064 | 2828 | $data['emergency'] = $line[19]; | 
| 2065 | 2829 | $data['format_source'] = 'sbs'; | 
| 2066 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; | |
| 2067 | - elseif ($line[0] == 'MLAT') $data['source_name'] = 'MLAT'; | |
| 2068 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; | |
| 2069 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 2830 | +				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { | |
| 2831 | + $data['source_name'] = $globalSources[$nb]['name']; | |
| 2832 | +				} elseif ($line[0] == 'MLAT') { | |
| 2833 | + $data['source_name'] = 'MLAT'; | |
| 2834 | + } | |
| 2835 | +				if (isset($globalSources[$nb]['sourcestats'])) { | |
| 2836 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; | |
| 2837 | + } | |
| 2838 | +				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { | |
| 2839 | + $data['noarchive'] = true; | |
| 2840 | + } | |
| 2070 | 2841 | $data['id_source'] = $id_source; | 
| 2071 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); | |
| 2072 | - else $error = true; | |
| 2842 | +    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { | |
| 2843 | + $send = $SI->add($data); | |
| 2844 | +    				} else { | |
| 2845 | + $error = true; | |
| 2846 | + } | |
| 2073 | 2847 | unset($data); | 
| 2074 | - } else $error = true; | |
| 2848 | +    			    } else { | |
| 2849 | + $error = true; | |
| 2850 | + } | |
| 2075 | 2851 |  			    if ($error) { | 
| 2076 | 2852 |  				if (count($line) > 1 && ($line[0] === 'STA' || $line[0] === 'AIR' || $line[0] === 'SEL' || $line[0] === 'ID' || $line[0] === 'CLK')) {  | 
| 2077 | - if ($globalDebug) echo "Not a message. Ignoring... \n"; | |
| 2853 | +					if ($globalDebug) { | |
| 2854 | + echo "Not a message. Ignoring... \n"; | |
| 2855 | + } | |
| 2078 | 2856 |  				} else { | 
| 2079 | - if ($globalDebug) echo "Wrong line format. Ignoring... \n"; | |
| 2857 | +					if ($globalDebug) { | |
| 2858 | + echo "Wrong line format. Ignoring... \n"; | |
| 2859 | + } | |
| 2080 | 2860 |  					if ($globalDebug) { | 
| 2081 | 2861 | echo $buffer; | 
| 2082 | 2862 | //print_r($line); | 
| 2083 | 2863 | } | 
| 2084 | 2864 | //socket_close($r); | 
| 2085 | - if ($globalDebug) echo "Reconnect after an error...\n"; | |
| 2086 | - if ($format === 'aprs') $aprs_connect = 0; | |
| 2865 | +					if ($globalDebug) { | |
| 2866 | + echo "Reconnect after an error...\n"; | |
| 2867 | + } | |
| 2868 | +					if ($format === 'aprs') { | |
| 2869 | + $aprs_connect = 0; | |
| 2870 | + } | |
| 2087 | 2871 | $sourceer[$nb] = $globalSources[$nb]; | 
| 2088 | 2872 | connect_all($sourceer); | 
| 2089 | 2873 | $sourceer = array(); | 
| @@ -2091,10 +2875,14 @@ discard block | ||
| 2091 | 2875 | } | 
| 2092 | 2876 | } | 
| 2093 | 2877 | // Sleep for xxx microseconds | 
| 2094 | - if (isset($globalSBSSleep)) usleep($globalSBSSleep); | |
| 2878 | +			if (isset($globalSBSSleep)) { | |
| 2879 | + usleep($globalSBSSleep); | |
| 2880 | + } | |
| 2095 | 2881 |  		    } else { | 
| 2096 | 2882 |  			if ($format === 'flightgearmp') { | 
| 2097 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; | |
| 2883 | +			    	if ($globalDebug) { | |
| 2884 | + echo "Reconnect FlightGear MP..."; | |
| 2885 | + } | |
| 2098 | 2886 | //@socket_close($r); | 
| 2099 | 2887 | sleep($globalMinFetch); | 
| 2100 | 2888 | $sourcefg[$nb] = $globalSources[$nb]; | 
| @@ -2103,10 +2891,15 @@ discard block | ||
| 2103 | 2891 | break; | 
| 2104 | 2892 | |
| 2105 | 2893 |  			} elseif ($format != 'acars' && $format != 'flightgearsp') { | 
| 2106 | - if (isset($tt[$format])) $tt[$format]++; | |
| 2107 | - else $tt[$format] = 0; | |
| 2894 | +			    if (isset($tt[$format])) { | |
| 2895 | + $tt[$format]++; | |
| 2896 | +			    } else { | |
| 2897 | + $tt[$format] = 0; | |
| 2898 | + } | |
| 2108 | 2899 |  			    if ($tt[$format] > 30 || $buffer === FALSE) { | 
| 2109 | - if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; | |
| 2900 | +				if ($globalDebug) { | |
| 2901 | + echo "ERROR : Reconnect ".$format."..."; | |
| 2902 | + } | |
| 2110 | 2903 | //@socket_close($r); | 
| 2111 | 2904 | sleep(2); | 
| 2112 | 2905 | $aprs_connect = 0; | 
| @@ -2124,11 +2917,17 @@ discard block | ||
| 2124 | 2917 |  	    } else { | 
| 2125 | 2918 | $error = socket_strerror(socket_last_error()); | 
| 2126 | 2919 |  		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { | 
| 2127 | - if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; | |
| 2128 | - if (isset($globalDebug)) echo "Restarting...\n"; | |
| 2920 | +			if ($globalDebug) { | |
| 2921 | + echo "ERROR : socket_select give this error ".$error . "\n"; | |
| 2922 | + } | |
| 2923 | +			if (isset($globalDebug)) { | |
| 2924 | + echo "Restarting...\n"; | |
| 2925 | + } | |
| 2129 | 2926 | // Restart the script if possible | 
| 2130 | 2927 |  			if (is_array($sockets)) { | 
| 2131 | - if ($globalDebug) echo "Shutdown all sockets..."; | |
| 2928 | +			    if ($globalDebug) { | |
| 2929 | + echo "Shutdown all sockets..."; | |
| 2930 | + } | |
| 2132 | 2931 | |
| 2133 | 2932 |  			    foreach ($sockets as $sock) { | 
| 2134 | 2933 | @socket_shutdown($sock,2); | 
| @@ -2136,25 +2935,45 @@ discard block | ||
| 2136 | 2935 | } | 
| 2137 | 2936 | |
| 2138 | 2937 | } | 
| 2139 | - if ($globalDebug) echo "Waiting..."; | |
| 2938 | +			if ($globalDebug) { | |
| 2939 | + echo "Waiting..."; | |
| 2940 | + } | |
| 2140 | 2941 | sleep(2); | 
| 2141 | 2942 | $time = time(); | 
| 2142 | 2943 | //connect_all($hosts); | 
| 2143 | 2944 | $aprs_connect = 0; | 
| 2144 | - if ($reset%5 === 0) sleep(20); | |
| 2145 | - if ($reset%10 === 0) sleep(100); | |
| 2146 | - if ($reset%20 === 0) sleep(200); | |
| 2147 | -			if ($reset > 100) exit('Too many attempts...'); | |
| 2148 | - if ($globalDebug) echo "Restart all connections..."; | |
| 2945 | +			if ($reset%5 === 0) { | |
| 2946 | + sleep(20); | |
| 2947 | + } | |
| 2948 | +			if ($reset%10 === 0) { | |
| 2949 | + sleep(100); | |
| 2950 | + } | |
| 2951 | +			if ($reset%20 === 0) { | |
| 2952 | + sleep(200); | |
| 2953 | + } | |
| 2954 | +			if ($reset > 100) { | |
| 2955 | +				exit('Too many attempts...'); | |
| 2956 | + } | |
| 2957 | +			if ($globalDebug) { | |
| 2958 | + echo "Restart all connections..."; | |
| 2959 | + } | |
| 2149 | 2960 | connect_all($globalSources); | 
| 2150 | 2961 | } | 
| 2151 | 2962 | } | 
| 2152 | 2963 | } | 
| 2153 | 2964 |  	if ($globalDaemon === false) { | 
| 2154 | - if ($globalDebug) echo 'Check all...'."\n"; | |
| 2155 | - if (isset($SI)) $SI->checkAll(); | |
| 2156 | - if (isset($TI)) $TI->checkAll(); | |
| 2157 | - if (isset($MI)) $MI->checkAll(); | |
| 2965 | +	    if ($globalDebug) { | |
| 2966 | + echo 'Check all...'."\n"; | |
| 2967 | + } | |
| 2968 | +	    if (isset($SI)) { | |
| 2969 | + $SI->checkAll(); | |
| 2970 | + } | |
| 2971 | +	    if (isset($TI)) { | |
| 2972 | + $TI->checkAll(); | |
| 2973 | + } | |
| 2974 | +	    if (isset($MI)) { | |
| 2975 | + $MI->checkAll(); | |
| 2976 | + } | |
| 2158 | 2977 | } | 
| 2159 | 2978 | } | 
| 2160 | 2979 | } |