| @@ -22,7 +22,9 @@ discard block | ||
| 22 | 22 | require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); | 
| 23 | 23 | } | 
| 24 | 24 | |
| 25 | -if (!isset($globalDebug)) $globalDebug = FALSE; | |
| 25 | +if (!isset($globalDebug)) { | |
| 26 | + $globalDebug = FALSE; | |
| 27 | +} | |
| 26 | 28 | |
| 27 | 29 |  if ($globalInstalled === FALSE) { | 
| 28 | 30 | echo "This script MUST be run after install script. Use your web browser to run install/index.php"; | 
| @@ -68,66 +70,107 @@ discard block | ||
| 68 | 70 | //elseif (isset($options['source'])) $hosts = array($options['source']); | 
| 69 | 71 |  if (isset($options['s'])) { | 
| 70 | 72 | $globalSources = array(); | 
| 71 | -    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); | |
| 72 | -    else $globalSources[] = array('host' => $options['s']); | |
| 73 | -} elseif (isset($options['source'])) { | |
| 73 | +    if (isset($options['format'])) { | |
| 74 | +    	$globalSources[] = array('host' => $options['s'],'format' => $options['format']); | |
| 75 | +    } else { | |
| 76 | +    	$globalSources[] = array('host' => $options['s']); | |
| 77 | + } | |
| 78 | +    } elseif (isset($options['source'])) { | |
| 74 | 79 | $globalSources = array(); | 
| 75 | -    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); | |
| 76 | -    else $globalSources[] = array('host' => $options['source']); | |
| 77 | -} | |
| 80 | +    if (isset($options['format'])) { | |
| 81 | +    	$globalSources[] = array('host' => $options['source'],'format' => $options['format']); | |
| 82 | +    } else { | |
| 83 | +    	$globalSources[] = array('host' => $options['source']); | |
| 84 | + } | |
| 85 | + } | |
| 78 | 86 |  if (isset($options['aprsserverhost'])) { | 
| 79 | 87 | $globalServerAPRS = TRUE; | 
| 80 | 88 | $globalServerAPRShost = $options['aprsserverhost']; | 
| 81 | 89 | } | 
| 82 | -if (isset($options['aprsserverport'])) $globalServerAPRSport = $options['aprsserverport']; | |
| 83 | -if (isset($options['aprsserverssid'])) $globalServerAPRSssid = $options['aprsserverssid']; | |
| 84 | -if (isset($options['aprsserverpass'])) $globalServerAPRSpass = $options['aprsserverpass']; | |
| 85 | -if (isset($options['noaprsserver'])) $globalServerAPRS = FALSE; | |
| 90 | +if (isset($options['aprsserverport'])) { | |
| 91 | + $globalServerAPRSport = $options['aprsserverport']; | |
| 92 | +} | |
| 93 | +if (isset($options['aprsserverssid'])) { | |
| 94 | + $globalServerAPRSssid = $options['aprsserverssid']; | |
| 95 | +} | |
| 96 | +if (isset($options['aprsserverpass'])) { | |
| 97 | + $globalServerAPRSpass = $options['aprsserverpass']; | |
| 98 | +} | |
| 99 | +if (isset($options['noaprsserver'])) { | |
| 100 | + $globalServerAPRS = FALSE; | |
| 101 | +} | |
| 86 | 102 |  if (isset($options['enable-aircraft'])) { | 
| 87 | - if ($globalDebug) echo 'Enable Aircraft mode'."\n"; | |
| 103 | +	if ($globalDebug) { | |
| 104 | + echo 'Enable Aircraft mode'."\n"; | |
| 105 | + } | |
| 88 | 106 | $globalAircraft = TRUE; | 
| 89 | 107 | } | 
| 90 | 108 |  if (isset($options['disable-aircraft'])) { | 
| 91 | - if ($globalDebug) echo 'Disable Aircraft mode'."\n"; | |
| 109 | +	if ($globalDebug) { | |
| 110 | + echo 'Disable Aircraft mode'."\n"; | |
| 111 | + } | |
| 92 | 112 | $globalAircraft = FALSE; | 
| 93 | 113 | } | 
| 94 | 114 |  if (isset($options['enable-tracker'])) { | 
| 95 | - if ($globalDebug) echo 'Enable Tracker mode'."\n"; | |
| 115 | +	if ($globalDebug) { | |
| 116 | + echo 'Enable Tracker mode'."\n"; | |
| 117 | + } | |
| 96 | 118 | $globalTracker = TRUE; | 
| 97 | 119 | } | 
| 98 | 120 |  if (isset($options['disable-tracker'])) { | 
| 99 | - if ($globalDebug) echo 'Disable Tracker mode'."\n"; | |
| 121 | +	if ($globalDebug) { | |
| 122 | + echo 'Disable Tracker mode'."\n"; | |
| 123 | + } | |
| 100 | 124 | $globalTracker = FALSE; | 
| 101 | 125 | } | 
| 102 | 126 |  if (isset($options['enable-marine'])) { | 
| 103 | - if ($globalDebug) echo 'Enable Marine mode'."\n"; | |
| 127 | +	if ($globalDebug) { | |
| 128 | + echo 'Enable Marine mode'."\n"; | |
| 129 | + } | |
| 104 | 130 | $globalMarine = TRUE; | 
| 105 | 131 | } | 
| 106 | 132 |  if (isset($options['disable-marine'])) { | 
| 107 | - if ($globalDebug) echo 'Disable Marine mode'."\n"; | |
| 133 | +	if ($globalDebug) { | |
| 134 | + echo 'Disable Marine mode'."\n"; | |
| 135 | + } | |
| 108 | 136 | $globalMarine = FALSE; | 
| 109 | 137 | } | 
| 110 | -if (isset($options['nodaemon'])) $globalDaemon = FALSE; | |
| 111 | -if (isset($options['server'])) $globalServer = TRUE; | |
| 112 | -if (isset($options['idsource'])) $id_source = $options['idsource']; | |
| 113 | -else $id_source = 1; | |
| 138 | +if (isset($options['nodaemon'])) { | |
| 139 | + $globalDaemon = FALSE; | |
| 140 | +} | |
| 141 | +if (isset($options['server'])) { | |
| 142 | + $globalServer = TRUE; | |
| 143 | +} | |
| 144 | +if (isset($options['idsource'])) { | |
| 145 | + $id_source = $options['idsource']; | |
| 146 | +} else { | |
| 147 | + $id_source = 1; | |
| 148 | +} | |
| 114 | 149 |  if (isset($globalServer) && $globalServer) { | 
| 115 | - if ($globalDebug) echo "Using Server Mode\n"; | |
| 150 | +    if ($globalDebug) { | |
| 151 | + echo "Using Server Mode\n"; | |
| 152 | + } | |
| 116 | 153 | $SI=new SpotterServer(); | 
| 117 | 154 | /* | 
| 118 | 155 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); | 
| 119 | 156 | $SI = new adsb2aprs(); | 
| 120 | 157 | $SI->connect(); | 
| 121 | 158 | */ | 
| 122 | -} else $SI=new SpotterImport($Connection->db); | |
| 159 | +} else { | |
| 160 | + $SI=new SpotterImport($Connection->db); | |
| 161 | +} | |
| 123 | 162 | |
| 124 | -if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); | |
| 163 | +if (isset($globalTracker) && $globalTracker) { | |
| 164 | + require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); | |
| 165 | +} | |
| 125 | 166 |  if (isset($globalMarine) && $globalMarine) { | 
| 126 | 167 | require_once(dirname(__FILE__).'/../require/class.AIS.php'); | 
| 127 | 168 | require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); | 
| 128 | 169 | } | 
| 129 | 170 | |
| 130 | -if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db); | |
| 171 | +if (isset($globalTracker) && $globalTracker) { | |
| 172 | + $TI = new TrackerImport($Connection->db); | |
| 173 | +} | |
| 131 | 174 |  if (isset($globalMarine) && $globalMarine) { | 
| 132 | 175 | $AIS = new AIS(); | 
| 133 | 176 | $MI = new MarineImport($Connection->db); | 
| @@ -152,7 +195,9 @@ discard block | ||
| 152 | 195 | } | 
| 153 | 196 | |
| 154 | 197 | // let's try and connect | 
| 155 | -if ($globalDebug) echo "Connecting...\n"; | |
| 198 | +if ($globalDebug) { | |
| 199 | + echo "Connecting...\n"; | |
| 200 | +} | |
| 156 | 201 | $use_aprs = false; | 
| 157 | 202 | $aprs_full = false; | 
| 158 | 203 | $reset = 0; | 
| @@ -161,7 +206,9 @@ discard block | ||
| 161 | 206 | //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; | 
| 162 | 207 | global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; | 
| 163 | 208 | $reset++; | 
| 164 | - if ($globalDebug) echo 'Connect to all...'."\n"; | |
| 209 | +    if ($globalDebug) { | |
| 210 | + echo 'Connect to all...'."\n"; | |
| 211 | + } | |
| 165 | 212 |      foreach ($hosts as $id => $value) { | 
| 166 | 213 | $host = $value['host']; | 
| 167 | 214 | $udp = false; | 
| @@ -172,32 +219,44 @@ discard block | ||
| 172 | 219 | //$formats[$id] = 'deltadbtxt'; | 
| 173 | 220 | $globalSources[$id]['format'] = 'deltadbtxt'; | 
| 174 | 221 | //$last_exec['deltadbtxt'] = 0; | 
| 175 | -        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; | |
| 222 | +        	if ($globalDebug) { | |
| 223 | +        		echo "Connect to deltadb source (".$host.")...\n"; | |
| 224 | + } | |
| 176 | 225 |              } else if (preg_match('/vatsim-data.txt$/i',$host)) { | 
| 177 | 226 | //$formats[$id] = 'vatsimtxt'; | 
| 178 | 227 | $globalSources[$id]['format'] = 'vatsimtxt'; | 
| 179 | 228 | //$last_exec['vatsimtxt'] = 0; | 
| 180 | -        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; | |
| 229 | +        	if ($globalDebug) { | |
| 230 | +        		echo "Connect to vatsim source (".$host.")...\n"; | |
| 231 | + } | |
| 181 | 232 |      	    } else if (preg_match('/aircraftlist.json$/i',$host)) { | 
| 182 | 233 | //$formats[$id] = 'aircraftlistjson'; | 
| 183 | 234 | $globalSources[$id]['format'] = 'aircraftlistjson'; | 
| 184 | 235 | //$last_exec['aircraftlistjson'] = 0; | 
| 185 | -        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; | |
| 236 | +        	if ($globalDebug) { | |
| 237 | +        		echo "Connect to aircraftlist.json source (".$host.")...\n"; | |
| 238 | + } | |
| 186 | 239 |      	    } else if (preg_match('/aircraft.json$/i',$host)) { | 
| 187 | 240 | //$formats[$id] = 'aircraftjson'; | 
| 188 | 241 | $globalSources[$id]['format'] = 'aircraftjson'; | 
| 189 | 242 | //$last_exec['aircraftlistjson'] = 0; | 
| 190 | -        	if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n"; | |
| 243 | +        	if ($globalDebug) { | |
| 244 | +        		echo "Connect to aircraft.json source (".$host.")...\n"; | |
| 245 | + } | |
| 191 | 246 |      	    } else if (preg_match('/aircraft$/i',$host)) { | 
| 192 | 247 | //$formats[$id] = 'planefinderclient'; | 
| 193 | 248 | $globalSources[$id]['format'] = 'planefinderclient'; | 
| 194 | 249 | //$last_exec['aircraftlistjson'] = 0; | 
| 195 | -        	if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n"; | |
| 250 | +        	if ($globalDebug) { | |
| 251 | +        		echo "Connect to planefinderclient source (".$host.")...\n"; | |
| 252 | + } | |
| 196 | 253 |      	    } else if (preg_match('/opensky/i',$host)) { | 
| 197 | 254 | //$formats[$id] = 'aircraftlistjson'; | 
| 198 | 255 | $globalSources[$id]['format'] = 'opensky'; | 
| 199 | 256 | //$last_exec['aircraftlistjson'] = 0; | 
| 200 | -        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; | |
| 257 | +        	if ($globalDebug) { | |
| 258 | +        		echo "Connect to opensky source (".$host.")...\n"; | |
| 259 | + } | |
| 201 | 260 | /* | 
| 202 | 261 | // Disabled for now, site change source format | 
| 203 | 262 |      	    } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) { | 
| @@ -214,7 +273,9 @@ discard block | ||
| 214 | 273 | //$formats[$id] = 'planeupdatefaa'; | 
| 215 | 274 | $globalSources[$id]['format'] = 'planeupdatefaa'; | 
| 216 | 275 | //$last_exec['planeupdatefaa'] = 0; | 
| 217 | -        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; | |
| 276 | +        	if ($globalDebug) { | |
| 277 | +        		echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; | |
| 278 | + } | |
| 218 | 279 |          	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { | 
| 219 | 280 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; | 
| 220 | 281 | exit(0); | 
| @@ -223,37 +284,53 @@ discard block | ||
| 223 | 284 | //$formats[$id] = 'phpvmacars'; | 
| 224 | 285 | $globalSources[$id]['format'] = 'phpvmacars'; | 
| 225 | 286 | //$last_exec['phpvmacars'] = 0; | 
| 226 | -        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; | |
| 287 | +        	if ($globalDebug) { | |
| 288 | +        		echo "Connect to phpvmacars source (".$host.")...\n"; | |
| 289 | + } | |
| 227 | 290 |              } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) { | 
| 228 | 291 | //$formats[$id] = 'phpvmacars'; | 
| 229 | 292 | $globalSources[$id]['format'] = 'vaos'; | 
| 230 | 293 | //$last_exec['phpvmacars'] = 0; | 
| 231 | -        	if ($globalDebug) echo "Connect to vaos source (".$host.")...\n"; | |
| 294 | +        	if ($globalDebug) { | |
| 295 | +        		echo "Connect to vaos source (".$host.")...\n"; | |
| 296 | + } | |
| 232 | 297 |              } else if (preg_match('/VAM-json.php$/i',$host)) { | 
| 233 | 298 | //$formats[$id] = 'phpvmacars'; | 
| 234 | 299 | $globalSources[$id]['format'] = 'vam'; | 
| 235 | -        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; | |
| 300 | +        	if ($globalDebug) { | |
| 301 | +        		echo "Connect to Vam source (".$host.")...\n"; | |
| 302 | + } | |
| 236 | 303 |              } else if (preg_match('/whazzup/i',$host)) { | 
| 237 | 304 | //$formats[$id] = 'whazzup'; | 
| 238 | 305 | $globalSources[$id]['format'] = 'whazzup'; | 
| 239 | 306 | //$last_exec['whazzup'] = 0; | 
| 240 | -        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; | |
| 307 | +        	if ($globalDebug) { | |
| 308 | +        		echo "Connect to whazzup source (".$host.")...\n"; | |
| 309 | + } | |
| 241 | 310 |              } else if (preg_match('/blitzortung/i',$host)) { | 
| 242 | 311 | $globalSources[$id]['format'] = 'blitzortung'; | 
| 243 | -        	if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n"; | |
| 312 | +        	if ($globalDebug) { | |
| 313 | +        		echo "Connect to blitzortung source (".$host.")...\n"; | |
| 314 | + } | |
| 244 | 315 |              } else if (preg_match('/airwhere/i',$host)) { | 
| 245 | 316 | $globalSources[$id]['format'] = 'airwhere'; | 
| 246 | -        	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; | |
| 317 | +        	if ($globalDebug) { | |
| 318 | +        		echo "Connect to airwhere source (".$host.")...\n"; | |
| 319 | + } | |
| 247 | 320 |              } else if (preg_match('/recentpireps/i',$host)) { | 
| 248 | 321 | //$formats[$id] = 'pirepsjson'; | 
| 249 | 322 | $globalSources[$id]['format'] = 'pirepsjson'; | 
| 250 | 323 | //$last_exec['pirepsjson'] = 0; | 
| 251 | -        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; | |
| 324 | +        	if ($globalDebug) { | |
| 325 | +        		echo "Connect to pirepsjson source (".$host.")...\n"; | |
| 326 | + } | |
| 252 | 327 |              } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { | 
| 253 | 328 | //$formats[$id] = 'fr24json'; | 
| 254 | 329 | $globalSources[$id]['format'] = 'fr24json'; | 
| 255 | 330 | //$last_exec['fr24json'] = 0; | 
| 256 | -        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; | |
| 331 | +        	if ($globalDebug) { | |
| 332 | +        		echo "Connect to fr24 source (".$host.")...\n"; | |
| 333 | + } | |
| 257 | 334 |          	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { | 
| 258 | 335 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; | 
| 259 | 336 | exit(0); | 
| @@ -262,7 +339,9 @@ discard block | ||
| 262 | 339 | //$formats[$id] = 'fr24json'; | 
| 263 | 340 | $globalSources[$id]['format'] = 'myshiptracking'; | 
| 264 | 341 | //$last_exec['fr24json'] = 0; | 
| 265 | -        	if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; | |
| 342 | +        	if ($globalDebug) { | |
| 343 | +        		echo "Connect to myshiptracking source (".$host.")...\n"; | |
| 344 | + } | |
| 266 | 345 |          	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { | 
| 267 | 346 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; | 
| 268 | 347 | exit(0); | 
| @@ -271,18 +350,28 @@ discard block | ||
| 271 | 350 |              } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { | 
| 272 | 351 | //$formats[$id] = 'tsv'; | 
| 273 | 352 | $globalSources[$id]['format'] = 'tsv'; | 
| 274 | -        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; | |
| 353 | +        	if ($globalDebug) { | |
| 354 | +        		echo "Connect to tsv source (".$host.")...\n"; | |
| 355 | + } | |
| 275 | 356 | } | 
| 276 | 357 |          } elseif (filter_var($host,FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailawayfull') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'acarsjson')) { | 
| 277 | 358 |      		if ($globalSources[$id]['format'] == 'aisnmeahttp' || $globalSources[$id]['format'] == 'acarsjson') { | 
| 278 | 359 | $idf = fopen($globalSources[$id]['host'],'r',false,$context); | 
| 279 | 360 |      		    if ($idf !== false) { | 
| 280 | 361 | $httpfeeds[$id] = $idf; | 
| 281 | -        		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; | |
| 282 | - } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; | |
| 283 | - } elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n"; | |
| 284 | - elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailawayfull') echo "Connect to ".$globalSources[$id]['format']." source (sailawayfull)...\n"; | |
| 285 | -    		elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; | |
| 362 | +        		if ($globalDebug) { | |
| 363 | +        			echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; | |
| 364 | + } | |
| 365 | +    		    } elseif ($globalDebug) { | |
| 366 | + echo "Can't connect to ".$globalSources[$id]['host']."\n"; | |
| 367 | + } | |
| 368 | +    		} elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') { | |
| 369 | + echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n"; | |
| 370 | +    		} elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailawayfull') { | |
| 371 | + echo "Connect to ".$globalSources[$id]['format']." source (sailawayfull)...\n"; | |
| 372 | +    		} elseif ($globalDebug) { | |
| 373 | +    			echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; | |
| 374 | + } | |
| 286 | 375 |          } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { | 
| 287 | 376 |  	    $hostport = explode(':',$host); | 
| 288 | 377 |  	    if (isset($hostport[1])) { | 
| @@ -323,20 +412,29 @@ discard block | ||
| 323 | 412 | //$formats[$id] = 'beast'; | 
| 324 | 413 | $globalSources[$id]['format'] = 'beast'; | 
| 325 | 414 | //} else $formats[$id] = 'sbs'; | 
| 326 | - } else $globalSources[$id]['format'] = 'sbs'; | |
| 415 | +		    } else { | |
| 416 | + $globalSources[$id]['format'] = 'sbs'; | |
| 417 | + } | |
| 327 | 418 |  		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; | 
| 328 | 419 | } | 
| 329 | -		if ($globalDebug && $udp) echo 'Listening in UDP from '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; | |
| 330 | -		elseif ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; | |
| 420 | +		if ($globalDebug && $udp) { | |
| 421 | +			echo 'Listening in UDP from '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; | |
| 422 | +		} elseif ($globalDebug) { | |
| 423 | +			echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; | |
| 424 | + } | |
| 331 | 425 |              } else { | 
| 332 | - if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; | |
| 426 | +		if ($globalDebug) { | |
| 427 | + echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; | |
| 428 | + } | |
| 333 | 429 | sleep(10); | 
| 334 | 430 | connect_all($hosts); | 
| 335 | 431 | } | 
| 336 | 432 | } | 
| 337 | 433 | } | 
| 338 | 434 | } | 
| 339 | -if (!isset($globalMinFetch)) $globalMinFetch = 15; | |
| 435 | +if (!isset($globalMinFetch)) { | |
| 436 | + $globalMinFetch = 15; | |
| 437 | +} | |
| 340 | 438 | |
| 341 | 439 | // Initialize all | 
| 342 | 440 | $status = array(); | 
| @@ -345,13 +443,19 @@ discard block | ||
| 345 | 443 | $formats = array(); | 
| 346 | 444 | $last_exec = array(); | 
| 347 | 445 | $time = time(); | 
| 348 | -if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut; | |
| 349 | -else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut; | |
| 350 | -else $timeout = 20; | |
| 446 | +if (isset($globalSourcesTimeout)) { | |
| 447 | + $timeout = $globalSourcesTimeOut; | |
| 448 | +} else if (isset($globalSBS1TimeOut)) { | |
| 449 | + $timeout = $globalSBS1TimeOut; | |
| 450 | +} else { | |
| 451 | + $timeout = 20; | |
| 452 | +} | |
| 351 | 453 | $errno = ''; | 
| 352 | 454 | $errstr=''; | 
| 353 | 455 | |
| 354 | -if (!isset($globalDaemon)) $globalDaemon = TRUE; | |
| 456 | +if (!isset($globalDaemon)) { | |
| 457 | + $globalDaemon = TRUE; | |
| 458 | +} | |
| 355 | 459 | /* Initiate connections to all the hosts simultaneously */ | 
| 356 | 460 | //connect_all($hosts); | 
| 357 | 461 | //connect_all($globalSources); | 
| @@ -380,7 +484,9 @@ discard block | ||
| 380 | 484 |      if (isset($source['format']) && $source['format'] == 'aprs') { | 
| 381 | 485 | $aprs_connect = 0; | 
| 382 | 486 | $use_aprs = true; | 
| 383 | - if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true; | |
| 487 | +	if (isset($source['port']) && $source['port'] == '10152') { | |
| 488 | + $aprs_full = true; | |
| 489 | + } | |
| 384 | 490 | break; | 
| 385 | 491 | } | 
| 386 | 492 | } | 
| @@ -391,25 +497,46 @@ discard block | ||
| 391 | 497 | $aprs_connect = 0; | 
| 392 | 498 | $aprs_keep = 120; | 
| 393 | 499 | $aprs_last_tx = time(); | 
| 394 | - if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; | |
| 395 | -	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); | |
| 396 | - if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid; | |
| 397 | -	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); | |
| 398 | - if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter; | |
| 399 | - else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; | |
| 400 | - if ($aprs_full) $aprs_filter = ''; | |
| 401 | - if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass; | |
| 402 | - else $aprs_pass = '-1'; | |
| 500 | +	if (isset($globalAPRSversion)) { | |
| 501 | + $aprs_version = $globalAPRSversion; | |
| 502 | +	} else { | |
| 503 | +		$aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); | |
| 504 | + } | |
| 505 | +	if (isset($globalAPRSssid)) { | |
| 506 | + $aprs_ssid = $globalAPRSssid; | |
| 507 | +	} else { | |
| 508 | +		$aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); | |
| 509 | + } | |
| 510 | +	if (isset($globalAPRSfilter)) { | |
| 511 | + $aprs_filter = $globalAPRSfilter; | |
| 512 | +	} else { | |
| 513 | + $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; | |
| 514 | + } | |
| 515 | +	if ($aprs_full) { | |
| 516 | + $aprs_filter = ''; | |
| 517 | + } | |
| 518 | +	if (isset($globalAPRSpass)) { | |
| 519 | + $aprs_pass = $globalAPRSpass; | |
| 520 | +	} else { | |
| 521 | + $aprs_pass = '-1'; | |
| 522 | + } | |
| 403 | 523 | |
| 404 | -	if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n"; | |
| 405 | -	else $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; | |
| 406 | -} | |
| 524 | +	if ($aprs_filter != '') { | |
| 525 | +		$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n"; | |
| 526 | +	} else { | |
| 527 | +		$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; | |
| 528 | + } | |
| 529 | + } | |
| 407 | 530 | |
| 408 | 531 | // connected - lets do some work | 
| 409 | 532 | //if ($globalDebug) echo "Connected!\n"; | 
| 410 | 533 | sleep(1); | 
| 411 | -if ($globalDebug) echo "SCAN MODE \n\n"; | |
| 412 | -if (!isset($globalCronEnd)) $globalCronEnd = 60; | |
| 534 | +if ($globalDebug) { | |
| 535 | + echo "SCAN MODE \n\n"; | |
| 536 | +} | |
| 537 | +if (!isset($globalCronEnd)) { | |
| 538 | + $globalCronEnd = 60; | |
| 539 | +} | |
| 413 | 540 | $endtime = time()+$globalCronEnd; | 
| 414 | 541 | $i = 1; | 
| 415 | 542 | $tt = array(); | 
| @@ -423,22 +550,32 @@ discard block | ||
| 423 | 550 | |
| 424 | 551 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. | 
| 425 | 552 |  while ($i > 0) { | 
| 426 | -    if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); | |
| 553 | +    if (function_exists('pcntl_fork')) { | |
| 554 | + pcntl_signal_dispatch(); | |
| 555 | + } | |
| 427 | 556 | |
| 428 | - if (!$globalDaemon) $i = $endtime-time(); | |
| 557 | +    if (!$globalDaemon) { | |
| 558 | + $i = $endtime-time(); | |
| 559 | + } | |
| 429 | 560 | // Delete old ATC | 
| 430 | 561 |      if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { | 
| 431 | - if ($globalDebug) echo 'Delete old ATC...'."\n"; | |
| 562 | +	if ($globalDebug) { | |
| 563 | + echo 'Delete old ATC...'."\n"; | |
| 564 | + } | |
| 432 | 565 | $ATC->deleteOldATC(); | 
| 433 | 566 | } | 
| 434 | 567 | |
| 435 | 568 |      if (count($last_exec) == count($globalSources)) { | 
| 436 | 569 | $max = $globalMinFetch; | 
| 437 | 570 |  	foreach ($last_exec as $last) { | 
| 438 | - if ((time() - $last['last']) < $max) $max = time() - $last['last']; | |
| 571 | +	    if ((time() - $last['last']) < $max) { | |
| 572 | + $max = time() - $last['last']; | |
| 573 | + } | |
| 439 | 574 | } | 
| 440 | 575 |  	if ($max < $globalMinFetch) { | 
| 441 | - if ($globalDebug) echo 'Sleeping...'."\n"; | |
| 576 | +	    if ($globalDebug) { | |
| 577 | + echo 'Sleeping...'."\n"; | |
| 578 | + } | |
| 442 | 579 | sleep($globalMinFetch-$max+2); | 
| 443 | 580 | } | 
| 444 | 581 | } | 
| @@ -448,7 +585,9 @@ discard block | ||
| 448 | 585 |      foreach ($globalSources as $id => $value) { | 
| 449 | 586 |  	date_default_timezone_set('UTC'); | 
| 450 | 587 | //if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n"; | 
| 451 | - if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0; | |
| 588 | +	if (!isset($last_exec[$id]['last'])) { | |
| 589 | + $last_exec[$id]['last'] = 0; | |
| 590 | + } | |
| 452 | 591 | if ($value['format'] === 'deltadbtxt' && | 
| 453 | 592 | ( | 
| 454 | 593 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || | 
| @@ -457,7 +596,9 @@ discard block | ||
| 457 | 596 |  	) { | 
| 458 | 597 | //$buffer = $Common->getData($hosts[$id]); | 
| 459 | 598 | $buffer = $Common->getData($value['host']); | 
| 460 | - if ($buffer != '') $reset = 0; | |
| 599 | +        if ($buffer != '') { | |
| 600 | + $reset = 0; | |
| 601 | + } | |
| 461 | 602 |          $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); | 
| 462 | 603 |          $buffer = explode('\n', $buffer); | 
| 463 | 604 |          foreach ($buffer as $line) { | 
| @@ -466,20 +607,41 @@ discard block | ||
| 466 | 607 | $data = array(); | 
| 467 | 608 | $data['hex'] = $line[1]; // hex | 
| 468 | 609 | $data['ident'] = $line[2]; // ident | 
| 469 | - if (isset($line[3])) $data['altitude'] = $line[3]; // altitude | |
| 470 | - if (isset($line[4])) $data['speed'] = $line[4]; // speed | |
| 471 | - if (isset($line[5])) $data['heading'] = $line[5]; // heading | |
| 472 | - if (isset($line[6])) $data['latitude'] = $line[6]; // lat | |
| 473 | - if (isset($line[7])) $data['longitude'] = $line[7]; // long | |
| 610 | +                if (isset($line[3])) { | |
| 611 | + $data['altitude'] = $line[3]; | |
| 612 | + } | |
| 613 | + // altitude | |
| 614 | +                if (isset($line[4])) { | |
| 615 | + $data['speed'] = $line[4]; | |
| 616 | + } | |
| 617 | + // speed | |
| 618 | +                if (isset($line[5])) { | |
| 619 | + $data['heading'] = $line[5]; | |
| 620 | + } | |
| 621 | + // heading | |
| 622 | +                if (isset($line[6])) { | |
| 623 | + $data['latitude'] = $line[6]; | |
| 624 | + } | |
| 625 | + // lat | |
| 626 | +                if (isset($line[7])) { | |
| 627 | + $data['longitude'] = $line[7]; | |
| 628 | + } | |
| 629 | + // long | |
| 474 | 630 | $data['verticalrate'] = ''; // vertical rate | 
| 475 | 631 | //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk | 
| 476 | 632 | $data['emergency'] = ''; // emergency | 
| 477 | 633 |                  $data['datetime'] = date('Y-m-d H:i:s'); | 
| 478 | 634 | $data['format_source'] = 'deltadbtxt'; | 
| 479 | 635 | $data['id_source'] = $id_source; | 
| 480 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; | |
| 481 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 482 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; | |
| 636 | +                if (isset($value['name']) && $value['name'] != '') { | |
| 637 | + $data['source_name'] = $value['name']; | |
| 638 | + } | |
| 639 | +                if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { | |
| 640 | + $data['noarchive'] = true; | |
| 641 | + } | |
| 642 | +                if (isset($value['sourcestats'])) { | |
| 643 | + $data['sourcestats'] = $value['sourcestats']; | |
| 644 | + } | |
| 483 | 645 | $SI->add($data); | 
| 484 | 646 | unset($data); | 
| 485 | 647 | } | 
| @@ -514,11 +676,20 @@ discard block | ||
| 514 | 676 | $data['format_source'] = 'radarcapejson'; | 
| 515 | 677 | $data['id_source'] = $id_source; | 
| 516 | 678 |                      if (isset($value['name']) && $value['name'] != '') { | 
| 517 | - if (isset($line['src']) && !$line['src'] == 'M') $data['source_name'] = $value['name'].'_MLAT'; | |
| 518 | - else $data['source_name'] = $value['name']; | |
| 519 | - } elseif (isset($line['src']) && $line['src'] == 'M') $data['source_name'] = 'MLAT'; | |
| 520 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 521 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; | |
| 679 | +                        if (isset($line['src']) && !$line['src'] == 'M') { | |
| 680 | + $data['source_name'] = $value['name'].'_MLAT'; | |
| 681 | +                        } else { | |
| 682 | + $data['source_name'] = $value['name']; | |
| 683 | + } | |
| 684 | +                    } elseif (isset($line['src']) && $line['src'] == 'M') { | |
| 685 | + $data['source_name'] = 'MLAT'; | |
| 686 | + } | |
| 687 | +                    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { | |
| 688 | + $data['noarchive'] = true; | |
| 689 | + } | |
| 690 | +                    if (isset($value['sourcestats'])) { | |
| 691 | + $data['sourcestats'] = $value['sourcestats']; | |
| 692 | + } | |
| 522 | 693 | |
| 523 | 694 | $SI->add($data); | 
| 524 | 695 | unset($data); | 
| @@ -534,7 +705,9 @@ discard block | ||
| 534 | 705 |  	    date_default_timezone_set('CET'); | 
| 535 | 706 |  	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); | 
| 536 | 707 |  	    date_default_timezone_set('UTC'); | 
| 537 | - if ($buffer != '') $reset = 0; | |
| 708 | +	    if ($buffer != '') { | |
| 709 | + $reset = 0; | |
| 710 | + } | |
| 538 | 711 |      	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); | 
| 539 | 712 |  	    $buffer = explode('\n',$buffer); | 
| 540 | 713 |  	    foreach ($buffer as $line) { | 
| @@ -543,18 +716,42 @@ discard block | ||
| 543 | 716 | $add = false; | 
| 544 | 717 | $ais_data = $AIS->parse_line(trim($line)); | 
| 545 | 718 | $data = array(); | 
| 546 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; | |
| 547 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); | |
| 548 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; | |
| 549 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; | |
| 550 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; | |
| 551 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; | |
| 552 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; | |
| 553 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; | |
| 554 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; | |
| 555 | - if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid']; | |
| 556 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; | |
| 557 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; | |
| 719 | +		    if (isset($ais_data['ident'])) { | |
| 720 | + $data['ident'] = $ais_data['ident']; | |
| 721 | + } | |
| 722 | +		    if (isset($ais_data['mmsi'])) { | |
| 723 | + $data['mmsi'] = substr($ais_data['mmsi'],-9); | |
| 724 | + } | |
| 725 | +		    if (isset($ais_data['speed'])) { | |
| 726 | + $data['speed'] = $ais_data['speed']; | |
| 727 | + } | |
| 728 | +		    if (isset($ais_data['heading'])) { | |
| 729 | + $data['heading'] = $ais_data['heading']; | |
| 730 | + } | |
| 731 | +		    if (isset($ais_data['latitude'])) { | |
| 732 | + $data['latitude'] = $ais_data['latitude']; | |
| 733 | + } | |
| 734 | +		    if (isset($ais_data['longitude'])) { | |
| 735 | + $data['longitude'] = $ais_data['longitude']; | |
| 736 | + } | |
| 737 | +		    if (isset($ais_data['status'])) { | |
| 738 | + $data['status'] = $ais_data['status']; | |
| 739 | + } | |
| 740 | +		    if (isset($ais_data['statusid'])) { | |
| 741 | + $data['status_id'] = $ais_data['statusid']; | |
| 742 | + } | |
| 743 | +		    if (isset($ais_data['type'])) { | |
| 744 | + $data['type'] = $ais_data['type']; | |
| 745 | + } | |
| 746 | +		    if (isset($ais_data['typeid'])) { | |
| 747 | + $data['type_id'] = $ais_data['typeid']; | |
| 748 | + } | |
| 749 | +		    if (isset($ais_data['imo'])) { | |
| 750 | + $data['imo'] = $ais_data['imo']; | |
| 751 | + } | |
| 752 | +		    if (isset($ais_data['callsign'])) { | |
| 753 | + $data['callsign'] = $ais_data['callsign']; | |
| 754 | + } | |
| 558 | 755 |  		    if (isset($ais_data['timestamp'])) { | 
| 559 | 756 |  			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); | 
| 560 | 757 |  			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { | 
| @@ -568,8 +765,12 @@ discard block | ||
| 568 | 765 | $data['format_source'] = 'aisnmeatxt'; | 
| 569 | 766 | $data['id_source'] = $id_source; | 
| 570 | 767 | //print_r($data); | 
| 571 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 572 | - if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); | |
| 768 | +		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { | |
| 769 | + $data['noarchive'] = true; | |
| 770 | + } | |
| 771 | +		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') { | |
| 772 | + $MI->add($data); | |
| 773 | + } | |
| 573 | 774 | unset($data); | 
| 574 | 775 | } | 
| 575 | 776 | } | 
| @@ -592,20 +793,48 @@ discard block | ||
| 592 | 793 |  			    if ($line != '') { | 
| 593 | 794 | $ais_data = $AIS->parse_line(trim($line)); | 
| 594 | 795 | $data = array(); | 
| 595 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; | |
| 596 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); | |
| 597 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; | |
| 598 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; | |
| 599 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; | |
| 600 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; | |
| 601 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; | |
| 602 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; | |
| 603 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; | |
| 604 | - if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid']; | |
| 605 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; | |
| 606 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; | |
| 607 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; | |
| 608 | -				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); | |
| 796 | +				if (isset($ais_data['ident'])) { | |
| 797 | + $data['ident'] = $ais_data['ident']; | |
| 798 | + } | |
| 799 | +				if (isset($ais_data['mmsi'])) { | |
| 800 | + $data['mmsi'] = substr($ais_data['mmsi'],-9); | |
| 801 | + } | |
| 802 | +				if (isset($ais_data['speed'])) { | |
| 803 | + $data['speed'] = $ais_data['speed']; | |
| 804 | + } | |
| 805 | +				if (isset($ais_data['heading'])) { | |
| 806 | + $data['heading'] = $ais_data['heading']; | |
| 807 | + } | |
| 808 | +				if (isset($ais_data['latitude'])) { | |
| 809 | + $data['latitude'] = $ais_data['latitude']; | |
| 810 | + } | |
| 811 | +				if (isset($ais_data['longitude'])) { | |
| 812 | + $data['longitude'] = $ais_data['longitude']; | |
| 813 | + } | |
| 814 | +				if (isset($ais_data['status'])) { | |
| 815 | + $data['status'] = $ais_data['status']; | |
| 816 | + } | |
| 817 | +				if (isset($ais_data['statusid'])) { | |
| 818 | + $data['status_id'] = $ais_data['statusid']; | |
| 819 | + } | |
| 820 | +				if (isset($ais_data['type'])) { | |
| 821 | + $data['type'] = $ais_data['type']; | |
| 822 | + } | |
| 823 | +				if (isset($ais_data['typeid'])) { | |
| 824 | + $data['type_id'] = $ais_data['typeid']; | |
| 825 | + } | |
| 826 | +				if (isset($ais_data['imo'])) { | |
| 827 | + $data['imo'] = $ais_data['imo']; | |
| 828 | + } | |
| 829 | +				if (isset($ais_data['callsign'])) { | |
| 830 | + $data['callsign'] = $ais_data['callsign']; | |
| 831 | + } | |
| 832 | +				if (isset($ais_data['destination'])) { | |
| 833 | + $data['arrival_code'] = $ais_data['destination']; | |
| 834 | + } | |
| 835 | +				if (isset($ais_data['eta_ts'])) { | |
| 836 | +					$data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); | |
| 837 | + } | |
| 609 | 838 |  				if (isset($ais_data['timestamp'])) { | 
| 610 | 839 |  				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); | 
| 611 | 840 |  				} else { | 
| @@ -613,18 +842,27 @@ discard block | ||
| 613 | 842 | } | 
| 614 | 843 | $data['format_source'] = 'aisnmeahttp'; | 
| 615 | 844 | $data['id_source'] = $id_source; | 
| 616 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 617 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); | |
| 845 | +				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { | |
| 846 | + $data['noarchive'] = true; | |
| 847 | + } | |
| 848 | +				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') { | |
| 849 | + $MI->add($data); | |
| 850 | + } | |
| 618 | 851 | unset($data); | 
| 619 | 852 | } | 
| 620 | 853 | } | 
| 621 | 854 | } | 
| 622 | 855 |  		} else { | 
| 623 | 856 | $format = $value['format']; | 
| 624 | - if (isset($tt[$format])) $tt[$format]++; | |
| 625 | - else $tt[$format] = 0; | |
| 857 | +		    if (isset($tt[$format])) { | |
| 858 | + $tt[$format]++; | |
| 859 | +		    } else { | |
| 860 | + $tt[$format] = 0; | |
| 861 | + } | |
| 626 | 862 |  		    if ($tt[$format] > 30) { | 
| 627 | - if ($globalDebug) echo 'Reconnect...'."\n"; | |
| 863 | +			if ($globalDebug) { | |
| 864 | + echo 'Reconnect...'."\n"; | |
| 865 | + } | |
| 628 | 866 | sleep(2); | 
| 629 | 867 | //$sourceeen[] = $value; | 
| 630 | 868 | //connect_all($sourceeen); | 
| @@ -660,12 +898,18 @@ discard block | ||
| 660 | 898 | // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; | 
| 661 | 899 | //$data['type_id'] = $line['TYPE']; | 
| 662 | 900 | $data['imo'] = $line['IMO']; | 
| 663 | - if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST']; | |
| 664 | -			    if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV'])); | |
| 901 | +			    if ($line['DEST'] != '') { | |
| 902 | + $data['arrival_code'] = $line['DEST']; | |
| 903 | + } | |
| 904 | +			    if ($line['ARV'] != '') { | |
| 905 | +			    	$data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV'])); | |
| 906 | + } | |
| 665 | 907 |  			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']); | 
| 666 | 908 | $data['format_source'] = 'myshiptracking'; | 
| 667 | 909 | $data['id_source'] = $id_source; | 
| 668 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 910 | +			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { | |
| 911 | + $data['noarchive'] = true; | |
| 912 | + } | |
| 669 | 913 | $MI->add($data); | 
| 670 | 914 | unset($data); | 
| 671 | 915 | } | 
| @@ -690,7 +934,9 @@ discard block | ||
| 690 | 934 | $data['callsign'] = $line['callsign']; | 
| 691 | 935 | $data['mmsi'] = substr($line['mmsi'],-9); | 
| 692 | 936 | $data['speed'] = $line['sog']; | 
| 693 | - if ($line['heading'] != '511') $data['heading'] = $line['heading']; | |
| 937 | +			    if ($line['heading'] != '511') { | |
| 938 | + $data['heading'] = $line['heading']; | |
| 939 | + } | |
| 694 | 940 | $data['latitude'] = $line['latitude']; | 
| 695 | 941 | $data['longitude'] = $line['longitude']; | 
| 696 | 942 | $data['type_id'] = $line['shiptype']; | 
| @@ -698,7 +944,9 @@ discard block | ||
| 698 | 944 | $data['datetime'] = $line['time']; | 
| 699 | 945 | $data['format_source'] = 'boatbeaconapp'; | 
| 700 | 946 | $data['id_source'] = $id_source; | 
| 701 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 947 | +			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { | |
| 948 | + $data['noarchive'] = true; | |
| 949 | + } | |
| 702 | 950 | $MI->add($data); | 
| 703 | 951 | unset($data); | 
| 704 | 952 | } | 
| @@ -720,22 +968,44 @@ discard block | ||
| 720 | 968 |  		    foreach ($all_data['features'] as $line) { | 
| 721 | 969 | print_r($line); | 
| 722 | 970 | $data = array(); | 
| 723 | - if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name']; | |
| 724 | - if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign']; | |
| 725 | - if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'],-9); | |
| 726 | - if (isset($line['properties']['imo'])) $data['imo'] = $line['properties']['imo']; | |
| 727 | - if (isset($line['properties']['speed'])) $data['speed'] = $line['properties']['speed']; | |
| 728 | - if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) $data['heading'] = $line['properties']['heading']; | |
| 971 | +			if (isset($line['properties']['name'])) { | |
| 972 | + $data['ident'] = $line['properties']['name']; | |
| 973 | + } | |
| 974 | +			if (isset($line['properties']['callsign'])) { | |
| 975 | + $data['callsign'] = $line['properties']['callsign']; | |
| 976 | + } | |
| 977 | +			if (isset($line['properties']['mmsi'])) { | |
| 978 | + $data['mmsi'] = substr($line['properties']['mmsi'],-9); | |
| 979 | + } | |
| 980 | +			if (isset($line['properties']['imo'])) { | |
| 981 | + $data['imo'] = $line['properties']['imo']; | |
| 982 | + } | |
| 983 | +			if (isset($line['properties']['speed'])) { | |
| 984 | + $data['speed'] = $line['properties']['speed']; | |
| 985 | + } | |
| 986 | +			if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) { | |
| 987 | + $data['heading'] = $line['properties']['heading']; | |
| 988 | + } | |
| 729 | 989 | $data['latitude'] = $line['geometry']['coordinates'][1]; | 
| 730 | 990 | $data['longitude'] = $line['geometry']['coordinates'][0]; | 
| 731 | - if (isset($line['properties']['vesselType'])) $data['type'] = $line['properties']['vesselType']; | |
| 732 | - if (isset($line['properties']['destination'])) $data['arrival_code'] = $line['properties']['destination']; | |
| 733 | - if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') $data['arrival_date'] = $line['properties']['eta']; | |
| 991 | +			if (isset($line['properties']['vesselType'])) { | |
| 992 | + $data['type'] = $line['properties']['vesselType']; | |
| 993 | + } | |
| 994 | +			if (isset($line['properties']['destination'])) { | |
| 995 | + $data['arrival_code'] = $line['properties']['destination']; | |
| 996 | + } | |
| 997 | +			if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') { | |
| 998 | + $data['arrival_date'] = $line['properties']['eta']; | |
| 999 | + } | |
| 734 | 1000 | $data['format_source'] = 'boatnerd'; | 
| 735 | 1001 | $data['id_source'] = $id_source; | 
| 736 | 1002 |  			$data['datetime'] = date('Y-m-d H:i:s'); | 
| 737 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 738 | - if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data); | |
| 1003 | +			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { | |
| 1004 | + $data['noarchive'] = true; | |
| 1005 | + } | |
| 1006 | +			if ($line['properties']['vesselType'] != 'Navigation Aid') { | |
| 1007 | + $MI->add($data); | |
| 1008 | + } | |
| 739 | 1009 | unset($data); | 
| 740 | 1010 | } | 
| 741 | 1011 | } | 
| @@ -748,11 +1018,17 @@ discard block | ||
| 748 | 1018 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) | 
| 749 | 1019 | ) | 
| 750 | 1020 |  	) { | 
| 751 | - if ($globalDebug) echo 'download...'; | |
| 1021 | +	    if ($globalDebug) { | |
| 1022 | + echo 'download...'; | |
| 1023 | + } | |
| 752 | 1024 | $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); | 
| 753 | - if ($globalDebug) echo 'done !'."\n"; | |
| 1025 | +	    if ($globalDebug) { | |
| 1026 | + echo 'done !'."\n"; | |
| 1027 | + } | |
| 754 | 1028 | // FIXME: Need more work | 
| 755 | - if ($buffer != '') $reset = 0; | |
| 1029 | +	    if ($buffer != '') { | |
| 1030 | + $reset = 0; | |
| 1031 | + } | |
| 756 | 1032 |      	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); | 
| 757 | 1033 |  	    $buffer = explode('\n',$buffer); | 
| 758 | 1034 |  	    foreach ($buffer as $line) { | 
| @@ -778,7 +1054,9 @@ discard block | ||
| 778 | 1054 | //$data['etaTime'] = substr($line,135,5); | 
| 779 | 1055 | $data['format_source'] = 'shipplotter'; | 
| 780 | 1056 | $data['id_source'] = $id_source; | 
| 781 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 1057 | +		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { | |
| 1058 | + $data['noarchive'] = true; | |
| 1059 | + } | |
| 782 | 1060 | //print_r($data); | 
| 783 | 1061 | //echo 'Add...'."\n"; | 
| 784 | 1062 | $MI->add($data); | 
| @@ -796,13 +1074,21 @@ discard block | ||
| 796 | 1074 | exit(0); | 
| 797 | 1075 | } | 
| 798 | 1076 |  	    $sailawayoption = array('key' => $globalSailaway['key']); | 
| 799 | -	    if (isset($globalSailaway['usrnr'])) $sailawayoption = array_merge($sailawayoption,array('usrnr' => $globalSailaway['usrnr'])); | |
| 800 | -	    if (isset($globalSailaway['ubtnr'])) $sailawayoption = array_merge($sailawayoption,array('ubtnr' => $globalSailaway['ubtnr'])); | |
| 1077 | +	    if (isset($globalSailaway['usrnr'])) { | |
| 1078 | +	    	$sailawayoption = array_merge($sailawayoption,array('usrnr' => $globalSailaway['usrnr'])); | |
| 1079 | + } | |
| 1080 | +	    if (isset($globalSailaway['ubtnr'])) { | |
| 1081 | +	    	$sailawayoption = array_merge($sailawayoption,array('ubtnr' => $globalSailaway['ubtnr'])); | |
| 1082 | + } | |
| 801 | 1083 | |
| 802 | 1084 |  	    for ($i = 0; $i <= 1; $i++) { | 
| 803 | - if ($globalDebug) echo '! Download... '; | |
| 1085 | +		if ($globalDebug) { | |
| 1086 | + echo '! Download... '; | |
| 1087 | + } | |
| 804 | 1088 |  		$buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/GetMissions.pl?'.http_build_query($sailawayoption).'&race='.$i.'&tutorial=0&hist=1&racetype=2&challengetype=2','get','','','','',30); | 
| 805 | - if ($globalDebug) echo 'done'."\n"; | |
| 1089 | +		if ($globalDebug) { | |
| 1090 | + echo 'done'."\n"; | |
| 1091 | + } | |
| 806 | 1092 |  		if ($buffer != '') { | 
| 807 | 1093 | $all_data = json_decode($buffer,true); | 
| 808 | 1094 |  		    if (isset($all_data['missions'])) { | 
| @@ -817,8 +1103,11 @@ discard block | ||
| 817 | 1103 |  					//$datar['creator'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($mission['usrname']))); | 
| 818 | 1104 | $datar['creator'] = ''; | 
| 819 | 1105 |  					$datar['name'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($mission['mistitle']))); | 
| 820 | - if (isset($mission['misstart'])) $datar['startdate'] = $mission['misstart']; | |
| 821 | - else $datar['startdate'] = '01/01/1970'; | |
| 1106 | +					if (isset($mission['misstart'])) { | |
| 1107 | + $datar['startdate'] = $mission['misstart']; | |
| 1108 | +					} else { | |
| 1109 | + $datar['startdate'] = '01/01/1970'; | |
| 1110 | + } | |
| 822 | 1111 | /* | 
| 823 | 1112 | $markers = array(); | 
| 824 | 1113 |  					foreach ($race_data['mission']['course'] as $course) { | 
| @@ -834,7 +1123,9 @@ discard block | ||
| 834 | 1123 | } | 
| 835 | 1124 | } | 
| 836 | 1125 | } | 
| 837 | - if ($globalDebug) echo '=== Wait... ==='; | |
| 1126 | +		if ($globalDebug) { | |
| 1127 | + echo '=== Wait... ==='; | |
| 1128 | + } | |
| 838 | 1129 | sleep(10*60); | 
| 839 | 1130 | } | 
| 840 | 1131 |  	    $buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/TrackAllBoats.pl?'.http_build_query($sailawayoption),'get','','','','',30); | 
| @@ -846,7 +1137,9 @@ discard block | ||
| 846 | 1137 | $data = array(); | 
| 847 | 1138 | $data['id'] = $sail['ubtnr']; | 
| 848 | 1139 |  			$data['datetime'] = date('Y-m-d H:i:s'); | 
| 849 | -			if ($sail['online'] == '1') $data['last_update'] = date('Y-m-d H:i:s'); | |
| 1140 | +			if ($sail['online'] == '1') { | |
| 1141 | +				$data['last_update'] = date('Y-m-d H:i:s'); | |
| 1142 | + } | |
| 850 | 1143 | $data['latitude'] = $sail['ubtlat']; | 
| 851 | 1144 | $data['longitude'] = $sail['ubtlon']; | 
| 852 | 1145 | $data['type_id'] = 36; | 
| @@ -855,16 +1148,24 @@ discard block | ||
| 855 | 1148 | $data['captain_name'] = $sail['usrname']; | 
| 856 | 1149 |  			$allboats = array('Sailaway Cruiser 38','Mini Transat','Caribbean Rose','52' Cruising Cat','50' Performance Cruiser','Nordic Folkboat'); | 
| 857 | 1150 | $boattype = $sail['ubtbtpnr']; | 
| 858 | - if (isset($allboats[$boattype-1])) $data['type'] = $allboats[$boattype-1]; | |
| 1151 | +			if (isset($allboats[$boattype-1])) { | |
| 1152 | + $data['type'] = $allboats[$boattype-1]; | |
| 1153 | + } | |
| 859 | 1154 | $data['speed'] = round($sail['ubtspeed']*3.6,2); | 
| 860 | 1155 | $data['format_source'] = 'sailaway'; | 
| 861 | 1156 | $data['id_source'] = $id_source; | 
| 862 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 1157 | +			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { | |
| 1158 | + $data['noarchive'] = true; | |
| 1159 | + } | |
| 863 | 1160 | $MI->add($data); | 
| 864 | 1161 | unset($data); | 
| 865 | 1162 | } | 
| 866 | - } elseif ($globalDebug) echo 'Error in JSON parsing'; | |
| 867 | - } elseif ($globalDebug) echo 'Empty result !'."\n"; | |
| 1163 | +		} elseif ($globalDebug) { | |
| 1164 | + echo 'Error in JSON parsing'; | |
| 1165 | + } | |
| 1166 | +	    } elseif ($globalDebug) { | |
| 1167 | + echo 'Empty result !'."\n"; | |
| 1168 | + } | |
| 868 | 1169 | |
| 869 | 1170 | $last_exec[$id]['last'] = time(); | 
| 870 | 1171 | } elseif ($value['format'] === 'sailaway' && | 
| @@ -887,10 +1188,16 @@ discard block | ||
| 887 | 1188 | echo 'Sailaway API key MUST be defined'; | 
| 888 | 1189 | exit(0); | 
| 889 | 1190 | } | 
| 890 | - if ($globalDebug) echo '! Download... '; | |
| 1191 | +	    if ($globalDebug) { | |
| 1192 | + echo '! Download... '; | |
| 1193 | + } | |
| 891 | 1194 |  	    $sailawayoption = array('key' => $globalSailaway['key']); | 
| 892 | -	    if (isset($globalSailaway['usrnr'])) $sailawayoption = array_merge($sailawayoption,array('usrnr' => $globalSailaway['usrnr'])); | |
| 893 | -	    if (isset($globalSailaway['ubtnr'])) $sailawayoption = array_merge($sailawayoption,array('ubtnr' => $globalSailaway['ubtnr'])); | |
| 1195 | +	    if (isset($globalSailaway['usrnr'])) { | |
| 1196 | +	    	$sailawayoption = array_merge($sailawayoption,array('usrnr' => $globalSailaway['usrnr'])); | |
| 1197 | + } | |
| 1198 | +	    if (isset($globalSailaway['ubtnr'])) { | |
| 1199 | +	    	$sailawayoption = array_merge($sailawayoption,array('ubtnr' => $globalSailaway['ubtnr'])); | |
| 1200 | + } | |
| 894 | 1201 |  	    $buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/TrackAllBoats.pl?'.http_build_query($sailawayoption),'get','','','','',30); | 
| 895 | 1202 |  	    if ($buffer != '') { | 
| 896 | 1203 | $data = json_decode($buffer,true); | 
| @@ -900,7 +1207,9 @@ discard block | ||
| 900 | 1207 | $data = array(); | 
| 901 | 1208 | $data['id'] = $sail['ubtnr']; | 
| 902 | 1209 |  			$data['datetime'] = date('Y-m-d H:i:s'); | 
| 903 | -			if ($sail['online'] == '1') $data['last_update'] = date('Y-m-d H:i:s'); | |
| 1210 | +			if ($sail['online'] == '1') { | |
| 1211 | +				$data['last_update'] = date('Y-m-d H:i:s'); | |
| 1212 | + } | |
| 904 | 1213 | $data['latitude'] = $sail['ubtlat']; | 
| 905 | 1214 | $data['longitude'] = $sail['ubtlon']; | 
| 906 | 1215 | $data['type_id'] = 36; | 
| @@ -909,16 +1218,24 @@ discard block | ||
| 909 | 1218 | $data['captain_name'] = $sail['usrname']; | 
| 910 | 1219 |  			$allboats = array('Sailaway Cruiser 38','Mini Transat','Caribbean Rose','52' Cruising Cat','50' Performance Cruiser','Nordic Folkboat'); | 
| 911 | 1220 | $boattype = $sail['ubtbtpnr']; | 
| 912 | - if (isset($allboats[$boattype-1])) $data['type'] = $allboats[$boattype-1]; | |
| 1221 | +			if (isset($allboats[$boattype-1])) { | |
| 1222 | + $data['type'] = $allboats[$boattype-1]; | |
| 1223 | + } | |
| 913 | 1224 | $data['speed'] = round($sail['ubtspeed']*3.6,2); | 
| 914 | 1225 | $data['format_source'] = 'sailaway'; | 
| 915 | 1226 | $data['id_source'] = $id_source; | 
| 916 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 1227 | +			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { | |
| 1228 | + $data['noarchive'] = true; | |
| 1229 | + } | |
| 917 | 1230 | $MI->add($data); | 
| 918 | 1231 | unset($data); | 
| 919 | 1232 | } | 
| 920 | - } elseif ($globalDebug) echo 'Error in JSON parsing'; | |
| 921 | - } elseif ($globalDebug) echo 'Empty result !'."\n"; | |
| 1233 | +		} elseif ($globalDebug) { | |
| 1234 | + echo 'Error in JSON parsing'; | |
| 1235 | + } | |
| 1236 | +	    } elseif ($globalDebug) { | |
| 1237 | + echo 'Empty result !'."\n"; | |
| 1238 | + } | |
| 922 | 1239 | $last_exec[$id]['last'] = time(); | 
| 923 | 1240 |  	//} elseif (($value === 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value === 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) { | 
| 924 | 1241 | } elseif ( | 
| @@ -946,16 +1263,28 @@ discard block | ||
| 946 | 1263 |      		    $line = explode(':', $line); | 
| 947 | 1264 |      		    if (count($line) > 30 && $line[0] != 'callsign') { | 
| 948 | 1265 | $data = array(); | 
| 949 | - if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; | |
| 950 | - else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; | |
| 1266 | +			if (isset($line[37]) && $line[37] != '') { | |
| 1267 | + $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; | |
| 1268 | +			} else { | |
| 1269 | + $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; | |
| 1270 | + } | |
| 951 | 1271 | $data['pilot_id'] = $line[1]; | 
| 952 | 1272 | $data['pilot_name'] = $line[2]; | 
| 953 | 1273 | $data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT); | 
| 954 | 1274 | $data['ident'] = $line[0]; // ident | 
| 955 | - if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude | |
| 1275 | +			if ($line[7] != '' && $line[7] != 0) { | |
| 1276 | + $data['altitude'] = $line[7]; | |
| 1277 | + } | |
| 1278 | + // altitude | |
| 956 | 1279 | $data['speed'] = $line[8]; // speed | 
| 957 | - if (isset($line[45])) $data['heading'] = $line[45]; // heading | |
| 958 | - elseif (isset($line[38])) $data['heading'] = $line[38]; // heading | |
| 1280 | +			if (isset($line[45])) { | |
| 1281 | + $data['heading'] = $line[45]; | |
| 1282 | + } | |
| 1283 | + // heading | |
| 1284 | +			elseif (isset($line[38])) { | |
| 1285 | + $data['heading'] = $line[38]; | |
| 1286 | + } | |
| 1287 | + // heading | |
| 959 | 1288 | $data['latitude'] = $line[5]; // lat | 
| 960 | 1289 | $data['longitude'] = $line[6]; // long | 
| 961 | 1290 | $data['verticalrate'] = ''; // vertical rate | 
| @@ -971,7 +1300,9 @@ discard block | ||
| 971 | 1300 | $data['frequency'] = $line[4]; | 
| 972 | 1301 | $data['type'] = $line[18]; | 
| 973 | 1302 | $data['range'] = $line[19]; | 
| 974 | - if (isset($line[35])) $data['info'] = $line[35]; | |
| 1303 | +			if (isset($line[35])) { | |
| 1304 | + $data['info'] = $line[35]; | |
| 1305 | + } | |
| 975 | 1306 | $data['id_source'] = $id_source; | 
| 976 | 1307 | //$data['arrival_airport_time'] = ; | 
| 977 | 1308 |  	    		if ($line[9] != '') { | 
| @@ -985,27 +1316,47 @@ discard block | ||
| 985 | 1316 | elseif ($value === 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; | 
| 986 | 1317 | */ | 
| 987 | 1318 | $data['format_source'] = $value['format']; | 
| 988 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 989 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; | |
| 990 | - if ($line[3] === 'PILOT') $SI->add($data); | |
| 991 | -			elseif ($line[3] === 'ATC') { | |
| 1319 | +			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { | |
| 1320 | + $data['noarchive'] = true; | |
| 1321 | + } | |
| 1322 | +			if (isset($value['name']) && $value['name'] != '') { | |
| 1323 | + $data['source_name'] = $value['name']; | |
| 1324 | + } | |
| 1325 | +    			if ($line[3] === 'PILOT') { | |
| 1326 | + $SI->add($data); | |
| 1327 | +    			} elseif ($line[3] === 'ATC') { | |
| 992 | 1328 | //print_r($data); | 
| 993 | 1329 |  				$data['info'] = str_replace('^§','<br />',$data['info']); | 
| 994 | 1330 |  				$data['info'] = str_replace('&sect;','',$data['info']); | 
| 995 | 1331 | $typec = substr($data['ident'],-3); | 
| 996 | - if ($typec === 'APP') $data['type'] = 'Approach'; | |
| 997 | - elseif ($typec === 'TWR') $data['type'] = 'Tower'; | |
| 998 | - elseif ($typec === 'OBS') $data['type'] = 'Observer'; | |
| 999 | - elseif ($typec === 'GND') $data['type'] = 'Ground'; | |
| 1000 | - elseif ($typec === 'DEL') $data['type'] = 'Delivery'; | |
| 1001 | - elseif ($typec === 'DEP') $data['type'] = 'Departure'; | |
| 1002 | - elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station'; | |
| 1003 | - elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre'; | |
| 1004 | - elseif ($data['type'] === '') $data['type'] = 'Observer'; | |
| 1005 | - if (!isset($data['source_name'])) $data['source_name'] = ''; | |
| 1332 | +				if ($typec === 'APP') { | |
| 1333 | + $data['type'] = 'Approach'; | |
| 1334 | +				} elseif ($typec === 'TWR') { | |
| 1335 | + $data['type'] = 'Tower'; | |
| 1336 | +				} elseif ($typec === 'OBS') { | |
| 1337 | + $data['type'] = 'Observer'; | |
| 1338 | +				} elseif ($typec === 'GND') { | |
| 1339 | + $data['type'] = 'Ground'; | |
| 1340 | +				} elseif ($typec === 'DEL') { | |
| 1341 | + $data['type'] = 'Delivery'; | |
| 1342 | +				} elseif ($typec === 'DEP') { | |
| 1343 | + $data['type'] = 'Departure'; | |
| 1344 | +				} elseif ($typec === 'FSS') { | |
| 1345 | + $data['type'] = 'Flight Service Station'; | |
| 1346 | +				} elseif ($typec === 'CTR') { | |
| 1347 | + $data['type'] = 'Control Radar or Centre'; | |
| 1348 | +				} elseif ($data['type'] === '') { | |
| 1349 | + $data['type'] = 'Observer'; | |
| 1350 | + } | |
| 1351 | +				if (!isset($data['source_name'])) { | |
| 1352 | + $data['source_name'] = ''; | |
| 1353 | + } | |
| 1006 | 1354 |  				if (isset($ATC)) { | 
| 1007 | - 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']); | |
| 1008 | - 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']); | |
| 1355 | +					if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) { | |
| 1356 | + 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']); | |
| 1357 | +					} else { | |
| 1358 | + 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']); | |
| 1359 | + } | |
| 1009 | 1360 | } | 
| 1010 | 1361 | } | 
| 1011 | 1362 | unset($data); | 
| @@ -1032,14 +1383,20 @@ discard block | ||
| 1032 | 1383 |  			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST')); | 
| 1033 | 1384 | $data['latitude'] = (float)$line['pktLatitude']; | 
| 1034 | 1385 | $data['longitude'] = (float)$line['pktLongitude']; | 
| 1035 | - if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack']; | |
| 1036 | - if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed']; | |
| 1386 | +			if ((float)$line['pktTrack'] != 0) { | |
| 1387 | + $data['heading'] = (float)$line['pktTrack']; | |
| 1388 | + } | |
| 1389 | +			if ((int)$line['pktSpeed'] != 0) { | |
| 1390 | + $data['speed'] = (int)$line['pktSpeed']; | |
| 1391 | + } | |
| 1037 | 1392 | $data['altitude'] = round((int)$line['pktAltitude']*3.28084); | 
| 1038 | 1393 | $data['altitude_relative'] = 'AMSL'; | 
| 1039 | 1394 | $data['pilot_id'] = (int)$line['pktPilotID']; | 
| 1040 | 1395 | $data['aircraft_icao'] = 'PARAGLIDER'; | 
| 1041 | 1396 |  			$pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id'])); | 
| 1042 | - if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4]; | |
| 1397 | +			if (isset($pilot_data[4])) { | |
| 1398 | + $data['pilot_name'] = $pilot_data[4]; | |
| 1399 | + } | |
| 1043 | 1400 | $data['format_source'] = $value['format']; | 
| 1044 | 1401 | $SI->add($data); | 
| 1045 | 1402 | unset($data); | 
| @@ -1087,25 +1444,59 @@ discard block | ||
| 1087 | 1444 |  		    foreach ($all_data['acList'] as $line) { | 
| 1088 | 1445 | $data = array(); | 
| 1089 | 1446 | $data['hex'] = $line['Icao']; // hex | 
| 1090 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident | |
| 1091 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude | |
| 1092 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed | |
| 1093 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading | |
| 1094 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat | |
| 1095 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long | |
| 1447 | +			if (isset($line['Call'])) { | |
| 1448 | + $data['ident'] = $line['Call']; | |
| 1449 | + } | |
| 1450 | + // ident | |
| 1451 | +			if (isset($line['Alt'])) { | |
| 1452 | + $data['altitude'] = $line['Alt']; | |
| 1453 | + } | |
| 1454 | + // altitude | |
| 1455 | +			if (isset($line['Spd'])) { | |
| 1456 | + $data['speed'] = $line['Spd']; | |
| 1457 | + } | |
| 1458 | + // speed | |
| 1459 | +			if (isset($line['Trak'])) { | |
| 1460 | + $data['heading'] = $line['Trak']; | |
| 1461 | + } | |
| 1462 | + // heading | |
| 1463 | +			if (isset($line['Lat'])) { | |
| 1464 | + $data['latitude'] = $line['Lat']; | |
| 1465 | + } | |
| 1466 | + // lat | |
| 1467 | +			if (isset($line['Long'])) { | |
| 1468 | + $data['longitude'] = $line['Long']; | |
| 1469 | + } | |
| 1470 | + // long | |
| 1096 | 1471 | //$data['verticalrate'] = $line['']; // verticale rate | 
| 1097 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk | |
| 1472 | +			if (isset($line['Sqk'])) { | |
| 1473 | + $data['squawk'] = $line['Sqk']; | |
| 1474 | + } | |
| 1475 | + // squawk | |
| 1098 | 1476 | $data['emergency'] = ''; // emergency | 
| 1099 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; | |
| 1100 | -			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); | |
| 1101 | -			else $data['datetime'] = date('Y-m-d H:i:s'); | |
| 1477 | +			if (isset($line['Reg'])) { | |
| 1478 | + $data['registration'] = $line['Reg']; | |
| 1479 | + } | |
| 1480 | +			if (isset($line['PosTime'])) { | |
| 1481 | +				$data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); | |
| 1482 | +			} else { | |
| 1483 | +				$data['datetime'] = date('Y-m-d H:i:s'); | |
| 1484 | + } | |
| 1102 | 1485 |  			//$data['datetime'] = date('Y-m-d H:i:s'); | 
| 1103 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; | |
| 1486 | +			if (isset($line['Type'])) { | |
| 1487 | + $data['aircraft_icao'] = $line['Type']; | |
| 1488 | + } | |
| 1104 | 1489 | $data['format_source'] = 'aircraftlistjson'; | 
| 1105 | 1490 | $data['id_source'] = $id_source; | 
| 1106 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; | |
| 1107 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 1108 | - if (isset($data['latitude'])) $SI->add($data); | |
| 1491 | +			if (isset($value['name']) && $value['name'] != '') { | |
| 1492 | + $data['source_name'] = $value['name']; | |
| 1493 | + } | |
| 1494 | +			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { | |
| 1495 | + $data['noarchive'] = true; | |
| 1496 | + } | |
| 1497 | +			if (isset($data['latitude'])) { | |
| 1498 | + $SI->add($data); | |
| 1499 | + } | |
| 1109 | 1500 | unset($data); | 
| 1110 | 1501 | } | 
| 1111 | 1502 |  		} elseif (is_array($all_data)) { | 
| @@ -1122,17 +1513,26 @@ discard block | ||
| 1122 | 1513 | $data['verticalrate'] = $line['vrt']; // verticale rate | 
| 1123 | 1514 | $data['squawk'] = $line['squawk']; // squawk | 
| 1124 | 1515 | $data['emergency'] = ''; // emergency | 
| 1125 | -			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); | |
| 1126 | -			else $data['datetime'] = date('Y-m-d H:i:s'); | |
| 1516 | +			if (isset($line['PosTime'])) { | |
| 1517 | +				$data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); | |
| 1518 | +			} else { | |
| 1519 | +				$data['datetime'] = date('Y-m-d H:i:s'); | |
| 1520 | + } | |
| 1127 | 1521 | $data['format_source'] = 'aircraftlistjson'; | 
| 1128 | 1522 | $data['id_source'] = $id_source; | 
| 1129 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 1130 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; | |
| 1523 | +			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { | |
| 1524 | + $data['noarchive'] = true; | |
| 1525 | + } | |
| 1526 | +			if (isset($value['name']) && $value['name'] != '') { | |
| 1527 | + $data['source_name'] = $value['name']; | |
| 1528 | + } | |
| 1131 | 1529 | $SI->add($data); | 
| 1132 | 1530 | unset($data); | 
| 1133 | 1531 | } | 
| 1134 | 1532 | } | 
| 1135 | - } elseif ($globalDebug) echo 'No data'."\n"; | |
| 1533 | +	    } elseif ($globalDebug) { | |
| 1534 | + echo 'No data'."\n"; | |
| 1535 | + } | |
| 1136 | 1536 | //$last_exec['aircraftlistjson'] = time(); | 
| 1137 | 1537 | $last_exec[$id]['last'] = time(); | 
| 1138 | 1538 |      	//} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { | 
| @@ -1168,8 +1568,12 @@ discard block | ||
| 1168 | 1568 |  		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]); | 
| 1169 | 1569 | $data['format_source'] = 'planeupdatefaa'; | 
| 1170 | 1570 | $data['id_source'] = $id_source; | 
| 1171 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 1172 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; | |
| 1571 | +		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { | |
| 1572 | + $data['noarchive'] = true; | |
| 1573 | + } | |
| 1574 | +		    if (isset($value['name']) && $value['name'] != '') { | |
| 1575 | + $data['source_name'] = $value['name']; | |
| 1576 | + } | |
| 1173 | 1577 | $SI->add($data); | 
| 1174 | 1578 | unset($data); | 
| 1175 | 1579 | } | 
| @@ -1203,7 +1607,9 @@ discard block | ||
| 1203 | 1607 |  		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]); | 
| 1204 | 1608 | $data['format_source'] = 'opensky'; | 
| 1205 | 1609 | $data['id_source'] = $id_source; | 
| 1206 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 1610 | +		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { | |
| 1611 | + $data['noarchive'] = true; | |
| 1612 | + } | |
| 1207 | 1613 | $SI->add($data); | 
| 1208 | 1614 | unset($data); | 
| 1209 | 1615 | } | 
| @@ -1223,15 +1629,42 @@ discard block | ||
| 1223 | 1629 |  		foreach ($all_data['aircraft'] as $key => $line) { | 
| 1224 | 1630 | $data = array(); | 
| 1225 | 1631 | // add support for ground vehicule with ~ in front of hex | 
| 1226 | - if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex | |
| 1227 | - if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident | |
| 1228 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude | |
| 1229 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed | |
| 1230 | - if (isset($line['track'])) $data['heading'] = $line['track']; // heading | |
| 1231 | - if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat | |
| 1232 | - if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long | |
| 1233 | - if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate | |
| 1234 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk | |
| 1632 | +		    if (isset($line['hex'])) { | |
| 1633 | + $data['hex'] = $line['hex']; | |
| 1634 | + } | |
| 1635 | + // hex | |
| 1636 | +		    if (isset($line['flight'])) { | |
| 1637 | + $data['ident'] = trim($line['flight']); | |
| 1638 | + } | |
| 1639 | + // ident | |
| 1640 | +		    if (isset($line['altitude'])) { | |
| 1641 | + $data['altitude'] = $line['altitude']; | |
| 1642 | + } | |
| 1643 | + // altitude | |
| 1644 | +		    if (isset($line['speed'])) { | |
| 1645 | + $data['speed'] = $line['speed']; | |
| 1646 | + } | |
| 1647 | + // speed | |
| 1648 | +		    if (isset($line['track'])) { | |
| 1649 | + $data['heading'] = $line['track']; | |
| 1650 | + } | |
| 1651 | + // heading | |
| 1652 | +		    if (isset($line['lat'])) { | |
| 1653 | + $data['latitude'] = $line['lat']; | |
| 1654 | + } | |
| 1655 | + // lat | |
| 1656 | +		    if (isset($line['lon'])) { | |
| 1657 | + $data['longitude'] = $line['lon']; | |
| 1658 | + } | |
| 1659 | + // long | |
| 1660 | +		    if (isset($line['vert_rate'])) { | |
| 1661 | + $data['verticalrate'] = $line['vert_rate']; | |
| 1662 | + } | |
| 1663 | + // verticale rate | |
| 1664 | +		    if (isset($line['squawk'])) { | |
| 1665 | + $data['squawk'] = $line['squawk']; | |
| 1666 | + } | |
| 1667 | + // squawk | |
| 1235 | 1668 | //$data['emergency'] = ''; // emergency | 
| 1236 | 1669 | //$data['registration'] = $line[2]; | 
| 1237 | 1670 | //$data['aircraft_icao'] = $line[0]; | 
| @@ -1239,10 +1672,17 @@ discard block | ||
| 1239 | 1672 | $data['format_source'] = 'aircraftjson'; | 
| 1240 | 1673 | $data['id_source'] = $id_source; | 
| 1241 | 1674 |  		    if (isset($value['name']) && $value['name'] != '') { | 
| 1242 | - if (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = $value['name'].'_MLAT'; | |
| 1243 | - else $data['source_name'] = $value['name']; | |
| 1244 | - } elseif (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = 'MLAT'; | |
| 1245 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 1675 | +			    if (isset($line['mlat']) && !empty($line['mlat'])) { | |
| 1676 | + $data['source_name'] = $value['name'].'_MLAT'; | |
| 1677 | +			    } else { | |
| 1678 | + $data['source_name'] = $value['name']; | |
| 1679 | + } | |
| 1680 | +		    } elseif (isset($line['mlat']) && !empty($line['mlat'])) { | |
| 1681 | + $data['source_name'] = 'MLAT'; | |
| 1682 | + } | |
| 1683 | +		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { | |
| 1684 | + $data['noarchive'] = true; | |
| 1685 | + } | |
| 1246 | 1686 | $SI->add($data); | 
| 1247 | 1687 | unset($data); | 
| 1248 | 1688 | } | 
| @@ -1262,22 +1702,54 @@ discard block | ||
| 1262 | 1702 |  		foreach ($all_data['aircraft'] as $key => $line) { | 
| 1263 | 1703 | $data = array(); | 
| 1264 | 1704 | $data['hex'] = $key; // hex | 
| 1265 | - if (isset($line['callsign'])) $data['ident'] = trim($line['callsign']); // ident | |
| 1266 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude | |
| 1267 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed | |
| 1268 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading | |
| 1269 | - if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat | |
| 1270 | - if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long | |
| 1271 | - if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate | |
| 1272 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk | |
| 1705 | +		    if (isset($line['callsign'])) { | |
| 1706 | + $data['ident'] = trim($line['callsign']); | |
| 1707 | + } | |
| 1708 | + // ident | |
| 1709 | +		    if (isset($line['altitude'])) { | |
| 1710 | + $data['altitude'] = $line['altitude']; | |
| 1711 | + } | |
| 1712 | + // altitude | |
| 1713 | +		    if (isset($line['speed'])) { | |
| 1714 | + $data['speed'] = $line['speed']; | |
| 1715 | + } | |
| 1716 | + // speed | |
| 1717 | +		    if (isset($line['heading'])) { | |
| 1718 | + $data['heading'] = $line['heading']; | |
| 1719 | + } | |
| 1720 | + // heading | |
| 1721 | +		    if (isset($line['lat'])) { | |
| 1722 | + $data['latitude'] = $line['lat']; | |
| 1723 | + } | |
| 1724 | + // lat | |
| 1725 | +		    if (isset($line['lon'])) { | |
| 1726 | + $data['longitude'] = $line['lon']; | |
| 1727 | + } | |
| 1728 | + // long | |
| 1729 | +		    if (isset($line['vert_rate'])) { | |
| 1730 | + $data['verticalrate'] = $line['vert_rate']; | |
| 1731 | + } | |
| 1732 | + // verticale rate | |
| 1733 | +		    if (isset($line['squawk'])) { | |
| 1734 | + $data['squawk'] = $line['squawk']; | |
| 1735 | + } | |
| 1736 | + // squawk | |
| 1273 | 1737 | //$data['emergency'] = ''; // emergency | 
| 1274 | - if (isset($line['reg'])) $data['registration'] = $line['reg']; | |
| 1275 | - if (isset($line['type'])) $data['aircraft_icao'] = $line['type']; | |
| 1738 | +		    if (isset($line['reg'])) { | |
| 1739 | + $data['registration'] = $line['reg']; | |
| 1740 | + } | |
| 1741 | +		    if (isset($line['type'])) { | |
| 1742 | + $data['aircraft_icao'] = $line['type']; | |
| 1743 | + } | |
| 1276 | 1744 |  		    $data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']); | 
| 1277 | 1745 | $data['format_source'] = 'planefinderclient'; | 
| 1278 | 1746 | $data['id_source'] = $id_source; | 
| 1279 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; | |
| 1280 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 1747 | +		    if (isset($value['name']) && $value['name'] != '') { | |
| 1748 | + $data['source_name'] = $value['name']; | |
| 1749 | + } | |
| 1750 | +		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { | |
| 1751 | + $data['noarchive'] = true; | |
| 1752 | + } | |
| 1281 | 1753 | $SI->add($data); | 
| 1282 | 1754 | unset($data); | 
| 1283 | 1755 | } | 
| @@ -1293,7 +1765,9 @@ discard block | ||
| 1293 | 1765 | //$buffer = $Common->getData($hosts[$id]); | 
| 1294 | 1766 | $buffer = $Common->getData($value['host']); | 
| 1295 | 1767 | $all_data = json_decode($buffer,true); | 
| 1296 | - if (!empty($all_data)) $reset = 0; | |
| 1768 | +	    if (!empty($all_data)) { | |
| 1769 | + $reset = 0; | |
| 1770 | + } | |
| 1297 | 1771 |  	    foreach ($all_data as $key => $line) { | 
| 1298 | 1772 |  		if ($key != 'full_count' && $key != 'version' && $key != 'stats') { | 
| 1299 | 1773 | $data = array(); | 
| @@ -1314,8 +1788,12 @@ discard block | ||
| 1314 | 1788 |  		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] | 
| 1315 | 1789 | $data['format_source'] = 'fr24json'; | 
| 1316 | 1790 | $data['id_source'] = $id_source; | 
| 1317 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 1318 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; | |
| 1791 | +		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { | |
| 1792 | + $data['noarchive'] = true; | |
| 1793 | + } | |
| 1794 | +		    if (isset($value['name']) && $value['name'] != '') { | |
| 1795 | + $data['source_name'] = $value['name']; | |
| 1796 | + } | |
| 1319 | 1797 | $SI->add($data); | 
| 1320 | 1798 | unset($data); | 
| 1321 | 1799 | } | 
| @@ -1344,24 +1822,42 @@ discard block | ||
| 1344 | 1822 |  		    if (isset($line['inf'])) { | 
| 1345 | 1823 | $data = array(); | 
| 1346 | 1824 | $data['hex'] = $line['inf']['ia']; | 
| 1347 | - if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] | |
| 1825 | +			if (isset($line['inf']['cs'])) { | |
| 1826 | + $data['ident'] = $line['inf']['cs']; | |
| 1827 | + } | |
| 1828 | + //$line[13] | |
| 1348 | 1829 | $data['altitude'] = round($line['inf']['al']*3.28084); // altitude | 
| 1349 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed | |
| 1350 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading | |
| 1830 | +	    		if (isset($line['inf']['gs'])) { | |
| 1831 | + $data['speed'] = round($line['inf']['gs']*0.539957); | |
| 1832 | + } | |
| 1833 | + // speed | |
| 1834 | +	    		if (isset($line['inf']['tr'])) { | |
| 1835 | + $data['heading'] = $line['inf']['tr']; | |
| 1836 | + } | |
| 1837 | + // heading | |
| 1351 | 1838 | $data['latitude'] = $line['pt'][0]; // lat | 
| 1352 | 1839 | $data['longitude'] = $line['pt'][1]; // long | 
| 1353 | 1840 | //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate | 
| 1354 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk | |
| 1841 | +	    		if (isset($line['inf']['sq'])) { | |
| 1842 | + $data['squawk'] = $line['inf']['sq']; | |
| 1843 | + } | |
| 1844 | + // squawk | |
| 1355 | 1845 | //$data['aircraft_icao'] = $line[8]; | 
| 1356 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; | |
| 1846 | +	    		if (isset($line['inf']['rc'])) { | |
| 1847 | + $data['registration'] = $line['inf']['rc']; | |
| 1848 | + } | |
| 1357 | 1849 | //$data['departure_airport_iata'] = $line[11]; | 
| 1358 | 1850 | //$data['arrival_airport_iata'] = $line[12]; | 
| 1359 | 1851 | //$data['emergency'] = ''; // emergency | 
| 1360 | 1852 |  			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] | 
| 1361 | 1853 | $data['format_source'] = 'radarvirtueljson'; | 
| 1362 | 1854 | $data['id_source'] = $id_source; | 
| 1363 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 1364 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; | |
| 1855 | +			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { | |
| 1856 | + $data['noarchive'] = true; | |
| 1857 | + } | |
| 1858 | +			if (isset($value['name']) && $value['name'] != '') { | |
| 1859 | + $data['source_name'] = $value['name']; | |
| 1860 | + } | |
| 1365 | 1861 | $SI->add($data); | 
| 1366 | 1862 | unset($data); | 
| 1367 | 1863 | } | 
| @@ -1387,30 +1883,65 @@ discard block | ||
| 1387 | 1883 | $data['id'] = $line['id']; | 
| 1388 | 1884 | $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); | 
| 1389 | 1885 | $data['ident'] = $line['callsign']; // ident | 
| 1390 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id | |
| 1391 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name | |
| 1392 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude | |
| 1393 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed | |
| 1394 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading | |
| 1395 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route | |
| 1886 | +		    if (isset($line['pilotid'])) { | |
| 1887 | + $data['pilot_id'] = $line['pilotid']; | |
| 1888 | + } | |
| 1889 | + // pilot id | |
| 1890 | +		    if (isset($line['name'])) { | |
| 1891 | + $data['pilot_name'] = $line['name']; | |
| 1892 | + } | |
| 1893 | + // pilot name | |
| 1894 | +		    if (isset($line['alt'])) { | |
| 1895 | + $data['altitude'] = $line['alt']; | |
| 1896 | + } | |
| 1897 | + // altitude | |
| 1898 | +		    if (isset($line['gs'])) { | |
| 1899 | + $data['speed'] = $line['gs']; | |
| 1900 | + } | |
| 1901 | + // speed | |
| 1902 | +		    if (isset($line['heading'])) { | |
| 1903 | + $data['heading'] = $line['heading']; | |
| 1904 | + } | |
| 1905 | + // heading | |
| 1906 | +		    if (isset($line['route'])) { | |
| 1907 | + $data['waypoints'] = $line['route']; | |
| 1908 | + } | |
| 1909 | + // route | |
| 1396 | 1910 | $data['latitude'] = $line['lat']; // lat | 
| 1397 | 1911 | $data['longitude'] = $line['lon']; // long | 
| 1398 | 1912 | //$data['verticalrate'] = $line['vrt']; // verticale rate | 
| 1399 | 1913 | //$data['squawk'] = $line['squawk']; // squawk | 
| 1400 | 1914 | //$data['emergency'] = ''; // emergency | 
| 1401 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; | |
| 1402 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; | |
| 1403 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; | |
| 1915 | +		    if (isset($line['depicao'])) { | |
| 1916 | + $data['departure_airport_icao'] = $line['depicao']; | |
| 1917 | + } | |
| 1918 | +		    if (isset($line['deptime'])) { | |
| 1919 | + $data['departure_airport_time'] = $line['deptime']; | |
| 1920 | + } | |
| 1921 | +		    if (isset($line['arricao'])) { | |
| 1922 | + $data['arrival_airport_icao'] = $line['arricao']; | |
| 1923 | + } | |
| 1404 | 1924 | //$data['arrival_airport_time'] = $line['arrtime']; | 
| 1405 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; | |
| 1406 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; | |
| 1407 | - if (isset($line['atis'])) $data['info'] = $line['atis']; | |
| 1408 | - else $data['info'] = ''; | |
| 1925 | +		    if (isset($line['aircraft'])) { | |
| 1926 | + $data['aircraft_icao'] = $line['aircraft']; | |
| 1927 | + } | |
| 1928 | +		    if (isset($line['transponder'])) { | |
| 1929 | + $data['squawk'] = $line['transponder']; | |
| 1930 | + } | |
| 1931 | +		    if (isset($line['atis'])) { | |
| 1932 | + $data['info'] = $line['atis']; | |
| 1933 | +		    } else { | |
| 1934 | + $data['info'] = ''; | |
| 1935 | + } | |
| 1409 | 1936 | $data['format_source'] = 'pireps'; | 
| 1410 | 1937 | $data['id_source'] = $id_source; | 
| 1411 | 1938 |  		    $data['datetime'] = date('Y-m-d H:i:s'); | 
| 1412 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 1413 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; | |
| 1939 | +		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { | |
| 1940 | + $data['noarchive'] = true; | |
| 1941 | + } | |
| 1942 | +		    if (isset($value['name']) && $value['name'] != '') { | |
| 1943 | + $data['source_name'] = $value['name']; | |
| 1944 | + } | |
| 1414 | 1945 |  		    if ($line['icon'] === 'plane') { | 
| 1415 | 1946 | $SI->add($data); | 
| 1416 | 1947 | // print_r($data); | 
| @@ -1419,16 +1950,28 @@ discard block | ||
| 1419 | 1950 |  			$data['info'] = str_replace('&sect;','',$data['info']); | 
| 1420 | 1951 | $typec = substr($data['ident'],-3); | 
| 1421 | 1952 | $data['type'] = ''; | 
| 1422 | - if ($typec === 'APP') $data['type'] = 'Approach'; | |
| 1423 | - elseif ($typec === 'TWR') $data['type'] = 'Tower'; | |
| 1424 | - elseif ($typec === 'OBS') $data['type'] = 'Observer'; | |
| 1425 | - elseif ($typec === 'GND') $data['type'] = 'Ground'; | |
| 1426 | - elseif ($typec === 'DEL') $data['type'] = 'Delivery'; | |
| 1427 | - elseif ($typec === 'DEP') $data['type'] = 'Departure'; | |
| 1428 | - elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station'; | |
| 1429 | - elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre'; | |
| 1430 | - else $data['type'] = 'Observer'; | |
| 1431 | - 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']); | |
| 1953 | +			if ($typec === 'APP') { | |
| 1954 | + $data['type'] = 'Approach'; | |
| 1955 | +			} elseif ($typec === 'TWR') { | |
| 1956 | + $data['type'] = 'Tower'; | |
| 1957 | +			} elseif ($typec === 'OBS') { | |
| 1958 | + $data['type'] = 'Observer'; | |
| 1959 | +			} elseif ($typec === 'GND') { | |
| 1960 | + $data['type'] = 'Ground'; | |
| 1961 | +			} elseif ($typec === 'DEL') { | |
| 1962 | + $data['type'] = 'Delivery'; | |
| 1963 | +			} elseif ($typec === 'DEP') { | |
| 1964 | + $data['type'] = 'Departure'; | |
| 1965 | +			} elseif ($typec === 'FSS') { | |
| 1966 | + $data['type'] = 'Flight Service Station'; | |
| 1967 | +			} elseif ($typec === 'CTR') { | |
| 1968 | + $data['type'] = 'Control Radar or Centre'; | |
| 1969 | +			} else { | |
| 1970 | + $data['type'] = 'Observer'; | |
| 1971 | + } | |
| 1972 | +			if (isset($ATC)) { | |
| 1973 | + 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']); | |
| 1974 | + } | |
| 1432 | 1975 | } | 
| 1433 | 1976 | unset($data); | 
| 1434 | 1977 | } | 
| @@ -1443,7 +1986,9 @@ discard block | ||
| 1443 | 1986 | ) | 
| 1444 | 1987 |  	) { | 
| 1445 | 1988 | //$buffer = $Common->getData($hosts[$id]); | 
| 1446 | - if ($globalDebug) echo 'Get Data...'."\n"; | |
| 1989 | +	    if ($globalDebug) { | |
| 1990 | + echo 'Get Data...'."\n"; | |
| 1991 | + } | |
| 1447 | 1992 | $buffer = $Common->getData($value['host']); | 
| 1448 | 1993 | $all_data = json_decode($buffer,true); | 
| 1449 | 1994 |  	    if ($buffer != '' && is_array($all_data)) { | 
| @@ -1451,10 +1996,16 @@ discard block | ||
| 1451 | 1996 |  		foreach ($all_data as $line) { | 
| 1452 | 1997 | $data = array(); | 
| 1453 | 1998 | //$data['id'] = $line['id']; // id not usable | 
| 1454 | - if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; | |
| 1999 | +	    	    if (isset($line['pilotid'])) { | |
| 2000 | + $data['id'] = $line['pilotid'].$line['flightnum']; | |
| 2001 | + } | |
| 1455 | 2002 | $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex | 
| 1456 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; | |
| 1457 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; | |
| 2003 | +	    	    if (isset($line['pilotname'])) { | |
| 2004 | + $data['pilot_name'] = $line['pilotname']; | |
| 2005 | + } | |
| 2006 | +	    	    if (isset($line['pilotid'])) { | |
| 2007 | + $data['pilot_id'] = $line['pilotid']; | |
| 2008 | + } | |
| 1458 | 2009 | $data['ident'] = $line['flightnum']; // ident | 
| 1459 | 2010 | $data['altitude'] = $line['alt']; // altitude | 
| 1460 | 2011 | $data['speed'] = $line['gs']; // speed | 
| @@ -1470,7 +2021,9 @@ discard block | ||
| 1470 | 2021 | $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); | 
| 1471 | 2022 |  	    		$datetime->setTimeZone(new DateTimeZone('UTC')); | 
| 1472 | 2023 |  	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s'); | 
| 1473 | -	    	    } else $data['datetime'] = date('Y-m-d H:i:s'); | |
| 2024 | +	    	    } else { | |
| 2025 | +	    	    	$data['datetime'] = date('Y-m-d H:i:s'); | |
| 2026 | + } | |
| 1474 | 2027 | $data['departure_airport_icao'] = $line['depicao']; | 
| 1475 | 2028 | $data['departure_airport_time'] = $line['deptime']; | 
| 1476 | 2029 | $data['arrival_airport_icao'] = $line['arricao']; | 
| @@ -1478,29 +2031,47 @@ discard block | ||
| 1478 | 2031 |      		    if (isset($line['registration'])) { | 
| 1479 | 2032 | $data['registration'] = $line['registration']; | 
| 1480 | 2033 | //if (isset($line['aircraft'])) $data['id'] = $line['aircraft']; | 
| 1481 | - } else $data['registration'] = $line['aircraft']; | |
| 1482 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 1483 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route | |
| 2034 | +    		    } else { | |
| 2035 | + $data['registration'] = $line['aircraft']; | |
| 2036 | + } | |
| 2037 | +		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { | |
| 2038 | + $data['noarchive'] = true; | |
| 2039 | + } | |
| 2040 | +		    if (isset($line['route'])) { | |
| 2041 | + $data['waypoints'] = $line['route']; | |
| 2042 | + } | |
| 2043 | + // route | |
| 1484 | 2044 |  		    if (isset($line['aircraftname'])) { | 
| 1485 | 2045 | $line['aircraftname'] = strtoupper($line['aircraftname']); | 
| 1486 | 2046 |  			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); | 
| 1487 | 2047 |  	    		$aircraft_data = explode('-',$line['aircraftname']); | 
| 1488 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; | |
| 1489 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; | |
| 1490 | -	    		else { | |
| 2048 | +	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) { | |
| 2049 | + $data['aircraft_icao'] = $aircraft_data[0]; | |
| 2050 | +	    		} elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) { | |
| 2051 | + $data['aircraft_icao'] = $aircraft_data[1]; | |
| 2052 | +	    		} else { | |
| 1491 | 2053 |  	    		    $aircraft_data = explode(' ',$line['aircraftname']); | 
| 1492 | -	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); | |
| 1493 | -	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); | |
| 2054 | +	    		    if (isset($aircraft_data[1])) { | |
| 2055 | +	    		    	$data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); | |
| 2056 | +	    		    } else { | |
| 2057 | +	    		    	$data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); | |
| 2058 | + } | |
| 1494 | 2059 | } | 
| 1495 | 2060 | } | 
| 1496 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; | |
| 2061 | +    		    if (isset($line['route'])) { | |
| 2062 | + $data['waypoints'] = $line['route']; | |
| 2063 | + } | |
| 1497 | 2064 | $data['id_source'] = $id_source; | 
| 1498 | 2065 | $data['format_source'] = 'phpvmacars'; | 
| 1499 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; | |
| 2066 | +		    if (isset($value['name']) && $value['name'] != '') { | |
| 2067 | + $data['source_name'] = $value['name']; | |
| 2068 | + } | |
| 1500 | 2069 | $SI->add($data); | 
| 1501 | 2070 | unset($data); | 
| 1502 | 2071 | } | 
| 1503 | - if ($globalDebug) echo 'No more data...'."\n"; | |
| 2072 | +		if ($globalDebug) { | |
| 2073 | + echo 'No more data...'."\n"; | |
| 2074 | + } | |
| 1504 | 2075 | unset($buffer); | 
| 1505 | 2076 | unset($all_data); | 
| 1506 | 2077 | } | 
| @@ -1513,7 +2084,9 @@ discard block | ||
| 1513 | 2084 | ) | 
| 1514 | 2085 |  	) { | 
| 1515 | 2086 | //$buffer = $Common->getData($hosts[$id]); | 
| 1516 | - if ($globalDebug) echo 'Get Data...'."\n"; | |
| 2087 | +	    if ($globalDebug) { | |
| 2088 | + echo 'Get Data...'."\n"; | |
| 2089 | + } | |
| 1517 | 2090 | $buffer = $Common->getData($value['host']); | 
| 1518 | 2091 | $all_data = json_decode($buffer,true); | 
| 1519 | 2092 |  	    if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) { | 
| @@ -1524,10 +2097,16 @@ discard block | ||
| 1524 | 2097 | //$data['id'] = $line['id']; // id not usable | 
| 1525 | 2098 | $data['id'] = $line['id']; | 
| 1526 | 2099 | //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex | 
| 1527 | - if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username']; | |
| 1528 | - if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id']; | |
| 2100 | +	    	    if (isset($line['user']['username'])) { | |
| 2101 | + $data['pilot_name'] = $line['user']['username']; | |
| 2102 | + } | |
| 2103 | +	    	    if (isset($line['user_id'])) { | |
| 2104 | + $data['pilot_id'] = $line['user_id']; | |
| 2105 | + } | |
| 1529 | 2106 |  	    	    $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident | 
| 1530 | - if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident']; | |
| 2107 | +	    	    if (is_numeric($data['ident'])) { | |
| 2108 | + $data['ident'] = $line['bid']['airline']['icao'].$data['ident']; | |
| 2109 | + } | |
| 1531 | 2110 | $data['altitude'] = $line['altitude']; // altitude | 
| 1532 | 2111 | $data['speed'] = $line['groundspeed']; // speed | 
| 1533 | 2112 | $data['heading'] = $line['heading']; // heading | 
| @@ -1540,7 +2119,9 @@ discard block | ||
| 1540 | 2119 | $datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone'])); | 
| 1541 | 2120 |  	    		$datetime->setTimeZone(new DateTimeZone('UTC')); | 
| 1542 | 2121 |  	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s'); | 
| 1543 | -	    	    } else $data['datetime'] = date('Y-m-d H:i:s'); | |
| 2122 | +	    	    } else { | |
| 2123 | +	    	    	$data['datetime'] = date('Y-m-d H:i:s'); | |
| 2124 | + } | |
| 1544 | 2125 | |
| 1545 | 2126 | $data['departure_airport_icao'] = $line['bid']['depapt']['icao']; | 
| 1546 | 2127 | $data['departure_airport_time'] = $line['bid']['deptime']; | 
| @@ -1548,17 +2129,26 @@ discard block | ||
| 1548 | 2129 | $data['arrival_airport_time'] = $line['bid']['arrtime']; | 
| 1549 | 2130 | $data['registration'] = $line['bid']['aircraft']['registration']; | 
| 1550 | 2131 | |
| 1551 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 1552 | - if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route | |
| 2132 | +		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { | |
| 2133 | + $data['noarchive'] = true; | |
| 2134 | + } | |
| 2135 | +		    if (isset($line['bid']['route']) && $line['bid']['route'] != '') { | |
| 2136 | + $data['waypoints'] = $line['bid']['route']; | |
| 2137 | + } | |
| 2138 | + // route | |
| 1553 | 2139 | $data['aircraft_icao'] = $line['bid']['aircraft']['icao']; | 
| 1554 | 2140 | |
| 1555 | 2141 | $data['id_source'] = $id_source; | 
| 1556 | 2142 | $data['format_source'] = 'vaos'; | 
| 1557 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; | |
| 2143 | +		    if (isset($value['name']) && $value['name'] != '') { | |
| 2144 | + $data['source_name'] = $value['name']; | |
| 2145 | + } | |
| 1558 | 2146 | $SI->add($data); | 
| 1559 | 2147 | unset($data); | 
| 1560 | 2148 | } | 
| 1561 | - if ($globalDebug) echo 'No more data...'."\n"; | |
| 2149 | +		if ($globalDebug) { | |
| 2150 | + echo 'No more data...'."\n"; | |
| 2151 | + } | |
| 1562 | 2152 | unset($buffer); | 
| 1563 | 2153 | unset($all_data); | 
| 1564 | 2154 | } | 
| @@ -1571,7 +2161,9 @@ discard block | ||
| 1571 | 2161 | ) | 
| 1572 | 2162 |  	) { | 
| 1573 | 2163 | //$buffer = $Common->getData($hosts[$id]); | 
| 1574 | - if ($globalDebug) echo 'Get Data...'."\n"; | |
| 2164 | +	    if ($globalDebug) { | |
| 2165 | + echo 'Get Data...'."\n"; | |
| 2166 | + } | |
| 1575 | 2167 | $buffer = $Common->getData($value['host']); | 
| 1576 | 2168 | $all_data = json_decode($buffer,true); | 
| 1577 | 2169 |  	    if ($buffer != '' && is_array($all_data)) { | 
| @@ -1600,16 +2192,25 @@ discard block | ||
| 1600 | 2192 | $data['arrival_airport_icao'] = $line['arrival']; | 
| 1601 | 2193 | //$data['arrival_airport_time'] = $line['arrival_time']; | 
| 1602 | 2194 | //$data['registration'] = $line['aircraft']; | 
| 1603 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route | |
| 2195 | +		    if (isset($line['route'])) { | |
| 2196 | + $data['waypoints'] = $line['route']; | |
| 2197 | + } | |
| 2198 | + // route | |
| 1604 | 2199 | $data['aircraft_icao'] = $line['plane_type']; | 
| 1605 | 2200 | $data['id_source'] = $id_source; | 
| 1606 | 2201 | $data['format_source'] = 'vam'; | 
| 1607 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 1608 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; | |
| 2202 | +		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { | |
| 2203 | + $data['noarchive'] = true; | |
| 2204 | + } | |
| 2205 | +		    if (isset($value['name']) && $value['name'] != '') { | |
| 2206 | + $data['source_name'] = $value['name']; | |
| 2207 | + } | |
| 1609 | 2208 | $SI->add($data); | 
| 1610 | 2209 | unset($data); | 
| 1611 | 2210 | } | 
| 1612 | - if ($globalDebug) echo 'No more data...'."\n"; | |
| 2211 | +		if ($globalDebug) { | |
| 2212 | + echo 'No more data...'."\n"; | |
| 2213 | + } | |
| 1613 | 2214 | unset($buffer); | 
| 1614 | 2215 | unset($all_data); | 
| 1615 | 2216 | } | 
| @@ -1622,7 +2223,9 @@ discard block | ||
| 1622 | 2223 | ) | 
| 1623 | 2224 |  	) { | 
| 1624 | 2225 | //$buffer = $Common->getData($hosts[$id]); | 
| 1625 | - if ($globalDebug) echo 'Get Data...'."\n"; | |
| 2226 | +	    if ($globalDebug) { | |
| 2227 | + echo 'Get Data...'."\n"; | |
| 2228 | + } | |
| 1626 | 2229 | $buffer = $Common->getData($value['host']); | 
| 1627 | 2230 | $all_data = json_decode($buffer,true); | 
| 1628 | 2231 |  	    if ($buffer != '') { | 
| @@ -1640,12 +2243,16 @@ discard block | ||
| 1640 | 2243 | $data['id_source'] = $id_source; | 
| 1641 | 2244 | $data['format_source'] = 'blitzortung'; | 
| 1642 | 2245 | $SI->add($data); | 
| 1643 | - if ($globalDebug) echo '☈ Lightning added'."\n"; | |
| 2246 | +			if ($globalDebug) { | |
| 2247 | + echo '☈ Lightning added'."\n"; | |
| 2248 | + } | |
| 1644 | 2249 |  			$Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']); | 
| 1645 | 2250 | unset($data); | 
| 1646 | 2251 | } | 
| 1647 | 2252 | } | 
| 1648 | - if ($globalDebug) echo 'No more data...'."\n"; | |
| 2253 | +		if ($globalDebug) { | |
| 2254 | + echo 'No more data...'."\n"; | |
| 2255 | + } | |
| 1649 | 2256 | unset($buffer); | 
| 1650 | 2257 | } | 
| 1651 | 2258 | $last_exec[$id]['last'] = time(); | 
| @@ -1674,10 +2281,15 @@ discard block | ||
| 1674 | 2281 | } | 
| 1675 | 2282 |              } else { | 
| 1676 | 2283 | $format = $value['format']; | 
| 1677 | - if (isset($tt[$format])) $tt[$format]++; | |
| 1678 | - else $tt[$format] = 0; | |
| 2284 | +                if (isset($tt[$format])) { | |
| 2285 | + $tt[$format]++; | |
| 2286 | +                } else { | |
| 2287 | + $tt[$format] = 0; | |
| 2288 | + } | |
| 1679 | 2289 |                  if ($tt[$format] > 30) { | 
| 1680 | - if ($globalDebug) echo 'Reconnect...'."\n"; | |
| 2290 | +                    if ($globalDebug) { | |
| 2291 | + echo 'Reconnect...'."\n"; | |
| 2292 | + } | |
| 1681 | 2293 | sleep(2); | 
| 1682 | 2294 | //$sourceeen[] = $value; | 
| 1683 | 2295 | //connect_all($sourceeen); | 
| @@ -1694,7 +2306,9 @@ discard block | ||
| 1694 | 2306 | $write = NULL; | 
| 1695 | 2307 | $e = NULL; | 
| 1696 | 2308 | $n = socket_select($read, $write, $e, $timeout); | 
| 1697 | - if ($e != NULL) var_dump($e); | |
| 2309 | +	    if ($e != NULL) { | |
| 2310 | + var_dump($e); | |
| 2311 | + } | |
| 1698 | 2312 |  	    if ($n > 0) { | 
| 1699 | 2313 | $reset = 0; | 
| 1700 | 2314 |  		foreach ($read as $nb => $r) { | 
| @@ -1716,13 +2330,17 @@ discard block | ||
| 1716 | 2330 |  		    if ($buffer !== FALSE) { | 
| 1717 | 2331 |  			if ($format === 'vrstcp') { | 
| 1718 | 2332 |  			    $buffer = explode('},{',$buffer); | 
| 1719 | -			} else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); | |
| 2333 | +			} else { | |
| 2334 | +				$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); | |
| 2335 | + } | |
| 1720 | 2336 | } | 
| 1721 | 2337 | // SBS format is CSV format | 
| 1722 | 2338 |  		    if ($buffer !== FALSE && $buffer !== '') { | 
| 1723 | 2339 | $tt[$format] = 0; | 
| 1724 | 2340 |  			if ($format === 'acarssbs3') { | 
| 1725 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; | |
| 2341 | +			    if ($globalDebug) { | |
| 2342 | + echo 'ACARS : '.$buffer."\n"; | |
| 2343 | + } | |
| 1726 | 2344 | $ACARS->add(trim($buffer)); | 
| 1727 | 2345 | $ACARS->deleteLiveAcarsData(); | 
| 1728 | 2346 |  			} elseif ($format === 'raw') { | 
| @@ -1732,9 +2350,15 @@ discard block | ||
| 1732 | 2350 | //if (!empty($data)) print_r($data); | 
| 1733 | 2351 |  				$data['datetime'] = date('Y-m-d H:i:s'); | 
| 1734 | 2352 | $data['format_source'] = 'raw'; | 
| 1735 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; | |
| 1736 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; | |
| 1737 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 2353 | +				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { | |
| 2354 | + $data['source_name'] = $globalSources[$nb]['name']; | |
| 2355 | + } | |
| 2356 | +				if (isset($globalSources[$nb]['sourcestats'])) { | |
| 2357 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; | |
| 2358 | + } | |
| 2359 | +				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { | |
| 2360 | + $data['noarchive'] = true; | |
| 2361 | + } | |
| 1738 | 2362 | //if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); | 
| 1739 | 2363 | $SI->add($data); | 
| 1740 | 2364 | unset($data); | 
| @@ -1742,22 +2366,54 @@ discard block | ||
| 1742 | 2366 |  			} elseif ($format === 'ais') { | 
| 1743 | 2367 | $ais_data = $AIS->parse_line(trim($buffer)); | 
| 1744 | 2368 | $data = array(); | 
| 1745 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; | |
| 1746 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); | |
| 1747 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; | |
| 1748 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; | |
| 1749 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; | |
| 1750 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; | |
| 1751 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; | |
| 1752 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; | |
| 1753 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; | |
| 1754 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; | |
| 1755 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; | |
| 1756 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; | |
| 1757 | -			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); | |
| 1758 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 1759 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; | |
| 1760 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; | |
| 2369 | +			    if (isset($ais_data['ident'])) { | |
| 2370 | + $data['ident'] = $ais_data['ident']; | |
| 2371 | + } | |
| 2372 | +			    if (isset($ais_data['mmsi'])) { | |
| 2373 | + $data['mmsi'] = substr($ais_data['mmsi'],-9); | |
| 2374 | + } | |
| 2375 | +			    if (isset($ais_data['speed'])) { | |
| 2376 | + $data['speed'] = $ais_data['speed']; | |
| 2377 | + } | |
| 2378 | +			    if (isset($ais_data['heading'])) { | |
| 2379 | + $data['heading'] = $ais_data['heading']; | |
| 2380 | + } | |
| 2381 | +			    if (isset($ais_data['latitude'])) { | |
| 2382 | + $data['latitude'] = $ais_data['latitude']; | |
| 2383 | + } | |
| 2384 | +			    if (isset($ais_data['longitude'])) { | |
| 2385 | + $data['longitude'] = $ais_data['longitude']; | |
| 2386 | + } | |
| 2387 | +			    if (isset($ais_data['status'])) { | |
| 2388 | + $data['status'] = $ais_data['status']; | |
| 2389 | + } | |
| 2390 | +			    if (isset($ais_data['statusid'])) { | |
| 2391 | + $data['status_id'] = $ais_data['statusid']; | |
| 2392 | + } | |
| 2393 | +			    if (isset($ais_data['type'])) { | |
| 2394 | + $data['type'] = $ais_data['type']; | |
| 2395 | + } | |
| 2396 | +			    if (isset($ais_data['imo'])) { | |
| 2397 | + $data['imo'] = $ais_data['imo']; | |
| 2398 | + } | |
| 2399 | +			    if (isset($ais_data['callsign'])) { | |
| 2400 | + $data['callsign'] = $ais_data['callsign']; | |
| 2401 | + } | |
| 2402 | +			    if (isset($ais_data['destination'])) { | |
| 2403 | + $data['arrival_code'] = $ais_data['destination']; | |
| 2404 | + } | |
| 2405 | +			    if (isset($ais_data['eta_ts'])) { | |
| 2406 | +			    	$data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); | |
| 2407 | + } | |
| 2408 | +			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { | |
| 2409 | + $data['noarchive'] = true; | |
| 2410 | + } | |
| 2411 | +			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { | |
| 2412 | + $data['source_name'] = $globalSources[$nb]['name']; | |
| 2413 | + } | |
| 2414 | +			    if (isset($globalSources[$nb]['sourcestats'])) { | |
| 2415 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; | |
| 2416 | + } | |
| 1761 | 2417 | |
| 1762 | 2418 |  			    if (isset($ais_data['timestamp'])) { | 
| 1763 | 2419 |  				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); | 
| @@ -1766,7 +2422,9 @@ discard block | ||
| 1766 | 2422 | } | 
| 1767 | 2423 | $data['format_source'] = 'aisnmea'; | 
| 1768 | 2424 | $data['id_source'] = $id_source; | 
| 1769 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); | |
| 2425 | +			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') { | |
| 2426 | + $MI->add($data); | |
| 2427 | + } | |
| 1770 | 2428 | unset($data); | 
| 1771 | 2429 |                          } elseif ($format === 'flightgearsp') { | 
| 1772 | 2430 | //echo $buffer."\n"; | 
| @@ -1784,17 +2442,25 @@ discard block | ||
| 1784 | 2442 | $data['speed'] = round($line[5]*1.94384); | 
| 1785 | 2443 |  				$data['datetime'] = date('Y-m-d H:i:s'); | 
| 1786 | 2444 | $data['format_source'] = 'flightgearsp'; | 
| 1787 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 1788 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); | |
| 2445 | +				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { | |
| 2446 | + $data['noarchive'] = true; | |
| 2447 | + } | |
| 2448 | +				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { | |
| 2449 | + $SI->add($data); | |
| 2450 | + } | |
| 1789 | 2451 | //$send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); | 
| 1790 | 2452 | } | 
| 1791 | 2453 |                          } elseif ($format === 'acars') { | 
| 1792 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; | |
| 2454 | +                    	    if ($globalDebug) { | |
| 2455 | + echo 'ACARS : '.$buffer."\n"; | |
| 2456 | + } | |
| 1793 | 2457 | $ACARS->add(trim($buffer)); | 
| 1794 | 2458 | socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); | 
| 1795 | 2459 | $ACARS->deleteLiveAcarsData(); | 
| 1796 | 2460 |  			} elseif ($format === 'acarsjsonudp') { | 
| 1797 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; | |
| 2461 | +			    if ($globalDebug) { | |
| 2462 | + echo 'ACARS : '.$buffer."\n"; | |
| 2463 | + } | |
| 1798 | 2464 | $line = json_decode(trim($buffer), true); | 
| 1799 | 2465 |                              if (!empty($line)) { | 
| 1800 | 2466 |  				$line = array_merge(array('text' => '','tail' => '','label' => '','block_id' => '','flight' => '','msgno' => ''),$line); | 
| @@ -1819,8 +2485,12 @@ discard block | ||
| 1819 | 2485 | $aircraft_type = $line[10]; | 
| 1820 | 2486 |  				    $aircraft_type = preg_split(':/:',$aircraft_type); | 
| 1821 | 2487 | $data['aircraft_name'] = substr(end($aircraft_type),0,-4); | 
| 1822 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 1823 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); | |
| 2488 | +				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { | |
| 2489 | + $data['noarchive'] = true; | |
| 2490 | + } | |
| 2491 | +				    if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { | |
| 2492 | + $SI->add($data); | |
| 2493 | + } | |
| 1824 | 2494 | } | 
| 1825 | 2495 | } | 
| 1826 | 2496 |  			} elseif ($format === 'beast') { | 
| @@ -1830,28 +2500,62 @@ discard block | ||
| 1830 | 2500 |  			    foreach($buffer as $all_data) { | 
| 1831 | 2501 |  				$line = json_decode('{'.$all_data.'}',true); | 
| 1832 | 2502 | $data = array(); | 
| 1833 | - if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex | |
| 1834 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident | |
| 1835 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude | |
| 1836 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed | |
| 1837 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading | |
| 1838 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat | |
| 1839 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long | |
| 2503 | +				if (isset($line['Icao'])) { | |
| 2504 | + $data['hex'] = $line['Icao']; | |
| 2505 | + } | |
| 2506 | + // hex | |
| 2507 | +				if (isset($line['Call'])) { | |
| 2508 | + $data['ident'] = $line['Call']; | |
| 2509 | + } | |
| 2510 | + // ident | |
| 2511 | +				if (isset($line['Alt'])) { | |
| 2512 | + $data['altitude'] = $line['Alt']; | |
| 2513 | + } | |
| 2514 | + // altitude | |
| 2515 | +				if (isset($line['Spd'])) { | |
| 2516 | + $data['speed'] = $line['Spd']; | |
| 2517 | + } | |
| 2518 | + // speed | |
| 2519 | +				if (isset($line['Trak'])) { | |
| 2520 | + $data['heading'] = $line['Trak']; | |
| 2521 | + } | |
| 2522 | + // heading | |
| 2523 | +				if (isset($line['Lat'])) { | |
| 2524 | + $data['latitude'] = $line['Lat']; | |
| 2525 | + } | |
| 2526 | + // lat | |
| 2527 | +				if (isset($line['Long'])) { | |
| 2528 | + $data['longitude'] = $line['Long']; | |
| 2529 | + } | |
| 2530 | + // long | |
| 1840 | 2531 | //$data['verticalrate'] = $line['']; // verticale rate | 
| 1841 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk | |
| 2532 | +				if (isset($line['Sqk'])) { | |
| 2533 | + $data['squawk'] = $line['Sqk']; | |
| 2534 | + } | |
| 2535 | + // squawk | |
| 1842 | 2536 | $data['emergency'] = ''; // emergency | 
| 1843 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; | |
| 2537 | +				if (isset($line['Reg'])) { | |
| 2538 | + $data['registration'] = $line['Reg']; | |
| 2539 | + } | |
| 1844 | 2540 | /* | 
| 1845 | 2541 |  				if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000); | 
| 1846 | 2542 |  				else $data['datetime'] = date('Y-m-d H:i:s'); | 
| 1847 | 2543 | */ | 
| 1848 | 2544 |  				$data['datetime'] = date('Y-m-d H:i:s'); | 
| 1849 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; | |
| 2545 | +				if (isset($line['Type'])) { | |
| 2546 | + $data['aircraft_icao'] = $line['Type']; | |
| 2547 | + } | |
| 1850 | 2548 | $data['format_source'] = 'vrstcp'; | 
| 1851 | 2549 | $data['id_source'] = $id_source; | 
| 1852 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 1853 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; | |
| 1854 | - if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); | |
| 2550 | +				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { | |
| 2551 | + $data['noarchive'] = true; | |
| 2552 | + } | |
| 2553 | +				if (isset($value['name']) && $value['name'] != '') { | |
| 2554 | + $data['source_name'] = $value['name']; | |
| 2555 | + } | |
| 2556 | +				if (isset($data['latitude']) && isset($data['hex'])) { | |
| 2557 | + $SI->add($data); | |
| 2558 | + } | |
| 1855 | 2559 | unset($data); | 
| 1856 | 2560 | } | 
| 1857 | 2561 |  			} elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') { | 
| @@ -1864,22 +2568,46 @@ discard block | ||
| 1864 | 2568 | $data['hex'] = $lined['hexid']; | 
| 1865 | 2569 |      				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; | 
| 1866 | 2570 |      				$data['datetime'] = date('Y-m-d H:i:s');; | 
| 1867 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; | |
| 1868 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; | |
| 1869 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; | |
| 1870 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; | |
| 1871 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; | |
| 1872 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; | |
| 1873 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; | |
| 2571 | +    				if (isset($lined['ident'])) { | |
| 2572 | + $data['ident'] = $lined['ident']; | |
| 2573 | + } | |
| 2574 | +    				if (isset($lined['lat'])) { | |
| 2575 | + $data['latitude'] = $lined['lat']; | |
| 2576 | + } | |
| 2577 | +    				if (isset($lined['lon'])) { | |
| 2578 | + $data['longitude'] = $lined['lon']; | |
| 2579 | + } | |
| 2580 | +    				if (isset($lined['speed'])) { | |
| 2581 | + $data['speed'] = $lined['speed']; | |
| 2582 | + } | |
| 2583 | +    				if (isset($lined['squawk'])) { | |
| 2584 | + $data['squawk'] = $lined['squawk']; | |
| 2585 | + } | |
| 2586 | +    				if (isset($lined['alt'])) { | |
| 2587 | + $data['altitude'] = $lined['alt']; | |
| 2588 | + } | |
| 2589 | +    				if (isset($lined['heading'])) { | |
| 2590 | + $data['heading'] = $lined['heading']; | |
| 2591 | + } | |
| 1874 | 2592 | $data['id_source'] = $id_source; | 
| 1875 | 2593 | $data['format_source'] = 'tsv'; | 
| 1876 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; | |
| 1877 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; | |
| 1878 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 1879 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); | |
| 2594 | +    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { | |
| 2595 | + $data['source_name'] = $globalSources[$nb]['name']; | |
| 2596 | + } | |
| 2597 | +    				if (isset($globalSources[$nb]['sourcestats'])) { | |
| 2598 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; | |
| 2599 | + } | |
| 2600 | +				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { | |
| 2601 | + $data['noarchive'] = true; | |
| 2602 | + } | |
| 2603 | +    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { | |
| 2604 | + $SI->add($data); | |
| 2605 | + } | |
| 1880 | 2606 | unset($lined); | 
| 1881 | 2607 | unset($data); | 
| 1882 | - } else $error = true; | |
| 2608 | +    			    } else { | |
| 2609 | + $error = true; | |
| 2610 | + } | |
| 1883 | 2611 |  			} elseif ($format === 'aprs' && $use_aprs) { | 
| 1884 | 2612 |  			    if ($aprs_connect === 0) { | 
| 1885 | 2613 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); | 
| @@ -1905,47 +2633,96 @@ discard block | ||
| 1905 | 2633 | $aprs_last_tx = time(); | 
| 1906 | 2634 | $data = array(); | 
| 1907 | 2635 | //print_r($line); | 
| 1908 | - if (isset($line['address'])) $data['hex'] = $line['address']; | |
| 1909 | - if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; | |
| 1910 | - if (isset($line['imo'])) $data['imo'] = $line['imo']; | |
| 1911 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; | |
| 1912 | - if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code']; | |
| 1913 | - if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date']; | |
| 1914 | - if (isset($line['typeid'])) $data['type_id'] = $line['typeid']; | |
| 1915 | - if (isset($line['statusid'])) $data['status_id'] = $line['statusid']; | |
| 1916 | -				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); | |
| 1917 | -				    else $data['datetime'] = date('Y-m-d H:i:s'); | |
| 2636 | +				    if (isset($line['address'])) { | |
| 2637 | + $data['hex'] = $line['address']; | |
| 2638 | + } | |
| 2639 | +				    if (isset($line['mmsi'])) { | |
| 2640 | + $data['mmsi'] = $line['mmsi']; | |
| 2641 | + } | |
| 2642 | +				    if (isset($line['imo'])) { | |
| 2643 | + $data['imo'] = $line['imo']; | |
| 2644 | + } | |
| 2645 | +				    if (isset($line['squawk'])) { | |
| 2646 | + $data['squawk'] = $line['squawk']; | |
| 2647 | + } | |
| 2648 | +				    if (isset($line['arrival_code'])) { | |
| 2649 | + $data['arrival_code'] = $line['arrival_code']; | |
| 2650 | + } | |
| 2651 | +				    if (isset($line['arrival_date'])) { | |
| 2652 | + $data['arrival_date'] = $line['arrival_date']; | |
| 2653 | + } | |
| 2654 | +				    if (isset($line['typeid'])) { | |
| 2655 | + $data['type_id'] = $line['typeid']; | |
| 2656 | + } | |
| 2657 | +				    if (isset($line['statusid'])) { | |
| 2658 | + $data['status_id'] = $line['statusid']; | |
| 2659 | + } | |
| 2660 | +				    if (isset($line['timestamp'])) { | |
| 2661 | +				    	$data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); | |
| 2662 | +				    } else { | |
| 2663 | +				    	$data['datetime'] = date('Y-m-d H:i:s'); | |
| 2664 | + } | |
| 1918 | 2665 |  				    //$data['datetime'] = date('Y-m-d H:i:s'); | 
| 1919 | - if (isset($line['ident'])) $data['ident'] = $line['ident']; | |
| 2666 | +				    if (isset($line['ident'])) { | |
| 2667 | + $data['ident'] = $line['ident']; | |
| 2668 | + } | |
| 1920 | 2669 | $data['latitude'] = $line['latitude']; | 
| 1921 | 2670 | $data['longitude'] = $line['longitude']; | 
| 1922 | 2671 | //$data['verticalrate'] = $line[16]; | 
| 1923 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; | |
| 2672 | +				    if (isset($line['speed'])) { | |
| 2673 | + $data['speed'] = $line['speed']; | |
| 2674 | + } | |
| 1924 | 2675 | //else $data['speed'] = 0; | 
| 1925 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; | |
| 1926 | - if (isset($line['comment'])) $data['comment'] = $line['comment']; | |
| 1927 | - if (isset($line['symbol'])) $data['type'] = $line['symbol']; | |
| 2676 | +				    if (isset($line['altitude'])) { | |
| 2677 | + $data['altitude'] = $line['altitude']; | |
| 2678 | + } | |
| 2679 | +				    if (isset($line['comment'])) { | |
| 2680 | + $data['comment'] = $line['comment']; | |
| 2681 | + } | |
| 2682 | +				    if (isset($line['symbol'])) { | |
| 2683 | + $data['type'] = $line['symbol']; | |
| 2684 | + } | |
| 1928 | 2685 | //if (isset($line['heading'])) $data['heading'] = $line['heading']; | 
| 1929 | 2686 | |
| 1930 | - if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading']; | |
| 2687 | +				    if (isset($line['heading']) && isset($line['format_source'])) { | |
| 2688 | + $data['heading'] = $line['heading']; | |
| 2689 | + } | |
| 1931 | 2690 | //else echo 'No heading...'."\n"; | 
| 1932 | 2691 | //else $data['heading'] = 0; | 
| 1933 | - if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; | |
| 2692 | +				    if (isset($line['stealth'])) { | |
| 2693 | + $data['aircraft_type'] = $line['stealth']; | |
| 2694 | + } | |
| 1934 | 2695 | //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; | 
| 1935 | - if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true; | |
| 1936 | - elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false; | |
| 1937 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 1938 | - elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; | |
| 2696 | +				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) { | |
| 2697 | + $data['noarchive'] = true; | |
| 2698 | +				    } elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) { | |
| 2699 | + $data['noarchive'] = false; | |
| 2700 | + } | |
| 2701 | +				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { | |
| 2702 | + $data['noarchive'] = true; | |
| 2703 | +				    } elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) { | |
| 2704 | + $data['noarchive'] = false; | |
| 2705 | + } | |
| 1939 | 2706 | $data['id_source'] = $id_source; | 
| 1940 | - if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; | |
| 1941 | - else $data['format_source'] = 'aprs'; | |
| 2707 | +    				    if (isset($line['format_source'])) { | |
| 2708 | + $data['format_source'] = $line['format_source']; | |
| 2709 | +    				    } else { | |
| 2710 | + $data['format_source'] = 'aprs'; | |
| 2711 | + } | |
| 1942 | 2712 | $data['source_name'] = $line['source']; | 
| 1943 | - if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; | |
| 1944 | - else $data['source_type'] = 'flarm'; | |
| 1945 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; | |
| 2713 | +				    if (isset($line['source_type'])) { | |
| 2714 | + $data['source_type'] = $line['source_type']; | |
| 2715 | +				    } else { | |
| 2716 | + $data['source_type'] = 'flarm'; | |
| 2717 | + } | |
| 2718 | +    				    if (isset($globalSources[$nb]['sourcestats'])) { | |
| 2719 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; | |
| 2720 | + } | |
| 1946 | 2721 |  				    $currentdate = date('Y-m-d H:i:s'); | 
| 1947 | 2722 | $aprsdate = strtotime($data['datetime']); | 
| 1948 | - if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL'; | |
| 2723 | +				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') { | |
| 2724 | + $data['altitude_relative'] = 'AMSL'; | |
| 2725 | + } | |
| 1949 | 2726 | // Accept data if time <= system time + 20s | 
| 1950 | 2727 |  				    //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'])))) { | 
| 1951 | 2728 | if ( | 
| @@ -1957,7 +2734,9 @@ discard block | ||
| 1957 | 2734 | $send = $SI->add($data); | 
| 1958 | 2735 |  				    } elseif ($data['source_type'] === 'ais') { | 
| 1959 | 2736 | $data['type'] = ''; | 
| 1960 | - if (isset($globalMarine) && $globalMarine) $send = $MI->add($data); | |
| 2737 | +					if (isset($globalMarine) && $globalMarine) { | |
| 2738 | + $send = $MI->add($data); | |
| 2739 | + } | |
| 1961 | 2740 |  				    } elseif (isset($line['stealth']) && $line['stealth'] != 0) { | 
| 1962 | 2741 | echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; | 
| 1963 | 2742 | } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( | 
| @@ -1965,8 +2744,12 @@ discard block | ||
| 1965 | 2744 | $line['symbol'] === 'Glider' || | 
| 1966 | 2745 | $line['symbol'] === 'No. Plane' || | 
| 1967 | 2746 |  					    $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) { | 
| 1968 | - if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL'; | |
| 1969 | - if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER'; | |
| 2747 | +					    if ($line['symbol'] === 'Ballon') { | |
| 2748 | + $data['aircraft_icao'] = 'BALL'; | |
| 2749 | + } | |
| 2750 | +					    if ($line['symbol'] === 'Glider') { | |
| 2751 | + $data['aircraft_icao'] = 'PARAGLIDER'; | |
| 2752 | + } | |
| 1970 | 2753 | $send = $SI->add($data); | 
| 1971 | 2754 | } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( | 
| 1972 | 2755 | $line['symbol'] === 'Yacht (Sail)' || | 
| @@ -1997,9 +2780,13 @@ discard block | ||
| 1997 | 2780 |  				    //} 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') { | 
| 1998 | 2781 |  				//    } 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') { | 
| 1999 | 2782 | //echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n"; | 
| 2000 | - if (isset($globalTracker) && $globalTracker) $send = $TI->add($data); | |
| 2783 | +					if (isset($globalTracker) && $globalTracker) { | |
| 2784 | + $send = $TI->add($data); | |
| 2785 | + } | |
| 2001 | 2786 |  				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { | 
| 2002 | - if (!isset($data['altitude'])) $data['altitude'] = 0; | |
| 2787 | +					if (!isset($data['altitude'])) { | |
| 2788 | + $data['altitude'] = 0; | |
| 2789 | + } | |
| 2003 | 2790 |  					$Source->deleteOldLocationByType('gs'); | 
| 2004 | 2791 |  					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) { | 
| 2005 | 2792 | $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); | 
| @@ -2008,7 +2795,9 @@ discard block | ||
| 2008 | 2795 | } | 
| 2009 | 2796 |  				    } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') { | 
| 2010 | 2797 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; | 
| 2011 | - if ($globalDebug) echo '# Weather Station added'."\n"; | |
| 2798 | +					if ($globalDebug) { | |
| 2799 | + echo '# Weather Station added'."\n"; | |
| 2800 | + } | |
| 2012 | 2801 |  					$Source->deleteOldLocationByType('wx'); | 
| 2013 | 2802 | $weather_data = json_encode($line); | 
| 2014 | 2803 |  					if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) { | 
| @@ -2018,7 +2807,9 @@ discard block | ||
| 2018 | 2807 | } | 
| 2019 | 2808 |  				    } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) { | 
| 2020 | 2809 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; | 
| 2021 | - if ($globalDebug) echo '☈ Lightning added'."\n"; | |
| 2810 | +					if ($globalDebug) { | |
| 2811 | + echo '☈ Lightning added'."\n"; | |
| 2812 | + } | |
| 2022 | 2813 |  					$Source->deleteOldLocationByType('lightning'); | 
| 2023 | 2814 |  					if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) { | 
| 2024 | 2815 | $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']); | 
| @@ -2030,8 +2821,7 @@ discard block | ||
| 2030 | 2821 | print_r($line); | 
| 2031 | 2822 | } | 
| 2032 | 2823 | unset($data); | 
| 2033 | - } | |
| 2034 | -				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { | |
| 2824 | +				} elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { | |
| 2035 | 2825 | $Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']); | 
| 2036 | 2826 | } | 
| 2037 | 2827 | /* | 
| @@ -2040,7 +2830,9 @@ discard block | ||
| 2040 | 2830 | } | 
| 2041 | 2831 | */ | 
| 2042 | 2832 |  				//elseif ($line === false && $globalDebug) echo 'Ignored ('.$buffer.")\n"; | 
| 2043 | - elseif ($line === true && $globalDebug) echo '!! Failed : '.$buffer."!!\n"; | |
| 2833 | +				elseif ($line === true && $globalDebug) { | |
| 2834 | + echo '!! Failed : '.$buffer."!!\n"; | |
| 2835 | + } | |
| 2044 | 2836 |  				if (isset($Source) && isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) { | 
| 2045 | 2837 |  					$Source->deleteOldLocationByType('lightning'); | 
| 2046 | 2838 |  					$Source->deleteOldLocationByType('wx'); | 
| @@ -2077,27 +2869,47 @@ discard block | ||
| 2077 | 2869 | $data['ground'] = $line[21]; | 
| 2078 | 2870 | $data['emergency'] = $line[19]; | 
| 2079 | 2871 | $data['format_source'] = 'sbs'; | 
| 2080 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; | |
| 2081 | - elseif ($line[0] == 'MLAT') $data['source_name'] = 'MLAT'; | |
| 2082 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; | |
| 2083 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 2872 | +				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { | |
| 2873 | + $data['source_name'] = $globalSources[$nb]['name']; | |
| 2874 | +				} elseif ($line[0] == 'MLAT') { | |
| 2875 | + $data['source_name'] = 'MLAT'; | |
| 2876 | + } | |
| 2877 | +				if (isset($globalSources[$nb]['sourcestats'])) { | |
| 2878 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; | |
| 2879 | + } | |
| 2880 | +				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { | |
| 2881 | + $data['noarchive'] = true; | |
| 2882 | + } | |
| 2084 | 2883 | $data['id_source'] = $id_source; | 
| 2085 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); | |
| 2086 | - else $error = true; | |
| 2884 | +    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { | |
| 2885 | + $send = $SI->add($data); | |
| 2886 | +    				} else { | |
| 2887 | + $error = true; | |
| 2888 | + } | |
| 2087 | 2889 | unset($data); | 
| 2088 | - } else $error = true; | |
| 2890 | +    			    } else { | |
| 2891 | + $error = true; | |
| 2892 | + } | |
| 2089 | 2893 |  			    if ($error) { | 
| 2090 | 2894 |  				if (count($line) > 1 && ($line[0] === 'STA' || $line[0] === 'AIR' || $line[0] === 'SEL' || $line[0] === 'ID' || $line[0] === 'CLK')) {  | 
| 2091 | - if ($globalDebug) echo "Not a message. Ignoring... \n"; | |
| 2895 | +					if ($globalDebug) { | |
| 2896 | + echo "Not a message. Ignoring... \n"; | |
| 2897 | + } | |
| 2092 | 2898 |  				} else { | 
| 2093 | - if ($globalDebug) echo "Wrong line format. Ignoring... \n"; | |
| 2899 | +					if ($globalDebug) { | |
| 2900 | + echo "Wrong line format. Ignoring... \n"; | |
| 2901 | + } | |
| 2094 | 2902 |  					if ($globalDebug) { | 
| 2095 | 2903 | echo $buffer; | 
| 2096 | 2904 | //print_r($line); | 
| 2097 | 2905 | } | 
| 2098 | 2906 | //socket_close($r); | 
| 2099 | - if ($globalDebug) echo "Reconnect after an error...\n"; | |
| 2100 | - if ($format === 'aprs') $aprs_connect = 0; | |
| 2907 | +					if ($globalDebug) { | |
| 2908 | + echo "Reconnect after an error...\n"; | |
| 2909 | + } | |
| 2910 | +					if ($format === 'aprs') { | |
| 2911 | + $aprs_connect = 0; | |
| 2912 | + } | |
| 2101 | 2913 | $sourceer[$nb] = $globalSources[$nb]; | 
| 2102 | 2914 | connect_all($sourceer); | 
| 2103 | 2915 | $sourceer = array(); | 
| @@ -2105,10 +2917,14 @@ discard block | ||
| 2105 | 2917 | } | 
| 2106 | 2918 | } | 
| 2107 | 2919 | // Sleep for xxx microseconds | 
| 2108 | - if (isset($globalSBSSleep)) usleep($globalSBSSleep); | |
| 2920 | +			if (isset($globalSBSSleep)) { | |
| 2921 | + usleep($globalSBSSleep); | |
| 2922 | + } | |
| 2109 | 2923 |  		    } else { | 
| 2110 | 2924 |  			if ($format === 'flightgearmp') { | 
| 2111 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; | |
| 2925 | +			    	if ($globalDebug) { | |
| 2926 | + echo "Reconnect FlightGear MP..."; | |
| 2927 | + } | |
| 2112 | 2928 | //@socket_close($r); | 
| 2113 | 2929 | sleep($globalMinFetch); | 
| 2114 | 2930 | $sourcefg[$nb] = $globalSources[$nb]; | 
| @@ -2117,10 +2933,15 @@ discard block | ||
| 2117 | 2933 | break; | 
| 2118 | 2934 | |
| 2119 | 2935 |  			} elseif ($format != 'acars' && $format != 'flightgearsp') { | 
| 2120 | - if (isset($tt[$format])) $tt[$format]++; | |
| 2121 | - else $tt[$format] = 0; | |
| 2936 | +			    if (isset($tt[$format])) { | |
| 2937 | + $tt[$format]++; | |
| 2938 | +			    } else { | |
| 2939 | + $tt[$format] = 0; | |
| 2940 | + } | |
| 2122 | 2941 |  			    if ($tt[$format] > 30 || $buffer === FALSE) { | 
| 2123 | - if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; | |
| 2942 | +				if ($globalDebug) { | |
| 2943 | + echo "ERROR : Reconnect ".$format."..."; | |
| 2944 | + } | |
| 2124 | 2945 | //@socket_close($r); | 
| 2125 | 2946 | sleep(2); | 
| 2126 | 2947 | $aprs_connect = 0; | 
| @@ -2138,11 +2959,17 @@ discard block | ||
| 2138 | 2959 |  	    } else { | 
| 2139 | 2960 | $error = socket_strerror(socket_last_error()); | 
| 2140 | 2961 |  		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { | 
| 2141 | - if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; | |
| 2142 | - if (isset($globalDebug)) echo "Restarting...\n"; | |
| 2962 | +			if ($globalDebug) { | |
| 2963 | + echo "ERROR : socket_select give this error ".$error . "\n"; | |
| 2964 | + } | |
| 2965 | +			if (isset($globalDebug)) { | |
| 2966 | + echo "Restarting...\n"; | |
| 2967 | + } | |
| 2143 | 2968 | // Restart the script if possible | 
| 2144 | 2969 |  			if (is_array($sockets)) { | 
| 2145 | - if ($globalDebug) echo "Shutdown all sockets..."; | |
| 2970 | +			    if ($globalDebug) { | |
| 2971 | + echo "Shutdown all sockets..."; | |
| 2972 | + } | |
| 2146 | 2973 | |
| 2147 | 2974 |  			    foreach ($sockets as $sock) { | 
| 2148 | 2975 | @socket_shutdown($sock,2); | 
| @@ -2150,25 +2977,45 @@ discard block | ||
| 2150 | 2977 | } | 
| 2151 | 2978 | |
| 2152 | 2979 | } | 
| 2153 | - if ($globalDebug) echo "Waiting..."; | |
| 2980 | +			if ($globalDebug) { | |
| 2981 | + echo "Waiting..."; | |
| 2982 | + } | |
| 2154 | 2983 | sleep(2); | 
| 2155 | 2984 | $time = time(); | 
| 2156 | 2985 | //connect_all($hosts); | 
| 2157 | 2986 | $aprs_connect = 0; | 
| 2158 | - if ($reset%5 === 0) sleep(20); | |
| 2159 | - if ($reset%10 === 0) sleep(100); | |
| 2160 | - if ($reset%20 === 0) sleep(200); | |
| 2161 | -			if ($reset > 100) exit('Too many attempts...'); | |
| 2162 | - if ($globalDebug) echo "Restart all connections..."; | |
| 2987 | +			if ($reset%5 === 0) { | |
| 2988 | + sleep(20); | |
| 2989 | + } | |
| 2990 | +			if ($reset%10 === 0) { | |
| 2991 | + sleep(100); | |
| 2992 | + } | |
| 2993 | +			if ($reset%20 === 0) { | |
| 2994 | + sleep(200); | |
| 2995 | + } | |
| 2996 | +			if ($reset > 100) { | |
| 2997 | +				exit('Too many attempts...'); | |
| 2998 | + } | |
| 2999 | +			if ($globalDebug) { | |
| 3000 | + echo "Restart all connections..."; | |
| 3001 | + } | |
| 2163 | 3002 | connect_all($globalSources); | 
| 2164 | 3003 | } | 
| 2165 | 3004 | } | 
| 2166 | 3005 | } | 
| 2167 | 3006 |  	if ($globalDaemon === false) { | 
| 2168 | - if ($globalDebug) echo 'Check all...'."\n"; | |
| 2169 | - if (isset($SI)) $SI->checkAll(); | |
| 2170 | - if (isset($TI)) $TI->checkAll(); | |
| 2171 | - if (isset($MI)) $MI->checkAll(); | |
| 3007 | +	    if ($globalDebug) { | |
| 3008 | + echo 'Check all...'."\n"; | |
| 3009 | + } | |
| 3010 | +	    if (isset($SI)) { | |
| 3011 | + $SI->checkAll(); | |
| 3012 | + } | |
| 3013 | +	    if (isset($TI)) { | |
| 3014 | + $TI->checkAll(); | |
| 3015 | + } | |
| 3016 | +	    if (isset($MI)) { | |
| 3017 | + $MI->checkAll(); | |
| 3018 | + } | |
| 2172 | 3019 | } | 
| 2173 | 3020 | } | 
| 2174 | 3021 | } |