| @@ -17,11 +17,17 @@ discard block | ||
| 17 | 17 |  date_default_timezone_set('UTC'); | 
| 18 | 18 | |
| 19 | 19 | print '<div class="top">'; | 
| 20 | -if ($spotter_item['name'] != '') print '<div class="right"><div class="callsign-details"><div class="callsign">'.$spotter_item['name'].'</div>'; | |
| 21 | -elseif ($spotter_item['location_id'] != 0) print '<div class="right"><div class="callsign-details"><div class="callsign">'.$spotter_item['location_id'].'</div>'; | |
| 22 | -elseif ($spotter_item['type'] == 'lightning') print '<div class="right"><div class="callsign-details"><div class="callsign">'._("Lightning").'</div>'; | |
| 23 | -elseif ($spotter_item['type'] == 'wx') print '<div class="right"><div class="callsign-details"><div class="callsign">'._("Weather Station").'</div>'; | |
| 24 | -else print '<div class="right"><div class="callsign-details"><div class="callsign"></div>'; | |
| 20 | +if ($spotter_item['name'] != '') { | |
| 21 | + print '<div class="right"><div class="callsign-details"><div class="callsign">'.$spotter_item['name'].'</div>'; | |
| 22 | +} elseif ($spotter_item['location_id'] != 0) { | |
| 23 | + print '<div class="right"><div class="callsign-details"><div class="callsign">'.$spotter_item['location_id'].'</div>'; | |
| 24 | +} elseif ($spotter_item['type'] == 'lightning') { | |
| 25 | +	print '<div class="right"><div class="callsign-details"><div class="callsign">'._("Lightning").'</div>'; | |
| 26 | +} elseif ($spotter_item['type'] == 'wx') { | |
| 27 | +	print '<div class="right"><div class="callsign-details"><div class="callsign">'._("Weather Station").'</div>'; | |
| 28 | +} else { | |
| 29 | + print '<div class="right"><div class="callsign-details"><div class="callsign"></div>'; | |
| 30 | +} | |
| 25 | 31 | print '</div>'; | 
| 26 | 32 | |
| 27 | 33 | print '</div></div>'; | 
| @@ -36,8 +42,12 @@ discard block | ||
| 36 | 42 | print $spotter_item['last_seen'].' UTC'; | 
| 37 | 43 | print '</div>'; | 
| 38 | 44 | |
| 39 | -if ($spotter_item['city'] != '') print '<div><span>'._("City").'</span>'.$spotter_item['city'].'</div>'; | |
| 40 | -if ($spotter_item['country'] !='') print '<div><span>'._("Country").'</span>'.$spotter_item['country'].'</div>'; | |
| 45 | +if ($spotter_item['city'] != '') { | |
| 46 | +	print '<div><span>'._("City").'</span>'.$spotter_item['city'].'</div>'; | |
| 47 | +} | |
| 48 | +if ($spotter_item['country'] !='') { | |
| 49 | +	print '<div><span>'._("Country").'</span>'.$spotter_item['country'].'</div>'; | |
| 50 | +} | |
| 41 | 51 |  print '<div><span>'._("Coordinates").'</span>'.round($spotter_item['latitude'],3).', '.round($spotter_item['longitude'],3).'</div>'; | 
| 42 | 52 | /* | 
| 43 | 53 |  if ($spotter_item['atc_range'] > 0) { | 
| @@ -49,13 +59,27 @@ discard block | ||
| 49 | 59 |  if ($spotter_item['type'] == 'wx') { | 
| 50 | 60 | $weather = json_decode($spotter_item['description'],true); | 
| 51 | 61 | //print_r($weather); | 
| 52 | -	if (isset($weather['temp'])) print '<div><span>'._("Temperature").'</span>'.$weather['temp'].'°C</div>'; | |
| 53 | -	if (isset($weather['pressure'])) print '<div><span>'._("Pressure").'</span>'.$weather['pressure'].'hPa</div>'; | |
| 54 | -	if (isset($weather['wind_gust'])) print '<div><span>'._("Wind Gust").'</span>'.$weather['wind_gust'].' km/h</div>'; | |
| 55 | -	if (isset($weather['humidity'])) print '<div><span>'._("Humidity").'</span>'.$weather['humidity'].'%</div>'; | |
| 56 | -	if (isset($weather['rain'])) print '<div><span>'._("Rain").'</span>'.$weather['rain'].' mm</div>'; | |
| 57 | -	if (isset($weather['precipitation'])) print '<div><span>'._("Precipitation 24H").'</span>'.$weather['precipitation'].' mm</div>'; | |
| 58 | -	if (isset($weather['precipitation24h'])) print '<div><span>'._("Precipitation Today").'</span>'.$weather['precipitation24h'].' mm</div>'; | |
| 62 | +	if (isset($weather['temp'])) { | |
| 63 | +		print '<div><span>'._("Temperature").'</span>'.$weather['temp'].'°C</div>'; | |
| 64 | + } | |
| 65 | +	if (isset($weather['pressure'])) { | |
| 66 | +		print '<div><span>'._("Pressure").'</span>'.$weather['pressure'].'hPa</div>'; | |
| 67 | + } | |
| 68 | +	if (isset($weather['wind_gust'])) { | |
| 69 | +		print '<div><span>'._("Wind Gust").'</span>'.$weather['wind_gust'].' km/h</div>'; | |
| 70 | + } | |
| 71 | +	if (isset($weather['humidity'])) { | |
| 72 | +		print '<div><span>'._("Humidity").'</span>'.$weather['humidity'].'%</div>'; | |
| 73 | + } | |
| 74 | +	if (isset($weather['rain'])) { | |
| 75 | +		print '<div><span>'._("Rain").'</span>'.$weather['rain'].' mm</div>'; | |
| 76 | + } | |
| 77 | +	if (isset($weather['precipitation'])) { | |
| 78 | +		print '<div><span>'._("Precipitation 24H").'</span>'.$weather['precipitation'].' mm</div>'; | |
| 79 | + } | |
| 80 | +	if (isset($weather['precipitation24h'])) { | |
| 81 | +		print '<div><span>'._("Precipitation Today").'</span>'.$weather['precipitation24h'].' mm</div>'; | |
| 82 | + } | |
| 59 | 83 | $spotter_item['description'] = $weather['comment']; | 
| 60 | 84 | } | 
| 61 | 85 | print '</div>'; | 
| @@ -16,8 +16,8 @@ discard block | ||
| 16 | 16 | require_once(dirname(__FILE__).'/../require/class.Common.php'); | 
| 17 | 17 | if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); | 
| 18 | 18 |  if (isset($globalMarine) && $globalMarine) { | 
| 19 | - require_once(dirname(__FILE__).'/../require/class.AIS.php'); | |
| 20 | - require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); | |
| 19 | + require_once(dirname(__FILE__).'/../require/class.AIS.php'); | |
| 20 | + require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); | |
| 21 | 21 | } | 
| 22 | 22 | |
| 23 | 23 | if (!isset($globalDebug)) $globalDebug = FALSE; | 
| @@ -25,42 +25,42 @@ discard block | ||
| 25 | 25 | // Check if schema is at latest version | 
| 26 | 26 | $Connection = new Connection(); | 
| 27 | 27 |  if ($Connection->latest() === false) { | 
| 28 | - echo "You MUST update to latest schema. Run install/index.php"; | |
| 29 | - exit(); | |
| 28 | + echo "You MUST update to latest schema. Run install/index.php"; | |
| 29 | + exit(); | |
| 30 | 30 | } | 
| 31 | 31 |  if (PHP_SAPI != 'cli') { | 
| 32 | - echo "This script MUST be called from console, not a web browser."; | |
| 32 | + echo "This script MUST be called from console, not a web browser."; | |
| 33 | 33 | // exit(); | 
| 34 | 34 | } | 
| 35 | 35 | |
| 36 | 36 | // This is to be compatible with old version of settings.php | 
| 37 | 37 |  if (!isset($globalSources)) { | 
| 38 | -    if (isset($globalSBS1Hosts)) { | |
| 39 | - //$hosts = $globalSBS1Hosts; | |
| 40 | -        foreach ($globalSBS1Hosts as $host) { | |
| 41 | -	    $globalSources[] = array('host' => $host); | |
| 42 | - } | |
| 43 | -    } else { | |
| 44 | -        if (!isset($globalSBS1Host)) { | |
| 45 | - echo '$globalSources MUST be defined !'; | |
| 46 | - die; | |
| 38 | +	if (isset($globalSBS1Hosts)) { | |
| 39 | + //$hosts = $globalSBS1Hosts; | |
| 40 | +		foreach ($globalSBS1Hosts as $host) { | |
| 41 | +		$globalSources[] = array('host' => $host); | |
| 42 | + } | |
| 43 | +	} else { | |
| 44 | +		if (!isset($globalSBS1Host)) { | |
| 45 | + echo '$globalSources MUST be defined !'; | |
| 46 | + die; | |
| 47 | 47 | } | 
| 48 | 48 | //$hosts = array($globalSBS1Host.':'.$globalSBS1Port); | 
| 49 | 49 |  	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port); | 
| 50 | - } | |
| 50 | + } | |
| 51 | 51 | } | 
| 52 | 52 | |
| 53 | 53 |  $options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver')); | 
| 54 | 54 | //if (isset($options['s'])) $hosts = array($options['s']); | 
| 55 | 55 | //elseif (isset($options['source'])) $hosts = array($options['source']); | 
| 56 | 56 |  if (isset($options['s'])) { | 
| 57 | - $globalSources = array(); | |
| 58 | -    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); | |
| 59 | -    else $globalSources[] = array('host' => $options['s']); | |
| 57 | + $globalSources = array(); | |
| 58 | +	if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); | |
| 59 | +	else $globalSources[] = array('host' => $options['s']); | |
| 60 | 60 |  } elseif (isset($options['source'])) { | 
| 61 | - $globalSources = array(); | |
| 62 | -    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); | |
| 63 | -    else $globalSources[] = array('host' => $options['source']); | |
| 61 | + $globalSources = array(); | |
| 62 | +	if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); | |
| 63 | +	else $globalSources[] = array('host' => $options['source']); | |
| 64 | 64 | } | 
| 65 | 65 |  if (isset($options['aprsserverhost'])) { | 
| 66 | 66 | $globalServerAPRS = TRUE; | 
| @@ -75,8 +75,8 @@ discard block | ||
| 75 | 75 | if (isset($options['idsource'])) $id_source = $options['idsource']; | 
| 76 | 76 | else $id_source = 1; | 
| 77 | 77 |  if (isset($globalServer) && $globalServer) { | 
| 78 | - if ($globalDebug) echo "Using Server Mode\n"; | |
| 79 | - $SI=new SpotterServer(); | |
| 78 | + if ($globalDebug) echo "Using Server Mode\n"; | |
| 79 | + $SI=new SpotterServer(); | |
| 80 | 80 | /* | 
| 81 | 81 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); | 
| 82 | 82 | $SI = new adsb2aprs(); | 
| @@ -85,8 +85,8 @@ discard block | ||
| 85 | 85 | } else $SI=new SpotterImport($Connection->db); | 
| 86 | 86 | if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db); | 
| 87 | 87 |  if (isset($globalMarine) && $globalMarine) { | 
| 88 | - $AIS = new AIS(); | |
| 89 | - $MI = new MarineImport($Connection->db); | |
| 88 | + $AIS = new AIS(); | |
| 89 | + $MI = new MarineImport($Connection->db); | |
| 90 | 90 | } | 
| 91 | 91 | //$APRS=new APRS($Connection->db); | 
| 92 | 92 | $SBS=new SBS(); | 
| @@ -97,12 +97,12 @@ discard block | ||
| 97 | 97 |  //$servertz = system('date +%Z'); | 
| 98 | 98 | // signal handler - playing nice with sockets and dump1090 | 
| 99 | 99 |  if (function_exists('pcntl_fork')) { | 
| 100 | -    pcntl_signal(SIGINT,  function() { | |
| 101 | - global $sockets; | |
| 102 | - echo "\n\nctrl-c or kill signal received. Tidying up ... "; | |
| 103 | -        die("Bye!\n"); | |
| 104 | - }); | |
| 105 | - pcntl_signal_dispatch(); | |
| 100 | +	pcntl_signal(SIGINT,  function() { | |
| 101 | + global $sockets; | |
| 102 | + echo "\n\nctrl-c or kill signal received. Tidying up ... "; | |
| 103 | +		die("Bye!\n"); | |
| 104 | + }); | |
| 105 | + pcntl_signal_dispatch(); | |
| 106 | 106 | } | 
| 107 | 107 | |
| 108 | 108 | // let's try and connect | 
| @@ -112,36 +112,36 @@ discard block | ||
| 112 | 112 | $reset = 0; | 
| 113 | 113 | |
| 114 | 114 |  function connect_all($hosts) { | 
| 115 | - //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; | |
| 116 | - global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; | |
| 117 | - $reset++; | |
| 118 | - if ($globalDebug) echo 'Connect to all...'."\n"; | |
| 119 | -    foreach ($hosts as $id => $value) { | |
| 115 | + //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; | |
| 116 | + global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; | |
| 117 | + $reset++; | |
| 118 | + if ($globalDebug) echo 'Connect to all...'."\n"; | |
| 119 | +	foreach ($hosts as $id => $value) { | |
| 120 | 120 | $host = $value['host']; | 
| 121 | 121 | $globalSources[$id]['last_exec'] = 0; | 
| 122 | 122 | // Here we check type of source(s) | 
| 123 | 123 |  	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { | 
| 124 | -            if (preg_match('/deltadb.txt$/i',$host)) { | |
| 125 | - //$formats[$id] = 'deltadbtxt'; | |
| 126 | - $globalSources[$id]['format'] = 'deltadbtxt'; | |
| 127 | - //$last_exec['deltadbtxt'] = 0; | |
| 128 | -        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; | |
| 129 | -            } else if (preg_match('/vatsim-data.txt$/i',$host)) { | |
| 130 | - //$formats[$id] = 'vatsimtxt'; | |
| 131 | - $globalSources[$id]['format'] = 'vatsimtxt'; | |
| 132 | - //$last_exec['vatsimtxt'] = 0; | |
| 133 | -        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; | |
| 134 | -    	    } else if (preg_match('/aircraftlist.json$/i',$host)) { | |
| 135 | - //$formats[$id] = 'aircraftlistjson'; | |
| 136 | - $globalSources[$id]['format'] = 'aircraftlistjson'; | |
| 137 | - //$last_exec['aircraftlistjson'] = 0; | |
| 138 | -        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; | |
| 139 | -    	    } else if (preg_match('/opensky/i',$host)) { | |
| 140 | - //$formats[$id] = 'aircraftlistjson'; | |
| 141 | - $globalSources[$id]['format'] = 'opensky'; | |
| 142 | - //$last_exec['aircraftlistjson'] = 0; | |
| 143 | -        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; | |
| 144 | - /* | |
| 124 | +			if (preg_match('/deltadb.txt$/i',$host)) { | |
| 125 | + //$formats[$id] = 'deltadbtxt'; | |
| 126 | + $globalSources[$id]['format'] = 'deltadbtxt'; | |
| 127 | + //$last_exec['deltadbtxt'] = 0; | |
| 128 | +			if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; | |
| 129 | +			} else if (preg_match('/vatsim-data.txt$/i',$host)) { | |
| 130 | + //$formats[$id] = 'vatsimtxt'; | |
| 131 | + $globalSources[$id]['format'] = 'vatsimtxt'; | |
| 132 | + //$last_exec['vatsimtxt'] = 0; | |
| 133 | +			if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; | |
| 134 | +			} else if (preg_match('/aircraftlist.json$/i',$host)) { | |
| 135 | + //$formats[$id] = 'aircraftlistjson'; | |
| 136 | + $globalSources[$id]['format'] = 'aircraftlistjson'; | |
| 137 | + //$last_exec['aircraftlistjson'] = 0; | |
| 138 | +			if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; | |
| 139 | +			} else if (preg_match('/opensky/i',$host)) { | |
| 140 | + //$formats[$id] = 'aircraftlistjson'; | |
| 141 | + $globalSources[$id]['format'] = 'opensky'; | |
| 142 | + //$last_exec['aircraftlistjson'] = 0; | |
| 143 | +			if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; | |
| 144 | + /* | |
| 145 | 145 | // Disabled for now, site change source format | 
| 146 | 146 |      	    } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) { | 
| 147 | 147 | //$formats[$id] = 'radarvirtueljson'; | 
| @@ -153,121 +153,121 @@ discard block | ||
| 153 | 153 | exit(0); | 
| 154 | 154 | } | 
| 155 | 155 | */ | 
| 156 | -    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { | |
| 157 | - //$formats[$id] = 'planeupdatefaa'; | |
| 158 | - $globalSources[$id]['format'] = 'planeupdatefaa'; | |
| 159 | - //$last_exec['planeupdatefaa'] = 0; | |
| 160 | -        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; | |
| 161 | -        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { | |
| 162 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; | |
| 163 | - exit(0); | |
| 164 | - } | |
| 165 | -            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { | |
| 166 | - //$formats[$id] = 'phpvmacars'; | |
| 167 | - $globalSources[$id]['format'] = 'phpvmacars'; | |
| 168 | - //$last_exec['phpvmacars'] = 0; | |
| 169 | -        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; | |
| 170 | -            } else if (preg_match('/VAM-json.php$/i',$host)) { | |
| 171 | - //$formats[$id] = 'phpvmacars'; | |
| 172 | - $globalSources[$id]['format'] = 'vam'; | |
| 173 | -        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; | |
| 174 | -            } else if (preg_match('/whazzup/i',$host)) { | |
| 175 | - //$formats[$id] = 'whazzup'; | |
| 176 | - $globalSources[$id]['format'] = 'whazzup'; | |
| 177 | - //$last_exec['whazzup'] = 0; | |
| 178 | -        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; | |
| 179 | -            } else if (preg_match('/blitzortung/i',$host)) { | |
| 180 | - $globalSources[$id]['format'] = 'blitzortung'; | |
| 181 | -        	if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n"; | |
| 182 | -            } else if (preg_match('/airwhere/i',$host)) { | |
| 183 | - $globalSources[$id]['format'] = 'airwhere'; | |
| 184 | -        	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; | |
| 185 | -            } else if (preg_match('/recentpireps/i',$host)) { | |
| 186 | - //$formats[$id] = 'pirepsjson'; | |
| 187 | - $globalSources[$id]['format'] = 'pirepsjson'; | |
| 188 | - //$last_exec['pirepsjson'] = 0; | |
| 189 | -        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; | |
| 190 | -            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { | |
| 191 | - //$formats[$id] = 'fr24json'; | |
| 192 | - $globalSources[$id]['format'] = 'fr24json'; | |
| 193 | - //$last_exec['fr24json'] = 0; | |
| 194 | -        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; | |
| 195 | -        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { | |
| 196 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; | |
| 197 | - exit(0); | |
| 198 | - } | |
| 199 | -            } else if (preg_match(':myshiptracking.com/:i',$host)) { | |
| 200 | - //$formats[$id] = 'fr24json'; | |
| 201 | - $globalSources[$id]['format'] = 'myshiptracking'; | |
| 202 | - //$last_exec['fr24json'] = 0; | |
| 203 | -        	if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; | |
| 204 | -        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { | |
| 205 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; | |
| 206 | - exit(0); | |
| 207 | - } | |
| 208 | -            //} else if (preg_match('/10001/',$host)) { | |
| 209 | -            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { | |
| 210 | - //$formats[$id] = 'tsv'; | |
| 211 | - $globalSources[$id]['format'] = 'tsv'; | |
| 212 | -        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; | |
| 213 | - } | |
| 214 | -        } elseif (filter_var($host,FILTER_VALIDATE_URL)) { | |
| 215 | -    		if ($globalSources[$id]['format'] == 'aisnmeahttp') { | |
| 216 | - $idf = fopen($globalSources[$id]['host'],'r',false,$context); | |
| 217 | -    		    if ($idf !== false) { | |
| 218 | - $httpfeeds[$id] = $idf; | |
| 219 | -        		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; | |
| 220 | - } | |
| 221 | - elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; | |
| 222 | -    		} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; | |
| 223 | -        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { | |
| 224 | -	    $hostport = explode(':',$host); | |
| 225 | -	    if (isset($hostport[1])) { | |
| 156 | +			} else if (preg_match('/planeUpdateFAA.php$/i',$host)) { | |
| 157 | + //$formats[$id] = 'planeupdatefaa'; | |
| 158 | + $globalSources[$id]['format'] = 'planeupdatefaa'; | |
| 159 | + //$last_exec['planeupdatefaa'] = 0; | |
| 160 | +			if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; | |
| 161 | +			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { | |
| 162 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; | |
| 163 | + exit(0); | |
| 164 | + } | |
| 165 | +			} else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { | |
| 166 | + //$formats[$id] = 'phpvmacars'; | |
| 167 | + $globalSources[$id]['format'] = 'phpvmacars'; | |
| 168 | + //$last_exec['phpvmacars'] = 0; | |
| 169 | +			if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; | |
| 170 | +			} else if (preg_match('/VAM-json.php$/i',$host)) { | |
| 171 | + //$formats[$id] = 'phpvmacars'; | |
| 172 | + $globalSources[$id]['format'] = 'vam'; | |
| 173 | +			if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; | |
| 174 | +			} else if (preg_match('/whazzup/i',$host)) { | |
| 175 | + //$formats[$id] = 'whazzup'; | |
| 176 | + $globalSources[$id]['format'] = 'whazzup'; | |
| 177 | + //$last_exec['whazzup'] = 0; | |
| 178 | +			if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; | |
| 179 | +			} else if (preg_match('/blitzortung/i',$host)) { | |
| 180 | + $globalSources[$id]['format'] = 'blitzortung'; | |
| 181 | +			if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n"; | |
| 182 | +			} else if (preg_match('/airwhere/i',$host)) { | |
| 183 | + $globalSources[$id]['format'] = 'airwhere'; | |
| 184 | +			if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; | |
| 185 | +			} else if (preg_match('/recentpireps/i',$host)) { | |
| 186 | + //$formats[$id] = 'pirepsjson'; | |
| 187 | + $globalSources[$id]['format'] = 'pirepsjson'; | |
| 188 | + //$last_exec['pirepsjson'] = 0; | |
| 189 | +			if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; | |
| 190 | +			} else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { | |
| 191 | + //$formats[$id] = 'fr24json'; | |
| 192 | + $globalSources[$id]['format'] = 'fr24json'; | |
| 193 | + //$last_exec['fr24json'] = 0; | |
| 194 | +			if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; | |
| 195 | +			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { | |
| 196 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; | |
| 197 | + exit(0); | |
| 198 | + } | |
| 199 | +			} else if (preg_match(':myshiptracking.com/:i',$host)) { | |
| 200 | + //$formats[$id] = 'fr24json'; | |
| 201 | + $globalSources[$id]['format'] = 'myshiptracking'; | |
| 202 | + //$last_exec['fr24json'] = 0; | |
| 203 | +			if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; | |
| 204 | +			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { | |
| 205 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; | |
| 206 | + exit(0); | |
| 207 | + } | |
| 208 | +			//} else if (preg_match('/10001/',$host)) { | |
| 209 | +			} else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { | |
| 210 | + //$formats[$id] = 'tsv'; | |
| 211 | + $globalSources[$id]['format'] = 'tsv'; | |
| 212 | +			if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; | |
| 213 | + } | |
| 214 | +		} elseif (filter_var($host,FILTER_VALIDATE_URL)) { | |
| 215 | +			if ($globalSources[$id]['format'] == 'aisnmeahttp') { | |
| 216 | + $idf = fopen($globalSources[$id]['host'],'r',false,$context); | |
| 217 | +				if ($idf !== false) { | |
| 218 | + $httpfeeds[$id] = $idf; | |
| 219 | +				if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; | |
| 220 | + } | |
| 221 | + elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; | |
| 222 | +			} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; | |
| 223 | +		} elseif (!filter_var($host,FILTER_VALIDATE_URL)) { | |
| 224 | +		$hostport = explode(':',$host); | |
| 225 | +		if (isset($hostport[1])) { | |
| 226 | 226 | $port = $hostport[1]; | 
| 227 | 227 | $hostn = $hostport[0]; | 
| 228 | -	    } else { | |
| 228 | +		} else { | |
| 229 | 229 | $port = $globalSources[$id]['port']; | 
| 230 | 230 | $hostn = $globalSources[$id]['host']; | 
| 231 | - } | |
| 232 | - $Common = new Common(); | |
| 233 | -	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { | |
| 234 | - $s = $Common->create_socket($hostn,$port, $errno, $errstr); | |
| 235 | -    	    } else { | |
| 236 | - $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); | |
| 237 | - } | |
| 238 | -	    if ($s) { | |
| 239 | - $sockets[$id] = $s; | |
| 240 | -    	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { | |
| 241 | -		    if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { | |
| 231 | + } | |
| 232 | + $Common = new Common(); | |
| 233 | +		if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { | |
| 234 | + $s = $Common->create_socket($hostn,$port, $errno, $errstr); | |
| 235 | +			} else { | |
| 236 | + $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); | |
| 237 | + } | |
| 238 | +		if ($s) { | |
| 239 | + $sockets[$id] = $s; | |
| 240 | +				if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { | |
| 241 | +			if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { | |
| 242 | 242 | //$formats[$id] = 'aprs'; | 
| 243 | 243 | $globalSources[$id]['format'] = 'aprs'; | 
| 244 | 244 | //$aprs_connect = 0; | 
| 245 | 245 | //$use_aprs = true; | 
| 246 | -		    } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { | |
| 246 | +			} elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { | |
| 247 | 247 | $globalSources[$id]['format'] = 'vrstcp'; | 
| 248 | -    		    } elseif ($port == '10001') { | |
| 249 | - //$formats[$id] = 'tsv'; | |
| 250 | - $globalSources[$id]['format'] = 'tsv'; | |
| 251 | -		    } elseif ($port == '30002') { | |
| 252 | - //$formats[$id] = 'raw'; | |
| 253 | - $globalSources[$id]['format'] = 'raw'; | |
| 254 | -		    } elseif ($port == '5001') { | |
| 255 | - //$formats[$id] = 'raw'; | |
| 256 | - $globalSources[$id]['format'] = 'flightgearmp'; | |
| 257 | -		    } elseif ($port == '30005') { | |
| 248 | +				} elseif ($port == '10001') { | |
| 249 | + //$formats[$id] = 'tsv'; | |
| 250 | + $globalSources[$id]['format'] = 'tsv'; | |
| 251 | +			} elseif ($port == '30002') { | |
| 252 | + //$formats[$id] = 'raw'; | |
| 253 | + $globalSources[$id]['format'] = 'raw'; | |
| 254 | +			} elseif ($port == '5001') { | |
| 255 | + //$formats[$id] = 'raw'; | |
| 256 | + $globalSources[$id]['format'] = 'flightgearmp'; | |
| 257 | +			} elseif ($port == '30005') { | |
| 258 | 258 | // Not yet supported | 
| 259 | - //$formats[$id] = 'beast'; | |
| 260 | - $globalSources[$id]['format'] = 'beast'; | |
| 261 | - //} else $formats[$id] = 'sbs'; | |
| 262 | - } else $globalSources[$id]['format'] = 'sbs'; | |
| 263 | -		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; | |
| 259 | + //$formats[$id] = 'beast'; | |
| 260 | + $globalSources[$id]['format'] = 'beast'; | |
| 261 | + //} else $formats[$id] = 'sbs'; | |
| 262 | + } else $globalSources[$id]['format'] = 'sbs'; | |
| 263 | +			//if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; | |
| 264 | 264 | } | 
| 265 | 265 |  		if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; | 
| 266 | -            } else { | |
| 266 | +			} else { | |
| 267 | 267 | if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; | 
| 268 | - } | |
| 269 | - } | |
| 270 | - } | |
| 268 | + } | |
| 269 | + } | |
| 270 | + } | |
| 271 | 271 | } | 
| 272 | 272 | if (!isset($globalMinFetch)) $globalMinFetch = 15; | 
| 273 | 273 | |
| @@ -290,9 +290,9 @@ discard block | ||
| 290 | 290 | //connect_all($globalSources); | 
| 291 | 291 | |
| 292 | 292 |  if (isset($globalProxy) && $globalProxy) { | 
| 293 | -    $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); | |
| 293 | +	$context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); | |
| 294 | 294 |  } else { | 
| 295 | -    $context = stream_context_create(array('http' => array('timeout' => $timeout))); | |
| 295 | +	$context = stream_context_create(array('http' => array('timeout' => $timeout))); | |
| 296 | 296 | } | 
| 297 | 297 | |
| 298 | 298 | // APRS Configuration | 
| @@ -301,21 +301,21 @@ discard block | ||
| 301 | 301 | die; | 
| 302 | 302 | } | 
| 303 | 303 |  foreach ($globalSources as $key => $source) { | 
| 304 | -    if (!isset($source['format'])) { | |
| 305 | - $globalSources[$key]['format'] = 'auto'; | |
| 306 | - } | |
| 307 | -    if (isset($source['callback']) && $source['callback'] === TRUE) { | |
| 308 | - unset($globalSources[$key]); | |
| 309 | - } | |
| 304 | +	if (!isset($source['format'])) { | |
| 305 | + $globalSources[$key]['format'] = 'auto'; | |
| 306 | + } | |
| 307 | +	if (isset($source['callback']) && $source['callback'] === TRUE) { | |
| 308 | + unset($globalSources[$key]); | |
| 309 | + } | |
| 310 | 310 | } | 
| 311 | 311 | connect_all($globalSources); | 
| 312 | 312 |  foreach ($globalSources as $key => $source) { | 
| 313 | -    if (isset($source['format']) && $source['format'] == 'aprs') { | |
| 313 | +	if (isset($source['format']) && $source['format'] == 'aprs') { | |
| 314 | 314 | $aprs_connect = 0; | 
| 315 | 315 | $use_aprs = true; | 
| 316 | 316 | if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true; | 
| 317 | 317 | break; | 
| 318 | - } | |
| 318 | + } | |
| 319 | 319 | } | 
| 320 | 320 | |
| 321 | 321 |  if ($use_aprs) { | 
| @@ -356,126 +356,126 @@ discard block | ||
| 356 | 356 | |
| 357 | 357 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. | 
| 358 | 358 |  while ($i > 0) { | 
| 359 | - if (!$globalDaemon) $i = $endtime-time(); | |
| 360 | - // Delete old ATC | |
| 361 | -    if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { | |
| 359 | + if (!$globalDaemon) $i = $endtime-time(); | |
| 360 | + // Delete old ATC | |
| 361 | +	if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { | |
| 362 | 362 | if ($globalDebug) echo 'Delete old ATC...'."\n"; | 
| 363 | - $ATC->deleteOldATC(); | |
| 364 | - } | |
| 363 | + $ATC->deleteOldATC(); | |
| 364 | + } | |
| 365 | 365 | |
| 366 | -    if (count($last_exec) == count($globalSources)) { | |
| 366 | +	if (count($last_exec) == count($globalSources)) { | |
| 367 | 367 | $max = $globalMinFetch; | 
| 368 | 368 |  	foreach ($last_exec as $last) { | 
| 369 | - if ((time() - $last['last']) < $max) $max = time() - $last['last']; | |
| 369 | + if ((time() - $last['last']) < $max) $max = time() - $last['last']; | |
| 370 | 370 | } | 
| 371 | 371 |  	if ($max != $globalMinFetch) { | 
| 372 | - if ($globalDebug) echo 'Sleeping...'."\n"; | |
| 373 | - sleep($globalMinFetch-$max+2); | |
| 372 | + if ($globalDebug) echo 'Sleeping...'."\n"; | |
| 373 | + sleep($globalMinFetch-$max+2); | |
| 374 | + } | |
| 374 | 375 | } | 
| 375 | - } | |
| 376 | 376 | |
| 377 | 377 | |
| 378 | -    //foreach ($formats as $id => $value) { | |
| 379 | -    foreach ($globalSources as $id => $value) { | |
| 378 | +	//foreach ($formats as $id => $value) { | |
| 379 | +	foreach ($globalSources as $id => $value) { | |
| 380 | 380 |  	date_default_timezone_set('UTC'); | 
| 381 | 381 | //if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n"; | 
| 382 | 382 | if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0; | 
| 383 | 383 | if ($value['format'] == 'deltadbtxt' && | 
| 384 | - ( | |
| 384 | + ( | |
| 385 | 385 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || | 
| 386 | 386 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) | 
| 387 | - ) | |
| 387 | + ) | |
| 388 | 388 |  	) { | 
| 389 | - //$buffer = $Common->getData($hosts[$id]); | |
| 390 | - $buffer = $Common->getData($value['host']); | |
| 391 | - if ($buffer != '') $reset = 0; | |
| 392 | -    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); | |
| 393 | -	    $buffer = explode('\n',$buffer); | |
| 394 | -	    foreach ($buffer as $line) { | |
| 395 | -    		if ($line != '' && count($line) > 7) { | |
| 396 | -    		    $line = explode(',', $line); | |
| 397 | - $data = array(); | |
| 398 | - $data['hex'] = $line[1]; // hex | |
| 399 | - $data['ident'] = $line[2]; // ident | |
| 400 | - if (isset($line[3])) $data['altitude'] = $line[3]; // altitude | |
| 401 | - if (isset($line[4])) $data['speed'] = $line[4]; // speed | |
| 402 | - if (isset($line[5])) $data['heading'] = $line[5]; // heading | |
| 403 | - if (isset($line[6])) $data['latitude'] = $line[6]; // lat | |
| 404 | - if (isset($line[7])) $data['longitude'] = $line[7]; // long | |
| 405 | - $data['verticalrate'] = ''; // vertical rate | |
| 406 | - //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk | |
| 407 | - $data['emergency'] = ''; // emergency | |
| 408 | -		    $data['datetime'] = date('Y-m-d H:i:s'); | |
| 409 | - $data['format_source'] = 'deltadbtxt'; | |
| 410 | - $data['id_source'] = $id_source; | |
| 411 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; | |
| 412 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 413 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; | |
| 414 | - $SI->add($data); | |
| 415 | - unset($data); | |
| 416 | - } | |
| 417 | - } | |
| 418 | - $last_exec[$id]['last'] = time(); | |
| 389 | + //$buffer = $Common->getData($hosts[$id]); | |
| 390 | + $buffer = $Common->getData($value['host']); | |
| 391 | + if ($buffer != '') $reset = 0; | |
| 392 | +			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); | |
| 393 | +		$buffer = explode('\n',$buffer); | |
| 394 | +		foreach ($buffer as $line) { | |
| 395 | +			if ($line != '' && count($line) > 7) { | |
| 396 | +				$line = explode(',', $line); | |
| 397 | + $data = array(); | |
| 398 | + $data['hex'] = $line[1]; // hex | |
| 399 | + $data['ident'] = $line[2]; // ident | |
| 400 | + if (isset($line[3])) $data['altitude'] = $line[3]; // altitude | |
| 401 | + if (isset($line[4])) $data['speed'] = $line[4]; // speed | |
| 402 | + if (isset($line[5])) $data['heading'] = $line[5]; // heading | |
| 403 | + if (isset($line[6])) $data['latitude'] = $line[6]; // lat | |
| 404 | + if (isset($line[7])) $data['longitude'] = $line[7]; // long | |
| 405 | + $data['verticalrate'] = ''; // vertical rate | |
| 406 | + //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk | |
| 407 | + $data['emergency'] = ''; // emergency | |
| 408 | +			$data['datetime'] = date('Y-m-d H:i:s'); | |
| 409 | + $data['format_source'] = 'deltadbtxt'; | |
| 410 | + $data['id_source'] = $id_source; | |
| 411 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; | |
| 412 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 413 | + if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; | |
| 414 | + $SI->add($data); | |
| 415 | + unset($data); | |
| 416 | + } | |
| 417 | + } | |
| 418 | + $last_exec[$id]['last'] = time(); | |
| 419 | 419 | } elseif ($value['format'] == 'aisnmeatxt' && | 
| 420 | - ( | |
| 420 | + ( | |
| 421 | 421 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || | 
| 422 | 422 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) | 
| 423 | - ) | |
| 423 | + ) | |
| 424 | 424 |  	) { | 
| 425 | -	    date_default_timezone_set('CET'); | |
| 426 | -	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); | |
| 427 | -	    date_default_timezone_set('UTC'); | |
| 428 | - if ($buffer != '') $reset = 0; | |
| 429 | -    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); | |
| 430 | -	    $buffer = explode('\n',$buffer); | |
| 431 | -	    foreach ($buffer as $line) { | |
| 425 | +		date_default_timezone_set('CET'); | |
| 426 | +		$buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); | |
| 427 | +		date_default_timezone_set('UTC'); | |
| 428 | + if ($buffer != '') $reset = 0; | |
| 429 | +			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); | |
| 430 | +		$buffer = explode('\n',$buffer); | |
| 431 | +		foreach ($buffer as $line) { | |
| 432 | 432 |  		if ($line != '') { | 
| 433 | - //echo "'".$line."'\n"; | |
| 434 | - $add = false; | |
| 435 | - $ais_data = $AIS->parse_line(trim($line)); | |
| 436 | - $data = array(); | |
| 437 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; | |
| 438 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; | |
| 439 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; | |
| 440 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; | |
| 441 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; | |
| 442 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; | |
| 443 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; | |
| 444 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; | |
| 445 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; | |
| 446 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; | |
| 447 | -		    if (isset($ais_data['timestamp'])) { | |
| 433 | + //echo "'".$line."'\n"; | |
| 434 | + $add = false; | |
| 435 | + $ais_data = $AIS->parse_line(trim($line)); | |
| 436 | + $data = array(); | |
| 437 | + if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; | |
| 438 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; | |
| 439 | + if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; | |
| 440 | + if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; | |
| 441 | + if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; | |
| 442 | + if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; | |
| 443 | + if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; | |
| 444 | + if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; | |
| 445 | + if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; | |
| 446 | + if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; | |
| 447 | +			if (isset($ais_data['timestamp'])) { | |
| 448 | 448 |  			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); | 
| 449 | 449 |  			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { | 
| 450 | - $last_exec[$id]['timestamp'] = $ais_data['timestamp']; | |
| 451 | - $add = true; | |
| 450 | + $last_exec[$id]['timestamp'] = $ais_data['timestamp']; | |
| 451 | + $add = true; | |
| 452 | 452 | } | 
| 453 | -		    } else { | |
| 453 | +			} else { | |
| 454 | 454 |  			$data['datetime'] = date('Y-m-d H:i:s'); | 
| 455 | 455 | $add = true; | 
| 456 | - } | |
| 457 | - $data['format_source'] = 'aisnmeatxt'; | |
| 458 | - $data['id_source'] = $id_source; | |
| 459 | - //print_r($data); | |
| 460 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 461 | - if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); | |
| 462 | - unset($data); | |
| 456 | + } | |
| 457 | + $data['format_source'] = 'aisnmeatxt'; | |
| 458 | + $data['id_source'] = $id_source; | |
| 459 | + //print_r($data); | |
| 460 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 461 | + if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); | |
| 462 | + unset($data); | |
| 463 | 463 | } | 
| 464 | - } | |
| 465 | - $last_exec[$id]['last'] = time(); | |
| 464 | + } | |
| 465 | + $last_exec[$id]['last'] = time(); | |
| 466 | 466 |  	} elseif ($value['format'] == 'aisnmeahttp') { | 
| 467 | - $arr = $httpfeeds; | |
| 468 | - $w = $e = null; | |
| 467 | + $arr = $httpfeeds; | |
| 468 | + $w = $e = null; | |
| 469 | 469 | |
| 470 | -	    if (isset($arr[$id])) { | |
| 470 | +		if (isset($arr[$id])) { | |
| 471 | 471 | $nn = stream_select($arr,$w,$e,$timeout); | 
| 472 | 472 |  		if ($nn > 0) { | 
| 473 | -		    foreach ($httpfeeds as $feed) { | |
| 473 | +			foreach ($httpfeeds as $feed) { | |
| 474 | 474 | $buffer = stream_get_line($feed,2000,"\n"); | 
| 475 | 475 |  			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); | 
| 476 | 476 |  			$buffer = explode('\n',$buffer); | 
| 477 | 477 |  			foreach ($buffer as $line) { | 
| 478 | -			    if ($line != '') { | |
| 478 | +				if ($line != '') { | |
| 479 | 479 | $ais_data = $AIS->parse_line(trim($line)); | 
| 480 | 480 | $data = array(); | 
| 481 | 481 | if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; | 
| @@ -493,111 +493,111 @@ discard block | ||
| 493 | 493 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; | 
| 494 | 494 |  				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); | 
| 495 | 495 |  				if (isset($ais_data['timestamp'])) { | 
| 496 | -				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); | |
| 496 | +					$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); | |
| 497 | 497 |  				} else { | 
| 498 | -				    $data['datetime'] = date('Y-m-d H:i:s'); | |
| 498 | +					$data['datetime'] = date('Y-m-d H:i:s'); | |
| 499 | 499 | } | 
| 500 | 500 | $data['format_source'] = 'aisnmeahttp'; | 
| 501 | 501 | $data['id_source'] = $id_source; | 
| 502 | 502 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | 
| 503 | 503 | if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); | 
| 504 | 504 | unset($data); | 
| 505 | - } | |
| 505 | + } | |
| 506 | + } | |
| 506 | 507 | } | 
| 507 | - } | |
| 508 | 508 |  		} else { | 
| 509 | - $format = $value['format']; | |
| 510 | - if (isset($tt[$format])) $tt[$format]++; | |
| 511 | - else $tt[$format] = 0; | |
| 512 | -		    if ($tt[$format] > 30) { | |
| 509 | + $format = $value['format']; | |
| 510 | + if (isset($tt[$format])) $tt[$format]++; | |
| 511 | + else $tt[$format] = 0; | |
| 512 | +			if ($tt[$format] > 30) { | |
| 513 | 513 | if ($globalDebug) echo 'Reconnect...'."\n"; | 
| 514 | 514 | sleep(2); | 
| 515 | 515 | $sourceeen[] = $value; | 
| 516 | 516 | connect_all($sourceeen); | 
| 517 | 517 | $sourceeen = array(); | 
| 518 | - } | |
| 518 | + } | |
| 519 | + } | |
| 519 | 520 | } | 
| 520 | - } | |
| 521 | 521 | } elseif ($value['format'] == 'myshiptracking' && | 
| 522 | - ( | |
| 522 | + ( | |
| 523 | 523 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || | 
| 524 | 524 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) | 
| 525 | - ) | |
| 525 | + ) | |
| 526 | 526 |  	) { | 
| 527 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); | |
| 528 | -	    if ($buffer != '') { | |
| 527 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); | |
| 528 | +		if ($buffer != '') { | |
| 529 | 529 | //echo $buffer; | 
| 530 | 530 | $all_data = json_decode($buffer,true); | 
| 531 | 531 | //print_r($all_data); | 
| 532 | 532 |  		if (isset($all_data[0]['DATA'])) { | 
| 533 | -		    foreach ($all_data[0]['DATA'] as $line) { | |
| 533 | +			foreach ($all_data[0]['DATA'] as $line) { | |
| 534 | 534 |  			if ($line != '') { | 
| 535 | - $data = array(); | |
| 536 | - $data['ident'] = $line['NAME']; | |
| 537 | - $data['mmsi'] = $line['MMSI']; | |
| 538 | - $data['speed'] = $line['SOG']; | |
| 539 | - $data['heading'] = $line['COG']; | |
| 540 | - $data['latitude'] = $line['LAT']; | |
| 541 | - $data['longitude'] = $line['LNG']; | |
| 542 | - // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; | |
| 543 | - $data['imo'] = $line['IMO']; | |
| 544 | - //$data['arrival_code'] = $ais_data['destination']; | |
| 545 | -			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']); | |
| 546 | - $data['format_source'] = 'myshiptracking'; | |
| 547 | - $data['id_source'] = $id_source; | |
| 548 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 549 | - $MI->add($data); | |
| 550 | - unset($data); | |
| 535 | + $data = array(); | |
| 536 | + $data['ident'] = $line['NAME']; | |
| 537 | + $data['mmsi'] = $line['MMSI']; | |
| 538 | + $data['speed'] = $line['SOG']; | |
| 539 | + $data['heading'] = $line['COG']; | |
| 540 | + $data['latitude'] = $line['LAT']; | |
| 541 | + $data['longitude'] = $line['LNG']; | |
| 542 | + // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; | |
| 543 | + $data['imo'] = $line['IMO']; | |
| 544 | + //$data['arrival_code'] = $ais_data['destination']; | |
| 545 | +				$data['datetime'] = date('Y-m-d H:i:s',$line['T']); | |
| 546 | + $data['format_source'] = 'myshiptracking'; | |
| 547 | + $data['id_source'] = $id_source; | |
| 548 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 549 | + $MI->add($data); | |
| 550 | + unset($data); | |
| 551 | + } | |
| 551 | 552 | } | 
| 552 | - } | |
| 553 | 553 | } | 
| 554 | - } | |
| 555 | - $last_exec[$id]['last'] = time(); | |
| 554 | + } | |
| 555 | + $last_exec[$id]['last'] = time(); | |
| 556 | 556 | } elseif ($value['format'] == 'boatbeaconapp' && | 
| 557 | - ( | |
| 557 | + ( | |
| 558 | 558 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || | 
| 559 | 559 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) | 
| 560 | - ) | |
| 560 | + ) | |
| 561 | 561 |  	) { | 
| 562 | -	    $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); | |
| 563 | -	    if ($buffer != '') { | |
| 562 | +		$buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); | |
| 563 | +		if ($buffer != '') { | |
| 564 | 564 | $all_data = json_decode($buffer,true); | 
| 565 | 565 |  		if (isset($all_data[0]['mmsi'])) { | 
| 566 | -		    foreach ($all_data as $line) { | |
| 566 | +			foreach ($all_data as $line) { | |
| 567 | 567 |  			if ($line != '') { | 
| 568 | - $data = array(); | |
| 569 | - $data['ident'] = $line['shipname']; | |
| 570 | - $data['callsign'] = $line['callsign']; | |
| 571 | - $data['mmsi'] = $line['mmsi']; | |
| 572 | - $data['speed'] = $line['sog']; | |
| 573 | - if ($line['heading'] != '511') $data['heading'] = $line['heading']; | |
| 574 | - $data['latitude'] = $line['latitude']; | |
| 575 | - $data['longitude'] = $line['longitude']; | |
| 576 | - $data['type_id'] = $line['shiptype']; | |
| 577 | - $data['arrival_code'] = $line['destination']; | |
| 578 | - $data['datetime'] = $line['time']; | |
| 579 | - $data['format_source'] = 'boatbeaconapp'; | |
| 580 | - $data['id_source'] = $id_source; | |
| 581 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 582 | - $MI->add($data); | |
| 583 | - unset($data); | |
| 568 | + $data = array(); | |
| 569 | + $data['ident'] = $line['shipname']; | |
| 570 | + $data['callsign'] = $line['callsign']; | |
| 571 | + $data['mmsi'] = $line['mmsi']; | |
| 572 | + $data['speed'] = $line['sog']; | |
| 573 | + if ($line['heading'] != '511') $data['heading'] = $line['heading']; | |
| 574 | + $data['latitude'] = $line['latitude']; | |
| 575 | + $data['longitude'] = $line['longitude']; | |
| 576 | + $data['type_id'] = $line['shiptype']; | |
| 577 | + $data['arrival_code'] = $line['destination']; | |
| 578 | + $data['datetime'] = $line['time']; | |
| 579 | + $data['format_source'] = 'boatbeaconapp'; | |
| 580 | + $data['id_source'] = $id_source; | |
| 581 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 582 | + $MI->add($data); | |
| 583 | + unset($data); | |
| 584 | + } | |
| 584 | 585 | } | 
| 585 | - } | |
| 586 | 586 | } | 
| 587 | 587 | |
| 588 | - } | |
| 589 | - $last_exec[$id]['last'] = time(); | |
| 588 | + } | |
| 589 | + $last_exec[$id]['last'] = time(); | |
| 590 | 590 | } elseif ($value['format'] == 'boatnerd' && | 
| 591 | - ( | |
| 591 | + ( | |
| 592 | 592 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || | 
| 593 | 593 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) | 
| 594 | - ) | |
| 594 | + ) | |
| 595 | 595 |  	) { | 
| 596 | - $buffer = $Common->getData($value['host']); | |
| 597 | -	    if ($buffer != '') { | |
| 596 | + $buffer = $Common->getData($value['host']); | |
| 597 | +		if ($buffer != '') { | |
| 598 | 598 | $all_data = json_decode($buffer,true); | 
| 599 | 599 |  		if (isset($all_data['features'][0]['id'])) { | 
| 600 | -		    foreach ($all_data['features'] as $line) { | |
| 600 | +			foreach ($all_data['features'] as $line) { | |
| 601 | 601 | $data = array(); | 
| 602 | 602 | if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name']; | 
| 603 | 603 | if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign']; | 
| @@ -616,78 +616,78 @@ discard block | ||
| 616 | 616 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | 
| 617 | 617 | if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data); | 
| 618 | 618 | unset($data); | 
| 619 | - } | |
| 619 | + } | |
| 620 | 620 | } | 
| 621 | 621 | |
| 622 | - } | |
| 623 | - $last_exec[$id]['last'] = time(); | |
| 622 | + } | |
| 623 | + $last_exec[$id]['last'] = time(); | |
| 624 | 624 | } elseif ($value['format'] == 'shipplotter' && | 
| 625 | - ( | |
| 625 | + ( | |
| 626 | 626 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || | 
| 627 | 627 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) | 
| 628 | - ) | |
| 628 | + ) | |
| 629 | 629 |  	) { | 
| 630 | - echo 'download...'; | |
| 631 | - $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); | |
| 632 | - echo 'done !'."\n"; | |
| 633 | - if ($buffer != '') $reset = 0; | |
| 634 | -    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); | |
| 635 | -	    $buffer = explode('\n',$buffer); | |
| 636 | -	    foreach ($buffer as $line) { | |
| 630 | + echo 'download...'; | |
| 631 | + $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); | |
| 632 | + echo 'done !'."\n"; | |
| 633 | + if ($buffer != '') $reset = 0; | |
| 634 | +			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); | |
| 635 | +		$buffer = explode('\n',$buffer); | |
| 636 | +		foreach ($buffer as $line) { | |
| 637 | 637 |  		if ($line != '') { | 
| 638 | - $data = array(); | |
| 639 | - $data['mmsi'] = (int)substr($line,0,9); | |
| 640 | -		    $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); | |
| 641 | - //$data['status'] = substr($line,21,2); | |
| 642 | - //$data['type'] = substr($line,24,3); | |
| 643 | - $data['latitude'] = substr($line,29,9); | |
| 644 | - $data['longitude'] = substr($line,41,9); | |
| 645 | - $data['speed'] = round(substr($line,51,5)); | |
| 646 | - //$data['course'] = substr($line,57,5); | |
| 647 | - $data['heading'] = round(substr($line,63,3)); | |
| 648 | - //$data['draft'] = substr($line,67,4); | |
| 649 | - //$data['length'] = substr($line,72,3); | |
| 650 | - //$data['beam'] = substr($line,76,2); | |
| 651 | - $data['ident'] = trim(utf8_encode(substr($line,79,20))); | |
| 652 | - //$data['callsign'] = trim(substr($line,100,7); | |
| 653 | - //$data['dest'] = substr($line,108,20); | |
| 654 | - //$data['etaDate'] = substr($line,129,5); | |
| 655 | - //$data['etaTime'] = substr($line,135,5); | |
| 656 | - $data['format_source'] = 'shipplotter'; | |
| 657 | - $data['id_source'] = $id_source; | |
| 658 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 659 | - //print_r($data); | |
| 660 | - echo 'Add...'."\n"; | |
| 661 | - $MI->add($data); | |
| 662 | - unset($data); | |
| 638 | + $data = array(); | |
| 639 | + $data['mmsi'] = (int)substr($line,0,9); | |
| 640 | +			$data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); | |
| 641 | + //$data['status'] = substr($line,21,2); | |
| 642 | + //$data['type'] = substr($line,24,3); | |
| 643 | + $data['latitude'] = substr($line,29,9); | |
| 644 | + $data['longitude'] = substr($line,41,9); | |
| 645 | + $data['speed'] = round(substr($line,51,5)); | |
| 646 | + //$data['course'] = substr($line,57,5); | |
| 647 | + $data['heading'] = round(substr($line,63,3)); | |
| 648 | + //$data['draft'] = substr($line,67,4); | |
| 649 | + //$data['length'] = substr($line,72,3); | |
| 650 | + //$data['beam'] = substr($line,76,2); | |
| 651 | + $data['ident'] = trim(utf8_encode(substr($line,79,20))); | |
| 652 | + //$data['callsign'] = trim(substr($line,100,7); | |
| 653 | + //$data['dest'] = substr($line,108,20); | |
| 654 | + //$data['etaDate'] = substr($line,129,5); | |
| 655 | + //$data['etaTime'] = substr($line,135,5); | |
| 656 | + $data['format_source'] = 'shipplotter'; | |
| 657 | + $data['id_source'] = $id_source; | |
| 658 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 659 | + //print_r($data); | |
| 660 | + echo 'Add...'."\n"; | |
| 661 | + $MI->add($data); | |
| 662 | + unset($data); | |
| 663 | 663 | } | 
| 664 | - } | |
| 665 | - $last_exec[$id]['last'] = time(); | |
| 664 | + } | |
| 665 | + $last_exec[$id]['last'] = time(); | |
| 666 | 666 |  	//} elseif (($value == 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value == 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) { | 
| 667 | 667 | } elseif ( | 
| 668 | - ( | |
| 668 | + ( | |
| 669 | 669 | $value['format'] == 'whazzup' && | 
| 670 | 670 | ( | 
| 671 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || | |
| 672 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) | |
| 671 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || | |
| 672 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) | |
| 673 | 673 | ) | 
| 674 | - ) || ( | |
| 674 | + ) || ( | |
| 675 | 675 | $value['format'] == 'vatsimtxt' && | 
| 676 | 676 | ( | 
| 677 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || | |
| 678 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) | |
| 677 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || | |
| 678 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) | |
| 679 | + ) | |
| 679 | 680 | ) | 
| 680 | - ) | |
| 681 | 681 |  	) { | 
| 682 | - //$buffer = $Common->getData($hosts[$id]); | |
| 683 | - $buffer = $Common->getData($value['host']); | |
| 684 | -    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); | |
| 685 | -	    $buffer = explode('\n',$buffer); | |
| 686 | - $reset = 0; | |
| 687 | -	    foreach ($buffer as $line) { | |
| 688 | -    		if ($line != '') { | |
| 689 | -    		    $line = explode(':', $line); | |
| 690 | -    		    if (count($line) > 30 && $line[0] != 'callsign') { | |
| 682 | + //$buffer = $Common->getData($hosts[$id]); | |
| 683 | + $buffer = $Common->getData($value['host']); | |
| 684 | +			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); | |
| 685 | +		$buffer = explode('\n',$buffer); | |
| 686 | + $reset = 0; | |
| 687 | +		foreach ($buffer as $line) { | |
| 688 | +			if ($line != '') { | |
| 689 | +				$line = explode(':', $line); | |
| 690 | +				if (count($line) > 30 && $line[0] != 'callsign') { | |
| 691 | 691 | $data = array(); | 
| 692 | 692 | if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; | 
| 693 | 693 | else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; | 
| @@ -700,37 +700,37 @@ discard block | ||
| 700 | 700 | if (isset($line[45])) $data['heading'] = $line[45]; // heading | 
| 701 | 701 | elseif (isset($line[38])) $data['heading'] = $line[38]; // heading | 
| 702 | 702 | $data['latitude'] = $line[5]; // lat | 
| 703 | - $data['longitude'] = $line[6]; // long | |
| 704 | - $data['verticalrate'] = ''; // vertical rate | |
| 705 | - $data['squawk'] = ''; // squawk | |
| 706 | - $data['emergency'] = ''; // emergency | |
| 707 | - $data['waypoints'] = $line[30]; | |
| 703 | + $data['longitude'] = $line[6]; // long | |
| 704 | + $data['verticalrate'] = ''; // vertical rate | |
| 705 | + $data['squawk'] = ''; // squawk | |
| 706 | + $data['emergency'] = ''; // emergency | |
| 707 | + $data['waypoints'] = $line[30]; | |
| 708 | 708 |  			$data['datetime'] = date('Y-m-d H:i:s'); | 
| 709 | 709 |  			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); | 
| 710 | 710 | //if (isset($line[37])) $data['last_update'] = $line[37]; | 
| 711 | - $data['departure_airport_icao'] = $line[11]; | |
| 712 | - $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); | |
| 713 | - $data['arrival_airport_icao'] = $line[13]; | |
| 711 | + $data['departure_airport_icao'] = $line[11]; | |
| 712 | + $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); | |
| 713 | + $data['arrival_airport_icao'] = $line[13]; | |
| 714 | 714 | $data['frequency'] = $line[4]; | 
| 715 | 715 | $data['type'] = $line[18]; | 
| 716 | 716 | $data['range'] = $line[19]; | 
| 717 | 717 | if (isset($line[35])) $data['info'] = $line[35]; | 
| 718 | - $data['id_source'] = $id_source; | |
| 719 | - //$data['arrival_airport_time'] = ; | |
| 720 | -	    		if ($line[9] != '') { | |
| 721 | -	    		    $aircraft_data = explode('/',$line[9]); | |
| 722 | -	    		    if (isset($aircraft_data[1])) { | |
| 723 | - $data['aircraft_icao'] = $aircraft_data[1]; | |
| 724 | - } | |
| 725 | - } | |
| 726 | - /* | |
| 718 | + $data['id_source'] = $id_source; | |
| 719 | + //$data['arrival_airport_time'] = ; | |
| 720 | +				if ($line[9] != '') { | |
| 721 | +					$aircraft_data = explode('/',$line[9]); | |
| 722 | +					if (isset($aircraft_data[1])) { | |
| 723 | + $data['aircraft_icao'] = $aircraft_data[1]; | |
| 724 | + } | |
| 725 | + } | |
| 726 | + /* | |
| 727 | 727 | if ($value == 'whazzup') $data['format_source'] = 'whazzup'; | 
| 728 | 728 | elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; | 
| 729 | 729 | */ | 
| 730 | - $data['format_source'] = $value['format']; | |
| 730 | + $data['format_source'] = $value['format']; | |
| 731 | 731 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | 
| 732 | 732 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; | 
| 733 | - if ($line[3] == 'PILOT') $SI->add($data); | |
| 733 | + if ($line[3] == 'PILOT') $SI->add($data); | |
| 734 | 734 |  			elseif ($line[3] == 'ATC') { | 
| 735 | 735 | //print_r($data); | 
| 736 | 736 |  				$data['info'] = str_replace('^§','<br />',$data['info']); | 
| @@ -751,21 +751,21 @@ discard block | ||
| 751 | 751 | 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']); | 
| 752 | 752 | } | 
| 753 | 753 | } | 
| 754 | - unset($data); | |
| 755 | - } | |
| 756 | - } | |
| 757 | - } | |
| 758 | - //if ($value == 'whazzup') $last_exec['whazzup'] = time(); | |
| 759 | - //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time(); | |
| 760 | - $last_exec[$id]['last'] = time(); | |
| 761 | - } elseif ($value['format'] == 'airwhere' && | |
| 762 | - ( | |
| 763 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || | |
| 764 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) | |
| 765 | - ) | |
| 766 | -    	) { | |
| 767 | -	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20'); | |
| 768 | -	    if ($buffer != '') { | |
| 754 | + unset($data); | |
| 755 | + } | |
| 756 | + } | |
| 757 | + } | |
| 758 | + //if ($value == 'whazzup') $last_exec['whazzup'] = time(); | |
| 759 | + //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time(); | |
| 760 | + $last_exec[$id]['last'] = time(); | |
| 761 | + } elseif ($value['format'] == 'airwhere' && | |
| 762 | + ( | |
| 763 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || | |
| 764 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) | |
| 765 | + ) | |
| 766 | +		) { | |
| 767 | +		$buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20'); | |
| 768 | +		if ($buffer != '') { | |
| 769 | 769 | $all_data = simplexml_load_string($buffer); | 
| 770 | 770 |  		foreach($all_data->children() as $childdata) { | 
| 771 | 771 | $data = array(); | 
| @@ -787,10 +787,10 @@ discard block | ||
| 787 | 787 | $SI->add($data); | 
| 788 | 788 | unset($data); | 
| 789 | 789 | } | 
| 790 | - } | |
| 791 | -	    $Source->deleteOldLocationByType('gs'); | |
| 792 | -	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20'); | |
| 793 | -	    if ($buffer != '') { | |
| 790 | + } | |
| 791 | +		$Source->deleteOldLocationByType('gs'); | |
| 792 | +		$buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20'); | |
| 793 | +		if ($buffer != '') { | |
| 794 | 794 | $all_data = simplexml_load_string($buffer); | 
| 795 | 795 |  		foreach($all_data->children() as $childdata) { | 
| 796 | 796 | $data = array(); | 
| @@ -808,8 +808,8 @@ discard block | ||
| 808 | 808 | } | 
| 809 | 809 | unset($data); | 
| 810 | 810 | } | 
| 811 | - } | |
| 812 | - $last_exec[$id]['last'] = time(); | |
| 811 | + } | |
| 812 | + $last_exec[$id]['last'] = time(); | |
| 813 | 813 | /* | 
| 814 | 814 |  	} if ($value['format'] == 'aircraftlistjson') { | 
| 815 | 815 | print_r($globalSources); | 
| @@ -817,17 +817,17 @@ discard block | ||
| 817 | 817 | echo $globalMinFetch; | 
| 818 | 818 | */ | 
| 819 | 819 | } elseif ($value['format'] == 'aircraftlistjson' && | 
| 820 | - ( | |
| 820 | + ( | |
| 821 | 821 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || | 
| 822 | 822 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) | 
| 823 | - ) | |
| 823 | + ) | |
| 824 | 824 |  	) { | 
| 825 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); | |
| 826 | -	    if ($buffer != '') { | |
| 827 | - $all_data = json_decode($buffer,true); | |
| 825 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); | |
| 826 | +		if ($buffer != '') { | |
| 827 | + $all_data = json_decode($buffer,true); | |
| 828 | 828 |  		if (isset($all_data['acList'])) { | 
| 829 | - $reset = 0; | |
| 830 | -		    foreach ($all_data['acList'] as $line) { | |
| 829 | + $reset = 0; | |
| 830 | +			foreach ($all_data['acList'] as $line) { | |
| 831 | 831 | $data = array(); | 
| 832 | 832 | $data['hex'] = $line['Icao']; // hex | 
| 833 | 833 | if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident | 
| @@ -850,10 +850,10 @@ discard block | ||
| 850 | 850 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | 
| 851 | 851 | if (isset($data['latitude'])) $SI->add($data); | 
| 852 | 852 | unset($data); | 
| 853 | - } | |
| 853 | + } | |
| 854 | 854 |  		} elseif (is_array($all_data)) { | 
| 855 | - $reset = 0; | |
| 856 | -		    foreach ($all_data as $line) { | |
| 855 | + $reset = 0; | |
| 856 | +			foreach ($all_data as $line) { | |
| 857 | 857 | $data = array(); | 
| 858 | 858 | $data['hex'] = $line['hex']; // hex | 
| 859 | 859 | $data['ident'] = $line['flight']; // ident | 
| @@ -873,218 +873,218 @@ discard block | ||
| 873 | 873 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; | 
| 874 | 874 | $SI->add($data); | 
| 875 | 875 | unset($data); | 
| 876 | - } | |
| 876 | + } | |
| 877 | 877 | } | 
| 878 | - } elseif ($globalDebug) echo 'No data'."\n"; | |
| 879 | - //$last_exec['aircraftlistjson'] = time(); | |
| 880 | - $last_exec[$id]['last'] = time(); | |
| 881 | -    	//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { | |
| 882 | - } elseif ($value['format'] == 'planeupdatefaa' && | |
| 883 | - ( | |
| 884 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || | |
| 885 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) | |
| 886 | - ) | |
| 887 | -    	) { | |
| 888 | - $buffer = $Common->getData($value['host']); | |
| 889 | - $all_data = json_decode($buffer,true); | |
| 890 | -	    if (isset($all_data['planes'])) { | |
| 878 | + } elseif ($globalDebug) echo 'No data'."\n"; | |
| 879 | + //$last_exec['aircraftlistjson'] = time(); | |
| 880 | + $last_exec[$id]['last'] = time(); | |
| 881 | +		//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { | |
| 882 | + } elseif ($value['format'] == 'planeupdatefaa' && | |
| 883 | + ( | |
| 884 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || | |
| 885 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) | |
| 886 | + ) | |
| 887 | +		) { | |
| 888 | + $buffer = $Common->getData($value['host']); | |
| 889 | + $all_data = json_decode($buffer,true); | |
| 890 | +		if (isset($all_data['planes'])) { | |
| 891 | 891 | $reset = 0; | 
| 892 | 892 |  		foreach ($all_data['planes'] as $key => $line) { | 
| 893 | - $data = array(); | |
| 894 | - $data['hex'] = $key; // hex | |
| 895 | - $data['ident'] = $line[3]; // ident | |
| 896 | - $data['altitude'] = $line[6]; // altitude | |
| 897 | - $data['speed'] = $line[8]; // speed | |
| 898 | - $data['heading'] = $line[7]; // heading | |
| 899 | - $data['latitude'] = $line[4]; // lat | |
| 900 | - $data['longitude'] = $line[5]; // long | |
| 901 | - //$data['verticalrate'] = $line[]; // verticale rate | |
| 902 | - $data['squawk'] = $line[10]; // squawk | |
| 903 | - $data['emergency'] = ''; // emergency | |
| 904 | - $data['registration'] = $line[2]; | |
| 905 | - $data['aircraft_icao'] = $line[0]; | |
| 906 | -		    $deparr = explode('-',$line[1]); | |
| 907 | -		    if (count($deparr) == 2) { | |
| 893 | + $data = array(); | |
| 894 | + $data['hex'] = $key; // hex | |
| 895 | + $data['ident'] = $line[3]; // ident | |
| 896 | + $data['altitude'] = $line[6]; // altitude | |
| 897 | + $data['speed'] = $line[8]; // speed | |
| 898 | + $data['heading'] = $line[7]; // heading | |
| 899 | + $data['latitude'] = $line[4]; // lat | |
| 900 | + $data['longitude'] = $line[5]; // long | |
| 901 | + //$data['verticalrate'] = $line[]; // verticale rate | |
| 902 | + $data['squawk'] = $line[10]; // squawk | |
| 903 | + $data['emergency'] = ''; // emergency | |
| 904 | + $data['registration'] = $line[2]; | |
| 905 | + $data['aircraft_icao'] = $line[0]; | |
| 906 | +			$deparr = explode('-',$line[1]); | |
| 907 | +			if (count($deparr) == 2) { | |
| 908 | 908 | $data['departure_airport_icao'] = $deparr[0]; | 
| 909 | 909 | $data['arrival_airport_icao'] = $deparr[1]; | 
| 910 | - } | |
| 911 | -		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]); | |
| 912 | - $data['format_source'] = 'planeupdatefaa'; | |
| 913 | - $data['id_source'] = $id_source; | |
| 914 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 915 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; | |
| 916 | - $SI->add($data); | |
| 917 | - unset($data); | |
| 910 | + } | |
| 911 | +			$data['datetime'] = date('Y-m-d H:i:s',$line[9]); | |
| 912 | + $data['format_source'] = 'planeupdatefaa'; | |
| 913 | + $data['id_source'] = $id_source; | |
| 914 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 915 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; | |
| 916 | + $SI->add($data); | |
| 917 | + unset($data); | |
| 918 | + } | |
| 918 | 919 | } | 
| 919 | - } | |
| 920 | - //$last_exec['planeupdatefaa'] = time(); | |
| 921 | - $last_exec[$id]['last'] = time(); | |
| 920 | + //$last_exec['planeupdatefaa'] = time(); | |
| 921 | + $last_exec[$id]['last'] = time(); | |
| 922 | 922 | } elseif ($value['format'] == 'opensky' && | 
| 923 | - ( | |
| 923 | + ( | |
| 924 | 924 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || | 
| 925 | 925 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) | 
| 926 | - ) | |
| 926 | + ) | |
| 927 | 927 |  	) { | 
| 928 | - $buffer = $Common->getData($value['host']); | |
| 929 | - $all_data = json_decode($buffer,true); | |
| 930 | -	    if (isset($all_data['states'])) { | |
| 928 | + $buffer = $Common->getData($value['host']); | |
| 929 | + $all_data = json_decode($buffer,true); | |
| 930 | +		if (isset($all_data['states'])) { | |
| 931 | 931 | $reset = 0; | 
| 932 | 932 |  		foreach ($all_data['states'] as $key => $line) { | 
| 933 | - $data = array(); | |
| 934 | - $data['hex'] = $line[0]; // hex | |
| 935 | - $data['ident'] = trim($line[1]); // ident | |
| 936 | - $data['altitude'] = round($line[7]*3.28084); // altitude | |
| 937 | - $data['speed'] = round($line[9]*1.94384); // speed | |
| 938 | - $data['heading'] = round($line[10]); // heading | |
| 939 | - $data['latitude'] = $line[6]; // lat | |
| 940 | - $data['longitude'] = $line[5]; // long | |
| 941 | - $data['verticalrate'] = $line[11]; // verticale rate | |
| 942 | - //$data['squawk'] = $line[10]; // squawk | |
| 943 | - //$data['emergency'] = ''; // emergency | |
| 944 | - //$data['registration'] = $line[2]; | |
| 945 | - //$data['aircraft_icao'] = $line[0]; | |
| 946 | -		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]); | |
| 947 | - $data['format_source'] = 'opensky'; | |
| 948 | - $data['id_source'] = $id_source; | |
| 949 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 950 | - $SI->add($data); | |
| 951 | - unset($data); | |
| 933 | + $data = array(); | |
| 934 | + $data['hex'] = $line[0]; // hex | |
| 935 | + $data['ident'] = trim($line[1]); // ident | |
| 936 | + $data['altitude'] = round($line[7]*3.28084); // altitude | |
| 937 | + $data['speed'] = round($line[9]*1.94384); // speed | |
| 938 | + $data['heading'] = round($line[10]); // heading | |
| 939 | + $data['latitude'] = $line[6]; // lat | |
| 940 | + $data['longitude'] = $line[5]; // long | |
| 941 | + $data['verticalrate'] = $line[11]; // verticale rate | |
| 942 | + //$data['squawk'] = $line[10]; // squawk | |
| 943 | + //$data['emergency'] = ''; // emergency | |
| 944 | + //$data['registration'] = $line[2]; | |
| 945 | + //$data['aircraft_icao'] = $line[0]; | |
| 946 | +			$data['datetime'] = date('Y-m-d H:i:s',$line[3]); | |
| 947 | + $data['format_source'] = 'opensky'; | |
| 948 | + $data['id_source'] = $id_source; | |
| 949 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 950 | + $SI->add($data); | |
| 951 | + unset($data); | |
| 952 | 952 | } | 
| 953 | - } | |
| 954 | - //$last_exec['planeupdatefaa'] = time(); | |
| 955 | - $last_exec[$id]['last'] = time(); | |
| 953 | + } | |
| 954 | + //$last_exec['planeupdatefaa'] = time(); | |
| 955 | + $last_exec[$id]['last'] = time(); | |
| 956 | 956 |  	//} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) { | 
| 957 | 957 | } elseif ($value['format'] == 'fr24json' && | 
| 958 | - ( | |
| 958 | + ( | |
| 959 | 959 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || | 
| 960 | 960 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) | 
| 961 | - ) | |
| 961 | + ) | |
| 962 | 962 |  	) { | 
| 963 | - //$buffer = $Common->getData($hosts[$id]); | |
| 964 | - $buffer = $Common->getData($value['host']); | |
| 965 | - $all_data = json_decode($buffer,true); | |
| 966 | - if (!empty($all_data)) $reset = 0; | |
| 967 | -	    foreach ($all_data as $key => $line) { | |
| 963 | + //$buffer = $Common->getData($hosts[$id]); | |
| 964 | + $buffer = $Common->getData($value['host']); | |
| 965 | + $all_data = json_decode($buffer,true); | |
| 966 | + if (!empty($all_data)) $reset = 0; | |
| 967 | +		foreach ($all_data as $key => $line) { | |
| 968 | 968 |  		if ($key != 'full_count' && $key != 'version' && $key != 'stats') { | 
| 969 | - $data = array(); | |
| 970 | - $data['hex'] = $line[0]; | |
| 971 | - $data['ident'] = $line[16]; //$line[13] | |
| 972 | - $data['altitude'] = $line[4]; // altitude | |
| 973 | - $data['speed'] = $line[5]; // speed | |
| 974 | - $data['heading'] = $line[3]; // heading | |
| 975 | - $data['latitude'] = $line[1]; // lat | |
| 976 | - $data['longitude'] = $line[2]; // long | |
| 977 | - $data['verticalrate'] = $line[15]; // verticale rate | |
| 978 | - $data['squawk'] = $line[6]; // squawk | |
| 979 | - $data['aircraft_icao'] = $line[8]; | |
| 980 | - $data['registration'] = $line[9]; | |
| 981 | - $data['departure_airport_iata'] = $line[11]; | |
| 982 | - $data['arrival_airport_iata'] = $line[12]; | |
| 983 | - $data['emergency'] = ''; // emergency | |
| 984 | -		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] | |
| 985 | - $data['format_source'] = 'fr24json'; | |
| 986 | - $data['id_source'] = $id_source; | |
| 987 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 988 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; | |
| 989 | - $SI->add($data); | |
| 990 | - unset($data); | |
| 969 | + $data = array(); | |
| 970 | + $data['hex'] = $line[0]; | |
| 971 | + $data['ident'] = $line[16]; //$line[13] | |
| 972 | + $data['altitude'] = $line[4]; // altitude | |
| 973 | + $data['speed'] = $line[5]; // speed | |
| 974 | + $data['heading'] = $line[3]; // heading | |
| 975 | + $data['latitude'] = $line[1]; // lat | |
| 976 | + $data['longitude'] = $line[2]; // long | |
| 977 | + $data['verticalrate'] = $line[15]; // verticale rate | |
| 978 | + $data['squawk'] = $line[6]; // squawk | |
| 979 | + $data['aircraft_icao'] = $line[8]; | |
| 980 | + $data['registration'] = $line[9]; | |
| 981 | + $data['departure_airport_iata'] = $line[11]; | |
| 982 | + $data['arrival_airport_iata'] = $line[12]; | |
| 983 | + $data['emergency'] = ''; // emergency | |
| 984 | +			$data['datetime'] = date('Y-m-d H:i:s'); //$line[10] | |
| 985 | + $data['format_source'] = 'fr24json'; | |
| 986 | + $data['id_source'] = $id_source; | |
| 987 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 988 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; | |
| 989 | + $SI->add($data); | |
| 990 | + unset($data); | |
| 991 | 991 | } | 
| 992 | - } | |
| 993 | - //$last_exec['fr24json'] = time(); | |
| 994 | - $last_exec[$id]['last'] = time(); | |
| 992 | + } | |
| 993 | + //$last_exec['fr24json'] = time(); | |
| 994 | + $last_exec[$id]['last'] = time(); | |
| 995 | 995 |  	//} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { | 
| 996 | 996 | } elseif ($value['format'] == 'radarvirtueljson' && | 
| 997 | - ( | |
| 997 | + ( | |
| 998 | 998 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || | 
| 999 | 999 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) | 
| 1000 | - ) | |
| 1000 | + ) | |
| 1001 | 1001 |  	) { | 
| 1002 | - //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); | |
| 1003 | - $buffer = $Common->getData($value['host'],'get','','','','','150'); | |
| 1004 | - //echo $buffer; | |
| 1005 | -	    $buffer = str_replace(array("\n","\r"),"",$buffer); | |
| 1006 | -	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer); | |
| 1007 | - $all_data = json_decode($buffer,true); | |
| 1008 | -	    if (json_last_error() != JSON_ERROR_NONE) { | |
| 1002 | + //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); | |
| 1003 | + $buffer = $Common->getData($value['host'],'get','','','','','150'); | |
| 1004 | + //echo $buffer; | |
| 1005 | +		$buffer = str_replace(array("\n","\r"),"",$buffer); | |
| 1006 | +		$buffer = preg_replace('/,"num":(.+)/','}',$buffer); | |
| 1007 | + $all_data = json_decode($buffer,true); | |
| 1008 | +		if (json_last_error() != JSON_ERROR_NONE) { | |
| 1009 | 1009 | die(json_last_error_msg()); | 
| 1010 | - } | |
| 1011 | -	    if (isset($all_data['mrkrs'])) { | |
| 1010 | + } | |
| 1011 | +		if (isset($all_data['mrkrs'])) { | |
| 1012 | 1012 | $reset = 0; | 
| 1013 | 1013 |  		foreach ($all_data['mrkrs'] as $key => $line) { | 
| 1014 | -		    if (isset($line['inf'])) { | |
| 1014 | +			if (isset($line['inf'])) { | |
| 1015 | 1015 | $data = array(); | 
| 1016 | 1016 | $data['hex'] = $line['inf']['ia']; | 
| 1017 | 1017 | if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] | 
| 1018 | - $data['altitude'] = round($line['inf']['al']*3.28084); // altitude | |
| 1019 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed | |
| 1020 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading | |
| 1021 | - $data['latitude'] = $line['pt'][0]; // lat | |
| 1022 | - $data['longitude'] = $line['pt'][1]; // long | |
| 1023 | - //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate | |
| 1024 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk | |
| 1025 | - //$data['aircraft_icao'] = $line[8]; | |
| 1026 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; | |
| 1018 | + $data['altitude'] = round($line['inf']['al']*3.28084); // altitude | |
| 1019 | + if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed | |
| 1020 | + if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading | |
| 1021 | + $data['latitude'] = $line['pt'][0]; // lat | |
| 1022 | + $data['longitude'] = $line['pt'][1]; // long | |
| 1023 | + //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate | |
| 1024 | + if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk | |
| 1025 | + //$data['aircraft_icao'] = $line[8]; | |
| 1026 | + if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; | |
| 1027 | 1027 | //$data['departure_airport_iata'] = $line[11]; | 
| 1028 | 1028 | //$data['arrival_airport_iata'] = $line[12]; | 
| 1029 | - //$data['emergency'] = ''; // emergency | |
| 1029 | + //$data['emergency'] = ''; // emergency | |
| 1030 | 1030 |  			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] | 
| 1031 | - $data['format_source'] = 'radarvirtueljson'; | |
| 1032 | - $data['id_source'] = $id_source; | |
| 1031 | + $data['format_source'] = 'radarvirtueljson'; | |
| 1032 | + $data['id_source'] = $id_source; | |
| 1033 | 1033 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | 
| 1034 | 1034 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; | 
| 1035 | 1035 | $SI->add($data); | 
| 1036 | 1036 | unset($data); | 
| 1037 | - } | |
| 1037 | + } | |
| 1038 | + } | |
| 1038 | 1039 | } | 
| 1039 | - } | |
| 1040 | - //$last_exec['radarvirtueljson'] = time(); | |
| 1041 | - $last_exec[$id]['last'] = time(); | |
| 1040 | + //$last_exec['radarvirtueljson'] = time(); | |
| 1041 | + $last_exec[$id]['last'] = time(); | |
| 1042 | 1042 |  	//} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) { | 
| 1043 | 1043 | } elseif ($value['format'] == 'pirepsjson' && | 
| 1044 | - ( | |
| 1044 | + ( | |
| 1045 | 1045 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || | 
| 1046 | 1046 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) | 
| 1047 | - ) | |
| 1047 | + ) | |
| 1048 | 1048 |  	) { | 
| 1049 | - //$buffer = $Common->getData($hosts[$id]); | |
| 1050 | - $buffer = $Common->getData($value['host'].'?'.time()); | |
| 1051 | - $all_data = json_decode(utf8_encode($buffer),true); | |
| 1049 | + //$buffer = $Common->getData($hosts[$id]); | |
| 1050 | + $buffer = $Common->getData($value['host'].'?'.time()); | |
| 1051 | + $all_data = json_decode(utf8_encode($buffer),true); | |
| 1052 | 1052 | |
| 1053 | -	    if (isset($all_data['pireps'])) { | |
| 1053 | +		if (isset($all_data['pireps'])) { | |
| 1054 | 1054 | $reset = 0; | 
| 1055 | -	        foreach ($all_data['pireps'] as $line) { | |
| 1056 | - $data = array(); | |
| 1057 | - $data['id'] = $line['id']; | |
| 1058 | - $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); | |
| 1059 | - $data['ident'] = $line['callsign']; // ident | |
| 1060 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id | |
| 1061 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name | |
| 1062 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude | |
| 1063 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed | |
| 1064 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading | |
| 1065 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route | |
| 1066 | - $data['latitude'] = $line['lat']; // lat | |
| 1067 | - $data['longitude'] = $line['lon']; // long | |
| 1068 | - //$data['verticalrate'] = $line['vrt']; // verticale rate | |
| 1069 | - //$data['squawk'] = $line['squawk']; // squawk | |
| 1070 | - //$data['emergency'] = ''; // emergency | |
| 1071 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; | |
| 1072 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; | |
| 1073 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; | |
| 1074 | - //$data['arrival_airport_time'] = $line['arrtime']; | |
| 1075 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; | |
| 1076 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; | |
| 1077 | - if (isset($line['atis'])) $data['info'] = $line['atis']; | |
| 1078 | - else $data['info'] = ''; | |
| 1079 | - $data['format_source'] = 'pireps'; | |
| 1080 | - $data['id_source'] = $id_source; | |
| 1081 | -		    $data['datetime'] = date('Y-m-d H:i:s'); | |
| 1082 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 1083 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; | |
| 1084 | -		    if ($line['icon'] == 'plane') { | |
| 1055 | +			foreach ($all_data['pireps'] as $line) { | |
| 1056 | + $data = array(); | |
| 1057 | + $data['id'] = $line['id']; | |
| 1058 | + $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); | |
| 1059 | + $data['ident'] = $line['callsign']; // ident | |
| 1060 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id | |
| 1061 | + if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name | |
| 1062 | + if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude | |
| 1063 | + if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed | |
| 1064 | + if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading | |
| 1065 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route | |
| 1066 | + $data['latitude'] = $line['lat']; // lat | |
| 1067 | + $data['longitude'] = $line['lon']; // long | |
| 1068 | + //$data['verticalrate'] = $line['vrt']; // verticale rate | |
| 1069 | + //$data['squawk'] = $line['squawk']; // squawk | |
| 1070 | + //$data['emergency'] = ''; // emergency | |
| 1071 | + if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; | |
| 1072 | + if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; | |
| 1073 | + if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; | |
| 1074 | + //$data['arrival_airport_time'] = $line['arrtime']; | |
| 1075 | + if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; | |
| 1076 | + if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; | |
| 1077 | + if (isset($line['atis'])) $data['info'] = $line['atis']; | |
| 1078 | + else $data['info'] = ''; | |
| 1079 | + $data['format_source'] = 'pireps'; | |
| 1080 | + $data['id_source'] = $id_source; | |
| 1081 | +			$data['datetime'] = date('Y-m-d H:i:s'); | |
| 1082 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 1083 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; | |
| 1084 | +			if ($line['icon'] == 'plane') { | |
| 1085 | 1085 | $SI->add($data); | 
| 1086 | - // print_r($data); | |
| 1087 | -    		    } elseif ($line['icon'] == 'ct') { | |
| 1086 | + // print_r($data); | |
| 1087 | +				} elseif ($line['icon'] == 'ct') { | |
| 1088 | 1088 |  			$data['info'] = str_replace('^§','<br />',$data['info']); | 
| 1089 | 1089 |  			$data['info'] = str_replace('&sect;','',$data['info']); | 
| 1090 | 1090 | $typec = substr($data['ident'],-3); | 
| @@ -1099,148 +1099,148 @@ discard block | ||
| 1099 | 1099 | elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; | 
| 1100 | 1100 | else $data['type'] = 'Observer'; | 
| 1101 | 1101 | 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']); | 
| 1102 | - } | |
| 1103 | - unset($data); | |
| 1102 | + } | |
| 1103 | + unset($data); | |
| 1104 | + } | |
| 1104 | 1105 | } | 
| 1105 | - } | |
| 1106 | - //$last_exec['pirepsjson'] = time(); | |
| 1107 | - $last_exec[$id]['last'] = time(); | |
| 1106 | + //$last_exec['pirepsjson'] = time(); | |
| 1107 | + $last_exec[$id]['last'] = time(); | |
| 1108 | 1108 |  	//} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { | 
| 1109 | 1109 | } elseif ($value['format'] == 'phpvmacars' && | 
| 1110 | - ( | |
| 1110 | + ( | |
| 1111 | 1111 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || | 
| 1112 | 1112 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) | 
| 1113 | - ) | |
| 1113 | + ) | |
| 1114 | 1114 |  	) { | 
| 1115 | - //$buffer = $Common->getData($hosts[$id]); | |
| 1116 | - if ($globalDebug) echo 'Get Data...'."\n"; | |
| 1117 | - $buffer = $Common->getData($value['host']); | |
| 1118 | - $all_data = json_decode($buffer,true); | |
| 1119 | -	    if ($buffer != '' && is_array($all_data)) { | |
| 1115 | + //$buffer = $Common->getData($hosts[$id]); | |
| 1116 | + if ($globalDebug) echo 'Get Data...'."\n"; | |
| 1117 | + $buffer = $Common->getData($value['host']); | |
| 1118 | + $all_data = json_decode($buffer,true); | |
| 1119 | +		if ($buffer != '' && is_array($all_data)) { | |
| 1120 | 1120 | $reset = 0; | 
| 1121 | 1121 |  		foreach ($all_data as $line) { | 
| 1122 | - $data = array(); | |
| 1123 | - //$data['id'] = $line['id']; // id not usable | |
| 1124 | - if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; | |
| 1125 | - $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex | |
| 1126 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; | |
| 1127 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; | |
| 1128 | - $data['ident'] = $line['flightnum']; // ident | |
| 1129 | - $data['altitude'] = $line['alt']; // altitude | |
| 1130 | - $data['speed'] = $line['gs']; // speed | |
| 1131 | - $data['heading'] = $line['heading']; // heading | |
| 1132 | - $data['latitude'] = $line['lat']; // lat | |
| 1133 | - $data['longitude'] = $line['lng']; // long | |
| 1134 | - $data['verticalrate'] = ''; // verticale rate | |
| 1135 | - $data['squawk'] = ''; // squawk | |
| 1136 | - $data['emergency'] = ''; // emergency | |
| 1137 | - //$data['datetime'] = $line['lastupdate']; | |
| 1138 | - //$data['last_update'] = $line['lastupdate']; | |
| 1139 | -	    	    if (isset($value['timezone'])) { | |
| 1140 | - $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); | |
| 1141 | -	    		$datetime->setTimeZone(new DateTimeZone('UTC')); | |
| 1142 | -	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s'); | |
| 1143 | -	    	    } else $data['datetime'] = date('Y-m-d H:i:s'); | |
| 1144 | - $data['departure_airport_icao'] = $line['depicao']; | |
| 1145 | - $data['departure_airport_time'] = $line['deptime']; | |
| 1146 | - $data['arrival_airport_icao'] = $line['arricao']; | |
| 1147 | - $data['arrival_airport_time'] = $line['arrtime']; | |
| 1148 | - $data['registration'] = $line['aircraft']; | |
| 1149 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 1150 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route | |
| 1151 | -		    if (isset($line['aircraftname'])) { | |
| 1122 | + $data = array(); | |
| 1123 | + //$data['id'] = $line['id']; // id not usable | |
| 1124 | + if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; | |
| 1125 | + $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex | |
| 1126 | + if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; | |
| 1127 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; | |
| 1128 | + $data['ident'] = $line['flightnum']; // ident | |
| 1129 | + $data['altitude'] = $line['alt']; // altitude | |
| 1130 | + $data['speed'] = $line['gs']; // speed | |
| 1131 | + $data['heading'] = $line['heading']; // heading | |
| 1132 | + $data['latitude'] = $line['lat']; // lat | |
| 1133 | + $data['longitude'] = $line['lng']; // long | |
| 1134 | + $data['verticalrate'] = ''; // verticale rate | |
| 1135 | + $data['squawk'] = ''; // squawk | |
| 1136 | + $data['emergency'] = ''; // emergency | |
| 1137 | + //$data['datetime'] = $line['lastupdate']; | |
| 1138 | + //$data['last_update'] = $line['lastupdate']; | |
| 1139 | +				if (isset($value['timezone'])) { | |
| 1140 | + $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); | |
| 1141 | +				$datetime->setTimeZone(new DateTimeZone('UTC')); | |
| 1142 | +				$data['datetime'] = $datetime->format('Y-m-d H:i:s'); | |
| 1143 | +				} else $data['datetime'] = date('Y-m-d H:i:s'); | |
| 1144 | + $data['departure_airport_icao'] = $line['depicao']; | |
| 1145 | + $data['departure_airport_time'] = $line['deptime']; | |
| 1146 | + $data['arrival_airport_icao'] = $line['arricao']; | |
| 1147 | + $data['arrival_airport_time'] = $line['arrtime']; | |
| 1148 | + $data['registration'] = $line['aircraft']; | |
| 1149 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 1150 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route | |
| 1151 | +			if (isset($line['aircraftname'])) { | |
| 1152 | 1152 | $line['aircraftname'] = strtoupper($line['aircraftname']); | 
| 1153 | 1153 |  			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); | 
| 1154 | -	    		$aircraft_data = explode('-',$line['aircraftname']); | |
| 1155 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; | |
| 1156 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; | |
| 1157 | -	    		else { | |
| 1158 | -	    		    $aircraft_data = explode(' ',$line['aircraftname']); | |
| 1159 | -	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); | |
| 1160 | -	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); | |
| 1161 | - } | |
| 1162 | - } | |
| 1163 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; | |
| 1164 | - $data['id_source'] = $id_source; | |
| 1165 | - $data['format_source'] = 'phpvmacars'; | |
| 1166 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; | |
| 1167 | - $SI->add($data); | |
| 1168 | - unset($data); | |
| 1154 | +				$aircraft_data = explode('-',$line['aircraftname']); | |
| 1155 | + if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; | |
| 1156 | + elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; | |
| 1157 | +				else { | |
| 1158 | +					$aircraft_data = explode(' ',$line['aircraftname']); | |
| 1159 | +					if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); | |
| 1160 | +					else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); | |
| 1161 | + } | |
| 1162 | + } | |
| 1163 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; | |
| 1164 | + $data['id_source'] = $id_source; | |
| 1165 | + $data['format_source'] = 'phpvmacars'; | |
| 1166 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; | |
| 1167 | + $SI->add($data); | |
| 1168 | + unset($data); | |
| 1169 | 1169 | } | 
| 1170 | 1170 | if ($globalDebug) echo 'No more data...'."\n"; | 
| 1171 | 1171 | unset($buffer); | 
| 1172 | 1172 | unset($all_data); | 
| 1173 | - } | |
| 1174 | - //$last_exec['phpvmacars'] = time(); | |
| 1175 | - $last_exec[$id]['last'] = time(); | |
| 1173 | + } | |
| 1174 | + //$last_exec['phpvmacars'] = time(); | |
| 1175 | + $last_exec[$id]['last'] = time(); | |
| 1176 | 1176 | } elseif ($value['format'] == 'vam' && | 
| 1177 | - ( | |
| 1177 | + ( | |
| 1178 | 1178 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || | 
| 1179 | 1179 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) | 
| 1180 | - ) | |
| 1180 | + ) | |
| 1181 | 1181 |  	) { | 
| 1182 | - //$buffer = $Common->getData($hosts[$id]); | |
| 1183 | - if ($globalDebug) echo 'Get Data...'."\n"; | |
| 1184 | - $buffer = $Common->getData($value['host']); | |
| 1185 | - $all_data = json_decode($buffer,true); | |
| 1186 | -	    if ($buffer != '' && is_array($all_data)) { | |
| 1182 | + //$buffer = $Common->getData($hosts[$id]); | |
| 1183 | + if ($globalDebug) echo 'Get Data...'."\n"; | |
| 1184 | + $buffer = $Common->getData($value['host']); | |
| 1185 | + $all_data = json_decode($buffer,true); | |
| 1186 | +		if ($buffer != '' && is_array($all_data)) { | |
| 1187 | 1187 | $reset = 0; | 
| 1188 | 1188 |  		foreach ($all_data as $line) { | 
| 1189 | - $data = array(); | |
| 1190 | - //$data['id'] = $line['id']; // id not usable | |
| 1191 | - $data['id'] = trim($line['flight_id']); | |
| 1192 | - $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex | |
| 1193 | - $data['pilot_name'] = $line['pilot_name']; | |
| 1194 | - $data['pilot_id'] = $line['pilot_id']; | |
| 1195 | - $data['ident'] = trim($line['callsign']); // ident | |
| 1196 | - $data['altitude'] = $line['altitude']; // altitude | |
| 1197 | - $data['speed'] = $line['gs']; // speed | |
| 1198 | - $data['heading'] = $line['heading']; // heading | |
| 1199 | - $data['latitude'] = $line['latitude']; // lat | |
| 1200 | - $data['longitude'] = $line['longitude']; // long | |
| 1201 | - $data['verticalrate'] = ''; // verticale rate | |
| 1202 | - $data['squawk'] = ''; // squawk | |
| 1203 | - $data['emergency'] = ''; // emergency | |
| 1204 | - //$data['datetime'] = $line['lastupdate']; | |
| 1205 | - $data['last_update'] = $line['last_update']; | |
| 1206 | -		    $data['datetime'] = date('Y-m-d H:i:s'); | |
| 1207 | - $data['departure_airport_icao'] = $line['departure']; | |
| 1208 | - //$data['departure_airport_time'] = $line['departure_time']; | |
| 1209 | - $data['arrival_airport_icao'] = $line['arrival']; | |
| 1210 | - //$data['arrival_airport_time'] = $line['arrival_time']; | |
| 1211 | - //$data['registration'] = $line['aircraft']; | |
| 1212 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route | |
| 1213 | - $data['aircraft_icao'] = $line['plane_type']; | |
| 1214 | - $data['id_source'] = $id_source; | |
| 1215 | - $data['format_source'] = 'vam'; | |
| 1216 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 1217 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; | |
| 1218 | - $SI->add($data); | |
| 1219 | - unset($data); | |
| 1189 | + $data = array(); | |
| 1190 | + //$data['id'] = $line['id']; // id not usable | |
| 1191 | + $data['id'] = trim($line['flight_id']); | |
| 1192 | + $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex | |
| 1193 | + $data['pilot_name'] = $line['pilot_name']; | |
| 1194 | + $data['pilot_id'] = $line['pilot_id']; | |
| 1195 | + $data['ident'] = trim($line['callsign']); // ident | |
| 1196 | + $data['altitude'] = $line['altitude']; // altitude | |
| 1197 | + $data['speed'] = $line['gs']; // speed | |
| 1198 | + $data['heading'] = $line['heading']; // heading | |
| 1199 | + $data['latitude'] = $line['latitude']; // lat | |
| 1200 | + $data['longitude'] = $line['longitude']; // long | |
| 1201 | + $data['verticalrate'] = ''; // verticale rate | |
| 1202 | + $data['squawk'] = ''; // squawk | |
| 1203 | + $data['emergency'] = ''; // emergency | |
| 1204 | + //$data['datetime'] = $line['lastupdate']; | |
| 1205 | + $data['last_update'] = $line['last_update']; | |
| 1206 | +			$data['datetime'] = date('Y-m-d H:i:s'); | |
| 1207 | + $data['departure_airport_icao'] = $line['departure']; | |
| 1208 | + //$data['departure_airport_time'] = $line['departure_time']; | |
| 1209 | + $data['arrival_airport_icao'] = $line['arrival']; | |
| 1210 | + //$data['arrival_airport_time'] = $line['arrival_time']; | |
| 1211 | + //$data['registration'] = $line['aircraft']; | |
| 1212 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route | |
| 1213 | + $data['aircraft_icao'] = $line['plane_type']; | |
| 1214 | + $data['id_source'] = $id_source; | |
| 1215 | + $data['format_source'] = 'vam'; | |
| 1216 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 1217 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; | |
| 1218 | + $SI->add($data); | |
| 1219 | + unset($data); | |
| 1220 | 1220 | } | 
| 1221 | 1221 | if ($globalDebug) echo 'No more data...'."\n"; | 
| 1222 | 1222 | unset($buffer); | 
| 1223 | 1223 | unset($all_data); | 
| 1224 | - } | |
| 1225 | - //$last_exec['phpvmacars'] = time(); | |
| 1226 | - $last_exec[$id]['last'] = time(); | |
| 1224 | + } | |
| 1225 | + //$last_exec['phpvmacars'] = time(); | |
| 1226 | + $last_exec[$id]['last'] = time(); | |
| 1227 | 1227 | } elseif ($value['format'] == 'blitzortung' && | 
| 1228 | - ( | |
| 1228 | + ( | |
| 1229 | 1229 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || | 
| 1230 | 1230 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) | 
| 1231 | - ) | |
| 1231 | + ) | |
| 1232 | 1232 |  	) { | 
| 1233 | - //$buffer = $Common->getData($hosts[$id]); | |
| 1234 | - if ($globalDebug) echo 'Get Data...'."\n"; | |
| 1235 | - $buffer = $Common->getData($value['host']); | |
| 1236 | - $all_data = json_decode($buffer,true); | |
| 1237 | -	    if ($buffer != '') { | |
| 1233 | + //$buffer = $Common->getData($hosts[$id]); | |
| 1234 | + if ($globalDebug) echo 'Get Data...'."\n"; | |
| 1235 | + $buffer = $Common->getData($value['host']); | |
| 1236 | + $all_data = json_decode($buffer,true); | |
| 1237 | +		if ($buffer != '') { | |
| 1238 | 1238 |  		$Source->deleteLocationBySource('blitzortung'); | 
| 1239 | 1239 |  		$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); | 
| 1240 | 1240 |  		$buffer = explode('\n',$buffer); | 
| 1241 | 1241 |  		foreach ($buffer as $buffer_line) { | 
| 1242 | - $line = json_decode($buffer_line,true); | |
| 1243 | -		    if (isset($line['time'])) { | |
| 1242 | + $line = json_decode($buffer_line,true); | |
| 1243 | +			if (isset($line['time'])) { | |
| 1244 | 1244 | $data = array(); | 
| 1245 | 1245 | $data['altitude'] = $line['alt']; // altitude | 
| 1246 | 1246 | $data['latitude'] = $line['lat']; // lat | 
| @@ -1252,94 +1252,94 @@ discard block | ||
| 1252 | 1252 | if ($globalDebug) echo '☈ Lightning added'."\n"; | 
| 1253 | 1253 |  			$Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']); | 
| 1254 | 1254 | unset($data); | 
| 1255 | - } | |
| 1255 | + } | |
| 1256 | 1256 | } | 
| 1257 | 1257 | if ($globalDebug) echo 'No more data...'."\n"; | 
| 1258 | 1258 | unset($buffer); | 
| 1259 | - } | |
| 1260 | - $last_exec[$id]['last'] = time(); | |
| 1259 | + } | |
| 1260 | + $last_exec[$id]['last'] = time(); | |
| 1261 | 1261 |  	//} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') { | 
| 1262 | 1262 |  	} elseif ($value['format'] == 'sbs' || $value['format'] == 'tsv' || $value['format'] == 'raw' || $value['format'] == 'aprs' || $value['format'] == 'famaprs' || $value['format'] == 'beast' || $value['format'] == 'flightgearmp' || $value['format'] == 'flightgearsp' || $value['format'] == 'acars' || $value['format'] == 'acarssbs3' || $value['format'] == 'ais' || $value['format'] == 'vrstcp') { | 
| 1263 | -	    if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); | |
| 1264 | - //$last_exec[$id]['last'] = time(); | |
| 1263 | +		if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); | |
| 1264 | + //$last_exec[$id]['last'] = time(); | |
| 1265 | 1265 | |
| 1266 | - //$read = array( $sockets[$id] ); | |
| 1267 | - $read = $sockets; | |
| 1268 | - $write = NULL; | |
| 1269 | - $e = NULL; | |
| 1270 | - $n = socket_select($read, $write, $e, $timeout); | |
| 1271 | - if ($e != NULL) var_dump($e); | |
| 1272 | -	    if ($n > 0) { | |
| 1266 | + //$read = array( $sockets[$id] ); | |
| 1267 | + $read = $sockets; | |
| 1268 | + $write = NULL; | |
| 1269 | + $e = NULL; | |
| 1270 | + $n = socket_select($read, $write, $e, $timeout); | |
| 1271 | + if ($e != NULL) var_dump($e); | |
| 1272 | +		if ($n > 0) { | |
| 1273 | 1273 | $reset = 0; | 
| 1274 | 1274 |  		foreach ($read as $nb => $r) { | 
| 1275 | - //$value = $formats[$nb]; | |
| 1276 | - $format = $globalSources[$nb]['format']; | |
| 1277 | -		    if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') { | |
| 1275 | + //$value = $formats[$nb]; | |
| 1276 | + $format = $globalSources[$nb]['format']; | |
| 1277 | +			if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') { | |
| 1278 | 1278 | $buffer = @socket_read($r, 6000,PHP_NORMAL_READ); | 
| 1279 | -		    } elseif ($format == 'vrstcp') { | |
| 1279 | +			} elseif ($format == 'vrstcp') { | |
| 1280 | 1280 | $buffer = @socket_read($r, 6000); | 
| 1281 | -		    } else { | |
| 1281 | +			} else { | |
| 1282 | 1282 | $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); | 
| 1283 | - } | |
| 1284 | - //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); | |
| 1285 | - //echo $buffer."\n"; | |
| 1286 | - // lets play nice and handle signals such as ctrl-c/kill properly | |
| 1287 | -		    //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); | |
| 1288 | - $error = false; | |
| 1289 | - //$SI::del(); | |
| 1290 | -		    if ($format == 'vrstcp') { | |
| 1283 | + } | |
| 1284 | + //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); | |
| 1285 | + //echo $buffer."\n"; | |
| 1286 | + // lets play nice and handle signals such as ctrl-c/kill properly | |
| 1287 | +			//if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); | |
| 1288 | + $error = false; | |
| 1289 | + //$SI::del(); | |
| 1290 | +			if ($format == 'vrstcp') { | |
| 1291 | 1291 |  			$buffer = explode('},{',$buffer); | 
| 1292 | -		    } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); | |
| 1293 | - // SBS format is CSV format | |
| 1294 | -		    if ($buffer !== FALSE && $buffer != '') { | |
| 1292 | +			} else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); | |
| 1293 | + // SBS format is CSV format | |
| 1294 | +			if ($buffer !== FALSE && $buffer != '') { | |
| 1295 | 1295 | $tt[$format] = 0; | 
| 1296 | 1296 |  			if ($format == 'acarssbs3') { | 
| 1297 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; | |
| 1298 | - $ACARS->add(trim($buffer)); | |
| 1299 | - $ACARS->deleteLiveAcarsData(); | |
| 1297 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; | |
| 1298 | + $ACARS->add(trim($buffer)); | |
| 1299 | + $ACARS->deleteLiveAcarsData(); | |
| 1300 | 1300 |  			} elseif ($format == 'raw') { | 
| 1301 | - // AVR format | |
| 1302 | - $data = $SBS->parse($buffer); | |
| 1303 | -			    if (is_array($data)) { | |
| 1301 | + // AVR format | |
| 1302 | + $data = $SBS->parse($buffer); | |
| 1303 | +				if (is_array($data)) { | |
| 1304 | 1304 |  				$data['datetime'] = date('Y-m-d H:i:s'); | 
| 1305 | 1305 | $data['format_source'] = 'raw'; | 
| 1306 | 1306 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; | 
| 1307 | 1307 | if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; | 
| 1308 | 1308 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; | 
| 1309 | 1309 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); | 
| 1310 | - } | |
| 1310 | + } | |
| 1311 | 1311 |  			} elseif ($format == 'ais') { | 
| 1312 | - $ais_data = $AIS->parse_line(trim($buffer)); | |
| 1313 | - $data = array(); | |
| 1314 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; | |
| 1315 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; | |
| 1316 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; | |
| 1317 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; | |
| 1318 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; | |
| 1319 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; | |
| 1320 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; | |
| 1321 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; | |
| 1322 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; | |
| 1323 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; | |
| 1324 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; | |
| 1325 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; | |
| 1326 | -			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); | |
| 1327 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 1328 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; | |
| 1329 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; | |
| 1312 | + $ais_data = $AIS->parse_line(trim($buffer)); | |
| 1313 | + $data = array(); | |
| 1314 | + if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; | |
| 1315 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; | |
| 1316 | + if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; | |
| 1317 | + if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; | |
| 1318 | + if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; | |
| 1319 | + if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; | |
| 1320 | + if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; | |
| 1321 | + if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; | |
| 1322 | + if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; | |
| 1323 | + if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; | |
| 1324 | + if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; | |
| 1325 | + if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; | |
| 1326 | +				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); | |
| 1327 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 1328 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; | |
| 1329 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; | |
| 1330 | 1330 | |
| 1331 | -			    if (isset($ais_data['timestamp'])) { | |
| 1331 | +				if (isset($ais_data['timestamp'])) { | |
| 1332 | 1332 |  				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); | 
| 1333 | -			    } else { | |
| 1333 | +				} else { | |
| 1334 | 1334 |  				$data['datetime'] = date('Y-m-d H:i:s'); | 
| 1335 | - } | |
| 1336 | - $data['format_source'] = 'aisnmea'; | |
| 1337 | - $data['id_source'] = $id_source; | |
| 1338 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); | |
| 1339 | - unset($data); | |
| 1340 | -                        } elseif ($format == 'flightgearsp') { | |
| 1341 | - //echo $buffer."\n"; | |
| 1342 | -                    	    if (strlen($buffer) > 5) { | |
| 1335 | + } | |
| 1336 | + $data['format_source'] = 'aisnmea'; | |
| 1337 | + $data['id_source'] = $id_source; | |
| 1338 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); | |
| 1339 | + unset($data); | |
| 1340 | +						} elseif ($format == 'flightgearsp') { | |
| 1341 | + //echo $buffer."\n"; | |
| 1342 | +							if (strlen($buffer) > 5) { | |
| 1343 | 1343 |  				$line = explode(',',$buffer); | 
| 1344 | 1344 | $data = array(); | 
| 1345 | 1345 | //XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p | 
| @@ -1356,38 +1356,38 @@ discard block | ||
| 1356 | 1356 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; | 
| 1357 | 1357 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); | 
| 1358 | 1358 | //$send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); | 
| 1359 | - } | |
| 1360 | -                        } elseif ($format == 'acars') { | |
| 1361 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; | |
| 1362 | - $ACARS->add(trim($buffer)); | |
| 1363 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); | |
| 1364 | - $ACARS->deleteLiveAcarsData(); | |
| 1359 | + } | |
| 1360 | +						} elseif ($format == 'acars') { | |
| 1361 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; | |
| 1362 | + $ACARS->add(trim($buffer)); | |
| 1363 | + socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); | |
| 1364 | + $ACARS->deleteLiveAcarsData(); | |
| 1365 | 1365 |  			} elseif ($format == 'flightgearmp') { | 
| 1366 | -			    if (substr($buffer,0,1) != '#') { | |
| 1366 | +				if (substr($buffer,0,1) != '#') { | |
| 1367 | 1367 | $data = array(); | 
| 1368 | 1368 | //echo $buffer."\n"; | 
| 1369 | 1369 |  				$line = explode(' ',$buffer); | 
| 1370 | 1370 |  				if (count($line) == 11) { | 
| 1371 | -				    $userserver = explode('@',$line[0]); | |
| 1372 | - $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex | |
| 1373 | - $data['ident'] = $userserver[0]; | |
| 1374 | - $data['registration'] = $userserver[0]; | |
| 1375 | - $data['latitude'] = $line[4]; | |
| 1376 | - $data['longitude'] = $line[5]; | |
| 1377 | - $data['altitude'] = $line[6]; | |
| 1378 | -				    $data['datetime'] = date('Y-m-d H:i:s'); | |
| 1379 | - $aircraft_type = $line[10]; | |
| 1380 | -				    $aircraft_type = preg_split(':/:',$aircraft_type); | |
| 1381 | - $data['aircraft_name'] = substr(end($aircraft_type),0,-4); | |
| 1382 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 1383 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); | |
| 1371 | +					$userserver = explode('@',$line[0]); | |
| 1372 | + $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex | |
| 1373 | + $data['ident'] = $userserver[0]; | |
| 1374 | + $data['registration'] = $userserver[0]; | |
| 1375 | + $data['latitude'] = $line[4]; | |
| 1376 | + $data['longitude'] = $line[5]; | |
| 1377 | + $data['altitude'] = $line[6]; | |
| 1378 | +					$data['datetime'] = date('Y-m-d H:i:s'); | |
| 1379 | + $aircraft_type = $line[10]; | |
| 1380 | +					$aircraft_type = preg_split(':/:',$aircraft_type); | |
| 1381 | + $data['aircraft_name'] = substr(end($aircraft_type),0,-4); | |
| 1382 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 1383 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); | |
| 1384 | + } | |
| 1384 | 1385 | } | 
| 1385 | - } | |
| 1386 | 1386 |  			} elseif ($format == 'beast') { | 
| 1387 | - echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; | |
| 1388 | - die; | |
| 1387 | + echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; | |
| 1388 | + die; | |
| 1389 | 1389 |  			} elseif ($format == 'vrstcp') { | 
| 1390 | -			    foreach($buffer as $all_data) { | |
| 1390 | +				foreach($buffer as $all_data) { | |
| 1391 | 1391 |  				$line = json_decode('{'.$all_data.'}',true); | 
| 1392 | 1392 | $data = array(); | 
| 1393 | 1393 | if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex | 
| @@ -1407,148 +1407,148 @@ discard block | ||
| 1407 | 1407 | */ | 
| 1408 | 1408 |  				$data['datetime'] = date('Y-m-d H:i:s'); | 
| 1409 | 1409 | if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; | 
| 1410 | - $data['format_source'] = 'vrstcp'; | |
| 1410 | + $data['format_source'] = 'vrstcp'; | |
| 1411 | 1411 | $data['id_source'] = $id_source; | 
| 1412 | 1412 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; | 
| 1413 | 1413 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; | 
| 1414 | 1414 | if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); | 
| 1415 | 1415 | unset($data); | 
| 1416 | - } | |
| 1416 | + } | |
| 1417 | 1417 |  			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') { | 
| 1418 | -			    $line = explode("\t", $buffer); | |
| 1419 | -			    for($k = 0; $k < count($line); $k=$k+2) { | |
| 1418 | +				$line = explode("\t", $buffer); | |
| 1419 | +				for($k = 0; $k < count($line); $k=$k+2) { | |
| 1420 | 1420 | $key = $line[$k]; | 
| 1421 | - $lined[$key] = $line[$k+1]; | |
| 1422 | - } | |
| 1423 | -    			    if (count($lined) > 3) { | |
| 1424 | - $data['hex'] = $lined['hexid']; | |
| 1425 | -    				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; | |
| 1426 | -    				$data['datetime'] = date('Y-m-d H:i:s');; | |
| 1427 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; | |
| 1428 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; | |
| 1429 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; | |
| 1430 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; | |
| 1431 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; | |
| 1432 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; | |
| 1433 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; | |
| 1434 | - $data['id_source'] = $id_source; | |
| 1435 | - $data['format_source'] = 'tsv'; | |
| 1436 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; | |
| 1437 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; | |
| 1421 | + $lined[$key] = $line[$k+1]; | |
| 1422 | + } | |
| 1423 | +					if (count($lined) > 3) { | |
| 1424 | + $data['hex'] = $lined['hexid']; | |
| 1425 | +					//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; | |
| 1426 | +					$data['datetime'] = date('Y-m-d H:i:s');; | |
| 1427 | + if (isset($lined['ident'])) $data['ident'] = $lined['ident']; | |
| 1428 | + if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; | |
| 1429 | + if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; | |
| 1430 | + if (isset($lined['speed'])) $data['speed'] = $lined['speed']; | |
| 1431 | + if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; | |
| 1432 | + if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; | |
| 1433 | + if (isset($lined['heading'])) $data['heading'] = $lined['heading']; | |
| 1434 | + $data['id_source'] = $id_source; | |
| 1435 | + $data['format_source'] = 'tsv'; | |
| 1436 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; | |
| 1437 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; | |
| 1438 | 1438 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; | 
| 1439 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); | |
| 1440 | - unset($lined); | |
| 1441 | - unset($data); | |
| 1442 | - } else $error = true; | |
| 1439 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); | |
| 1440 | + unset($lined); | |
| 1441 | + unset($data); | |
| 1442 | + } else $error = true; | |
| 1443 | 1443 |  			} elseif ($format == 'aprs' && $use_aprs) { | 
| 1444 | -			    if ($aprs_connect == 0) { | |
| 1444 | +				if ($aprs_connect == 0) { | |
| 1445 | 1445 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); | 
| 1446 | 1446 | $aprs_connect = 1; | 
| 1447 | - } | |
| 1447 | + } | |
| 1448 | 1448 | |
| 1449 | -			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { | |
| 1449 | +				if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { | |
| 1450 | 1450 | $aprs_last_tx = time(); | 
| 1451 | 1451 | $data_aprs = "# Keep alive"; | 
| 1452 | 1452 | $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); | 
| 1453 | - } | |
| 1453 | + } | |
| 1454 | 1454 | |
| 1455 | - //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; | |
| 1456 | - //echo 'APRS data : '.$buffer."\n"; | |
| 1457 | -			    $buffer = str_replace('APRS <- ','',$buffer); | |
| 1458 | -			    $buffer = str_replace('APRS -> ','',$buffer); | |
| 1459 | - //echo $buffer."\n"; | |
| 1460 | -			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { | |
| 1455 | + //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; | |
| 1456 | + //echo 'APRS data : '.$buffer."\n"; | |
| 1457 | +				$buffer = str_replace('APRS <- ','',$buffer); | |
| 1458 | +				$buffer = str_replace('APRS -> ','',$buffer); | |
| 1459 | + //echo $buffer."\n"; | |
| 1460 | +				if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { | |
| 1461 | 1461 | $line = $APRS->parse($buffer); | 
| 1462 | 1462 |  				//if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) { | 
| 1463 | 1463 |  				if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) { | 
| 1464 | - $aprs_last_tx = time(); | |
| 1465 | - $data = array(); | |
| 1466 | - //print_r($line); | |
| 1467 | - if (isset($line['address'])) $data['hex'] = $line['address']; | |
| 1468 | - if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; | |
| 1469 | - if (isset($line['imo'])) $data['imo'] = $line['imo']; | |
| 1470 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; | |
| 1471 | - if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code']; | |
| 1472 | - if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date']; | |
| 1473 | - if (isset($line['type_id'])) $data['type_id'] = $line['typeid']; | |
| 1474 | - if (isset($line['status_id'])) $data['status_id'] = $line['statusid']; | |
| 1475 | -				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); | |
| 1476 | -				    else $data['datetime'] = date('Y-m-d H:i:s'); | |
| 1477 | -				    //$data['datetime'] = date('Y-m-d H:i:s'); | |
| 1478 | - if (isset($line['ident'])) $data['ident'] = $line['ident']; | |
| 1479 | - $data['latitude'] = $line['latitude']; | |
| 1480 | - $data['longitude'] = $line['longitude']; | |
| 1481 | - //$data['verticalrate'] = $line[16]; | |
| 1482 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; | |
| 1483 | - //else $data['speed'] = 0; | |
| 1484 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; | |
| 1485 | - if (isset($line['comment'])) $data['comment'] = $line['comment']; | |
| 1486 | - if (isset($line['symbol'])) $data['type'] = $line['symbol']; | |
| 1487 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; | |
| 1488 | - //else $data['heading'] = 0; | |
| 1489 | - if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; | |
| 1490 | - //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; | |
| 1491 | - if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true; | |
| 1492 | - elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false; | |
| 1493 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 1494 | - elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; | |
| 1495 | - $data['id_source'] = $id_source; | |
| 1496 | - if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; | |
| 1497 | - else $data['format_source'] = 'aprs'; | |
| 1498 | - $data['source_name'] = $line['source']; | |
| 1499 | - if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; | |
| 1500 | - else $data['source_type'] = 'flarm'; | |
| 1501 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; | |
| 1502 | -				    $currentdate = date('Y-m-d H:i:s'); | |
| 1503 | - $aprsdate = strtotime($data['datetime']); | |
| 1504 | - if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL'; | |
| 1505 | - // Accept data if time <= system time + 20s | |
| 1506 | -				    //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'])))) { | |
| 1507 | -				    if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { | |
| 1464 | + $aprs_last_tx = time(); | |
| 1465 | + $data = array(); | |
| 1466 | + //print_r($line); | |
| 1467 | + if (isset($line['address'])) $data['hex'] = $line['address']; | |
| 1468 | + if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; | |
| 1469 | + if (isset($line['imo'])) $data['imo'] = $line['imo']; | |
| 1470 | + if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; | |
| 1471 | + if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code']; | |
| 1472 | + if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date']; | |
| 1473 | + if (isset($line['type_id'])) $data['type_id'] = $line['typeid']; | |
| 1474 | + if (isset($line['status_id'])) $data['status_id'] = $line['statusid']; | |
| 1475 | +					if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); | |
| 1476 | +					else $data['datetime'] = date('Y-m-d H:i:s'); | |
| 1477 | +					//$data['datetime'] = date('Y-m-d H:i:s'); | |
| 1478 | + if (isset($line['ident'])) $data['ident'] = $line['ident']; | |
| 1479 | + $data['latitude'] = $line['latitude']; | |
| 1480 | + $data['longitude'] = $line['longitude']; | |
| 1481 | + //$data['verticalrate'] = $line[16]; | |
| 1482 | + if (isset($line['speed'])) $data['speed'] = $line['speed']; | |
| 1483 | + //else $data['speed'] = 0; | |
| 1484 | + if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; | |
| 1485 | + if (isset($line['comment'])) $data['comment'] = $line['comment']; | |
| 1486 | + if (isset($line['symbol'])) $data['type'] = $line['symbol']; | |
| 1487 | + if (isset($line['heading'])) $data['heading'] = $line['heading']; | |
| 1488 | + //else $data['heading'] = 0; | |
| 1489 | + if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; | |
| 1490 | + //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; | |
| 1491 | + if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true; | |
| 1492 | + elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false; | |
| 1493 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 1494 | + elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; | |
| 1495 | + $data['id_source'] = $id_source; | |
| 1496 | + if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; | |
| 1497 | + else $data['format_source'] = 'aprs'; | |
| 1498 | + $data['source_name'] = $line['source']; | |
| 1499 | + if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; | |
| 1500 | + else $data['source_type'] = 'flarm'; | |
| 1501 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; | |
| 1502 | +					$currentdate = date('Y-m-d H:i:s'); | |
| 1503 | + $aprsdate = strtotime($data['datetime']); | |
| 1504 | + if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL'; | |
| 1505 | + // Accept data if time <= system time + 20s | |
| 1506 | +					//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'])))) { | |
| 1507 | +					if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { | |
| 1508 | 1508 | $send = $SI->add($data); | 
| 1509 | -				    } elseif ($data['source_type'] == 'ais') { | |
| 1509 | +					} elseif ($data['source_type'] == 'ais') { | |
| 1510 | 1510 | if (isset($globalMarine) && $globalMarine) $send = $MI->add($data); | 
| 1511 | -				    } elseif (isset($line['stealth'])) { | |
| 1511 | +					} elseif (isset($line['stealth'])) { | |
| 1512 | 1512 | if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; | 
| 1513 | 1513 | else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; | 
| 1514 | - } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( | |
| 1515 | - //$line['symbol'] == 'Balloon' || | |
| 1516 | - $line['symbol'] == 'Glider' || | |
| 1517 | -					    $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) { | |
| 1518 | - if ($line['symbol'] == 'Ballon') $data['aircraft_icao'] = 'BALL'; | |
| 1519 | - if ($line['symbol'] == 'Glider') $data['aircraft_icao'] = 'PARAGLIDER'; | |
| 1520 | - $send = $SI->add($data); | |
| 1521 | - } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( | |
| 1522 | - $line['symbol'] == 'Yacht (Sail)' || | |
| 1523 | -					    $line['symbol'] == 'Ship (Power Boat)')) { | |
| 1524 | - $send = $MI->add($data); | |
| 1525 | - } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( | |
| 1526 | - $line['symbol'] == 'Car' || | |
| 1527 | - $line['symbol'] == 'Ambulance' || | |
| 1528 | - $line['symbol'] == 'Van' || | |
| 1529 | - $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || | |
| 1530 | - $line['symbol'] == 'Motorcycle' || | |
| 1531 | - $line['symbol'] == 'Tractor' || | |
| 1532 | - $line['symbol'] == 'Police' || | |
| 1533 | - $line['symbol'] == 'Bike' || | |
| 1534 | - $line['symbol'] == 'Jogger' || | |
| 1535 | - $line['symbol'] == 'Horse' || | |
| 1536 | - $line['symbol'] == 'Bus' || | |
| 1537 | - $line['symbol'] == 'Jeep' || | |
| 1538 | - $line['symbol'] == 'Recreational Vehicle' || | |
| 1539 | - $line['symbol'] == 'Yacht (Sail)' || | |
| 1540 | - $line['symbol'] == 'Ship (Power Boat)' || | |
| 1541 | - $line['symbol'] == 'Firetruck' || | |
| 1542 | - $line['symbol'] == 'Balloon' || $line['symbol'] == 'Glider' || | |
| 1543 | - $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter' || | |
| 1544 | - $line['symbol'] == 'SUV' || | |
| 1545 | - $line['symbol'] == 'Snowmobile' || | |
| 1546 | -					    $line['symbol'] == 'Mobile Satellite Station')) { | |
| 1547 | -				    //} 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') { | |
| 1514 | + } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( | |
| 1515 | + //$line['symbol'] == 'Balloon' || | |
| 1516 | + $line['symbol'] == 'Glider' || | |
| 1517 | +						$line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) { | |
| 1518 | + if ($line['symbol'] == 'Ballon') $data['aircraft_icao'] = 'BALL'; | |
| 1519 | + if ($line['symbol'] == 'Glider') $data['aircraft_icao'] = 'PARAGLIDER'; | |
| 1520 | + $send = $SI->add($data); | |
| 1521 | + } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( | |
| 1522 | + $line['symbol'] == 'Yacht (Sail)' || | |
| 1523 | +						$line['symbol'] == 'Ship (Power Boat)')) { | |
| 1524 | + $send = $MI->add($data); | |
| 1525 | + } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( | |
| 1526 | + $line['symbol'] == 'Car' || | |
| 1527 | + $line['symbol'] == 'Ambulance' || | |
| 1528 | + $line['symbol'] == 'Van' || | |
| 1529 | + $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || | |
| 1530 | + $line['symbol'] == 'Motorcycle' || | |
| 1531 | + $line['symbol'] == 'Tractor' || | |
| 1532 | + $line['symbol'] == 'Police' || | |
| 1533 | + $line['symbol'] == 'Bike' || | |
| 1534 | + $line['symbol'] == 'Jogger' || | |
| 1535 | + $line['symbol'] == 'Horse' || | |
| 1536 | + $line['symbol'] == 'Bus' || | |
| 1537 | + $line['symbol'] == 'Jeep' || | |
| 1538 | + $line['symbol'] == 'Recreational Vehicle' || | |
| 1539 | + $line['symbol'] == 'Yacht (Sail)' || | |
| 1540 | + $line['symbol'] == 'Ship (Power Boat)' || | |
| 1541 | + $line['symbol'] == 'Firetruck' || | |
| 1542 | + $line['symbol'] == 'Balloon' || $line['symbol'] == 'Glider' || | |
| 1543 | + $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter' || | |
| 1544 | + $line['symbol'] == 'SUV' || | |
| 1545 | + $line['symbol'] == 'Snowmobile' || | |
| 1546 | +						$line['symbol'] == 'Mobile Satellite Station')) { | |
| 1547 | +					//} 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') { | |
| 1548 | 1548 |  				//    } 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') { | 
| 1549 | 1549 | //echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n"; | 
| 1550 | 1550 | if (isset($globalTracker) && $globalTracker) $send = $TI->add($data); | 
| 1551 | -				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { | |
| 1551 | +					} elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { | |
| 1552 | 1552 | if (!isset($data['altitude'])) $data['altitude'] = 0; | 
| 1553 | 1553 |  					$Source->deleteOldLocationByType('gs'); | 
| 1554 | 1554 |  					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) { | 
| @@ -1556,7 +1556,7 @@ discard block | ||
| 1556 | 1556 |  					} else { | 
| 1557 | 1557 | $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); | 
| 1558 | 1558 | } | 
| 1559 | -				    } elseif (isset($line['symbol']) && $line['symbol'] == 'Weather Station') { | |
| 1559 | +					} elseif (isset($line['symbol']) && $line['symbol'] == 'Weather Station') { | |
| 1560 | 1560 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; | 
| 1561 | 1561 | if ($globalDebug) echo '# Weather Station added'."\n"; | 
| 1562 | 1562 |  					$Source->deleteOldLocationByType('wx'); | 
| @@ -1566,7 +1566,7 @@ discard block | ||
| 1566 | 1566 |  					} else { | 
| 1567 | 1567 | $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data); | 
| 1568 | 1568 | } | 
| 1569 | -				    } elseif (isset($line['symbol']) && $line['symbol'] == 'Lightning') { | |
| 1569 | +					} elseif (isset($line['symbol']) && $line['symbol'] == 'Lightning') { | |
| 1570 | 1570 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; | 
| 1571 | 1571 | if ($globalDebug) echo '☈ Lightning added'."\n"; | 
| 1572 | 1572 |  					$Source->deleteOldLocationByType('lightning'); | 
| @@ -1575,11 +1575,11 @@ discard block | ||
| 1575 | 1575 |  					} else { | 
| 1576 | 1576 | $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']); | 
| 1577 | 1577 | } | 
| 1578 | -				    } elseif ($globalDebug) { | |
| 1579 | - echo '/!\ Not added: '.$buffer."\n"; | |
| 1580 | - print_r($line); | |
| 1581 | - } | |
| 1582 | - unset($data); | |
| 1578 | +					} elseif ($globalDebug) { | |
| 1579 | + echo '/!\ Not added: '.$buffer."\n"; | |
| 1580 | + print_r($line); | |
| 1581 | + } | |
| 1582 | + unset($data); | |
| 1583 | 1583 | } | 
| 1584 | 1584 |  				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { | 
| 1585 | 1585 | $Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']); | 
| @@ -1598,12 +1598,12 @@ discard block | ||
| 1598 | 1598 |  				} elseif (!isset($globalSources[$nb]['last_weather_clean'])) { | 
| 1599 | 1599 | $globalSources[$nb]['last_weather_clean'] = time(); | 
| 1600 | 1600 | } | 
| 1601 | - } | |
| 1601 | + } | |
| 1602 | 1602 |  			} else { | 
| 1603 | -			    $line = explode(',', $buffer); | |
| 1604 | -    			    if (count($line) > 20) { | |
| 1605 | - $data['hex'] = $line[4]; | |
| 1606 | - /* | |
| 1603 | +				$line = explode(',', $buffer); | |
| 1604 | +					if (count($line) > 20) { | |
| 1605 | + $data['hex'] = $line[4]; | |
| 1606 | + /* | |
| 1607 | 1607 | $data['datetime'] = $line[6].' '.$line[7]; | 
| 1608 | 1608 | date_default_timezone_set($globalTimezone); | 
| 1609 | 1609 | $datetime = new DateTime($data['datetime']); | 
| @@ -1611,30 +1611,30 @@ discard block | ||
| 1611 | 1611 |      					$data['datetime'] = $datetime->format('Y-m-d H:i:s'); | 
| 1612 | 1612 |      					date_default_timezone_set('UTC'); | 
| 1613 | 1613 | */ | 
| 1614 | - // Force datetime to current UTC datetime | |
| 1615 | -    				date_default_timezone_set('UTC'); | |
| 1616 | -    				$data['datetime'] = date('Y-m-d H:i:s'); | |
| 1617 | - $data['ident'] = trim($line[10]); | |
| 1618 | - $data['latitude'] = $line[14]; | |
| 1619 | - $data['longitude'] = $line[15]; | |
| 1620 | - $data['verticalrate'] = $line[16]; | |
| 1621 | - $data['emergency'] = $line[20]; | |
| 1622 | - $data['speed'] = $line[12]; | |
| 1623 | - $data['squawk'] = $line[17]; | |
| 1624 | - $data['altitude'] = $line[11]; | |
| 1625 | - $data['heading'] = $line[13]; | |
| 1626 | - $data['ground'] = $line[21]; | |
| 1627 | - $data['emergency'] = $line[19]; | |
| 1628 | - $data['format_source'] = 'sbs'; | |
| 1614 | + // Force datetime to current UTC datetime | |
| 1615 | +					date_default_timezone_set('UTC'); | |
| 1616 | +					$data['datetime'] = date('Y-m-d H:i:s'); | |
| 1617 | + $data['ident'] = trim($line[10]); | |
| 1618 | + $data['latitude'] = $line[14]; | |
| 1619 | + $data['longitude'] = $line[15]; | |
| 1620 | + $data['verticalrate'] = $line[16]; | |
| 1621 | + $data['emergency'] = $line[20]; | |
| 1622 | + $data['speed'] = $line[12]; | |
| 1623 | + $data['squawk'] = $line[17]; | |
| 1624 | + $data['altitude'] = $line[11]; | |
| 1625 | + $data['heading'] = $line[13]; | |
| 1626 | + $data['ground'] = $line[21]; | |
| 1627 | + $data['emergency'] = $line[19]; | |
| 1628 | + $data['format_source'] = 'sbs'; | |
| 1629 | 1629 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; | 
| 1630 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; | |
| 1630 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; | |
| 1631 | 1631 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; | 
| 1632 | - $data['id_source'] = $id_source; | |
| 1633 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); | |
| 1634 | - else $error = true; | |
| 1635 | - unset($data); | |
| 1636 | - } else $error = true; | |
| 1637 | -			    if ($error) { | |
| 1632 | + $data['id_source'] = $id_source; | |
| 1633 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); | |
| 1634 | + else $error = true; | |
| 1635 | + unset($data); | |
| 1636 | + } else $error = true; | |
| 1637 | +				if ($error) { | |
| 1638 | 1638 |  				if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) {  | 
| 1639 | 1639 | if ($globalDebug) echo "Not a message. Ignoring... \n"; | 
| 1640 | 1640 |  				} else { | 
| @@ -1650,13 +1650,13 @@ discard block | ||
| 1650 | 1650 | connect_all($sourceer); | 
| 1651 | 1651 | $sourceer = array(); | 
| 1652 | 1652 | } | 
| 1653 | - } | |
| 1653 | + } | |
| 1654 | 1654 | } | 
| 1655 | 1655 | // Sleep for xxx microseconds | 
| 1656 | 1656 | if (isset($globalSBSSleep)) usleep($globalSBSSleep); | 
| 1657 | -		    } else { | |
| 1657 | +			} else { | |
| 1658 | 1658 |  			if ($format == 'flightgearmp') { | 
| 1659 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; | |
| 1659 | + if ($globalDebug) echo "Reconnect FlightGear MP..."; | |
| 1660 | 1660 | //@socket_close($r); | 
| 1661 | 1661 | sleep($globalMinFetch); | 
| 1662 | 1662 | $sourcefg[$nb] = $globalSources[$nb]; | 
| @@ -1665,9 +1665,9 @@ discard block | ||
| 1665 | 1665 | break; | 
| 1666 | 1666 | |
| 1667 | 1667 |  			} elseif ($format != 'acars' && $format != 'flightgearsp') { | 
| 1668 | - if (isset($tt[$format])) $tt[$format]++; | |
| 1669 | - else $tt[$format] = 0; | |
| 1670 | -			    if ($tt[$format] > 30) { | |
| 1668 | + if (isset($tt[$format])) $tt[$format]++; | |
| 1669 | + else $tt[$format] = 0; | |
| 1670 | +				if ($tt[$format] > 30) { | |
| 1671 | 1671 | if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; | 
| 1672 | 1672 | //@socket_close($r); | 
| 1673 | 1673 | sleep(2); | 
| @@ -1678,23 +1678,23 @@ discard block | ||
| 1678 | 1678 | //connect_all($globalSources); | 
| 1679 | 1679 | $tt[$format]=0; | 
| 1680 | 1680 | break; | 
| 1681 | - } | |
| 1681 | + } | |
| 1682 | + } | |
| 1682 | 1683 | } | 
| 1683 | - } | |
| 1684 | 1684 | } | 
| 1685 | -	    } else { | |
| 1685 | +		} else { | |
| 1686 | 1686 | $error = socket_strerror(socket_last_error()); | 
| 1687 | 1687 |  		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { | 
| 1688 | 1688 | if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; | 
| 1689 | 1689 | if (isset($globalDebug)) echo "Restarting...\n"; | 
| 1690 | 1690 | // Restart the script if possible | 
| 1691 | 1691 |  			if (is_array($sockets)) { | 
| 1692 | - if ($globalDebug) echo "Shutdown all sockets..."; | |
| 1692 | + if ($globalDebug) echo "Shutdown all sockets..."; | |
| 1693 | 1693 | |
| 1694 | -			    foreach ($sockets as $sock) { | |
| 1694 | +				foreach ($sockets as $sock) { | |
| 1695 | 1695 | @socket_shutdown($sock,2); | 
| 1696 | 1696 | @socket_close($sock); | 
| 1697 | - } | |
| 1697 | + } | |
| 1698 | 1698 | |
| 1699 | 1699 | } | 
| 1700 | 1700 | if ($globalDebug) echo "Waiting..."; | 
| @@ -1709,15 +1709,15 @@ discard block | ||
| 1709 | 1709 | if ($globalDebug) echo "Restart all connections..."; | 
| 1710 | 1710 | connect_all($globalSources); | 
| 1711 | 1711 | } | 
| 1712 | - } | |
| 1712 | + } | |
| 1713 | 1713 | } | 
| 1714 | 1714 |  	if ($globalDaemon === false) { | 
| 1715 | - if ($globalDebug) echo 'Check all...'."\n"; | |
| 1716 | - if (isset($SI)) $SI->checkAll(); | |
| 1717 | - if (isset($TI)) $TI->checkAll(); | |
| 1718 | - if (isset($MI)) $MI->checkAll(); | |
| 1715 | + if ($globalDebug) echo 'Check all...'."\n"; | |
| 1716 | + if (isset($SI)) $SI->checkAll(); | |
| 1717 | + if (isset($TI)) $TI->checkAll(); | |
| 1718 | + if (isset($MI)) $MI->checkAll(); | |
| 1719 | + } | |
| 1719 | 1720 | } | 
| 1720 | - } | |
| 1721 | 1721 | } | 
| 1722 | 1722 | |
| 1723 | 1723 | ?> | 
| @@ -46,20 +46,20 @@ discard block | ||
| 46 | 46 | die; | 
| 47 | 47 | } | 
| 48 | 48 | //$hosts = array($globalSBS1Host.':'.$globalSBS1Port); | 
| 49 | -	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port); | |
| 49 | +	$globalSources[] = array('host' => $globalSBS1Host, 'port' => $globalSBS1Port); | |
| 50 | 50 | } | 
| 51 | 51 | } | 
| 52 | 52 | |
| 53 | -$options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver')); | |
| 53 | +$options = getopt('s::', array('source::', 'server', 'nodaemon', 'idsource::', 'aprsserverssid::', 'aprsserverpass::', 'aprsserverhost::', 'aprsserverport::', 'format::', 'noaprsserver')); | |
| 54 | 54 | //if (isset($options['s'])) $hosts = array($options['s']); | 
| 55 | 55 | //elseif (isset($options['source'])) $hosts = array($options['source']); | 
| 56 | 56 |  if (isset($options['s'])) { | 
| 57 | 57 | $globalSources = array(); | 
| 58 | -    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); | |
| 58 | +    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'], 'format' => $options['format']); | |
| 59 | 59 |      else $globalSources[] = array('host' => $options['s']); | 
| 60 | 60 |  } elseif (isset($options['source'])) { | 
| 61 | 61 | $globalSources = array(); | 
| 62 | -    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); | |
| 62 | +    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'], 'format' => $options['format']); | |
| 63 | 63 |      else $globalSources[] = array('host' => $options['source']); | 
| 64 | 64 | } | 
| 65 | 65 |  if (isset($options['aprsserverhost'])) { | 
| @@ -76,28 +76,28 @@ discard block | ||
| 76 | 76 | else $id_source = 1; | 
| 77 | 77 |  if (isset($globalServer) && $globalServer) { | 
| 78 | 78 | if ($globalDebug) echo "Using Server Mode\n"; | 
| 79 | - $SI=new SpotterServer(); | |
| 79 | + $SI = new SpotterServer(); | |
| 80 | 80 | /* | 
| 81 | 81 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); | 
| 82 | 82 | $SI = new adsb2aprs(); | 
| 83 | 83 | $SI->connect(); | 
| 84 | 84 | */ | 
| 85 | -} else $SI=new SpotterImport($Connection->db); | |
| 85 | +} else $SI = new SpotterImport($Connection->db); | |
| 86 | 86 | if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db); | 
| 87 | 87 |  if (isset($globalMarine) && $globalMarine) { | 
| 88 | 88 | $AIS = new AIS(); | 
| 89 | 89 | $MI = new MarineImport($Connection->db); | 
| 90 | 90 | } | 
| 91 | 91 | //$APRS=new APRS($Connection->db); | 
| 92 | -$SBS=new SBS(); | |
| 93 | -$ACARS=new ACARS($Connection->db); | |
| 94 | -$Source=new Source($Connection->db); | |
| 95 | -$Common=new Common(); | |
| 92 | +$SBS = new SBS(); | |
| 93 | +$ACARS = new ACARS($Connection->db); | |
| 94 | +$Source = new Source($Connection->db); | |
| 95 | +$Common = new Common(); | |
| 96 | 96 |  date_default_timezone_set('UTC'); | 
| 97 | 97 |  //$servertz = system('date +%Z'); | 
| 98 | 98 | // signal handler - playing nice with sockets and dump1090 | 
| 99 | 99 |  if (function_exists('pcntl_fork')) { | 
| 100 | -    pcntl_signal(SIGINT,  function() { | |
| 100 | +    pcntl_signal(SIGINT, function() { | |
| 101 | 101 | global $sockets; | 
| 102 | 102 | echo "\n\nctrl-c or kill signal received. Tidying up ... "; | 
| 103 | 103 |          die("Bye!\n"); | 
| @@ -113,30 +113,30 @@ discard block | ||
| 113 | 113 | |
| 114 | 114 |  function connect_all($hosts) { | 
| 115 | 115 | //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; | 
| 116 | - global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; | |
| 116 | + global $sockets, $httpfeeds, $globalSources, $globalDebug, $aprs_connect, $last_exec, $globalSourcesRights, $use_aprs, $reset, $context; | |
| 117 | 117 | $reset++; | 
| 118 | 118 | if ($globalDebug) echo 'Connect to all...'."\n"; | 
| 119 | 119 |      foreach ($hosts as $id => $value) { | 
| 120 | 120 | $host = $value['host']; | 
| 121 | 121 | $globalSources[$id]['last_exec'] = 0; | 
| 122 | 122 | // Here we check type of source(s) | 
| 123 | -	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { | |
| 124 | -            if (preg_match('/deltadb.txt$/i',$host)) { | |
| 123 | +	if (filter_var($host, FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { | |
| 124 | +            if (preg_match('/deltadb.txt$/i', $host)) { | |
| 125 | 125 | //$formats[$id] = 'deltadbtxt'; | 
| 126 | 126 | $globalSources[$id]['format'] = 'deltadbtxt'; | 
| 127 | 127 | //$last_exec['deltadbtxt'] = 0; | 
| 128 | 128 |          	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; | 
| 129 | -            } else if (preg_match('/vatsim-data.txt$/i',$host)) { | |
| 129 | +            } else if (preg_match('/vatsim-data.txt$/i', $host)) { | |
| 130 | 130 | //$formats[$id] = 'vatsimtxt'; | 
| 131 | 131 | $globalSources[$id]['format'] = 'vatsimtxt'; | 
| 132 | 132 | //$last_exec['vatsimtxt'] = 0; | 
| 133 | 133 |          	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; | 
| 134 | -    	    } else if (preg_match('/aircraftlist.json$/i',$host)) { | |
| 134 | +    	    } else if (preg_match('/aircraftlist.json$/i', $host)) { | |
| 135 | 135 | //$formats[$id] = 'aircraftlistjson'; | 
| 136 | 136 | $globalSources[$id]['format'] = 'aircraftlistjson'; | 
| 137 | 137 | //$last_exec['aircraftlistjson'] = 0; | 
| 138 | 138 |          	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; | 
| 139 | -    	    } else if (preg_match('/opensky/i',$host)) { | |
| 139 | +    	    } else if (preg_match('/opensky/i', $host)) { | |
| 140 | 140 | //$formats[$id] = 'aircraftlistjson'; | 
| 141 | 141 | $globalSources[$id]['format'] = 'opensky'; | 
| 142 | 142 | //$last_exec['aircraftlistjson'] = 0; | 
| @@ -153,7 +153,7 @@ discard block | ||
| 153 | 153 | exit(0); | 
| 154 | 154 | } | 
| 155 | 155 | */ | 
| 156 | -    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { | |
| 156 | +    	    } else if (preg_match('/planeUpdateFAA.php$/i', $host)) { | |
| 157 | 157 | //$formats[$id] = 'planeupdatefaa'; | 
| 158 | 158 | $globalSources[$id]['format'] = 'planeupdatefaa'; | 
| 159 | 159 | //$last_exec['planeupdatefaa'] = 0; | 
| @@ -162,32 +162,32 @@ discard block | ||
| 162 | 162 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; | 
| 163 | 163 | exit(0); | 
| 164 | 164 | } | 
| 165 | -            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { | |
| 165 | +            } else if (preg_match('/\/action.php\/acars\/data$/i', $host)) { | |
| 166 | 166 | //$formats[$id] = 'phpvmacars'; | 
| 167 | 167 | $globalSources[$id]['format'] = 'phpvmacars'; | 
| 168 | 168 | //$last_exec['phpvmacars'] = 0; | 
| 169 | 169 |          	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; | 
| 170 | -            } else if (preg_match('/VAM-json.php$/i',$host)) { | |
| 170 | +            } else if (preg_match('/VAM-json.php$/i', $host)) { | |
| 171 | 171 | //$formats[$id] = 'phpvmacars'; | 
| 172 | 172 | $globalSources[$id]['format'] = 'vam'; | 
| 173 | 173 |          	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; | 
| 174 | -            } else if (preg_match('/whazzup/i',$host)) { | |
| 174 | +            } else if (preg_match('/whazzup/i', $host)) { | |
| 175 | 175 | //$formats[$id] = 'whazzup'; | 
| 176 | 176 | $globalSources[$id]['format'] = 'whazzup'; | 
| 177 | 177 | //$last_exec['whazzup'] = 0; | 
| 178 | 178 |          	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; | 
| 179 | -            } else if (preg_match('/blitzortung/i',$host)) { | |
| 179 | +            } else if (preg_match('/blitzortung/i', $host)) { | |
| 180 | 180 | $globalSources[$id]['format'] = 'blitzortung'; | 
| 181 | 181 |          	if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n"; | 
| 182 | -            } else if (preg_match('/airwhere/i',$host)) { | |
| 182 | +            } else if (preg_match('/airwhere/i', $host)) { | |
| 183 | 183 | $globalSources[$id]['format'] = 'airwhere'; | 
| 184 | 184 |          	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; | 
| 185 | -            } else if (preg_match('/recentpireps/i',$host)) { | |
| 185 | +            } else if (preg_match('/recentpireps/i', $host)) { | |
| 186 | 186 | //$formats[$id] = 'pirepsjson'; | 
| 187 | 187 | $globalSources[$id]['format'] = 'pirepsjson'; | 
| 188 | 188 | //$last_exec['pirepsjson'] = 0; | 
| 189 | 189 |          	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; | 
| 190 | -            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { | |
| 190 | +            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i', $host)) { | |
| 191 | 191 | //$formats[$id] = 'fr24json'; | 
| 192 | 192 | $globalSources[$id]['format'] = 'fr24json'; | 
| 193 | 193 | //$last_exec['fr24json'] = 0; | 
| @@ -196,7 +196,7 @@ discard block | ||
| 196 | 196 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; | 
| 197 | 197 | exit(0); | 
| 198 | 198 | } | 
| 199 | -            } else if (preg_match(':myshiptracking.com/:i',$host)) { | |
| 199 | +            } else if (preg_match(':myshiptracking.com/:i', $host)) { | |
| 200 | 200 | //$formats[$id] = 'fr24json'; | 
| 201 | 201 | $globalSources[$id]['format'] = 'myshiptracking'; | 
| 202 | 202 | //$last_exec['fr24json'] = 0; | 
| @@ -206,22 +206,22 @@ discard block | ||
| 206 | 206 | exit(0); | 
| 207 | 207 | } | 
| 208 | 208 |              //} else if (preg_match('/10001/',$host)) { | 
| 209 | -            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { | |
| 209 | +            } else if (preg_match('/10001/', $host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { | |
| 210 | 210 | //$formats[$id] = 'tsv'; | 
| 211 | 211 | $globalSources[$id]['format'] = 'tsv'; | 
| 212 | 212 |          	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; | 
| 213 | 213 | } | 
| 214 | -        } elseif (filter_var($host,FILTER_VALIDATE_URL)) { | |
| 214 | +        } elseif (filter_var($host, FILTER_VALIDATE_URL)) { | |
| 215 | 215 |      		if ($globalSources[$id]['format'] == 'aisnmeahttp') { | 
| 216 | - $idf = fopen($globalSources[$id]['host'],'r',false,$context); | |
| 216 | + $idf = fopen($globalSources[$id]['host'], 'r', false, $context); | |
| 217 | 217 |      		    if ($idf !== false) { | 
| 218 | 218 | $httpfeeds[$id] = $idf; | 
| 219 | 219 |          		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; | 
| 220 | 220 | } | 
| 221 | 221 | elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; | 
| 222 | 222 |      		} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; | 
| 223 | -        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { | |
| 224 | -	    $hostport = explode(':',$host); | |
| 223 | +        } elseif (!filter_var($host, FILTER_VALIDATE_URL)) { | |
| 224 | +	    $hostport = explode(':', $host); | |
| 225 | 225 |  	    if (isset($hostport[1])) { | 
| 226 | 226 | $port = $hostport[1]; | 
| 227 | 227 | $hostn = $hostport[0]; | 
| @@ -231,19 +231,19 @@ discard block | ||
| 231 | 231 | } | 
| 232 | 232 | $Common = new Common(); | 
| 233 | 233 |  	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { | 
| 234 | - $s = $Common->create_socket($hostn,$port, $errno, $errstr); | |
| 234 | + $s = $Common->create_socket($hostn, $port, $errno, $errstr); | |
| 235 | 235 |      	    } else { | 
| 236 | - $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); | |
| 236 | + $s = $Common->create_socket_udp($hostn, $port, $errno, $errstr); | |
| 237 | 237 | } | 
| 238 | 238 |  	    if ($s) { | 
| 239 | 239 | $sockets[$id] = $s; | 
| 240 | 240 |      	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { | 
| 241 | -		    if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { | |
| 241 | +		    if (preg_match('/aprs/', $hostn) || $port == '10152' || $port == '14580') { | |
| 242 | 242 | //$formats[$id] = 'aprs'; | 
| 243 | 243 | $globalSources[$id]['format'] = 'aprs'; | 
| 244 | 244 | //$aprs_connect = 0; | 
| 245 | 245 | //$use_aprs = true; | 
| 246 | -		    } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { | |
| 246 | +		    } elseif (preg_match('/pub-vrs/', $hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { | |
| 247 | 247 | $globalSources[$id]['format'] = 'vrstcp'; | 
| 248 | 248 |      		    } elseif ($port == '10001') { | 
| 249 | 249 | //$formats[$id] = 'tsv'; | 
| @@ -282,7 +282,7 @@ discard block | ||
| 282 | 282 | else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut; | 
| 283 | 283 | else $timeout = 20; | 
| 284 | 284 | $errno = ''; | 
| 285 | -$errstr=''; | |
| 285 | +$errstr = ''; | |
| 286 | 286 | |
| 287 | 287 | if (!isset($globalDaemon)) $globalDaemon = TRUE; | 
| 288 | 288 | /* Initiate connections to all the hosts simultaneously */ | 
| @@ -290,7 +290,7 @@ discard block | ||
| 290 | 290 | //connect_all($globalSources); | 
| 291 | 291 | |
| 292 | 292 |  if (isset($globalProxy) && $globalProxy) { | 
| 293 | -    $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); | |
| 293 | +    $context = stream_context_create(array('http' => array('timeout' => $timeout, 'proxy' => $globalProxy, 'request_fulluri' => true))); | |
| 294 | 294 |  } else { | 
| 295 | 295 |      $context = stream_context_create(array('http' => array('timeout' => $timeout))); | 
| 296 | 296 | } | 
| @@ -320,16 +320,16 @@ discard block | ||
| 320 | 320 | |
| 321 | 321 |  if ($use_aprs) { | 
| 322 | 322 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); | 
| 323 | - $APRS=new APRS(); | |
| 323 | + $APRS = new APRS(); | |
| 324 | 324 | $aprs_connect = 0; | 
| 325 | 325 | $aprs_keep = 120; | 
| 326 | 326 | $aprs_last_tx = time(); | 
| 327 | 327 | if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; | 
| 328 | -	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); | |
| 328 | +	else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName); | |
| 329 | 329 | if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid; | 
| 330 | -	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); | |
| 330 | +	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8); | |
| 331 | 331 | if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter; | 
| 332 | - else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; | |
| 332 | + else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; | |
| 333 | 333 | if ($aprs_full) $aprs_filter = ''; | 
| 334 | 334 | if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass; | 
| 335 | 335 | else $aprs_pass = '-1'; | 
| @@ -343,12 +343,12 @@ discard block | ||
| 343 | 343 | sleep(1); | 
| 344 | 344 | if ($globalDebug) echo "SCAN MODE \n\n"; | 
| 345 | 345 | if (!isset($globalCronEnd)) $globalCronEnd = 60; | 
| 346 | -$endtime = time()+$globalCronEnd; | |
| 346 | +$endtime = time() + $globalCronEnd; | |
| 347 | 347 | $i = 1; | 
| 348 | 348 | $tt = array(); | 
| 349 | 349 | // Delete all ATC | 
| 350 | 350 |  if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) { | 
| 351 | - $ATC=new ATC($Connection->db); | |
| 351 | + $ATC = new ATC($Connection->db); | |
| 352 | 352 | } | 
| 353 | 353 |  if (!$globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { | 
| 354 | 354 | $ATC->deleteAll(); | 
| @@ -356,7 +356,7 @@ discard block | ||
| 356 | 356 | |
| 357 | 357 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. | 
| 358 | 358 |  while ($i > 0) { | 
| 359 | - if (!$globalDaemon) $i = $endtime-time(); | |
| 359 | + if (!$globalDaemon) $i = $endtime - time(); | |
| 360 | 360 | // Delete old ATC | 
| 361 | 361 |      if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { | 
| 362 | 362 | if ($globalDebug) echo 'Delete old ATC...'."\n"; | 
| @@ -370,7 +370,7 @@ discard block | ||
| 370 | 370 | } | 
| 371 | 371 |  	if ($max != $globalMinFetch) { | 
| 372 | 372 | if ($globalDebug) echo 'Sleeping...'."\n"; | 
| 373 | - sleep($globalMinFetch-$max+2); | |
| 373 | + sleep($globalMinFetch - $max + 2); | |
| 374 | 374 | } | 
| 375 | 375 | } | 
| 376 | 376 | |
| @@ -389,8 +389,8 @@ discard block | ||
| 389 | 389 | //$buffer = $Common->getData($hosts[$id]); | 
| 390 | 390 | $buffer = $Common->getData($value['host']); | 
| 391 | 391 | if ($buffer != '') $reset = 0; | 
| 392 | -    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); | |
| 393 | -	    $buffer = explode('\n',$buffer); | |
| 392 | +    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); | |
| 393 | +	    $buffer = explode('\n', $buffer); | |
| 394 | 394 |  	    foreach ($buffer as $line) { | 
| 395 | 395 |      		if ($line != '' && count($line) > 7) { | 
| 396 | 396 |      		    $line = explode(',', $line); | 
| @@ -423,11 +423,11 @@ discard block | ||
| 423 | 423 | ) | 
| 424 | 424 |  	) { | 
| 425 | 425 |  	    date_default_timezone_set('CET'); | 
| 426 | -	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); | |
| 426 | +	    $buffer = $Common->getData(str_replace('{date}', date('Ymd'), $value['host'])); | |
| 427 | 427 |  	    date_default_timezone_set('UTC'); | 
| 428 | 428 | if ($buffer != '') $reset = 0; | 
| 429 | -    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); | |
| 430 | -	    $buffer = explode('\n',$buffer); | |
| 429 | +    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); | |
| 430 | +	    $buffer = explode('\n', $buffer); | |
| 431 | 431 |  	    foreach ($buffer as $line) { | 
| 432 | 432 |  		if ($line != '') { | 
| 433 | 433 | //echo "'".$line."'\n"; | 
| @@ -445,7 +445,7 @@ discard block | ||
| 445 | 445 | if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; | 
| 446 | 446 | if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; | 
| 447 | 447 |  		    if (isset($ais_data['timestamp'])) { | 
| 448 | -			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); | |
| 448 | +			$data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); | |
| 449 | 449 |  			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { | 
| 450 | 450 | $last_exec[$id]['timestamp'] = $ais_data['timestamp']; | 
| 451 | 451 | $add = true; | 
| @@ -468,12 +468,12 @@ discard block | ||
| 468 | 468 | $w = $e = null; | 
| 469 | 469 | |
| 470 | 470 |  	    if (isset($arr[$id])) { | 
| 471 | - $nn = stream_select($arr,$w,$e,$timeout); | |
| 471 | + $nn = stream_select($arr, $w, $e, $timeout); | |
| 472 | 472 |  		if ($nn > 0) { | 
| 473 | 473 |  		    foreach ($httpfeeds as $feed) { | 
| 474 | - $buffer = stream_get_line($feed,2000,"\n"); | |
| 475 | -			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); | |
| 476 | -			$buffer = explode('\n',$buffer); | |
| 474 | + $buffer = stream_get_line($feed, 2000, "\n"); | |
| 475 | +			$buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); | |
| 476 | +			$buffer = explode('\n', $buffer); | |
| 477 | 477 |  			foreach ($buffer as $line) { | 
| 478 | 478 |  			    if ($line != '') { | 
| 479 | 479 | $ais_data = $AIS->parse_line(trim($line)); | 
| @@ -491,9 +491,9 @@ discard block | ||
| 491 | 491 | if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; | 
| 492 | 492 | if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; | 
| 493 | 493 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; | 
| 494 | -				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); | |
| 494 | +				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']); | |
| 495 | 495 |  				if (isset($ais_data['timestamp'])) { | 
| 496 | -				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); | |
| 496 | +				    $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); | |
| 497 | 497 |  				} else { | 
| 498 | 498 |  				    $data['datetime'] = date('Y-m-d H:i:s'); | 
| 499 | 499 | } | 
| @@ -524,10 +524,10 @@ discard block | ||
| 524 | 524 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) | 
| 525 | 525 | ) | 
| 526 | 526 |  	) { | 
| 527 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); | |
| 527 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20'); | |
| 528 | 528 |  	    if ($buffer != '') { | 
| 529 | 529 | //echo $buffer; | 
| 530 | - $all_data = json_decode($buffer,true); | |
| 530 | + $all_data = json_decode($buffer, true); | |
| 531 | 531 | //print_r($all_data); | 
| 532 | 532 |  		if (isset($all_data[0]['DATA'])) { | 
| 533 | 533 |  		    foreach ($all_data[0]['DATA'] as $line) { | 
| @@ -542,7 +542,7 @@ discard block | ||
| 542 | 542 | // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; | 
| 543 | 543 | $data['imo'] = $line['IMO']; | 
| 544 | 544 | //$data['arrival_code'] = $ais_data['destination']; | 
| 545 | -			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']); | |
| 545 | +			    $data['datetime'] = date('Y-m-d H:i:s', $line['T']); | |
| 546 | 546 | $data['format_source'] = 'myshiptracking'; | 
| 547 | 547 | $data['id_source'] = $id_source; | 
| 548 | 548 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | 
| @@ -559,9 +559,9 @@ discard block | ||
| 559 | 559 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) | 
| 560 | 560 | ) | 
| 561 | 561 |  	) { | 
| 562 | -	    $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); | |
| 562 | +	    $buffer = $Common->getData(str_replace('{timestamp}', time(), $value['host'])); | |
| 563 | 563 |  	    if ($buffer != '') { | 
| 564 | - $all_data = json_decode($buffer,true); | |
| 564 | + $all_data = json_decode($buffer, true); | |
| 565 | 565 |  		if (isset($all_data[0]['mmsi'])) { | 
| 566 | 566 |  		    foreach ($all_data as $line) { | 
| 567 | 567 |  			if ($line != '') { | 
| @@ -595,7 +595,7 @@ discard block | ||
| 595 | 595 |  	) { | 
| 596 | 596 | $buffer = $Common->getData($value['host']); | 
| 597 | 597 |  	    if ($buffer != '') { | 
| 598 | - $all_data = json_decode($buffer,true); | |
| 598 | + $all_data = json_decode($buffer, true); | |
| 599 | 599 |  		if (isset($all_data['features'][0]['id'])) { | 
| 600 | 600 |  		    foreach ($all_data['features'] as $line) { | 
| 601 | 601 | $data = array(); | 
| @@ -628,27 +628,27 @@ discard block | ||
| 628 | 628 | ) | 
| 629 | 629 |  	) { | 
| 630 | 630 | echo 'download...'; | 
| 631 | - $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); | |
| 631 | + $buffer = $Common->getData($value['host'], 'post', $value['post'], '', '', '', '', 'ShipPlotter'); | |
| 632 | 632 | echo 'done !'."\n"; | 
| 633 | 633 | if ($buffer != '') $reset = 0; | 
| 634 | -    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); | |
| 635 | -	    $buffer = explode('\n',$buffer); | |
| 634 | +    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); | |
| 635 | +	    $buffer = explode('\n', $buffer); | |
| 636 | 636 |  	    foreach ($buffer as $line) { | 
| 637 | 637 |  		if ($line != '') { | 
| 638 | 638 | $data = array(); | 
| 639 | - $data['mmsi'] = (int)substr($line,0,9); | |
| 640 | -		    $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); | |
| 639 | + $data['mmsi'] = (int) substr($line, 0, 9); | |
| 640 | +		    $data['datetime'] = date('Y-m-d H:i:s', substr($line, 10, 10)); | |
| 641 | 641 | //$data['status'] = substr($line,21,2); | 
| 642 | 642 | //$data['type'] = substr($line,24,3); | 
| 643 | - $data['latitude'] = substr($line,29,9); | |
| 644 | - $data['longitude'] = substr($line,41,9); | |
| 645 | - $data['speed'] = round(substr($line,51,5)); | |
| 643 | + $data['latitude'] = substr($line, 29, 9); | |
| 644 | + $data['longitude'] = substr($line, 41, 9); | |
| 645 | + $data['speed'] = round(substr($line, 51, 5)); | |
| 646 | 646 | //$data['course'] = substr($line,57,5); | 
| 647 | - $data['heading'] = round(substr($line,63,3)); | |
| 647 | + $data['heading'] = round(substr($line, 63, 3)); | |
| 648 | 648 | //$data['draft'] = substr($line,67,4); | 
| 649 | 649 | //$data['length'] = substr($line,72,3); | 
| 650 | 650 | //$data['beam'] = substr($line,76,2); | 
| 651 | - $data['ident'] = trim(utf8_encode(substr($line,79,20))); | |
| 651 | + $data['ident'] = trim(utf8_encode(substr($line, 79, 20))); | |
| 652 | 652 | //$data['callsign'] = trim(substr($line,100,7); | 
| 653 | 653 | //$data['dest'] = substr($line,108,20); | 
| 654 | 654 | //$data['etaDate'] = substr($line,129,5); | 
| @@ -681,8 +681,8 @@ discard block | ||
| 681 | 681 |  	) { | 
| 682 | 682 | //$buffer = $Common->getData($hosts[$id]); | 
| 683 | 683 | $buffer = $Common->getData($value['host']); | 
| 684 | -    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); | |
| 685 | -	    $buffer = explode('\n',$buffer); | |
| 684 | +    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); | |
| 685 | +	    $buffer = explode('\n', $buffer); | |
| 686 | 686 | $reset = 0; | 
| 687 | 687 |  	    foreach ($buffer as $line) { | 
| 688 | 688 |      		if ($line != '') { | 
| @@ -693,7 +693,7 @@ discard block | ||
| 693 | 693 | else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; | 
| 694 | 694 | $data['pilot_id'] = $line[1]; | 
| 695 | 695 | $data['pilot_name'] = $line[2]; | 
| 696 | - $data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT); | |
| 696 | + $data['hex'] = str_pad(dechex($Common->str2int($line[1])), 6, '000000', STR_PAD_LEFT); | |
| 697 | 697 | $data['ident'] = $line[0]; // ident | 
| 698 | 698 | if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude | 
| 699 | 699 | $data['speed'] = $line[8]; // speed | 
| @@ -709,7 +709,7 @@ discard block | ||
| 709 | 709 |  			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); | 
| 710 | 710 | //if (isset($line[37])) $data['last_update'] = $line[37]; | 
| 711 | 711 | $data['departure_airport_icao'] = $line[11]; | 
| 712 | - $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); | |
| 712 | + $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':'); | |
| 713 | 713 | $data['arrival_airport_icao'] = $line[13]; | 
| 714 | 714 | $data['frequency'] = $line[4]; | 
| 715 | 715 | $data['type'] = $line[18]; | 
| @@ -718,7 +718,7 @@ discard block | ||
| 718 | 718 | $data['id_source'] = $id_source; | 
| 719 | 719 | //$data['arrival_airport_time'] = ; | 
| 720 | 720 |  	    		if ($line[9] != '') { | 
| 721 | -	    		    $aircraft_data = explode('/',$line[9]); | |
| 721 | +	    		    $aircraft_data = explode('/', $line[9]); | |
| 722 | 722 |  	    		    if (isset($aircraft_data[1])) { | 
| 723 | 723 | $data['aircraft_icao'] = $aircraft_data[1]; | 
| 724 | 724 | } | 
| @@ -733,9 +733,9 @@ discard block | ||
| 733 | 733 | if ($line[3] == 'PILOT') $SI->add($data); | 
| 734 | 734 |  			elseif ($line[3] == 'ATC') { | 
| 735 | 735 | //print_r($data); | 
| 736 | -				$data['info'] = str_replace('^§','<br />',$data['info']); | |
| 737 | -				$data['info'] = str_replace('&sect;','',$data['info']); | |
| 738 | - $typec = substr($data['ident'],-3); | |
| 736 | +				$data['info'] = str_replace('^§', '<br />', $data['info']); | |
| 737 | +				$data['info'] = str_replace('&sect;', '', $data['info']); | |
| 738 | + $typec = substr($data['ident'], -3); | |
| 739 | 739 | if ($typec == 'APP') $data['type'] = 'Approach'; | 
| 740 | 740 | elseif ($typec == 'TWR') $data['type'] = 'Tower'; | 
| 741 | 741 | elseif ($typec == 'OBS') $data['type'] = 'Observer'; | 
| @@ -747,8 +747,8 @@ discard block | ||
| 747 | 747 | elseif ($data['type'] == '') $data['type'] = 'Observer'; | 
| 748 | 748 | if (!isset($data['source_name'])) $data['source_name'] = ''; | 
| 749 | 749 |  				if (isset($ATC)) { | 
| 750 | - 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']); | |
| 751 | - 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']); | |
| 750 | + 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']); | |
| 751 | + 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']); | |
| 752 | 752 | } | 
| 753 | 753 | } | 
| 754 | 754 | unset($data); | 
| @@ -764,24 +764,24 @@ discard block | ||
| 764 | 764 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) | 
| 765 | 765 | ) | 
| 766 | 766 |      	) { | 
| 767 | -	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20'); | |
| 767 | +	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php', 'get', '', '', '', '', '20'); | |
| 768 | 768 |  	    if ($buffer != '') { | 
| 769 | 769 | $all_data = simplexml_load_string($buffer); | 
| 770 | -		foreach($all_data->children() as $childdata) { | |
| 770 | +		foreach ($all_data->children() as $childdata) { | |
| 771 | 771 | $data = array(); | 
| 772 | 772 | $line = $childdata; | 
| 773 | 773 | //$data['hex'] = str_pad(dechex((int)$line['pktPilotID']),6,'000000',STR_PAD_LEFT); | 
| 774 | -			$data['id'] = date('Ymd').(int)$line['pktPilotID']; | |
| 775 | -			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST')); | |
| 776 | - $data['latitude'] = (float)$line['pktLatitude']; | |
| 777 | - $data['longitude'] = (float)$line['pktLongitude']; | |
| 778 | - if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack']; | |
| 779 | - if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed']; | |
| 780 | - $data['altitude'] = round((int)$line['pktAltitude']*3.28084); | |
| 774 | +			$data['id'] = date('Ymd').(int) $line['pktPilotID']; | |
| 775 | +			$data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['entryTime'].' BST')); | |
| 776 | + $data['latitude'] = (float) $line['pktLatitude']; | |
| 777 | + $data['longitude'] = (float) $line['pktLongitude']; | |
| 778 | + if ((float) $line['pktTrack'] != 0) $data['heading'] = (float) $line['pktTrack']; | |
| 779 | + if ((int) $line['pktSpeed'] != 0) $data['speed'] = (int) $line['pktSpeed']; | |
| 780 | + $data['altitude'] = round((int) $line['pktAltitude']*3.28084); | |
| 781 | 781 | $data['altitude_relative'] = 'AMSL'; | 
| 782 | - $data['pilot_id'] = (int)$line['pktPilotID']; | |
| 782 | + $data['pilot_id'] = (int) $line['pktPilotID']; | |
| 783 | 783 | $data['aircraft_icao'] = 'PARAGLIDER'; | 
| 784 | -			$pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id'])); | |
| 784 | +			$pilot_data = explode(',', $Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id'])); | |
| 785 | 785 | if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4]; | 
| 786 | 786 | $data['format_source'] = $value['format']; | 
| 787 | 787 | $SI->add($data); | 
| @@ -789,22 +789,22 @@ discard block | ||
| 789 | 789 | } | 
| 790 | 790 | } | 
| 791 | 791 |  	    $Source->deleteOldLocationByType('gs'); | 
| 792 | -	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20'); | |
| 792 | +	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php', 'get', '', '', '', '', '20'); | |
| 793 | 793 |  	    if ($buffer != '') { | 
| 794 | 794 | $all_data = simplexml_load_string($buffer); | 
| 795 | -		foreach($all_data->children() as $childdata) { | |
| 795 | +		foreach ($all_data->children() as $childdata) { | |
| 796 | 796 | $data = array(); | 
| 797 | 797 | $line = $childdata; | 
| 798 | - $data['id'] = (int)$line['gsID']; | |
| 799 | - $data['latitude'] = (float)$line['gsLatitude']; | |
| 800 | - $data['longitude'] = (float)$line['gsLongitude']; | |
| 801 | - $data['altitude'] = round((int)$line['gsHeight']*3.28084); | |
| 798 | + $data['id'] = (int) $line['gsID']; | |
| 799 | + $data['latitude'] = (float) $line['gsLatitude']; | |
| 800 | + $data['longitude'] = (float) $line['gsLongitude']; | |
| 801 | + $data['altitude'] = round((int) $line['gsHeight']*3.28084); | |
| 802 | 802 | $data['altitude_relative'] = 'AMSL'; | 
| 803 | -			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['gsLastUpdate'].' BST')); | |
| 803 | +			$data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['gsLastUpdate'].' BST')); | |
| 804 | 804 |  			if (count($Source->getLocationInfoByLocationID($data['id'])) > 0) { | 
| 805 | -				$Source->updateLocationByLocationID('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']); | |
| 805 | +				$Source->updateLocationByLocationID('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']); | |
| 806 | 806 |  			} else { | 
| 807 | -				$Source->addLocation('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']); | |
| 807 | +				$Source->addLocation('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']); | |
| 808 | 808 | } | 
| 809 | 809 | unset($data); | 
| 810 | 810 | } | 
| @@ -822,9 +822,9 @@ discard block | ||
| 822 | 822 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) | 
| 823 | 823 | ) | 
| 824 | 824 |  	) { | 
| 825 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); | |
| 825 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20'); | |
| 826 | 826 |  	    if ($buffer != '') { | 
| 827 | - $all_data = json_decode($buffer,true); | |
| 827 | + $all_data = json_decode($buffer, true); | |
| 828 | 828 |  		if (isset($all_data['acList'])) { | 
| 829 | 829 | $reset = 0; | 
| 830 | 830 |  		    foreach ($all_data['acList'] as $line) { | 
| @@ -840,7 +840,7 @@ discard block | ||
| 840 | 840 | if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk | 
| 841 | 841 | $data['emergency'] = ''; // emergency | 
| 842 | 842 | if (isset($line['Reg'])) $data['registration'] = $line['Reg']; | 
| 843 | -			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); | |
| 843 | +			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000)); | |
| 844 | 844 |  			else $data['datetime'] = date('Y-m-d H:i:s'); | 
| 845 | 845 |  			//$data['datetime'] = date('Y-m-d H:i:s'); | 
| 846 | 846 | if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; | 
| @@ -865,7 +865,7 @@ discard block | ||
| 865 | 865 | $data['verticalrate'] = $line['vrt']; // verticale rate | 
| 866 | 866 | $data['squawk'] = $line['squawk']; // squawk | 
| 867 | 867 | $data['emergency'] = ''; // emergency | 
| 868 | -			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); | |
| 868 | +			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000)); | |
| 869 | 869 |  			else $data['datetime'] = date('Y-m-d H:i:s'); | 
| 870 | 870 | $data['format_source'] = 'aircraftlistjson'; | 
| 871 | 871 | $data['id_source'] = $id_source; | 
| @@ -886,7 +886,7 @@ discard block | ||
| 886 | 886 | ) | 
| 887 | 887 |      	) { | 
| 888 | 888 | $buffer = $Common->getData($value['host']); | 
| 889 | - $all_data = json_decode($buffer,true); | |
| 889 | + $all_data = json_decode($buffer, true); | |
| 890 | 890 |  	    if (isset($all_data['planes'])) { | 
| 891 | 891 | $reset = 0; | 
| 892 | 892 |  		foreach ($all_data['planes'] as $key => $line) { | 
| @@ -903,12 +903,12 @@ discard block | ||
| 903 | 903 | $data['emergency'] = ''; // emergency | 
| 904 | 904 | $data['registration'] = $line[2]; | 
| 905 | 905 | $data['aircraft_icao'] = $line[0]; | 
| 906 | -		    $deparr = explode('-',$line[1]); | |
| 906 | +		    $deparr = explode('-', $line[1]); | |
| 907 | 907 |  		    if (count($deparr) == 2) { | 
| 908 | 908 | $data['departure_airport_icao'] = $deparr[0]; | 
| 909 | 909 | $data['arrival_airport_icao'] = $deparr[1]; | 
| 910 | 910 | } | 
| 911 | -		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]); | |
| 911 | +		    $data['datetime'] = date('Y-m-d H:i:s', $line[9]); | |
| 912 | 912 | $data['format_source'] = 'planeupdatefaa'; | 
| 913 | 913 | $data['id_source'] = $id_source; | 
| 914 | 914 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | 
| @@ -926,7 +926,7 @@ discard block | ||
| 926 | 926 | ) | 
| 927 | 927 |  	) { | 
| 928 | 928 | $buffer = $Common->getData($value['host']); | 
| 929 | - $all_data = json_decode($buffer,true); | |
| 929 | + $all_data = json_decode($buffer, true); | |
| 930 | 930 |  	    if (isset($all_data['states'])) { | 
| 931 | 931 | $reset = 0; | 
| 932 | 932 |  		foreach ($all_data['states'] as $key => $line) { | 
| @@ -943,7 +943,7 @@ discard block | ||
| 943 | 943 | //$data['emergency'] = ''; // emergency | 
| 944 | 944 | //$data['registration'] = $line[2]; | 
| 945 | 945 | //$data['aircraft_icao'] = $line[0]; | 
| 946 | -		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]); | |
| 946 | +		    $data['datetime'] = date('Y-m-d H:i:s', $line[3]); | |
| 947 | 947 | $data['format_source'] = 'opensky'; | 
| 948 | 948 | $data['id_source'] = $id_source; | 
| 949 | 949 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | 
| @@ -962,7 +962,7 @@ discard block | ||
| 962 | 962 |  	) { | 
| 963 | 963 | //$buffer = $Common->getData($hosts[$id]); | 
| 964 | 964 | $buffer = $Common->getData($value['host']); | 
| 965 | - $all_data = json_decode($buffer,true); | |
| 965 | + $all_data = json_decode($buffer, true); | |
| 966 | 966 | if (!empty($all_data)) $reset = 0; | 
| 967 | 967 |  	    foreach ($all_data as $key => $line) { | 
| 968 | 968 |  		if ($key != 'full_count' && $key != 'version' && $key != 'stats') { | 
| @@ -1000,11 +1000,11 @@ discard block | ||
| 1000 | 1000 | ) | 
| 1001 | 1001 |  	) { | 
| 1002 | 1002 | //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); | 
| 1003 | - $buffer = $Common->getData($value['host'],'get','','','','','150'); | |
| 1003 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150'); | |
| 1004 | 1004 | //echo $buffer; | 
| 1005 | -	    $buffer = str_replace(array("\n","\r"),"",$buffer); | |
| 1006 | -	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer); | |
| 1007 | - $all_data = json_decode($buffer,true); | |
| 1005 | +	    $buffer = str_replace(array("\n", "\r"), "", $buffer); | |
| 1006 | +	    $buffer = preg_replace('/,"num":(.+)/', '}', $buffer); | |
| 1007 | + $all_data = json_decode($buffer, true); | |
| 1008 | 1008 |  	    if (json_last_error() != JSON_ERROR_NONE) { | 
| 1009 | 1009 | die(json_last_error_msg()); | 
| 1010 | 1010 | } | 
| @@ -1027,7 +1027,7 @@ discard block | ||
| 1027 | 1027 | //$data['departure_airport_iata'] = $line[11]; | 
| 1028 | 1028 | //$data['arrival_airport_iata'] = $line[12]; | 
| 1029 | 1029 | //$data['emergency'] = ''; // emergency | 
| 1030 | -			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] | |
| 1030 | +			$data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10] | |
| 1031 | 1031 | $data['format_source'] = 'radarvirtueljson'; | 
| 1032 | 1032 | $data['id_source'] = $id_source; | 
| 1033 | 1033 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | 
| @@ -1048,14 +1048,14 @@ discard block | ||
| 1048 | 1048 |  	) { | 
| 1049 | 1049 | //$buffer = $Common->getData($hosts[$id]); | 
| 1050 | 1050 | $buffer = $Common->getData($value['host'].'?'.time()); | 
| 1051 | - $all_data = json_decode(utf8_encode($buffer),true); | |
| 1051 | + $all_data = json_decode(utf8_encode($buffer), true); | |
| 1052 | 1052 | |
| 1053 | 1053 |  	    if (isset($all_data['pireps'])) { | 
| 1054 | 1054 | $reset = 0; | 
| 1055 | 1055 |  	        foreach ($all_data['pireps'] as $line) { | 
| 1056 | 1056 | $data = array(); | 
| 1057 | 1057 | $data['id'] = $line['id']; | 
| 1058 | - $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); | |
| 1058 | + $data['hex'] = substr(str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT), 0, 6); | |
| 1059 | 1059 | $data['ident'] = $line['callsign']; // ident | 
| 1060 | 1060 | if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id | 
| 1061 | 1061 | if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name | 
| @@ -1085,9 +1085,9 @@ discard block | ||
| 1085 | 1085 | $SI->add($data); | 
| 1086 | 1086 | // print_r($data); | 
| 1087 | 1087 |      		    } elseif ($line['icon'] == 'ct') { | 
| 1088 | -			$data['info'] = str_replace('^§','<br />',$data['info']); | |
| 1089 | -			$data['info'] = str_replace('&sect;','',$data['info']); | |
| 1090 | - $typec = substr($data['ident'],-3); | |
| 1088 | +			$data['info'] = str_replace('^§', '<br />', $data['info']); | |
| 1089 | +			$data['info'] = str_replace('&sect;', '', $data['info']); | |
| 1090 | + $typec = substr($data['ident'], -3); | |
| 1091 | 1091 | $data['type'] = ''; | 
| 1092 | 1092 | if ($typec == 'APP') $data['type'] = 'Approach'; | 
| 1093 | 1093 | elseif ($typec == 'TWR') $data['type'] = 'Tower'; | 
| @@ -1098,7 +1098,7 @@ discard block | ||
| 1098 | 1098 | elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station'; | 
| 1099 | 1099 | elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; | 
| 1100 | 1100 | else $data['type'] = 'Observer'; | 
| 1101 | - 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']); | |
| 1101 | + 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']); | |
| 1102 | 1102 | } | 
| 1103 | 1103 | unset($data); | 
| 1104 | 1104 | } | 
| @@ -1115,14 +1115,14 @@ discard block | ||
| 1115 | 1115 | //$buffer = $Common->getData($hosts[$id]); | 
| 1116 | 1116 | if ($globalDebug) echo 'Get Data...'."\n"; | 
| 1117 | 1117 | $buffer = $Common->getData($value['host']); | 
| 1118 | - $all_data = json_decode($buffer,true); | |
| 1118 | + $all_data = json_decode($buffer, true); | |
| 1119 | 1119 |  	    if ($buffer != '' && is_array($all_data)) { | 
| 1120 | 1120 | $reset = 0; | 
| 1121 | 1121 |  		foreach ($all_data as $line) { | 
| 1122 | 1122 | $data = array(); | 
| 1123 | 1123 | //$data['id'] = $line['id']; // id not usable | 
| 1124 | 1124 | if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; | 
| 1125 | - $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex | |
| 1125 | + $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex | |
| 1126 | 1126 | if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; | 
| 1127 | 1127 | if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; | 
| 1128 | 1128 | $data['ident'] = $line['flightnum']; // ident | 
| @@ -1137,7 +1137,7 @@ discard block | ||
| 1137 | 1137 | //$data['datetime'] = $line['lastupdate']; | 
| 1138 | 1138 | //$data['last_update'] = $line['lastupdate']; | 
| 1139 | 1139 |  	    	    if (isset($value['timezone'])) { | 
| 1140 | - $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); | |
| 1140 | + $datetime = new DateTime($line['lastupdate'], new DateTimeZone($value['timezone'])); | |
| 1141 | 1141 |  	    		$datetime->setTimeZone(new DateTimeZone('UTC')); | 
| 1142 | 1142 |  	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s'); | 
| 1143 | 1143 |  	    	    } else $data['datetime'] = date('Y-m-d H:i:s'); | 
| @@ -1150,14 +1150,14 @@ discard block | ||
| 1150 | 1150 | if (isset($line['route'])) $data['waypoints'] = $line['route']; // route | 
| 1151 | 1151 |  		    if (isset($line['aircraftname'])) { | 
| 1152 | 1152 | $line['aircraftname'] = strtoupper($line['aircraftname']); | 
| 1153 | -			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); | |
| 1154 | -	    		$aircraft_data = explode('-',$line['aircraftname']); | |
| 1153 | +			$line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']); | |
| 1154 | +	    		$aircraft_data = explode('-', $line['aircraftname']); | |
| 1155 | 1155 | if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; | 
| 1156 | 1156 | elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; | 
| 1157 | 1157 |  	    		else { | 
| 1158 | -	    		    $aircraft_data = explode(' ',$line['aircraftname']); | |
| 1159 | -	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); | |
| 1160 | -	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); | |
| 1158 | +	    		    $aircraft_data = explode(' ', $line['aircraftname']); | |
| 1159 | +	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-', '', $aircraft_data[1]); | |
| 1160 | +	    		    else $data['aircraft_icao'] = str_replace('-', '', $line['aircraftname']); | |
| 1161 | 1161 | } | 
| 1162 | 1162 | } | 
| 1163 | 1163 | if (isset($line['route'])) $data['waypoints'] = $line['route']; | 
| @@ -1182,14 +1182,14 @@ discard block | ||
| 1182 | 1182 | //$buffer = $Common->getData($hosts[$id]); | 
| 1183 | 1183 | if ($globalDebug) echo 'Get Data...'."\n"; | 
| 1184 | 1184 | $buffer = $Common->getData($value['host']); | 
| 1185 | - $all_data = json_decode($buffer,true); | |
| 1185 | + $all_data = json_decode($buffer, true); | |
| 1186 | 1186 |  	    if ($buffer != '' && is_array($all_data)) { | 
| 1187 | 1187 | $reset = 0; | 
| 1188 | 1188 |  		foreach ($all_data as $line) { | 
| 1189 | 1189 | $data = array(); | 
| 1190 | 1190 | //$data['id'] = $line['id']; // id not usable | 
| 1191 | 1191 | $data['id'] = trim($line['flight_id']); | 
| 1192 | - $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex | |
| 1192 | + $data['hex'] = substr(str_pad(bin2hex($line['callsign']), 6, '000000', STR_PAD_LEFT), -6); // hex | |
| 1193 | 1193 | $data['pilot_name'] = $line['pilot_name']; | 
| 1194 | 1194 | $data['pilot_id'] = $line['pilot_id']; | 
| 1195 | 1195 | $data['ident'] = trim($line['callsign']); // ident | 
| @@ -1233,24 +1233,24 @@ discard block | ||
| 1233 | 1233 | //$buffer = $Common->getData($hosts[$id]); | 
| 1234 | 1234 | if ($globalDebug) echo 'Get Data...'."\n"; | 
| 1235 | 1235 | $buffer = $Common->getData($value['host']); | 
| 1236 | - $all_data = json_decode($buffer,true); | |
| 1236 | + $all_data = json_decode($buffer, true); | |
| 1237 | 1237 |  	    if ($buffer != '') { | 
| 1238 | 1238 |  		$Source->deleteLocationBySource('blitzortung'); | 
| 1239 | -		$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); | |
| 1240 | -		$buffer = explode('\n',$buffer); | |
| 1239 | +		$buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); | |
| 1240 | +		$buffer = explode('\n', $buffer); | |
| 1241 | 1241 |  		foreach ($buffer as $buffer_line) { | 
| 1242 | - $line = json_decode($buffer_line,true); | |
| 1242 | + $line = json_decode($buffer_line, true); | |
| 1243 | 1243 |  		    if (isset($line['time'])) { | 
| 1244 | 1244 | $data = array(); | 
| 1245 | 1245 | $data['altitude'] = $line['alt']; // altitude | 
| 1246 | 1246 | $data['latitude'] = $line['lat']; // lat | 
| 1247 | 1247 | $data['longitude'] = $line['lon']; // long | 
| 1248 | -			$data['datetime'] = date('Y-m-d H:i:s',substr($line['time'],0,10)); | |
| 1248 | +			$data['datetime'] = date('Y-m-d H:i:s', substr($line['time'], 0, 10)); | |
| 1249 | 1249 | $data['id_source'] = $id_source; | 
| 1250 | 1250 | $data['format_source'] = 'blitzortung'; | 
| 1251 | 1251 | $SI->add($data); | 
| 1252 | 1252 | if ($globalDebug) echo '☈ Lightning added'."\n"; | 
| 1253 | -			$Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']); | |
| 1253 | +			$Source->addLocation('', $data['latitude'], $data['longitude'], 0, '', '', 'blitzortung', 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime']); | |
| 1254 | 1254 | unset($data); | 
| 1255 | 1255 | } | 
| 1256 | 1256 | } | 
| @@ -1275,11 +1275,11 @@ discard block | ||
| 1275 | 1275 | //$value = $formats[$nb]; | 
| 1276 | 1276 | $format = $globalSources[$nb]['format']; | 
| 1277 | 1277 |  		    if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') { | 
| 1278 | - $buffer = @socket_read($r, 6000,PHP_NORMAL_READ); | |
| 1278 | + $buffer = @socket_read($r, 6000, PHP_NORMAL_READ); | |
| 1279 | 1279 |  		    } elseif ($format == 'vrstcp') { | 
| 1280 | 1280 | $buffer = @socket_read($r, 6000); | 
| 1281 | 1281 |  		    } else { | 
| 1282 | - $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); | |
| 1282 | + $az = socket_recvfrom($r, $buffer, 6000, 0, $remote_ip, $remote_port); | |
| 1283 | 1283 | } | 
| 1284 | 1284 | //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); | 
| 1285 | 1285 | //echo $buffer."\n"; | 
| @@ -1288,8 +1288,8 @@ discard block | ||
| 1288 | 1288 | $error = false; | 
| 1289 | 1289 | //$SI::del(); | 
| 1290 | 1290 |  		    if ($format == 'vrstcp') { | 
| 1291 | -			$buffer = explode('},{',$buffer); | |
| 1292 | -		    } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); | |
| 1291 | +			$buffer = explode('},{', $buffer); | |
| 1292 | +		    } else $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer)); | |
| 1293 | 1293 | // SBS format is CSV format | 
| 1294 | 1294 |  		    if ($buffer !== FALSE && $buffer != '') { | 
| 1295 | 1295 | $tt[$format] = 0; | 
| @@ -1323,13 +1323,13 @@ discard block | ||
| 1323 | 1323 | if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; | 
| 1324 | 1324 | if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; | 
| 1325 | 1325 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; | 
| 1326 | -			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); | |
| 1326 | +			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']); | |
| 1327 | 1327 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; | 
| 1328 | 1328 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; | 
| 1329 | 1329 | if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; | 
| 1330 | 1330 | |
| 1331 | 1331 |  			    if (isset($ais_data['timestamp'])) { | 
| 1332 | -				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); | |
| 1332 | +				$data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); | |
| 1333 | 1333 |  			    } else { | 
| 1334 | 1334 |  				$data['datetime'] = date('Y-m-d H:i:s'); | 
| 1335 | 1335 | } | 
| @@ -1340,10 +1340,10 @@ discard block | ||
| 1340 | 1340 |                          } elseif ($format == 'flightgearsp') { | 
| 1341 | 1341 | //echo $buffer."\n"; | 
| 1342 | 1342 |                      	    if (strlen($buffer) > 5) { | 
| 1343 | -				$line = explode(',',$buffer); | |
| 1343 | +				$line = explode(',', $buffer); | |
| 1344 | 1344 | $data = array(); | 
| 1345 | 1345 | //XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p | 
| 1346 | - $data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]),6,'000000',STR_PAD_LEFT),0,6); | |
| 1346 | + $data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]), 6, '000000', STR_PAD_LEFT), 0, 6); | |
| 1347 | 1347 | $data['ident'] = $line[6]; | 
| 1348 | 1348 | $data['aircraft_name'] = $line[7]; | 
| 1349 | 1349 | $data['longitude'] = $line[1]; | 
| @@ -1360,16 +1360,16 @@ discard block | ||
| 1360 | 1360 |                          } elseif ($format == 'acars') { | 
| 1361 | 1361 | if ($globalDebug) echo 'ACARS : '.$buffer."\n"; | 
| 1362 | 1362 | $ACARS->add(trim($buffer)); | 
| 1363 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); | |
| 1363 | + socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port); | |
| 1364 | 1364 | $ACARS->deleteLiveAcarsData(); | 
| 1365 | 1365 |  			} elseif ($format == 'flightgearmp') { | 
| 1366 | -			    if (substr($buffer,0,1) != '#') { | |
| 1366 | +			    if (substr($buffer, 0, 1) != '#') { | |
| 1367 | 1367 | $data = array(); | 
| 1368 | 1368 | //echo $buffer."\n"; | 
| 1369 | -				$line = explode(' ',$buffer); | |
| 1369 | +				$line = explode(' ', $buffer); | |
| 1370 | 1370 |  				if (count($line) == 11) { | 
| 1371 | -				    $userserver = explode('@',$line[0]); | |
| 1372 | - $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex | |
| 1371 | +				    $userserver = explode('@', $line[0]); | |
| 1372 | + $data['hex'] = substr(str_pad(bin2hex($line[0]), 6, '000000', STR_PAD_LEFT), 0, 6); // hex | |
| 1373 | 1373 | $data['ident'] = $userserver[0]; | 
| 1374 | 1374 | $data['registration'] = $userserver[0]; | 
| 1375 | 1375 | $data['latitude'] = $line[4]; | 
| @@ -1377,8 +1377,8 @@ discard block | ||
| 1377 | 1377 | $data['altitude'] = $line[6]; | 
| 1378 | 1378 |  				    $data['datetime'] = date('Y-m-d H:i:s'); | 
| 1379 | 1379 | $aircraft_type = $line[10]; | 
| 1380 | -				    $aircraft_type = preg_split(':/:',$aircraft_type); | |
| 1381 | - $data['aircraft_name'] = substr(end($aircraft_type),0,-4); | |
| 1380 | +				    $aircraft_type = preg_split(':/:', $aircraft_type); | |
| 1381 | + $data['aircraft_name'] = substr(end($aircraft_type), 0, -4); | |
| 1382 | 1382 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; | 
| 1383 | 1383 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); | 
| 1384 | 1384 | } | 
| @@ -1387,8 +1387,8 @@ discard block | ||
| 1387 | 1387 | echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; | 
| 1388 | 1388 | die; | 
| 1389 | 1389 |  			} elseif ($format == 'vrstcp') { | 
| 1390 | -			    foreach($buffer as $all_data) { | |
| 1391 | -				$line = json_decode('{'.$all_data.'}',true); | |
| 1390 | +			    foreach ($buffer as $all_data) { | |
| 1391 | +				$line = json_decode('{'.$all_data.'}', true); | |
| 1392 | 1392 | $data = array(); | 
| 1393 | 1393 | if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex | 
| 1394 | 1394 | if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident | 
| @@ -1414,16 +1414,16 @@ discard block | ||
| 1414 | 1414 | if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); | 
| 1415 | 1415 | unset($data); | 
| 1416 | 1416 | } | 
| 1417 | -			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') { | |
| 1417 | +			} elseif ($format == 'tsv' || substr($buffer, 0, 4) == 'clock') { | |
| 1418 | 1418 |  			    $line = explode("\t", $buffer); | 
| 1419 | -			    for($k = 0; $k < count($line); $k=$k+2) { | |
| 1419 | +			    for ($k = 0; $k < count($line); $k = $k + 2) { | |
| 1420 | 1420 | $key = $line[$k]; | 
| 1421 | - $lined[$key] = $line[$k+1]; | |
| 1421 | + $lined[$key] = $line[$k + 1]; | |
| 1422 | 1422 | } | 
| 1423 | 1423 |      			    if (count($lined) > 3) { | 
| 1424 | 1424 | $data['hex'] = $lined['hexid']; | 
| 1425 | 1425 |      				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; | 
| 1426 | -    				$data['datetime'] = date('Y-m-d H:i:s');; | |
| 1426 | +    				$data['datetime'] = date('Y-m-d H:i:s'); ; | |
| 1427 | 1427 | if (isset($lined['ident'])) $data['ident'] = $lined['ident']; | 
| 1428 | 1428 | if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; | 
| 1429 | 1429 | if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; | 
| @@ -1442,22 +1442,22 @@ discard block | ||
| 1442 | 1442 | } else $error = true; | 
| 1443 | 1443 |  			} elseif ($format == 'aprs' && $use_aprs) { | 
| 1444 | 1444 |  			    if ($aprs_connect == 0) { | 
| 1445 | - $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); | |
| 1445 | + $send = @ socket_send($r, $aprs_login, strlen($aprs_login), 0); | |
| 1446 | 1446 | $aprs_connect = 1; | 
| 1447 | 1447 | } | 
| 1448 | 1448 | |
| 1449 | -			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { | |
| 1449 | +			    if ($aprs_keep > 60 && time() - $aprs_last_tx > $aprs_keep) { | |
| 1450 | 1450 | $aprs_last_tx = time(); | 
| 1451 | 1451 | $data_aprs = "# Keep alive"; | 
| 1452 | - $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); | |
| 1452 | + $send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0); | |
| 1453 | 1453 | } | 
| 1454 | 1454 | |
| 1455 | 1455 | //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; | 
| 1456 | 1456 | //echo 'APRS data : '.$buffer."\n"; | 
| 1457 | -			    $buffer = str_replace('APRS <- ','',$buffer); | |
| 1458 | -			    $buffer = str_replace('APRS -> ','',$buffer); | |
| 1457 | +			    $buffer = str_replace('APRS <- ', '', $buffer); | |
| 1458 | +			    $buffer = str_replace('APRS -> ', '', $buffer); | |
| 1459 | 1459 | //echo $buffer."\n"; | 
| 1460 | -			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { | |
| 1460 | +			    if (substr($buffer, 0, 1) != '#' && substr($buffer, 0, 1) != '@' && substr($buffer, 0, 5) != 'APRS ') { | |
| 1461 | 1461 | $line = $APRS->parse($buffer); | 
| 1462 | 1462 |  				//if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) { | 
| 1463 | 1463 |  				if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) { | 
| @@ -1472,7 +1472,7 @@ discard block | ||
| 1472 | 1472 | if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date']; | 
| 1473 | 1473 | if (isset($line['type_id'])) $data['type_id'] = $line['typeid']; | 
| 1474 | 1474 | if (isset($line['status_id'])) $data['status_id'] = $line['statusid']; | 
| 1475 | -				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); | |
| 1475 | +				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']); | |
| 1476 | 1476 |  				    else $data['datetime'] = date('Y-m-d H:i:s'); | 
| 1477 | 1477 |  				    //$data['datetime'] = date('Y-m-d H:i:s'); | 
| 1478 | 1478 | if (isset($line['ident'])) $data['ident'] = $line['ident']; | 
| @@ -1551,29 +1551,29 @@ discard block | ||
| 1551 | 1551 |  				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { | 
| 1552 | 1552 | if (!isset($data['altitude'])) $data['altitude'] = 0; | 
| 1553 | 1553 |  					$Source->deleteOldLocationByType('gs'); | 
| 1554 | -					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) { | |
| 1555 | - $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); | |
| 1554 | +					if (count($Source->getLocationInfoByNameType($data['ident'], 'gs')) > 0) { | |
| 1555 | + $Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']); | |
| 1556 | 1556 |  					} else { | 
| 1557 | - $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); | |
| 1557 | + $Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']); | |
| 1558 | 1558 | } | 
| 1559 | 1559 |  				    } elseif (isset($line['symbol']) && $line['symbol'] == 'Weather Station') { | 
| 1560 | 1560 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; | 
| 1561 | 1561 | if ($globalDebug) echo '# Weather Station added'."\n"; | 
| 1562 | 1562 |  					$Source->deleteOldLocationByType('wx'); | 
| 1563 | 1563 | $weather_data = json_encode($line); | 
| 1564 | -					if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) { | |
| 1565 | - $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data); | |
| 1564 | +					if (count($Source->getLocationInfoByNameType($data['ident'], 'wx')) > 0) { | |
| 1565 | + $Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data); | |
| 1566 | 1566 |  					} else { | 
| 1567 | - $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data); | |
| 1567 | + $Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data); | |
| 1568 | 1568 | } | 
| 1569 | 1569 |  				    } elseif (isset($line['symbol']) && $line['symbol'] == 'Lightning') { | 
| 1570 | 1570 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; | 
| 1571 | 1571 | if ($globalDebug) echo '☈ Lightning added'."\n"; | 
| 1572 | 1572 |  					$Source->deleteOldLocationByType('lightning'); | 
| 1573 | -					if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) { | |
| 1574 | - $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']); | |
| 1573 | +					if (count($Source->getLocationInfoByNameType($data['ident'], 'lightning')) > 0) { | |
| 1574 | + $Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']); | |
| 1575 | 1575 |  					} else { | 
| 1576 | - $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']); | |
| 1576 | + $Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']); | |
| 1577 | 1577 | } | 
| 1578 | 1578 |  				    } elseif ($globalDebug) { | 
| 1579 | 1579 | echo '/!\ Not added: '.$buffer."\n"; | 
| @@ -1582,7 +1582,7 @@ discard block | ||
| 1582 | 1582 | unset($data); | 
| 1583 | 1583 | } | 
| 1584 | 1584 |  				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { | 
| 1585 | - $Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']); | |
| 1585 | + $Source->updateLocationDescByName($line['ident'], $line['source'], $id, $line['comment']); | |
| 1586 | 1586 | } | 
| 1587 | 1587 | /* | 
| 1588 | 1588 |  				elseif (is_array($line) && $globalDebug && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] == 'Car' || $line['symbol'] == 'Ambulance' || $line['symbol'] == 'Van' || $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || $line['symbol'] == 'Motorcycle')) { | 
| @@ -1591,7 +1591,7 @@ discard block | ||
| 1591 | 1591 | */ | 
| 1592 | 1592 |  				//elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n"; | 
| 1593 | 1593 | elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n"; | 
| 1594 | -				if (isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) { | |
| 1594 | +				if (isset($globalSources[$nb]['last_weather_clean']) && time() - $globalSources[$nb]['last_weather_clean'] > 60*5) { | |
| 1595 | 1595 |  					$Source->deleteOldLocationByType('lightning'); | 
| 1596 | 1596 |  					$Source->deleteOldLocationByType('wx'); | 
| 1597 | 1597 | $globalSources[$nb]['last_weather_clean'] = time(); | 
| @@ -1676,7 +1676,7 @@ discard block | ||
| 1676 | 1676 | connect_all($sourceee); | 
| 1677 | 1677 | $sourceee = array(); | 
| 1678 | 1678 | //connect_all($globalSources); | 
| 1679 | - $tt[$format]=0; | |
| 1679 | + $tt[$format] = 0; | |
| 1680 | 1680 | break; | 
| 1681 | 1681 | } | 
| 1682 | 1682 | } | 
| @@ -1685,14 +1685,14 @@ discard block | ||
| 1685 | 1685 |  	    } else { | 
| 1686 | 1686 | $error = socket_strerror(socket_last_error()); | 
| 1687 | 1687 |  		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { | 
| 1688 | - if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; | |
| 1688 | + if ($globalDebug) echo "ERROR : socket_select give this error ".$error."\n"; | |
| 1689 | 1689 | if (isset($globalDebug)) echo "Restarting...\n"; | 
| 1690 | 1690 | // Restart the script if possible | 
| 1691 | 1691 |  			if (is_array($sockets)) { | 
| 1692 | 1692 | if ($globalDebug) echo "Shutdown all sockets..."; | 
| 1693 | 1693 | |
| 1694 | 1694 |  			    foreach ($sockets as $sock) { | 
| 1695 | - @socket_shutdown($sock,2); | |
| 1695 | + @socket_shutdown($sock, 2); | |
| 1696 | 1696 | @socket_close($sock); | 
| 1697 | 1697 | } | 
| 1698 | 1698 | |
| @@ -14,13 +14,17 @@ discard block | ||
| 14 | 14 | require_once(dirname(__FILE__).'/../require/class.Source.php'); | 
| 15 | 15 | require_once(dirname(__FILE__).'/../require/class.Connection.php'); | 
| 16 | 16 | require_once(dirname(__FILE__).'/../require/class.Common.php'); | 
| 17 | -if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); | |
| 17 | +if (isset($globalTracker) && $globalTracker) { | |
| 18 | + require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); | |
| 19 | +} | |
| 18 | 20 |  if (isset($globalMarine) && $globalMarine) { | 
| 19 | 21 | require_once(dirname(__FILE__).'/../require/class.AIS.php'); | 
| 20 | 22 | require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); | 
| 21 | 23 | } | 
| 22 | 24 | |
| 23 | -if (!isset($globalDebug)) $globalDebug = FALSE; | |
| 25 | +if (!isset($globalDebug)) { | |
| 26 | + $globalDebug = FALSE; | |
| 27 | +} | |
| 24 | 28 | |
| 25 | 29 | // Check if schema is at latest version | 
| 26 | 30 | $Connection = new Connection(); | 
| @@ -55,35 +59,62 @@ discard block | ||
| 55 | 59 | //elseif (isset($options['source'])) $hosts = array($options['source']); | 
| 56 | 60 |  if (isset($options['s'])) { | 
| 57 | 61 | $globalSources = array(); | 
| 58 | -    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); | |
| 59 | -    else $globalSources[] = array('host' => $options['s']); | |
| 60 | -} elseif (isset($options['source'])) { | |
| 62 | +    if (isset($options['format'])) { | |
| 63 | +    	$globalSources[] = array('host' => $options['s'],'format' => $options['format']); | |
| 64 | +    } else { | |
| 65 | +    	$globalSources[] = array('host' => $options['s']); | |
| 66 | + } | |
| 67 | +    } elseif (isset($options['source'])) { | |
| 61 | 68 | $globalSources = array(); | 
| 62 | -    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); | |
| 63 | -    else $globalSources[] = array('host' => $options['source']); | |
| 64 | -} | |
| 69 | +    if (isset($options['format'])) { | |
| 70 | +    	$globalSources[] = array('host' => $options['source'],'format' => $options['format']); | |
| 71 | +    } else { | |
| 72 | +    	$globalSources[] = array('host' => $options['source']); | |
| 73 | + } | |
| 74 | + } | |
| 65 | 75 |  if (isset($options['aprsserverhost'])) { | 
| 66 | 76 | $globalServerAPRS = TRUE; | 
| 67 | 77 | $globalServerAPRShost = $options['aprsserverhost']; | 
| 68 | 78 | } | 
| 69 | -if (isset($options['aprsserverport'])) $globalServerAPRSport = $options['aprsserverport']; | |
| 70 | -if (isset($options['aprsserverssid'])) $globalServerAPRSssid = $options['aprsserverssid']; | |
| 71 | -if (isset($options['aprsserverpass'])) $globalServerAPRSpass = $options['aprsserverpass']; | |
| 72 | -if (isset($options['noaprsserver'])) $globalServerAPRS = FALSE; | |
| 73 | -if (isset($options['nodaemon'])) $globalDaemon = FALSE; | |
| 74 | -if (isset($options['server'])) $globalServer = TRUE; | |
| 75 | -if (isset($options['idsource'])) $id_source = $options['idsource']; | |
| 76 | -else $id_source = 1; | |
| 79 | +if (isset($options['aprsserverport'])) { | |
| 80 | + $globalServerAPRSport = $options['aprsserverport']; | |
| 81 | +} | |
| 82 | +if (isset($options['aprsserverssid'])) { | |
| 83 | + $globalServerAPRSssid = $options['aprsserverssid']; | |
| 84 | +} | |
| 85 | +if (isset($options['aprsserverpass'])) { | |
| 86 | + $globalServerAPRSpass = $options['aprsserverpass']; | |
| 87 | +} | |
| 88 | +if (isset($options['noaprsserver'])) { | |
| 89 | + $globalServerAPRS = FALSE; | |
| 90 | +} | |
| 91 | +if (isset($options['nodaemon'])) { | |
| 92 | + $globalDaemon = FALSE; | |
| 93 | +} | |
| 94 | +if (isset($options['server'])) { | |
| 95 | + $globalServer = TRUE; | |
| 96 | +} | |
| 97 | +if (isset($options['idsource'])) { | |
| 98 | + $id_source = $options['idsource']; | |
| 99 | +} else { | |
| 100 | + $id_source = 1; | |
| 101 | +} | |
| 77 | 102 |  if (isset($globalServer) && $globalServer) { | 
| 78 | - if ($globalDebug) echo "Using Server Mode\n"; | |
| 103 | +    if ($globalDebug) { | |
| 104 | + echo "Using Server Mode\n"; | |
| 105 | + } | |
| 79 | 106 | $SI=new SpotterServer(); | 
| 80 | 107 | /* | 
| 81 | 108 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); | 
| 82 | 109 | $SI = new adsb2aprs(); | 
| 83 | 110 | $SI->connect(); | 
| 84 | 111 | */ | 
| 85 | -} else $SI=new SpotterImport($Connection->db); | |
| 86 | -if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db); | |
| 112 | +} else { | |
| 113 | + $SI=new SpotterImport($Connection->db); | |
| 114 | +} | |
| 115 | +if (isset($globalTracker) && $globalTracker) { | |
| 116 | + $TI = new TrackerImport($Connection->db); | |
| 117 | +} | |
| 87 | 118 |  if (isset($globalMarine) && $globalMarine) { | 
| 88 | 119 | $AIS = new AIS(); | 
| 89 | 120 | $MI = new MarineImport($Connection->db); | 
| @@ -106,7 +137,9 @@ discard block | ||
| 106 | 137 | } | 
| 107 | 138 | |
| 108 | 139 | // let's try and connect | 
| 109 | -if ($globalDebug) echo "Connecting...\n"; | |
| 140 | +if ($globalDebug) { | |
| 141 | + echo "Connecting...\n"; | |
| 142 | +} | |
| 110 | 143 | $use_aprs = false; | 
| 111 | 144 | $aprs_full = false; | 
| 112 | 145 | $reset = 0; | 
| @@ -115,7 +148,9 @@ discard block | ||
| 115 | 148 | //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; | 
| 116 | 149 | global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; | 
| 117 | 150 | $reset++; | 
| 118 | - if ($globalDebug) echo 'Connect to all...'."\n"; | |
| 151 | +    if ($globalDebug) { | |
| 152 | + echo 'Connect to all...'."\n"; | |
| 153 | + } | |
| 119 | 154 |      foreach ($hosts as $id => $value) { | 
| 120 | 155 | $host = $value['host']; | 
| 121 | 156 | $globalSources[$id]['last_exec'] = 0; | 
| @@ -125,22 +160,30 @@ discard block | ||
| 125 | 160 | //$formats[$id] = 'deltadbtxt'; | 
| 126 | 161 | $globalSources[$id]['format'] = 'deltadbtxt'; | 
| 127 | 162 | //$last_exec['deltadbtxt'] = 0; | 
| 128 | -        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; | |
| 163 | +        	if ($globalDebug) { | |
| 164 | +        		echo "Connect to deltadb source (".$host.")...\n"; | |
| 165 | + } | |
| 129 | 166 |              } else if (preg_match('/vatsim-data.txt$/i',$host)) { | 
| 130 | 167 | //$formats[$id] = 'vatsimtxt'; | 
| 131 | 168 | $globalSources[$id]['format'] = 'vatsimtxt'; | 
| 132 | 169 | //$last_exec['vatsimtxt'] = 0; | 
| 133 | -        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; | |
| 170 | +        	if ($globalDebug) { | |
| 171 | +        		echo "Connect to vatsim source (".$host.")...\n"; | |
| 172 | + } | |
| 134 | 173 |      	    } else if (preg_match('/aircraftlist.json$/i',$host)) { | 
| 135 | 174 | //$formats[$id] = 'aircraftlistjson'; | 
| 136 | 175 | $globalSources[$id]['format'] = 'aircraftlistjson'; | 
| 137 | 176 | //$last_exec['aircraftlistjson'] = 0; | 
| 138 | -        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; | |
| 177 | +        	if ($globalDebug) { | |
| 178 | +        		echo "Connect to aircraftlist.json source (".$host.")...\n"; | |
| 179 | + } | |
| 139 | 180 |      	    } else if (preg_match('/opensky/i',$host)) { | 
| 140 | 181 | //$formats[$id] = 'aircraftlistjson'; | 
| 141 | 182 | $globalSources[$id]['format'] = 'opensky'; | 
| 142 | 183 | //$last_exec['aircraftlistjson'] = 0; | 
| 143 | -        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; | |
| 184 | +        	if ($globalDebug) { | |
| 185 | +        		echo "Connect to opensky source (".$host.")...\n"; | |
| 186 | + } | |
| 144 | 187 | /* | 
| 145 | 188 | // Disabled for now, site change source format | 
| 146 | 189 |      	    } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) { | 
| @@ -157,7 +200,9 @@ discard block | ||
| 157 | 200 | //$formats[$id] = 'planeupdatefaa'; | 
| 158 | 201 | $globalSources[$id]['format'] = 'planeupdatefaa'; | 
| 159 | 202 | //$last_exec['planeupdatefaa'] = 0; | 
| 160 | -        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; | |
| 203 | +        	if ($globalDebug) { | |
| 204 | +        		echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; | |
| 205 | + } | |
| 161 | 206 |          	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { | 
| 162 | 207 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; | 
| 163 | 208 | exit(0); | 
| @@ -166,32 +211,46 @@ discard block | ||
| 166 | 211 | //$formats[$id] = 'phpvmacars'; | 
| 167 | 212 | $globalSources[$id]['format'] = 'phpvmacars'; | 
| 168 | 213 | //$last_exec['phpvmacars'] = 0; | 
| 169 | -        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; | |
| 214 | +        	if ($globalDebug) { | |
| 215 | +        		echo "Connect to phpvmacars source (".$host.")...\n"; | |
| 216 | + } | |
| 170 | 217 |              } else if (preg_match('/VAM-json.php$/i',$host)) { | 
| 171 | 218 | //$formats[$id] = 'phpvmacars'; | 
| 172 | 219 | $globalSources[$id]['format'] = 'vam'; | 
| 173 | -        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; | |
| 220 | +        	if ($globalDebug) { | |
| 221 | +        		echo "Connect to Vam source (".$host.")...\n"; | |
| 222 | + } | |
| 174 | 223 |              } else if (preg_match('/whazzup/i',$host)) { | 
| 175 | 224 | //$formats[$id] = 'whazzup'; | 
| 176 | 225 | $globalSources[$id]['format'] = 'whazzup'; | 
| 177 | 226 | //$last_exec['whazzup'] = 0; | 
| 178 | -        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; | |
| 227 | +        	if ($globalDebug) { | |
| 228 | +        		echo "Connect to whazzup source (".$host.")...\n"; | |
| 229 | + } | |
| 179 | 230 |              } else if (preg_match('/blitzortung/i',$host)) { | 
| 180 | 231 | $globalSources[$id]['format'] = 'blitzortung'; | 
| 181 | -        	if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n"; | |
| 232 | +        	if ($globalDebug) { | |
| 233 | +        		echo "Connect to blitzortung source (".$host.")...\n"; | |
| 234 | + } | |
| 182 | 235 |              } else if (preg_match('/airwhere/i',$host)) { | 
| 183 | 236 | $globalSources[$id]['format'] = 'airwhere'; | 
| 184 | -        	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; | |
| 237 | +        	if ($globalDebug) { | |
| 238 | +        		echo "Connect to airwhere source (".$host.")...\n"; | |
| 239 | + } | |
| 185 | 240 |              } else if (preg_match('/recentpireps/i',$host)) { | 
| 186 | 241 | //$formats[$id] = 'pirepsjson'; | 
| 187 | 242 | $globalSources[$id]['format'] = 'pirepsjson'; | 
| 188 | 243 | //$last_exec['pirepsjson'] = 0; | 
| 189 | -        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; | |
| 244 | +        	if ($globalDebug) { | |
| 245 | +        		echo "Connect to pirepsjson source (".$host.")...\n"; | |
| 246 | + } | |
| 190 | 247 |              } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { | 
| 191 | 248 | //$formats[$id] = 'fr24json'; | 
| 192 | 249 | $globalSources[$id]['format'] = 'fr24json'; | 
| 193 | 250 | //$last_exec['fr24json'] = 0; | 
| 194 | -        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; | |
| 251 | +        	if ($globalDebug) { | |
| 252 | +        		echo "Connect to fr24 source (".$host.")...\n"; | |
| 253 | + } | |
| 195 | 254 |          	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { | 
| 196 | 255 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; | 
| 197 | 256 | exit(0); | 
| @@ -200,7 +259,9 @@ discard block | ||
| 200 | 259 | //$formats[$id] = 'fr24json'; | 
| 201 | 260 | $globalSources[$id]['format'] = 'myshiptracking'; | 
| 202 | 261 | //$last_exec['fr24json'] = 0; | 
| 203 | -        	if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; | |
| 262 | +        	if ($globalDebug) { | |
| 263 | +        		echo "Connect to myshiptracking source (".$host.")...\n"; | |
| 264 | + } | |
| 204 | 265 |          	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { | 
| 205 | 266 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; | 
| 206 | 267 | exit(0); | 
| @@ -209,17 +270,24 @@ discard block | ||
| 209 | 270 |              } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { | 
| 210 | 271 | //$formats[$id] = 'tsv'; | 
| 211 | 272 | $globalSources[$id]['format'] = 'tsv'; | 
| 212 | -        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; | |
| 273 | +        	if ($globalDebug) { | |
| 274 | +        		echo "Connect to tsv source (".$host.")...\n"; | |
| 275 | + } | |
| 213 | 276 | } | 
| 214 | 277 |          } elseif (filter_var($host,FILTER_VALIDATE_URL)) { | 
| 215 | 278 |      		if ($globalSources[$id]['format'] == 'aisnmeahttp') { | 
| 216 | 279 | $idf = fopen($globalSources[$id]['host'],'r',false,$context); | 
| 217 | 280 |      		    if ($idf !== false) { | 
| 218 | 281 | $httpfeeds[$id] = $idf; | 
| 219 | -        		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; | |
| 282 | +        		if ($globalDebug) { | |
| 283 | +        			echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; | |
| 284 | + } | |
| 285 | +    		    } elseif ($globalDebug) { | |
| 286 | + echo "Can't connect to ".$globalSources[$id]['host']."\n"; | |
| 220 | 287 | } | 
| 221 | - elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; | |
| 222 | -    		} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; | |
| 288 | +    		} elseif ($globalDebug) { | |
| 289 | +    			echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; | |
| 290 | + } | |
| 223 | 291 |          } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { | 
| 224 | 292 |  	    $hostport = explode(':',$host); | 
| 225 | 293 |  	    if (isset($hostport[1])) { | 
| @@ -259,17 +327,25 @@ discard block | ||
| 259 | 327 | //$formats[$id] = 'beast'; | 
| 260 | 328 | $globalSources[$id]['format'] = 'beast'; | 
| 261 | 329 | //} else $formats[$id] = 'sbs'; | 
| 262 | - } else $globalSources[$id]['format'] = 'sbs'; | |
| 330 | +		    } else { | |
| 331 | + $globalSources[$id]['format'] = 'sbs'; | |
| 332 | + } | |
| 263 | 333 |  		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; | 
| 264 | 334 | } | 
| 265 | -		if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; | |
| 335 | +		if ($globalDebug) { | |
| 336 | +			echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; | |
| 337 | + } | |
| 266 | 338 |              } else { | 
| 267 | - if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; | |
| 339 | +		if ($globalDebug) { | |
| 340 | + echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; | |
| 341 | + } | |
| 268 | 342 | } | 
| 269 | 343 | } | 
| 270 | 344 | } | 
| 271 | 345 | } | 
| 272 | -if (!isset($globalMinFetch)) $globalMinFetch = 15; | |
| 346 | +if (!isset($globalMinFetch)) { | |
| 347 | + $globalMinFetch = 15; | |
| 348 | +} | |
| 273 | 349 | |
| 274 | 350 | // Initialize all | 
| 275 | 351 | $status = array(); | 
| @@ -278,13 +354,19 @@ discard block | ||
| 278 | 354 | $formats = array(); | 
| 279 | 355 | $last_exec = array(); | 
| 280 | 356 | $time = time(); | 
| 281 | -if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut; | |
| 282 | -else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut; | |
| 283 | -else $timeout = 20; | |
| 357 | +if (isset($globalSourcesTimeout)) { | |
| 358 | + $timeout = $globalSourcesTimeOut; | |
| 359 | +} else if (isset($globalSBS1TimeOut)) { | |
| 360 | + $timeout = $globalSBS1TimeOut; | |
| 361 | +} else { | |
| 362 | + $timeout = 20; | |
| 363 | +} | |
| 284 | 364 | $errno = ''; | 
| 285 | 365 | $errstr=''; | 
| 286 | 366 | |
| 287 | -if (!isset($globalDaemon)) $globalDaemon = TRUE; | |
| 367 | +if (!isset($globalDaemon)) { | |
| 368 | + $globalDaemon = TRUE; | |
| 369 | +} | |
| 288 | 370 | /* Initiate connections to all the hosts simultaneously */ | 
| 289 | 371 | //connect_all($hosts); | 
| 290 | 372 | //connect_all($globalSources); | 
| @@ -313,7 +395,9 @@ discard block | ||
| 313 | 395 |      if (isset($source['format']) && $source['format'] == 'aprs') { | 
| 314 | 396 | $aprs_connect = 0; | 
| 315 | 397 | $use_aprs = true; | 
| 316 | - if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true; | |
| 398 | +	if (isset($source['port']) && $source['port'] == '10152') { | |
| 399 | + $aprs_full = true; | |
| 400 | + } | |
| 317 | 401 | break; | 
| 318 | 402 | } | 
| 319 | 403 | } | 
| @@ -324,25 +408,48 @@ discard block | ||
| 324 | 408 | $aprs_connect = 0; | 
| 325 | 409 | $aprs_keep = 120; | 
| 326 | 410 | $aprs_last_tx = time(); | 
| 327 | - if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; | |
| 328 | -	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); | |
| 329 | - if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid; | |
| 330 | -	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); | |
| 331 | - if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter; | |
| 332 | - else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; | |
| 333 | - if ($aprs_full) $aprs_filter = ''; | |
| 334 | - if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass; | |
| 335 | - else $aprs_pass = '-1'; | |
| 411 | +	if (isset($globalAPRSversion)) { | |
| 412 | + $aprs_version = $globalAPRSversion; | |
| 413 | +	} else { | |
| 414 | +		$aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); | |
| 415 | + } | |
| 416 | +	if (isset($globalAPRSssid)) { | |
| 417 | + $aprs_ssid = $globalAPRSssid; | |
| 418 | +	} else { | |
| 419 | +		$aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); | |
| 420 | + } | |
| 421 | +	if (isset($globalAPRSfilter)) { | |
| 422 | + $aprs_filter = $globalAPRSfilter; | |
| 423 | +	} else { | |
| 424 | + $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; | |
| 425 | + } | |
| 426 | +	if ($aprs_full) { | |
| 427 | + $aprs_filter = ''; | |
| 428 | + } | |
| 429 | +	if (isset($globalAPRSpass)) { | |
| 430 | + $aprs_pass = $globalAPRSpass; | |
| 431 | +	} else { | |
| 432 | + $aprs_pass = '-1'; | |
| 433 | + } | |
| 336 | 434 | |
| 337 | -	if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n"; | |
| 338 | -	else $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; | |
| 339 | -} | |
| 435 | +	if ($aprs_filter != '') { | |
| 436 | +		$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n"; | |
| 437 | +	} else { | |
| 438 | +		$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; | |
| 439 | + } | |
| 440 | + } | |
| 340 | 441 | |
| 341 | 442 | // connected - lets do some work | 
| 342 | -if ($globalDebug) echo "Connected!\n"; | |
| 443 | +if ($globalDebug) { | |
| 444 | + echo "Connected!\n"; | |
| 445 | +} | |
| 343 | 446 | sleep(1); | 
| 344 | -if ($globalDebug) echo "SCAN MODE \n\n"; | |
| 345 | -if (!isset($globalCronEnd)) $globalCronEnd = 60; | |
| 447 | +if ($globalDebug) { | |
| 448 | + echo "SCAN MODE \n\n"; | |
| 449 | +} | |
| 450 | +if (!isset($globalCronEnd)) { | |
| 451 | + $globalCronEnd = 60; | |
| 452 | +} | |
| 346 | 453 | $endtime = time()+$globalCronEnd; | 
| 347 | 454 | $i = 1; | 
| 348 | 455 | $tt = array(); | 
| @@ -356,20 +463,28 @@ discard block | ||
| 356 | 463 | |
| 357 | 464 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. | 
| 358 | 465 |  while ($i > 0) { | 
| 359 | - if (!$globalDaemon) $i = $endtime-time(); | |
| 466 | +    if (!$globalDaemon) { | |
| 467 | + $i = $endtime-time(); | |
| 468 | + } | |
| 360 | 469 | // Delete old ATC | 
| 361 | 470 |      if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { | 
| 362 | - if ($globalDebug) echo 'Delete old ATC...'."\n"; | |
| 471 | +	if ($globalDebug) { | |
| 472 | + echo 'Delete old ATC...'."\n"; | |
| 473 | + } | |
| 363 | 474 | $ATC->deleteOldATC(); | 
| 364 | 475 | } | 
| 365 | 476 | |
| 366 | 477 |      if (count($last_exec) == count($globalSources)) { | 
| 367 | 478 | $max = $globalMinFetch; | 
| 368 | 479 |  	foreach ($last_exec as $last) { | 
| 369 | - if ((time() - $last['last']) < $max) $max = time() - $last['last']; | |
| 480 | +	    if ((time() - $last['last']) < $max) { | |
| 481 | + $max = time() - $last['last']; | |
| 482 | + } | |
| 370 | 483 | } | 
| 371 | 484 |  	if ($max != $globalMinFetch) { | 
| 372 | - if ($globalDebug) echo 'Sleeping...'."\n"; | |
| 485 | +	    if ($globalDebug) { | |
| 486 | + echo 'Sleeping...'."\n"; | |
| 487 | + } | |
| 373 | 488 | sleep($globalMinFetch-$max+2); | 
| 374 | 489 | } | 
| 375 | 490 | } | 
| @@ -379,7 +494,9 @@ discard block | ||
| 379 | 494 |      foreach ($globalSources as $id => $value) { | 
| 380 | 495 |  	date_default_timezone_set('UTC'); | 
| 381 | 496 | //if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n"; | 
| 382 | - if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0; | |
| 497 | +	if (!isset($last_exec[$id]['last'])) { | |
| 498 | + $last_exec[$id]['last'] = 0; | |
| 499 | + } | |
| 383 | 500 | if ($value['format'] == 'deltadbtxt' && | 
| 384 | 501 | ( | 
| 385 | 502 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || | 
| @@ -388,7 +505,9 @@ discard block | ||
| 388 | 505 |  	) { | 
| 389 | 506 | //$buffer = $Common->getData($hosts[$id]); | 
| 390 | 507 | $buffer = $Common->getData($value['host']); | 
| 391 | - if ($buffer != '') $reset = 0; | |
| 508 | +	    if ($buffer != '') { | |
| 509 | + $reset = 0; | |
| 510 | + } | |
| 392 | 511 |      	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); | 
| 393 | 512 |  	    $buffer = explode('\n',$buffer); | 
| 394 | 513 |  	    foreach ($buffer as $line) { | 
| @@ -397,20 +516,41 @@ discard block | ||
| 397 | 516 | $data = array(); | 
| 398 | 517 | $data['hex'] = $line[1]; // hex | 
| 399 | 518 | $data['ident'] = $line[2]; // ident | 
| 400 | - if (isset($line[3])) $data['altitude'] = $line[3]; // altitude | |
| 401 | - if (isset($line[4])) $data['speed'] = $line[4]; // speed | |
| 402 | - if (isset($line[5])) $data['heading'] = $line[5]; // heading | |
| 403 | - if (isset($line[6])) $data['latitude'] = $line[6]; // lat | |
| 404 | - if (isset($line[7])) $data['longitude'] = $line[7]; // long | |
| 519 | +	            if (isset($line[3])) { | |
| 520 | + $data['altitude'] = $line[3]; | |
| 521 | + } | |
| 522 | + // altitude | |
| 523 | +	            if (isset($line[4])) { | |
| 524 | + $data['speed'] = $line[4]; | |
| 525 | + } | |
| 526 | + // speed | |
| 527 | +	            if (isset($line[5])) { | |
| 528 | + $data['heading'] = $line[5]; | |
| 529 | + } | |
| 530 | + // heading | |
| 531 | +	            if (isset($line[6])) { | |
| 532 | + $data['latitude'] = $line[6]; | |
| 533 | + } | |
| 534 | + // lat | |
| 535 | +	            if (isset($line[7])) { | |
| 536 | + $data['longitude'] = $line[7]; | |
| 537 | + } | |
| 538 | + // long | |
| 405 | 539 | $data['verticalrate'] = ''; // vertical rate | 
| 406 | 540 | //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk | 
| 407 | 541 | $data['emergency'] = ''; // emergency | 
| 408 | 542 |  		    $data['datetime'] = date('Y-m-d H:i:s'); | 
| 409 | 543 | $data['format_source'] = 'deltadbtxt'; | 
| 410 | 544 | $data['id_source'] = $id_source; | 
| 411 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; | |
| 412 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 413 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; | |
| 545 | +		    if (isset($value['name']) && $value['name'] != '') { | |
| 546 | + $data['source_name'] = $value['name']; | |
| 547 | + } | |
| 548 | +		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { | |
| 549 | + $data['noarchive'] = true; | |
| 550 | + } | |
| 551 | +		    if (isset($value['sourcestats'])) { | |
| 552 | + $data['sourcestats'] = $value['sourcestats']; | |
| 553 | + } | |
| 414 | 554 | $SI->add($data); | 
| 415 | 555 | unset($data); | 
| 416 | 556 | } | 
| @@ -425,7 +565,9 @@ discard block | ||
| 425 | 565 |  	    date_default_timezone_set('CET'); | 
| 426 | 566 |  	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); | 
| 427 | 567 |  	    date_default_timezone_set('UTC'); | 
| 428 | - if ($buffer != '') $reset = 0; | |
| 568 | +	    if ($buffer != '') { | |
| 569 | + $reset = 0; | |
| 570 | + } | |
| 429 | 571 |      	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); | 
| 430 | 572 |  	    $buffer = explode('\n',$buffer); | 
| 431 | 573 |  	    foreach ($buffer as $line) { | 
| @@ -434,16 +576,36 @@ discard block | ||
| 434 | 576 | $add = false; | 
| 435 | 577 | $ais_data = $AIS->parse_line(trim($line)); | 
| 436 | 578 | $data = array(); | 
| 437 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; | |
| 438 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; | |
| 439 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; | |
| 440 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; | |
| 441 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; | |
| 442 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; | |
| 443 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; | |
| 444 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; | |
| 445 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; | |
| 446 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; | |
| 579 | +		    if (isset($ais_data['ident'])) { | |
| 580 | + $data['ident'] = $ais_data['ident']; | |
| 581 | + } | |
| 582 | +		    if (isset($ais_data['mmsi'])) { | |
| 583 | + $data['mmsi'] = $ais_data['mmsi']; | |
| 584 | + } | |
| 585 | +		    if (isset($ais_data['speed'])) { | |
| 586 | + $data['speed'] = $ais_data['speed']; | |
| 587 | + } | |
| 588 | +		    if (isset($ais_data['heading'])) { | |
| 589 | + $data['heading'] = $ais_data['heading']; | |
| 590 | + } | |
| 591 | +		    if (isset($ais_data['latitude'])) { | |
| 592 | + $data['latitude'] = $ais_data['latitude']; | |
| 593 | + } | |
| 594 | +		    if (isset($ais_data['longitude'])) { | |
| 595 | + $data['longitude'] = $ais_data['longitude']; | |
| 596 | + } | |
| 597 | +		    if (isset($ais_data['status'])) { | |
| 598 | + $data['status'] = $ais_data['status']; | |
| 599 | + } | |
| 600 | +		    if (isset($ais_data['type'])) { | |
| 601 | + $data['type'] = $ais_data['type']; | |
| 602 | + } | |
| 603 | +		    if (isset($ais_data['imo'])) { | |
| 604 | + $data['imo'] = $ais_data['imo']; | |
| 605 | + } | |
| 606 | +		    if (isset($ais_data['callsign'])) { | |
| 607 | + $data['callsign'] = $ais_data['callsign']; | |
| 608 | + } | |
| 447 | 609 |  		    if (isset($ais_data['timestamp'])) { | 
| 448 | 610 |  			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); | 
| 449 | 611 |  			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { | 
| @@ -457,8 +619,12 @@ discard block | ||
| 457 | 619 | $data['format_source'] = 'aisnmeatxt'; | 
| 458 | 620 | $data['id_source'] = $id_source; | 
| 459 | 621 | //print_r($data); | 
| 460 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 461 | - if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); | |
| 622 | +		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { | |
| 623 | + $data['noarchive'] = true; | |
| 624 | + } | |
| 625 | +		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') { | |
| 626 | + $MI->add($data); | |
| 627 | + } | |
| 462 | 628 | unset($data); | 
| 463 | 629 | } | 
| 464 | 630 | } | 
| @@ -478,20 +644,48 @@ discard block | ||
| 478 | 644 |  			    if ($line != '') { | 
| 479 | 645 | $ais_data = $AIS->parse_line(trim($line)); | 
| 480 | 646 | $data = array(); | 
| 481 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; | |
| 482 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; | |
| 483 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; | |
| 484 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; | |
| 485 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; | |
| 486 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; | |
| 487 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; | |
| 488 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; | |
| 489 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; | |
| 490 | - if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid']; | |
| 491 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; | |
| 492 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; | |
| 493 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; | |
| 494 | -				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); | |
| 647 | +				if (isset($ais_data['ident'])) { | |
| 648 | + $data['ident'] = $ais_data['ident']; | |
| 649 | + } | |
| 650 | +				if (isset($ais_data['mmsi'])) { | |
| 651 | + $data['mmsi'] = $ais_data['mmsi']; | |
| 652 | + } | |
| 653 | +				if (isset($ais_data['speed'])) { | |
| 654 | + $data['speed'] = $ais_data['speed']; | |
| 655 | + } | |
| 656 | +				if (isset($ais_data['heading'])) { | |
| 657 | + $data['heading'] = $ais_data['heading']; | |
| 658 | + } | |
| 659 | +				if (isset($ais_data['latitude'])) { | |
| 660 | + $data['latitude'] = $ais_data['latitude']; | |
| 661 | + } | |
| 662 | +				if (isset($ais_data['longitude'])) { | |
| 663 | + $data['longitude'] = $ais_data['longitude']; | |
| 664 | + } | |
| 665 | +				if (isset($ais_data['status'])) { | |
| 666 | + $data['status'] = $ais_data['status']; | |
| 667 | + } | |
| 668 | +				if (isset($ais_data['statusid'])) { | |
| 669 | + $data['status_id'] = $ais_data['statusid']; | |
| 670 | + } | |
| 671 | +				if (isset($ais_data['type'])) { | |
| 672 | + $data['type'] = $ais_data['type']; | |
| 673 | + } | |
| 674 | +				if (isset($ais_data['typeid'])) { | |
| 675 | + $data['type_id'] = $ais_data['typeid']; | |
| 676 | + } | |
| 677 | +				if (isset($ais_data['imo'])) { | |
| 678 | + $data['imo'] = $ais_data['imo']; | |
| 679 | + } | |
| 680 | +				if (isset($ais_data['callsign'])) { | |
| 681 | + $data['callsign'] = $ais_data['callsign']; | |
| 682 | + } | |
| 683 | +				if (isset($ais_data['destination'])) { | |
| 684 | + $data['arrival_code'] = $ais_data['destination']; | |
| 685 | + } | |
| 686 | +				if (isset($ais_data['eta_ts'])) { | |
| 687 | +					$data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); | |
| 688 | + } | |
| 495 | 689 |  				if (isset($ais_data['timestamp'])) { | 
| 496 | 690 |  				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); | 
| 497 | 691 |  				} else { | 
| @@ -499,18 +693,27 @@ discard block | ||
| 499 | 693 | } | 
| 500 | 694 | $data['format_source'] = 'aisnmeahttp'; | 
| 501 | 695 | $data['id_source'] = $id_source; | 
| 502 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 503 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); | |
| 696 | +				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { | |
| 697 | + $data['noarchive'] = true; | |
| 698 | + } | |
| 699 | +				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') { | |
| 700 | + $MI->add($data); | |
| 701 | + } | |
| 504 | 702 | unset($data); | 
| 505 | 703 | } | 
| 506 | 704 | } | 
| 507 | 705 | } | 
| 508 | 706 |  		} else { | 
| 509 | 707 | $format = $value['format']; | 
| 510 | - if (isset($tt[$format])) $tt[$format]++; | |
| 511 | - else $tt[$format] = 0; | |
| 708 | +		    if (isset($tt[$format])) { | |
| 709 | + $tt[$format]++; | |
| 710 | +		    } else { | |
| 711 | + $tt[$format] = 0; | |
| 712 | + } | |
| 512 | 713 |  		    if ($tt[$format] > 30) { | 
| 513 | - if ($globalDebug) echo 'Reconnect...'."\n"; | |
| 714 | +			if ($globalDebug) { | |
| 715 | + echo 'Reconnect...'."\n"; | |
| 716 | + } | |
| 514 | 717 | sleep(2); | 
| 515 | 718 | $sourceeen[] = $value; | 
| 516 | 719 | connect_all($sourceeen); | 
| @@ -545,7 +748,9 @@ discard block | ||
| 545 | 748 |  			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']); | 
| 546 | 749 | $data['format_source'] = 'myshiptracking'; | 
| 547 | 750 | $data['id_source'] = $id_source; | 
| 548 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 751 | +			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { | |
| 752 | + $data['noarchive'] = true; | |
| 753 | + } | |
| 549 | 754 | $MI->add($data); | 
| 550 | 755 | unset($data); | 
| 551 | 756 | } | 
| @@ -570,7 +775,9 @@ discard block | ||
| 570 | 775 | $data['callsign'] = $line['callsign']; | 
| 571 | 776 | $data['mmsi'] = $line['mmsi']; | 
| 572 | 777 | $data['speed'] = $line['sog']; | 
| 573 | - if ($line['heading'] != '511') $data['heading'] = $line['heading']; | |
| 778 | +			    if ($line['heading'] != '511') { | |
| 779 | + $data['heading'] = $line['heading']; | |
| 780 | + } | |
| 574 | 781 | $data['latitude'] = $line['latitude']; | 
| 575 | 782 | $data['longitude'] = $line['longitude']; | 
| 576 | 783 | $data['type_id'] = $line['shiptype']; | 
| @@ -578,7 +785,9 @@ discard block | ||
| 578 | 785 | $data['datetime'] = $line['time']; | 
| 579 | 786 | $data['format_source'] = 'boatbeaconapp'; | 
| 580 | 787 | $data['id_source'] = $id_source; | 
| 581 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 788 | +			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { | |
| 789 | + $data['noarchive'] = true; | |
| 790 | + } | |
| 582 | 791 | $MI->add($data); | 
| 583 | 792 | unset($data); | 
| 584 | 793 | } | 
| @@ -599,22 +808,44 @@ discard block | ||
| 599 | 808 |  		if (isset($all_data['features'][0]['id'])) { | 
| 600 | 809 |  		    foreach ($all_data['features'] as $line) { | 
| 601 | 810 | $data = array(); | 
| 602 | - if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name']; | |
| 603 | - if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign']; | |
| 604 | - if (isset($line['properties']['mmsi'])) $data['mmsi'] = $line['properties']['mmsi']; | |
| 605 | - if (isset($line['properties']['imo'])) $data['mmsi'] = $line['properties']['imo']; | |
| 606 | - if (isset($line['properties']['speed'])) $data['speed'] = $line['properties']['speed']; | |
| 607 | - if (isset($line['properties']['heading'])) $data['heading'] = $line['properties']['heading']; | |
| 811 | +			if (isset($line['properties']['name'])) { | |
| 812 | + $data['ident'] = $line['properties']['name']; | |
| 813 | + } | |
| 814 | +			if (isset($line['properties']['callsign'])) { | |
| 815 | + $data['callsign'] = $line['properties']['callsign']; | |
| 816 | + } | |
| 817 | +			if (isset($line['properties']['mmsi'])) { | |
| 818 | + $data['mmsi'] = $line['properties']['mmsi']; | |
| 819 | + } | |
| 820 | +			if (isset($line['properties']['imo'])) { | |
| 821 | + $data['mmsi'] = $line['properties']['imo']; | |
| 822 | + } | |
| 823 | +			if (isset($line['properties']['speed'])) { | |
| 824 | + $data['speed'] = $line['properties']['speed']; | |
| 825 | + } | |
| 826 | +			if (isset($line['properties']['heading'])) { | |
| 827 | + $data['heading'] = $line['properties']['heading']; | |
| 828 | + } | |
| 608 | 829 | $data['latitude'] = $line['geometry']['coordinates'][1]; | 
| 609 | 830 | $data['longitude'] = $line['geometry']['coordinates'][0]; | 
| 610 | - if (isset($line['properties']['vesselType'])) $data['type'] = $line['properties']['vesselType']; | |
| 611 | - if (isset($line['properties']['destination'])) $data['arrival_code'] = $line['properties']['destination']; | |
| 612 | - if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') $data['arrival_date'] = $line['properties']['eta']; | |
| 831 | +			if (isset($line['properties']['vesselType'])) { | |
| 832 | + $data['type'] = $line['properties']['vesselType']; | |
| 833 | + } | |
| 834 | +			if (isset($line['properties']['destination'])) { | |
| 835 | + $data['arrival_code'] = $line['properties']['destination']; | |
| 836 | + } | |
| 837 | +			if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') { | |
| 838 | + $data['arrival_date'] = $line['properties']['eta']; | |
| 839 | + } | |
| 613 | 840 | $data['format_source'] = 'boatnerd'; | 
| 614 | 841 | $data['id_source'] = $id_source; | 
| 615 | 842 |  			$data['datetime'] = date('Y-m-d H:i:s'); | 
| 616 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 617 | - if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data); | |
| 843 | +			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { | |
| 844 | + $data['noarchive'] = true; | |
| 845 | + } | |
| 846 | +			if ($line['properties']['vesselType'] != 'Navigation Aid') { | |
| 847 | + $MI->add($data); | |
| 848 | + } | |
| 618 | 849 | unset($data); | 
| 619 | 850 | } | 
| 620 | 851 | } | 
| @@ -630,7 +861,9 @@ discard block | ||
| 630 | 861 | echo 'download...'; | 
| 631 | 862 | $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); | 
| 632 | 863 | echo 'done !'."\n"; | 
| 633 | - if ($buffer != '') $reset = 0; | |
| 864 | +	    if ($buffer != '') { | |
| 865 | + $reset = 0; | |
| 866 | + } | |
| 634 | 867 |      	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); | 
| 635 | 868 |  	    $buffer = explode('\n',$buffer); | 
| 636 | 869 |  	    foreach ($buffer as $line) { | 
| @@ -655,7 +888,9 @@ discard block | ||
| 655 | 888 | //$data['etaTime'] = substr($line,135,5); | 
| 656 | 889 | $data['format_source'] = 'shipplotter'; | 
| 657 | 890 | $data['id_source'] = $id_source; | 
| 658 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 891 | +		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { | |
| 892 | + $data['noarchive'] = true; | |
| 893 | + } | |
| 659 | 894 | //print_r($data); | 
| 660 | 895 | echo 'Add...'."\n"; | 
| 661 | 896 | $MI->add($data); | 
| @@ -689,16 +924,28 @@ discard block | ||
| 689 | 924 |      		    $line = explode(':', $line); | 
| 690 | 925 |      		    if (count($line) > 30 && $line[0] != 'callsign') { | 
| 691 | 926 | $data = array(); | 
| 692 | - if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; | |
| 693 | - else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; | |
| 927 | +			if (isset($line[37]) && $line[37] != '') { | |
| 928 | + $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; | |
| 929 | +			} else { | |
| 930 | + $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; | |
| 931 | + } | |
| 694 | 932 | $data['pilot_id'] = $line[1]; | 
| 695 | 933 | $data['pilot_name'] = $line[2]; | 
| 696 | 934 | $data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT); | 
| 697 | 935 | $data['ident'] = $line[0]; // ident | 
| 698 | - if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude | |
| 936 | +			if ($line[7] != '' && $line[7] != 0) { | |
| 937 | + $data['altitude'] = $line[7]; | |
| 938 | + } | |
| 939 | + // altitude | |
| 699 | 940 | $data['speed'] = $line[8]; // speed | 
| 700 | - if (isset($line[45])) $data['heading'] = $line[45]; // heading | |
| 701 | - elseif (isset($line[38])) $data['heading'] = $line[38]; // heading | |
| 941 | +			if (isset($line[45])) { | |
| 942 | + $data['heading'] = $line[45]; | |
| 943 | + } | |
| 944 | + // heading | |
| 945 | +			elseif (isset($line[38])) { | |
| 946 | + $data['heading'] = $line[38]; | |
| 947 | + } | |
| 948 | + // heading | |
| 702 | 949 | $data['latitude'] = $line[5]; // lat | 
| 703 | 950 | $data['longitude'] = $line[6]; // long | 
| 704 | 951 | $data['verticalrate'] = ''; // vertical rate | 
| @@ -714,7 +961,9 @@ discard block | ||
| 714 | 961 | $data['frequency'] = $line[4]; | 
| 715 | 962 | $data['type'] = $line[18]; | 
| 716 | 963 | $data['range'] = $line[19]; | 
| 717 | - if (isset($line[35])) $data['info'] = $line[35]; | |
| 964 | +			if (isset($line[35])) { | |
| 965 | + $data['info'] = $line[35]; | |
| 966 | + } | |
| 718 | 967 | $data['id_source'] = $id_source; | 
| 719 | 968 | //$data['arrival_airport_time'] = ; | 
| 720 | 969 |  	    		if ($line[9] != '') { | 
| @@ -728,27 +977,47 @@ discard block | ||
| 728 | 977 | elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; | 
| 729 | 978 | */ | 
| 730 | 979 | $data['format_source'] = $value['format']; | 
| 731 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 732 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; | |
| 733 | - if ($line[3] == 'PILOT') $SI->add($data); | |
| 734 | -			elseif ($line[3] == 'ATC') { | |
| 980 | +			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { | |
| 981 | + $data['noarchive'] = true; | |
| 982 | + } | |
| 983 | +			if (isset($value['name']) && $value['name'] != '') { | |
| 984 | + $data['source_name'] = $value['name']; | |
| 985 | + } | |
| 986 | +    			if ($line[3] == 'PILOT') { | |
| 987 | + $SI->add($data); | |
| 988 | +    			} elseif ($line[3] == 'ATC') { | |
| 735 | 989 | //print_r($data); | 
| 736 | 990 |  				$data['info'] = str_replace('^§','<br />',$data['info']); | 
| 737 | 991 |  				$data['info'] = str_replace('&sect;','',$data['info']); | 
| 738 | 992 | $typec = substr($data['ident'],-3); | 
| 739 | - if ($typec == 'APP') $data['type'] = 'Approach'; | |
| 740 | - elseif ($typec == 'TWR') $data['type'] = 'Tower'; | |
| 741 | - elseif ($typec == 'OBS') $data['type'] = 'Observer'; | |
| 742 | - elseif ($typec == 'GND') $data['type'] = 'Ground'; | |
| 743 | - elseif ($typec == 'DEL') $data['type'] = 'Delivery'; | |
| 744 | - elseif ($typec == 'DEP') $data['type'] = 'Departure'; | |
| 745 | - elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station'; | |
| 746 | - elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; | |
| 747 | - elseif ($data['type'] == '') $data['type'] = 'Observer'; | |
| 748 | - if (!isset($data['source_name'])) $data['source_name'] = ''; | |
| 993 | +				if ($typec == 'APP') { | |
| 994 | + $data['type'] = 'Approach'; | |
| 995 | +				} elseif ($typec == 'TWR') { | |
| 996 | + $data['type'] = 'Tower'; | |
| 997 | +				} elseif ($typec == 'OBS') { | |
| 998 | + $data['type'] = 'Observer'; | |
| 999 | +				} elseif ($typec == 'GND') { | |
| 1000 | + $data['type'] = 'Ground'; | |
| 1001 | +				} elseif ($typec == 'DEL') { | |
| 1002 | + $data['type'] = 'Delivery'; | |
| 1003 | +				} elseif ($typec == 'DEP') { | |
| 1004 | + $data['type'] = 'Departure'; | |
| 1005 | +				} elseif ($typec == 'FSS') { | |
| 1006 | + $data['type'] = 'Flight Service Station'; | |
| 1007 | +				} elseif ($typec == 'CTR') { | |
| 1008 | + $data['type'] = 'Control Radar or Centre'; | |
| 1009 | +				} elseif ($data['type'] == '') { | |
| 1010 | + $data['type'] = 'Observer'; | |
| 1011 | + } | |
| 1012 | +				if (!isset($data['source_name'])) { | |
| 1013 | + $data['source_name'] = ''; | |
| 1014 | + } | |
| 749 | 1015 |  				if (isset($ATC)) { | 
| 750 | - 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']); | |
| 751 | - 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']); | |
| 1016 | +					if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) { | |
| 1017 | + 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']); | |
| 1018 | +					} else { | |
| 1019 | + 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']); | |
| 1020 | + } | |
| 752 | 1021 | } | 
| 753 | 1022 | } | 
| 754 | 1023 | unset($data); | 
| @@ -775,14 +1044,20 @@ discard block | ||
| 775 | 1044 |  			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST')); | 
| 776 | 1045 | $data['latitude'] = (float)$line['pktLatitude']; | 
| 777 | 1046 | $data['longitude'] = (float)$line['pktLongitude']; | 
| 778 | - if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack']; | |
| 779 | - if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed']; | |
| 1047 | +			if ((float)$line['pktTrack'] != 0) { | |
| 1048 | + $data['heading'] = (float)$line['pktTrack']; | |
| 1049 | + } | |
| 1050 | +			if ((int)$line['pktSpeed'] != 0) { | |
| 1051 | + $data['speed'] = (int)$line['pktSpeed']; | |
| 1052 | + } | |
| 780 | 1053 | $data['altitude'] = round((int)$line['pktAltitude']*3.28084); | 
| 781 | 1054 | $data['altitude_relative'] = 'AMSL'; | 
| 782 | 1055 | $data['pilot_id'] = (int)$line['pktPilotID']; | 
| 783 | 1056 | $data['aircraft_icao'] = 'PARAGLIDER'; | 
| 784 | 1057 |  			$pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id'])); | 
| 785 | - if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4]; | |
| 1058 | +			if (isset($pilot_data[4])) { | |
| 1059 | + $data['pilot_name'] = $pilot_data[4]; | |
| 1060 | + } | |
| 786 | 1061 | $data['format_source'] = $value['format']; | 
| 787 | 1062 | $SI->add($data); | 
| 788 | 1063 | unset($data); | 
| @@ -830,25 +1105,59 @@ discard block | ||
| 830 | 1105 |  		    foreach ($all_data['acList'] as $line) { | 
| 831 | 1106 | $data = array(); | 
| 832 | 1107 | $data['hex'] = $line['Icao']; // hex | 
| 833 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident | |
| 834 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude | |
| 835 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed | |
| 836 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading | |
| 837 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat | |
| 838 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long | |
| 1108 | +			if (isset($line['Call'])) { | |
| 1109 | + $data['ident'] = $line['Call']; | |
| 1110 | + } | |
| 1111 | + // ident | |
| 1112 | +			if (isset($line['Alt'])) { | |
| 1113 | + $data['altitude'] = $line['Alt']; | |
| 1114 | + } | |
| 1115 | + // altitude | |
| 1116 | +			if (isset($line['Spd'])) { | |
| 1117 | + $data['speed'] = $line['Spd']; | |
| 1118 | + } | |
| 1119 | + // speed | |
| 1120 | +			if (isset($line['Trak'])) { | |
| 1121 | + $data['heading'] = $line['Trak']; | |
| 1122 | + } | |
| 1123 | + // heading | |
| 1124 | +			if (isset($line['Lat'])) { | |
| 1125 | + $data['latitude'] = $line['Lat']; | |
| 1126 | + } | |
| 1127 | + // lat | |
| 1128 | +			if (isset($line['Long'])) { | |
| 1129 | + $data['longitude'] = $line['Long']; | |
| 1130 | + } | |
| 1131 | + // long | |
| 839 | 1132 | //$data['verticalrate'] = $line['']; // verticale rate | 
| 840 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk | |
| 1133 | +			if (isset($line['Sqk'])) { | |
| 1134 | + $data['squawk'] = $line['Sqk']; | |
| 1135 | + } | |
| 1136 | + // squawk | |
| 841 | 1137 | $data['emergency'] = ''; // emergency | 
| 842 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; | |
| 843 | -			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); | |
| 844 | -			else $data['datetime'] = date('Y-m-d H:i:s'); | |
| 1138 | +			if (isset($line['Reg'])) { | |
| 1139 | + $data['registration'] = $line['Reg']; | |
| 1140 | + } | |
| 1141 | +			if (isset($line['PosTime'])) { | |
| 1142 | +				$data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); | |
| 1143 | +			} else { | |
| 1144 | +				$data['datetime'] = date('Y-m-d H:i:s'); | |
| 1145 | + } | |
| 845 | 1146 |  			//$data['datetime'] = date('Y-m-d H:i:s'); | 
| 846 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; | |
| 1147 | +			if (isset($line['Type'])) { | |
| 1148 | + $data['aircraft_icao'] = $line['Type']; | |
| 1149 | + } | |
| 847 | 1150 | $data['format_source'] = 'aircraftlistjson'; | 
| 848 | 1151 | $data['id_source'] = $id_source; | 
| 849 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; | |
| 850 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 851 | - if (isset($data['latitude'])) $SI->add($data); | |
| 1152 | +			if (isset($value['name']) && $value['name'] != '') { | |
| 1153 | + $data['source_name'] = $value['name']; | |
| 1154 | + } | |
| 1155 | +			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { | |
| 1156 | + $data['noarchive'] = true; | |
| 1157 | + } | |
| 1158 | +			if (isset($data['latitude'])) { | |
| 1159 | + $SI->add($data); | |
| 1160 | + } | |
| 852 | 1161 | unset($data); | 
| 853 | 1162 | } | 
| 854 | 1163 |  		} elseif (is_array($all_data)) { | 
| @@ -865,17 +1174,26 @@ discard block | ||
| 865 | 1174 | $data['verticalrate'] = $line['vrt']; // verticale rate | 
| 866 | 1175 | $data['squawk'] = $line['squawk']; // squawk | 
| 867 | 1176 | $data['emergency'] = ''; // emergency | 
| 868 | -			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); | |
| 869 | -			else $data['datetime'] = date('Y-m-d H:i:s'); | |
| 1177 | +			if (isset($line['PosTime'])) { | |
| 1178 | +				$data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); | |
| 1179 | +			} else { | |
| 1180 | +				$data['datetime'] = date('Y-m-d H:i:s'); | |
| 1181 | + } | |
| 870 | 1182 | $data['format_source'] = 'aircraftlistjson'; | 
| 871 | 1183 | $data['id_source'] = $id_source; | 
| 872 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 873 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; | |
| 1184 | +			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { | |
| 1185 | + $data['noarchive'] = true; | |
| 1186 | + } | |
| 1187 | +			if (isset($value['name']) && $value['name'] != '') { | |
| 1188 | + $data['source_name'] = $value['name']; | |
| 1189 | + } | |
| 874 | 1190 | $SI->add($data); | 
| 875 | 1191 | unset($data); | 
| 876 | 1192 | } | 
| 877 | 1193 | } | 
| 878 | - } elseif ($globalDebug) echo 'No data'."\n"; | |
| 1194 | +	    } elseif ($globalDebug) { | |
| 1195 | + echo 'No data'."\n"; | |
| 1196 | + } | |
| 879 | 1197 | //$last_exec['aircraftlistjson'] = time(); | 
| 880 | 1198 | $last_exec[$id]['last'] = time(); | 
| 881 | 1199 |      	//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { | 
| @@ -911,8 +1229,12 @@ discard block | ||
| 911 | 1229 |  		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]); | 
| 912 | 1230 | $data['format_source'] = 'planeupdatefaa'; | 
| 913 | 1231 | $data['id_source'] = $id_source; | 
| 914 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 915 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; | |
| 1232 | +		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { | |
| 1233 | + $data['noarchive'] = true; | |
| 1234 | + } | |
| 1235 | +		    if (isset($value['name']) && $value['name'] != '') { | |
| 1236 | + $data['source_name'] = $value['name']; | |
| 1237 | + } | |
| 916 | 1238 | $SI->add($data); | 
| 917 | 1239 | unset($data); | 
| 918 | 1240 | } | 
| @@ -946,7 +1268,9 @@ discard block | ||
| 946 | 1268 |  		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]); | 
| 947 | 1269 | $data['format_source'] = 'opensky'; | 
| 948 | 1270 | $data['id_source'] = $id_source; | 
| 949 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 1271 | +		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { | |
| 1272 | + $data['noarchive'] = true; | |
| 1273 | + } | |
| 950 | 1274 | $SI->add($data); | 
| 951 | 1275 | unset($data); | 
| 952 | 1276 | } | 
| @@ -963,7 +1287,9 @@ discard block | ||
| 963 | 1287 | //$buffer = $Common->getData($hosts[$id]); | 
| 964 | 1288 | $buffer = $Common->getData($value['host']); | 
| 965 | 1289 | $all_data = json_decode($buffer,true); | 
| 966 | - if (!empty($all_data)) $reset = 0; | |
| 1290 | +	    if (!empty($all_data)) { | |
| 1291 | + $reset = 0; | |
| 1292 | + } | |
| 967 | 1293 |  	    foreach ($all_data as $key => $line) { | 
| 968 | 1294 |  		if ($key != 'full_count' && $key != 'version' && $key != 'stats') { | 
| 969 | 1295 | $data = array(); | 
| @@ -984,8 +1310,12 @@ discard block | ||
| 984 | 1310 |  		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] | 
| 985 | 1311 | $data['format_source'] = 'fr24json'; | 
| 986 | 1312 | $data['id_source'] = $id_source; | 
| 987 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 988 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; | |
| 1313 | +		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { | |
| 1314 | + $data['noarchive'] = true; | |
| 1315 | + } | |
| 1316 | +		    if (isset($value['name']) && $value['name'] != '') { | |
| 1317 | + $data['source_name'] = $value['name']; | |
| 1318 | + } | |
| 989 | 1319 | $SI->add($data); | 
| 990 | 1320 | unset($data); | 
| 991 | 1321 | } | 
| @@ -1014,24 +1344,42 @@ discard block | ||
| 1014 | 1344 |  		    if (isset($line['inf'])) { | 
| 1015 | 1345 | $data = array(); | 
| 1016 | 1346 | $data['hex'] = $line['inf']['ia']; | 
| 1017 | - if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] | |
| 1347 | +			if (isset($line['inf']['cs'])) { | |
| 1348 | + $data['ident'] = $line['inf']['cs']; | |
| 1349 | + } | |
| 1350 | + //$line[13] | |
| 1018 | 1351 | $data['altitude'] = round($line['inf']['al']*3.28084); // altitude | 
| 1019 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed | |
| 1020 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading | |
| 1352 | +	    		if (isset($line['inf']['gs'])) { | |
| 1353 | + $data['speed'] = round($line['inf']['gs']*0.539957); | |
| 1354 | + } | |
| 1355 | + // speed | |
| 1356 | +	    		if (isset($line['inf']['tr'])) { | |
| 1357 | + $data['heading'] = $line['inf']['tr']; | |
| 1358 | + } | |
| 1359 | + // heading | |
| 1021 | 1360 | $data['latitude'] = $line['pt'][0]; // lat | 
| 1022 | 1361 | $data['longitude'] = $line['pt'][1]; // long | 
| 1023 | 1362 | //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate | 
| 1024 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk | |
| 1363 | +	    		if (isset($line['inf']['sq'])) { | |
| 1364 | + $data['squawk'] = $line['inf']['sq']; | |
| 1365 | + } | |
| 1366 | + // squawk | |
| 1025 | 1367 | //$data['aircraft_icao'] = $line[8]; | 
| 1026 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; | |
| 1368 | +	    		if (isset($line['inf']['rc'])) { | |
| 1369 | + $data['registration'] = $line['inf']['rc']; | |
| 1370 | + } | |
| 1027 | 1371 | //$data['departure_airport_iata'] = $line[11]; | 
| 1028 | 1372 | //$data['arrival_airport_iata'] = $line[12]; | 
| 1029 | 1373 | //$data['emergency'] = ''; // emergency | 
| 1030 | 1374 |  			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] | 
| 1031 | 1375 | $data['format_source'] = 'radarvirtueljson'; | 
| 1032 | 1376 | $data['id_source'] = $id_source; | 
| 1033 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 1034 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; | |
| 1377 | +			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { | |
| 1378 | + $data['noarchive'] = true; | |
| 1379 | + } | |
| 1380 | +			if (isset($value['name']) && $value['name'] != '') { | |
| 1381 | + $data['source_name'] = $value['name']; | |
| 1382 | + } | |
| 1035 | 1383 | $SI->add($data); | 
| 1036 | 1384 | unset($data); | 
| 1037 | 1385 | } | 
| @@ -1057,30 +1405,65 @@ discard block | ||
| 1057 | 1405 | $data['id'] = $line['id']; | 
| 1058 | 1406 | $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); | 
| 1059 | 1407 | $data['ident'] = $line['callsign']; // ident | 
| 1060 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id | |
| 1061 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name | |
| 1062 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude | |
| 1063 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed | |
| 1064 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading | |
| 1065 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route | |
| 1408 | +		    if (isset($line['pilotid'])) { | |
| 1409 | + $data['pilot_id'] = $line['pilotid']; | |
| 1410 | + } | |
| 1411 | + // pilot id | |
| 1412 | +		    if (isset($line['name'])) { | |
| 1413 | + $data['pilot_name'] = $line['name']; | |
| 1414 | + } | |
| 1415 | + // pilot name | |
| 1416 | +		    if (isset($line['alt'])) { | |
| 1417 | + $data['altitude'] = $line['alt']; | |
| 1418 | + } | |
| 1419 | + // altitude | |
| 1420 | +		    if (isset($line['gs'])) { | |
| 1421 | + $data['speed'] = $line['gs']; | |
| 1422 | + } | |
| 1423 | + // speed | |
| 1424 | +		    if (isset($line['heading'])) { | |
| 1425 | + $data['heading'] = $line['heading']; | |
| 1426 | + } | |
| 1427 | + // heading | |
| 1428 | +		    if (isset($line['route'])) { | |
| 1429 | + $data['waypoints'] = $line['route']; | |
| 1430 | + } | |
| 1431 | + // route | |
| 1066 | 1432 | $data['latitude'] = $line['lat']; // lat | 
| 1067 | 1433 | $data['longitude'] = $line['lon']; // long | 
| 1068 | 1434 | //$data['verticalrate'] = $line['vrt']; // verticale rate | 
| 1069 | 1435 | //$data['squawk'] = $line['squawk']; // squawk | 
| 1070 | 1436 | //$data['emergency'] = ''; // emergency | 
| 1071 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; | |
| 1072 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; | |
| 1073 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; | |
| 1437 | +		    if (isset($line['depicao'])) { | |
| 1438 | + $data['departure_airport_icao'] = $line['depicao']; | |
| 1439 | + } | |
| 1440 | +		    if (isset($line['deptime'])) { | |
| 1441 | + $data['departure_airport_time'] = $line['deptime']; | |
| 1442 | + } | |
| 1443 | +		    if (isset($line['arricao'])) { | |
| 1444 | + $data['arrival_airport_icao'] = $line['arricao']; | |
| 1445 | + } | |
| 1074 | 1446 | //$data['arrival_airport_time'] = $line['arrtime']; | 
| 1075 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; | |
| 1076 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; | |
| 1077 | - if (isset($line['atis'])) $data['info'] = $line['atis']; | |
| 1078 | - else $data['info'] = ''; | |
| 1447 | +		    if (isset($line['aircraft'])) { | |
| 1448 | + $data['aircraft_icao'] = $line['aircraft']; | |
| 1449 | + } | |
| 1450 | +		    if (isset($line['transponder'])) { | |
| 1451 | + $data['squawk'] = $line['transponder']; | |
| 1452 | + } | |
| 1453 | +		    if (isset($line['atis'])) { | |
| 1454 | + $data['info'] = $line['atis']; | |
| 1455 | +		    } else { | |
| 1456 | + $data['info'] = ''; | |
| 1457 | + } | |
| 1079 | 1458 | $data['format_source'] = 'pireps'; | 
| 1080 | 1459 | $data['id_source'] = $id_source; | 
| 1081 | 1460 |  		    $data['datetime'] = date('Y-m-d H:i:s'); | 
| 1082 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 1083 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; | |
| 1461 | +		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { | |
| 1462 | + $data['noarchive'] = true; | |
| 1463 | + } | |
| 1464 | +		    if (isset($value['name']) && $value['name'] != '') { | |
| 1465 | + $data['source_name'] = $value['name']; | |
| 1466 | + } | |
| 1084 | 1467 |  		    if ($line['icon'] == 'plane') { | 
| 1085 | 1468 | $SI->add($data); | 
| 1086 | 1469 | // print_r($data); | 
| @@ -1089,16 +1472,28 @@ discard block | ||
| 1089 | 1472 |  			$data['info'] = str_replace('&sect;','',$data['info']); | 
| 1090 | 1473 | $typec = substr($data['ident'],-3); | 
| 1091 | 1474 | $data['type'] = ''; | 
| 1092 | - if ($typec == 'APP') $data['type'] = 'Approach'; | |
| 1093 | - elseif ($typec == 'TWR') $data['type'] = 'Tower'; | |
| 1094 | - elseif ($typec == 'OBS') $data['type'] = 'Observer'; | |
| 1095 | - elseif ($typec == 'GND') $data['type'] = 'Ground'; | |
| 1096 | - elseif ($typec == 'DEL') $data['type'] = 'Delivery'; | |
| 1097 | - elseif ($typec == 'DEP') $data['type'] = 'Departure'; | |
| 1098 | - elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station'; | |
| 1099 | - elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; | |
| 1100 | - else $data['type'] = 'Observer'; | |
| 1101 | - 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']); | |
| 1475 | +			if ($typec == 'APP') { | |
| 1476 | + $data['type'] = 'Approach'; | |
| 1477 | +			} elseif ($typec == 'TWR') { | |
| 1478 | + $data['type'] = 'Tower'; | |
| 1479 | +			} elseif ($typec == 'OBS') { | |
| 1480 | + $data['type'] = 'Observer'; | |
| 1481 | +			} elseif ($typec == 'GND') { | |
| 1482 | + $data['type'] = 'Ground'; | |
| 1483 | +			} elseif ($typec == 'DEL') { | |
| 1484 | + $data['type'] = 'Delivery'; | |
| 1485 | +			} elseif ($typec == 'DEP') { | |
| 1486 | + $data['type'] = 'Departure'; | |
| 1487 | +			} elseif ($typec == 'FSS') { | |
| 1488 | + $data['type'] = 'Flight Service Station'; | |
| 1489 | +			} elseif ($typec == 'CTR') { | |
| 1490 | + $data['type'] = 'Control Radar or Centre'; | |
| 1491 | +			} else { | |
| 1492 | + $data['type'] = 'Observer'; | |
| 1493 | + } | |
| 1494 | +			if (isset($ATC)) { | |
| 1495 | + 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']); | |
| 1496 | + } | |
| 1102 | 1497 | } | 
| 1103 | 1498 | unset($data); | 
| 1104 | 1499 | } | 
| @@ -1113,7 +1508,9 @@ discard block | ||
| 1113 | 1508 | ) | 
| 1114 | 1509 |  	) { | 
| 1115 | 1510 | //$buffer = $Common->getData($hosts[$id]); | 
| 1116 | - if ($globalDebug) echo 'Get Data...'."\n"; | |
| 1511 | +	    if ($globalDebug) { | |
| 1512 | + echo 'Get Data...'."\n"; | |
| 1513 | + } | |
| 1117 | 1514 | $buffer = $Common->getData($value['host']); | 
| 1118 | 1515 | $all_data = json_decode($buffer,true); | 
| 1119 | 1516 |  	    if ($buffer != '' && is_array($all_data)) { | 
| @@ -1121,10 +1518,16 @@ discard block | ||
| 1121 | 1518 |  		foreach ($all_data as $line) { | 
| 1122 | 1519 | $data = array(); | 
| 1123 | 1520 | //$data['id'] = $line['id']; // id not usable | 
| 1124 | - if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; | |
| 1521 | +	    	    if (isset($line['pilotid'])) { | |
| 1522 | + $data['id'] = $line['pilotid'].$line['flightnum']; | |
| 1523 | + } | |
| 1125 | 1524 | $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex | 
| 1126 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; | |
| 1127 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; | |
| 1525 | +	    	    if (isset($line['pilotname'])) { | |
| 1526 | + $data['pilot_name'] = $line['pilotname']; | |
| 1527 | + } | |
| 1528 | +	    	    if (isset($line['pilotid'])) { | |
| 1529 | + $data['pilot_id'] = $line['pilotid']; | |
| 1530 | + } | |
| 1128 | 1531 | $data['ident'] = $line['flightnum']; // ident | 
| 1129 | 1532 | $data['altitude'] = $line['alt']; // altitude | 
| 1130 | 1533 | $data['speed'] = $line['gs']; // speed | 
| @@ -1140,34 +1543,52 @@ discard block | ||
| 1140 | 1543 | $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); | 
| 1141 | 1544 |  	    		$datetime->setTimeZone(new DateTimeZone('UTC')); | 
| 1142 | 1545 |  	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s'); | 
| 1143 | -	    	    } else $data['datetime'] = date('Y-m-d H:i:s'); | |
| 1546 | +	    	    } else { | |
| 1547 | +	    	    	$data['datetime'] = date('Y-m-d H:i:s'); | |
| 1548 | + } | |
| 1144 | 1549 | $data['departure_airport_icao'] = $line['depicao']; | 
| 1145 | 1550 | $data['departure_airport_time'] = $line['deptime']; | 
| 1146 | 1551 | $data['arrival_airport_icao'] = $line['arricao']; | 
| 1147 | 1552 | $data['arrival_airport_time'] = $line['arrtime']; | 
| 1148 | 1553 | $data['registration'] = $line['aircraft']; | 
| 1149 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 1150 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route | |
| 1554 | +		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { | |
| 1555 | + $data['noarchive'] = true; | |
| 1556 | + } | |
| 1557 | +		    if (isset($line['route'])) { | |
| 1558 | + $data['waypoints'] = $line['route']; | |
| 1559 | + } | |
| 1560 | + // route | |
| 1151 | 1561 |  		    if (isset($line['aircraftname'])) { | 
| 1152 | 1562 | $line['aircraftname'] = strtoupper($line['aircraftname']); | 
| 1153 | 1563 |  			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); | 
| 1154 | 1564 |  	    		$aircraft_data = explode('-',$line['aircraftname']); | 
| 1155 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; | |
| 1156 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; | |
| 1157 | -	    		else { | |
| 1565 | +	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) { | |
| 1566 | + $data['aircraft_icao'] = $aircraft_data[0]; | |
| 1567 | +	    		} elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) { | |
| 1568 | + $data['aircraft_icao'] = $aircraft_data[1]; | |
| 1569 | +	    		} else { | |
| 1158 | 1570 |  	    		    $aircraft_data = explode(' ',$line['aircraftname']); | 
| 1159 | -	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); | |
| 1160 | -	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); | |
| 1571 | +	    		    if (isset($aircraft_data[1])) { | |
| 1572 | +	    		    	$data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); | |
| 1573 | +	    		    } else { | |
| 1574 | +	    		    	$data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); | |
| 1575 | + } | |
| 1161 | 1576 | } | 
| 1162 | 1577 | } | 
| 1163 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; | |
| 1578 | +    		    if (isset($line['route'])) { | |
| 1579 | + $data['waypoints'] = $line['route']; | |
| 1580 | + } | |
| 1164 | 1581 | $data['id_source'] = $id_source; | 
| 1165 | 1582 | $data['format_source'] = 'phpvmacars'; | 
| 1166 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; | |
| 1583 | +		    if (isset($value['name']) && $value['name'] != '') { | |
| 1584 | + $data['source_name'] = $value['name']; | |
| 1585 | + } | |
| 1167 | 1586 | $SI->add($data); | 
| 1168 | 1587 | unset($data); | 
| 1169 | 1588 | } | 
| 1170 | - if ($globalDebug) echo 'No more data...'."\n"; | |
| 1589 | +		if ($globalDebug) { | |
| 1590 | + echo 'No more data...'."\n"; | |
| 1591 | + } | |
| 1171 | 1592 | unset($buffer); | 
| 1172 | 1593 | unset($all_data); | 
| 1173 | 1594 | } | 
| @@ -1180,7 +1601,9 @@ discard block | ||
| 1180 | 1601 | ) | 
| 1181 | 1602 |  	) { | 
| 1182 | 1603 | //$buffer = $Common->getData($hosts[$id]); | 
| 1183 | - if ($globalDebug) echo 'Get Data...'."\n"; | |
| 1604 | +	    if ($globalDebug) { | |
| 1605 | + echo 'Get Data...'."\n"; | |
| 1606 | + } | |
| 1184 | 1607 | $buffer = $Common->getData($value['host']); | 
| 1185 | 1608 | $all_data = json_decode($buffer,true); | 
| 1186 | 1609 |  	    if ($buffer != '' && is_array($all_data)) { | 
| @@ -1209,16 +1632,25 @@ discard block | ||
| 1209 | 1632 | $data['arrival_airport_icao'] = $line['arrival']; | 
| 1210 | 1633 | //$data['arrival_airport_time'] = $line['arrival_time']; | 
| 1211 | 1634 | //$data['registration'] = $line['aircraft']; | 
| 1212 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route | |
| 1635 | +		    if (isset($line['route'])) { | |
| 1636 | + $data['waypoints'] = $line['route']; | |
| 1637 | + } | |
| 1638 | + // route | |
| 1213 | 1639 | $data['aircraft_icao'] = $line['plane_type']; | 
| 1214 | 1640 | $data['id_source'] = $id_source; | 
| 1215 | 1641 | $data['format_source'] = 'vam'; | 
| 1216 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 1217 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; | |
| 1642 | +		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { | |
| 1643 | + $data['noarchive'] = true; | |
| 1644 | + } | |
| 1645 | +		    if (isset($value['name']) && $value['name'] != '') { | |
| 1646 | + $data['source_name'] = $value['name']; | |
| 1647 | + } | |
| 1218 | 1648 | $SI->add($data); | 
| 1219 | 1649 | unset($data); | 
| 1220 | 1650 | } | 
| 1221 | - if ($globalDebug) echo 'No more data...'."\n"; | |
| 1651 | +		if ($globalDebug) { | |
| 1652 | + echo 'No more data...'."\n"; | |
| 1653 | + } | |
| 1222 | 1654 | unset($buffer); | 
| 1223 | 1655 | unset($all_data); | 
| 1224 | 1656 | } | 
| @@ -1231,7 +1663,9 @@ discard block | ||
| 1231 | 1663 | ) | 
| 1232 | 1664 |  	) { | 
| 1233 | 1665 | //$buffer = $Common->getData($hosts[$id]); | 
| 1234 | - if ($globalDebug) echo 'Get Data...'."\n"; | |
| 1666 | +	    if ($globalDebug) { | |
| 1667 | + echo 'Get Data...'."\n"; | |
| 1668 | + } | |
| 1235 | 1669 | $buffer = $Common->getData($value['host']); | 
| 1236 | 1670 | $all_data = json_decode($buffer,true); | 
| 1237 | 1671 |  	    if ($buffer != '') { | 
| @@ -1249,18 +1683,24 @@ discard block | ||
| 1249 | 1683 | $data['id_source'] = $id_source; | 
| 1250 | 1684 | $data['format_source'] = 'blitzortung'; | 
| 1251 | 1685 | $SI->add($data); | 
| 1252 | - if ($globalDebug) echo '☈ Lightning added'."\n"; | |
| 1686 | +			if ($globalDebug) { | |
| 1687 | + echo '☈ Lightning added'."\n"; | |
| 1688 | + } | |
| 1253 | 1689 |  			$Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']); | 
| 1254 | 1690 | unset($data); | 
| 1255 | 1691 | } | 
| 1256 | 1692 | } | 
| 1257 | - if ($globalDebug) echo 'No more data...'."\n"; | |
| 1693 | +		if ($globalDebug) { | |
| 1694 | + echo 'No more data...'."\n"; | |
| 1695 | + } | |
| 1258 | 1696 | unset($buffer); | 
| 1259 | 1697 | } | 
| 1260 | 1698 | $last_exec[$id]['last'] = time(); | 
| 1261 | 1699 |  	//} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') { | 
| 1262 | 1700 |  	} elseif ($value['format'] == 'sbs' || $value['format'] == 'tsv' || $value['format'] == 'raw' || $value['format'] == 'aprs' || $value['format'] == 'famaprs' || $value['format'] == 'beast' || $value['format'] == 'flightgearmp' || $value['format'] == 'flightgearsp' || $value['format'] == 'acars' || $value['format'] == 'acarssbs3' || $value['format'] == 'ais' || $value['format'] == 'vrstcp') { | 
| 1263 | -	    if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); | |
| 1701 | +	    if (function_exists('pcntl_fork')) { | |
| 1702 | + pcntl_signal_dispatch(); | |
| 1703 | + } | |
| 1264 | 1704 | //$last_exec[$id]['last'] = time(); | 
| 1265 | 1705 | |
| 1266 | 1706 | //$read = array( $sockets[$id] ); | 
| @@ -1268,7 +1708,9 @@ discard block | ||
| 1268 | 1708 | $write = NULL; | 
| 1269 | 1709 | $e = NULL; | 
| 1270 | 1710 | $n = socket_select($read, $write, $e, $timeout); | 
| 1271 | - if ($e != NULL) var_dump($e); | |
| 1711 | +	    if ($e != NULL) { | |
| 1712 | + var_dump($e); | |
| 1713 | + } | |
| 1272 | 1714 |  	    if ($n > 0) { | 
| 1273 | 1715 | $reset = 0; | 
| 1274 | 1716 |  		foreach ($read as $nb => $r) { | 
| @@ -1289,12 +1731,16 @@ discard block | ||
| 1289 | 1731 | //$SI::del(); | 
| 1290 | 1732 |  		    if ($format == 'vrstcp') { | 
| 1291 | 1733 |  			$buffer = explode('},{',$buffer); | 
| 1292 | -		    } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); | |
| 1734 | +		    } else { | |
| 1735 | +		    	$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); | |
| 1736 | + } | |
| 1293 | 1737 | // SBS format is CSV format | 
| 1294 | 1738 |  		    if ($buffer !== FALSE && $buffer != '') { | 
| 1295 | 1739 | $tt[$format] = 0; | 
| 1296 | 1740 |  			if ($format == 'acarssbs3') { | 
| 1297 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; | |
| 1741 | +			    if ($globalDebug) { | |
| 1742 | + echo 'ACARS : '.$buffer."\n"; | |
| 1743 | + } | |
| 1298 | 1744 | $ACARS->add(trim($buffer)); | 
| 1299 | 1745 | $ACARS->deleteLiveAcarsData(); | 
| 1300 | 1746 |  			} elseif ($format == 'raw') { | 
| @@ -1303,30 +1749,70 @@ discard block | ||
| 1303 | 1749 |  			    if (is_array($data)) { | 
| 1304 | 1750 |  				$data['datetime'] = date('Y-m-d H:i:s'); | 
| 1305 | 1751 | $data['format_source'] = 'raw'; | 
| 1306 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; | |
| 1307 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; | |
| 1308 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 1309 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); | |
| 1752 | +				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { | |
| 1753 | + $data['source_name'] = $globalSources[$nb]['name']; | |
| 1754 | + } | |
| 1755 | +				if (isset($globalSources[$nb]['sourcestats'])) { | |
| 1756 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; | |
| 1757 | + } | |
| 1758 | +				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { | |
| 1759 | + $data['noarchive'] = true; | |
| 1760 | + } | |
| 1761 | +				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { | |
| 1762 | + $SI->add($data); | |
| 1763 | + } | |
| 1310 | 1764 | } | 
| 1311 | 1765 |  			} elseif ($format == 'ais') { | 
| 1312 | 1766 | $ais_data = $AIS->parse_line(trim($buffer)); | 
| 1313 | 1767 | $data = array(); | 
| 1314 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; | |
| 1315 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; | |
| 1316 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; | |
| 1317 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; | |
| 1318 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; | |
| 1319 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; | |
| 1320 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; | |
| 1321 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; | |
| 1322 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; | |
| 1323 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; | |
| 1324 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; | |
| 1325 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; | |
| 1326 | -			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); | |
| 1327 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 1328 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; | |
| 1329 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; | |
| 1768 | +			    if (isset($ais_data['ident'])) { | |
| 1769 | + $data['ident'] = $ais_data['ident']; | |
| 1770 | + } | |
| 1771 | +			    if (isset($ais_data['mmsi'])) { | |
| 1772 | + $data['mmsi'] = $ais_data['mmsi']; | |
| 1773 | + } | |
| 1774 | +			    if (isset($ais_data['speed'])) { | |
| 1775 | + $data['speed'] = $ais_data['speed']; | |
| 1776 | + } | |
| 1777 | +			    if (isset($ais_data['heading'])) { | |
| 1778 | + $data['heading'] = $ais_data['heading']; | |
| 1779 | + } | |
| 1780 | +			    if (isset($ais_data['latitude'])) { | |
| 1781 | + $data['latitude'] = $ais_data['latitude']; | |
| 1782 | + } | |
| 1783 | +			    if (isset($ais_data['longitude'])) { | |
| 1784 | + $data['longitude'] = $ais_data['longitude']; | |
| 1785 | + } | |
| 1786 | +			    if (isset($ais_data['status'])) { | |
| 1787 | + $data['status'] = $ais_data['status']; | |
| 1788 | + } | |
| 1789 | +			    if (isset($ais_data['statusid'])) { | |
| 1790 | + $data['status_id'] = $ais_data['statusid']; | |
| 1791 | + } | |
| 1792 | +			    if (isset($ais_data['type'])) { | |
| 1793 | + $data['type'] = $ais_data['type']; | |
| 1794 | + } | |
| 1795 | +			    if (isset($ais_data['imo'])) { | |
| 1796 | + $data['imo'] = $ais_data['imo']; | |
| 1797 | + } | |
| 1798 | +			    if (isset($ais_data['callsign'])) { | |
| 1799 | + $data['callsign'] = $ais_data['callsign']; | |
| 1800 | + } | |
| 1801 | +			    if (isset($ais_data['destination'])) { | |
| 1802 | + $data['arrival_code'] = $ais_data['destination']; | |
| 1803 | + } | |
| 1804 | +			    if (isset($ais_data['eta_ts'])) { | |
| 1805 | +			    	$data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); | |
| 1806 | + } | |
| 1807 | +			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { | |
| 1808 | + $data['noarchive'] = true; | |
| 1809 | + } | |
| 1810 | +			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { | |
| 1811 | + $data['source_name'] = $globalSources[$nb]['name']; | |
| 1812 | + } | |
| 1813 | +			    if (isset($globalSources[$nb]['sourcestats'])) { | |
| 1814 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; | |
| 1815 | + } | |
| 1330 | 1816 | |
| 1331 | 1817 |  			    if (isset($ais_data['timestamp'])) { | 
| 1332 | 1818 |  				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); | 
| @@ -1335,7 +1821,9 @@ discard block | ||
| 1335 | 1821 | } | 
| 1336 | 1822 | $data['format_source'] = 'aisnmea'; | 
| 1337 | 1823 | $data['id_source'] = $id_source; | 
| 1338 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); | |
| 1824 | +			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') { | |
| 1825 | + $MI->add($data); | |
| 1826 | + } | |
| 1339 | 1827 | unset($data); | 
| 1340 | 1828 |                          } elseif ($format == 'flightgearsp') { | 
| 1341 | 1829 | //echo $buffer."\n"; | 
| @@ -1353,12 +1841,18 @@ discard block | ||
| 1353 | 1841 | $data['speed'] = round($line[5]*1.94384); | 
| 1354 | 1842 |  				$data['datetime'] = date('Y-m-d H:i:s'); | 
| 1355 | 1843 | $data['format_source'] = 'flightgearsp'; | 
| 1356 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 1357 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); | |
| 1844 | +				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { | |
| 1845 | + $data['noarchive'] = true; | |
| 1846 | + } | |
| 1847 | +				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { | |
| 1848 | + $SI->add($data); | |
| 1849 | + } | |
| 1358 | 1850 | //$send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); | 
| 1359 | 1851 | } | 
| 1360 | 1852 |                          } elseif ($format == 'acars') { | 
| 1361 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; | |
| 1853 | +                    	    if ($globalDebug) { | |
| 1854 | + echo 'ACARS : '.$buffer."\n"; | |
| 1855 | + } | |
| 1362 | 1856 | $ACARS->add(trim($buffer)); | 
| 1363 | 1857 | socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); | 
| 1364 | 1858 | $ACARS->deleteLiveAcarsData(); | 
| @@ -1379,8 +1873,12 @@ discard block | ||
| 1379 | 1873 | $aircraft_type = $line[10]; | 
| 1380 | 1874 |  				    $aircraft_type = preg_split(':/:',$aircraft_type); | 
| 1381 | 1875 | $data['aircraft_name'] = substr(end($aircraft_type),0,-4); | 
| 1382 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 1383 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); | |
| 1876 | +				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { | |
| 1877 | + $data['noarchive'] = true; | |
| 1878 | + } | |
| 1879 | +				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { | |
| 1880 | + $SI->add($data); | |
| 1881 | + } | |
| 1384 | 1882 | } | 
| 1385 | 1883 | } | 
| 1386 | 1884 |  			} elseif ($format == 'beast') { | 
| @@ -1390,28 +1888,62 @@ discard block | ||
| 1390 | 1888 |  			    foreach($buffer as $all_data) { | 
| 1391 | 1889 |  				$line = json_decode('{'.$all_data.'}',true); | 
| 1392 | 1890 | $data = array(); | 
| 1393 | - if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex | |
| 1394 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident | |
| 1395 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude | |
| 1396 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed | |
| 1397 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading | |
| 1398 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat | |
| 1399 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long | |
| 1891 | +				if (isset($line['Icao'])) { | |
| 1892 | + $data['hex'] = $line['Icao']; | |
| 1893 | + } | |
| 1894 | + // hex | |
| 1895 | +				if (isset($line['Call'])) { | |
| 1896 | + $data['ident'] = $line['Call']; | |
| 1897 | + } | |
| 1898 | + // ident | |
| 1899 | +				if (isset($line['Alt'])) { | |
| 1900 | + $data['altitude'] = $line['Alt']; | |
| 1901 | + } | |
| 1902 | + // altitude | |
| 1903 | +				if (isset($line['Spd'])) { | |
| 1904 | + $data['speed'] = $line['Spd']; | |
| 1905 | + } | |
| 1906 | + // speed | |
| 1907 | +				if (isset($line['Trak'])) { | |
| 1908 | + $data['heading'] = $line['Trak']; | |
| 1909 | + } | |
| 1910 | + // heading | |
| 1911 | +				if (isset($line['Lat'])) { | |
| 1912 | + $data['latitude'] = $line['Lat']; | |
| 1913 | + } | |
| 1914 | + // lat | |
| 1915 | +				if (isset($line['Long'])) { | |
| 1916 | + $data['longitude'] = $line['Long']; | |
| 1917 | + } | |
| 1918 | + // long | |
| 1400 | 1919 | //$data['verticalrate'] = $line['']; // verticale rate | 
| 1401 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk | |
| 1920 | +				if (isset($line['Sqk'])) { | |
| 1921 | + $data['squawk'] = $line['Sqk']; | |
| 1922 | + } | |
| 1923 | + // squawk | |
| 1402 | 1924 | $data['emergency'] = ''; // emergency | 
| 1403 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; | |
| 1925 | +				if (isset($line['Reg'])) { | |
| 1926 | + $data['registration'] = $line['Reg']; | |
| 1927 | + } | |
| 1404 | 1928 | /* | 
| 1405 | 1929 |  				if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000); | 
| 1406 | 1930 |  				else $data['datetime'] = date('Y-m-d H:i:s'); | 
| 1407 | 1931 | */ | 
| 1408 | 1932 |  				$data['datetime'] = date('Y-m-d H:i:s'); | 
| 1409 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; | |
| 1933 | +				if (isset($line['Type'])) { | |
| 1934 | + $data['aircraft_icao'] = $line['Type']; | |
| 1935 | + } | |
| 1410 | 1936 | $data['format_source'] = 'vrstcp'; | 
| 1411 | 1937 | $data['id_source'] = $id_source; | 
| 1412 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 1413 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; | |
| 1414 | - if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); | |
| 1938 | +				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { | |
| 1939 | + $data['noarchive'] = true; | |
| 1940 | + } | |
| 1941 | +				if (isset($value['name']) && $value['name'] != '') { | |
| 1942 | + $data['source_name'] = $value['name']; | |
| 1943 | + } | |
| 1944 | +				if (isset($data['latitude']) && isset($data['hex'])) { | |
| 1945 | + $SI->add($data); | |
| 1946 | + } | |
| 1415 | 1947 | unset($data); | 
| 1416 | 1948 | } | 
| 1417 | 1949 |  			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') { | 
| @@ -1424,22 +1956,46 @@ discard block | ||
| 1424 | 1956 | $data['hex'] = $lined['hexid']; | 
| 1425 | 1957 |      				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; | 
| 1426 | 1958 |      				$data['datetime'] = date('Y-m-d H:i:s');; | 
| 1427 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; | |
| 1428 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; | |
| 1429 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; | |
| 1430 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; | |
| 1431 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; | |
| 1432 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; | |
| 1433 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; | |
| 1959 | +    				if (isset($lined['ident'])) { | |
| 1960 | + $data['ident'] = $lined['ident']; | |
| 1961 | + } | |
| 1962 | +    				if (isset($lined['lat'])) { | |
| 1963 | + $data['latitude'] = $lined['lat']; | |
| 1964 | + } | |
| 1965 | +    				if (isset($lined['lon'])) { | |
| 1966 | + $data['longitude'] = $lined['lon']; | |
| 1967 | + } | |
| 1968 | +    				if (isset($lined['speed'])) { | |
| 1969 | + $data['speed'] = $lined['speed']; | |
| 1970 | + } | |
| 1971 | +    				if (isset($lined['squawk'])) { | |
| 1972 | + $data['squawk'] = $lined['squawk']; | |
| 1973 | + } | |
| 1974 | +    				if (isset($lined['alt'])) { | |
| 1975 | + $data['altitude'] = $lined['alt']; | |
| 1976 | + } | |
| 1977 | +    				if (isset($lined['heading'])) { | |
| 1978 | + $data['heading'] = $lined['heading']; | |
| 1979 | + } | |
| 1434 | 1980 | $data['id_source'] = $id_source; | 
| 1435 | 1981 | $data['format_source'] = 'tsv'; | 
| 1436 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; | |
| 1437 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; | |
| 1438 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 1439 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); | |
| 1982 | +    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { | |
| 1983 | + $data['source_name'] = $globalSources[$nb]['name']; | |
| 1984 | + } | |
| 1985 | +    				if (isset($globalSources[$nb]['sourcestats'])) { | |
| 1986 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; | |
| 1987 | + } | |
| 1988 | +				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { | |
| 1989 | + $data['noarchive'] = true; | |
| 1990 | + } | |
| 1991 | +    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { | |
| 1992 | + $SI->add($data); | |
| 1993 | + } | |
| 1440 | 1994 | unset($lined); | 
| 1441 | 1995 | unset($data); | 
| 1442 | - } else $error = true; | |
| 1996 | +    			    } else { | |
| 1997 | + $error = true; | |
| 1998 | + } | |
| 1443 | 1999 |  			} elseif ($format == 'aprs' && $use_aprs) { | 
| 1444 | 2000 |  			    if ($aprs_connect == 0) { | 
| 1445 | 2001 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); | 
| @@ -1464,59 +2020,117 @@ discard block | ||
| 1464 | 2020 | $aprs_last_tx = time(); | 
| 1465 | 2021 | $data = array(); | 
| 1466 | 2022 | //print_r($line); | 
| 1467 | - if (isset($line['address'])) $data['hex'] = $line['address']; | |
| 1468 | - if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; | |
| 1469 | - if (isset($line['imo'])) $data['imo'] = $line['imo']; | |
| 1470 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; | |
| 1471 | - if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code']; | |
| 1472 | - if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date']; | |
| 1473 | - if (isset($line['type_id'])) $data['type_id'] = $line['typeid']; | |
| 1474 | - if (isset($line['status_id'])) $data['status_id'] = $line['statusid']; | |
| 1475 | -				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); | |
| 1476 | -				    else $data['datetime'] = date('Y-m-d H:i:s'); | |
| 2023 | +				    if (isset($line['address'])) { | |
| 2024 | + $data['hex'] = $line['address']; | |
| 2025 | + } | |
| 2026 | +				    if (isset($line['mmsi'])) { | |
| 2027 | + $data['mmsi'] = $line['mmsi']; | |
| 2028 | + } | |
| 2029 | +				    if (isset($line['imo'])) { | |
| 2030 | + $data['imo'] = $line['imo']; | |
| 2031 | + } | |
| 2032 | +				    if (isset($line['squawk'])) { | |
| 2033 | + $data['squawk'] = $line['squawk']; | |
| 2034 | + } | |
| 2035 | +				    if (isset($line['arrival_code'])) { | |
| 2036 | + $data['arrical_code'] = $line['arrival_code']; | |
| 2037 | + } | |
| 2038 | +				    if (isset($line['arrival_date'])) { | |
| 2039 | + $data['arrical_date'] = $line['arrival_date']; | |
| 2040 | + } | |
| 2041 | +				    if (isset($line['type_id'])) { | |
| 2042 | + $data['type_id'] = $line['typeid']; | |
| 2043 | + } | |
| 2044 | +				    if (isset($line['status_id'])) { | |
| 2045 | + $data['status_id'] = $line['statusid']; | |
| 2046 | + } | |
| 2047 | +				    if (isset($line['timestamp'])) { | |
| 2048 | +				    	$data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); | |
| 2049 | +				    } else { | |
| 2050 | +				    	$data['datetime'] = date('Y-m-d H:i:s'); | |
| 2051 | + } | |
| 1477 | 2052 |  				    //$data['datetime'] = date('Y-m-d H:i:s'); | 
| 1478 | - if (isset($line['ident'])) $data['ident'] = $line['ident']; | |
| 2053 | +				    if (isset($line['ident'])) { | |
| 2054 | + $data['ident'] = $line['ident']; | |
| 2055 | + } | |
| 1479 | 2056 | $data['latitude'] = $line['latitude']; | 
| 1480 | 2057 | $data['longitude'] = $line['longitude']; | 
| 1481 | 2058 | //$data['verticalrate'] = $line[16]; | 
| 1482 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; | |
| 2059 | +				    if (isset($line['speed'])) { | |
| 2060 | + $data['speed'] = $line['speed']; | |
| 2061 | + } | |
| 1483 | 2062 | //else $data['speed'] = 0; | 
| 1484 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; | |
| 1485 | - if (isset($line['comment'])) $data['comment'] = $line['comment']; | |
| 1486 | - if (isset($line['symbol'])) $data['type'] = $line['symbol']; | |
| 1487 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; | |
| 2063 | +				    if (isset($line['altitude'])) { | |
| 2064 | + $data['altitude'] = $line['altitude']; | |
| 2065 | + } | |
| 2066 | +				    if (isset($line['comment'])) { | |
| 2067 | + $data['comment'] = $line['comment']; | |
| 2068 | + } | |
| 2069 | +				    if (isset($line['symbol'])) { | |
| 2070 | + $data['type'] = $line['symbol']; | |
| 2071 | + } | |
| 2072 | +				    if (isset($line['heading'])) { | |
| 2073 | + $data['heading'] = $line['heading']; | |
| 2074 | + } | |
| 1488 | 2075 | //else $data['heading'] = 0; | 
| 1489 | - if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; | |
| 2076 | +				    if (isset($line['stealth'])) { | |
| 2077 | + $data['aircraft_type'] = $line['stealth']; | |
| 2078 | + } | |
| 1490 | 2079 | //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; | 
| 1491 | - if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true; | |
| 1492 | - elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false; | |
| 1493 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 1494 | - elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; | |
| 2080 | +				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) { | |
| 2081 | + $data['noarchive'] = true; | |
| 2082 | +				    } elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) { | |
| 2083 | + $data['noarchive'] = false; | |
| 2084 | + } | |
| 2085 | +				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { | |
| 2086 | + $data['noarchive'] = true; | |
| 2087 | +				    } elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) { | |
| 2088 | + $data['noarchive'] = false; | |
| 2089 | + } | |
| 1495 | 2090 | $data['id_source'] = $id_source; | 
| 1496 | - if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; | |
| 1497 | - else $data['format_source'] = 'aprs'; | |
| 2091 | +    				    if (isset($line['format_source'])) { | |
| 2092 | + $data['format_source'] = $line['format_source']; | |
| 2093 | +    				    } else { | |
| 2094 | + $data['format_source'] = 'aprs'; | |
| 2095 | + } | |
| 1498 | 2096 | $data['source_name'] = $line['source']; | 
| 1499 | - if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; | |
| 1500 | - else $data['source_type'] = 'flarm'; | |
| 1501 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; | |
| 2097 | +				    if (isset($line['source_type'])) { | |
| 2098 | + $data['source_type'] = $line['source_type']; | |
| 2099 | +				    } else { | |
| 2100 | + $data['source_type'] = 'flarm'; | |
| 2101 | + } | |
| 2102 | +    				    if (isset($globalSources[$nb]['sourcestats'])) { | |
| 2103 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; | |
| 2104 | + } | |
| 1502 | 2105 |  				    $currentdate = date('Y-m-d H:i:s'); | 
| 1503 | 2106 | $aprsdate = strtotime($data['datetime']); | 
| 1504 | - if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL'; | |
| 2107 | +				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') { | |
| 2108 | + $data['altitude_relative'] = 'AMSL'; | |
| 2109 | + } | |
| 1505 | 2110 | // Accept data if time <= system time + 20s | 
| 1506 | 2111 |  				    //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'])))) { | 
| 1507 | 2112 |  				    if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { | 
| 1508 | 2113 | $send = $SI->add($data); | 
| 1509 | 2114 |  				    } elseif ($data['source_type'] == 'ais') { | 
| 1510 | - if (isset($globalMarine) && $globalMarine) $send = $MI->add($data); | |
| 2115 | +					if (isset($globalMarine) && $globalMarine) { | |
| 2116 | + $send = $MI->add($data); | |
| 2117 | + } | |
| 1511 | 2118 |  				    } elseif (isset($line['stealth'])) { | 
| 1512 | - if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; | |
| 1513 | - else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; | |
| 2119 | +					if ($line['stealth'] != 0) { | |
| 2120 | + echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; | |
| 2121 | +					} else { | |
| 2122 | + echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; | |
| 2123 | + } | |
| 1514 | 2124 | } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( | 
| 1515 | 2125 | //$line['symbol'] == 'Balloon' || | 
| 1516 | 2126 | $line['symbol'] == 'Glider' || | 
| 1517 | 2127 |  					    $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) { | 
| 1518 | - if ($line['symbol'] == 'Ballon') $data['aircraft_icao'] = 'BALL'; | |
| 1519 | - if ($line['symbol'] == 'Glider') $data['aircraft_icao'] = 'PARAGLIDER'; | |
| 2128 | +					    if ($line['symbol'] == 'Ballon') { | |
| 2129 | + $data['aircraft_icao'] = 'BALL'; | |
| 2130 | + } | |
| 2131 | +					    if ($line['symbol'] == 'Glider') { | |
| 2132 | + $data['aircraft_icao'] = 'PARAGLIDER'; | |
| 2133 | + } | |
| 1520 | 2134 | $send = $SI->add($data); | 
| 1521 | 2135 | } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( | 
| 1522 | 2136 | $line['symbol'] == 'Yacht (Sail)' || | 
| @@ -1547,9 +2161,13 @@ discard block | ||
| 1547 | 2161 |  				    //} 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') { | 
| 1548 | 2162 |  				//    } 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') { | 
| 1549 | 2163 | //echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n"; | 
| 1550 | - if (isset($globalTracker) && $globalTracker) $send = $TI->add($data); | |
| 2164 | +					if (isset($globalTracker) && $globalTracker) { | |
| 2165 | + $send = $TI->add($data); | |
| 2166 | + } | |
| 1551 | 2167 |  				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { | 
| 1552 | - if (!isset($data['altitude'])) $data['altitude'] = 0; | |
| 2168 | +					if (!isset($data['altitude'])) { | |
| 2169 | + $data['altitude'] = 0; | |
| 2170 | + } | |
| 1553 | 2171 |  					$Source->deleteOldLocationByType('gs'); | 
| 1554 | 2172 |  					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) { | 
| 1555 | 2173 | $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); | 
| @@ -1558,7 +2176,9 @@ discard block | ||
| 1558 | 2176 | } | 
| 1559 | 2177 |  				    } elseif (isset($line['symbol']) && $line['symbol'] == 'Weather Station') { | 
| 1560 | 2178 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; | 
| 1561 | - if ($globalDebug) echo '# Weather Station added'."\n"; | |
| 2179 | +					if ($globalDebug) { | |
| 2180 | + echo '# Weather Station added'."\n"; | |
| 2181 | + } | |
| 1562 | 2182 |  					$Source->deleteOldLocationByType('wx'); | 
| 1563 | 2183 | $weather_data = json_encode($line); | 
| 1564 | 2184 |  					if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) { | 
| @@ -1568,7 +2188,9 @@ discard block | ||
| 1568 | 2188 | } | 
| 1569 | 2189 |  				    } elseif (isset($line['symbol']) && $line['symbol'] == 'Lightning') { | 
| 1570 | 2190 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; | 
| 1571 | - if ($globalDebug) echo '☈ Lightning added'."\n"; | |
| 2191 | +					if ($globalDebug) { | |
| 2192 | + echo '☈ Lightning added'."\n"; | |
| 2193 | + } | |
| 1572 | 2194 |  					$Source->deleteOldLocationByType('lightning'); | 
| 1573 | 2195 |  					if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) { | 
| 1574 | 2196 | $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']); | 
| @@ -1580,8 +2202,7 @@ discard block | ||
| 1580 | 2202 | print_r($line); | 
| 1581 | 2203 | } | 
| 1582 | 2204 | unset($data); | 
| 1583 | - } | |
| 1584 | -				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { | |
| 2205 | +				} elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { | |
| 1585 | 2206 | $Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']); | 
| 1586 | 2207 | } | 
| 1587 | 2208 | /* | 
| @@ -1590,7 +2211,9 @@ discard block | ||
| 1590 | 2211 | } | 
| 1591 | 2212 | */ | 
| 1592 | 2213 |  				//elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n"; | 
| 1593 | - elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n"; | |
| 2214 | +				elseif ($line == true && $globalDebug) { | |
| 2215 | + echo '!! Failed : '.$buffer."!!\n"; | |
| 2216 | + } | |
| 1594 | 2217 |  				if (isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) { | 
| 1595 | 2218 |  					$Source->deleteOldLocationByType('lightning'); | 
| 1596 | 2219 |  					$Source->deleteOldLocationByType('wx'); | 
| @@ -1626,26 +2249,45 @@ discard block | ||
| 1626 | 2249 | $data['ground'] = $line[21]; | 
| 1627 | 2250 | $data['emergency'] = $line[19]; | 
| 1628 | 2251 | $data['format_source'] = 'sbs'; | 
| 1629 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; | |
| 1630 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; | |
| 1631 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 2252 | +				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { | |
| 2253 | + $data['source_name'] = $globalSources[$nb]['name']; | |
| 2254 | + } | |
| 2255 | +    				if (isset($globalSources[$nb]['sourcestats'])) { | |
| 2256 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; | |
| 2257 | + } | |
| 2258 | +				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { | |
| 2259 | + $data['noarchive'] = true; | |
| 2260 | + } | |
| 1632 | 2261 | $data['id_source'] = $id_source; | 
| 1633 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); | |
| 1634 | - else $error = true; | |
| 2262 | +    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { | |
| 2263 | + $send = $SI->add($data); | |
| 2264 | +    				} else { | |
| 2265 | + $error = true; | |
| 2266 | + } | |
| 1635 | 2267 | unset($data); | 
| 1636 | - } else $error = true; | |
| 2268 | +    			    } else { | |
| 2269 | + $error = true; | |
| 2270 | + } | |
| 1637 | 2271 |  			    if ($error) { | 
| 1638 | 2272 |  				if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) {  | 
| 1639 | - if ($globalDebug) echo "Not a message. Ignoring... \n"; | |
| 2273 | +					if ($globalDebug) { | |
| 2274 | + echo "Not a message. Ignoring... \n"; | |
| 2275 | + } | |
| 1640 | 2276 |  				} else { | 
| 1641 | - if ($globalDebug) echo "Wrong line format. Ignoring... \n"; | |
| 2277 | +					if ($globalDebug) { | |
| 2278 | + echo "Wrong line format. Ignoring... \n"; | |
| 2279 | + } | |
| 1642 | 2280 |  					if ($globalDebug) { | 
| 1643 | 2281 | echo $buffer; | 
| 1644 | 2282 | //print_r($line); | 
| 1645 | 2283 | } | 
| 1646 | 2284 | //socket_close($r); | 
| 1647 | - if ($globalDebug) echo "Reconnect after an error...\n"; | |
| 1648 | - if ($format == 'aprs') $aprs_connect = 0; | |
| 2285 | +					if ($globalDebug) { | |
| 2286 | + echo "Reconnect after an error...\n"; | |
| 2287 | + } | |
| 2288 | +					if ($format == 'aprs') { | |
| 2289 | + $aprs_connect = 0; | |
| 2290 | + } | |
| 1649 | 2291 | $sourceer[$nb] = $globalSources[$nb]; | 
| 1650 | 2292 | connect_all($sourceer); | 
| 1651 | 2293 | $sourceer = array(); | 
| @@ -1653,10 +2295,14 @@ discard block | ||
| 1653 | 2295 | } | 
| 1654 | 2296 | } | 
| 1655 | 2297 | // Sleep for xxx microseconds | 
| 1656 | - if (isset($globalSBSSleep)) usleep($globalSBSSleep); | |
| 2298 | +			if (isset($globalSBSSleep)) { | |
| 2299 | + usleep($globalSBSSleep); | |
| 2300 | + } | |
| 1657 | 2301 |  		    } else { | 
| 1658 | 2302 |  			if ($format == 'flightgearmp') { | 
| 1659 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; | |
| 2303 | +			    	if ($globalDebug) { | |
| 2304 | + echo "Reconnect FlightGear MP..."; | |
| 2305 | + } | |
| 1660 | 2306 | //@socket_close($r); | 
| 1661 | 2307 | sleep($globalMinFetch); | 
| 1662 | 2308 | $sourcefg[$nb] = $globalSources[$nb]; | 
| @@ -1665,10 +2311,15 @@ discard block | ||
| 1665 | 2311 | break; | 
| 1666 | 2312 | |
| 1667 | 2313 |  			} elseif ($format != 'acars' && $format != 'flightgearsp') { | 
| 1668 | - if (isset($tt[$format])) $tt[$format]++; | |
| 1669 | - else $tt[$format] = 0; | |
| 2314 | +			    if (isset($tt[$format])) { | |
| 2315 | + $tt[$format]++; | |
| 2316 | +			    } else { | |
| 2317 | + $tt[$format] = 0; | |
| 2318 | + } | |
| 1670 | 2319 |  			    if ($tt[$format] > 30) { | 
| 1671 | - if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; | |
| 2320 | +				if ($globalDebug) { | |
| 2321 | + echo "ERROR : Reconnect ".$format."..."; | |
| 2322 | + } | |
| 1672 | 2323 | //@socket_close($r); | 
| 1673 | 2324 | sleep(2); | 
| 1674 | 2325 | $aprs_connect = 0; | 
| @@ -1685,11 +2336,17 @@ discard block | ||
| 1685 | 2336 |  	    } else { | 
| 1686 | 2337 | $error = socket_strerror(socket_last_error()); | 
| 1687 | 2338 |  		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { | 
| 1688 | - if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; | |
| 1689 | - if (isset($globalDebug)) echo "Restarting...\n"; | |
| 2339 | +			if ($globalDebug) { | |
| 2340 | + echo "ERROR : socket_select give this error ".$error . "\n"; | |
| 2341 | + } | |
| 2342 | +			if (isset($globalDebug)) { | |
| 2343 | + echo "Restarting...\n"; | |
| 2344 | + } | |
| 1690 | 2345 | // Restart the script if possible | 
| 1691 | 2346 |  			if (is_array($sockets)) { | 
| 1692 | - if ($globalDebug) echo "Shutdown all sockets..."; | |
| 2347 | +			    if ($globalDebug) { | |
| 2348 | + echo "Shutdown all sockets..."; | |
| 2349 | + } | |
| 1693 | 2350 | |
| 1694 | 2351 |  			    foreach ($sockets as $sock) { | 
| 1695 | 2352 | @socket_shutdown($sock,2); | 
| @@ -1697,25 +2354,45 @@ discard block | ||
| 1697 | 2354 | } | 
| 1698 | 2355 | |
| 1699 | 2356 | } | 
| 1700 | - if ($globalDebug) echo "Waiting..."; | |
| 2357 | +			if ($globalDebug) { | |
| 2358 | + echo "Waiting..."; | |
| 2359 | + } | |
| 1701 | 2360 | sleep(2); | 
| 1702 | 2361 | $time = time(); | 
| 1703 | 2362 | //connect_all($hosts); | 
| 1704 | 2363 | $aprs_connect = 0; | 
| 1705 | - if ($reset%5 == 0) sleep(20); | |
| 1706 | - if ($reset%10 == 0) sleep(100); | |
| 1707 | - if ($reset%20 == 0) sleep(200); | |
| 1708 | -			if ($reset > 100) exit('Too many attempts...'); | |
| 1709 | - if ($globalDebug) echo "Restart all connections..."; | |
| 2364 | +			if ($reset%5 == 0) { | |
| 2365 | + sleep(20); | |
| 2366 | + } | |
| 2367 | +			if ($reset%10 == 0) { | |
| 2368 | + sleep(100); | |
| 2369 | + } | |
| 2370 | +			if ($reset%20 == 0) { | |
| 2371 | + sleep(200); | |
| 2372 | + } | |
| 2373 | +			if ($reset > 100) { | |
| 2374 | +				exit('Too many attempts...'); | |
| 2375 | + } | |
| 2376 | +			if ($globalDebug) { | |
| 2377 | + echo "Restart all connections..."; | |
| 2378 | + } | |
| 1710 | 2379 | connect_all($globalSources); | 
| 1711 | 2380 | } | 
| 1712 | 2381 | } | 
| 1713 | 2382 | } | 
| 1714 | 2383 |  	if ($globalDaemon === false) { | 
| 1715 | - if ($globalDebug) echo 'Check all...'."\n"; | |
| 1716 | - if (isset($SI)) $SI->checkAll(); | |
| 1717 | - if (isset($TI)) $TI->checkAll(); | |
| 1718 | - if (isset($MI)) $MI->checkAll(); | |
| 2384 | +	    if ($globalDebug) { | |
| 2385 | + echo 'Check all...'."\n"; | |
| 2386 | + } | |
| 2387 | +	    if (isset($SI)) { | |
| 2388 | + $SI->checkAll(); | |
| 2389 | + } | |
| 2390 | +	    if (isset($TI)) { | |
| 2391 | + $TI->checkAll(); | |
| 2392 | + } | |
| 2393 | +	    if (isset($MI)) { | |
| 2394 | + $MI->checkAll(); | |
| 2395 | + } | |
| 1719 | 2396 | } | 
| 1720 | 2397 | } | 
| 1721 | 2398 | } | 
| @@ -3,10 +3,10 @@ discard block | ||
| 3 | 3 | require_once(dirname(__FILE__).'/class.Common.php'); | 
| 4 | 4 | require_once(dirname(__FILE__).'/class.GeoidHeight.php'); | 
| 5 | 5 |  class aprs { | 
| 6 | - private $socket; | |
| 7 | - private $connected = false; | |
| 6 | + private $socket; | |
| 7 | + private $connected = false; | |
| 8 | 8 | |
| 9 | -    protected $symbols = array('/!' => 'Police', | |
| 9 | +	protected $symbols = array('/!' => 'Police', | |
| 10 | 10 | '/#' => 'DIGI', | 
| 11 | 11 | '/$' => 'Phone', | 
| 12 | 12 | '/%' => 'DX Cluster', | 
| @@ -166,13 +166,13 @@ discard block | ||
| 166 | 166 | '\~' => 'TNC Stream SW'); | 
| 167 | 167 | |
| 168 | 168 | |
| 169 | -    private function urshift($n, $s) { | |
| 169 | +	private function urshift($n, $s) { | |
| 170 | 170 | return ($n >= 0) ? ($n >> $s) : | 
| 171 | - (($n & 0x7fffffff) >> $s) | | |
| 171 | + (($n & 0x7fffffff) >> $s) | | |
| 172 | 172 | (0x40000000 >> ($s - 1)); | 
| 173 | - } | |
| 173 | + } | |
| 174 | 174 | |
| 175 | -    public function parse($input) { | |
| 175 | +	public function parse($input) { | |
| 176 | 176 | global $globalDebug; | 
| 177 | 177 | $debug = false; | 
| 178 | 178 | $result = array(); | 
| @@ -184,8 +184,8 @@ discard block | ||
| 184 | 184 | |
| 185 | 185 | /* Check that end was found and body has at least one byte. */ | 
| 186 | 186 |  	if ($splitpos == 0 || $splitpos + 1 == $input_len || $splitpos === FALSE) { | 
| 187 | - if ($globalDebug) echo '!!! APRS invalid : '.$input."\n"; | |
| 188 | - return false; | |
| 187 | + if ($globalDebug) echo '!!! APRS invalid : '.$input."\n"; | |
| 188 | + return false; | |
| 189 | 189 | } | 
| 190 | 190 | |
| 191 | 191 | if ($debug) echo 'input : '.$input."\n"; | 
| @@ -199,34 +199,34 @@ discard block | ||
| 199 | 199 | /* Parse source, target and path. */ | 
| 200 | 200 | //FLRDF0A52>APRS,qAS,LSTB | 
| 201 | 201 |  	if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/',$header,$matches)) { | 
| 202 | - $ident = $matches[1]; | |
| 203 | - $all_elements = $matches[2]; | |
| 204 | -	    if ($ident == 'AIRCRAFT') { | |
| 202 | + $ident = $matches[1]; | |
| 203 | + $all_elements = $matches[2]; | |
| 204 | +		if ($ident == 'AIRCRAFT') { | |
| 205 | 205 | $result['format_source'] = 'famaprs'; | 
| 206 | 206 | $result['source_type'] = 'modes'; | 
| 207 | -	    } elseif ($ident == 'MARINE') { | |
| 207 | +		} elseif ($ident == 'MARINE') { | |
| 208 | 208 | $result['format_source'] = 'famaprs'; | 
| 209 | 209 | $result['source_type'] = 'ais'; | 
| 210 | -	    } else { | |
| 210 | +		} else { | |
| 211 | 211 | if ($debug) echo 'ident : '.$ident."\n"; | 
| 212 | 212 | $result['ident'] = $ident; | 
| 213 | - } | |
| 213 | + } | |
| 214 | 214 |  	} else { | 
| 215 | - if ($debug) 'No ident'."\n"; | |
| 216 | - return false; | |
| 215 | + if ($debug) 'No ident'."\n"; | |
| 216 | + return false; | |
| 217 | 217 | } | 
| 218 | 218 |  	$elements = explode(',',$all_elements); | 
| 219 | 219 | $source = end($elements); | 
| 220 | 220 | $result['source'] = $source; | 
| 221 | 221 |  	foreach ($elements as $element) { | 
| 222 | -	    if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) { | |
| 223 | - //echo "ok"; | |
| 224 | - //if ($element == 'TCPIP*') return false; | |
| 225 | -	    } elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) { | |
| 222 | +		if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) { | |
| 223 | + //echo "ok"; | |
| 224 | + //if ($element == 'TCPIP*') return false; | |
| 225 | +		} elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) { | |
| 226 | 226 | if ($debug) echo 'element : '.$element."\n"; | 
| 227 | 227 | return false; | 
| 228 | - } | |
| 229 | - /* | |
| 228 | + } | |
| 229 | + /* | |
| 230 | 230 |  	    } elseif (preg_match('/^([0-9A-F]{32})$/',$element)) { | 
| 231 | 231 | //echo "ok"; | 
| 232 | 232 |  	    } else { | 
| @@ -253,48 +253,48 @@ discard block | ||
| 253 | 253 | $body_parse = substr($body,1); | 
| 254 | 254 | //echo 'Body : '.$body."\n"; | 
| 255 | 255 |  	if (preg_match('/^;(.){9}\*/',$body,$matches)) { | 
| 256 | - $body_parse = substr($body_parse,10); | |
| 257 | - $find = true; | |
| 258 | - //echo $body_parse."\n"; | |
| 256 | + $body_parse = substr($body_parse,10); | |
| 257 | + $find = true; | |
| 258 | + //echo $body_parse."\n"; | |
| 259 | 259 | } | 
| 260 | 260 |  	if (preg_match('/^`(.*)\//',$body,$matches)) { | 
| 261 | - $body_parse = substr($body_parse,strlen($matches[1])-1); | |
| 262 | - $find = true; | |
| 263 | - //echo $body_parse."\n"; | |
| 261 | + $body_parse = substr($body_parse,strlen($matches[1])-1); | |
| 262 | + $find = true; | |
| 263 | + //echo $body_parse."\n"; | |
| 264 | 264 | } | 
| 265 | 265 |  	if (preg_match("/^'(.*)\//",$body,$matches)) { | 
| 266 | - $body_parse = substr($body_parse,strlen($matches[1])-1); | |
| 267 | - $find = true; | |
| 268 | - //echo $body_parse."\n"; | |
| 266 | + $body_parse = substr($body_parse,strlen($matches[1])-1); | |
| 267 | + $find = true; | |
| 268 | + //echo $body_parse."\n"; | |
| 269 | 269 | } | 
| 270 | 270 |  	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/',$body_parse,$matches)) { | 
| 271 | - $find = true; | |
| 272 | - //print_r($matches); | |
| 273 | - $timestamp = $matches[0]; | |
| 274 | -	    if ($matches[4] == 'h') { | |
| 271 | + $find = true; | |
| 272 | + //print_r($matches); | |
| 273 | + $timestamp = $matches[0]; | |
| 274 | +		if ($matches[4] == 'h') { | |
| 275 | 275 |  		$timestamp = strtotime(date('Ymd').' '.$matches[1].':'.$matches[2].':'.$matches[3]); | 
| 276 | 276 | //echo 'timestamp : '.$timestamp.' - now : '.time()."\n"; | 
| 277 | 277 | /* | 
| 278 | 278 | if (time() + 3900 < $timestamp) $timestamp -= 86400; | 
| 279 | 279 | elseif (time() - 82500 > $timestamp) $timestamp += 86400; | 
| 280 | 280 | */ | 
| 281 | -	    } elseif ($matches[4] == 'z' || $matches[4] == '/') { | |
| 281 | +		} elseif ($matches[4] == 'z' || $matches[4] == '/') { | |
| 282 | 282 | // This work or not ? | 
| 283 | 283 |  		$timestamp = strtotime(date('Ym').$matches[1].' '.$matches[2].':'.$matches[3]); | 
| 284 | - } | |
| 285 | - $body_parse = substr($body_parse,7); | |
| 286 | - $result['timestamp'] = $timestamp; | |
| 287 | -	    //echo date('Ymd H:i:s',$timestamp); | |
| 284 | + } | |
| 285 | + $body_parse = substr($body_parse,7); | |
| 286 | + $result['timestamp'] = $timestamp; | |
| 287 | +		//echo date('Ymd H:i:s',$timestamp); | |
| 288 | 288 | } | 
| 289 | 289 |  	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/',$body_parse,$matches)) { | 
| 290 | - $find = true; | |
| 291 | -	    $timestamp = strtotime(date('Y').$matches[1].$matches[2].' '.$matches[3].':'.$matches[4]); | |
| 292 | - $body_parse = substr($body_parse,8); | |
| 293 | - $result['timestamp'] = $timestamp; | |
| 294 | -	    //echo date('Ymd H:i:s',$timestamp); | |
| 290 | + $find = true; | |
| 291 | +		$timestamp = strtotime(date('Y').$matches[1].$matches[2].' '.$matches[3].':'.$matches[4]); | |
| 292 | + $body_parse = substr($body_parse,8); | |
| 293 | + $result['timestamp'] = $timestamp; | |
| 294 | +		//echo date('Ymd H:i:s',$timestamp); | |
| 295 | 295 | } | 
| 296 | 296 |  	//if (strlen($body_parse) > 19) { | 
| 297 | -	    if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/',$body_parse,$matches)) { | |
| 297 | +		if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/',$body_parse,$matches)) { | |
| 298 | 298 | $find = true; | 
| 299 | 299 | // 4658.70N/00707.78Ez | 
| 300 | 300 | //print_r(str_split($body_parse)); | 
| @@ -313,7 +313,7 @@ discard block | ||
| 313 | 313 | $lon = intval($lon_deg); | 
| 314 | 314 | if ($lat > 89 || $lon > 179) return false; | 
| 315 | 315 | |
| 316 | - /* | |
| 316 | + /* | |
| 317 | 317 |  	    $tmp_5b = str_replace('.','',$lat_min); | 
| 318 | 318 |  	    if (preg_match('/^([0-9]{0,4})( {0,4})$/',$tmp_5b,$matches)) { | 
| 319 | 319 | print_r($matches); | 
| @@ -327,9 +327,9 @@ discard block | ||
| 327 | 327 | $result['longitude'] = $longitude; | 
| 328 | 328 | $body_parse = substr($body_parse,18); | 
| 329 | 329 | $body_parse_len = strlen($body_parse); | 
| 330 | - } | |
| 331 | - $body_parse_len = strlen($body_parse); | |
| 332 | -	    if ($body_parse_len > 0) { | |
| 330 | + } | |
| 331 | + $body_parse_len = strlen($body_parse); | |
| 332 | +		if ($body_parse_len > 0) { | |
| 333 | 333 | /* | 
| 334 | 334 |  		if (!isset($result['timestamp']) && !isset($result['latitude'])) { | 
| 335 | 335 | $body_split = str_split($body); | 
| @@ -363,95 +363,95 @@ discard block | ||
| 363 | 363 | if (isset($this->symbols[$symbol_code])) $result['symbol'] = $this->symbols[$symbol_code]; | 
| 364 | 364 |  			if ($symbol_code != '_') { | 
| 365 | 365 | } | 
| 366 | - //$body_parse = substr($body_parse,1); | |
| 367 | - //$body_parse = trim($body_parse); | |
| 368 | - //$body_parse_len = strlen($body_parse); | |
| 369 | -		    if ($body_parse_len >= 7) { | |
| 366 | + //$body_parse = substr($body_parse,1); | |
| 367 | + //$body_parse = trim($body_parse); | |
| 368 | + //$body_parse_len = strlen($body_parse); | |
| 369 | +			if ($body_parse_len >= 7) { | |
| 370 | 370 | |
| 371 | -		        if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) { | |
| 372 | - $course = substr($body_parse,0,3); | |
| 373 | - $tmp_s = intval($course); | |
| 374 | - if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course); | |
| 375 | - $speed = substr($body_parse,4,3); | |
| 376 | -		    	    if ($speed != '...') { | |
| 377 | - //$result['speed'] = round($speed*1.852); | |
| 378 | - $result['speed'] = intval($speed); | |
| 379 | - } | |
| 380 | - $body_parse = substr($body_parse,7); | |
| 381 | - } | |
| 382 | - // Check PHGR, PHG, RNG | |
| 383 | - } | |
| 384 | - /* | |
| 371 | +				if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) { | |
| 372 | + $course = substr($body_parse,0,3); | |
| 373 | + $tmp_s = intval($course); | |
| 374 | + if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course); | |
| 375 | + $speed = substr($body_parse,4,3); | |
| 376 | +					if ($speed != '...') { | |
| 377 | + //$result['speed'] = round($speed*1.852); | |
| 378 | + $result['speed'] = intval($speed); | |
| 379 | + } | |
| 380 | + $body_parse = substr($body_parse,7); | |
| 381 | + } | |
| 382 | + // Check PHGR, PHG, RNG | |
| 383 | + } | |
| 384 | + /* | |
| 385 | 385 |  		    else if ($body_parse_len > 0) { | 
| 386 | 386 | $rest = $body_parse; | 
| 387 | 387 | } | 
| 388 | 388 | */ | 
| 389 | -		    if (strlen($body_parse) > 0) { | |
| 390 | -		        if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/',$body_parse,$matches)) { | |
| 391 | - $altitude = intval($matches[1]); | |
| 392 | - //$result['altitude'] = round($altitude*0.3048); | |
| 393 | - $result['altitude'] = $altitude; | |
| 394 | - //$body_parse = trim(substr($body_parse,strlen($matches[0]))); | |
| 395 | -		            $body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/','',$body_parse)); | |
| 396 | - } | |
| 397 | - } | |
| 389 | +			if (strlen($body_parse) > 0) { | |
| 390 | +				if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/',$body_parse,$matches)) { | |
| 391 | + $altitude = intval($matches[1]); | |
| 392 | + //$result['altitude'] = round($altitude*0.3048); | |
| 393 | + $result['altitude'] = $altitude; | |
| 394 | + //$body_parse = trim(substr($body_parse,strlen($matches[0]))); | |
| 395 | +					$body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/','',$body_parse)); | |
| 396 | + } | |
| 397 | + } | |
| 398 | 398 | |
| 399 | - // Telemetry | |
| 400 | - /* | |
| 399 | + // Telemetry | |
| 400 | + /* | |
| 401 | 401 |  		    if (preg_match('/^([0-9]+),(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,([01]{0,8})/',$body_parse,$matches)) { | 
| 402 | 402 | // Nothing yet... | 
| 403 | 403 | } | 
| 404 | 404 | */ | 
| 405 | - // DAO | |
| 405 | + // DAO | |
| 406 | 406 | |
| 407 | -		    if (preg_match('/^!([0-9A-Z]{3})/',$body_parse,$matches)) { | |
| 407 | +			if (preg_match('/^!([0-9A-Z]{3})/',$body_parse,$matches)) { | |
| 408 | 408 | |
| 409 | - $dao = $matches[1]; | |
| 410 | -			    if (preg_match('/^([A-Z])([0-9]{2})/',$dao)) { | |
| 409 | + $dao = $matches[1]; | |
| 410 | +				if (preg_match('/^([A-Z])([0-9]{2})/',$dao)) { | |
| 411 | 411 | $dao_split = str_split($dao); | 
| 412 | - $lat_off = (($dao_split[1])-48.0)*0.001/60.0; | |
| 413 | - $lon_off = (($dao_split[2])-48.0)*0.001/60.0; | |
| 412 | + $lat_off = (($dao_split[1])-48.0)*0.001/60.0; | |
| 413 | + $lon_off = (($dao_split[2])-48.0)*0.001/60.0; | |
| 414 | 414 | |
| 415 | 415 | if ($result['latitude'] < 0) $result['latitude'] -= $lat_off; | 
| 416 | 416 | else $result['latitude'] += $lat_off; | 
| 417 | 417 | if ($result['longitude'] < 0) $result['longitude'] -= $lon_off; | 
| 418 | 418 | else $result['longitude'] += $lon_off; | 
| 419 | - } | |
| 419 | + } | |
| 420 | 420 | |
| 421 | - $body_parse = substr($body_parse,6); | |
| 422 | - } | |
| 421 | + $body_parse = substr($body_parse,6); | |
| 422 | + } | |
| 423 | 423 | |
| 424 | -		    if (preg_match('/CS=([0-9A-Z_]*)/',$body_parse,$matches)) { | |
| 424 | +			if (preg_match('/CS=([0-9A-Z_]*)/',$body_parse,$matches)) { | |
| 425 | 425 |  			$result['ident'] = str_replace('_',' ',$matches[1]); | 
| 426 | - } | |
| 427 | -		    if (preg_match('/SQ=([0-9]{4})/',$body_parse,$matches)) { | |
| 426 | + } | |
| 427 | +			if (preg_match('/SQ=([0-9]{4})/',$body_parse,$matches)) { | |
| 428 | 428 | $result['squawk'] = $matches[1]; | 
| 429 | - } | |
| 430 | -		    if (preg_match('/AI=([0-9A-Z]{4})/',$body_parse,$matches)) { | |
| 429 | + } | |
| 430 | +			if (preg_match('/AI=([0-9A-Z]{4})/',$body_parse,$matches)) { | |
| 431 | 431 | $result['aircraft_icao'] = $matches[1]; | 
| 432 | - } | |
| 433 | -		    if (preg_match('/VR=([0-9]*)/',$body_parse,$matches)) { | |
| 432 | + } | |
| 433 | +			if (preg_match('/VR=([0-9]*)/',$body_parse,$matches)) { | |
| 434 | 434 | $result['verticalrate'] = $matches[1]; | 
| 435 | - } | |
| 436 | -		    if (preg_match('/TI=([0-9]*)/',$body_parse,$matches)) { | |
| 435 | + } | |
| 436 | +			if (preg_match('/TI=([0-9]*)/',$body_parse,$matches)) { | |
| 437 | 437 | $result['typeid'] = $matches[1]; | 
| 438 | - } | |
| 439 | -		    if (preg_match('/SI=([0-9]*)/',$body_parse,$matches)) { | |
| 438 | + } | |
| 439 | +			if (preg_match('/SI=([0-9]*)/',$body_parse,$matches)) { | |
| 440 | 440 | $result['statusid'] = $matches[1]; | 
| 441 | - } | |
| 442 | -		    if (preg_match('/IMO=([0-9]{7})/',$body_parse,$matches)) { | |
| 441 | + } | |
| 442 | +			if (preg_match('/IMO=([0-9]{7})/',$body_parse,$matches)) { | |
| 443 | 443 | $result['imo'] = $matches[1]; | 
| 444 | - } | |
| 445 | -		    if (preg_match('/AD=([0-9]*)/',$body_parse,$matches)) { | |
| 444 | + } | |
| 445 | +			if (preg_match('/AD=([0-9]*)/',$body_parse,$matches)) { | |
| 446 | 446 | $result['arrival_date'] = $matches[1]; | 
| 447 | - } | |
| 448 | -		    if (preg_match('/AC=([0-9A-Z_]*)/',$body_parse,$matches)) { | |
| 447 | + } | |
| 448 | +			if (preg_match('/AC=([0-9A-Z_]*)/',$body_parse,$matches)) { | |
| 449 | 449 |  			$result['arrival_code'] = str_replace('_',' ',$matches[1]); | 
| 450 | - } | |
| 451 | - // OGN comment | |
| 450 | + } | |
| 451 | + // OGN comment | |
| 452 | 452 | // echo "Before OGN : ".$body_parse."\n"; | 
| 453 | -		    //if (preg_match('/^id([0-9A-F]{8}) ([+-])([0-9]{3,4})fpm ([+-])([0-9.]{3,4})rot (.*)$/',$body_parse,$matches)) { | |
| 454 | -		    if (preg_match('/^id([0-9A-F]{8})/',$body_parse,$matches)) { | |
| 453 | +			//if (preg_match('/^id([0-9A-F]{8}) ([+-])([0-9]{3,4})fpm ([+-])([0-9.]{3,4})rot (.*)$/',$body_parse,$matches)) { | |
| 454 | +			if (preg_match('/^id([0-9A-F]{8})/',$body_parse,$matches)) { | |
| 455 | 455 | $id = $matches[1]; | 
| 456 | 456 | //$mode = substr($id,0,2); | 
| 457 | 457 | $address = substr($id,2); | 
| @@ -481,42 +481,42 @@ discard block | ||
| 481 | 481 | $stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0; | 
| 482 | 482 | $result['stealth'] = $stealth; | 
| 483 | 483 | $result['address'] = $address; | 
| 484 | - } | |
| 484 | + } | |
| 485 | 485 | |
| 486 | - //Comment | |
| 487 | - $result['comment'] = trim($body_parse); | |
| 486 | + //Comment | |
| 487 | + $result['comment'] = trim($body_parse); | |
| 488 | 488 |  		//} else { | 
| 489 | - // parse weather | |
| 490 | - //$body_parse = substr($body_parse,1); | |
| 491 | - //$body_parse_len = strlen($body_parse); | |
| 492 | - //echo 'weather'."\n"; | |
| 493 | -		    if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { | |
| 494 | - $result['wind_dir'] = intval($matches[1]); | |
| 495 | - $result['wind_speed'] = round(intval($matches[2])*1.60934,1); | |
| 496 | - $result['wind_gust'] = round(intval($matches[3])*1.60934,1); | |
| 497 | - $result['temp'] = round(5/9*((intval($matches[4]))-32),1); | |
| 498 | - $body_parse = substr($body_parse,strlen($matches[0])+1); | |
| 499 | -		    } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { | |
| 489 | + // parse weather | |
| 490 | + //$body_parse = substr($body_parse,1); | |
| 491 | + //$body_parse_len = strlen($body_parse); | |
| 492 | + //echo 'weather'."\n"; | |
| 493 | +			if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { | |
| 494 | + $result['wind_dir'] = intval($matches[1]); | |
| 495 | + $result['wind_speed'] = round(intval($matches[2])*1.60934,1); | |
| 496 | + $result['wind_gust'] = round(intval($matches[3])*1.60934,1); | |
| 497 | + $result['temp'] = round(5/9*((intval($matches[4]))-32),1); | |
| 498 | + $body_parse = substr($body_parse,strlen($matches[0])+1); | |
| 499 | +			} elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { | |
| 500 | 500 | $result['wind_dir'] = intval($matches[1]); | 
| 501 | 501 | $result['wind_speed'] = round($matches[2]*1.60934,1); | 
| 502 | 502 | $result['wind_gust'] = round($matches[3]*1.60934,1); | 
| 503 | 503 | $result['temp'] = round(5/9*(($matches[4])-32),1); | 
| 504 | - $body_parse = substr($body_parse,strlen($matches[0])+1); | |
| 505 | -		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { | |
| 504 | + $body_parse = substr($body_parse,strlen($matches[0])+1); | |
| 505 | +			} elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { | |
| 506 | 506 | $result['wind_dir'] = intval($matches[1]); | 
| 507 | 507 | $result['wind_speed'] = round($matches[2]*1.60934,1); | 
| 508 | 508 | $result['wind_gust'] = round($matches[3]*1.60934,1); | 
| 509 | - $body_parse = substr($body_parse,strlen($matches[0])+1); | |
| 510 | -		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/',$body_parse,$matches)) { | |
| 509 | + $body_parse = substr($body_parse,strlen($matches[0])+1); | |
| 510 | +			} elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/',$body_parse,$matches)) { | |
| 511 | 511 | $result['wind_dir'] = intval($matches[1]); | 
| 512 | 512 | $result['wind_speed'] = round($matches[2]*1.60934,1); | 
| 513 | 513 | $result['wind_gust'] = round($matches[3]*1.60934,1); | 
| 514 | - $body_parse = substr($body_parse,strlen($matches[0])+1); | |
| 515 | - } | |
| 516 | -		    //if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/',$body_parse,$matches)) { | |
| 517 | - //g012t088r000p000P000h38b10110 | |
| 518 | - //g011t086r000p000P000h29b10198 | |
| 519 | -		    if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/',$body_parse,$matches)) { | |
| 514 | + $body_parse = substr($body_parse,strlen($matches[0])+1); | |
| 515 | + } | |
| 516 | +			//if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/',$body_parse,$matches)) { | |
| 517 | + //g012t088r000p000P000h38b10110 | |
| 518 | + //g011t086r000p000P000h29b10198 | |
| 519 | +			if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/',$body_parse,$matches)) { | |
| 520 | 520 | if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); | 
| 521 | 521 | if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); | 
| 522 | 522 | if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); | 
| @@ -524,8 +524,8 @@ discard block | ||
| 524 | 524 | if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1,1); | 
| 525 | 525 | if ($matches[6] != '...') $result['humidity'] = intval($matches[6]); | 
| 526 | 526 | if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10),1); | 
| 527 | - $body_parse = substr($body_parse,strlen($matches[0])); | |
| 528 | -		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})P([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/',$body_parse,$matches)) { | |
| 527 | + $body_parse = substr($body_parse,strlen($matches[0])); | |
| 528 | +			} elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})P([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/',$body_parse,$matches)) { | |
| 529 | 529 | if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); | 
| 530 | 530 | if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); | 
| 531 | 531 | if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); | 
| @@ -533,8 +533,8 @@ discard block | ||
| 533 | 533 | if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1,1); | 
| 534 | 534 | if ($matches[6] != '...') $result['humidity'] = intval($matches[6]); | 
| 535 | 535 | if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10),1); | 
| 536 | - $body_parse = substr($body_parse,strlen($matches[0])); | |
| 537 | -		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) { | |
| 536 | + $body_parse = substr($body_parse,strlen($matches[0])); | |
| 537 | +			} elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) { | |
| 538 | 538 | if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); | 
| 539 | 539 | if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); | 
| 540 | 540 | if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); | 
| @@ -542,58 +542,58 @@ discard block | ||
| 542 | 542 | if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1,1); | 
| 543 | 543 | if ($matches[7] != '...') $result['humidity'] = intval($matches[7]); | 
| 544 | 544 | if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10),1); | 
| 545 | - $body_parse = substr($body_parse,strlen($matches[0])); | |
| 546 | -		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) { | |
| 545 | + $body_parse = substr($body_parse,strlen($matches[0])); | |
| 546 | +			} elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) { | |
| 547 | 547 | if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); | 
| 548 | 548 | if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); | 
| 549 | 549 | if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); | 
| 550 | 550 | if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1,1); | 
| 551 | 551 | if ($matches[6] != '...') $result['humidity'] = intval($matches[6]); | 
| 552 | 552 | if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1); | 
| 553 | - $body_parse = substr($body_parse,strlen($matches[0])); | |
| 554 | -		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) { | |
| 553 | + $body_parse = substr($body_parse,strlen($matches[0])); | |
| 554 | +			} elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) { | |
| 555 | 555 | if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); | 
| 556 | 556 | if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); | 
| 557 | 557 | if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); | 
| 558 | 558 | if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1); | 
| 559 | 559 | if ($matches[6] != '...') $result['humidity'] = intval($matches[6]); | 
| 560 | 560 | if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1); | 
| 561 | - $body_parse = substr($body_parse,strlen($matches[0])); | |
| 562 | -		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) { | |
| 561 | + $body_parse = substr($body_parse,strlen($matches[0])); | |
| 562 | +			} elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) { | |
| 563 | 563 | if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); | 
| 564 | 564 | if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); | 
| 565 | 565 | if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); | 
| 566 | 566 | if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1); | 
| 567 | 567 | if ($matches[5] != '...') $result['humidity'] = intval($matches[5]); | 
| 568 | 568 | if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10),1); | 
| 569 | - $body_parse = substr($body_parse,strlen($matches[0])); | |
| 570 | -		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) { | |
| 569 | + $body_parse = substr($body_parse,strlen($matches[0])); | |
| 570 | +			} elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) { | |
| 571 | 571 | if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); | 
| 572 | 572 | if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); | 
| 573 | 573 | if ($matches[2] != '...') $result['humidity'] = intval($matches[3]); | 
| 574 | 574 | if ($matches[4] != '...') $result['pressure'] = round((intval($matches[4])/10),1); | 
| 575 | - $body_parse = substr($body_parse,strlen($matches[0])); | |
| 576 | -		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{2,3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) { | |
| 575 | + $body_parse = substr($body_parse,strlen($matches[0])); | |
| 576 | +			} elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{2,3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) { | |
| 577 | 577 | if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); | 
| 578 | 578 | if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); | 
| 579 | 579 | if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); | 
| 580 | 580 | if ($matches[4] != '...') $result['humidity'] = intval($matches[4]); | 
| 581 | 581 | if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1); | 
| 582 | - $body_parse = substr($body_parse,strlen($matches[0])); | |
| 583 | - } | |
| 584 | - $result['comment'] = trim($body_parse); | |
| 582 | + $body_parse = substr($body_parse,strlen($matches[0])); | |
| 583 | + } | |
| 584 | + $result['comment'] = trim($body_parse); | |
| 585 | 585 | } | 
| 586 | 586 | } else $result['comment'] = trim($body_parse); | 
| 587 | 587 | |
| 588 | - } | |
| 588 | + } | |
| 589 | 589 | //} | 
| 590 | 590 | if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4); | 
| 591 | 591 | if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4); | 
| 592 | 592 | if ($debug) print_r($result); | 
| 593 | 593 | return $result; | 
| 594 | - } | |
| 594 | + } | |
| 595 | 595 | |
| 596 | -    public function connect() { | |
| 596 | +	public function connect() { | |
| 597 | 597 | global $globalAPRSversion, $globalServerAPRSssid, $globalServerAPRSpass,$globalName, $globalServerAPRShost, $globalServerAPRSport; | 
| 598 | 598 | $aprs_connect = 0; | 
| 599 | 599 | $aprs_keep = 120; | 
| @@ -617,24 +617,24 @@ discard block | ||
| 617 | 617 | socket_set_option($this->socket,SOL_SOCKET,SO_KEEPALIVE,1); | 
| 618 | 618 |  		while ($msgin = socket_read($this->socket, 1000,PHP_NORMAL_READ)) { | 
| 619 | 619 |  			if (strpos($msgin, "$aprs_ssid verified") !== FALSE) { | 
| 620 | - echo 'APRS user verified !'."\n"; | |
| 621 | - $this->connected = true; | |
| 622 | - return true; | |
| 623 | - break; | |
| 620 | + echo 'APRS user verified !'."\n"; | |
| 621 | + $this->connected = true; | |
| 622 | + return true; | |
| 623 | + break; | |
| 624 | 624 | } | 
| 625 | 625 |  			if (time()-$authstart > 5) { | 
| 626 | - echo 'APRS timeout'."\n"; | |
| 627 | - break; | |
| 626 | + echo 'APRS timeout'."\n"; | |
| 627 | + break; | |
| 628 | 628 | } | 
| 629 | 629 | } | 
| 630 | 630 | } | 
| 631 | - } | |
| 631 | + } | |
| 632 | 632 | |
| 633 | -    public function disconnect() { | |
| 633 | +	public function disconnect() { | |
| 634 | 634 | socket_close($this->socket); | 
| 635 | - } | |
| 635 | + } | |
| 636 | 636 | |
| 637 | -    public function send($data) { | |
| 637 | +	public function send($data) { | |
| 638 | 638 | global $globalDebug; | 
| 639 | 639 | if ($this->connected === false) $this->connect(); | 
| 640 | 640 | $send = socket_send( $this->socket , $data , strlen($data),0); | 
| @@ -643,7 +643,7 @@ discard block | ||
| 643 | 643 | socket_close($this->socket); | 
| 644 | 644 | $this->connect(); | 
| 645 | 645 | } | 
| 646 | - } | |
| 646 | + } | |
| 647 | 647 | } | 
| 648 | 648 | |
| 649 | 649 |  class APRSSpotter extends APRS { | 
| @@ -167,8 +167,7 @@ discard block | ||
| 167 | 167 | |
| 168 | 168 | |
| 169 | 169 |      private function urshift($n, $s) { | 
| 170 | - return ($n >= 0) ? ($n >> $s) : | |
| 171 | - (($n & 0x7fffffff) >> $s) | | |
| 170 | + return ($n >= 0) ? ($n >> $s) : (($n&0x7fffffff) >> $s)| | |
| 172 | 171 | (0x40000000 >> ($s - 1)); | 
| 173 | 172 | } | 
| 174 | 173 | |
| @@ -180,7 +179,7 @@ discard block | ||
| 180 | 179 | //$split_input = str_split($input); | 
| 181 | 180 | |
| 182 | 181 | /* Find the end of header checking for NULL bytes while doing it. */ | 
| 183 | - $splitpos = strpos($input,':'); | |
| 182 | + $splitpos = strpos($input, ':'); | |
| 184 | 183 | |
| 185 | 184 | /* Check that end was found and body has at least one byte. */ | 
| 186 | 185 |  	if ($splitpos == 0 || $splitpos + 1 == $input_len || $splitpos === FALSE) { | 
| @@ -190,15 +189,15 @@ discard block | ||
| 190 | 189 | |
| 191 | 190 | if ($debug) echo 'input : '.$input."\n"; | 
| 192 | 191 | /* Save header and body. */ | 
| 193 | - $body = substr($input,$splitpos+1,$input_len); | |
| 192 | + $body = substr($input, $splitpos + 1, $input_len); | |
| 194 | 193 | $body_len = strlen($body); | 
| 195 | - $header = substr($input,0,$splitpos); | |
| 194 | + $header = substr($input, 0, $splitpos); | |
| 196 | 195 | //$header_len = strlen($header); | 
| 197 | 196 | if ($debug) echo 'header : '.$header."\n"; | 
| 198 | 197 | |
| 199 | 198 | /* Parse source, target and path. */ | 
| 200 | 199 | //FLRDF0A52>APRS,qAS,LSTB | 
| 201 | -	if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/',$header,$matches)) { | |
| 200 | +	if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/', $header, $matches)) { | |
| 202 | 201 | $ident = $matches[1]; | 
| 203 | 202 | $all_elements = $matches[2]; | 
| 204 | 203 |  	    if ($ident == 'AIRCRAFT') { | 
| @@ -215,14 +214,14 @@ discard block | ||
| 215 | 214 | if ($debug) 'No ident'."\n"; | 
| 216 | 215 | return false; | 
| 217 | 216 | } | 
| 218 | -	$elements = explode(',',$all_elements); | |
| 217 | +	$elements = explode(',', $all_elements); | |
| 219 | 218 | $source = end($elements); | 
| 220 | 219 | $result['source'] = $source; | 
| 221 | 220 |  	foreach ($elements as $element) { | 
| 222 | -	    if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) { | |
| 221 | +	    if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/', $element)) { | |
| 223 | 222 | //echo "ok"; | 
| 224 | 223 | //if ($element == 'TCPIP*') return false; | 
| 225 | -	    } elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) { | |
| 224 | +	    } elseif (!preg_match('/^([0-9A-F]{32})$/', $element)) { | |
| 226 | 225 | if ($debug) echo 'element : '.$element."\n"; | 
| 227 | 226 | return false; | 
| 228 | 227 | } | 
| @@ -235,14 +234,14 @@ discard block | ||
| 235 | 234 | */ | 
| 236 | 235 | } | 
| 237 | 236 | |
| 238 | - $type = substr($body,0,1); | |
| 237 | + $type = substr($body, 0, 1); | |
| 239 | 238 | if ($debug) echo 'type : '.$type."\n"; | 
| 240 | 239 |  	if ($type == ';') { | 
| 241 | 240 |  		if (isset($result['source_type']) && $result['source_type'] == 'modes') { | 
| 242 | - $result['address'] = trim(substr($body,1,9)); | |
| 241 | + $result['address'] = trim(substr($body, 1, 9)); | |
| 243 | 242 |  		} elseif (isset($result['source_type']) && $result['source_type'] == 'ais') { | 
| 244 | - $result['mmsi'] = trim(substr($body,1,9)); | |
| 245 | - } else $result['ident'] = trim(substr($body,1,9)); | |
| 243 | + $result['mmsi'] = trim(substr($body, 1, 9)); | |
| 244 | + } else $result['ident'] = trim(substr($body, 1, 9)); | |
| 246 | 245 |  	} elseif ($type == ',') { | 
| 247 | 246 | // Invalid data or test data | 
| 248 | 247 | return false; | 
| @@ -250,24 +249,24 @@ discard block | ||
| 250 | 249 | |
| 251 | 250 | // Check for Timestamp | 
| 252 | 251 | $find = false; | 
| 253 | - $body_parse = substr($body,1); | |
| 252 | + $body_parse = substr($body, 1); | |
| 254 | 253 | //echo 'Body : '.$body."\n"; | 
| 255 | -	if (preg_match('/^;(.){9}\*/',$body,$matches)) { | |
| 256 | - $body_parse = substr($body_parse,10); | |
| 254 | +	if (preg_match('/^;(.){9}\*/', $body, $matches)) { | |
| 255 | + $body_parse = substr($body_parse, 10); | |
| 257 | 256 | $find = true; | 
| 258 | 257 | //echo $body_parse."\n"; | 
| 259 | 258 | } | 
| 260 | -	if (preg_match('/^`(.*)\//',$body,$matches)) { | |
| 261 | - $body_parse = substr($body_parse,strlen($matches[1])-1); | |
| 259 | +	if (preg_match('/^`(.*)\//', $body, $matches)) { | |
| 260 | + $body_parse = substr($body_parse, strlen($matches[1]) - 1); | |
| 262 | 261 | $find = true; | 
| 263 | 262 | //echo $body_parse."\n"; | 
| 264 | 263 | } | 
| 265 | -	if (preg_match("/^'(.*)\//",$body,$matches)) { | |
| 266 | - $body_parse = substr($body_parse,strlen($matches[1])-1); | |
| 264 | +	if (preg_match("/^'(.*)\//", $body, $matches)) { | |
| 265 | + $body_parse = substr($body_parse, strlen($matches[1]) - 1); | |
| 267 | 266 | $find = true; | 
| 268 | 267 | //echo $body_parse."\n"; | 
| 269 | 268 | } | 
| 270 | -	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/',$body_parse,$matches)) { | |
| 269 | +	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/', $body_parse, $matches)) { | |
| 271 | 270 | $find = true; | 
| 272 | 271 | //print_r($matches); | 
| 273 | 272 | $timestamp = $matches[0]; | 
| @@ -282,19 +281,19 @@ discard block | ||
| 282 | 281 | // This work or not ? | 
| 283 | 282 |  		$timestamp = strtotime(date('Ym').$matches[1].' '.$matches[2].':'.$matches[3]); | 
| 284 | 283 | } | 
| 285 | - $body_parse = substr($body_parse,7); | |
| 284 | + $body_parse = substr($body_parse, 7); | |
| 286 | 285 | $result['timestamp'] = $timestamp; | 
| 287 | 286 |  	    //echo date('Ymd H:i:s',$timestamp); | 
| 288 | 287 | } | 
| 289 | -	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/',$body_parse,$matches)) { | |
| 288 | +	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/', $body_parse, $matches)) { | |
| 290 | 289 | $find = true; | 
| 291 | 290 |  	    $timestamp = strtotime(date('Y').$matches[1].$matches[2].' '.$matches[3].':'.$matches[4]); | 
| 292 | - $body_parse = substr($body_parse,8); | |
| 291 | + $body_parse = substr($body_parse, 8); | |
| 293 | 292 | $result['timestamp'] = $timestamp; | 
| 294 | 293 |  	    //echo date('Ymd H:i:s',$timestamp); | 
| 295 | 294 | } | 
| 296 | 295 |  	//if (strlen($body_parse) > 19) { | 
| 297 | -	    if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/',$body_parse,$matches)) { | |
| 296 | +	    if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/', $body_parse, $matches)) { | |
| 298 | 297 | $find = true; | 
| 299 | 298 | // 4658.70N/00707.78Ez | 
| 300 | 299 | //print_r(str_split($body_parse)); | 
| @@ -321,11 +320,11 @@ discard block | ||
| 321 | 320 | */ | 
| 322 | 321 | $latitude = $lat + floatval($lat_min)/60; | 
| 323 | 322 | $longitude = $lon + floatval($lon_min)/60; | 
| 324 | - if ($sind == 'S') $latitude = 0-$latitude; | |
| 325 | - if ($wind == 'W') $longitude = 0-$longitude; | |
| 323 | + if ($sind == 'S') $latitude = 0 - $latitude; | |
| 324 | + if ($wind == 'W') $longitude = 0 - $longitude; | |
| 326 | 325 | $result['latitude'] = $latitude; | 
| 327 | 326 | $result['longitude'] = $longitude; | 
| 328 | - $body_parse = substr($body_parse,18); | |
| 327 | + $body_parse = substr($body_parse, 18); | |
| 329 | 328 | $body_parse_len = strlen($body_parse); | 
| 330 | 329 | } | 
| 331 | 330 | $body_parse_len = strlen($body_parse); | 
| @@ -357,7 +356,7 @@ discard block | ||
| 357 | 356 | //echo $body_parse; | 
| 358 | 357 |  			//if ($type != ';' && $type != '>') { | 
| 359 | 358 |  			if ($type != '') { | 
| 360 | - $body_parse = substr($body_parse,1); | |
| 359 | + $body_parse = substr($body_parse, 1); | |
| 361 | 360 | $body_parse_len = strlen($body_parse); | 
| 362 | 361 | $result['symbol_code'] = $symbol_code; | 
| 363 | 362 | if (isset($this->symbols[$symbol_code])) $result['symbol'] = $this->symbols[$symbol_code]; | 
| @@ -368,16 +367,16 @@ discard block | ||
| 368 | 367 | //$body_parse_len = strlen($body_parse); | 
| 369 | 368 |  		    if ($body_parse_len >= 7) { | 
| 370 | 369 | |
| 371 | -		        if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) { | |
| 372 | - $course = substr($body_parse,0,3); | |
| 370 | +		        if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/', $body_parse)) { | |
| 371 | + $course = substr($body_parse, 0, 3); | |
| 373 | 372 | $tmp_s = intval($course); | 
| 374 | 373 | if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course); | 
| 375 | - $speed = substr($body_parse,4,3); | |
| 374 | + $speed = substr($body_parse, 4, 3); | |
| 376 | 375 |  		    	    if ($speed != '...') { | 
| 377 | 376 | //$result['speed'] = round($speed*1.852); | 
| 378 | 377 | $result['speed'] = intval($speed); | 
| 379 | 378 | } | 
| 380 | - $body_parse = substr($body_parse,7); | |
| 379 | + $body_parse = substr($body_parse, 7); | |
| 381 | 380 | } | 
| 382 | 381 | // Check PHGR, PHG, RNG | 
| 383 | 382 | } | 
| @@ -387,12 +386,12 @@ discard block | ||
| 387 | 386 | } | 
| 388 | 387 | */ | 
| 389 | 388 |  		    if (strlen($body_parse) > 0) { | 
| 390 | -		        if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/',$body_parse,$matches)) { | |
| 389 | +		        if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/', $body_parse, $matches)) { | |
| 391 | 390 | $altitude = intval($matches[1]); | 
| 392 | 391 | //$result['altitude'] = round($altitude*0.3048); | 
| 393 | 392 | $result['altitude'] = $altitude; | 
| 394 | 393 | //$body_parse = trim(substr($body_parse,strlen($matches[0]))); | 
| 395 | -		            $body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/','',$body_parse)); | |
| 394 | +		            $body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/', '', $body_parse)); | |
| 396 | 395 | } | 
| 397 | 396 | } | 
| 398 | 397 | |
| @@ -404,13 +403,13 @@ discard block | ||
| 404 | 403 | */ | 
| 405 | 404 | // DAO | 
| 406 | 405 | |
| 407 | -		    if (preg_match('/^!([0-9A-Z]{3})/',$body_parse,$matches)) { | |
| 406 | +		    if (preg_match('/^!([0-9A-Z]{3})/', $body_parse, $matches)) { | |
| 408 | 407 | |
| 409 | 408 | $dao = $matches[1]; | 
| 410 | -			    if (preg_match('/^([A-Z])([0-9]{2})/',$dao)) { | |
| 409 | +			    if (preg_match('/^([A-Z])([0-9]{2})/', $dao)) { | |
| 411 | 410 | $dao_split = str_split($dao); | 
| 412 | - $lat_off = (($dao_split[1])-48.0)*0.001/60.0; | |
| 413 | - $lon_off = (($dao_split[2])-48.0)*0.001/60.0; | |
| 411 | + $lat_off = (($dao_split[1]) - 48.0)*0.001/60.0; | |
| 412 | + $lon_off = (($dao_split[2]) - 48.0)*0.001/60.0; | |
| 414 | 413 | |
| 415 | 414 | if ($result['latitude'] < 0) $result['latitude'] -= $lat_off; | 
| 416 | 415 | else $result['latitude'] += $lat_off; | 
| @@ -418,50 +417,50 @@ discard block | ||
| 418 | 417 | else $result['longitude'] += $lon_off; | 
| 419 | 418 | } | 
| 420 | 419 | |
| 421 | - $body_parse = substr($body_parse,6); | |
| 420 | + $body_parse = substr($body_parse, 6); | |
| 422 | 421 | } | 
| 423 | 422 | |
| 424 | -		    if (preg_match('/CS=([0-9A-Z_]*)/',$body_parse,$matches)) { | |
| 425 | -			$result['ident'] = str_replace('_',' ',$matches[1]); | |
| 423 | +		    if (preg_match('/CS=([0-9A-Z_]*)/', $body_parse, $matches)) { | |
| 424 | +			$result['ident'] = str_replace('_', ' ', $matches[1]); | |
| 426 | 425 | } | 
| 427 | -		    if (preg_match('/SQ=([0-9]{4})/',$body_parse,$matches)) { | |
| 426 | +		    if (preg_match('/SQ=([0-9]{4})/', $body_parse, $matches)) { | |
| 428 | 427 | $result['squawk'] = $matches[1]; | 
| 429 | 428 | } | 
| 430 | -		    if (preg_match('/AI=([0-9A-Z]{4})/',$body_parse,$matches)) { | |
| 429 | +		    if (preg_match('/AI=([0-9A-Z]{4})/', $body_parse, $matches)) { | |
| 431 | 430 | $result['aircraft_icao'] = $matches[1]; | 
| 432 | 431 | } | 
| 433 | -		    if (preg_match('/VR=([0-9]*)/',$body_parse,$matches)) { | |
| 432 | +		    if (preg_match('/VR=([0-9]*)/', $body_parse, $matches)) { | |
| 434 | 433 | $result['verticalrate'] = $matches[1]; | 
| 435 | 434 | } | 
| 436 | -		    if (preg_match('/TI=([0-9]*)/',$body_parse,$matches)) { | |
| 435 | +		    if (preg_match('/TI=([0-9]*)/', $body_parse, $matches)) { | |
| 437 | 436 | $result['typeid'] = $matches[1]; | 
| 438 | 437 | } | 
| 439 | -		    if (preg_match('/SI=([0-9]*)/',$body_parse,$matches)) { | |
| 438 | +		    if (preg_match('/SI=([0-9]*)/', $body_parse, $matches)) { | |
| 440 | 439 | $result['statusid'] = $matches[1]; | 
| 441 | 440 | } | 
| 442 | -		    if (preg_match('/IMO=([0-9]{7})/',$body_parse,$matches)) { | |
| 441 | +		    if (preg_match('/IMO=([0-9]{7})/', $body_parse, $matches)) { | |
| 443 | 442 | $result['imo'] = $matches[1]; | 
| 444 | 443 | } | 
| 445 | -		    if (preg_match('/AD=([0-9]*)/',$body_parse,$matches)) { | |
| 444 | +		    if (preg_match('/AD=([0-9]*)/', $body_parse, $matches)) { | |
| 446 | 445 | $result['arrival_date'] = $matches[1]; | 
| 447 | 446 | } | 
| 448 | -		    if (preg_match('/AC=([0-9A-Z_]*)/',$body_parse,$matches)) { | |
| 449 | -			$result['arrival_code'] = str_replace('_',' ',$matches[1]); | |
| 447 | +		    if (preg_match('/AC=([0-9A-Z_]*)/', $body_parse, $matches)) { | |
| 448 | +			$result['arrival_code'] = str_replace('_', ' ', $matches[1]); | |
| 450 | 449 | } | 
| 451 | 450 | // OGN comment | 
| 452 | 451 | // echo "Before OGN : ".$body_parse."\n"; | 
| 453 | 452 |  		    //if (preg_match('/^id([0-9A-F]{8}) ([+-])([0-9]{3,4})fpm ([+-])([0-9.]{3,4})rot (.*)$/',$body_parse,$matches)) { | 
| 454 | -		    if (preg_match('/^id([0-9A-F]{8})/',$body_parse,$matches)) { | |
| 453 | +		    if (preg_match('/^id([0-9A-F]{8})/', $body_parse, $matches)) { | |
| 455 | 454 | $id = $matches[1]; | 
| 456 | 455 | //$mode = substr($id,0,2); | 
| 457 | - $address = substr($id,2); | |
| 456 | + $address = substr($id, 2); | |
| 458 | 457 | //print_r($matches); | 
| 459 | - $addressType = (intval(substr($id,0,2),16))&3; | |
| 458 | + $addressType = (intval(substr($id, 0, 2), 16))&3; | |
| 460 | 459 | if ($addressType == 0) $result['addresstype'] = "RANDOM"; | 
| 461 | 460 | elseif ($addressType == 1) $result['addresstype'] = "ICAO"; | 
| 462 | 461 | elseif ($addressType == 2) $result['addresstype'] = "FLARM"; | 
| 463 | 462 | elseif ($addressType == 3) $result['addresstype'] = "OGN"; | 
| 464 | - $aircraftType = $this->urshift(((intval(substr($id,0,2),16)) & 0b1111100),2); | |
| 463 | + $aircraftType = $this->urshift(((intval(substr($id, 0, 2), 16))&0b1111100), 2); | |
| 465 | 464 | $result['aircrafttype_code'] = $aircraftType; | 
| 466 | 465 | if ($aircraftType == 0) $result['aircrafttype'] = "UNKNOWN"; | 
| 467 | 466 | elseif ($aircraftType == 1) $result['aircrafttype'] = "GLIDER"; | 
| @@ -478,7 +477,7 @@ discard block | ||
| 478 | 477 | elseif ($aircraftType == 12) $result['aircrafttype'] = "AIRSHIP"; | 
| 479 | 478 | elseif ($aircraftType == 13) $result['aircrafttype'] = "UAV"; | 
| 480 | 479 | elseif ($aircraftType == 15) $result['aircrafttype'] = "STATIC_OBJECT"; | 
| 481 | - $stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0; | |
| 480 | + $stealth = (intval(substr($id, 0, 2), 16)&0b10000000) != 0; | |
| 482 | 481 | $result['stealth'] = $stealth; | 
| 483 | 482 | $result['address'] = $address; | 
| 484 | 483 | } | 
| @@ -490,96 +489,96 @@ discard block | ||
| 490 | 489 | //$body_parse = substr($body_parse,1); | 
| 491 | 490 | //$body_parse_len = strlen($body_parse); | 
| 492 | 491 | //echo 'weather'."\n"; | 
| 493 | -		    if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { | |
| 492 | +		    if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) { | |
| 494 | 493 | $result['wind_dir'] = intval($matches[1]); | 
| 495 | - $result['wind_speed'] = round(intval($matches[2])*1.60934,1); | |
| 496 | - $result['wind_gust'] = round(intval($matches[3])*1.60934,1); | |
| 497 | - $result['temp'] = round(5/9*((intval($matches[4]))-32),1); | |
| 498 | - $body_parse = substr($body_parse,strlen($matches[0])+1); | |
| 499 | -		    } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { | |
| 494 | + $result['wind_speed'] = round(intval($matches[2])*1.60934, 1); | |
| 495 | + $result['wind_gust'] = round(intval($matches[3])*1.60934, 1); | |
| 496 | + $result['temp'] = round(5/9*((intval($matches[4])) - 32), 1); | |
| 497 | + $body_parse = substr($body_parse, strlen($matches[0]) + 1); | |
| 498 | +		    } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) { | |
| 500 | 499 | $result['wind_dir'] = intval($matches[1]); | 
| 501 | - $result['wind_speed'] = round($matches[2]*1.60934,1); | |
| 502 | - $result['wind_gust'] = round($matches[3]*1.60934,1); | |
| 503 | - $result['temp'] = round(5/9*(($matches[4])-32),1); | |
| 504 | - $body_parse = substr($body_parse,strlen($matches[0])+1); | |
| 505 | -		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { | |
| 500 | + $result['wind_speed'] = round($matches[2]*1.60934, 1); | |
| 501 | + $result['wind_gust'] = round($matches[3]*1.60934, 1); | |
| 502 | + $result['temp'] = round(5/9*(($matches[4]) - 32), 1); | |
| 503 | + $body_parse = substr($body_parse, strlen($matches[0]) + 1); | |
| 504 | +		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) { | |
| 506 | 505 | $result['wind_dir'] = intval($matches[1]); | 
| 507 | - $result['wind_speed'] = round($matches[2]*1.60934,1); | |
| 508 | - $result['wind_gust'] = round($matches[3]*1.60934,1); | |
| 509 | - $body_parse = substr($body_parse,strlen($matches[0])+1); | |
| 510 | -		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/',$body_parse,$matches)) { | |
| 506 | + $result['wind_speed'] = round($matches[2]*1.60934, 1); | |
| 507 | + $result['wind_gust'] = round($matches[3]*1.60934, 1); | |
| 508 | + $body_parse = substr($body_parse, strlen($matches[0]) + 1); | |
| 509 | +		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/', $body_parse, $matches)) { | |
| 511 | 510 | $result['wind_dir'] = intval($matches[1]); | 
| 512 | - $result['wind_speed'] = round($matches[2]*1.60934,1); | |
| 513 | - $result['wind_gust'] = round($matches[3]*1.60934,1); | |
| 514 | - $body_parse = substr($body_parse,strlen($matches[0])+1); | |
| 511 | + $result['wind_speed'] = round($matches[2]*1.60934, 1); | |
| 512 | + $result['wind_gust'] = round($matches[3]*1.60934, 1); | |
| 513 | + $body_parse = substr($body_parse, strlen($matches[0]) + 1); | |
| 515 | 514 | } | 
| 516 | 515 |  		    //if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/',$body_parse,$matches)) { | 
| 517 | 516 | //g012t088r000p000P000h38b10110 | 
| 518 | 517 | //g011t086r000p000P000h29b10198 | 
| 519 | -		    if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/',$body_parse,$matches)) { | |
| 520 | - if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); | |
| 521 | - if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); | |
| 522 | - if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); | |
| 523 | - if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1); | |
| 524 | - if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1,1); | |
| 518 | +		    if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/', $body_parse, $matches)) { | |
| 519 | + if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1); | |
| 520 | + if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1); | |
| 521 | + if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1); | |
| 522 | + if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1, 1); | |
| 523 | + if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1, 1); | |
| 525 | 524 | if ($matches[6] != '...') $result['humidity'] = intval($matches[6]); | 
| 526 | - if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10),1); | |
| 527 | - $body_parse = substr($body_parse,strlen($matches[0])); | |
| 528 | -		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})P([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/',$body_parse,$matches)) { | |
| 529 | - if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); | |
| 530 | - if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); | |
| 531 | - if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); | |
| 532 | - if ($matches[5] != '...') $result['precipitation'] = round((intval($matches[5])/100)*25.1,1); | |
| 533 | - if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1,1); | |
| 525 | + if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10), 1); | |
| 526 | + $body_parse = substr($body_parse, strlen($matches[0])); | |
| 527 | +		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})P([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/', $body_parse, $matches)) { | |
| 528 | + if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1); | |
| 529 | + if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1); | |
| 530 | + if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1); | |
| 531 | + if ($matches[5] != '...') $result['precipitation'] = round((intval($matches[5])/100)*25.1, 1); | |
| 532 | + if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1, 1); | |
| 534 | 533 | if ($matches[6] != '...') $result['humidity'] = intval($matches[6]); | 
| 535 | - if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10),1); | |
| 536 | - $body_parse = substr($body_parse,strlen($matches[0])); | |
| 537 | -		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) { | |
| 538 | - if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); | |
| 539 | - if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); | |
| 540 | - if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); | |
| 541 | - if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1); | |
| 542 | - if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1,1); | |
| 534 | + if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10), 1); | |
| 535 | + $body_parse = substr($body_parse, strlen($matches[0])); | |
| 536 | +		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/', $body_parse, $matches)) { | |
| 537 | + if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1); | |
| 538 | + if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1); | |
| 539 | + if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1); | |
| 540 | + if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1, 1); | |
| 541 | + if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1, 1); | |
| 543 | 542 | if ($matches[7] != '...') $result['humidity'] = intval($matches[7]); | 
| 544 | - if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10),1); | |
| 545 | - $body_parse = substr($body_parse,strlen($matches[0])); | |
| 546 | -		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) { | |
| 547 | - if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); | |
| 548 | - if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); | |
| 549 | - if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); | |
| 550 | - if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1,1); | |
| 543 | + if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10), 1); | |
| 544 | + $body_parse = substr($body_parse, strlen($matches[0])); | |
| 545 | +		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/', $body_parse, $matches)) { | |
| 546 | + if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1); | |
| 547 | + if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1); | |
| 548 | + if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1); | |
| 549 | + if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1, 1); | |
| 551 | 550 | if ($matches[6] != '...') $result['humidity'] = intval($matches[6]); | 
| 552 | - if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1); | |
| 553 | - $body_parse = substr($body_parse,strlen($matches[0])); | |
| 554 | -		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) { | |
| 555 | - if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); | |
| 556 | - if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); | |
| 557 | - if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); | |
| 558 | - if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1); | |
| 551 | + if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10), 1); | |
| 552 | + $body_parse = substr($body_parse, strlen($matches[0])); | |
| 553 | +		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/', $body_parse, $matches)) { | |
| 554 | + if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1); | |
| 555 | + if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1); | |
| 556 | + if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1); | |
| 557 | + if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1, 1); | |
| 559 | 558 | if ($matches[6] != '...') $result['humidity'] = intval($matches[6]); | 
| 560 | - if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1); | |
| 561 | - $body_parse = substr($body_parse,strlen($matches[0])); | |
| 562 | -		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) { | |
| 563 | - if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); | |
| 564 | - if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); | |
| 565 | - if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); | |
| 566 | - if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1); | |
| 559 | + if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10), 1); | |
| 560 | + $body_parse = substr($body_parse, strlen($matches[0])); | |
| 561 | +		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/', $body_parse, $matches)) { | |
| 562 | + if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1); | |
| 563 | + if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1); | |
| 564 | + if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1); | |
| 565 | + if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1, 1); | |
| 567 | 566 | if ($matches[5] != '...') $result['humidity'] = intval($matches[5]); | 
| 568 | - if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10),1); | |
| 569 | - $body_parse = substr($body_parse,strlen($matches[0])); | |
| 570 | -		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) { | |
| 571 | - if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); | |
| 572 | - if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); | |
| 567 | + if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10), 1); | |
| 568 | + $body_parse = substr($body_parse, strlen($matches[0])); | |
| 569 | +		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/', $body_parse, $matches)) { | |
| 570 | + if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1); | |
| 571 | + if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1); | |
| 573 | 572 | if ($matches[2] != '...') $result['humidity'] = intval($matches[3]); | 
| 574 | - if ($matches[4] != '...') $result['pressure'] = round((intval($matches[4])/10),1); | |
| 575 | - $body_parse = substr($body_parse,strlen($matches[0])); | |
| 576 | -		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{2,3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) { | |
| 577 | - if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); | |
| 578 | - if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); | |
| 579 | - if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); | |
| 573 | + if ($matches[4] != '...') $result['pressure'] = round((intval($matches[4])/10), 1); | |
| 574 | + $body_parse = substr($body_parse, strlen($matches[0])); | |
| 575 | +		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{2,3})h([0-9 \\.]{2})b([0-9 \\.]{5})/', $body_parse, $matches)) { | |
| 576 | + if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1); | |
| 577 | + if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1); | |
| 578 | + if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1); | |
| 580 | 579 | if ($matches[4] != '...') $result['humidity'] = intval($matches[4]); | 
| 581 | - if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1); | |
| 582 | - $body_parse = substr($body_parse,strlen($matches[0])); | |
| 580 | + if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10), 1); | |
| 581 | + $body_parse = substr($body_parse, strlen($matches[0])); | |
| 583 | 582 | } | 
| 584 | 583 | $result['comment'] = trim($body_parse); | 
| 585 | 584 | } | 
| @@ -587,42 +586,42 @@ discard block | ||
| 587 | 586 | |
| 588 | 587 | } | 
| 589 | 588 | //} | 
| 590 | - if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4); | |
| 591 | - if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4); | |
| 589 | + if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'], 4); | |
| 590 | + if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'], 4); | |
| 592 | 591 | if ($debug) print_r($result); | 
| 593 | 592 | return $result; | 
| 594 | 593 | } | 
| 595 | 594 | |
| 596 | 595 |      public function connect() { | 
| 597 | - global $globalAPRSversion, $globalServerAPRSssid, $globalServerAPRSpass,$globalName, $globalServerAPRShost, $globalServerAPRSport; | |
| 596 | + global $globalAPRSversion, $globalServerAPRSssid, $globalServerAPRSpass, $globalName, $globalServerAPRShost, $globalServerAPRSport; | |
| 598 | 597 | $aprs_connect = 0; | 
| 599 | 598 | $aprs_keep = 120; | 
| 600 | 599 | $aprs_last_tx = time(); | 
| 601 | 600 | if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; | 
| 602 | -	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); | |
| 601 | +	else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName); | |
| 603 | 602 | if (isset($globalServerAPRSssid)) $aprs_ssid = $globalServerAPRSssid; | 
| 604 | -	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); | |
| 603 | +	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8); | |
| 605 | 604 | if (isset($globalServerAPRSpass)) $aprs_pass = $globalServerAPRSpass; | 
| 606 | 605 | else $aprs_pass = '-1'; | 
| 607 | 606 | |
| 608 | - $aprs_filter = ''; | |
| 607 | + $aprs_filter = ''; | |
| 609 | 608 |  	$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; | 
| 610 | 609 | $Common = new Common(); | 
| 611 | - $s = $Common->create_socket($globalServerAPRShost,$globalServerAPRSport,$errno,$errstr); | |
| 610 | + $s = $Common->create_socket($globalServerAPRShost, $globalServerAPRSport, $errno, $errstr); | |
| 612 | 611 |  	if ($s !== false) { | 
| 613 | 612 | echo 'Connected to APRS server! '."\n"; | 
| 614 | 613 | $authstart = time(); | 
| 615 | 614 | $this->socket = $s; | 
| 616 | - $send = socket_send( $this->socket , $aprs_login , strlen($aprs_login) , 0 ); | |
| 617 | - socket_set_option($this->socket,SOL_SOCKET,SO_KEEPALIVE,1); | |
| 618 | -		while ($msgin = socket_read($this->socket, 1000,PHP_NORMAL_READ)) { | |
| 615 | + $send = socket_send($this->socket, $aprs_login, strlen($aprs_login), 0); | |
| 616 | + socket_set_option($this->socket, SOL_SOCKET, SO_KEEPALIVE, 1); | |
| 617 | +		while ($msgin = socket_read($this->socket, 1000, PHP_NORMAL_READ)) { | |
| 619 | 618 |  			if (strpos($msgin, "$aprs_ssid verified") !== FALSE) { | 
| 620 | 619 | echo 'APRS user verified !'."\n"; | 
| 621 | 620 | $this->connected = true; | 
| 622 | 621 | return true; | 
| 623 | 622 | break; | 
| 624 | 623 | } | 
| 625 | -			if (time()-$authstart > 5) { | |
| 624 | +			if (time() - $authstart > 5) { | |
| 626 | 625 | echo 'APRS timeout'."\n"; | 
| 627 | 626 | break; | 
| 628 | 627 | } | 
| @@ -637,7 +636,7 @@ discard block | ||
| 637 | 636 |      public function send($data) { | 
| 638 | 637 | global $globalDebug; | 
| 639 | 638 | if ($this->connected === false) $this->connect(); | 
| 640 | - $send = socket_send( $this->socket , $data , strlen($data),0); | |
| 639 | + $send = socket_send($this->socket, $data, strlen($data), 0); | |
| 641 | 640 |  	if ($send === FALSE) { | 
| 642 | 641 | if ($globalDebug) echo 'Reconnect...'; | 
| 643 | 642 | socket_close($this->socket); | 
| @@ -647,16 +646,16 @@ discard block | ||
| 647 | 646 | } | 
| 648 | 647 | |
| 649 | 648 |  class APRSSpotter extends APRS { | 
| 650 | -	public function addLiveSpotterData($id,$ident,$aircraft_icao,$departure_airport,$arrival_airport,$latitude,$longitude,$waypoints,$altitude,$altitude_real,$heading,$speed,$datetime,$departure_airport_time,$arrival_airport_time,$squawk,$route_stop,$hex,$putinarchive,$registration,$pilot_id,$pilot_name, $verticalrate, $noarchive, $ground,$format_source,$source_name,$over_country) { | |
| 649 | +	public function addLiveSpotterData($id, $ident, $aircraft_icao, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $altitude_real, $heading, $speed, $datetime, $departure_airport_time, $arrival_airport_time, $squawk, $route_stop, $hex, $putinarchive, $registration, $pilot_id, $pilot_name, $verticalrate, $noarchive, $ground, $format_source, $source_name, $over_country) { | |
| 651 | 650 | $Common = new Common(); | 
| 652 | 651 |  		if ($latitude != '' && $longitude != '') { | 
| 653 | 652 | $lat = $latitude; | 
| 654 | 653 | $long = $longitude; | 
| 655 | - $latitude = $Common->convertDM($latitude,'latitude'); | |
| 656 | - $longitude = $Common->convertDM($longitude,'longitude'); | |
| 657 | -			$coordinate = sprintf("%02d",$latitude['deg']).str_pad(number_format($latitude['min'],2,'.',''),5,'0',STR_PAD_LEFT).$latitude['NSEW'].'/'.sprintf("%03d",$longitude['deg']).str_pad(number_format($longitude['min'],2,'.',''),5,'0',STR_PAD_LEFT).$longitude['NSEW']; | |
| 658 | - $w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'],2,'.',''))*1000)); | |
| 659 | - $w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'],2,'.',''))*1000)); | |
| 654 | + $latitude = $Common->convertDM($latitude, 'latitude'); | |
| 655 | + $longitude = $Common->convertDM($longitude, 'longitude'); | |
| 656 | +			$coordinate = sprintf("%02d", $latitude['deg']).str_pad(number_format($latitude['min'], 2, '.', ''), 5, '0', STR_PAD_LEFT).$latitude['NSEW'].'/'.sprintf("%03d", $longitude['deg']).str_pad(number_format($longitude['min'], 2, '.', ''), 5, '0', STR_PAD_LEFT).$longitude['NSEW']; | |
| 657 | + $w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'], 2, '.', ''))*1000)); | |
| 658 | + $w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'], 2, '.', ''))*1000)); | |
| 660 | 659 | $w = $w1.$w2; | 
| 661 | 660 | //$w = '00'; | 
| 662 | 661 | $custom = ''; | 
| @@ -683,25 +682,25 @@ discard block | ||
| 683 | 682 | $geoid= round($GeoidClass->get($lat,$long)*3.28084,2); | 
| 684 | 683 | $altitude_real = round($altitude_real + $geoid); | 
| 685 | 684 | */ | 
| 686 | -			$this->send('AIRCRAFT>APRS,TCPIP*:;'.$hex.'   *'.date('His',strtotime($datetime)).'h'.$coordinate.'^'.str_pad($heading,3,'0',STR_PAD_LEFT).'/'.str_pad($speed,3,'0',STR_PAD_LEFT).'/A='.str_pad($altitude_real,6,'0',STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n"); | |
| 685 | +			$this->send('AIRCRAFT>APRS,TCPIP*:;'.$hex.'   *'.date('His', strtotime($datetime)).'h'.$coordinate.'^'.str_pad($heading, 3, '0', STR_PAD_LEFT).'/'.str_pad($speed, 3, '0', STR_PAD_LEFT).'/A='.str_pad($altitude_real, 6, '0', STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n"); | |
| 687 | 686 | } | 
| 688 | 687 | } | 
| 689 | 688 | } | 
| 690 | 689 |  class APRSMarine extends APRS { | 
| 691 | -	public function addLiveMarineData($id, $ident, $latitude, $longitude, $heading, $speed,$datetime, $putinarchive,$mmsi,$type,$typeid,$imo,$callsign,$arrival_code,$arrival_date,$status,$statusid,$noarchive,$format_source,$source_name,$over_country) { | |
| 690 | +	public function addLiveMarineData($id, $ident, $latitude, $longitude, $heading, $speed, $datetime, $putinarchive, $mmsi, $type, $typeid, $imo, $callsign, $arrival_code, $arrival_date, $status, $statusid, $noarchive, $format_source, $source_name, $over_country) { | |
| 692 | 691 | $Common = new Common(); | 
| 693 | 692 |  		if ($latitude != '' && $longitude != '') { | 
| 694 | - $latitude = $Common->convertDM($latitude,'latitude'); | |
| 695 | - $longitude = $Common->convertDM($longitude,'longitude'); | |
| 696 | -			$coordinate = sprintf("%02d",$latitude['deg']).str_pad(number_format($latitude['min'],2,'.',''),5,'0',STR_PAD_LEFT).$latitude['NSEW'].'/'.sprintf("%03d",$longitude['deg']).str_pad(number_format($longitude['min'],2,'.',''),5,'0',STR_PAD_LEFT).$longitude['NSEW']; | |
| 697 | - $w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'],2,'.',''))*1000)); | |
| 698 | - $w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'],2,'.',''))*1000)); | |
| 693 | + $latitude = $Common->convertDM($latitude, 'latitude'); | |
| 694 | + $longitude = $Common->convertDM($longitude, 'longitude'); | |
| 695 | +			$coordinate = sprintf("%02d", $latitude['deg']).str_pad(number_format($latitude['min'], 2, '.', ''), 5, '0', STR_PAD_LEFT).$latitude['NSEW'].'/'.sprintf("%03d", $longitude['deg']).str_pad(number_format($longitude['min'], 2, '.', ''), 5, '0', STR_PAD_LEFT).$longitude['NSEW']; | |
| 696 | + $w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'], 2, '.', ''))*1000)); | |
| 697 | + $w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'], 2, '.', ''))*1000)); | |
| 699 | 698 | $w = $w1.$w2; | 
| 700 | 699 | //$w = '00'; | 
| 701 | 700 | $custom = ''; | 
| 702 | 701 |  			if ($ident != '') { | 
| 703 | 702 | if ($custom != '') $custom .= '/'; | 
| 704 | -				$custom .= 'CS='.str_replace(' ','_',$ident); | |
| 703 | +				$custom .= 'CS='.str_replace(' ', '_', $ident); | |
| 705 | 704 | } | 
| 706 | 705 |  			if ($typeid != '') { | 
| 707 | 706 | if ($custom != '') $custom .= '/'; | 
| @@ -721,11 +720,11 @@ discard block | ||
| 721 | 720 | } | 
| 722 | 721 |  			if ($arrival_code != '') { | 
| 723 | 722 | if ($custom != '') $custom .= '/'; | 
| 724 | -				$custom .= 'AC='.str_replace(' ','_',$arrival_code); | |
| 723 | +				$custom .= 'AC='.str_replace(' ', '_', $arrival_code); | |
| 725 | 724 | } | 
| 726 | 725 | if ($custom != '') $custom = ' '.$custom; | 
| 727 | 726 | $altitude = 0; | 
| 728 | -			$this->send('MARINE>APRS,TCPIP*:;'.$mmsi.'*'.date('His',strtotime($datetime)).'h'.$coordinate.'s'.str_pad($heading,3,'0',STR_PAD_LEFT).'/'.str_pad($speed,3,'0',STR_PAD_LEFT).'/A='.str_pad($altitude,6,'0',STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n"); | |
| 727 | +			$this->send('MARINE>APRS,TCPIP*:;'.$mmsi.'*'.date('His', strtotime($datetime)).'h'.$coordinate.'s'.str_pad($heading, 3, '0', STR_PAD_LEFT).'/'.str_pad($speed, 3, '0', STR_PAD_LEFT).'/A='.str_pad($altitude, 6, '0', STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n"); | |
| 729 | 728 | } | 
| 730 | 729 | } | 
| 731 | 730 | } | 
| @@ -184,17 +184,23 @@ discard block | ||
| 184 | 184 | |
| 185 | 185 | /* Check that end was found and body has at least one byte. */ | 
| 186 | 186 |  	if ($splitpos == 0 || $splitpos + 1 == $input_len || $splitpos === FALSE) { | 
| 187 | - if ($globalDebug) echo '!!! APRS invalid : '.$input."\n"; | |
| 187 | +	    if ($globalDebug) { | |
| 188 | + echo '!!! APRS invalid : '.$input."\n"; | |
| 189 | + } | |
| 188 | 190 | return false; | 
| 189 | 191 | } | 
| 190 | 192 | |
| 191 | - if ($debug) echo 'input : '.$input."\n"; | |
| 193 | +	if ($debug) { | |
| 194 | + echo 'input : '.$input."\n"; | |
| 195 | + } | |
| 192 | 196 | /* Save header and body. */ | 
| 193 | 197 | $body = substr($input,$splitpos+1,$input_len); | 
| 194 | 198 | $body_len = strlen($body); | 
| 195 | 199 | $header = substr($input,0,$splitpos); | 
| 196 | 200 | //$header_len = strlen($header); | 
| 197 | - if ($debug) echo 'header : '.$header."\n"; | |
| 201 | +	if ($debug) { | |
| 202 | + echo 'header : '.$header."\n"; | |
| 203 | + } | |
| 198 | 204 | |
| 199 | 205 | /* Parse source, target and path. */ | 
| 200 | 206 | //FLRDF0A52>APRS,qAS,LSTB | 
| @@ -208,11 +214,15 @@ discard block | ||
| 208 | 214 | $result['format_source'] = 'famaprs'; | 
| 209 | 215 | $result['source_type'] = 'ais'; | 
| 210 | 216 |  	    } else { | 
| 211 | - if ($debug) echo 'ident : '.$ident."\n"; | |
| 217 | +		if ($debug) { | |
| 218 | + echo 'ident : '.$ident."\n"; | |
| 219 | + } | |
| 212 | 220 | $result['ident'] = $ident; | 
| 213 | 221 | } | 
| 214 | 222 |  	} else { | 
| 215 | - if ($debug) 'No ident'."\n"; | |
| 223 | +	    if ($debug) { | |
| 224 | + 'No ident'."\n"; | |
| 225 | + } | |
| 216 | 226 | return false; | 
| 217 | 227 | } | 
| 218 | 228 |  	$elements = explode(',',$all_elements); | 
| @@ -223,7 +233,9 @@ discard block | ||
| 223 | 233 | //echo "ok"; | 
| 224 | 234 | //if ($element == 'TCPIP*') return false; | 
| 225 | 235 |  	    } elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) { | 
| 226 | - if ($debug) echo 'element : '.$element."\n"; | |
| 236 | +		if ($debug) { | |
| 237 | + echo 'element : '.$element."\n"; | |
| 238 | + } | |
| 227 | 239 | return false; | 
| 228 | 240 | } | 
| 229 | 241 | /* | 
| @@ -236,13 +248,17 @@ discard block | ||
| 236 | 248 | } | 
| 237 | 249 | |
| 238 | 250 | $type = substr($body,0,1); | 
| 239 | - if ($debug) echo 'type : '.$type."\n"; | |
| 251 | +	if ($debug) { | |
| 252 | + echo 'type : '.$type."\n"; | |
| 253 | + } | |
| 240 | 254 |  	if ($type == ';') { | 
| 241 | 255 |  		if (isset($result['source_type']) && $result['source_type'] == 'modes') { | 
| 242 | 256 | $result['address'] = trim(substr($body,1,9)); | 
| 243 | 257 |  		} elseif (isset($result['source_type']) && $result['source_type'] == 'ais') { | 
| 244 | 258 | $result['mmsi'] = trim(substr($body,1,9)); | 
| 245 | - } else $result['ident'] = trim(substr($body,1,9)); | |
| 259 | +		} else { | |
| 260 | + $result['ident'] = trim(substr($body,1,9)); | |
| 261 | + } | |
| 246 | 262 |  	} elseif ($type == ',') { | 
| 247 | 263 | // Invalid data or test data | 
| 248 | 264 | return false; | 
| @@ -311,7 +327,9 @@ discard block | ||
| 311 | 327 | //$symbol_table = $matches[4]; | 
| 312 | 328 | $lat = intval($lat_deg); | 
| 313 | 329 | $lon = intval($lon_deg); | 
| 314 | - if ($lat > 89 || $lon > 179) return false; | |
| 330 | +		if ($lat > 89 || $lon > 179) { | |
| 331 | + return false; | |
| 332 | + } | |
| 315 | 333 | |
| 316 | 334 | /* | 
| 317 | 335 |  	    $tmp_5b = str_replace('.','',$lat_min); | 
| @@ -321,8 +339,12 @@ discard block | ||
| 321 | 339 | */ | 
| 322 | 340 | $latitude = $lat + floatval($lat_min)/60; | 
| 323 | 341 | $longitude = $lon + floatval($lon_min)/60; | 
| 324 | - if ($sind == 'S') $latitude = 0-$latitude; | |
| 325 | - if ($wind == 'W') $longitude = 0-$longitude; | |
| 342 | +		if ($sind == 'S') { | |
| 343 | + $latitude = 0-$latitude; | |
| 344 | + } | |
| 345 | +		if ($wind == 'W') { | |
| 346 | + $longitude = 0-$longitude; | |
| 347 | + } | |
| 326 | 348 | $result['latitude'] = $latitude; | 
| 327 | 349 | $result['longitude'] = $longitude; | 
| 328 | 350 | $body_parse = substr($body_parse,18); | 
| @@ -350,8 +372,11 @@ discard block | ||
| 350 | 372 | //echo 'find'."\n"; | 
| 351 | 373 | $body_split = str_split($body_parse); | 
| 352 | 374 | $symbol_code = $body_split[0]; | 
| 353 | - if (!isset($symbolll) || $symbolll == '/') $symbol_code = '/'.$symbol_code; | |
| 354 | - else $symbol_code = '\\'.$symbol_code; | |
| 375 | +			if (!isset($symbolll) || $symbolll == '/') { | |
| 376 | + $symbol_code = '/'.$symbol_code; | |
| 377 | +			} else { | |
| 378 | + $symbol_code = '\\'.$symbol_code; | |
| 379 | + } | |
| 355 | 380 | //' | 
| 356 | 381 | //} | 
| 357 | 382 | //echo $body_parse; | 
| @@ -360,7 +385,9 @@ discard block | ||
| 360 | 385 | $body_parse = substr($body_parse,1); | 
| 361 | 386 | $body_parse_len = strlen($body_parse); | 
| 362 | 387 | $result['symbol_code'] = $symbol_code; | 
| 363 | - if (isset($this->symbols[$symbol_code])) $result['symbol'] = $this->symbols[$symbol_code]; | |
| 388 | +			if (isset($this->symbols[$symbol_code])) { | |
| 389 | + $result['symbol'] = $this->symbols[$symbol_code]; | |
| 390 | + } | |
| 364 | 391 |  			if ($symbol_code != '_') { | 
| 365 | 392 | } | 
| 366 | 393 | //$body_parse = substr($body_parse,1); | 
| @@ -371,7 +398,9 @@ discard block | ||
| 371 | 398 |  		        if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) { | 
| 372 | 399 | $course = substr($body_parse,0,3); | 
| 373 | 400 | $tmp_s = intval($course); | 
| 374 | - if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course); | |
| 401 | +		    	    if ($tmp_s >= 1 && $tmp_s <= 360) { | |
| 402 | + $result['heading'] = intval($course); | |
| 403 | + } | |
| 375 | 404 | $speed = substr($body_parse,4,3); | 
| 376 | 405 |  		    	    if ($speed != '...') { | 
| 377 | 406 | //$result['speed'] = round($speed*1.852); | 
| @@ -412,10 +441,16 @@ discard block | ||
| 412 | 441 | $lat_off = (($dao_split[1])-48.0)*0.001/60.0; | 
| 413 | 442 | $lon_off = (($dao_split[2])-48.0)*0.001/60.0; | 
| 414 | 443 | |
| 415 | - if ($result['latitude'] < 0) $result['latitude'] -= $lat_off; | |
| 416 | - else $result['latitude'] += $lat_off; | |
| 417 | - if ($result['longitude'] < 0) $result['longitude'] -= $lon_off; | |
| 418 | - else $result['longitude'] += $lon_off; | |
| 444 | +				if ($result['latitude'] < 0) { | |
| 445 | + $result['latitude'] -= $lat_off; | |
| 446 | +				} else { | |
| 447 | + $result['latitude'] += $lat_off; | |
| 448 | + } | |
| 449 | +				if ($result['longitude'] < 0) { | |
| 450 | + $result['longitude'] -= $lon_off; | |
| 451 | +				} else { | |
| 452 | + $result['longitude'] += $lon_off; | |
| 453 | + } | |
| 419 | 454 | } | 
| 420 | 455 | |
| 421 | 456 | $body_parse = substr($body_parse,6); | 
| @@ -457,27 +492,48 @@ discard block | ||
| 457 | 492 | $address = substr($id,2); | 
| 458 | 493 | //print_r($matches); | 
| 459 | 494 | $addressType = (intval(substr($id,0,2),16))&3; | 
| 460 | - if ($addressType == 0) $result['addresstype'] = "RANDOM"; | |
| 461 | - elseif ($addressType == 1) $result['addresstype'] = "ICAO"; | |
| 462 | - elseif ($addressType == 2) $result['addresstype'] = "FLARM"; | |
| 463 | - elseif ($addressType == 3) $result['addresstype'] = "OGN"; | |
| 495 | +			if ($addressType == 0) { | |
| 496 | + $result['addresstype'] = "RANDOM"; | |
| 497 | +			} elseif ($addressType == 1) { | |
| 498 | + $result['addresstype'] = "ICAO"; | |
| 499 | +			} elseif ($addressType == 2) { | |
| 500 | + $result['addresstype'] = "FLARM"; | |
| 501 | +			} elseif ($addressType == 3) { | |
| 502 | + $result['addresstype'] = "OGN"; | |
| 503 | + } | |
| 464 | 504 | $aircraftType = $this->urshift(((intval(substr($id,0,2),16)) & 0b1111100),2); | 
| 465 | 505 | $result['aircrafttype_code'] = $aircraftType; | 
| 466 | - if ($aircraftType == 0) $result['aircrafttype'] = "UNKNOWN"; | |
| 467 | - elseif ($aircraftType == 1) $result['aircrafttype'] = "GLIDER"; | |
| 468 | - elseif ($aircraftType == 2) $result['aircrafttype'] = "TOW_PLANE"; | |
| 469 | - elseif ($aircraftType == 3) $result['aircrafttype'] = "HELICOPTER_ROTORCRAFT"; | |
| 470 | - elseif ($aircraftType == 4) $result['aircrafttype'] = "PARACHUTE"; | |
| 471 | - elseif ($aircraftType == 5) $result['aircrafttype'] = "DROP_PLANE"; | |
| 472 | - elseif ($aircraftType == 6) $result['aircrafttype'] = "HANG_GLIDER"; | |
| 473 | - elseif ($aircraftType == 7) $result['aircrafttype'] = "PARA_GLIDER"; | |
| 474 | - elseif ($aircraftType == 8) $result['aircrafttype'] = "POWERED_AIRCRAFT"; | |
| 475 | - elseif ($aircraftType == 9) $result['aircrafttype'] = "JET_AIRCRAFT"; | |
| 476 | - elseif ($aircraftType == 10) $result['aircrafttype'] = "UFO"; | |
| 477 | - elseif ($aircraftType == 11) $result['aircrafttype'] = "BALLOON"; | |
| 478 | - elseif ($aircraftType == 12) $result['aircrafttype'] = "AIRSHIP"; | |
| 479 | - elseif ($aircraftType == 13) $result['aircrafttype'] = "UAV"; | |
| 480 | - elseif ($aircraftType == 15) $result['aircrafttype'] = "STATIC_OBJECT"; | |
| 506 | +			if ($aircraftType == 0) { | |
| 507 | + $result['aircrafttype'] = "UNKNOWN"; | |
| 508 | +			} elseif ($aircraftType == 1) { | |
| 509 | + $result['aircrafttype'] = "GLIDER"; | |
| 510 | +			} elseif ($aircraftType == 2) { | |
| 511 | + $result['aircrafttype'] = "TOW_PLANE"; | |
| 512 | +			} elseif ($aircraftType == 3) { | |
| 513 | + $result['aircrafttype'] = "HELICOPTER_ROTORCRAFT"; | |
| 514 | +			} elseif ($aircraftType == 4) { | |
| 515 | + $result['aircrafttype'] = "PARACHUTE"; | |
| 516 | +			} elseif ($aircraftType == 5) { | |
| 517 | + $result['aircrafttype'] = "DROP_PLANE"; | |
| 518 | +			} elseif ($aircraftType == 6) { | |
| 519 | + $result['aircrafttype'] = "HANG_GLIDER"; | |
| 520 | +			} elseif ($aircraftType == 7) { | |
| 521 | + $result['aircrafttype'] = "PARA_GLIDER"; | |
| 522 | +			} elseif ($aircraftType == 8) { | |
| 523 | + $result['aircrafttype'] = "POWERED_AIRCRAFT"; | |
| 524 | +			} elseif ($aircraftType == 9) { | |
| 525 | + $result['aircrafttype'] = "JET_AIRCRAFT"; | |
| 526 | +			} elseif ($aircraftType == 10) { | |
| 527 | + $result['aircrafttype'] = "UFO"; | |
| 528 | +			} elseif ($aircraftType == 11) { | |
| 529 | + $result['aircrafttype'] = "BALLOON"; | |
| 530 | +			} elseif ($aircraftType == 12) { | |
| 531 | + $result['aircrafttype'] = "AIRSHIP"; | |
| 532 | +			} elseif ($aircraftType == 13) { | |
| 533 | + $result['aircrafttype'] = "UAV"; | |
| 534 | +			} elseif ($aircraftType == 15) { | |
| 535 | + $result['aircrafttype'] = "STATIC_OBJECT"; | |
| 536 | + } | |
| 481 | 537 | $stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0; | 
| 482 | 538 | $result['stealth'] = $stealth; | 
| 483 | 539 | $result['address'] = $address; | 
| @@ -517,79 +573,183 @@ discard block | ||
| 517 | 573 | //g012t088r000p000P000h38b10110 | 
| 518 | 574 | //g011t086r000p000P000h29b10198 | 
| 519 | 575 |  		    if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/',$body_parse,$matches)) { | 
| 520 | - if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); | |
| 521 | - if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); | |
| 522 | - if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); | |
| 523 | - if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1); | |
| 524 | - if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1,1); | |
| 525 | - if ($matches[6] != '...') $result['humidity'] = intval($matches[6]); | |
| 526 | - if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10),1); | |
| 576 | +			if ($matches[1] != '...') { | |
| 577 | + $result['wind_gust'] = round($matches[1]*1.60934,1); | |
| 578 | + } | |
| 579 | +			if ($matches[2] != '...') { | |
| 580 | + $result['temp'] = round(5/9*((intval($matches[2]))-32),1); | |
| 581 | + } | |
| 582 | +			if ($matches[3] != '...') { | |
| 583 | + $result['rain'] = round((intval($matches[3])/100)*25.1,1); | |
| 584 | + } | |
| 585 | +			if ($matches[4] != '...') { | |
| 586 | + $result['precipitation'] = round((intval($matches[4])/100)*25.1,1); | |
| 587 | + } | |
| 588 | +			if ($matches[5] != '...') { | |
| 589 | + $result['precipitation24h'] = round((intval($matches[5])/100)*25.1,1); | |
| 590 | + } | |
| 591 | +			if ($matches[6] != '...') { | |
| 592 | + $result['humidity'] = intval($matches[6]); | |
| 593 | + } | |
| 594 | +			if ($matches[7] != '...') { | |
| 595 | + $result['pressure'] = round((intval($matches[7])/10),1); | |
| 596 | + } | |
| 527 | 597 | $body_parse = substr($body_parse,strlen($matches[0])); | 
| 528 | 598 |  		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})P([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/',$body_parse,$matches)) { | 
| 529 | - if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); | |
| 530 | - if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); | |
| 531 | - if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); | |
| 532 | - if ($matches[5] != '...') $result['precipitation'] = round((intval($matches[5])/100)*25.1,1); | |
| 533 | - if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1,1); | |
| 534 | - if ($matches[6] != '...') $result['humidity'] = intval($matches[6]); | |
| 535 | - if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10),1); | |
| 599 | +			if ($matches[1] != '...') { | |
| 600 | + $result['wind_gust'] = round($matches[1]*1.60934,1); | |
| 601 | + } | |
| 602 | +			if ($matches[2] != '...') { | |
| 603 | + $result['temp'] = round(5/9*((intval($matches[2]))-32),1); | |
| 604 | + } | |
| 605 | +			if ($matches[3] != '...') { | |
| 606 | + $result['rain'] = round((intval($matches[3])/100)*25.1,1); | |
| 607 | + } | |
| 608 | +			if ($matches[5] != '...') { | |
| 609 | + $result['precipitation'] = round((intval($matches[5])/100)*25.1,1); | |
| 610 | + } | |
| 611 | +			if ($matches[4] != '...') { | |
| 612 | + $result['precipitation24h'] = round((intval($matches[4])/100)*25.1,1); | |
| 613 | + } | |
| 614 | +			if ($matches[6] != '...') { | |
| 615 | + $result['humidity'] = intval($matches[6]); | |
| 616 | + } | |
| 617 | +			if ($matches[7] != '...') { | |
| 618 | + $result['pressure'] = round((intval($matches[7])/10),1); | |
| 619 | + } | |
| 536 | 620 | $body_parse = substr($body_parse,strlen($matches[0])); | 
| 537 | 621 |  		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) { | 
| 538 | - if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); | |
| 539 | - if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); | |
| 540 | - if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); | |
| 541 | - if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1); | |
| 542 | - if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1,1); | |
| 543 | - if ($matches[7] != '...') $result['humidity'] = intval($matches[7]); | |
| 544 | - if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10),1); | |
| 622 | +			if ($matches[1] != '...') { | |
| 623 | + $result['wind_gust'] = round($matches[1]*1.60934,1); | |
| 624 | + } | |
| 625 | +			if ($matches[2] != '...') { | |
| 626 | + $result['temp'] = round(5/9*((intval($matches[2]))-32),1); | |
| 627 | + } | |
| 628 | +			if ($matches[3] != '...') { | |
| 629 | + $result['rain'] = round((intval($matches[3])/100)*25.1,1); | |
| 630 | + } | |
| 631 | +			if ($matches[4] != '...') { | |
| 632 | + $result['precipitation'] = round((intval($matches[4])/100)*25.1,1); | |
| 633 | + } | |
| 634 | +			if ($matches[5] != '...') { | |
| 635 | + $result['precipitation24h'] = round((intval($matches[5])/100)*25.1,1); | |
| 636 | + } | |
| 637 | +			if ($matches[7] != '...') { | |
| 638 | + $result['humidity'] = intval($matches[7]); | |
| 639 | + } | |
| 640 | +			if ($matches[6] != '...') { | |
| 641 | + $result['pressure'] = round((intval($matches[6])/10),1); | |
| 642 | + } | |
| 545 | 643 | $body_parse = substr($body_parse,strlen($matches[0])); | 
| 546 | 644 |  		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) { | 
| 547 | - if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); | |
| 548 | - if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); | |
| 549 | - if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); | |
| 550 | - if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1,1); | |
| 551 | - if ($matches[6] != '...') $result['humidity'] = intval($matches[6]); | |
| 552 | - if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1); | |
| 645 | +			if ($matches[1] != '...') { | |
| 646 | + $result['wind_gust'] = round($matches[1]*1.60934,1); | |
| 647 | + } | |
| 648 | +			if ($matches[2] != '...') { | |
| 649 | + $result['temp'] = round(5/9*((intval($matches[2]))-32),1); | |
| 650 | + } | |
| 651 | +			if ($matches[3] != '...') { | |
| 652 | + $result['rain'] = round((intval($matches[3])/100)*25.1,1); | |
| 653 | + } | |
| 654 | +			if ($matches[4] != '...') { | |
| 655 | + $result['precipitation24h'] = round((intval($matches[4])/100)*25.1,1); | |
| 656 | + } | |
| 657 | +			if ($matches[6] != '...') { | |
| 658 | + $result['humidity'] = intval($matches[6]); | |
| 659 | + } | |
| 660 | +			if ($matches[5] != '...') { | |
| 661 | + $result['pressure'] = round((intval($matches[5])/10),1); | |
| 662 | + } | |
| 553 | 663 | $body_parse = substr($body_parse,strlen($matches[0])); | 
| 554 | 664 |  		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) { | 
| 555 | - if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); | |
| 556 | - if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); | |
| 557 | - if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); | |
| 558 | - if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1); | |
| 559 | - if ($matches[6] != '...') $result['humidity'] = intval($matches[6]); | |
| 560 | - if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1); | |
| 665 | +			if ($matches[1] != '...') { | |
| 666 | + $result['wind_gust'] = round($matches[1]*1.60934,1); | |
| 667 | + } | |
| 668 | +			if ($matches[2] != '...') { | |
| 669 | + $result['temp'] = round(5/9*((intval($matches[2]))-32),1); | |
| 670 | + } | |
| 671 | +			if ($matches[3] != '...') { | |
| 672 | + $result['rain'] = round((intval($matches[3])/100)*25.1,1); | |
| 673 | + } | |
| 674 | +			if ($matches[4] != '...') { | |
| 675 | + $result['precipitation'] = round((intval($matches[4])/100)*25.1,1); | |
| 676 | + } | |
| 677 | +			if ($matches[6] != '...') { | |
| 678 | + $result['humidity'] = intval($matches[6]); | |
| 679 | + } | |
| 680 | +			if ($matches[5] != '...') { | |
| 681 | + $result['pressure'] = round((intval($matches[5])/10),1); | |
| 682 | + } | |
| 561 | 683 | $body_parse = substr($body_parse,strlen($matches[0])); | 
| 562 | 684 |  		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) { | 
| 563 | - if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); | |
| 564 | - if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); | |
| 565 | - if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); | |
| 566 | - if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1); | |
| 567 | - if ($matches[5] != '...') $result['humidity'] = intval($matches[5]); | |
| 568 | - if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10),1); | |
| 685 | +			if ($matches[1] != '...') { | |
| 686 | + $result['wind_gust'] = round($matches[1]*1.60934,1); | |
| 687 | + } | |
| 688 | +			if ($matches[2] != '...') { | |
| 689 | + $result['temp'] = round(5/9*((intval($matches[2]))-32),1); | |
| 690 | + } | |
| 691 | +			if ($matches[3] != '...') { | |
| 692 | + $result['rain'] = round((intval($matches[3])/100)*25.1,1); | |
| 693 | + } | |
| 694 | +			if ($matches[4] != '...') { | |
| 695 | + $result['precipitation'] = round((intval($matches[4])/100)*25.1,1); | |
| 696 | + } | |
| 697 | +			if ($matches[5] != '...') { | |
| 698 | + $result['humidity'] = intval($matches[5]); | |
| 699 | + } | |
| 700 | +			if ($matches[6] != '...') { | |
| 701 | + $result['pressure'] = round((intval($matches[6])/10),1); | |
| 702 | + } | |
| 569 | 703 | $body_parse = substr($body_parse,strlen($matches[0])); | 
| 570 | 704 |  		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) { | 
| 571 | - if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); | |
| 572 | - if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); | |
| 573 | - if ($matches[2] != '...') $result['humidity'] = intval($matches[3]); | |
| 574 | - if ($matches[4] != '...') $result['pressure'] = round((intval($matches[4])/10),1); | |
| 705 | +			if ($matches[1] != '...') { | |
| 706 | + $result['wind_gust'] = round($matches[1]*1.60934,1); | |
| 707 | + } | |
| 708 | +			if ($matches[2] != '...') { | |
| 709 | + $result['temp'] = round(5/9*((intval($matches[2]))-32),1); | |
| 710 | + } | |
| 711 | +			if ($matches[2] != '...') { | |
| 712 | + $result['humidity'] = intval($matches[3]); | |
| 713 | + } | |
| 714 | +			if ($matches[4] != '...') { | |
| 715 | + $result['pressure'] = round((intval($matches[4])/10),1); | |
| 716 | + } | |
| 575 | 717 | $body_parse = substr($body_parse,strlen($matches[0])); | 
| 576 | 718 |  		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{2,3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) { | 
| 577 | - if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); | |
| 578 | - if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); | |
| 579 | - if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); | |
| 580 | - if ($matches[4] != '...') $result['humidity'] = intval($matches[4]); | |
| 581 | - if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1); | |
| 719 | +			if ($matches[1] != '...') { | |
| 720 | + $result['wind_gust'] = round($matches[1]*1.60934,1); | |
| 721 | + } | |
| 722 | +			if ($matches[2] != '...') { | |
| 723 | + $result['temp'] = round(5/9*((intval($matches[2]))-32),1); | |
| 724 | + } | |
| 725 | +			if ($matches[3] != '...') { | |
| 726 | + $result['rain'] = round((intval($matches[3])/100)*25.1,1); | |
| 727 | + } | |
| 728 | +			if ($matches[4] != '...') { | |
| 729 | + $result['humidity'] = intval($matches[4]); | |
| 730 | + } | |
| 731 | +			if ($matches[5] != '...') { | |
| 732 | + $result['pressure'] = round((intval($matches[5])/10),1); | |
| 733 | + } | |
| 582 | 734 | $body_parse = substr($body_parse,strlen($matches[0])); | 
| 583 | 735 | } | 
| 584 | 736 | $result['comment'] = trim($body_parse); | 
| 585 | 737 | } | 
| 586 | - } else $result['comment'] = trim($body_parse); | |
| 738 | +		} else { | |
| 739 | + $result['comment'] = trim($body_parse); | |
| 740 | + } | |
| 587 | 741 | |
| 588 | 742 | } | 
| 589 | 743 | //} | 
| 590 | - if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4); | |
| 591 | - if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4); | |
| 592 | - if ($debug) print_r($result); | |
| 744 | +	if (isset($result['latitude'])) { | |
| 745 | + $result['latitude'] = round($result['latitude'],4); | |
| 746 | + } | |
| 747 | +	if (isset($result['longitude'])) { | |
| 748 | + $result['longitude'] = round($result['longitude'],4); | |
| 749 | + } | |
| 750 | +	if ($debug) { | |
| 751 | + print_r($result); | |
| 752 | + } | |
| 593 | 753 | return $result; | 
| 594 | 754 | } | 
| 595 | 755 | |
| @@ -598,12 +758,21 @@ discard block | ||
| 598 | 758 | $aprs_connect = 0; | 
| 599 | 759 | $aprs_keep = 120; | 
| 600 | 760 | $aprs_last_tx = time(); | 
| 601 | - if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; | |
| 602 | -	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); | |
| 603 | - if (isset($globalServerAPRSssid)) $aprs_ssid = $globalServerAPRSssid; | |
| 604 | -	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); | |
| 605 | - if (isset($globalServerAPRSpass)) $aprs_pass = $globalServerAPRSpass; | |
| 606 | - else $aprs_pass = '-1'; | |
| 761 | +	if (isset($globalAPRSversion)) { | |
| 762 | + $aprs_version = $globalAPRSversion; | |
| 763 | +	} else { | |
| 764 | +		$aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); | |
| 765 | + } | |
| 766 | +	if (isset($globalServerAPRSssid)) { | |
| 767 | + $aprs_ssid = $globalServerAPRSssid; | |
| 768 | +	} else { | |
| 769 | +		$aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); | |
| 770 | + } | |
| 771 | +	if (isset($globalServerAPRSpass)) { | |
| 772 | + $aprs_pass = $globalServerAPRSpass; | |
| 773 | +	} else { | |
| 774 | + $aprs_pass = '-1'; | |
| 775 | + } | |
| 607 | 776 | |
| 608 | 777 | $aprs_filter = ''; | 
| 609 | 778 |  	$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; | 
| @@ -636,10 +805,14 @@ discard block | ||
| 636 | 805 | |
| 637 | 806 |      public function send($data) { | 
| 638 | 807 | global $globalDebug; | 
| 639 | - if ($this->connected === false) $this->connect(); | |
| 808 | +	if ($this->connected === false) { | |
| 809 | + $this->connect(); | |
| 810 | + } | |
| 640 | 811 | $send = socket_send( $this->socket , $data , strlen($data),0); | 
| 641 | 812 |  	if ($send === FALSE) { | 
| 642 | - if ($globalDebug) echo 'Reconnect...'; | |
| 813 | +		if ($globalDebug) { | |
| 814 | + echo 'Reconnect...'; | |
| 815 | + } | |
| 643 | 816 | socket_close($this->socket); | 
| 644 | 817 | $this->connect(); | 
| 645 | 818 | } | 
| @@ -661,22 +834,32 @@ discard block | ||
| 661 | 834 | //$w = '00'; | 
| 662 | 835 | $custom = ''; | 
| 663 | 836 |  			if ($ident != '') { | 
| 664 | - if ($custom != '') $custom .= '/'; | |
| 837 | +				if ($custom != '') { | |
| 838 | + $custom .= '/'; | |
| 839 | + } | |
| 665 | 840 | $custom .= 'CS='.$ident; | 
| 666 | 841 | } | 
| 667 | 842 |  			if ($squawk != '') { | 
| 668 | - if ($custom != '') $custom .= '/'; | |
| 843 | +				if ($custom != '') { | |
| 844 | + $custom .= '/'; | |
| 845 | + } | |
| 669 | 846 | $custom .= 'SQ='.$squawk; | 
| 670 | 847 | } | 
| 671 | 848 |  			if ($verticalrate != '') { | 
| 672 | - if ($custom != '') $custom .= '/'; | |
| 849 | +				if ($custom != '') { | |
| 850 | + $custom .= '/'; | |
| 851 | + } | |
| 673 | 852 | $custom .= 'VR='.$verticalrate; | 
| 674 | 853 | } | 
| 675 | 854 |  			if ($aircraft_icao != '' && $aircraft_icao != 'NA') { | 
| 676 | - if ($custom != '') $custom .= '/'; | |
| 855 | +				if ($custom != '') { | |
| 856 | + $custom .= '/'; | |
| 857 | + } | |
| 677 | 858 | $custom .= 'AI='.$aircraft_icao; | 
| 678 | 859 | } | 
| 679 | - if ($custom != '') $custom = ' '.$custom; | |
| 860 | +			if ($custom != '') { | |
| 861 | + $custom = ' '.$custom; | |
| 862 | + } | |
| 680 | 863 | /* | 
| 681 | 864 | // Use AMSL altitude | 
| 682 | 865 | $GeoidClass = new GeoidHeight(); | 
| @@ -700,30 +883,44 @@ discard block | ||
| 700 | 883 | //$w = '00'; | 
| 701 | 884 | $custom = ''; | 
| 702 | 885 |  			if ($ident != '') { | 
| 703 | - if ($custom != '') $custom .= '/'; | |
| 886 | +				if ($custom != '') { | |
| 887 | + $custom .= '/'; | |
| 888 | + } | |
| 704 | 889 |  				$custom .= 'CS='.str_replace(' ','_',$ident); | 
| 705 | 890 | } | 
| 706 | 891 |  			if ($typeid != '') { | 
| 707 | - if ($custom != '') $custom .= '/'; | |
| 892 | +				if ($custom != '') { | |
| 893 | + $custom .= '/'; | |
| 894 | + } | |
| 708 | 895 | $custom .= 'TI='.$typeid; | 
| 709 | 896 | } | 
| 710 | 897 |  			if ($statusid != '') { | 
| 711 | - if ($custom != '') $custom .= '/'; | |
| 898 | +				if ($custom != '') { | |
| 899 | + $custom .= '/'; | |
| 900 | + } | |
| 712 | 901 | $custom .= 'SI='.$statusid; | 
| 713 | 902 | } | 
| 714 | 903 |  			if ($imo != '') { | 
| 715 | - if ($custom != '') $custom .= '/'; | |
| 904 | +				if ($custom != '') { | |
| 905 | + $custom .= '/'; | |
| 906 | + } | |
| 716 | 907 | $custom .= 'IMO='.$imo; | 
| 717 | 908 | } | 
| 718 | 909 |  			if ($arrival_date != '') { | 
| 719 | - if ($custom != '') $custom .= '/'; | |
| 910 | +				if ($custom != '') { | |
| 911 | + $custom .= '/'; | |
| 912 | + } | |
| 720 | 913 | $custom .= 'AD='.strtotime($arrival_date); | 
| 721 | 914 | } | 
| 722 | 915 |  			if ($arrival_code != '') { | 
| 723 | - if ($custom != '') $custom .= '/'; | |
| 916 | +				if ($custom != '') { | |
| 917 | + $custom .= '/'; | |
| 918 | + } | |
| 724 | 919 |  				$custom .= 'AC='.str_replace(' ','_',$arrival_code); | 
| 725 | 920 | } | 
| 726 | - if ($custom != '') $custom = ' '.$custom; | |
| 921 | +			if ($custom != '') { | |
| 922 | + $custom = ' '.$custom; | |
| 923 | + } | |
| 727 | 924 | $altitude = 0; | 
| 728 | 925 |  			$this->send('MARINE>APRS,TCPIP*:;'.$mmsi.'*'.date('His',strtotime($datetime)).'h'.$coordinate.'s'.str_pad($heading,3,'0',STR_PAD_LEFT).'/'.str_pad($speed,3,'0',STR_PAD_LEFT).'/A='.str_pad($altitude,6,'0',STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n"); | 
| 729 | 926 | } |