@@ -15,8 +15,8 @@ discard block |
||
| 15 | 15 | require_once(dirname(__FILE__).'/../require/class.Common.php'); |
| 16 | 16 | if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
| 17 | 17 | if (isset($globalMarine) && $globalMarine) { |
| 18 | - require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
|
| 19 | - require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
|
| 18 | + require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
|
| 19 | + require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | if (!isset($globalDebug)) $globalDebug = FALSE; |
@@ -24,40 +24,40 @@ discard block |
||
| 24 | 24 | // Check if schema is at latest version |
| 25 | 25 | $Connection = new Connection(); |
| 26 | 26 | if ($Connection->latest() === false) { |
| 27 | - echo "You MUST update to latest schema. Run install/index.php"; |
|
| 28 | - exit(); |
|
| 27 | + echo "You MUST update to latest schema. Run install/index.php"; |
|
| 28 | + exit(); |
|
| 29 | 29 | } |
| 30 | 30 | if (PHP_SAPI != 'cli') { |
| 31 | - echo "This script MUST be called from console, not a web browser."; |
|
| 31 | + echo "This script MUST be called from console, not a web browser."; |
|
| 32 | 32 | // exit(); |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | // This is to be compatible with old version of settings.php |
| 36 | 36 | if (!isset($globalSources)) { |
| 37 | - if (isset($globalSBS1Hosts)) { |
|
| 38 | - //$hosts = $globalSBS1Hosts; |
|
| 39 | - foreach ($globalSBS1Hosts as $host) { |
|
| 40 | - $globalSources[] = array('host' => $host); |
|
| 41 | - } |
|
| 42 | - } else { |
|
| 43 | - if (!isset($globalSBS1Host)) { |
|
| 44 | - echo '$globalSources MUST be defined !'; |
|
| 45 | - die; |
|
| 37 | + if (isset($globalSBS1Hosts)) { |
|
| 38 | + //$hosts = $globalSBS1Hosts; |
|
| 39 | + foreach ($globalSBS1Hosts as $host) { |
|
| 40 | + $globalSources[] = array('host' => $host); |
|
| 41 | + } |
|
| 42 | + } else { |
|
| 43 | + if (!isset($globalSBS1Host)) { |
|
| 44 | + echo '$globalSources MUST be defined !'; |
|
| 45 | + die; |
|
| 46 | 46 | } |
| 47 | 47 | //$hosts = array($globalSBS1Host.':'.$globalSBS1Port); |
| 48 | 48 | $globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port); |
| 49 | - } |
|
| 49 | + } |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | $options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::')); |
| 53 | 53 | //if (isset($options['s'])) $hosts = array($options['s']); |
| 54 | 54 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
| 55 | 55 | if (isset($options['s'])) { |
| 56 | - $globalSources = array(); |
|
| 57 | - $globalSources[] = array('host' => $options['s']); |
|
| 56 | + $globalSources = array(); |
|
| 57 | + $globalSources[] = array('host' => $options['s']); |
|
| 58 | 58 | } elseif (isset($options['source'])) { |
| 59 | - $globalSources = array(); |
|
| 60 | - $globalSources[] = array('host' => $options['source']); |
|
| 59 | + $globalSources = array(); |
|
| 60 | + $globalSources[] = array('host' => $options['source']); |
|
| 61 | 61 | } |
| 62 | 62 | if (isset($options['aprsserverssid'])) $globalServerAPRSssid = $options['aprsserverssid']; |
| 63 | 63 | if (isset($options['aprsserverpass'])) $globalServerAPRSpass = $options['aprsserverpass']; |
@@ -66,8 +66,8 @@ discard block |
||
| 66 | 66 | if (isset($options['idsource'])) $id_source = $options['idsource']; |
| 67 | 67 | else $id_source = 1; |
| 68 | 68 | if (isset($globalServer) && $globalServer) { |
| 69 | - if ($globalDebug) echo "Using Server Mode\n"; |
|
| 70 | - $SI=new SpotterServer(); |
|
| 69 | + if ($globalDebug) echo "Using Server Mode\n"; |
|
| 70 | + $SI=new SpotterServer(); |
|
| 71 | 71 | /* |
| 72 | 72 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
| 73 | 73 | $SI = new adsb2aprs(); |
@@ -76,8 +76,8 @@ discard block |
||
| 76 | 76 | } else $SI=new SpotterImport($Connection->db); |
| 77 | 77 | if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db); |
| 78 | 78 | if (isset($globalMarine) && $globalMarine) { |
| 79 | - $AIS = new AIS(); |
|
| 80 | - $MI = new MarineImport($Connection->db); |
|
| 79 | + $AIS = new AIS(); |
|
| 80 | + $MI = new MarineImport($Connection->db); |
|
| 81 | 81 | } |
| 82 | 82 | //$APRS=new APRS($Connection->db); |
| 83 | 83 | $SBS=new SBS(); |
@@ -87,12 +87,12 @@ discard block |
||
| 87 | 87 | //$servertz = system('date +%Z'); |
| 88 | 88 | // signal handler - playing nice with sockets and dump1090 |
| 89 | 89 | if (function_exists('pcntl_fork')) { |
| 90 | - pcntl_signal(SIGINT, function() { |
|
| 91 | - global $sockets; |
|
| 92 | - echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
|
| 93 | - die("Bye!\n"); |
|
| 94 | - }); |
|
| 95 | - pcntl_signal_dispatch(); |
|
| 90 | + pcntl_signal(SIGINT, function() { |
|
| 91 | + global $sockets; |
|
| 92 | + echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
|
| 93 | + die("Bye!\n"); |
|
| 94 | + }); |
|
| 95 | + pcntl_signal_dispatch(); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | // let's try and connect |
@@ -102,153 +102,153 @@ discard block |
||
| 102 | 102 | $reset = 0; |
| 103 | 103 | |
| 104 | 104 | function connect_all($hosts) { |
| 105 | - //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
| 106 | - global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
| 107 | - $reset++; |
|
| 108 | - if ($globalDebug) echo 'Connect to all...'."\n"; |
|
| 109 | - foreach ($hosts as $id => $value) { |
|
| 105 | + //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
| 106 | + global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
| 107 | + $reset++; |
|
| 108 | + if ($globalDebug) echo 'Connect to all...'."\n"; |
|
| 109 | + foreach ($hosts as $id => $value) { |
|
| 110 | 110 | $host = $value['host']; |
| 111 | 111 | $globalSources[$id]['last_exec'] = 0; |
| 112 | 112 | // Here we check type of source(s) |
| 113 | 113 | if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
| 114 | - if (preg_match('/deltadb.txt$/i',$host)) { |
|
| 115 | - //$formats[$id] = 'deltadbtxt'; |
|
| 116 | - $globalSources[$id]['format'] = 'deltadbtxt'; |
|
| 117 | - //$last_exec['deltadbtxt'] = 0; |
|
| 118 | - if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
| 119 | - } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
| 120 | - //$formats[$id] = 'vatsimtxt'; |
|
| 121 | - $globalSources[$id]['format'] = 'vatsimtxt'; |
|
| 122 | - //$last_exec['vatsimtxt'] = 0; |
|
| 123 | - if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
| 124 | - } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
| 125 | - //$formats[$id] = 'aircraftlistjson'; |
|
| 126 | - $globalSources[$id]['format'] = 'aircraftlistjson'; |
|
| 127 | - //$last_exec['aircraftlistjson'] = 0; |
|
| 128 | - if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
| 129 | - } else if (preg_match('/opensky/i',$host)) { |
|
| 130 | - //$formats[$id] = 'aircraftlistjson'; |
|
| 131 | - $globalSources[$id]['format'] = 'opensky'; |
|
| 132 | - //$last_exec['aircraftlistjson'] = 0; |
|
| 133 | - if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
| 134 | - } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) { |
|
| 135 | - //$formats[$id] = 'radarvirtueljson'; |
|
| 136 | - $globalSources[$id]['format'] = 'radarvirtueljson'; |
|
| 137 | - //$last_exec['radarvirtueljson'] = 0; |
|
| 138 | - if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n"; |
|
| 139 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 140 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 141 | - exit(0); |
|
| 142 | - } |
|
| 143 | - } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
| 144 | - //$formats[$id] = 'planeupdatefaa'; |
|
| 145 | - $globalSources[$id]['format'] = 'planeupdatefaa'; |
|
| 146 | - //$last_exec['planeupdatefaa'] = 0; |
|
| 147 | - if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
| 148 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 149 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 150 | - exit(0); |
|
| 151 | - } |
|
| 152 | - } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
| 153 | - //$formats[$id] = 'phpvmacars'; |
|
| 154 | - $globalSources[$id]['format'] = 'phpvmacars'; |
|
| 155 | - //$last_exec['phpvmacars'] = 0; |
|
| 156 | - if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
| 157 | - } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
| 158 | - //$formats[$id] = 'phpvmacars'; |
|
| 159 | - $globalSources[$id]['format'] = 'vam'; |
|
| 160 | - if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
| 161 | - } else if (preg_match('/whazzup/i',$host)) { |
|
| 162 | - //$formats[$id] = 'whazzup'; |
|
| 163 | - $globalSources[$id]['format'] = 'whazzup'; |
|
| 164 | - //$last_exec['whazzup'] = 0; |
|
| 165 | - if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
| 166 | - } else if (preg_match('/recentpireps/i',$host)) { |
|
| 167 | - //$formats[$id] = 'pirepsjson'; |
|
| 168 | - $globalSources[$id]['format'] = 'pirepsjson'; |
|
| 169 | - //$last_exec['pirepsjson'] = 0; |
|
| 170 | - if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
| 171 | - } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
| 172 | - //$formats[$id] = 'fr24json'; |
|
| 173 | - $globalSources[$id]['format'] = 'fr24json'; |
|
| 174 | - //$last_exec['fr24json'] = 0; |
|
| 175 | - if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
| 176 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 177 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 178 | - exit(0); |
|
| 179 | - } |
|
| 180 | - } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
| 181 | - //$formats[$id] = 'fr24json'; |
|
| 182 | - $globalSources[$id]['format'] = 'myshiptracking'; |
|
| 183 | - //$last_exec['fr24json'] = 0; |
|
| 184 | - if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
| 185 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 186 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 187 | - exit(0); |
|
| 188 | - } |
|
| 189 | - //} else if (preg_match('/10001/',$host)) { |
|
| 190 | - } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
| 191 | - //$formats[$id] = 'tsv'; |
|
| 192 | - $globalSources[$id]['format'] = 'tsv'; |
|
| 193 | - if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
| 194 | - } |
|
| 195 | - } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
| 196 | - if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
|
| 197 | - $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
| 198 | - if ($idf !== false) { |
|
| 199 | - $httpfeeds[$id] = $idf; |
|
| 200 | - if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 201 | - } |
|
| 202 | - elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
| 203 | - } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 204 | - } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
| 205 | - $hostport = explode(':',$host); |
|
| 206 | - if (isset($hostport[1])) { |
|
| 114 | + if (preg_match('/deltadb.txt$/i',$host)) { |
|
| 115 | + //$formats[$id] = 'deltadbtxt'; |
|
| 116 | + $globalSources[$id]['format'] = 'deltadbtxt'; |
|
| 117 | + //$last_exec['deltadbtxt'] = 0; |
|
| 118 | + if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
| 119 | + } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
| 120 | + //$formats[$id] = 'vatsimtxt'; |
|
| 121 | + $globalSources[$id]['format'] = 'vatsimtxt'; |
|
| 122 | + //$last_exec['vatsimtxt'] = 0; |
|
| 123 | + if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
| 124 | + } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
| 125 | + //$formats[$id] = 'aircraftlistjson'; |
|
| 126 | + $globalSources[$id]['format'] = 'aircraftlistjson'; |
|
| 127 | + //$last_exec['aircraftlistjson'] = 0; |
|
| 128 | + if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
| 129 | + } else if (preg_match('/opensky/i',$host)) { |
|
| 130 | + //$formats[$id] = 'aircraftlistjson'; |
|
| 131 | + $globalSources[$id]['format'] = 'opensky'; |
|
| 132 | + //$last_exec['aircraftlistjson'] = 0; |
|
| 133 | + if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
| 134 | + } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) { |
|
| 135 | + //$formats[$id] = 'radarvirtueljson'; |
|
| 136 | + $globalSources[$id]['format'] = 'radarvirtueljson'; |
|
| 137 | + //$last_exec['radarvirtueljson'] = 0; |
|
| 138 | + if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n"; |
|
| 139 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 140 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 141 | + exit(0); |
|
| 142 | + } |
|
| 143 | + } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
| 144 | + //$formats[$id] = 'planeupdatefaa'; |
|
| 145 | + $globalSources[$id]['format'] = 'planeupdatefaa'; |
|
| 146 | + //$last_exec['planeupdatefaa'] = 0; |
|
| 147 | + if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
| 148 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 149 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 150 | + exit(0); |
|
| 151 | + } |
|
| 152 | + } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
| 153 | + //$formats[$id] = 'phpvmacars'; |
|
| 154 | + $globalSources[$id]['format'] = 'phpvmacars'; |
|
| 155 | + //$last_exec['phpvmacars'] = 0; |
|
| 156 | + if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
| 157 | + } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
| 158 | + //$formats[$id] = 'phpvmacars'; |
|
| 159 | + $globalSources[$id]['format'] = 'vam'; |
|
| 160 | + if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
| 161 | + } else if (preg_match('/whazzup/i',$host)) { |
|
| 162 | + //$formats[$id] = 'whazzup'; |
|
| 163 | + $globalSources[$id]['format'] = 'whazzup'; |
|
| 164 | + //$last_exec['whazzup'] = 0; |
|
| 165 | + if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
| 166 | + } else if (preg_match('/recentpireps/i',$host)) { |
|
| 167 | + //$formats[$id] = 'pirepsjson'; |
|
| 168 | + $globalSources[$id]['format'] = 'pirepsjson'; |
|
| 169 | + //$last_exec['pirepsjson'] = 0; |
|
| 170 | + if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
| 171 | + } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
| 172 | + //$formats[$id] = 'fr24json'; |
|
| 173 | + $globalSources[$id]['format'] = 'fr24json'; |
|
| 174 | + //$last_exec['fr24json'] = 0; |
|
| 175 | + if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
| 176 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 177 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 178 | + exit(0); |
|
| 179 | + } |
|
| 180 | + } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
| 181 | + //$formats[$id] = 'fr24json'; |
|
| 182 | + $globalSources[$id]['format'] = 'myshiptracking'; |
|
| 183 | + //$last_exec['fr24json'] = 0; |
|
| 184 | + if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
| 185 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 186 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 187 | + exit(0); |
|
| 188 | + } |
|
| 189 | + //} else if (preg_match('/10001/',$host)) { |
|
| 190 | + } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
| 191 | + //$formats[$id] = 'tsv'; |
|
| 192 | + $globalSources[$id]['format'] = 'tsv'; |
|
| 193 | + if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
| 194 | + } |
|
| 195 | + } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
| 196 | + if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
|
| 197 | + $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
| 198 | + if ($idf !== false) { |
|
| 199 | + $httpfeeds[$id] = $idf; |
|
| 200 | + if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 201 | + } |
|
| 202 | + elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
| 203 | + } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 204 | + } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
| 205 | + $hostport = explode(':',$host); |
|
| 206 | + if (isset($hostport[1])) { |
|
| 207 | 207 | $port = $hostport[1]; |
| 208 | 208 | $hostn = $hostport[0]; |
| 209 | - } else { |
|
| 209 | + } else { |
|
| 210 | 210 | $port = $globalSources[$id]['port']; |
| 211 | 211 | $hostn = $globalSources[$id]['host']; |
| 212 | - } |
|
| 213 | - $Common = new Common(); |
|
| 214 | - if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
|
| 215 | - $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
| 216 | - } else { |
|
| 217 | - $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
| 218 | - } |
|
| 219 | - if ($s) { |
|
| 220 | - $sockets[$id] = $s; |
|
| 221 | - if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
|
| 222 | - if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
| 212 | + } |
|
| 213 | + $Common = new Common(); |
|
| 214 | + if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
|
| 215 | + $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
| 216 | + } else { |
|
| 217 | + $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
| 218 | + } |
|
| 219 | + if ($s) { |
|
| 220 | + $sockets[$id] = $s; |
|
| 221 | + if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
|
| 222 | + if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
| 223 | 223 | //$formats[$id] = 'aprs'; |
| 224 | 224 | $globalSources[$id]['format'] = 'aprs'; |
| 225 | 225 | //$aprs_connect = 0; |
| 226 | 226 | //$use_aprs = true; |
| 227 | - } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
| 227 | + } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
| 228 | 228 | $globalSources[$id]['format'] = 'vrstcp'; |
| 229 | - } elseif ($port == '10001') { |
|
| 230 | - //$formats[$id] = 'tsv'; |
|
| 231 | - $globalSources[$id]['format'] = 'tsv'; |
|
| 232 | - } elseif ($port == '30002') { |
|
| 233 | - //$formats[$id] = 'raw'; |
|
| 234 | - $globalSources[$id]['format'] = 'raw'; |
|
| 235 | - } elseif ($port == '5001') { |
|
| 236 | - //$formats[$id] = 'raw'; |
|
| 237 | - $globalSources[$id]['format'] = 'flightgearmp'; |
|
| 238 | - } elseif ($port == '30005') { |
|
| 229 | + } elseif ($port == '10001') { |
|
| 230 | + //$formats[$id] = 'tsv'; |
|
| 231 | + $globalSources[$id]['format'] = 'tsv'; |
|
| 232 | + } elseif ($port == '30002') { |
|
| 233 | + //$formats[$id] = 'raw'; |
|
| 234 | + $globalSources[$id]['format'] = 'raw'; |
|
| 235 | + } elseif ($port == '5001') { |
|
| 236 | + //$formats[$id] = 'raw'; |
|
| 237 | + $globalSources[$id]['format'] = 'flightgearmp'; |
|
| 238 | + } elseif ($port == '30005') { |
|
| 239 | 239 | // Not yet supported |
| 240 | - //$formats[$id] = 'beast'; |
|
| 241 | - $globalSources[$id]['format'] = 'beast'; |
|
| 242 | - //} else $formats[$id] = 'sbs'; |
|
| 243 | - } else $globalSources[$id]['format'] = 'sbs'; |
|
| 244 | - //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
|
| 240 | + //$formats[$id] = 'beast'; |
|
| 241 | + $globalSources[$id]['format'] = 'beast'; |
|
| 242 | + //} else $formats[$id] = 'sbs'; |
|
| 243 | + } else $globalSources[$id]['format'] = 'sbs'; |
|
| 244 | + //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
|
| 245 | 245 | } |
| 246 | 246 | if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
| 247 | - } else { |
|
| 247 | + } else { |
|
| 248 | 248 | if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
| 249 | - } |
|
| 250 | - } |
|
| 251 | - } |
|
| 249 | + } |
|
| 250 | + } |
|
| 251 | + } |
|
| 252 | 252 | } |
| 253 | 253 | if (!isset($globalMinFetch)) $globalMinFetch = 15; |
| 254 | 254 | |
@@ -271,9 +271,9 @@ discard block |
||
| 271 | 271 | //connect_all($globalSources); |
| 272 | 272 | |
| 273 | 273 | if (isset($globalProxy) && $globalProxy) { |
| 274 | - $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
| 274 | + $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
| 275 | 275 | } else { |
| 276 | - $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
|
| 276 | + $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
|
| 277 | 277 | } |
| 278 | 278 | |
| 279 | 279 | // APRS Configuration |
@@ -282,18 +282,18 @@ discard block |
||
| 282 | 282 | die; |
| 283 | 283 | } |
| 284 | 284 | foreach ($globalSources as $key => $source) { |
| 285 | - if (!isset($source['format'])) { |
|
| 286 | - $globalSources[$key]['format'] = 'auto'; |
|
| 287 | - } |
|
| 285 | + if (!isset($source['format'])) { |
|
| 286 | + $globalSources[$key]['format'] = 'auto'; |
|
| 287 | + } |
|
| 288 | 288 | } |
| 289 | 289 | connect_all($globalSources); |
| 290 | 290 | foreach ($globalSources as $key => $source) { |
| 291 | - if (isset($source['format']) && $source['format'] == 'aprs') { |
|
| 291 | + if (isset($source['format']) && $source['format'] == 'aprs') { |
|
| 292 | 292 | $aprs_connect = 0; |
| 293 | 293 | $use_aprs = true; |
| 294 | 294 | if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true; |
| 295 | 295 | break; |
| 296 | - } |
|
| 296 | + } |
|
| 297 | 297 | } |
| 298 | 298 | |
| 299 | 299 | if ($use_aprs) { |
@@ -334,152 +334,152 @@ discard block |
||
| 334 | 334 | |
| 335 | 335 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
| 336 | 336 | while ($i > 0) { |
| 337 | - if (!$globalDaemon) $i = $endtime-time(); |
|
| 338 | - // Delete old ATC |
|
| 339 | - if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
| 337 | + if (!$globalDaemon) $i = $endtime-time(); |
|
| 338 | + // Delete old ATC |
|
| 339 | + if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
| 340 | 340 | if ($globalDebug) echo 'Delete old ATC...'."\n"; |
| 341 | - $ATC->deleteOldATC(); |
|
| 342 | - } |
|
| 341 | + $ATC->deleteOldATC(); |
|
| 342 | + } |
|
| 343 | 343 | |
| 344 | - //if (count($last_exec) > 0) { |
|
| 345 | - if (count($last_exec) == count($globalSources)) { |
|
| 344 | + //if (count($last_exec) > 0) { |
|
| 345 | + if (count($last_exec) == count($globalSources)) { |
|
| 346 | 346 | $max = $globalMinFetch; |
| 347 | 347 | foreach ($last_exec as $last) { |
| 348 | - if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
| 348 | + if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
| 349 | 349 | } |
| 350 | 350 | if ($max != $globalMinFetch) { |
| 351 | - if ($globalDebug) echo 'Sleeping...'."\n"; |
|
| 352 | - sleep($globalMinFetch-$max+2); |
|
| 351 | + if ($globalDebug) echo 'Sleeping...'."\n"; |
|
| 352 | + sleep($globalMinFetch-$max+2); |
|
| 353 | + } |
|
| 353 | 354 | } |
| 354 | - } |
|
| 355 | 355 | |
| 356 | 356 | |
| 357 | - //foreach ($formats as $id => $value) { |
|
| 358 | - foreach ($globalSources as $id => $value) { |
|
| 357 | + //foreach ($formats as $id => $value) { |
|
| 358 | + foreach ($globalSources as $id => $value) { |
|
| 359 | 359 | date_default_timezone_set('UTC'); |
| 360 | 360 | if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0; |
| 361 | 361 | if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
| 362 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 363 | - $buffer = $Common->getData($value['host']); |
|
| 364 | - if ($buffer != '') $reset = 0; |
|
| 365 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 366 | - $buffer = explode('\n',$buffer); |
|
| 367 | - foreach ($buffer as $line) { |
|
| 368 | - if ($line != '' && count($line) > 7) { |
|
| 369 | - $line = explode(',', $line); |
|
| 370 | - $data = array(); |
|
| 371 | - $data['hex'] = $line[1]; // hex |
|
| 372 | - $data['ident'] = $line[2]; // ident |
|
| 373 | - if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
| 374 | - if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
| 375 | - if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
| 376 | - if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
| 377 | - if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
| 378 | - $data['verticalrate'] = ''; // vertical rate |
|
| 379 | - //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
|
| 380 | - $data['emergency'] = ''; // emergency |
|
| 381 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 382 | - $data['format_source'] = 'deltadbtxt'; |
|
| 383 | - $data['id_source'] = $id_source; |
|
| 384 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 385 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
| 386 | - $SI->add($data); |
|
| 387 | - unset($data); |
|
| 388 | - } |
|
| 389 | - } |
|
| 390 | - $last_exec[$id]['last'] = time(); |
|
| 362 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 363 | + $buffer = $Common->getData($value['host']); |
|
| 364 | + if ($buffer != '') $reset = 0; |
|
| 365 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 366 | + $buffer = explode('\n',$buffer); |
|
| 367 | + foreach ($buffer as $line) { |
|
| 368 | + if ($line != '' && count($line) > 7) { |
|
| 369 | + $line = explode(',', $line); |
|
| 370 | + $data = array(); |
|
| 371 | + $data['hex'] = $line[1]; // hex |
|
| 372 | + $data['ident'] = $line[2]; // ident |
|
| 373 | + if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
| 374 | + if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
| 375 | + if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
| 376 | + if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
| 377 | + if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
| 378 | + $data['verticalrate'] = ''; // vertical rate |
|
| 379 | + //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
|
| 380 | + $data['emergency'] = ''; // emergency |
|
| 381 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 382 | + $data['format_source'] = 'deltadbtxt'; |
|
| 383 | + $data['id_source'] = $id_source; |
|
| 384 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 385 | + if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
| 386 | + $SI->add($data); |
|
| 387 | + unset($data); |
|
| 388 | + } |
|
| 389 | + } |
|
| 390 | + $last_exec[$id]['last'] = time(); |
|
| 391 | 391 | } elseif ($value['format'] == 'aisnmeatxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
| 392 | - date_default_timezone_set('CET'); |
|
| 393 | - $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
| 394 | - date_default_timezone_set('UTC'); |
|
| 395 | - if ($buffer != '') $reset = 0; |
|
| 396 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 397 | - $buffer = explode('\n',$buffer); |
|
| 398 | - foreach ($buffer as $line) { |
|
| 392 | + date_default_timezone_set('CET'); |
|
| 393 | + $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
| 394 | + date_default_timezone_set('UTC'); |
|
| 395 | + if ($buffer != '') $reset = 0; |
|
| 396 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 397 | + $buffer = explode('\n',$buffer); |
|
| 398 | + foreach ($buffer as $line) { |
|
| 399 | 399 | if ($line != '') { |
| 400 | - echo "'".$line."'\n"; |
|
| 401 | - $add = false; |
|
| 402 | - $ais_data = $AIS->parse_line(trim($line)); |
|
| 403 | - $data = array(); |
|
| 404 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 405 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
| 406 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 407 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 408 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 409 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 410 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 411 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 412 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 413 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 414 | - if (isset($ais_data['timestamp'])) { |
|
| 400 | + echo "'".$line."'\n"; |
|
| 401 | + $add = false; |
|
| 402 | + $ais_data = $AIS->parse_line(trim($line)); |
|
| 403 | + $data = array(); |
|
| 404 | + if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 405 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
| 406 | + if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 407 | + if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 408 | + if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 409 | + if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 410 | + if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 411 | + if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 412 | + if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 413 | + if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 414 | + if (isset($ais_data['timestamp'])) { |
|
| 415 | 415 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
| 416 | 416 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
| 417 | - $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
|
| 418 | - $add = true; |
|
| 417 | + $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
|
| 418 | + $add = true; |
|
| 419 | 419 | } |
| 420 | - } else { |
|
| 420 | + } else { |
|
| 421 | 421 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 422 | 422 | $add = true; |
| 423 | - } |
|
| 424 | - $data['format_source'] = 'aisnmeatxt'; |
|
| 425 | - $data['id_source'] = $id_source; |
|
| 426 | - print_r($data); |
|
| 427 | - echo 'Add...'."\n"; |
|
| 428 | - if ($add && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
| 429 | - unset($data); |
|
| 423 | + } |
|
| 424 | + $data['format_source'] = 'aisnmeatxt'; |
|
| 425 | + $data['id_source'] = $id_source; |
|
| 426 | + print_r($data); |
|
| 427 | + echo 'Add...'."\n"; |
|
| 428 | + if ($add && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
| 429 | + unset($data); |
|
| 430 | 430 | } |
| 431 | - } |
|
| 432 | - $last_exec[$id]['last'] = time(); |
|
| 431 | + } |
|
| 432 | + $last_exec[$id]['last'] = time(); |
|
| 433 | 433 | } elseif ($value['format'] == 'aisnmeahttp') { |
| 434 | - $arr = $httpfeeds; |
|
| 435 | - $w = $e = null; |
|
| 434 | + $arr = $httpfeeds; |
|
| 435 | + $w = $e = null; |
|
| 436 | 436 | |
| 437 | - if (isset($arr[$id])) { |
|
| 438 | - $nn = stream_select($arr,$w,$e,$timeout); |
|
| 439 | - if ($nn > 0) { |
|
| 437 | + if (isset($arr[$id])) { |
|
| 438 | + $nn = stream_select($arr,$w,$e,$timeout); |
|
| 439 | + if ($nn > 0) { |
|
| 440 | 440 | foreach ($httpfeeds as $feed) { |
| 441 | - $buffer = stream_get_line($feed,2000,"\n"); |
|
| 442 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 443 | - $buffer = explode('\n',$buffer); |
|
| 444 | - foreach ($buffer as $line) { |
|
| 441 | + $buffer = stream_get_line($feed,2000,"\n"); |
|
| 442 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 443 | + $buffer = explode('\n',$buffer); |
|
| 444 | + foreach ($buffer as $line) { |
|
| 445 | 445 | if ($line != '') { |
| 446 | - $ais_data = $AIS->parse_line(trim($line)); |
|
| 447 | - $data = array(); |
|
| 448 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 449 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
| 450 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 451 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 452 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 453 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 454 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 455 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 456 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 457 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 458 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
| 459 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 460 | - if (isset($ais_data['timestamp'])) { |
|
| 446 | + $ais_data = $AIS->parse_line(trim($line)); |
|
| 447 | + $data = array(); |
|
| 448 | + if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 449 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
| 450 | + if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 451 | + if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 452 | + if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 453 | + if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 454 | + if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 455 | + if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 456 | + if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 457 | + if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 458 | + if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
| 459 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 460 | + if (isset($ais_data['timestamp'])) { |
|
| 461 | 461 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
| 462 | - } else { |
|
| 462 | + } else { |
|
| 463 | 463 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 464 | - } |
|
| 465 | - $data['format_source'] = 'aisnmeahttp'; |
|
| 466 | - $data['id_source'] = $id_source; |
|
| 467 | - if ($ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
| 468 | - unset($data); |
|
| 464 | + } |
|
| 465 | + $data['format_source'] = 'aisnmeahttp'; |
|
| 466 | + $data['id_source'] = $id_source; |
|
| 467 | + if ($ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
| 468 | + unset($data); |
|
| 469 | 469 | } |
| 470 | - } |
|
| 470 | + } |
|
| 471 | + } |
|
| 471 | 472 | } |
| 472 | 473 | } |
| 473 | - } |
|
| 474 | 474 | } elseif ($value['format'] == 'myshiptracking' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
| 475 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
| 476 | - if ($buffer != '') { |
|
| 475 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
| 476 | + if ($buffer != '') { |
|
| 477 | 477 | //echo $buffer; |
| 478 | 478 | $all_data = json_decode($buffer,true); |
| 479 | 479 | //print_r($all_data); |
| 480 | 480 | if (isset($all_data[0]['DATA'])) { |
| 481 | 481 | foreach ($all_data[0]['DATA'] as $line) { |
| 482 | - if ($line != '') { |
|
| 482 | + if ($line != '') { |
|
| 483 | 483 | $data = array(); |
| 484 | 484 | $data['ident'] = $line['NAME']; |
| 485 | 485 | $data['mmsi'] = $line['MMSI']; |
@@ -495,87 +495,87 @@ discard block |
||
| 495 | 495 | $data['id_source'] = $id_source; |
| 496 | 496 | $MI->add($data); |
| 497 | 497 | unset($data); |
| 498 | - } |
|
| 498 | + } |
|
| 499 | 499 | } |
| 500 | 500 | } |
| 501 | 501 | |
| 502 | - } |
|
| 503 | - $last_exec[$id]['last'] = time(); |
|
| 502 | + } |
|
| 503 | + $last_exec[$id]['last'] = time(); |
|
| 504 | 504 | } elseif ($value['format'] == 'boatbeaconapp' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
| 505 | - $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
| 506 | - if ($buffer != '') { |
|
| 505 | + $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
| 506 | + if ($buffer != '') { |
|
| 507 | 507 | $all_data = json_decode($buffer,true); |
| 508 | 508 | if (isset($all_data[0]['mmsi'])) { |
| 509 | - foreach ($all_data as $line) { |
|
| 509 | + foreach ($all_data as $line) { |
|
| 510 | 510 | if ($line != '') { |
| 511 | - $data = array(); |
|
| 512 | - $data['ident'] = $line['shipname']; |
|
| 513 | - $data['callsign'] = $line['callsign']; |
|
| 514 | - $data['mmsi'] = $line['mmsi']; |
|
| 515 | - $data['speed'] = $line['sog']; |
|
| 516 | - if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
| 517 | - $data['latitude'] = $line['latitude']; |
|
| 518 | - $data['longitude'] = $line['longitude']; |
|
| 519 | - $data['type_id'] = $line['shiptype']; |
|
| 520 | - $data['arrival_code'] = $line['destination']; |
|
| 521 | - $data['datetime'] = $line['time']; |
|
| 522 | - $data['format_source'] = 'boatbeaconapp'; |
|
| 523 | - $data['id_source'] = $id_source; |
|
| 524 | - $MI->add($data); |
|
| 525 | - unset($data); |
|
| 511 | + $data = array(); |
|
| 512 | + $data['ident'] = $line['shipname']; |
|
| 513 | + $data['callsign'] = $line['callsign']; |
|
| 514 | + $data['mmsi'] = $line['mmsi']; |
|
| 515 | + $data['speed'] = $line['sog']; |
|
| 516 | + if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
| 517 | + $data['latitude'] = $line['latitude']; |
|
| 518 | + $data['longitude'] = $line['longitude']; |
|
| 519 | + $data['type_id'] = $line['shiptype']; |
|
| 520 | + $data['arrival_code'] = $line['destination']; |
|
| 521 | + $data['datetime'] = $line['time']; |
|
| 522 | + $data['format_source'] = 'boatbeaconapp'; |
|
| 523 | + $data['id_source'] = $id_source; |
|
| 524 | + $MI->add($data); |
|
| 525 | + unset($data); |
|
| 526 | + } |
|
| 526 | 527 | } |
| 527 | - } |
|
| 528 | 528 | } |
| 529 | 529 | |
| 530 | - } |
|
| 531 | - $last_exec[$id]['last'] = time(); |
|
| 530 | + } |
|
| 531 | + $last_exec[$id]['last'] = time(); |
|
| 532 | 532 | } elseif ($value['format'] == 'shipplotter' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
| 533 | - echo 'download...'; |
|
| 534 | - $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
| 535 | - echo 'done !'."\n"; |
|
| 536 | - if ($buffer != '') $reset = 0; |
|
| 537 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 538 | - $buffer = explode('\n',$buffer); |
|
| 539 | - foreach ($buffer as $line) { |
|
| 533 | + echo 'download...'; |
|
| 534 | + $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
| 535 | + echo 'done !'."\n"; |
|
| 536 | + if ($buffer != '') $reset = 0; |
|
| 537 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 538 | + $buffer = explode('\n',$buffer); |
|
| 539 | + foreach ($buffer as $line) { |
|
| 540 | 540 | if ($line != '') { |
| 541 | - $data = array(); |
|
| 542 | - $data['mmsi'] = (int)substr($line,0,9); |
|
| 543 | - $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
| 544 | - //$data['status'] = substr($line,21,2); |
|
| 545 | - //$data['type'] = substr($line,24,3); |
|
| 546 | - $data['latitude'] = substr($line,29,9); |
|
| 547 | - $data['longitude'] = substr($line,41,9); |
|
| 548 | - $data['speed'] = round(substr($line,51,5)); |
|
| 549 | - //$data['course'] = substr($line,57,5); |
|
| 550 | - $data['heading'] = round(substr($line,63,3)); |
|
| 551 | - //$data['draft'] = substr($line,67,4); |
|
| 552 | - //$data['length'] = substr($line,72,3); |
|
| 553 | - //$data['beam'] = substr($line,76,2); |
|
| 554 | - $data['ident'] = trim(utf8_encode(substr($line,79,20))); |
|
| 555 | - //$data['callsign'] = trim(substr($line,100,7); |
|
| 556 | - //$data['dest'] = substr($line,108,20); |
|
| 557 | - //$data['etaDate'] = substr($line,129,5); |
|
| 558 | - //$data['etaTime'] = substr($line,135,5); |
|
| 559 | - $data['format_source'] = 'shipplotter'; |
|
| 560 | - $data['id_source'] = $id_source; |
|
| 561 | - print_r($data); |
|
| 562 | - echo 'Add...'."\n"; |
|
| 563 | - $MI->add($data); |
|
| 564 | - unset($data); |
|
| 541 | + $data = array(); |
|
| 542 | + $data['mmsi'] = (int)substr($line,0,9); |
|
| 543 | + $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
| 544 | + //$data['status'] = substr($line,21,2); |
|
| 545 | + //$data['type'] = substr($line,24,3); |
|
| 546 | + $data['latitude'] = substr($line,29,9); |
|
| 547 | + $data['longitude'] = substr($line,41,9); |
|
| 548 | + $data['speed'] = round(substr($line,51,5)); |
|
| 549 | + //$data['course'] = substr($line,57,5); |
|
| 550 | + $data['heading'] = round(substr($line,63,3)); |
|
| 551 | + //$data['draft'] = substr($line,67,4); |
|
| 552 | + //$data['length'] = substr($line,72,3); |
|
| 553 | + //$data['beam'] = substr($line,76,2); |
|
| 554 | + $data['ident'] = trim(utf8_encode(substr($line,79,20))); |
|
| 555 | + //$data['callsign'] = trim(substr($line,100,7); |
|
| 556 | + //$data['dest'] = substr($line,108,20); |
|
| 557 | + //$data['etaDate'] = substr($line,129,5); |
|
| 558 | + //$data['etaTime'] = substr($line,135,5); |
|
| 559 | + $data['format_source'] = 'shipplotter'; |
|
| 560 | + $data['id_source'] = $id_source; |
|
| 561 | + print_r($data); |
|
| 562 | + echo 'Add...'."\n"; |
|
| 563 | + $MI->add($data); |
|
| 564 | + unset($data); |
|
| 565 | 565 | } |
| 566 | - } |
|
| 567 | - $last_exec[$id]['last'] = time(); |
|
| 566 | + } |
|
| 567 | + $last_exec[$id]['last'] = time(); |
|
| 568 | 568 | //} elseif (($value == 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value == 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) { |
| 569 | 569 | } elseif (($value['format'] == 'whazzup' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch))) { |
| 570 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 571 | - $buffer = $Common->getData($value['host']); |
|
| 572 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 573 | - $buffer = explode('\n',$buffer); |
|
| 574 | - $reset = 0; |
|
| 575 | - foreach ($buffer as $line) { |
|
| 576 | - if ($line != '') { |
|
| 577 | - $line = explode(':', $line); |
|
| 578 | - if (count($line) > 30 && $line[0] != 'callsign') { |
|
| 570 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 571 | + $buffer = $Common->getData($value['host']); |
|
| 572 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 573 | + $buffer = explode('\n',$buffer); |
|
| 574 | + $reset = 0; |
|
| 575 | + foreach ($buffer as $line) { |
|
| 576 | + if ($line != '') { |
|
| 577 | + $line = explode(':', $line); |
|
| 578 | + if (count($line) > 30 && $line[0] != 'callsign') { |
|
| 579 | 579 | $data = array(); |
| 580 | 580 | if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
| 581 | 581 | else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
@@ -588,36 +588,36 @@ discard block |
||
| 588 | 588 | if (isset($line[45])) $data['heading'] = $line[45]; // heading |
| 589 | 589 | elseif (isset($line[38])) $data['heading'] = $line[38]; // heading |
| 590 | 590 | $data['latitude'] = $line[5]; // lat |
| 591 | - $data['longitude'] = $line[6]; // long |
|
| 592 | - $data['verticalrate'] = ''; // vertical rate |
|
| 593 | - $data['squawk'] = ''; // squawk |
|
| 594 | - $data['emergency'] = ''; // emergency |
|
| 595 | - $data['waypoints'] = $line[30]; |
|
| 591 | + $data['longitude'] = $line[6]; // long |
|
| 592 | + $data['verticalrate'] = ''; // vertical rate |
|
| 593 | + $data['squawk'] = ''; // squawk |
|
| 594 | + $data['emergency'] = ''; // emergency |
|
| 595 | + $data['waypoints'] = $line[30]; |
|
| 596 | 596 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 597 | 597 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); |
| 598 | 598 | //if (isset($line[37])) $data['last_update'] = $line[37]; |
| 599 | - $data['departure_airport_icao'] = $line[11]; |
|
| 600 | - $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
| 601 | - $data['arrival_airport_icao'] = $line[13]; |
|
| 599 | + $data['departure_airport_icao'] = $line[11]; |
|
| 600 | + $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
| 601 | + $data['arrival_airport_icao'] = $line[13]; |
|
| 602 | 602 | $data['frequency'] = $line[4]; |
| 603 | 603 | $data['type'] = $line[18]; |
| 604 | 604 | $data['range'] = $line[19]; |
| 605 | 605 | if (isset($line[35])) $data['info'] = $line[35]; |
| 606 | - $data['id_source'] = $id_source; |
|
| 607 | - //$data['arrival_airport_time'] = ; |
|
| 608 | - if ($line[9] != '') { |
|
| 609 | - $aircraft_data = explode('/',$line[9]); |
|
| 610 | - if (isset($aircraft_data[1])) { |
|
| 611 | - $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 612 | - } |
|
| 613 | - } |
|
| 614 | - /* |
|
| 606 | + $data['id_source'] = $id_source; |
|
| 607 | + //$data['arrival_airport_time'] = ; |
|
| 608 | + if ($line[9] != '') { |
|
| 609 | + $aircraft_data = explode('/',$line[9]); |
|
| 610 | + if (isset($aircraft_data[1])) { |
|
| 611 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 612 | + } |
|
| 613 | + } |
|
| 614 | + /* |
|
| 615 | 615 | if ($value == 'whazzup') $data['format_source'] = 'whazzup'; |
| 616 | 616 | elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; |
| 617 | 617 | */ |
| 618 | - $data['format_source'] = $value['format']; |
|
| 618 | + $data['format_source'] = $value['format']; |
|
| 619 | 619 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
| 620 | - if ($line[3] == 'PILOT') $SI->add($data); |
|
| 620 | + if ($line[3] == 'PILOT') $SI->add($data); |
|
| 621 | 621 | elseif ($line[3] == 'ATC') { |
| 622 | 622 | //print_r($data); |
| 623 | 623 | $data['info'] = str_replace('^§','<br />',$data['info']); |
@@ -635,247 +635,247 @@ discard block |
||
| 635 | 635 | if (!isset($data['source_name'])) $data['source_name'] = ''; |
| 636 | 636 | if (isset($ATC)) 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']); |
| 637 | 637 | } |
| 638 | - unset($data); |
|
| 639 | - } |
|
| 640 | - } |
|
| 641 | - } |
|
| 642 | - //if ($value == 'whazzup') $last_exec['whazzup'] = time(); |
|
| 643 | - //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
| 644 | - $last_exec[$id]['last'] = time(); |
|
| 645 | - //} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) { |
|
| 646 | - } elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 647 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
| 648 | - if ($buffer != '') { |
|
| 649 | - $all_data = json_decode($buffer,true); |
|
| 650 | - if (isset($all_data['acList'])) { |
|
| 638 | + unset($data); |
|
| 639 | + } |
|
| 640 | + } |
|
| 641 | + } |
|
| 642 | + //if ($value == 'whazzup') $last_exec['whazzup'] = time(); |
|
| 643 | + //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
| 644 | + $last_exec[$id]['last'] = time(); |
|
| 645 | + //} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) { |
|
| 646 | + } elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 647 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
| 648 | + if ($buffer != '') { |
|
| 649 | + $all_data = json_decode($buffer,true); |
|
| 650 | + if (isset($all_data['acList'])) { |
|
| 651 | 651 | $reset = 0; |
| 652 | 652 | foreach ($all_data['acList'] as $line) { |
| 653 | - $data = array(); |
|
| 654 | - $data['hex'] = $line['Icao']; // hex |
|
| 655 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
| 656 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
| 657 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
| 658 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
| 659 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
| 660 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
| 661 | - //$data['verticalrate'] = $line['']; // verticale rate |
|
| 662 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
| 663 | - $data['emergency'] = ''; // emergency |
|
| 664 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
| 665 | - /* |
|
| 653 | + $data = array(); |
|
| 654 | + $data['hex'] = $line['Icao']; // hex |
|
| 655 | + if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
| 656 | + if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
| 657 | + if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
| 658 | + if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
| 659 | + if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
| 660 | + if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
| 661 | + //$data['verticalrate'] = $line['']; // verticale rate |
|
| 662 | + if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
| 663 | + $data['emergency'] = ''; // emergency |
|
| 664 | + if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
| 665 | + /* |
|
| 666 | 666 | if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000); |
| 667 | 667 | else $data['datetime'] = date('Y-m-d H:i:s'); |
| 668 | 668 | */ |
| 669 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 670 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
| 671 | - $data['format_source'] = 'aircraftlistjson'; |
|
| 672 | - $data['id_source'] = $id_source; |
|
| 673 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 674 | - if (isset($data['latitude'])) $SI->add($data); |
|
| 675 | - unset($data); |
|
| 669 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 670 | + if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
| 671 | + $data['format_source'] = 'aircraftlistjson'; |
|
| 672 | + $data['id_source'] = $id_source; |
|
| 673 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 674 | + if (isset($data['latitude'])) $SI->add($data); |
|
| 675 | + unset($data); |
|
| 676 | 676 | } |
| 677 | - } elseif (is_array($all_data)) { |
|
| 677 | + } elseif (is_array($all_data)) { |
|
| 678 | 678 | $reset = 0; |
| 679 | 679 | foreach ($all_data as $line) { |
| 680 | - $data = array(); |
|
| 681 | - $data['hex'] = $line['hex']; // hex |
|
| 682 | - $data['ident'] = $line['flight']; // ident |
|
| 683 | - $data['altitude'] = $line['altitude']; // altitude |
|
| 684 | - $data['speed'] = $line['speed']; // speed |
|
| 685 | - $data['heading'] = $line['track']; // heading |
|
| 686 | - $data['latitude'] = $line['lat']; // lat |
|
| 687 | - $data['longitude'] = $line['lon']; // long |
|
| 688 | - $data['verticalrate'] = $line['vrt']; // verticale rate |
|
| 689 | - $data['squawk'] = $line['squawk']; // squawk |
|
| 690 | - $data['emergency'] = ''; // emergency |
|
| 691 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 692 | - $data['format_source'] = 'aircraftlistjson'; |
|
| 693 | - $data['id_source'] = $id_source; |
|
| 694 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 695 | - $SI->add($data); |
|
| 696 | - unset($data); |
|
| 680 | + $data = array(); |
|
| 681 | + $data['hex'] = $line['hex']; // hex |
|
| 682 | + $data['ident'] = $line['flight']; // ident |
|
| 683 | + $data['altitude'] = $line['altitude']; // altitude |
|
| 684 | + $data['speed'] = $line['speed']; // speed |
|
| 685 | + $data['heading'] = $line['track']; // heading |
|
| 686 | + $data['latitude'] = $line['lat']; // lat |
|
| 687 | + $data['longitude'] = $line['lon']; // long |
|
| 688 | + $data['verticalrate'] = $line['vrt']; // verticale rate |
|
| 689 | + $data['squawk'] = $line['squawk']; // squawk |
|
| 690 | + $data['emergency'] = ''; // emergency |
|
| 691 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 692 | + $data['format_source'] = 'aircraftlistjson'; |
|
| 693 | + $data['id_source'] = $id_source; |
|
| 694 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 695 | + $SI->add($data); |
|
| 696 | + unset($data); |
|
| 697 | + } |
|
| 697 | 698 | } |
| 698 | - } |
|
| 699 | - } |
|
| 700 | - //$last_exec['aircraftlistjson'] = time(); |
|
| 701 | - $last_exec[$id]['last'] = time(); |
|
| 702 | - //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
| 703 | - } elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 704 | - $buffer = $Common->getData($value['host']); |
|
| 705 | - $all_data = json_decode($buffer,true); |
|
| 706 | - if (isset($all_data['planes'])) { |
|
| 699 | + } |
|
| 700 | + //$last_exec['aircraftlistjson'] = time(); |
|
| 701 | + $last_exec[$id]['last'] = time(); |
|
| 702 | + //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
| 703 | + } elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 704 | + $buffer = $Common->getData($value['host']); |
|
| 705 | + $all_data = json_decode($buffer,true); |
|
| 706 | + if (isset($all_data['planes'])) { |
|
| 707 | 707 | $reset = 0; |
| 708 | 708 | foreach ($all_data['planes'] as $key => $line) { |
| 709 | - $data = array(); |
|
| 710 | - $data['hex'] = $key; // hex |
|
| 711 | - $data['ident'] = $line[3]; // ident |
|
| 712 | - $data['altitude'] = $line[6]; // altitude |
|
| 713 | - $data['speed'] = $line[8]; // speed |
|
| 714 | - $data['heading'] = $line[7]; // heading |
|
| 715 | - $data['latitude'] = $line[4]; // lat |
|
| 716 | - $data['longitude'] = $line[5]; // long |
|
| 717 | - //$data['verticalrate'] = $line[]; // verticale rate |
|
| 718 | - $data['squawk'] = $line[10]; // squawk |
|
| 719 | - $data['emergency'] = ''; // emergency |
|
| 720 | - $data['registration'] = $line[2]; |
|
| 721 | - $data['aircraft_icao'] = $line[0]; |
|
| 722 | - $deparr = explode('-',$line[1]); |
|
| 723 | - if (count($deparr) == 2) { |
|
| 709 | + $data = array(); |
|
| 710 | + $data['hex'] = $key; // hex |
|
| 711 | + $data['ident'] = $line[3]; // ident |
|
| 712 | + $data['altitude'] = $line[6]; // altitude |
|
| 713 | + $data['speed'] = $line[8]; // speed |
|
| 714 | + $data['heading'] = $line[7]; // heading |
|
| 715 | + $data['latitude'] = $line[4]; // lat |
|
| 716 | + $data['longitude'] = $line[5]; // long |
|
| 717 | + //$data['verticalrate'] = $line[]; // verticale rate |
|
| 718 | + $data['squawk'] = $line[10]; // squawk |
|
| 719 | + $data['emergency'] = ''; // emergency |
|
| 720 | + $data['registration'] = $line[2]; |
|
| 721 | + $data['aircraft_icao'] = $line[0]; |
|
| 722 | + $deparr = explode('-',$line[1]); |
|
| 723 | + if (count($deparr) == 2) { |
|
| 724 | 724 | $data['departure_airport_icao'] = $deparr[0]; |
| 725 | 725 | $data['arrival_airport_icao'] = $deparr[1]; |
| 726 | - } |
|
| 727 | - $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
| 728 | - $data['format_source'] = 'planeupdatefaa'; |
|
| 729 | - $data['id_source'] = $id_source; |
|
| 730 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 731 | - $SI->add($data); |
|
| 732 | - unset($data); |
|
| 726 | + } |
|
| 727 | + $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
| 728 | + $data['format_source'] = 'planeupdatefaa'; |
|
| 729 | + $data['id_source'] = $id_source; |
|
| 730 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 731 | + $SI->add($data); |
|
| 732 | + unset($data); |
|
| 733 | + } |
|
| 733 | 734 | } |
| 734 | - } |
|
| 735 | - //$last_exec['planeupdatefaa'] = time(); |
|
| 736 | - $last_exec[$id]['last'] = time(); |
|
| 737 | - } elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 738 | - $buffer = $Common->getData($value['host']); |
|
| 739 | - $all_data = json_decode($buffer,true); |
|
| 740 | - if (isset($all_data['states'])) { |
|
| 735 | + //$last_exec['planeupdatefaa'] = time(); |
|
| 736 | + $last_exec[$id]['last'] = time(); |
|
| 737 | + } elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 738 | + $buffer = $Common->getData($value['host']); |
|
| 739 | + $all_data = json_decode($buffer,true); |
|
| 740 | + if (isset($all_data['states'])) { |
|
| 741 | 741 | $reset = 0; |
| 742 | 742 | foreach ($all_data['states'] as $key => $line) { |
| 743 | - $data = array(); |
|
| 744 | - $data['hex'] = $line[0]; // hex |
|
| 745 | - $data['ident'] = trim($line[1]); // ident |
|
| 746 | - $data['altitude'] = round($line[7]*3.28084); // altitude |
|
| 747 | - $data['speed'] = round($line[9]*1.94384); // speed |
|
| 748 | - $data['heading'] = round($line[10]); // heading |
|
| 749 | - $data['latitude'] = $line[5]; // lat |
|
| 750 | - $data['longitude'] = $line[6]; // long |
|
| 751 | - $data['verticalrate'] = $line[11]; // verticale rate |
|
| 752 | - //$data['squawk'] = $line[10]; // squawk |
|
| 753 | - //$data['emergency'] = ''; // emergency |
|
| 754 | - //$data['registration'] = $line[2]; |
|
| 755 | - //$data['aircraft_icao'] = $line[0]; |
|
| 756 | - $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
| 757 | - $data['format_source'] = 'opensky'; |
|
| 758 | - $data['id_source'] = $id_source; |
|
| 759 | - $SI->add($data); |
|
| 760 | - unset($data); |
|
| 743 | + $data = array(); |
|
| 744 | + $data['hex'] = $line[0]; // hex |
|
| 745 | + $data['ident'] = trim($line[1]); // ident |
|
| 746 | + $data['altitude'] = round($line[7]*3.28084); // altitude |
|
| 747 | + $data['speed'] = round($line[9]*1.94384); // speed |
|
| 748 | + $data['heading'] = round($line[10]); // heading |
|
| 749 | + $data['latitude'] = $line[5]; // lat |
|
| 750 | + $data['longitude'] = $line[6]; // long |
|
| 751 | + $data['verticalrate'] = $line[11]; // verticale rate |
|
| 752 | + //$data['squawk'] = $line[10]; // squawk |
|
| 753 | + //$data['emergency'] = ''; // emergency |
|
| 754 | + //$data['registration'] = $line[2]; |
|
| 755 | + //$data['aircraft_icao'] = $line[0]; |
|
| 756 | + $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
| 757 | + $data['format_source'] = 'opensky'; |
|
| 758 | + $data['id_source'] = $id_source; |
|
| 759 | + $SI->add($data); |
|
| 760 | + unset($data); |
|
| 761 | + } |
|
| 761 | 762 | } |
| 762 | - } |
|
| 763 | - //$last_exec['planeupdatefaa'] = time(); |
|
| 764 | - $last_exec[$id]['last'] = time(); |
|
| 765 | - //} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) { |
|
| 766 | - } elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 767 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 768 | - $buffer = $Common->getData($value['host']); |
|
| 769 | - $all_data = json_decode($buffer,true); |
|
| 770 | - if (!empty($all_data)) $reset = 0; |
|
| 771 | - foreach ($all_data as $key => $line) { |
|
| 763 | + //$last_exec['planeupdatefaa'] = time(); |
|
| 764 | + $last_exec[$id]['last'] = time(); |
|
| 765 | + //} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) { |
|
| 766 | + } elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 767 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 768 | + $buffer = $Common->getData($value['host']); |
|
| 769 | + $all_data = json_decode($buffer,true); |
|
| 770 | + if (!empty($all_data)) $reset = 0; |
|
| 771 | + foreach ($all_data as $key => $line) { |
|
| 772 | 772 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
| 773 | - $data = array(); |
|
| 774 | - $data['hex'] = $line[0]; |
|
| 775 | - $data['ident'] = $line[16]; //$line[13] |
|
| 776 | - $data['altitude'] = $line[4]; // altitude |
|
| 777 | - $data['speed'] = $line[5]; // speed |
|
| 778 | - $data['heading'] = $line[3]; // heading |
|
| 779 | - $data['latitude'] = $line[1]; // lat |
|
| 780 | - $data['longitude'] = $line[2]; // long |
|
| 781 | - $data['verticalrate'] = $line[15]; // verticale rate |
|
| 782 | - $data['squawk'] = $line[6]; // squawk |
|
| 783 | - $data['aircraft_icao'] = $line[8]; |
|
| 784 | - $data['registration'] = $line[9]; |
|
| 785 | - $data['departure_airport_iata'] = $line[11]; |
|
| 786 | - $data['arrival_airport_iata'] = $line[12]; |
|
| 787 | - $data['emergency'] = ''; // emergency |
|
| 788 | - $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
| 789 | - $data['format_source'] = 'fr24json'; |
|
| 790 | - $data['id_source'] = $id_source; |
|
| 791 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 792 | - $SI->add($data); |
|
| 793 | - unset($data); |
|
| 773 | + $data = array(); |
|
| 774 | + $data['hex'] = $line[0]; |
|
| 775 | + $data['ident'] = $line[16]; //$line[13] |
|
| 776 | + $data['altitude'] = $line[4]; // altitude |
|
| 777 | + $data['speed'] = $line[5]; // speed |
|
| 778 | + $data['heading'] = $line[3]; // heading |
|
| 779 | + $data['latitude'] = $line[1]; // lat |
|
| 780 | + $data['longitude'] = $line[2]; // long |
|
| 781 | + $data['verticalrate'] = $line[15]; // verticale rate |
|
| 782 | + $data['squawk'] = $line[6]; // squawk |
|
| 783 | + $data['aircraft_icao'] = $line[8]; |
|
| 784 | + $data['registration'] = $line[9]; |
|
| 785 | + $data['departure_airport_iata'] = $line[11]; |
|
| 786 | + $data['arrival_airport_iata'] = $line[12]; |
|
| 787 | + $data['emergency'] = ''; // emergency |
|
| 788 | + $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
| 789 | + $data['format_source'] = 'fr24json'; |
|
| 790 | + $data['id_source'] = $id_source; |
|
| 791 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 792 | + $SI->add($data); |
|
| 793 | + unset($data); |
|
| 794 | + } |
|
| 794 | 795 | } |
| 795 | - } |
|
| 796 | - //$last_exec['fr24json'] = time(); |
|
| 797 | - $last_exec[$id]['last'] = time(); |
|
| 798 | - //} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
|
| 799 | - } elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 800 | - //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
| 801 | - $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
| 802 | - //echo $buffer; |
|
| 803 | - $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
| 804 | - $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
| 805 | - $all_data = json_decode($buffer,true); |
|
| 806 | - if (json_last_error() != JSON_ERROR_NONE) { |
|
| 796 | + //$last_exec['fr24json'] = time(); |
|
| 797 | + $last_exec[$id]['last'] = time(); |
|
| 798 | + //} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
|
| 799 | + } elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 800 | + //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
| 801 | + $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
| 802 | + //echo $buffer; |
|
| 803 | + $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
| 804 | + $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
| 805 | + $all_data = json_decode($buffer,true); |
|
| 806 | + if (json_last_error() != JSON_ERROR_NONE) { |
|
| 807 | 807 | die(json_last_error_msg()); |
| 808 | - } |
|
| 809 | - if (isset($all_data['mrkrs'])) { |
|
| 808 | + } |
|
| 809 | + if (isset($all_data['mrkrs'])) { |
|
| 810 | 810 | $reset = 0; |
| 811 | 811 | foreach ($all_data['mrkrs'] as $key => $line) { |
| 812 | - if (isset($line['inf'])) { |
|
| 812 | + if (isset($line['inf'])) { |
|
| 813 | 813 | $data = array(); |
| 814 | 814 | $data['hex'] = $line['inf']['ia']; |
| 815 | 815 | if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] |
| 816 | - $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
| 817 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
| 818 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
| 819 | - $data['latitude'] = $line['pt'][0]; // lat |
|
| 820 | - $data['longitude'] = $line['pt'][1]; // long |
|
| 821 | - //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
| 822 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
| 823 | - //$data['aircraft_icao'] = $line[8]; |
|
| 824 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
| 816 | + $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
| 817 | + if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
| 818 | + if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
| 819 | + $data['latitude'] = $line['pt'][0]; // lat |
|
| 820 | + $data['longitude'] = $line['pt'][1]; // long |
|
| 821 | + //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
| 822 | + if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
| 823 | + //$data['aircraft_icao'] = $line[8]; |
|
| 824 | + if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
| 825 | 825 | //$data['departure_airport_iata'] = $line[11]; |
| 826 | 826 | //$data['arrival_airport_iata'] = $line[12]; |
| 827 | - //$data['emergency'] = ''; // emergency |
|
| 827 | + //$data['emergency'] = ''; // emergency |
|
| 828 | 828 | $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
| 829 | - $data['format_source'] = 'radarvirtueljson'; |
|
| 830 | - $data['id_source'] = $id_source; |
|
| 829 | + $data['format_source'] = 'radarvirtueljson'; |
|
| 830 | + $data['id_source'] = $id_source; |
|
| 831 | 831 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
| 832 | 832 | $SI->add($data); |
| 833 | 833 | unset($data); |
| 834 | - } |
|
| 834 | + } |
|
| 835 | 835 | } |
| 836 | - } |
|
| 837 | - //$last_exec['radarvirtueljson'] = time(); |
|
| 838 | - $last_exec[$id]['last'] = time(); |
|
| 839 | - //} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) { |
|
| 840 | - } elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 841 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 842 | - $buffer = $Common->getData($value['host'].'?'.time()); |
|
| 843 | - $all_data = json_decode(utf8_encode($buffer),true); |
|
| 836 | + } |
|
| 837 | + //$last_exec['radarvirtueljson'] = time(); |
|
| 838 | + $last_exec[$id]['last'] = time(); |
|
| 839 | + //} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) { |
|
| 840 | + } elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 841 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 842 | + $buffer = $Common->getData($value['host'].'?'.time()); |
|
| 843 | + $all_data = json_decode(utf8_encode($buffer),true); |
|
| 844 | 844 | |
| 845 | - if (isset($all_data['pireps'])) { |
|
| 845 | + if (isset($all_data['pireps'])) { |
|
| 846 | 846 | $reset = 0; |
| 847 | - foreach ($all_data['pireps'] as $line) { |
|
| 848 | - $data = array(); |
|
| 849 | - $data['id'] = $line['id']; |
|
| 850 | - $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
| 851 | - $data['ident'] = $line['callsign']; // ident |
|
| 852 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
| 853 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
| 854 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
| 855 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
| 856 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
| 857 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 858 | - $data['latitude'] = $line['lat']; // lat |
|
| 859 | - $data['longitude'] = $line['lon']; // long |
|
| 860 | - //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
| 861 | - //$data['squawk'] = $line['squawk']; // squawk |
|
| 862 | - //$data['emergency'] = ''; // emergency |
|
| 863 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
| 864 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
| 865 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
| 866 | - //$data['arrival_airport_time'] = $line['arrtime']; |
|
| 867 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
| 868 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
| 869 | - if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
| 870 | - else $data['info'] = ''; |
|
| 871 | - $data['format_source'] = 'pireps'; |
|
| 872 | - $data['id_source'] = $id_source; |
|
| 873 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 874 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 875 | - if ($line['icon'] == 'plane') { |
|
| 847 | + foreach ($all_data['pireps'] as $line) { |
|
| 848 | + $data = array(); |
|
| 849 | + $data['id'] = $line['id']; |
|
| 850 | + $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
| 851 | + $data['ident'] = $line['callsign']; // ident |
|
| 852 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
| 853 | + if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
| 854 | + if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
| 855 | + if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
| 856 | + if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
| 857 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 858 | + $data['latitude'] = $line['lat']; // lat |
|
| 859 | + $data['longitude'] = $line['lon']; // long |
|
| 860 | + //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
| 861 | + //$data['squawk'] = $line['squawk']; // squawk |
|
| 862 | + //$data['emergency'] = ''; // emergency |
|
| 863 | + if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
| 864 | + if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
| 865 | + if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
| 866 | + //$data['arrival_airport_time'] = $line['arrtime']; |
|
| 867 | + if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
| 868 | + if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
| 869 | + if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
| 870 | + else $data['info'] = ''; |
|
| 871 | + $data['format_source'] = 'pireps'; |
|
| 872 | + $data['id_source'] = $id_source; |
|
| 873 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 874 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 875 | + if ($line['icon'] == 'plane') { |
|
| 876 | 876 | $SI->add($data); |
| 877 | - // print_r($data); |
|
| 878 | - } elseif ($line['icon'] == 'ct') { |
|
| 877 | + // print_r($data); |
|
| 878 | + } elseif ($line['icon'] == 'ct') { |
|
| 879 | 879 | $data['info'] = str_replace('^§','<br />',$data['info']); |
| 880 | 880 | $data['info'] = str_replace('&sect;','',$data['info']); |
| 881 | 881 | $typec = substr($data['ident'],-3); |
@@ -890,190 +890,190 @@ discard block |
||
| 890 | 890 | elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
| 891 | 891 | else $data['type'] = 'Observer'; |
| 892 | 892 | 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']); |
| 893 | - } |
|
| 894 | - unset($data); |
|
| 893 | + } |
|
| 894 | + unset($data); |
|
| 895 | 895 | } |
| 896 | - } |
|
| 897 | - //$last_exec['pirepsjson'] = time(); |
|
| 898 | - $last_exec[$id]['last'] = time(); |
|
| 899 | - //} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
|
| 900 | - } elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 901 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 902 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 903 | - $buffer = $Common->getData($value['host']); |
|
| 904 | - $all_data = json_decode($buffer,true); |
|
| 905 | - if ($buffer != '' && is_array($all_data)) { |
|
| 896 | + } |
|
| 897 | + //$last_exec['pirepsjson'] = time(); |
|
| 898 | + $last_exec[$id]['last'] = time(); |
|
| 899 | + //} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
|
| 900 | + } elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 901 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 902 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 903 | + $buffer = $Common->getData($value['host']); |
|
| 904 | + $all_data = json_decode($buffer,true); |
|
| 905 | + if ($buffer != '' && is_array($all_data)) { |
|
| 906 | 906 | $reset = 0; |
| 907 | 907 | foreach ($all_data as $line) { |
| 908 | - $data = array(); |
|
| 909 | - //$data['id'] = $line['id']; // id not usable |
|
| 910 | - if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
| 911 | - $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 912 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
| 913 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
| 914 | - $data['ident'] = $line['flightnum']; // ident |
|
| 915 | - $data['altitude'] = $line['alt']; // altitude |
|
| 916 | - $data['speed'] = $line['gs']; // speed |
|
| 917 | - $data['heading'] = $line['heading']; // heading |
|
| 918 | - $data['latitude'] = $line['lat']; // lat |
|
| 919 | - $data['longitude'] = $line['lng']; // long |
|
| 920 | - $data['verticalrate'] = ''; // verticale rate |
|
| 921 | - $data['squawk'] = ''; // squawk |
|
| 922 | - $data['emergency'] = ''; // emergency |
|
| 923 | - //$data['datetime'] = $line['lastupdate']; |
|
| 924 | - $data['last_update'] = $line['lastupdate']; |
|
| 925 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 926 | - $data['departure_airport_icao'] = $line['depicao']; |
|
| 927 | - $data['departure_airport_time'] = $line['deptime']; |
|
| 928 | - $data['arrival_airport_icao'] = $line['arricao']; |
|
| 929 | - $data['arrival_airport_time'] = $line['arrtime']; |
|
| 930 | - $data['registration'] = $line['aircraft']; |
|
| 931 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 932 | - if (isset($line['aircraftname'])) { |
|
| 908 | + $data = array(); |
|
| 909 | + //$data['id'] = $line['id']; // id not usable |
|
| 910 | + if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
| 911 | + $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 912 | + if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
| 913 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
| 914 | + $data['ident'] = $line['flightnum']; // ident |
|
| 915 | + $data['altitude'] = $line['alt']; // altitude |
|
| 916 | + $data['speed'] = $line['gs']; // speed |
|
| 917 | + $data['heading'] = $line['heading']; // heading |
|
| 918 | + $data['latitude'] = $line['lat']; // lat |
|
| 919 | + $data['longitude'] = $line['lng']; // long |
|
| 920 | + $data['verticalrate'] = ''; // verticale rate |
|
| 921 | + $data['squawk'] = ''; // squawk |
|
| 922 | + $data['emergency'] = ''; // emergency |
|
| 923 | + //$data['datetime'] = $line['lastupdate']; |
|
| 924 | + $data['last_update'] = $line['lastupdate']; |
|
| 925 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 926 | + $data['departure_airport_icao'] = $line['depicao']; |
|
| 927 | + $data['departure_airport_time'] = $line['deptime']; |
|
| 928 | + $data['arrival_airport_icao'] = $line['arricao']; |
|
| 929 | + $data['arrival_airport_time'] = $line['arrtime']; |
|
| 930 | + $data['registration'] = $line['aircraft']; |
|
| 931 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 932 | + if (isset($line['aircraftname'])) { |
|
| 933 | 933 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
| 934 | 934 | $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
| 935 | - $aircraft_data = explode('-',$line['aircraftname']); |
|
| 936 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) $data['aircraft_icao'] = $aircraft_data[0]; |
|
| 937 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 938 | - else { |
|
| 939 | - $aircraft_data = explode(' ',$line['aircraftname']); |
|
| 940 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 941 | - else $data['aircraft_icao'] = $line['aircraftname']; |
|
| 942 | - } |
|
| 943 | - } |
|
| 944 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
| 945 | - $data['id_source'] = $id_source; |
|
| 946 | - $data['format_source'] = 'phpvmacars'; |
|
| 947 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 948 | - $SI->add($data); |
|
| 949 | - unset($data); |
|
| 935 | + $aircraft_data = explode('-',$line['aircraftname']); |
|
| 936 | + if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) $data['aircraft_icao'] = $aircraft_data[0]; |
|
| 937 | + elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 938 | + else { |
|
| 939 | + $aircraft_data = explode(' ',$line['aircraftname']); |
|
| 940 | + if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 941 | + else $data['aircraft_icao'] = $line['aircraftname']; |
|
| 942 | + } |
|
| 943 | + } |
|
| 944 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
| 945 | + $data['id_source'] = $id_source; |
|
| 946 | + $data['format_source'] = 'phpvmacars'; |
|
| 947 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 948 | + $SI->add($data); |
|
| 949 | + unset($data); |
|
| 950 | 950 | } |
| 951 | 951 | if ($globalDebug) echo 'No more data...'."\n"; |
| 952 | 952 | unset($buffer); |
| 953 | 953 | unset($all_data); |
| 954 | - } |
|
| 955 | - //$last_exec['phpvmacars'] = time(); |
|
| 956 | - $last_exec[$id]['last'] = time(); |
|
| 957 | - } elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 958 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 959 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 960 | - $buffer = $Common->getData($value['host']); |
|
| 961 | - $all_data = json_decode($buffer,true); |
|
| 962 | - if ($buffer != '' && is_array($all_data)) { |
|
| 954 | + } |
|
| 955 | + //$last_exec['phpvmacars'] = time(); |
|
| 956 | + $last_exec[$id]['last'] = time(); |
|
| 957 | + } elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 958 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 959 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 960 | + $buffer = $Common->getData($value['host']); |
|
| 961 | + $all_data = json_decode($buffer,true); |
|
| 962 | + if ($buffer != '' && is_array($all_data)) { |
|
| 963 | 963 | $reset = 0; |
| 964 | 964 | foreach ($all_data as $line) { |
| 965 | - $data = array(); |
|
| 966 | - //$data['id'] = $line['id']; // id not usable |
|
| 967 | - $data['id'] = trim($line['flight_id']); |
|
| 968 | - $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 969 | - $data['pilot_name'] = $line['pilot_name']; |
|
| 970 | - $data['pilot_id'] = $line['pilot_id']; |
|
| 971 | - $data['ident'] = trim($line['callsign']); // ident |
|
| 972 | - $data['altitude'] = $line['altitude']; // altitude |
|
| 973 | - $data['speed'] = $line['gs']; // speed |
|
| 974 | - $data['heading'] = $line['heading']; // heading |
|
| 975 | - $data['latitude'] = $line['latitude']; // lat |
|
| 976 | - $data['longitude'] = $line['longitude']; // long |
|
| 977 | - $data['verticalrate'] = ''; // verticale rate |
|
| 978 | - $data['squawk'] = ''; // squawk |
|
| 979 | - $data['emergency'] = ''; // emergency |
|
| 980 | - //$data['datetime'] = $line['lastupdate']; |
|
| 981 | - $data['last_update'] = $line['last_update']; |
|
| 982 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 983 | - $data['departure_airport_icao'] = $line['departure']; |
|
| 984 | - //$data['departure_airport_time'] = $line['departure_time']; |
|
| 985 | - $data['arrival_airport_icao'] = $line['arrival']; |
|
| 986 | - //$data['arrival_airport_time'] = $line['arrival_time']; |
|
| 987 | - //$data['registration'] = $line['aircraft']; |
|
| 988 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 989 | - $data['aircraft_icao'] = $line['plane_type']; |
|
| 990 | - $data['id_source'] = $id_source; |
|
| 991 | - $data['format_source'] = 'vam'; |
|
| 992 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 993 | - $SI->add($data); |
|
| 994 | - unset($data); |
|
| 965 | + $data = array(); |
|
| 966 | + //$data['id'] = $line['id']; // id not usable |
|
| 967 | + $data['id'] = trim($line['flight_id']); |
|
| 968 | + $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 969 | + $data['pilot_name'] = $line['pilot_name']; |
|
| 970 | + $data['pilot_id'] = $line['pilot_id']; |
|
| 971 | + $data['ident'] = trim($line['callsign']); // ident |
|
| 972 | + $data['altitude'] = $line['altitude']; // altitude |
|
| 973 | + $data['speed'] = $line['gs']; // speed |
|
| 974 | + $data['heading'] = $line['heading']; // heading |
|
| 975 | + $data['latitude'] = $line['latitude']; // lat |
|
| 976 | + $data['longitude'] = $line['longitude']; // long |
|
| 977 | + $data['verticalrate'] = ''; // verticale rate |
|
| 978 | + $data['squawk'] = ''; // squawk |
|
| 979 | + $data['emergency'] = ''; // emergency |
|
| 980 | + //$data['datetime'] = $line['lastupdate']; |
|
| 981 | + $data['last_update'] = $line['last_update']; |
|
| 982 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 983 | + $data['departure_airport_icao'] = $line['departure']; |
|
| 984 | + //$data['departure_airport_time'] = $line['departure_time']; |
|
| 985 | + $data['arrival_airport_icao'] = $line['arrival']; |
|
| 986 | + //$data['arrival_airport_time'] = $line['arrival_time']; |
|
| 987 | + //$data['registration'] = $line['aircraft']; |
|
| 988 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 989 | + $data['aircraft_icao'] = $line['plane_type']; |
|
| 990 | + $data['id_source'] = $id_source; |
|
| 991 | + $data['format_source'] = 'vam'; |
|
| 992 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 993 | + $SI->add($data); |
|
| 994 | + unset($data); |
|
| 995 | 995 | } |
| 996 | 996 | if ($globalDebug) echo 'No more data...'."\n"; |
| 997 | 997 | unset($buffer); |
| 998 | 998 | unset($all_data); |
| 999 | - } |
|
| 1000 | - //$last_exec['phpvmacars'] = time(); |
|
| 1001 | - $last_exec[$id]['last'] = time(); |
|
| 999 | + } |
|
| 1000 | + //$last_exec['phpvmacars'] = time(); |
|
| 1001 | + $last_exec[$id]['last'] = time(); |
|
| 1002 | 1002 | //} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') { |
| 1003 | 1003 | } elseif ($value['format'] == 'sbs' || $value['format'] == 'tsv' || $value['format'] == 'raw' || $value['format'] == 'aprs' || $value['format'] == 'beast' || $value['format'] == 'flightgearmp' || $value['format'] == 'flightgearsp' || $value['format'] == 'acars' || $value['format'] == 'acarssbs3' || $value['format'] == 'ais' || $value['format'] == 'vrstcp') { |
| 1004 | - if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
| 1005 | - //$last_exec[$id]['last'] = time(); |
|
| 1004 | + if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
| 1005 | + //$last_exec[$id]['last'] = time(); |
|
| 1006 | 1006 | |
| 1007 | - //$read = array( $sockets[$id] ); |
|
| 1008 | - $read = $sockets; |
|
| 1009 | - $write = NULL; |
|
| 1010 | - $e = NULL; |
|
| 1011 | - $n = socket_select($read, $write, $e, $timeout); |
|
| 1012 | - if ($e != NULL) var_dump($e); |
|
| 1013 | - if ($n > 0) { |
|
| 1007 | + //$read = array( $sockets[$id] ); |
|
| 1008 | + $read = $sockets; |
|
| 1009 | + $write = NULL; |
|
| 1010 | + $e = NULL; |
|
| 1011 | + $n = socket_select($read, $write, $e, $timeout); |
|
| 1012 | + if ($e != NULL) var_dump($e); |
|
| 1013 | + if ($n > 0) { |
|
| 1014 | 1014 | $reset = 0; |
| 1015 | 1015 | foreach ($read as $nb => $r) { |
| 1016 | - //$value = $formats[$nb]; |
|
| 1017 | - $format = $globalSources[$nb]['format']; |
|
| 1018 | - if ($format == 'sbs' || $format == 'aprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3' || $format == 'vrstcp') { |
|
| 1019 | - $buffer = socket_read($r, 6000,PHP_NORMAL_READ); |
|
| 1020 | - } else { |
|
| 1021 | - $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); |
|
| 1022 | - } |
|
| 1023 | - //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
| 1024 | - //echo $buffer."\n"; |
|
| 1025 | - // lets play nice and handle signals such as ctrl-c/kill properly |
|
| 1026 | - //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
| 1027 | - $error = false; |
|
| 1028 | - //$SI::del(); |
|
| 1029 | - if ($format == 'vrstcp') { |
|
| 1016 | + //$value = $formats[$nb]; |
|
| 1017 | + $format = $globalSources[$nb]['format']; |
|
| 1018 | + if ($format == 'sbs' || $format == 'aprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3' || $format == 'vrstcp') { |
|
| 1019 | + $buffer = socket_read($r, 6000,PHP_NORMAL_READ); |
|
| 1020 | + } else { |
|
| 1021 | + $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); |
|
| 1022 | + } |
|
| 1023 | + //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
| 1024 | + //echo $buffer."\n"; |
|
| 1025 | + // lets play nice and handle signals such as ctrl-c/kill properly |
|
| 1026 | + //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
| 1027 | + $error = false; |
|
| 1028 | + //$SI::del(); |
|
| 1029 | + if ($format == 'vrstcp') { |
|
| 1030 | 1030 | $buffer = explode('},{',$buffer); |
| 1031 | - } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
| 1032 | - // SBS format is CSV format |
|
| 1033 | - if ($buffer !== FALSE && $buffer != '') { |
|
| 1031 | + } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
| 1032 | + // SBS format is CSV format |
|
| 1033 | + if ($buffer !== FALSE && $buffer != '') { |
|
| 1034 | 1034 | $tt[$format] = 0; |
| 1035 | 1035 | if ($format == 'acarssbs3') { |
| 1036 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 1037 | - $ACARS->add(trim($buffer)); |
|
| 1038 | - $ACARS->deleteLiveAcarsData(); |
|
| 1036 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 1037 | + $ACARS->add(trim($buffer)); |
|
| 1038 | + $ACARS->deleteLiveAcarsData(); |
|
| 1039 | 1039 | } elseif ($format == 'raw') { |
| 1040 | - // AVR format |
|
| 1041 | - $data = $SBS->parse($buffer); |
|
| 1042 | - if (is_array($data)) { |
|
| 1040 | + // AVR format |
|
| 1041 | + $data = $SBS->parse($buffer); |
|
| 1042 | + if (is_array($data)) { |
|
| 1043 | 1043 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1044 | 1044 | $data['format_source'] = 'raw'; |
| 1045 | 1045 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
| 1046 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1047 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 1048 | - } |
|
| 1049 | - } elseif ($format == 'ais') { |
|
| 1050 | - $ais_data = $AIS->parse_line(trim($buffer)); |
|
| 1051 | - $data = array(); |
|
| 1052 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 1053 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
| 1054 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 1055 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 1056 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 1057 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 1058 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 1059 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 1060 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 1061 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 1062 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
| 1063 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 1046 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1047 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 1048 | + } |
|
| 1049 | + } elseif ($format == 'ais') { |
|
| 1050 | + $ais_data = $AIS->parse_line(trim($buffer)); |
|
| 1051 | + $data = array(); |
|
| 1052 | + if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 1053 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
| 1054 | + if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 1055 | + if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 1056 | + if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 1057 | + if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 1058 | + if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 1059 | + if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 1060 | + if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 1061 | + if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 1062 | + if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
| 1063 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 1064 | 1064 | |
| 1065 | - if (isset($ais_data['timestamp'])) { |
|
| 1065 | + if (isset($ais_data['timestamp'])) { |
|
| 1066 | 1066 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
| 1067 | - } else { |
|
| 1067 | + } else { |
|
| 1068 | 1068 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1069 | - } |
|
| 1070 | - $data['format_source'] = 'aisnmea'; |
|
| 1071 | - $data['id_source'] = $id_source; |
|
| 1072 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
| 1073 | - unset($data); |
|
| 1074 | - } elseif ($format == 'flightgearsp') { |
|
| 1075 | - //echo $buffer."\n"; |
|
| 1076 | - if (strlen($buffer) > 5) { |
|
| 1069 | + } |
|
| 1070 | + $data['format_source'] = 'aisnmea'; |
|
| 1071 | + $data['id_source'] = $id_source; |
|
| 1072 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
| 1073 | + unset($data); |
|
| 1074 | + } elseif ($format == 'flightgearsp') { |
|
| 1075 | + //echo $buffer."\n"; |
|
| 1076 | + if (strlen($buffer) > 5) { |
|
| 1077 | 1077 | $line = explode(',',$buffer); |
| 1078 | 1078 | $data = array(); |
| 1079 | 1079 | //XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p |
@@ -1089,37 +1089,37 @@ discard block |
||
| 1089 | 1089 | $data['format_source'] = 'flightgearsp'; |
| 1090 | 1090 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
| 1091 | 1091 | $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
| 1092 | - } |
|
| 1093 | - } elseif ($format == 'acars') { |
|
| 1094 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 1095 | - $ACARS->add(trim($buffer)); |
|
| 1096 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
| 1097 | - $ACARS->deleteLiveAcarsData(); |
|
| 1092 | + } |
|
| 1093 | + } elseif ($format == 'acars') { |
|
| 1094 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 1095 | + $ACARS->add(trim($buffer)); |
|
| 1096 | + socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
| 1097 | + $ACARS->deleteLiveAcarsData(); |
|
| 1098 | 1098 | } elseif ($format == 'flightgearmp') { |
| 1099 | - if (substr($buffer,0,1) != '#') { |
|
| 1099 | + if (substr($buffer,0,1) != '#') { |
|
| 1100 | 1100 | $data = array(); |
| 1101 | 1101 | //echo $buffer."\n"; |
| 1102 | 1102 | $line = explode(' ',$buffer); |
| 1103 | 1103 | if (count($line) == 11) { |
| 1104 | - $userserver = explode('@',$line[0]); |
|
| 1105 | - $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
| 1106 | - $data['ident'] = $userserver[0]; |
|
| 1107 | - $data['registration'] = $userserver[0]; |
|
| 1108 | - $data['latitude'] = $line[4]; |
|
| 1109 | - $data['longitude'] = $line[5]; |
|
| 1110 | - $data['altitude'] = $line[6]; |
|
| 1111 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1112 | - $aircraft_type = $line[10]; |
|
| 1113 | - $aircraft_type = preg_split(':/:',$aircraft_type); |
|
| 1114 | - $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
| 1115 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 1104 | + $userserver = explode('@',$line[0]); |
|
| 1105 | + $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
| 1106 | + $data['ident'] = $userserver[0]; |
|
| 1107 | + $data['registration'] = $userserver[0]; |
|
| 1108 | + $data['latitude'] = $line[4]; |
|
| 1109 | + $data['longitude'] = $line[5]; |
|
| 1110 | + $data['altitude'] = $line[6]; |
|
| 1111 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1112 | + $aircraft_type = $line[10]; |
|
| 1113 | + $aircraft_type = preg_split(':/:',$aircraft_type); |
|
| 1114 | + $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
| 1115 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 1116 | + } |
|
| 1116 | 1117 | } |
| 1117 | - } |
|
| 1118 | 1118 | } elseif ($format == 'beast') { |
| 1119 | - echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
| 1120 | - die; |
|
| 1119 | + echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
| 1120 | + die; |
|
| 1121 | 1121 | } elseif ($format == 'vrstcp') { |
| 1122 | - foreach($buffer as $all_data) { |
|
| 1122 | + foreach($buffer as $all_data) { |
|
| 1123 | 1123 | $line = json_decode('{'.$all_data.'}',true); |
| 1124 | 1124 | $data = array(); |
| 1125 | 1125 | if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
@@ -1139,100 +1139,100 @@ discard block |
||
| 1139 | 1139 | */ |
| 1140 | 1140 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1141 | 1141 | if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
| 1142 | - $data['format_source'] = 'vrstcp'; |
|
| 1142 | + $data['format_source'] = 'vrstcp'; |
|
| 1143 | 1143 | $data['id_source'] = $id_source; |
| 1144 | 1144 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
| 1145 | 1145 | if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
| 1146 | 1146 | unset($data); |
| 1147 | - } |
|
| 1147 | + } |
|
| 1148 | 1148 | } elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') { |
| 1149 | - $line = explode("\t", $buffer); |
|
| 1150 | - for($k = 0; $k < count($line); $k=$k+2) { |
|
| 1149 | + $line = explode("\t", $buffer); |
|
| 1150 | + for($k = 0; $k < count($line); $k=$k+2) { |
|
| 1151 | 1151 | $key = $line[$k]; |
| 1152 | - $lined[$key] = $line[$k+1]; |
|
| 1153 | - } |
|
| 1154 | - if (count($lined) > 3) { |
|
| 1155 | - $data['hex'] = $lined['hexid']; |
|
| 1156 | - //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
| 1157 | - $data['datetime'] = date('Y-m-d H:i:s');; |
|
| 1158 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
| 1159 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
| 1160 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
| 1161 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
| 1162 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
| 1163 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
| 1164 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
| 1165 | - $data['id_source'] = $id_source; |
|
| 1166 | - $data['format_source'] = 'tsv'; |
|
| 1167 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1168 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1169 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 1170 | - unset($lined); |
|
| 1171 | - unset($data); |
|
| 1172 | - } else $error = true; |
|
| 1152 | + $lined[$key] = $line[$k+1]; |
|
| 1153 | + } |
|
| 1154 | + if (count($lined) > 3) { |
|
| 1155 | + $data['hex'] = $lined['hexid']; |
|
| 1156 | + //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
| 1157 | + $data['datetime'] = date('Y-m-d H:i:s');; |
|
| 1158 | + if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
| 1159 | + if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
| 1160 | + if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
| 1161 | + if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
| 1162 | + if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
| 1163 | + if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
| 1164 | + if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
| 1165 | + $data['id_source'] = $id_source; |
|
| 1166 | + $data['format_source'] = 'tsv'; |
|
| 1167 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1168 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1169 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 1170 | + unset($lined); |
|
| 1171 | + unset($data); |
|
| 1172 | + } else $error = true; |
|
| 1173 | 1173 | } elseif ($format == 'aprs' && $use_aprs) { |
| 1174 | - if ($aprs_connect == 0) { |
|
| 1174 | + if ($aprs_connect == 0) { |
|
| 1175 | 1175 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
| 1176 | 1176 | $aprs_connect = 1; |
| 1177 | - } |
|
| 1177 | + } |
|
| 1178 | 1178 | |
| 1179 | - if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
| 1179 | + if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
| 1180 | 1180 | $aprs_last_tx = time(); |
| 1181 | 1181 | $data_aprs = "# Keep alive"; |
| 1182 | 1182 | $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
| 1183 | - } |
|
| 1183 | + } |
|
| 1184 | 1184 | |
| 1185 | - //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
| 1186 | - //echo 'APRS data : '.$buffer."\n"; |
|
| 1187 | - $buffer = str_replace('APRS <- ','',$buffer); |
|
| 1188 | - $buffer = str_replace('APRS -> ','',$buffer); |
|
| 1189 | - //echo $buffer."\n"; |
|
| 1190 | - if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
| 1185 | + //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
| 1186 | + //echo 'APRS data : '.$buffer."\n"; |
|
| 1187 | + $buffer = str_replace('APRS <- ','',$buffer); |
|
| 1188 | + $buffer = str_replace('APRS -> ','',$buffer); |
|
| 1189 | + //echo $buffer."\n"; |
|
| 1190 | + if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
| 1191 | 1191 | $line = $APRS->parse($buffer); |
| 1192 | 1192 | //print_r($line); |
| 1193 | 1193 | //if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) { |
| 1194 | 1194 | if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']))) { |
| 1195 | - $aprs_last_tx = time(); |
|
| 1196 | - $data = array(); |
|
| 1197 | - //print_r($line); |
|
| 1198 | - if (isset($line['address'])) $data['hex'] = $line['address']; |
|
| 1199 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
| 1200 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1201 | - //$data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1202 | - if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
| 1203 | - $data['latitude'] = $line['latitude']; |
|
| 1204 | - $data['longitude'] = $line['longitude']; |
|
| 1205 | - //$data['verticalrate'] = $line[16]; |
|
| 1206 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
| 1207 | - else $data['speed'] = 0; |
|
| 1208 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
| 1209 | - if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
| 1210 | - if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
| 1211 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
| 1212 | - //else $data['heading'] = 0; |
|
| 1213 | - if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
| 1214 | - if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) $data['noarchive'] = true; |
|
| 1215 | - $data['id_source'] = $id_source; |
|
| 1216 | - if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
| 1217 | - else $data['format_source'] = 'aprs'; |
|
| 1218 | - $data['source_name'] = $line['source']; |
|
| 1219 | - if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
| 1220 | - else $data['source_type'] = 'flarm'; |
|
| 1221 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1222 | - $currentdate = date('Y-m-d H:i:s'); |
|
| 1223 | - $aprsdate = strtotime($data['datetime']); |
|
| 1224 | - // Accept data if time <= system time + 20s |
|
| 1225 | - 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'])))) { |
|
| 1195 | + $aprs_last_tx = time(); |
|
| 1196 | + $data = array(); |
|
| 1197 | + //print_r($line); |
|
| 1198 | + if (isset($line['address'])) $data['hex'] = $line['address']; |
|
| 1199 | + if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
| 1200 | + else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1201 | + //$data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1202 | + if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
| 1203 | + $data['latitude'] = $line['latitude']; |
|
| 1204 | + $data['longitude'] = $line['longitude']; |
|
| 1205 | + //$data['verticalrate'] = $line[16]; |
|
| 1206 | + if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
| 1207 | + else $data['speed'] = 0; |
|
| 1208 | + if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
| 1209 | + if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
| 1210 | + if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
| 1211 | + if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
| 1212 | + //else $data['heading'] = 0; |
|
| 1213 | + if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
| 1214 | + if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) $data['noarchive'] = true; |
|
| 1215 | + $data['id_source'] = $id_source; |
|
| 1216 | + if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
| 1217 | + else $data['format_source'] = 'aprs'; |
|
| 1218 | + $data['source_name'] = $line['source']; |
|
| 1219 | + if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
| 1220 | + else $data['source_type'] = 'flarm'; |
|
| 1221 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1222 | + $currentdate = date('Y-m-d H:i:s'); |
|
| 1223 | + $aprsdate = strtotime($data['datetime']); |
|
| 1224 | + // Accept data if time <= system time + 20s |
|
| 1225 | + 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'])))) { |
|
| 1226 | 1226 | $send = $SI->add($data); |
| 1227 | - } elseif (isset($line['stealth'])) { |
|
| 1227 | + } elseif (isset($line['stealth'])) { |
|
| 1228 | 1228 | if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
| 1229 | 1229 | else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
| 1230 | - //} elseif (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' || $line['symbol'] == 'Police' || $line['symbol'] == 'Bike' || $line['symbol'] == 'Jogger' || $line['symbol'] == 'Bus' || $line['symbol'] == 'Jeep' || $line['symbol'] == 'Recreational Vehicle' || $line['symbol'] == 'Yacht (Sail)' || $line['symbol'] == 'Ship (Power Boat)' || $line['symbol'] == 'Firetruck' || $line['symbol'] == 'Balloon' || $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) { |
|
| 1231 | - } 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') { |
|
| 1230 | + //} elseif (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' || $line['symbol'] == 'Police' || $line['symbol'] == 'Bike' || $line['symbol'] == 'Jogger' || $line['symbol'] == 'Bus' || $line['symbol'] == 'Jeep' || $line['symbol'] == 'Recreational Vehicle' || $line['symbol'] == 'Yacht (Sail)' || $line['symbol'] == 'Ship (Power Boat)' || $line['symbol'] == 'Firetruck' || $line['symbol'] == 'Balloon' || $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) { |
|
| 1231 | + } 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') { |
|
| 1232 | 1232 | //echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n"; |
| 1233 | 1233 | if (isset($globalTracker) && $globalTracker) $send = $TI->add($data); |
| 1234 | - } |
|
| 1235 | - unset($data); |
|
| 1234 | + } |
|
| 1235 | + unset($data); |
|
| 1236 | 1236 | } |
| 1237 | 1237 | elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') { |
| 1238 | 1238 | echo '!! Weather Station not yet supported'."\n"; |
@@ -1242,12 +1242,12 @@ discard block |
||
| 1242 | 1242 | } |
| 1243 | 1243 | //elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n"; |
| 1244 | 1244 | //elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n"; |
| 1245 | - } |
|
| 1245 | + } |
|
| 1246 | 1246 | } else { |
| 1247 | - $line = explode(',', $buffer); |
|
| 1248 | - if (count($line) > 20) { |
|
| 1249 | - $data['hex'] = $line[4]; |
|
| 1250 | - /* |
|
| 1247 | + $line = explode(',', $buffer); |
|
| 1248 | + if (count($line) > 20) { |
|
| 1249 | + $data['hex'] = $line[4]; |
|
| 1250 | + /* |
|
| 1251 | 1251 | $data['datetime'] = $line[6].' '.$line[7]; |
| 1252 | 1252 | date_default_timezone_set($globalTimezone); |
| 1253 | 1253 | $datetime = new DateTime($data['datetime']); |
@@ -1255,29 +1255,29 @@ discard block |
||
| 1255 | 1255 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
| 1256 | 1256 | date_default_timezone_set('UTC'); |
| 1257 | 1257 | */ |
| 1258 | - // Force datetime to current UTC datetime |
|
| 1259 | - date_default_timezone_set('UTC'); |
|
| 1260 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1261 | - $data['ident'] = trim($line[10]); |
|
| 1262 | - $data['latitude'] = $line[14]; |
|
| 1263 | - $data['longitude'] = $line[15]; |
|
| 1264 | - $data['verticalrate'] = $line[16]; |
|
| 1265 | - $data['emergency'] = $line[20]; |
|
| 1266 | - $data['speed'] = $line[12]; |
|
| 1267 | - $data['squawk'] = $line[17]; |
|
| 1268 | - $data['altitude'] = $line[11]; |
|
| 1269 | - $data['heading'] = $line[13]; |
|
| 1270 | - $data['ground'] = $line[21]; |
|
| 1271 | - $data['emergency'] = $line[19]; |
|
| 1272 | - $data['format_source'] = 'sbs'; |
|
| 1258 | + // Force datetime to current UTC datetime |
|
| 1259 | + date_default_timezone_set('UTC'); |
|
| 1260 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1261 | + $data['ident'] = trim($line[10]); |
|
| 1262 | + $data['latitude'] = $line[14]; |
|
| 1263 | + $data['longitude'] = $line[15]; |
|
| 1264 | + $data['verticalrate'] = $line[16]; |
|
| 1265 | + $data['emergency'] = $line[20]; |
|
| 1266 | + $data['speed'] = $line[12]; |
|
| 1267 | + $data['squawk'] = $line[17]; |
|
| 1268 | + $data['altitude'] = $line[11]; |
|
| 1269 | + $data['heading'] = $line[13]; |
|
| 1270 | + $data['ground'] = $line[21]; |
|
| 1271 | + $data['emergency'] = $line[19]; |
|
| 1272 | + $data['format_source'] = 'sbs'; |
|
| 1273 | 1273 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
| 1274 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1275 | - $data['id_source'] = $id_source; |
|
| 1276 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
| 1277 | - else $error = true; |
|
| 1278 | - unset($data); |
|
| 1279 | - } else $error = true; |
|
| 1280 | - if ($error) { |
|
| 1274 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1275 | + $data['id_source'] = $id_source; |
|
| 1276 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
| 1277 | + else $error = true; |
|
| 1278 | + unset($data); |
|
| 1279 | + } else $error = true; |
|
| 1280 | + if ($error) { |
|
| 1281 | 1281 | if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { |
| 1282 | 1282 | if ($globalDebug) echo "Not a message. Ignoring... \n"; |
| 1283 | 1283 | } else { |
@@ -1293,13 +1293,13 @@ discard block |
||
| 1293 | 1293 | connect_all($sourceer); |
| 1294 | 1294 | $sourceer = array(); |
| 1295 | 1295 | } |
| 1296 | - } |
|
| 1296 | + } |
|
| 1297 | 1297 | } |
| 1298 | 1298 | // Sleep for xxx microseconds |
| 1299 | 1299 | if (isset($globalSBSSleep)) usleep($globalSBSSleep); |
| 1300 | - } else { |
|
| 1300 | + } else { |
|
| 1301 | 1301 | if ($format == 'flightgearmp') { |
| 1302 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
| 1302 | + if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
| 1303 | 1303 | //@socket_close($r); |
| 1304 | 1304 | sleep($globalMinFetch); |
| 1305 | 1305 | $sourcefg[$nb] = $globalSources[$nb]; |
@@ -1308,9 +1308,9 @@ discard block |
||
| 1308 | 1308 | break; |
| 1309 | 1309 | |
| 1310 | 1310 | } elseif ($format != 'acars' && $format != 'flightgearsp') { |
| 1311 | - if (isset($tt[$format])) $tt[$format]++; |
|
| 1312 | - else $tt[$format] = 0; |
|
| 1313 | - if ($tt[$format] > 30) { |
|
| 1311 | + if (isset($tt[$format])) $tt[$format]++; |
|
| 1312 | + else $tt[$format] = 0; |
|
| 1313 | + if ($tt[$format] > 30) { |
|
| 1314 | 1314 | if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; |
| 1315 | 1315 | //@socket_close($r); |
| 1316 | 1316 | sleep(2); |
@@ -1321,23 +1321,23 @@ discard block |
||
| 1321 | 1321 | //connect_all($globalSources); |
| 1322 | 1322 | $tt[$format]=0; |
| 1323 | 1323 | break; |
| 1324 | - } |
|
| 1324 | + } |
|
| 1325 | + } |
|
| 1325 | 1326 | } |
| 1326 | - } |
|
| 1327 | 1327 | } |
| 1328 | - } else { |
|
| 1328 | + } else { |
|
| 1329 | 1329 | $error = socket_strerror(socket_last_error()); |
| 1330 | 1330 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
| 1331 | 1331 | if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
| 1332 | 1332 | if (isset($globalDebug)) echo "Restarting...\n"; |
| 1333 | 1333 | // Restart the script if possible |
| 1334 | 1334 | if (is_array($sockets)) { |
| 1335 | - if ($globalDebug) echo "Shutdown all sockets..."; |
|
| 1335 | + if ($globalDebug) echo "Shutdown all sockets..."; |
|
| 1336 | 1336 | |
| 1337 | - foreach ($sockets as $sock) { |
|
| 1337 | + foreach ($sockets as $sock) { |
|
| 1338 | 1338 | @socket_shutdown($sock,2); |
| 1339 | 1339 | @socket_close($sock); |
| 1340 | - } |
|
| 1340 | + } |
|
| 1341 | 1341 | |
| 1342 | 1342 | } |
| 1343 | 1343 | if ($globalDebug) echo "Restart all connections..."; |
@@ -1348,13 +1348,13 @@ discard block |
||
| 1348 | 1348 | if ($reset > 40) exit('Too many attempts...'); |
| 1349 | 1349 | connect_all($globalSources); |
| 1350 | 1350 | } |
| 1351 | - } |
|
| 1351 | + } |
|
| 1352 | 1352 | } |
| 1353 | 1353 | if ($globalDaemon === false) { |
| 1354 | - if ($globalDebug) echo 'Check all...'."\n"; |
|
| 1355 | - $SI->checkAll(); |
|
| 1354 | + if ($globalDebug) echo 'Check all...'."\n"; |
|
| 1355 | + $SI->checkAll(); |
|
| 1356 | + } |
|
| 1356 | 1357 | } |
| 1357 | - } |
|
| 1358 | 1358 | } |
| 1359 | 1359 | |
| 1360 | 1360 | ?> |
@@ -45,11 +45,11 @@ discard block |
||
| 45 | 45 | die; |
| 46 | 46 | } |
| 47 | 47 | //$hosts = array($globalSBS1Host.':'.$globalSBS1Port); |
| 48 | - $globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port); |
|
| 48 | + $globalSources[] = array('host' => $globalSBS1Host, 'port' => $globalSBS1Port); |
|
| 49 | 49 | } |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | -$options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::')); |
|
| 52 | +$options = getopt('s::', array('source::', 'server', 'nodaemon', 'idsource::', 'aprsserverssid::', 'aprsserverpass::')); |
|
| 53 | 53 | //if (isset($options['s'])) $hosts = array($options['s']); |
| 54 | 54 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
| 55 | 55 | if (isset($options['s'])) { |
@@ -67,27 +67,27 @@ discard block |
||
| 67 | 67 | else $id_source = 1; |
| 68 | 68 | if (isset($globalServer) && $globalServer) { |
| 69 | 69 | if ($globalDebug) echo "Using Server Mode\n"; |
| 70 | - $SI=new SpotterServer(); |
|
| 70 | + $SI = new SpotterServer(); |
|
| 71 | 71 | /* |
| 72 | 72 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
| 73 | 73 | $SI = new adsb2aprs(); |
| 74 | 74 | $SI->connect(); |
| 75 | 75 | */ |
| 76 | -} else $SI=new SpotterImport($Connection->db); |
|
| 76 | +} else $SI = new SpotterImport($Connection->db); |
|
| 77 | 77 | if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db); |
| 78 | 78 | if (isset($globalMarine) && $globalMarine) { |
| 79 | 79 | $AIS = new AIS(); |
| 80 | 80 | $MI = new MarineImport($Connection->db); |
| 81 | 81 | } |
| 82 | 82 | //$APRS=new APRS($Connection->db); |
| 83 | -$SBS=new SBS(); |
|
| 84 | -$ACARS=new ACARS($Connection->db); |
|
| 85 | -$Common=new Common(); |
|
| 83 | +$SBS = new SBS(); |
|
| 84 | +$ACARS = new ACARS($Connection->db); |
|
| 85 | +$Common = new Common(); |
|
| 86 | 86 | date_default_timezone_set('UTC'); |
| 87 | 87 | //$servertz = system('date +%Z'); |
| 88 | 88 | // signal handler - playing nice with sockets and dump1090 |
| 89 | 89 | if (function_exists('pcntl_fork')) { |
| 90 | - pcntl_signal(SIGINT, function() { |
|
| 90 | + pcntl_signal(SIGINT, function() { |
|
| 91 | 91 | global $sockets; |
| 92 | 92 | echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
| 93 | 93 | die("Bye!\n"); |
@@ -103,35 +103,35 @@ discard block |
||
| 103 | 103 | |
| 104 | 104 | function connect_all($hosts) { |
| 105 | 105 | //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
| 106 | - global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
| 106 | + global $sockets, $httpfeeds, $globalSources, $globalDebug, $aprs_connect, $last_exec, $globalSourcesRights, $use_aprs, $reset, $context; |
|
| 107 | 107 | $reset++; |
| 108 | 108 | if ($globalDebug) echo 'Connect to all...'."\n"; |
| 109 | 109 | foreach ($hosts as $id => $value) { |
| 110 | 110 | $host = $value['host']; |
| 111 | 111 | $globalSources[$id]['last_exec'] = 0; |
| 112 | 112 | // Here we check type of source(s) |
| 113 | - if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
|
| 114 | - if (preg_match('/deltadb.txt$/i',$host)) { |
|
| 113 | + if (filter_var($host, FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
|
| 114 | + if (preg_match('/deltadb.txt$/i', $host)) { |
|
| 115 | 115 | //$formats[$id] = 'deltadbtxt'; |
| 116 | 116 | $globalSources[$id]['format'] = 'deltadbtxt'; |
| 117 | 117 | //$last_exec['deltadbtxt'] = 0; |
| 118 | 118 | if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
| 119 | - } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
| 119 | + } else if (preg_match('/vatsim-data.txt$/i', $host)) { |
|
| 120 | 120 | //$formats[$id] = 'vatsimtxt'; |
| 121 | 121 | $globalSources[$id]['format'] = 'vatsimtxt'; |
| 122 | 122 | //$last_exec['vatsimtxt'] = 0; |
| 123 | 123 | if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
| 124 | - } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
| 124 | + } else if (preg_match('/aircraftlist.json$/i', $host)) { |
|
| 125 | 125 | //$formats[$id] = 'aircraftlistjson'; |
| 126 | 126 | $globalSources[$id]['format'] = 'aircraftlistjson'; |
| 127 | 127 | //$last_exec['aircraftlistjson'] = 0; |
| 128 | 128 | if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
| 129 | - } else if (preg_match('/opensky/i',$host)) { |
|
| 129 | + } else if (preg_match('/opensky/i', $host)) { |
|
| 130 | 130 | //$formats[$id] = 'aircraftlistjson'; |
| 131 | 131 | $globalSources[$id]['format'] = 'opensky'; |
| 132 | 132 | //$last_exec['aircraftlistjson'] = 0; |
| 133 | 133 | if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
| 134 | - } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) { |
|
| 134 | + } else if (preg_match('/radarvirtuel.com\/file.json$/i', $host)) { |
|
| 135 | 135 | //$formats[$id] = 'radarvirtueljson'; |
| 136 | 136 | $globalSources[$id]['format'] = 'radarvirtueljson'; |
| 137 | 137 | //$last_exec['radarvirtueljson'] = 0; |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
| 141 | 141 | exit(0); |
| 142 | 142 | } |
| 143 | - } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
| 143 | + } else if (preg_match('/planeUpdateFAA.php$/i', $host)) { |
|
| 144 | 144 | //$formats[$id] = 'planeupdatefaa'; |
| 145 | 145 | $globalSources[$id]['format'] = 'planeupdatefaa'; |
| 146 | 146 | //$last_exec['planeupdatefaa'] = 0; |
@@ -149,26 +149,26 @@ discard block |
||
| 149 | 149 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
| 150 | 150 | exit(0); |
| 151 | 151 | } |
| 152 | - } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
| 152 | + } else if (preg_match('/\/action.php\/acars\/data$/i', $host)) { |
|
| 153 | 153 | //$formats[$id] = 'phpvmacars'; |
| 154 | 154 | $globalSources[$id]['format'] = 'phpvmacars'; |
| 155 | 155 | //$last_exec['phpvmacars'] = 0; |
| 156 | 156 | if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
| 157 | - } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
| 157 | + } else if (preg_match('/VAM-json.php$/i', $host)) { |
|
| 158 | 158 | //$formats[$id] = 'phpvmacars'; |
| 159 | 159 | $globalSources[$id]['format'] = 'vam'; |
| 160 | 160 | if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
| 161 | - } else if (preg_match('/whazzup/i',$host)) { |
|
| 161 | + } else if (preg_match('/whazzup/i', $host)) { |
|
| 162 | 162 | //$formats[$id] = 'whazzup'; |
| 163 | 163 | $globalSources[$id]['format'] = 'whazzup'; |
| 164 | 164 | //$last_exec['whazzup'] = 0; |
| 165 | 165 | if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
| 166 | - } else if (preg_match('/recentpireps/i',$host)) { |
|
| 166 | + } else if (preg_match('/recentpireps/i', $host)) { |
|
| 167 | 167 | //$formats[$id] = 'pirepsjson'; |
| 168 | 168 | $globalSources[$id]['format'] = 'pirepsjson'; |
| 169 | 169 | //$last_exec['pirepsjson'] = 0; |
| 170 | 170 | if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
| 171 | - } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
| 171 | + } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i', $host)) { |
|
| 172 | 172 | //$formats[$id] = 'fr24json'; |
| 173 | 173 | $globalSources[$id]['format'] = 'fr24json'; |
| 174 | 174 | //$last_exec['fr24json'] = 0; |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
| 178 | 178 | exit(0); |
| 179 | 179 | } |
| 180 | - } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
| 180 | + } else if (preg_match(':myshiptracking.com/:i', $host)) { |
|
| 181 | 181 | //$formats[$id] = 'fr24json'; |
| 182 | 182 | $globalSources[$id]['format'] = 'myshiptracking'; |
| 183 | 183 | //$last_exec['fr24json'] = 0; |
@@ -187,22 +187,22 @@ discard block |
||
| 187 | 187 | exit(0); |
| 188 | 188 | } |
| 189 | 189 | //} else if (preg_match('/10001/',$host)) { |
| 190 | - } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
| 190 | + } else if (preg_match('/10001/', $host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
| 191 | 191 | //$formats[$id] = 'tsv'; |
| 192 | 192 | $globalSources[$id]['format'] = 'tsv'; |
| 193 | 193 | if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
| 194 | 194 | } |
| 195 | - } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
| 195 | + } elseif (filter_var($host, FILTER_VALIDATE_URL)) { |
|
| 196 | 196 | if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
| 197 | - $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
| 197 | + $idf = fopen($globalSources[$id]['host'], 'r', false, $context); |
|
| 198 | 198 | if ($idf !== false) { |
| 199 | 199 | $httpfeeds[$id] = $idf; |
| 200 | 200 | if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
| 201 | 201 | } |
| 202 | 202 | elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
| 203 | 203 | } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
| 204 | - } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
| 205 | - $hostport = explode(':',$host); |
|
| 204 | + } elseif (!filter_var($host, FILTER_VALIDATE_URL)) { |
|
| 205 | + $hostport = explode(':', $host); |
|
| 206 | 206 | if (isset($hostport[1])) { |
| 207 | 207 | $port = $hostport[1]; |
| 208 | 208 | $hostn = $hostport[0]; |
@@ -212,19 +212,19 @@ discard block |
||
| 212 | 212 | } |
| 213 | 213 | $Common = new Common(); |
| 214 | 214 | if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
| 215 | - $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
| 215 | + $s = $Common->create_socket($hostn, $port, $errno, $errstr); |
|
| 216 | 216 | } else { |
| 217 | - $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
| 217 | + $s = $Common->create_socket_udp($hostn, $port, $errno, $errstr); |
|
| 218 | 218 | } |
| 219 | 219 | if ($s) { |
| 220 | 220 | $sockets[$id] = $s; |
| 221 | 221 | if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
| 222 | - if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
| 222 | + if (preg_match('/aprs/', $hostn) || $port == '10152' || $port == '14580') { |
|
| 223 | 223 | //$formats[$id] = 'aprs'; |
| 224 | 224 | $globalSources[$id]['format'] = 'aprs'; |
| 225 | 225 | //$aprs_connect = 0; |
| 226 | 226 | //$use_aprs = true; |
| 227 | - } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
| 227 | + } elseif (preg_match('/pub-vrs/', $hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
| 228 | 228 | $globalSources[$id]['format'] = 'vrstcp'; |
| 229 | 229 | } elseif ($port == '10001') { |
| 230 | 230 | //$formats[$id] = 'tsv'; |
@@ -263,7 +263,7 @@ discard block |
||
| 263 | 263 | else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut; |
| 264 | 264 | else $timeout = 20; |
| 265 | 265 | $errno = ''; |
| 266 | -$errstr=''; |
|
| 266 | +$errstr = ''; |
|
| 267 | 267 | |
| 268 | 268 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
| 269 | 269 | /* Initiate connections to all the hosts simultaneously */ |
@@ -271,7 +271,7 @@ discard block |
||
| 271 | 271 | //connect_all($globalSources); |
| 272 | 272 | |
| 273 | 273 | if (isset($globalProxy) && $globalProxy) { |
| 274 | - $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
| 274 | + $context = stream_context_create(array('http' => array('timeout' => $timeout, 'proxy' => $globalProxy, 'request_fulluri' => true))); |
|
| 275 | 275 | } else { |
| 276 | 276 | $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
| 277 | 277 | } |
@@ -298,16 +298,16 @@ discard block |
||
| 298 | 298 | |
| 299 | 299 | if ($use_aprs) { |
| 300 | 300 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
| 301 | - $APRS=new APRS(); |
|
| 301 | + $APRS = new APRS(); |
|
| 302 | 302 | $aprs_connect = 0; |
| 303 | 303 | $aprs_keep = 120; |
| 304 | 304 | $aprs_last_tx = time(); |
| 305 | 305 | if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; |
| 306 | - else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
| 306 | + else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName); |
|
| 307 | 307 | if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid; |
| 308 | - else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
| 308 | + else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8); |
|
| 309 | 309 | if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter; |
| 310 | - else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
| 310 | + else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
| 311 | 311 | if ($aprs_full) $aprs_filter = ''; |
| 312 | 312 | if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass; |
| 313 | 313 | else $aprs_pass = '-1'; |
@@ -321,12 +321,12 @@ discard block |
||
| 321 | 321 | sleep(1); |
| 322 | 322 | if ($globalDebug) echo "SCAN MODE \n\n"; |
| 323 | 323 | if (!isset($globalCronEnd)) $globalCronEnd = 60; |
| 324 | -$endtime = time()+$globalCronEnd; |
|
| 324 | +$endtime = time() + $globalCronEnd; |
|
| 325 | 325 | $i = 1; |
| 326 | 326 | $tt = array(); |
| 327 | 327 | // Delete all ATC |
| 328 | 328 | if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) { |
| 329 | - $ATC=new ATC($Connection->db); |
|
| 329 | + $ATC = new ATC($Connection->db); |
|
| 330 | 330 | } |
| 331 | 331 | if (!$globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
| 332 | 332 | $ATC->deleteAll(); |
@@ -334,7 +334,7 @@ discard block |
||
| 334 | 334 | |
| 335 | 335 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
| 336 | 336 | while ($i > 0) { |
| 337 | - if (!$globalDaemon) $i = $endtime-time(); |
|
| 337 | + if (!$globalDaemon) $i = $endtime - time(); |
|
| 338 | 338 | // Delete old ATC |
| 339 | 339 | if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
| 340 | 340 | if ($globalDebug) echo 'Delete old ATC...'."\n"; |
@@ -349,7 +349,7 @@ discard block |
||
| 349 | 349 | } |
| 350 | 350 | if ($max != $globalMinFetch) { |
| 351 | 351 | if ($globalDebug) echo 'Sleeping...'."\n"; |
| 352 | - sleep($globalMinFetch-$max+2); |
|
| 352 | + sleep($globalMinFetch - $max + 2); |
|
| 353 | 353 | } |
| 354 | 354 | } |
| 355 | 355 | |
@@ -362,8 +362,8 @@ discard block |
||
| 362 | 362 | //$buffer = $Common->getData($hosts[$id]); |
| 363 | 363 | $buffer = $Common->getData($value['host']); |
| 364 | 364 | if ($buffer != '') $reset = 0; |
| 365 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 366 | - $buffer = explode('\n',$buffer); |
|
| 365 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
| 366 | + $buffer = explode('\n', $buffer); |
|
| 367 | 367 | foreach ($buffer as $line) { |
| 368 | 368 | if ($line != '' && count($line) > 7) { |
| 369 | 369 | $line = explode(',', $line); |
@@ -390,11 +390,11 @@ discard block |
||
| 390 | 390 | $last_exec[$id]['last'] = time(); |
| 391 | 391 | } elseif ($value['format'] == 'aisnmeatxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
| 392 | 392 | date_default_timezone_set('CET'); |
| 393 | - $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
| 393 | + $buffer = $Common->getData(str_replace('{date}', date('Ymd'), $value['host'])); |
|
| 394 | 394 | date_default_timezone_set('UTC'); |
| 395 | 395 | if ($buffer != '') $reset = 0; |
| 396 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 397 | - $buffer = explode('\n',$buffer); |
|
| 396 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
| 397 | + $buffer = explode('\n', $buffer); |
|
| 398 | 398 | foreach ($buffer as $line) { |
| 399 | 399 | if ($line != '') { |
| 400 | 400 | echo "'".$line."'\n"; |
@@ -412,7 +412,7 @@ discard block |
||
| 412 | 412 | if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
| 413 | 413 | if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
| 414 | 414 | if (isset($ais_data['timestamp'])) { |
| 415 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
| 415 | + $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); |
|
| 416 | 416 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
| 417 | 417 | $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
| 418 | 418 | $add = true; |
@@ -435,12 +435,12 @@ discard block |
||
| 435 | 435 | $w = $e = null; |
| 436 | 436 | |
| 437 | 437 | if (isset($arr[$id])) { |
| 438 | - $nn = stream_select($arr,$w,$e,$timeout); |
|
| 438 | + $nn = stream_select($arr, $w, $e, $timeout); |
|
| 439 | 439 | if ($nn > 0) { |
| 440 | 440 | foreach ($httpfeeds as $feed) { |
| 441 | - $buffer = stream_get_line($feed,2000,"\n"); |
|
| 442 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 443 | - $buffer = explode('\n',$buffer); |
|
| 441 | + $buffer = stream_get_line($feed, 2000, "\n"); |
|
| 442 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
| 443 | + $buffer = explode('\n', $buffer); |
|
| 444 | 444 | foreach ($buffer as $line) { |
| 445 | 445 | if ($line != '') { |
| 446 | 446 | $ais_data = $AIS->parse_line(trim($line)); |
@@ -456,9 +456,9 @@ discard block |
||
| 456 | 456 | if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
| 457 | 457 | if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
| 458 | 458 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
| 459 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 459 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']); |
|
| 460 | 460 | if (isset($ais_data['timestamp'])) { |
| 461 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
| 461 | + $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); |
|
| 462 | 462 | } else { |
| 463 | 463 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 464 | 464 | } |
@@ -472,10 +472,10 @@ discard block |
||
| 472 | 472 | } |
| 473 | 473 | } |
| 474 | 474 | } elseif ($value['format'] == 'myshiptracking' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
| 475 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
| 475 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20'); |
|
| 476 | 476 | if ($buffer != '') { |
| 477 | 477 | //echo $buffer; |
| 478 | - $all_data = json_decode($buffer,true); |
|
| 478 | + $all_data = json_decode($buffer, true); |
|
| 479 | 479 | //print_r($all_data); |
| 480 | 480 | if (isset($all_data[0]['DATA'])) { |
| 481 | 481 | foreach ($all_data[0]['DATA'] as $line) { |
@@ -490,7 +490,7 @@ discard block |
||
| 490 | 490 | // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
| 491 | 491 | $data['imo'] = $line['IMO']; |
| 492 | 492 | //$data['arrival_code'] = $ais_data['destination']; |
| 493 | - $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
|
| 493 | + $data['datetime'] = date('Y-m-d H:i:s', $line['T']); |
|
| 494 | 494 | $data['format_source'] = 'myshiptracking'; |
| 495 | 495 | $data['id_source'] = $id_source; |
| 496 | 496 | $MI->add($data); |
@@ -502,9 +502,9 @@ discard block |
||
| 502 | 502 | } |
| 503 | 503 | $last_exec[$id]['last'] = time(); |
| 504 | 504 | } elseif ($value['format'] == 'boatbeaconapp' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
| 505 | - $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
| 505 | + $buffer = $Common->getData(str_replace('{timestamp}', time(), $value['host'])); |
|
| 506 | 506 | if ($buffer != '') { |
| 507 | - $all_data = json_decode($buffer,true); |
|
| 507 | + $all_data = json_decode($buffer, true); |
|
| 508 | 508 | if (isset($all_data[0]['mmsi'])) { |
| 509 | 509 | foreach ($all_data as $line) { |
| 510 | 510 | if ($line != '') { |
@@ -531,27 +531,27 @@ discard block |
||
| 531 | 531 | $last_exec[$id]['last'] = time(); |
| 532 | 532 | } elseif ($value['format'] == 'shipplotter' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
| 533 | 533 | echo 'download...'; |
| 534 | - $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
| 534 | + $buffer = $Common->getData($value['host'], 'post', $value['post'], '', '', '', '', 'ShipPlotter'); |
|
| 535 | 535 | echo 'done !'."\n"; |
| 536 | 536 | if ($buffer != '') $reset = 0; |
| 537 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 538 | - $buffer = explode('\n',$buffer); |
|
| 537 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
| 538 | + $buffer = explode('\n', $buffer); |
|
| 539 | 539 | foreach ($buffer as $line) { |
| 540 | 540 | if ($line != '') { |
| 541 | 541 | $data = array(); |
| 542 | - $data['mmsi'] = (int)substr($line,0,9); |
|
| 543 | - $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
| 542 | + $data['mmsi'] = (int) substr($line, 0, 9); |
|
| 543 | + $data['datetime'] = date('Y-m-d H:i:s', substr($line, 10, 10)); |
|
| 544 | 544 | //$data['status'] = substr($line,21,2); |
| 545 | 545 | //$data['type'] = substr($line,24,3); |
| 546 | - $data['latitude'] = substr($line,29,9); |
|
| 547 | - $data['longitude'] = substr($line,41,9); |
|
| 548 | - $data['speed'] = round(substr($line,51,5)); |
|
| 546 | + $data['latitude'] = substr($line, 29, 9); |
|
| 547 | + $data['longitude'] = substr($line, 41, 9); |
|
| 548 | + $data['speed'] = round(substr($line, 51, 5)); |
|
| 549 | 549 | //$data['course'] = substr($line,57,5); |
| 550 | - $data['heading'] = round(substr($line,63,3)); |
|
| 550 | + $data['heading'] = round(substr($line, 63, 3)); |
|
| 551 | 551 | //$data['draft'] = substr($line,67,4); |
| 552 | 552 | //$data['length'] = substr($line,72,3); |
| 553 | 553 | //$data['beam'] = substr($line,76,2); |
| 554 | - $data['ident'] = trim(utf8_encode(substr($line,79,20))); |
|
| 554 | + $data['ident'] = trim(utf8_encode(substr($line, 79, 20))); |
|
| 555 | 555 | //$data['callsign'] = trim(substr($line,100,7); |
| 556 | 556 | //$data['dest'] = substr($line,108,20); |
| 557 | 557 | //$data['etaDate'] = substr($line,129,5); |
@@ -569,8 +569,8 @@ discard block |
||
| 569 | 569 | } elseif (($value['format'] == 'whazzup' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch))) { |
| 570 | 570 | //$buffer = $Common->getData($hosts[$id]); |
| 571 | 571 | $buffer = $Common->getData($value['host']); |
| 572 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 573 | - $buffer = explode('\n',$buffer); |
|
| 572 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
| 573 | + $buffer = explode('\n', $buffer); |
|
| 574 | 574 | $reset = 0; |
| 575 | 575 | foreach ($buffer as $line) { |
| 576 | 576 | if ($line != '') { |
@@ -581,7 +581,7 @@ discard block |
||
| 581 | 581 | else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
| 582 | 582 | $data['pilot_id'] = $line[1]; |
| 583 | 583 | $data['pilot_name'] = $line[2]; |
| 584 | - $data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT); |
|
| 584 | + $data['hex'] = str_pad(dechex($Common->str2int($line[1])), 6, '000000', STR_PAD_LEFT); |
|
| 585 | 585 | $data['ident'] = $line[0]; // ident |
| 586 | 586 | if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude |
| 587 | 587 | $data['speed'] = $line[8]; // speed |
@@ -597,7 +597,7 @@ discard block |
||
| 597 | 597 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); |
| 598 | 598 | //if (isset($line[37])) $data['last_update'] = $line[37]; |
| 599 | 599 | $data['departure_airport_icao'] = $line[11]; |
| 600 | - $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
| 600 | + $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':'); |
|
| 601 | 601 | $data['arrival_airport_icao'] = $line[13]; |
| 602 | 602 | $data['frequency'] = $line[4]; |
| 603 | 603 | $data['type'] = $line[18]; |
@@ -606,7 +606,7 @@ discard block |
||
| 606 | 606 | $data['id_source'] = $id_source; |
| 607 | 607 | //$data['arrival_airport_time'] = ; |
| 608 | 608 | if ($line[9] != '') { |
| 609 | - $aircraft_data = explode('/',$line[9]); |
|
| 609 | + $aircraft_data = explode('/', $line[9]); |
|
| 610 | 610 | if (isset($aircraft_data[1])) { |
| 611 | 611 | $data['aircraft_icao'] = $aircraft_data[1]; |
| 612 | 612 | } |
@@ -620,9 +620,9 @@ discard block |
||
| 620 | 620 | if ($line[3] == 'PILOT') $SI->add($data); |
| 621 | 621 | elseif ($line[3] == 'ATC') { |
| 622 | 622 | //print_r($data); |
| 623 | - $data['info'] = str_replace('^§','<br />',$data['info']); |
|
| 624 | - $data['info'] = str_replace('&sect;','',$data['info']); |
|
| 625 | - $typec = substr($data['ident'],-3); |
|
| 623 | + $data['info'] = str_replace('^§', '<br />', $data['info']); |
|
| 624 | + $data['info'] = str_replace('&sect;', '', $data['info']); |
|
| 625 | + $typec = substr($data['ident'], -3); |
|
| 626 | 626 | if ($typec == 'APP') $data['type'] = 'Approach'; |
| 627 | 627 | elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
| 628 | 628 | elseif ($typec == 'OBS') $data['type'] = 'Observer'; |
@@ -633,7 +633,7 @@ discard block |
||
| 633 | 633 | elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
| 634 | 634 | elseif ($data['type'] == '') $data['type'] = 'Observer'; |
| 635 | 635 | if (!isset($data['source_name'])) $data['source_name'] = ''; |
| 636 | - if (isset($ATC)) 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']); |
|
| 636 | + if (isset($ATC)) 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']); |
|
| 637 | 637 | } |
| 638 | 638 | unset($data); |
| 639 | 639 | } |
@@ -644,9 +644,9 @@ discard block |
||
| 644 | 644 | $last_exec[$id]['last'] = time(); |
| 645 | 645 | //} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) { |
| 646 | 646 | } elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
| 647 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
| 647 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20'); |
|
| 648 | 648 | if ($buffer != '') { |
| 649 | - $all_data = json_decode($buffer,true); |
|
| 649 | + $all_data = json_decode($buffer, true); |
|
| 650 | 650 | if (isset($all_data['acList'])) { |
| 651 | 651 | $reset = 0; |
| 652 | 652 | foreach ($all_data['acList'] as $line) { |
@@ -702,7 +702,7 @@ discard block |
||
| 702 | 702 | //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
| 703 | 703 | } elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
| 704 | 704 | $buffer = $Common->getData($value['host']); |
| 705 | - $all_data = json_decode($buffer,true); |
|
| 705 | + $all_data = json_decode($buffer, true); |
|
| 706 | 706 | if (isset($all_data['planes'])) { |
| 707 | 707 | $reset = 0; |
| 708 | 708 | foreach ($all_data['planes'] as $key => $line) { |
@@ -719,12 +719,12 @@ discard block |
||
| 719 | 719 | $data['emergency'] = ''; // emergency |
| 720 | 720 | $data['registration'] = $line[2]; |
| 721 | 721 | $data['aircraft_icao'] = $line[0]; |
| 722 | - $deparr = explode('-',$line[1]); |
|
| 722 | + $deparr = explode('-', $line[1]); |
|
| 723 | 723 | if (count($deparr) == 2) { |
| 724 | 724 | $data['departure_airport_icao'] = $deparr[0]; |
| 725 | 725 | $data['arrival_airport_icao'] = $deparr[1]; |
| 726 | 726 | } |
| 727 | - $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
| 727 | + $data['datetime'] = date('Y-m-d H:i:s', $line[9]); |
|
| 728 | 728 | $data['format_source'] = 'planeupdatefaa'; |
| 729 | 729 | $data['id_source'] = $id_source; |
| 730 | 730 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
@@ -736,7 +736,7 @@ discard block |
||
| 736 | 736 | $last_exec[$id]['last'] = time(); |
| 737 | 737 | } elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
| 738 | 738 | $buffer = $Common->getData($value['host']); |
| 739 | - $all_data = json_decode($buffer,true); |
|
| 739 | + $all_data = json_decode($buffer, true); |
|
| 740 | 740 | if (isset($all_data['states'])) { |
| 741 | 741 | $reset = 0; |
| 742 | 742 | foreach ($all_data['states'] as $key => $line) { |
@@ -753,7 +753,7 @@ discard block |
||
| 753 | 753 | //$data['emergency'] = ''; // emergency |
| 754 | 754 | //$data['registration'] = $line[2]; |
| 755 | 755 | //$data['aircraft_icao'] = $line[0]; |
| 756 | - $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
| 756 | + $data['datetime'] = date('Y-m-d H:i:s', $line[3]); |
|
| 757 | 757 | $data['format_source'] = 'opensky'; |
| 758 | 758 | $data['id_source'] = $id_source; |
| 759 | 759 | $SI->add($data); |
@@ -766,7 +766,7 @@ discard block |
||
| 766 | 766 | } elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
| 767 | 767 | //$buffer = $Common->getData($hosts[$id]); |
| 768 | 768 | $buffer = $Common->getData($value['host']); |
| 769 | - $all_data = json_decode($buffer,true); |
|
| 769 | + $all_data = json_decode($buffer, true); |
|
| 770 | 770 | if (!empty($all_data)) $reset = 0; |
| 771 | 771 | foreach ($all_data as $key => $line) { |
| 772 | 772 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
@@ -798,11 +798,11 @@ discard block |
||
| 798 | 798 | //} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
| 799 | 799 | } elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
| 800 | 800 | //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
| 801 | - $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
| 801 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150'); |
|
| 802 | 802 | //echo $buffer; |
| 803 | - $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
| 804 | - $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
| 805 | - $all_data = json_decode($buffer,true); |
|
| 803 | + $buffer = str_replace(array("\n", "\r"), "", $buffer); |
|
| 804 | + $buffer = preg_replace('/,"num":(.+)/', '}', $buffer); |
|
| 805 | + $all_data = json_decode($buffer, true); |
|
| 806 | 806 | if (json_last_error() != JSON_ERROR_NONE) { |
| 807 | 807 | die(json_last_error_msg()); |
| 808 | 808 | } |
@@ -825,7 +825,7 @@ discard block |
||
| 825 | 825 | //$data['departure_airport_iata'] = $line[11]; |
| 826 | 826 | //$data['arrival_airport_iata'] = $line[12]; |
| 827 | 827 | //$data['emergency'] = ''; // emergency |
| 828 | - $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
|
| 828 | + $data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10] |
|
| 829 | 829 | $data['format_source'] = 'radarvirtueljson'; |
| 830 | 830 | $data['id_source'] = $id_source; |
| 831 | 831 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
@@ -840,14 +840,14 @@ discard block |
||
| 840 | 840 | } elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
| 841 | 841 | //$buffer = $Common->getData($hosts[$id]); |
| 842 | 842 | $buffer = $Common->getData($value['host'].'?'.time()); |
| 843 | - $all_data = json_decode(utf8_encode($buffer),true); |
|
| 843 | + $all_data = json_decode(utf8_encode($buffer), true); |
|
| 844 | 844 | |
| 845 | 845 | if (isset($all_data['pireps'])) { |
| 846 | 846 | $reset = 0; |
| 847 | 847 | foreach ($all_data['pireps'] as $line) { |
| 848 | 848 | $data = array(); |
| 849 | 849 | $data['id'] = $line['id']; |
| 850 | - $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
| 850 | + $data['hex'] = substr(str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT), 0, 6); |
|
| 851 | 851 | $data['ident'] = $line['callsign']; // ident |
| 852 | 852 | if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
| 853 | 853 | if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
@@ -876,9 +876,9 @@ discard block |
||
| 876 | 876 | $SI->add($data); |
| 877 | 877 | // print_r($data); |
| 878 | 878 | } elseif ($line['icon'] == 'ct') { |
| 879 | - $data['info'] = str_replace('^§','<br />',$data['info']); |
|
| 880 | - $data['info'] = str_replace('&sect;','',$data['info']); |
|
| 881 | - $typec = substr($data['ident'],-3); |
|
| 879 | + $data['info'] = str_replace('^§', '<br />', $data['info']); |
|
| 880 | + $data['info'] = str_replace('&sect;', '', $data['info']); |
|
| 881 | + $typec = substr($data['ident'], -3); |
|
| 882 | 882 | $data['type'] = ''; |
| 883 | 883 | if ($typec == 'APP') $data['type'] = 'Approach'; |
| 884 | 884 | elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
@@ -889,7 +889,7 @@ discard block |
||
| 889 | 889 | elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station'; |
| 890 | 890 | elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
| 891 | 891 | else $data['type'] = 'Observer'; |
| 892 | - 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']); |
|
| 892 | + 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']); |
|
| 893 | 893 | } |
| 894 | 894 | unset($data); |
| 895 | 895 | } |
@@ -901,14 +901,14 @@ discard block |
||
| 901 | 901 | //$buffer = $Common->getData($hosts[$id]); |
| 902 | 902 | if ($globalDebug) echo 'Get Data...'."\n"; |
| 903 | 903 | $buffer = $Common->getData($value['host']); |
| 904 | - $all_data = json_decode($buffer,true); |
|
| 904 | + $all_data = json_decode($buffer, true); |
|
| 905 | 905 | if ($buffer != '' && is_array($all_data)) { |
| 906 | 906 | $reset = 0; |
| 907 | 907 | foreach ($all_data as $line) { |
| 908 | 908 | $data = array(); |
| 909 | 909 | //$data['id'] = $line['id']; // id not usable |
| 910 | 910 | if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
| 911 | - $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 911 | + $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex |
|
| 912 | 912 | if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
| 913 | 913 | if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
| 914 | 914 | $data['ident'] = $line['flightnum']; // ident |
@@ -931,12 +931,12 @@ discard block |
||
| 931 | 931 | if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
| 932 | 932 | if (isset($line['aircraftname'])) { |
| 933 | 933 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
| 934 | - $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
|
| 935 | - $aircraft_data = explode('-',$line['aircraftname']); |
|
| 934 | + $line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']); |
|
| 935 | + $aircraft_data = explode('-', $line['aircraftname']); |
|
| 936 | 936 | if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) $data['aircraft_icao'] = $aircraft_data[0]; |
| 937 | 937 | elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) $data['aircraft_icao'] = $aircraft_data[1]; |
| 938 | 938 | else { |
| 939 | - $aircraft_data = explode(' ',$line['aircraftname']); |
|
| 939 | + $aircraft_data = explode(' ', $line['aircraftname']); |
|
| 940 | 940 | if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1]; |
| 941 | 941 | else $data['aircraft_icao'] = $line['aircraftname']; |
| 942 | 942 | } |
@@ -958,14 +958,14 @@ discard block |
||
| 958 | 958 | //$buffer = $Common->getData($hosts[$id]); |
| 959 | 959 | if ($globalDebug) echo 'Get Data...'."\n"; |
| 960 | 960 | $buffer = $Common->getData($value['host']); |
| 961 | - $all_data = json_decode($buffer,true); |
|
| 961 | + $all_data = json_decode($buffer, true); |
|
| 962 | 962 | if ($buffer != '' && is_array($all_data)) { |
| 963 | 963 | $reset = 0; |
| 964 | 964 | foreach ($all_data as $line) { |
| 965 | 965 | $data = array(); |
| 966 | 966 | //$data['id'] = $line['id']; // id not usable |
| 967 | 967 | $data['id'] = trim($line['flight_id']); |
| 968 | - $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 968 | + $data['hex'] = substr(str_pad(bin2hex($line['callsign']), 6, '000000', STR_PAD_LEFT), -6); // hex |
|
| 969 | 969 | $data['pilot_name'] = $line['pilot_name']; |
| 970 | 970 | $data['pilot_id'] = $line['pilot_id']; |
| 971 | 971 | $data['ident'] = trim($line['callsign']); // ident |
@@ -1016,9 +1016,9 @@ discard block |
||
| 1016 | 1016 | //$value = $formats[$nb]; |
| 1017 | 1017 | $format = $globalSources[$nb]['format']; |
| 1018 | 1018 | if ($format == 'sbs' || $format == 'aprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3' || $format == 'vrstcp') { |
| 1019 | - $buffer = socket_read($r, 6000,PHP_NORMAL_READ); |
|
| 1019 | + $buffer = socket_read($r, 6000, PHP_NORMAL_READ); |
|
| 1020 | 1020 | } else { |
| 1021 | - $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); |
|
| 1021 | + $az = socket_recvfrom($r, $buffer, 6000, 0, $remote_ip, $remote_port); |
|
| 1022 | 1022 | } |
| 1023 | 1023 | //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
| 1024 | 1024 | //echo $buffer."\n"; |
@@ -1027,8 +1027,8 @@ discard block |
||
| 1027 | 1027 | $error = false; |
| 1028 | 1028 | //$SI::del(); |
| 1029 | 1029 | if ($format == 'vrstcp') { |
| 1030 | - $buffer = explode('},{',$buffer); |
|
| 1031 | - } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
| 1030 | + $buffer = explode('},{', $buffer); |
|
| 1031 | + } else $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer)); |
|
| 1032 | 1032 | // SBS format is CSV format |
| 1033 | 1033 | if ($buffer !== FALSE && $buffer != '') { |
| 1034 | 1034 | $tt[$format] = 0; |
@@ -1060,10 +1060,10 @@ discard block |
||
| 1060 | 1060 | if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
| 1061 | 1061 | if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
| 1062 | 1062 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
| 1063 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 1063 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']); |
|
| 1064 | 1064 | |
| 1065 | 1065 | if (isset($ais_data['timestamp'])) { |
| 1066 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
| 1066 | + $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); |
|
| 1067 | 1067 | } else { |
| 1068 | 1068 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1069 | 1069 | } |
@@ -1074,10 +1074,10 @@ discard block |
||
| 1074 | 1074 | } elseif ($format == 'flightgearsp') { |
| 1075 | 1075 | //echo $buffer."\n"; |
| 1076 | 1076 | if (strlen($buffer) > 5) { |
| 1077 | - $line = explode(',',$buffer); |
|
| 1077 | + $line = explode(',', $buffer); |
|
| 1078 | 1078 | $data = array(); |
| 1079 | 1079 | //XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p |
| 1080 | - $data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]),6,'000000',STR_PAD_LEFT),0,6); |
|
| 1080 | + $data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]), 6, '000000', STR_PAD_LEFT), 0, 6); |
|
| 1081 | 1081 | $data['ident'] = $line[6]; |
| 1082 | 1082 | $data['aircraft_name'] = $line[7]; |
| 1083 | 1083 | $data['longitude'] = $line[1]; |
@@ -1088,21 +1088,21 @@ discard block |
||
| 1088 | 1088 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1089 | 1089 | $data['format_source'] = 'flightgearsp'; |
| 1090 | 1090 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
| 1091 | - $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
|
| 1091 | + $send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0); |
|
| 1092 | 1092 | } |
| 1093 | 1093 | } elseif ($format == 'acars') { |
| 1094 | 1094 | if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
| 1095 | 1095 | $ACARS->add(trim($buffer)); |
| 1096 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
| 1096 | + socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port); |
|
| 1097 | 1097 | $ACARS->deleteLiveAcarsData(); |
| 1098 | 1098 | } elseif ($format == 'flightgearmp') { |
| 1099 | - if (substr($buffer,0,1) != '#') { |
|
| 1099 | + if (substr($buffer, 0, 1) != '#') { |
|
| 1100 | 1100 | $data = array(); |
| 1101 | 1101 | //echo $buffer."\n"; |
| 1102 | - $line = explode(' ',$buffer); |
|
| 1102 | + $line = explode(' ', $buffer); |
|
| 1103 | 1103 | if (count($line) == 11) { |
| 1104 | - $userserver = explode('@',$line[0]); |
|
| 1105 | - $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
| 1104 | + $userserver = explode('@', $line[0]); |
|
| 1105 | + $data['hex'] = substr(str_pad(bin2hex($line[0]), 6, '000000', STR_PAD_LEFT), 0, 6); // hex |
|
| 1106 | 1106 | $data['ident'] = $userserver[0]; |
| 1107 | 1107 | $data['registration'] = $userserver[0]; |
| 1108 | 1108 | $data['latitude'] = $line[4]; |
@@ -1110,8 +1110,8 @@ discard block |
||
| 1110 | 1110 | $data['altitude'] = $line[6]; |
| 1111 | 1111 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1112 | 1112 | $aircraft_type = $line[10]; |
| 1113 | - $aircraft_type = preg_split(':/:',$aircraft_type); |
|
| 1114 | - $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
| 1113 | + $aircraft_type = preg_split(':/:', $aircraft_type); |
|
| 1114 | + $data['aircraft_name'] = substr(end($aircraft_type), 0, -4); |
|
| 1115 | 1115 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
| 1116 | 1116 | } |
| 1117 | 1117 | } |
@@ -1119,8 +1119,8 @@ discard block |
||
| 1119 | 1119 | echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
| 1120 | 1120 | die; |
| 1121 | 1121 | } elseif ($format == 'vrstcp') { |
| 1122 | - foreach($buffer as $all_data) { |
|
| 1123 | - $line = json_decode('{'.$all_data.'}',true); |
|
| 1122 | + foreach ($buffer as $all_data) { |
|
| 1123 | + $line = json_decode('{'.$all_data.'}', true); |
|
| 1124 | 1124 | $data = array(); |
| 1125 | 1125 | if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
| 1126 | 1126 | if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
@@ -1145,16 +1145,16 @@ discard block |
||
| 1145 | 1145 | if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
| 1146 | 1146 | unset($data); |
| 1147 | 1147 | } |
| 1148 | - } elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') { |
|
| 1148 | + } elseif ($format == 'tsv' || substr($buffer, 0, 4) == 'clock') { |
|
| 1149 | 1149 | $line = explode("\t", $buffer); |
| 1150 | - for($k = 0; $k < count($line); $k=$k+2) { |
|
| 1150 | + for ($k = 0; $k < count($line); $k = $k + 2) { |
|
| 1151 | 1151 | $key = $line[$k]; |
| 1152 | - $lined[$key] = $line[$k+1]; |
|
| 1152 | + $lined[$key] = $line[$k + 1]; |
|
| 1153 | 1153 | } |
| 1154 | 1154 | if (count($lined) > 3) { |
| 1155 | 1155 | $data['hex'] = $lined['hexid']; |
| 1156 | 1156 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
| 1157 | - $data['datetime'] = date('Y-m-d H:i:s');; |
|
| 1157 | + $data['datetime'] = date('Y-m-d H:i:s'); ; |
|
| 1158 | 1158 | if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
| 1159 | 1159 | if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
| 1160 | 1160 | if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
@@ -1172,22 +1172,22 @@ discard block |
||
| 1172 | 1172 | } else $error = true; |
| 1173 | 1173 | } elseif ($format == 'aprs' && $use_aprs) { |
| 1174 | 1174 | if ($aprs_connect == 0) { |
| 1175 | - $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
|
| 1175 | + $send = @ socket_send($r, $aprs_login, strlen($aprs_login), 0); |
|
| 1176 | 1176 | $aprs_connect = 1; |
| 1177 | 1177 | } |
| 1178 | 1178 | |
| 1179 | - if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
| 1179 | + if ($aprs_keep > 60 && time() - $aprs_last_tx > $aprs_keep) { |
|
| 1180 | 1180 | $aprs_last_tx = time(); |
| 1181 | 1181 | $data_aprs = "# Keep alive"; |
| 1182 | - $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
|
| 1182 | + $send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0); |
|
| 1183 | 1183 | } |
| 1184 | 1184 | |
| 1185 | 1185 | //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
| 1186 | 1186 | //echo 'APRS data : '.$buffer."\n"; |
| 1187 | - $buffer = str_replace('APRS <- ','',$buffer); |
|
| 1188 | - $buffer = str_replace('APRS -> ','',$buffer); |
|
| 1187 | + $buffer = str_replace('APRS <- ', '', $buffer); |
|
| 1188 | + $buffer = str_replace('APRS -> ', '', $buffer); |
|
| 1189 | 1189 | //echo $buffer."\n"; |
| 1190 | - if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
| 1190 | + if (substr($buffer, 0, 1) != '#' && substr($buffer, 0, 1) != '@' && substr($buffer, 0, 5) != 'APRS ') { |
|
| 1191 | 1191 | $line = $APRS->parse($buffer); |
| 1192 | 1192 | //print_r($line); |
| 1193 | 1193 | //if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) { |
@@ -1196,7 +1196,7 @@ discard block |
||
| 1196 | 1196 | $data = array(); |
| 1197 | 1197 | //print_r($line); |
| 1198 | 1198 | if (isset($line['address'])) $data['hex'] = $line['address']; |
| 1199 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
| 1199 | + if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']); |
|
| 1200 | 1200 | else $data['datetime'] = date('Y-m-d H:i:s'); |
| 1201 | 1201 | //$data['datetime'] = date('Y-m-d H:i:s'); |
| 1202 | 1202 | if (isset($line['ident'])) $data['ident'] = $line['ident']; |
@@ -1222,7 +1222,7 @@ discard block |
||
| 1222 | 1222 | $currentdate = date('Y-m-d H:i:s'); |
| 1223 | 1223 | $aprsdate = strtotime($data['datetime']); |
| 1224 | 1224 | // Accept data if time <= system time + 20s |
| 1225 | - 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'])))) { |
|
| 1225 | + 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'])))) { |
|
| 1226 | 1226 | $send = $SI->add($data); |
| 1227 | 1227 | } elseif (isset($line['stealth'])) { |
| 1228 | 1228 | if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
@@ -1319,7 +1319,7 @@ discard block |
||
| 1319 | 1319 | connect_all($sourceee); |
| 1320 | 1320 | $sourceee = array(); |
| 1321 | 1321 | //connect_all($globalSources); |
| 1322 | - $tt[$format]=0; |
|
| 1322 | + $tt[$format] = 0; |
|
| 1323 | 1323 | break; |
| 1324 | 1324 | } |
| 1325 | 1325 | } |
@@ -1328,14 +1328,14 @@ discard block |
||
| 1328 | 1328 | } else { |
| 1329 | 1329 | $error = socket_strerror(socket_last_error()); |
| 1330 | 1330 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
| 1331 | - if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
|
| 1331 | + if ($globalDebug) echo "ERROR : socket_select give this error ".$error."\n"; |
|
| 1332 | 1332 | if (isset($globalDebug)) echo "Restarting...\n"; |
| 1333 | 1333 | // Restart the script if possible |
| 1334 | 1334 | if (is_array($sockets)) { |
| 1335 | 1335 | if ($globalDebug) echo "Shutdown all sockets..."; |
| 1336 | 1336 | |
| 1337 | 1337 | foreach ($sockets as $sock) { |
| 1338 | - @socket_shutdown($sock,2); |
|
| 1338 | + @socket_shutdown($sock, 2); |
|
| 1339 | 1339 | @socket_close($sock); |
| 1340 | 1340 | } |
| 1341 | 1341 | |
@@ -13,13 +13,17 @@ discard block |
||
| 13 | 13 | require_once(dirname(__FILE__).'/../require/class.SBS.php'); |
| 14 | 14 | require_once(dirname(__FILE__).'/../require/class.Connection.php'); |
| 15 | 15 | require_once(dirname(__FILE__).'/../require/class.Common.php'); |
| 16 | -if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
| 16 | +if (isset($globalTracker) && $globalTracker) { |
|
| 17 | + require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
| 18 | +} |
|
| 17 | 19 | if (isset($globalMarine) && $globalMarine) { |
| 18 | 20 | require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
| 19 | 21 | require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
| 20 | 22 | } |
| 21 | 23 | |
| 22 | -if (!isset($globalDebug)) $globalDebug = FALSE; |
|
| 24 | +if (!isset($globalDebug)) { |
|
| 25 | + $globalDebug = FALSE; |
|
| 26 | +} |
|
| 23 | 27 | |
| 24 | 28 | // Check if schema is at latest version |
| 25 | 29 | $Connection = new Connection(); |
@@ -59,22 +63,39 @@ discard block |
||
| 59 | 63 | $globalSources = array(); |
| 60 | 64 | $globalSources[] = array('host' => $options['source']); |
| 61 | 65 | } |
| 62 | -if (isset($options['aprsserverssid'])) $globalServerAPRSssid = $options['aprsserverssid']; |
|
| 63 | -if (isset($options['aprsserverpass'])) $globalServerAPRSpass = $options['aprsserverpass']; |
|
| 64 | -if (isset($options['nodaemon'])) $globalDaemon = FALSE; |
|
| 65 | -if (isset($options['server'])) $globalServer = TRUE; |
|
| 66 | -if (isset($options['idsource'])) $id_source = $options['idsource']; |
|
| 67 | -else $id_source = 1; |
|
| 66 | +if (isset($options['aprsserverssid'])) { |
|
| 67 | + $globalServerAPRSssid = $options['aprsserverssid']; |
|
| 68 | +} |
|
| 69 | +if (isset($options['aprsserverpass'])) { |
|
| 70 | + $globalServerAPRSpass = $options['aprsserverpass']; |
|
| 71 | +} |
|
| 72 | +if (isset($options['nodaemon'])) { |
|
| 73 | + $globalDaemon = FALSE; |
|
| 74 | +} |
|
| 75 | +if (isset($options['server'])) { |
|
| 76 | + $globalServer = TRUE; |
|
| 77 | +} |
|
| 78 | +if (isset($options['idsource'])) { |
|
| 79 | + $id_source = $options['idsource']; |
|
| 80 | +} else { |
|
| 81 | + $id_source = 1; |
|
| 82 | +} |
|
| 68 | 83 | if (isset($globalServer) && $globalServer) { |
| 69 | - if ($globalDebug) echo "Using Server Mode\n"; |
|
| 84 | + if ($globalDebug) { |
|
| 85 | + echo "Using Server Mode\n"; |
|
| 86 | + } |
|
| 70 | 87 | $SI=new SpotterServer(); |
| 71 | 88 | /* |
| 72 | 89 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
| 73 | 90 | $SI = new adsb2aprs(); |
| 74 | 91 | $SI->connect(); |
| 75 | 92 | */ |
| 76 | -} else $SI=new SpotterImport($Connection->db); |
|
| 77 | -if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db); |
|
| 93 | +} else { |
|
| 94 | + $SI=new SpotterImport($Connection->db); |
|
| 95 | +} |
|
| 96 | +if (isset($globalTracker) && $globalTracker) { |
|
| 97 | + $TI = new TrackerImport($Connection->db); |
|
| 98 | +} |
|
| 78 | 99 | if (isset($globalMarine) && $globalMarine) { |
| 79 | 100 | $AIS = new AIS(); |
| 80 | 101 | $MI = new MarineImport($Connection->db); |
@@ -96,7 +117,9 @@ discard block |
||
| 96 | 117 | } |
| 97 | 118 | |
| 98 | 119 | // let's try and connect |
| 99 | -if ($globalDebug) echo "Connecting...\n"; |
|
| 120 | +if ($globalDebug) { |
|
| 121 | + echo "Connecting...\n"; |
|
| 122 | +} |
|
| 100 | 123 | $use_aprs = false; |
| 101 | 124 | $aprs_full = false; |
| 102 | 125 | $reset = 0; |
@@ -105,7 +128,9 @@ discard block |
||
| 105 | 128 | //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
| 106 | 129 | global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
| 107 | 130 | $reset++; |
| 108 | - if ($globalDebug) echo 'Connect to all...'."\n"; |
|
| 131 | + if ($globalDebug) { |
|
| 132 | + echo 'Connect to all...'."\n"; |
|
| 133 | + } |
|
| 109 | 134 | foreach ($hosts as $id => $value) { |
| 110 | 135 | $host = $value['host']; |
| 111 | 136 | $globalSources[$id]['last_exec'] = 0; |
@@ -115,27 +140,37 @@ discard block |
||
| 115 | 140 | //$formats[$id] = 'deltadbtxt'; |
| 116 | 141 | $globalSources[$id]['format'] = 'deltadbtxt'; |
| 117 | 142 | //$last_exec['deltadbtxt'] = 0; |
| 118 | - if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
| 143 | + if ($globalDebug) { |
|
| 144 | + echo "Connect to deltadb source (".$host.")...\n"; |
|
| 145 | + } |
|
| 119 | 146 | } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
| 120 | 147 | //$formats[$id] = 'vatsimtxt'; |
| 121 | 148 | $globalSources[$id]['format'] = 'vatsimtxt'; |
| 122 | 149 | //$last_exec['vatsimtxt'] = 0; |
| 123 | - if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
| 150 | + if ($globalDebug) { |
|
| 151 | + echo "Connect to vatsim source (".$host.")...\n"; |
|
| 152 | + } |
|
| 124 | 153 | } else if (preg_match('/aircraftlist.json$/i',$host)) { |
| 125 | 154 | //$formats[$id] = 'aircraftlistjson'; |
| 126 | 155 | $globalSources[$id]['format'] = 'aircraftlistjson'; |
| 127 | 156 | //$last_exec['aircraftlistjson'] = 0; |
| 128 | - if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
| 157 | + if ($globalDebug) { |
|
| 158 | + echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
| 159 | + } |
|
| 129 | 160 | } else if (preg_match('/opensky/i',$host)) { |
| 130 | 161 | //$formats[$id] = 'aircraftlistjson'; |
| 131 | 162 | $globalSources[$id]['format'] = 'opensky'; |
| 132 | 163 | //$last_exec['aircraftlistjson'] = 0; |
| 133 | - if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
| 164 | + if ($globalDebug) { |
|
| 165 | + echo "Connect to opensky source (".$host.")...\n"; |
|
| 166 | + } |
|
| 134 | 167 | } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) { |
| 135 | 168 | //$formats[$id] = 'radarvirtueljson'; |
| 136 | 169 | $globalSources[$id]['format'] = 'radarvirtueljson'; |
| 137 | 170 | //$last_exec['radarvirtueljson'] = 0; |
| 138 | - if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n"; |
|
| 171 | + if ($globalDebug) { |
|
| 172 | + echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n"; |
|
| 173 | + } |
|
| 139 | 174 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
| 140 | 175 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
| 141 | 176 | exit(0); |
@@ -144,7 +179,9 @@ discard block |
||
| 144 | 179 | //$formats[$id] = 'planeupdatefaa'; |
| 145 | 180 | $globalSources[$id]['format'] = 'planeupdatefaa'; |
| 146 | 181 | //$last_exec['planeupdatefaa'] = 0; |
| 147 | - if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
| 182 | + if ($globalDebug) { |
|
| 183 | + echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
| 184 | + } |
|
| 148 | 185 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
| 149 | 186 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
| 150 | 187 | exit(0); |
@@ -153,26 +190,36 @@ discard block |
||
| 153 | 190 | //$formats[$id] = 'phpvmacars'; |
| 154 | 191 | $globalSources[$id]['format'] = 'phpvmacars'; |
| 155 | 192 | //$last_exec['phpvmacars'] = 0; |
| 156 | - if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
| 193 | + if ($globalDebug) { |
|
| 194 | + echo "Connect to phpvmacars source (".$host.")...\n"; |
|
| 195 | + } |
|
| 157 | 196 | } else if (preg_match('/VAM-json.php$/i',$host)) { |
| 158 | 197 | //$formats[$id] = 'phpvmacars'; |
| 159 | 198 | $globalSources[$id]['format'] = 'vam'; |
| 160 | - if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
| 199 | + if ($globalDebug) { |
|
| 200 | + echo "Connect to Vam source (".$host.")...\n"; |
|
| 201 | + } |
|
| 161 | 202 | } else if (preg_match('/whazzup/i',$host)) { |
| 162 | 203 | //$formats[$id] = 'whazzup'; |
| 163 | 204 | $globalSources[$id]['format'] = 'whazzup'; |
| 164 | 205 | //$last_exec['whazzup'] = 0; |
| 165 | - if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
| 206 | + if ($globalDebug) { |
|
| 207 | + echo "Connect to whazzup source (".$host.")...\n"; |
|
| 208 | + } |
|
| 166 | 209 | } else if (preg_match('/recentpireps/i',$host)) { |
| 167 | 210 | //$formats[$id] = 'pirepsjson'; |
| 168 | 211 | $globalSources[$id]['format'] = 'pirepsjson'; |
| 169 | 212 | //$last_exec['pirepsjson'] = 0; |
| 170 | - if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
| 213 | + if ($globalDebug) { |
|
| 214 | + echo "Connect to pirepsjson source (".$host.")...\n"; |
|
| 215 | + } |
|
| 171 | 216 | } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
| 172 | 217 | //$formats[$id] = 'fr24json'; |
| 173 | 218 | $globalSources[$id]['format'] = 'fr24json'; |
| 174 | 219 | //$last_exec['fr24json'] = 0; |
| 175 | - if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
| 220 | + if ($globalDebug) { |
|
| 221 | + echo "Connect to fr24 source (".$host.")...\n"; |
|
| 222 | + } |
|
| 176 | 223 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
| 177 | 224 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
| 178 | 225 | exit(0); |
@@ -181,7 +228,9 @@ discard block |
||
| 181 | 228 | //$formats[$id] = 'fr24json'; |
| 182 | 229 | $globalSources[$id]['format'] = 'myshiptracking'; |
| 183 | 230 | //$last_exec['fr24json'] = 0; |
| 184 | - if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
| 231 | + if ($globalDebug) { |
|
| 232 | + echo "Connect to myshiptracking source (".$host.")...\n"; |
|
| 233 | + } |
|
| 185 | 234 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
| 186 | 235 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
| 187 | 236 | exit(0); |
@@ -190,17 +239,24 @@ discard block |
||
| 190 | 239 | } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
| 191 | 240 | //$formats[$id] = 'tsv'; |
| 192 | 241 | $globalSources[$id]['format'] = 'tsv'; |
| 193 | - if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
| 242 | + if ($globalDebug) { |
|
| 243 | + echo "Connect to tsv source (".$host.")...\n"; |
|
| 244 | + } |
|
| 194 | 245 | } |
| 195 | 246 | } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
| 196 | 247 | if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
| 197 | 248 | $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
| 198 | 249 | if ($idf !== false) { |
| 199 | 250 | $httpfeeds[$id] = $idf; |
| 200 | - if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 251 | + if ($globalDebug) { |
|
| 252 | + echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 253 | + } |
|
| 254 | + } elseif ($globalDebug) { |
|
| 255 | + echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
| 201 | 256 | } |
| 202 | - elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
| 203 | - } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 257 | + } elseif ($globalDebug) { |
|
| 258 | + echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 259 | + } |
|
| 204 | 260 | } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
| 205 | 261 | $hostport = explode(':',$host); |
| 206 | 262 | if (isset($hostport[1])) { |
@@ -240,17 +296,25 @@ discard block |
||
| 240 | 296 | //$formats[$id] = 'beast'; |
| 241 | 297 | $globalSources[$id]['format'] = 'beast'; |
| 242 | 298 | //} else $formats[$id] = 'sbs'; |
| 243 | - } else $globalSources[$id]['format'] = 'sbs'; |
|
| 299 | + } else { |
|
| 300 | + $globalSources[$id]['format'] = 'sbs'; |
|
| 301 | + } |
|
| 244 | 302 | //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
| 245 | 303 | } |
| 246 | - if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
|
| 304 | + if ($globalDebug) { |
|
| 305 | + echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
|
| 306 | + } |
|
| 247 | 307 | } else { |
| 248 | - if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
|
| 308 | + if ($globalDebug) { |
|
| 309 | + echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
|
| 310 | + } |
|
| 249 | 311 | } |
| 250 | 312 | } |
| 251 | 313 | } |
| 252 | 314 | } |
| 253 | -if (!isset($globalMinFetch)) $globalMinFetch = 15; |
|
| 315 | +if (!isset($globalMinFetch)) { |
|
| 316 | + $globalMinFetch = 15; |
|
| 317 | +} |
|
| 254 | 318 | |
| 255 | 319 | // Initialize all |
| 256 | 320 | $status = array(); |
@@ -259,13 +323,19 @@ discard block |
||
| 259 | 323 | $formats = array(); |
| 260 | 324 | $last_exec = array(); |
| 261 | 325 | $time = time(); |
| 262 | -if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut; |
|
| 263 | -else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut; |
|
| 264 | -else $timeout = 20; |
|
| 326 | +if (isset($globalSourcesTimeout)) { |
|
| 327 | + $timeout = $globalSourcesTimeOut; |
|
| 328 | +} else if (isset($globalSBS1TimeOut)) { |
|
| 329 | + $timeout = $globalSBS1TimeOut; |
|
| 330 | +} else { |
|
| 331 | + $timeout = 20; |
|
| 332 | +} |
|
| 265 | 333 | $errno = ''; |
| 266 | 334 | $errstr=''; |
| 267 | 335 | |
| 268 | -if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
| 336 | +if (!isset($globalDaemon)) { |
|
| 337 | + $globalDaemon = TRUE; |
|
| 338 | +} |
|
| 269 | 339 | /* Initiate connections to all the hosts simultaneously */ |
| 270 | 340 | //connect_all($hosts); |
| 271 | 341 | //connect_all($globalSources); |
@@ -291,7 +361,9 @@ discard block |
||
| 291 | 361 | if (isset($source['format']) && $source['format'] == 'aprs') { |
| 292 | 362 | $aprs_connect = 0; |
| 293 | 363 | $use_aprs = true; |
| 294 | - if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true; |
|
| 364 | + if (isset($source['port']) && $source['port'] == '10152') { |
|
| 365 | + $aprs_full = true; |
|
| 366 | + } |
|
| 295 | 367 | break; |
| 296 | 368 | } |
| 297 | 369 | } |
@@ -302,25 +374,48 @@ discard block |
||
| 302 | 374 | $aprs_connect = 0; |
| 303 | 375 | $aprs_keep = 120; |
| 304 | 376 | $aprs_last_tx = time(); |
| 305 | - if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; |
|
| 306 | - else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
| 307 | - if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid; |
|
| 308 | - else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
| 309 | - if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter; |
|
| 310 | - else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
| 311 | - if ($aprs_full) $aprs_filter = ''; |
|
| 312 | - if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass; |
|
| 313 | - else $aprs_pass = '-1'; |
|
| 377 | + if (isset($globalAPRSversion)) { |
|
| 378 | + $aprs_version = $globalAPRSversion; |
|
| 379 | + } else { |
|
| 380 | + $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
| 381 | + } |
|
| 382 | + if (isset($globalAPRSssid)) { |
|
| 383 | + $aprs_ssid = $globalAPRSssid; |
|
| 384 | + } else { |
|
| 385 | + $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
| 386 | + } |
|
| 387 | + if (isset($globalAPRSfilter)) { |
|
| 388 | + $aprs_filter = $globalAPRSfilter; |
|
| 389 | + } else { |
|
| 390 | + $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
| 391 | + } |
|
| 392 | + if ($aprs_full) { |
|
| 393 | + $aprs_filter = ''; |
|
| 394 | + } |
|
| 395 | + if (isset($globalAPRSpass)) { |
|
| 396 | + $aprs_pass = $globalAPRSpass; |
|
| 397 | + } else { |
|
| 398 | + $aprs_pass = '-1'; |
|
| 399 | + } |
|
| 314 | 400 | |
| 315 | - if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n"; |
|
| 316 | - else $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; |
|
| 317 | -} |
|
| 401 | + if ($aprs_filter != '') { |
|
| 402 | + $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n"; |
|
| 403 | + } else { |
|
| 404 | + $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; |
|
| 405 | + } |
|
| 406 | + } |
|
| 318 | 407 | |
| 319 | 408 | // connected - lets do some work |
| 320 | -if ($globalDebug) echo "Connected!\n"; |
|
| 409 | +if ($globalDebug) { |
|
| 410 | + echo "Connected!\n"; |
|
| 411 | +} |
|
| 321 | 412 | sleep(1); |
| 322 | -if ($globalDebug) echo "SCAN MODE \n\n"; |
|
| 323 | -if (!isset($globalCronEnd)) $globalCronEnd = 60; |
|
| 413 | +if ($globalDebug) { |
|
| 414 | + echo "SCAN MODE \n\n"; |
|
| 415 | +} |
|
| 416 | +if (!isset($globalCronEnd)) { |
|
| 417 | + $globalCronEnd = 60; |
|
| 418 | +} |
|
| 324 | 419 | $endtime = time()+$globalCronEnd; |
| 325 | 420 | $i = 1; |
| 326 | 421 | $tt = array(); |
@@ -334,10 +429,14 @@ discard block |
||
| 334 | 429 | |
| 335 | 430 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
| 336 | 431 | while ($i > 0) { |
| 337 | - if (!$globalDaemon) $i = $endtime-time(); |
|
| 432 | + if (!$globalDaemon) { |
|
| 433 | + $i = $endtime-time(); |
|
| 434 | + } |
|
| 338 | 435 | // Delete old ATC |
| 339 | 436 | if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
| 340 | - if ($globalDebug) echo 'Delete old ATC...'."\n"; |
|
| 437 | + if ($globalDebug) { |
|
| 438 | + echo 'Delete old ATC...'."\n"; |
|
| 439 | + } |
|
| 341 | 440 | $ATC->deleteOldATC(); |
| 342 | 441 | } |
| 343 | 442 | |
@@ -345,10 +444,14 @@ discard block |
||
| 345 | 444 | if (count($last_exec) == count($globalSources)) { |
| 346 | 445 | $max = $globalMinFetch; |
| 347 | 446 | foreach ($last_exec as $last) { |
| 348 | - if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
| 447 | + if ((time() - $last['last']) < $max) { |
|
| 448 | + $max = time() - $last['last']; |
|
| 449 | + } |
|
| 349 | 450 | } |
| 350 | 451 | if ($max != $globalMinFetch) { |
| 351 | - if ($globalDebug) echo 'Sleeping...'."\n"; |
|
| 452 | + if ($globalDebug) { |
|
| 453 | + echo 'Sleeping...'."\n"; |
|
| 454 | + } |
|
| 352 | 455 | sleep($globalMinFetch-$max+2); |
| 353 | 456 | } |
| 354 | 457 | } |
@@ -357,11 +460,15 @@ discard block |
||
| 357 | 460 | //foreach ($formats as $id => $value) { |
| 358 | 461 | foreach ($globalSources as $id => $value) { |
| 359 | 462 | date_default_timezone_set('UTC'); |
| 360 | - if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0; |
|
| 463 | + if (!isset($last_exec[$id]['last'])) { |
|
| 464 | + $last_exec[$id]['last'] = 0; |
|
| 465 | + } |
|
| 361 | 466 | if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
| 362 | 467 | //$buffer = $Common->getData($hosts[$id]); |
| 363 | 468 | $buffer = $Common->getData($value['host']); |
| 364 | - if ($buffer != '') $reset = 0; |
|
| 469 | + if ($buffer != '') { |
|
| 470 | + $reset = 0; |
|
| 471 | + } |
|
| 365 | 472 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
| 366 | 473 | $buffer = explode('\n',$buffer); |
| 367 | 474 | foreach ($buffer as $line) { |
@@ -370,19 +477,38 @@ discard block |
||
| 370 | 477 | $data = array(); |
| 371 | 478 | $data['hex'] = $line[1]; // hex |
| 372 | 479 | $data['ident'] = $line[2]; // ident |
| 373 | - if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
| 374 | - if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
| 375 | - if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
| 376 | - if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
| 377 | - if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
| 480 | + if (isset($line[3])) { |
|
| 481 | + $data['altitude'] = $line[3]; |
|
| 482 | + } |
|
| 483 | + // altitude |
|
| 484 | + if (isset($line[4])) { |
|
| 485 | + $data['speed'] = $line[4]; |
|
| 486 | + } |
|
| 487 | + // speed |
|
| 488 | + if (isset($line[5])) { |
|
| 489 | + $data['heading'] = $line[5]; |
|
| 490 | + } |
|
| 491 | + // heading |
|
| 492 | + if (isset($line[6])) { |
|
| 493 | + $data['latitude'] = $line[6]; |
|
| 494 | + } |
|
| 495 | + // lat |
|
| 496 | + if (isset($line[7])) { |
|
| 497 | + $data['longitude'] = $line[7]; |
|
| 498 | + } |
|
| 499 | + // long |
|
| 378 | 500 | $data['verticalrate'] = ''; // vertical rate |
| 379 | 501 | //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
| 380 | 502 | $data['emergency'] = ''; // emergency |
| 381 | 503 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 382 | 504 | $data['format_source'] = 'deltadbtxt'; |
| 383 | 505 | $data['id_source'] = $id_source; |
| 384 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 385 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
| 506 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 507 | + $data['source_name'] = $value['name']; |
|
| 508 | + } |
|
| 509 | + if (isset($value['sourcestats'])) { |
|
| 510 | + $data['sourcestats'] = $value['sourcestats']; |
|
| 511 | + } |
|
| 386 | 512 | $SI->add($data); |
| 387 | 513 | unset($data); |
| 388 | 514 | } |
@@ -392,7 +518,9 @@ discard block |
||
| 392 | 518 | date_default_timezone_set('CET'); |
| 393 | 519 | $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
| 394 | 520 | date_default_timezone_set('UTC'); |
| 395 | - if ($buffer != '') $reset = 0; |
|
| 521 | + if ($buffer != '') { |
|
| 522 | + $reset = 0; |
|
| 523 | + } |
|
| 396 | 524 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
| 397 | 525 | $buffer = explode('\n',$buffer); |
| 398 | 526 | foreach ($buffer as $line) { |
@@ -401,16 +529,36 @@ discard block |
||
| 401 | 529 | $add = false; |
| 402 | 530 | $ais_data = $AIS->parse_line(trim($line)); |
| 403 | 531 | $data = array(); |
| 404 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 405 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
| 406 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 407 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 408 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 409 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 410 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 411 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 412 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 413 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 532 | + if (isset($ais_data['ident'])) { |
|
| 533 | + $data['ident'] = $ais_data['ident']; |
|
| 534 | + } |
|
| 535 | + if (isset($ais_data['mmsi'])) { |
|
| 536 | + $data['mmsi'] = $ais_data['mmsi']; |
|
| 537 | + } |
|
| 538 | + if (isset($ais_data['speed'])) { |
|
| 539 | + $data['speed'] = $ais_data['speed']; |
|
| 540 | + } |
|
| 541 | + if (isset($ais_data['heading'])) { |
|
| 542 | + $data['heading'] = $ais_data['heading']; |
|
| 543 | + } |
|
| 544 | + if (isset($ais_data['latitude'])) { |
|
| 545 | + $data['latitude'] = $ais_data['latitude']; |
|
| 546 | + } |
|
| 547 | + if (isset($ais_data['longitude'])) { |
|
| 548 | + $data['longitude'] = $ais_data['longitude']; |
|
| 549 | + } |
|
| 550 | + if (isset($ais_data['status'])) { |
|
| 551 | + $data['status'] = $ais_data['status']; |
|
| 552 | + } |
|
| 553 | + if (isset($ais_data['type'])) { |
|
| 554 | + $data['type'] = $ais_data['type']; |
|
| 555 | + } |
|
| 556 | + if (isset($ais_data['imo'])) { |
|
| 557 | + $data['imo'] = $ais_data['imo']; |
|
| 558 | + } |
|
| 559 | + if (isset($ais_data['callsign'])) { |
|
| 560 | + $data['callsign'] = $ais_data['callsign']; |
|
| 561 | + } |
|
| 414 | 562 | if (isset($ais_data['timestamp'])) { |
| 415 | 563 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
| 416 | 564 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
@@ -425,7 +573,9 @@ discard block |
||
| 425 | 573 | $data['id_source'] = $id_source; |
| 426 | 574 | print_r($data); |
| 427 | 575 | echo 'Add...'."\n"; |
| 428 | - if ($add && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
| 576 | + if ($add && $ais_data['mmsi_type'] == 'Ship') { |
|
| 577 | + $MI->add($data); |
|
| 578 | + } |
|
| 429 | 579 | unset($data); |
| 430 | 580 | } |
| 431 | 581 | } |
@@ -445,18 +595,42 @@ discard block |
||
| 445 | 595 | if ($line != '') { |
| 446 | 596 | $ais_data = $AIS->parse_line(trim($line)); |
| 447 | 597 | $data = array(); |
| 448 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 449 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
| 450 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 451 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 452 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 453 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 454 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 455 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 456 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 457 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 458 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
| 459 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 598 | + if (isset($ais_data['ident'])) { |
|
| 599 | + $data['ident'] = $ais_data['ident']; |
|
| 600 | + } |
|
| 601 | + if (isset($ais_data['mmsi'])) { |
|
| 602 | + $data['mmsi'] = $ais_data['mmsi']; |
|
| 603 | + } |
|
| 604 | + if (isset($ais_data['speed'])) { |
|
| 605 | + $data['speed'] = $ais_data['speed']; |
|
| 606 | + } |
|
| 607 | + if (isset($ais_data['heading'])) { |
|
| 608 | + $data['heading'] = $ais_data['heading']; |
|
| 609 | + } |
|
| 610 | + if (isset($ais_data['latitude'])) { |
|
| 611 | + $data['latitude'] = $ais_data['latitude']; |
|
| 612 | + } |
|
| 613 | + if (isset($ais_data['longitude'])) { |
|
| 614 | + $data['longitude'] = $ais_data['longitude']; |
|
| 615 | + } |
|
| 616 | + if (isset($ais_data['status'])) { |
|
| 617 | + $data['status'] = $ais_data['status']; |
|
| 618 | + } |
|
| 619 | + if (isset($ais_data['type'])) { |
|
| 620 | + $data['type'] = $ais_data['type']; |
|
| 621 | + } |
|
| 622 | + if (isset($ais_data['imo'])) { |
|
| 623 | + $data['imo'] = $ais_data['imo']; |
|
| 624 | + } |
|
| 625 | + if (isset($ais_data['callsign'])) { |
|
| 626 | + $data['callsign'] = $ais_data['callsign']; |
|
| 627 | + } |
|
| 628 | + if (isset($ais_data['destination'])) { |
|
| 629 | + $data['arrival_code'] = $ais_data['destination']; |
|
| 630 | + } |
|
| 631 | + if (isset($ais_data['eta_ts'])) { |
|
| 632 | + $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 633 | + } |
|
| 460 | 634 | if (isset($ais_data['timestamp'])) { |
| 461 | 635 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
| 462 | 636 | } else { |
@@ -464,7 +638,9 @@ discard block |
||
| 464 | 638 | } |
| 465 | 639 | $data['format_source'] = 'aisnmeahttp'; |
| 466 | 640 | $data['id_source'] = $id_source; |
| 467 | - if ($ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
| 641 | + if ($ais_data['mmsi_type'] == 'Ship') { |
|
| 642 | + $MI->add($data); |
|
| 643 | + } |
|
| 468 | 644 | unset($data); |
| 469 | 645 | } |
| 470 | 646 | } |
@@ -513,7 +689,9 @@ discard block |
||
| 513 | 689 | $data['callsign'] = $line['callsign']; |
| 514 | 690 | $data['mmsi'] = $line['mmsi']; |
| 515 | 691 | $data['speed'] = $line['sog']; |
| 516 | - if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
| 692 | + if ($line['heading'] != '511') { |
|
| 693 | + $data['heading'] = $line['heading']; |
|
| 694 | + } |
|
| 517 | 695 | $data['latitude'] = $line['latitude']; |
| 518 | 696 | $data['longitude'] = $line['longitude']; |
| 519 | 697 | $data['type_id'] = $line['shiptype']; |
@@ -533,7 +711,9 @@ discard block |
||
| 533 | 711 | echo 'download...'; |
| 534 | 712 | $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
| 535 | 713 | echo 'done !'."\n"; |
| 536 | - if ($buffer != '') $reset = 0; |
|
| 714 | + if ($buffer != '') { |
|
| 715 | + $reset = 0; |
|
| 716 | + } |
|
| 537 | 717 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
| 538 | 718 | $buffer = explode('\n',$buffer); |
| 539 | 719 | foreach ($buffer as $line) { |
@@ -577,16 +757,28 @@ discard block |
||
| 577 | 757 | $line = explode(':', $line); |
| 578 | 758 | if (count($line) > 30 && $line[0] != 'callsign') { |
| 579 | 759 | $data = array(); |
| 580 | - if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
|
| 581 | - else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
|
| 760 | + if (isset($line[37]) && $line[37] != '') { |
|
| 761 | + $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
|
| 762 | + } else { |
|
| 763 | + $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
|
| 764 | + } |
|
| 582 | 765 | $data['pilot_id'] = $line[1]; |
| 583 | 766 | $data['pilot_name'] = $line[2]; |
| 584 | 767 | $data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT); |
| 585 | 768 | $data['ident'] = $line[0]; // ident |
| 586 | - if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude |
|
| 769 | + if ($line[7] != '' && $line[7] != 0) { |
|
| 770 | + $data['altitude'] = $line[7]; |
|
| 771 | + } |
|
| 772 | + // altitude |
|
| 587 | 773 | $data['speed'] = $line[8]; // speed |
| 588 | - if (isset($line[45])) $data['heading'] = $line[45]; // heading |
|
| 589 | - elseif (isset($line[38])) $data['heading'] = $line[38]; // heading |
|
| 774 | + if (isset($line[45])) { |
|
| 775 | + $data['heading'] = $line[45]; |
|
| 776 | + } |
|
| 777 | + // heading |
|
| 778 | + elseif (isset($line[38])) { |
|
| 779 | + $data['heading'] = $line[38]; |
|
| 780 | + } |
|
| 781 | + // heading |
|
| 590 | 782 | $data['latitude'] = $line[5]; // lat |
| 591 | 783 | $data['longitude'] = $line[6]; // long |
| 592 | 784 | $data['verticalrate'] = ''; // vertical rate |
@@ -602,7 +794,9 @@ discard block |
||
| 602 | 794 | $data['frequency'] = $line[4]; |
| 603 | 795 | $data['type'] = $line[18]; |
| 604 | 796 | $data['range'] = $line[19]; |
| 605 | - if (isset($line[35])) $data['info'] = $line[35]; |
|
| 797 | + if (isset($line[35])) { |
|
| 798 | + $data['info'] = $line[35]; |
|
| 799 | + } |
|
| 606 | 800 | $data['id_source'] = $id_source; |
| 607 | 801 | //$data['arrival_airport_time'] = ; |
| 608 | 802 | if ($line[9] != '') { |
@@ -616,24 +810,41 @@ discard block |
||
| 616 | 810 | elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; |
| 617 | 811 | */ |
| 618 | 812 | $data['format_source'] = $value['format']; |
| 619 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 620 | - if ($line[3] == 'PILOT') $SI->add($data); |
|
| 621 | - elseif ($line[3] == 'ATC') { |
|
| 813 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 814 | + $data['source_name'] = $value['name']; |
|
| 815 | + } |
|
| 816 | + if ($line[3] == 'PILOT') { |
|
| 817 | + $SI->add($data); |
|
| 818 | + } elseif ($line[3] == 'ATC') { |
|
| 622 | 819 | //print_r($data); |
| 623 | 820 | $data['info'] = str_replace('^§','<br />',$data['info']); |
| 624 | 821 | $data['info'] = str_replace('&sect;','',$data['info']); |
| 625 | 822 | $typec = substr($data['ident'],-3); |
| 626 | - if ($typec == 'APP') $data['type'] = 'Approach'; |
|
| 627 | - elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
|
| 628 | - elseif ($typec == 'OBS') $data['type'] = 'Observer'; |
|
| 629 | - elseif ($typec == 'GND') $data['type'] = 'Ground'; |
|
| 630 | - elseif ($typec == 'DEL') $data['type'] = 'Delivery'; |
|
| 631 | - elseif ($typec == 'DEP') $data['type'] = 'Departure'; |
|
| 632 | - elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station'; |
|
| 633 | - elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
|
| 634 | - elseif ($data['type'] == '') $data['type'] = 'Observer'; |
|
| 635 | - if (!isset($data['source_name'])) $data['source_name'] = ''; |
|
| 636 | - if (isset($ATC)) 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']); |
|
| 823 | + if ($typec == 'APP') { |
|
| 824 | + $data['type'] = 'Approach'; |
|
| 825 | + } elseif ($typec == 'TWR') { |
|
| 826 | + $data['type'] = 'Tower'; |
|
| 827 | + } elseif ($typec == 'OBS') { |
|
| 828 | + $data['type'] = 'Observer'; |
|
| 829 | + } elseif ($typec == 'GND') { |
|
| 830 | + $data['type'] = 'Ground'; |
|
| 831 | + } elseif ($typec == 'DEL') { |
|
| 832 | + $data['type'] = 'Delivery'; |
|
| 833 | + } elseif ($typec == 'DEP') { |
|
| 834 | + $data['type'] = 'Departure'; |
|
| 835 | + } elseif ($typec == 'FSS') { |
|
| 836 | + $data['type'] = 'Flight Service Station'; |
|
| 837 | + } elseif ($typec == 'CTR') { |
|
| 838 | + $data['type'] = 'Control Radar or Centre'; |
|
| 839 | + } elseif ($data['type'] == '') { |
|
| 840 | + $data['type'] = 'Observer'; |
|
| 841 | + } |
|
| 842 | + if (!isset($data['source_name'])) { |
|
| 843 | + $data['source_name'] = ''; |
|
| 844 | + } |
|
| 845 | + if (isset($ATC)) { |
|
| 846 | + 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']); |
|
| 847 | + } |
|
| 637 | 848 | } |
| 638 | 849 | unset($data); |
| 639 | 850 | } |
@@ -652,26 +863,55 @@ discard block |
||
| 652 | 863 | foreach ($all_data['acList'] as $line) { |
| 653 | 864 | $data = array(); |
| 654 | 865 | $data['hex'] = $line['Icao']; // hex |
| 655 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
| 656 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
| 657 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
| 658 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
| 659 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
| 660 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
| 866 | + if (isset($line['Call'])) { |
|
| 867 | + $data['ident'] = $line['Call']; |
|
| 868 | + } |
|
| 869 | + // ident |
|
| 870 | + if (isset($line['Alt'])) { |
|
| 871 | + $data['altitude'] = $line['Alt']; |
|
| 872 | + } |
|
| 873 | + // altitude |
|
| 874 | + if (isset($line['Spd'])) { |
|
| 875 | + $data['speed'] = $line['Spd']; |
|
| 876 | + } |
|
| 877 | + // speed |
|
| 878 | + if (isset($line['Trak'])) { |
|
| 879 | + $data['heading'] = $line['Trak']; |
|
| 880 | + } |
|
| 881 | + // heading |
|
| 882 | + if (isset($line['Lat'])) { |
|
| 883 | + $data['latitude'] = $line['Lat']; |
|
| 884 | + } |
|
| 885 | + // lat |
|
| 886 | + if (isset($line['Long'])) { |
|
| 887 | + $data['longitude'] = $line['Long']; |
|
| 888 | + } |
|
| 889 | + // long |
|
| 661 | 890 | //$data['verticalrate'] = $line['']; // verticale rate |
| 662 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
| 891 | + if (isset($line['Sqk'])) { |
|
| 892 | + $data['squawk'] = $line['Sqk']; |
|
| 893 | + } |
|
| 894 | + // squawk |
|
| 663 | 895 | $data['emergency'] = ''; // emergency |
| 664 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
| 896 | + if (isset($line['Reg'])) { |
|
| 897 | + $data['registration'] = $line['Reg']; |
|
| 898 | + } |
|
| 665 | 899 | /* |
| 666 | 900 | if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000); |
| 667 | 901 | else $data['datetime'] = date('Y-m-d H:i:s'); |
| 668 | 902 | */ |
| 669 | 903 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 670 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
| 904 | + if (isset($line['Type'])) { |
|
| 905 | + $data['aircraft_icao'] = $line['Type']; |
|
| 906 | + } |
|
| 671 | 907 | $data['format_source'] = 'aircraftlistjson'; |
| 672 | 908 | $data['id_source'] = $id_source; |
| 673 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 674 | - if (isset($data['latitude'])) $SI->add($data); |
|
| 909 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 910 | + $data['source_name'] = $value['name']; |
|
| 911 | + } |
|
| 912 | + if (isset($data['latitude'])) { |
|
| 913 | + $SI->add($data); |
|
| 914 | + } |
|
| 675 | 915 | unset($data); |
| 676 | 916 | } |
| 677 | 917 | } elseif (is_array($all_data)) { |
@@ -691,7 +931,9 @@ discard block |
||
| 691 | 931 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 692 | 932 | $data['format_source'] = 'aircraftlistjson'; |
| 693 | 933 | $data['id_source'] = $id_source; |
| 694 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 934 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 935 | + $data['source_name'] = $value['name']; |
|
| 936 | + } |
|
| 695 | 937 | $SI->add($data); |
| 696 | 938 | unset($data); |
| 697 | 939 | } |
@@ -727,7 +969,9 @@ discard block |
||
| 727 | 969 | $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
| 728 | 970 | $data['format_source'] = 'planeupdatefaa'; |
| 729 | 971 | $data['id_source'] = $id_source; |
| 730 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 972 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 973 | + $data['source_name'] = $value['name']; |
|
| 974 | + } |
|
| 731 | 975 | $SI->add($data); |
| 732 | 976 | unset($data); |
| 733 | 977 | } |
@@ -767,7 +1011,9 @@ discard block |
||
| 767 | 1011 | //$buffer = $Common->getData($hosts[$id]); |
| 768 | 1012 | $buffer = $Common->getData($value['host']); |
| 769 | 1013 | $all_data = json_decode($buffer,true); |
| 770 | - if (!empty($all_data)) $reset = 0; |
|
| 1014 | + if (!empty($all_data)) { |
|
| 1015 | + $reset = 0; |
|
| 1016 | + } |
|
| 771 | 1017 | foreach ($all_data as $key => $line) { |
| 772 | 1018 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
| 773 | 1019 | $data = array(); |
@@ -788,7 +1034,9 @@ discard block |
||
| 788 | 1034 | $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
| 789 | 1035 | $data['format_source'] = 'fr24json'; |
| 790 | 1036 | $data['id_source'] = $id_source; |
| 791 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1037 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1038 | + $data['source_name'] = $value['name']; |
|
| 1039 | + } |
|
| 792 | 1040 | $SI->add($data); |
| 793 | 1041 | unset($data); |
| 794 | 1042 | } |
@@ -812,23 +1060,39 @@ discard block |
||
| 812 | 1060 | if (isset($line['inf'])) { |
| 813 | 1061 | $data = array(); |
| 814 | 1062 | $data['hex'] = $line['inf']['ia']; |
| 815 | - if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] |
|
| 1063 | + if (isset($line['inf']['cs'])) { |
|
| 1064 | + $data['ident'] = $line['inf']['cs']; |
|
| 1065 | + } |
|
| 1066 | + //$line[13] |
|
| 816 | 1067 | $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
| 817 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
| 818 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
| 1068 | + if (isset($line['inf']['gs'])) { |
|
| 1069 | + $data['speed'] = round($line['inf']['gs']*0.539957); |
|
| 1070 | + } |
|
| 1071 | + // speed |
|
| 1072 | + if (isset($line['inf']['tr'])) { |
|
| 1073 | + $data['heading'] = $line['inf']['tr']; |
|
| 1074 | + } |
|
| 1075 | + // heading |
|
| 819 | 1076 | $data['latitude'] = $line['pt'][0]; // lat |
| 820 | 1077 | $data['longitude'] = $line['pt'][1]; // long |
| 821 | 1078 | //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
| 822 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
| 1079 | + if (isset($line['inf']['sq'])) { |
|
| 1080 | + $data['squawk'] = $line['inf']['sq']; |
|
| 1081 | + } |
|
| 1082 | + // squawk |
|
| 823 | 1083 | //$data['aircraft_icao'] = $line[8]; |
| 824 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
| 1084 | + if (isset($line['inf']['rc'])) { |
|
| 1085 | + $data['registration'] = $line['inf']['rc']; |
|
| 1086 | + } |
|
| 825 | 1087 | //$data['departure_airport_iata'] = $line[11]; |
| 826 | 1088 | //$data['arrival_airport_iata'] = $line[12]; |
| 827 | 1089 | //$data['emergency'] = ''; // emergency |
| 828 | 1090 | $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
| 829 | 1091 | $data['format_source'] = 'radarvirtueljson'; |
| 830 | 1092 | $data['id_source'] = $id_source; |
| 831 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1093 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1094 | + $data['source_name'] = $value['name']; |
|
| 1095 | + } |
|
| 832 | 1096 | $SI->add($data); |
| 833 | 1097 | unset($data); |
| 834 | 1098 | } |
@@ -849,29 +1113,62 @@ discard block |
||
| 849 | 1113 | $data['id'] = $line['id']; |
| 850 | 1114 | $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
| 851 | 1115 | $data['ident'] = $line['callsign']; // ident |
| 852 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
| 853 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
| 854 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
| 855 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
| 856 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
| 857 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1116 | + if (isset($line['pilotid'])) { |
|
| 1117 | + $data['pilot_id'] = $line['pilotid']; |
|
| 1118 | + } |
|
| 1119 | + // pilot id |
|
| 1120 | + if (isset($line['name'])) { |
|
| 1121 | + $data['pilot_name'] = $line['name']; |
|
| 1122 | + } |
|
| 1123 | + // pilot name |
|
| 1124 | + if (isset($line['alt'])) { |
|
| 1125 | + $data['altitude'] = $line['alt']; |
|
| 1126 | + } |
|
| 1127 | + // altitude |
|
| 1128 | + if (isset($line['gs'])) { |
|
| 1129 | + $data['speed'] = $line['gs']; |
|
| 1130 | + } |
|
| 1131 | + // speed |
|
| 1132 | + if (isset($line['heading'])) { |
|
| 1133 | + $data['heading'] = $line['heading']; |
|
| 1134 | + } |
|
| 1135 | + // heading |
|
| 1136 | + if (isset($line['route'])) { |
|
| 1137 | + $data['waypoints'] = $line['route']; |
|
| 1138 | + } |
|
| 1139 | + // route |
|
| 858 | 1140 | $data['latitude'] = $line['lat']; // lat |
| 859 | 1141 | $data['longitude'] = $line['lon']; // long |
| 860 | 1142 | //$data['verticalrate'] = $line['vrt']; // verticale rate |
| 861 | 1143 | //$data['squawk'] = $line['squawk']; // squawk |
| 862 | 1144 | //$data['emergency'] = ''; // emergency |
| 863 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
| 864 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
| 865 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
| 1145 | + if (isset($line['depicao'])) { |
|
| 1146 | + $data['departure_airport_icao'] = $line['depicao']; |
|
| 1147 | + } |
|
| 1148 | + if (isset($line['deptime'])) { |
|
| 1149 | + $data['departure_airport_time'] = $line['deptime']; |
|
| 1150 | + } |
|
| 1151 | + if (isset($line['arricao'])) { |
|
| 1152 | + $data['arrival_airport_icao'] = $line['arricao']; |
|
| 1153 | + } |
|
| 866 | 1154 | //$data['arrival_airport_time'] = $line['arrtime']; |
| 867 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
| 868 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
| 869 | - if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
| 870 | - else $data['info'] = ''; |
|
| 1155 | + if (isset($line['aircraft'])) { |
|
| 1156 | + $data['aircraft_icao'] = $line['aircraft']; |
|
| 1157 | + } |
|
| 1158 | + if (isset($line['transponder'])) { |
|
| 1159 | + $data['squawk'] = $line['transponder']; |
|
| 1160 | + } |
|
| 1161 | + if (isset($line['atis'])) { |
|
| 1162 | + $data['info'] = $line['atis']; |
|
| 1163 | + } else { |
|
| 1164 | + $data['info'] = ''; |
|
| 1165 | + } |
|
| 871 | 1166 | $data['format_source'] = 'pireps'; |
| 872 | 1167 | $data['id_source'] = $id_source; |
| 873 | 1168 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 874 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1169 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1170 | + $data['source_name'] = $value['name']; |
|
| 1171 | + } |
|
| 875 | 1172 | if ($line['icon'] == 'plane') { |
| 876 | 1173 | $SI->add($data); |
| 877 | 1174 | // print_r($data); |
@@ -880,16 +1177,28 @@ discard block |
||
| 880 | 1177 | $data['info'] = str_replace('&sect;','',$data['info']); |
| 881 | 1178 | $typec = substr($data['ident'],-3); |
| 882 | 1179 | $data['type'] = ''; |
| 883 | - if ($typec == 'APP') $data['type'] = 'Approach'; |
|
| 884 | - elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
|
| 885 | - elseif ($typec == 'OBS') $data['type'] = 'Observer'; |
|
| 886 | - elseif ($typec == 'GND') $data['type'] = 'Ground'; |
|
| 887 | - elseif ($typec == 'DEL') $data['type'] = 'Delivery'; |
|
| 888 | - elseif ($typec == 'DEP') $data['type'] = 'Departure'; |
|
| 889 | - elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station'; |
|
| 890 | - elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
|
| 891 | - else $data['type'] = 'Observer'; |
|
| 892 | - 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']); |
|
| 1180 | + if ($typec == 'APP') { |
|
| 1181 | + $data['type'] = 'Approach'; |
|
| 1182 | + } elseif ($typec == 'TWR') { |
|
| 1183 | + $data['type'] = 'Tower'; |
|
| 1184 | + } elseif ($typec == 'OBS') { |
|
| 1185 | + $data['type'] = 'Observer'; |
|
| 1186 | + } elseif ($typec == 'GND') { |
|
| 1187 | + $data['type'] = 'Ground'; |
|
| 1188 | + } elseif ($typec == 'DEL') { |
|
| 1189 | + $data['type'] = 'Delivery'; |
|
| 1190 | + } elseif ($typec == 'DEP') { |
|
| 1191 | + $data['type'] = 'Departure'; |
|
| 1192 | + } elseif ($typec == 'FSS') { |
|
| 1193 | + $data['type'] = 'Flight Service Station'; |
|
| 1194 | + } elseif ($typec == 'CTR') { |
|
| 1195 | + $data['type'] = 'Control Radar or Centre'; |
|
| 1196 | + } else { |
|
| 1197 | + $data['type'] = 'Observer'; |
|
| 1198 | + } |
|
| 1199 | + if (isset($ATC)) { |
|
| 1200 | + 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']); |
|
| 1201 | + } |
|
| 893 | 1202 | } |
| 894 | 1203 | unset($data); |
| 895 | 1204 | } |
@@ -899,7 +1208,9 @@ discard block |
||
| 899 | 1208 | //} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
| 900 | 1209 | } elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
| 901 | 1210 | //$buffer = $Common->getData($hosts[$id]); |
| 902 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 1211 | + if ($globalDebug) { |
|
| 1212 | + echo 'Get Data...'."\n"; |
|
| 1213 | + } |
|
| 903 | 1214 | $buffer = $Common->getData($value['host']); |
| 904 | 1215 | $all_data = json_decode($buffer,true); |
| 905 | 1216 | if ($buffer != '' && is_array($all_data)) { |
@@ -907,10 +1218,16 @@ discard block |
||
| 907 | 1218 | foreach ($all_data as $line) { |
| 908 | 1219 | $data = array(); |
| 909 | 1220 | //$data['id'] = $line['id']; // id not usable |
| 910 | - if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
| 1221 | + if (isset($line['pilotid'])) { |
|
| 1222 | + $data['id'] = $line['pilotid'].$line['flightnum']; |
|
| 1223 | + } |
|
| 911 | 1224 | $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
| 912 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
| 913 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
| 1225 | + if (isset($line['pilotname'])) { |
|
| 1226 | + $data['pilot_name'] = $line['pilotname']; |
|
| 1227 | + } |
|
| 1228 | + if (isset($line['pilotid'])) { |
|
| 1229 | + $data['pilot_id'] = $line['pilotid']; |
|
| 1230 | + } |
|
| 914 | 1231 | $data['ident'] = $line['flightnum']; // ident |
| 915 | 1232 | $data['altitude'] = $line['alt']; // altitude |
| 916 | 1233 | $data['speed'] = $line['gs']; // speed |
@@ -928,27 +1245,41 @@ discard block |
||
| 928 | 1245 | $data['arrival_airport_icao'] = $line['arricao']; |
| 929 | 1246 | $data['arrival_airport_time'] = $line['arrtime']; |
| 930 | 1247 | $data['registration'] = $line['aircraft']; |
| 931 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1248 | + if (isset($line['route'])) { |
|
| 1249 | + $data['waypoints'] = $line['route']; |
|
| 1250 | + } |
|
| 1251 | + // route |
|
| 932 | 1252 | if (isset($line['aircraftname'])) { |
| 933 | 1253 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
| 934 | 1254 | $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
| 935 | 1255 | $aircraft_data = explode('-',$line['aircraftname']); |
| 936 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) $data['aircraft_icao'] = $aircraft_data[0]; |
|
| 937 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 938 | - else { |
|
| 1256 | + if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) { |
|
| 1257 | + $data['aircraft_icao'] = $aircraft_data[0]; |
|
| 1258 | + } elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) { |
|
| 1259 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 1260 | + } else { |
|
| 939 | 1261 | $aircraft_data = explode(' ',$line['aircraftname']); |
| 940 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 941 | - else $data['aircraft_icao'] = $line['aircraftname']; |
|
| 1262 | + if (isset($aircraft_data[1])) { |
|
| 1263 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 1264 | + } else { |
|
| 1265 | + $data['aircraft_icao'] = $line['aircraftname']; |
|
| 1266 | + } |
|
| 942 | 1267 | } |
| 943 | 1268 | } |
| 944 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
| 1269 | + if (isset($line['route'])) { |
|
| 1270 | + $data['waypoints'] = $line['route']; |
|
| 1271 | + } |
|
| 945 | 1272 | $data['id_source'] = $id_source; |
| 946 | 1273 | $data['format_source'] = 'phpvmacars'; |
| 947 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1274 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1275 | + $data['source_name'] = $value['name']; |
|
| 1276 | + } |
|
| 948 | 1277 | $SI->add($data); |
| 949 | 1278 | unset($data); |
| 950 | 1279 | } |
| 951 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
| 1280 | + if ($globalDebug) { |
|
| 1281 | + echo 'No more data...'."\n"; |
|
| 1282 | + } |
|
| 952 | 1283 | unset($buffer); |
| 953 | 1284 | unset($all_data); |
| 954 | 1285 | } |
@@ -956,7 +1287,9 @@ discard block |
||
| 956 | 1287 | $last_exec[$id]['last'] = time(); |
| 957 | 1288 | } elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
| 958 | 1289 | //$buffer = $Common->getData($hosts[$id]); |
| 959 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 1290 | + if ($globalDebug) { |
|
| 1291 | + echo 'Get Data...'."\n"; |
|
| 1292 | + } |
|
| 960 | 1293 | $buffer = $Common->getData($value['host']); |
| 961 | 1294 | $all_data = json_decode($buffer,true); |
| 962 | 1295 | if ($buffer != '' && is_array($all_data)) { |
@@ -985,15 +1318,22 @@ discard block |
||
| 985 | 1318 | $data['arrival_airport_icao'] = $line['arrival']; |
| 986 | 1319 | //$data['arrival_airport_time'] = $line['arrival_time']; |
| 987 | 1320 | //$data['registration'] = $line['aircraft']; |
| 988 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1321 | + if (isset($line['route'])) { |
|
| 1322 | + $data['waypoints'] = $line['route']; |
|
| 1323 | + } |
|
| 1324 | + // route |
|
| 989 | 1325 | $data['aircraft_icao'] = $line['plane_type']; |
| 990 | 1326 | $data['id_source'] = $id_source; |
| 991 | 1327 | $data['format_source'] = 'vam'; |
| 992 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1328 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1329 | + $data['source_name'] = $value['name']; |
|
| 1330 | + } |
|
| 993 | 1331 | $SI->add($data); |
| 994 | 1332 | unset($data); |
| 995 | 1333 | } |
| 996 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
| 1334 | + if ($globalDebug) { |
|
| 1335 | + echo 'No more data...'."\n"; |
|
| 1336 | + } |
|
| 997 | 1337 | unset($buffer); |
| 998 | 1338 | unset($all_data); |
| 999 | 1339 | } |
@@ -1001,7 +1341,9 @@ discard block |
||
| 1001 | 1341 | $last_exec[$id]['last'] = time(); |
| 1002 | 1342 | //} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') { |
| 1003 | 1343 | } elseif ($value['format'] == 'sbs' || $value['format'] == 'tsv' || $value['format'] == 'raw' || $value['format'] == 'aprs' || $value['format'] == 'beast' || $value['format'] == 'flightgearmp' || $value['format'] == 'flightgearsp' || $value['format'] == 'acars' || $value['format'] == 'acarssbs3' || $value['format'] == 'ais' || $value['format'] == 'vrstcp') { |
| 1004 | - if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
| 1344 | + if (function_exists('pcntl_fork')) { |
|
| 1345 | + pcntl_signal_dispatch(); |
|
| 1346 | + } |
|
| 1005 | 1347 | //$last_exec[$id]['last'] = time(); |
| 1006 | 1348 | |
| 1007 | 1349 | //$read = array( $sockets[$id] ); |
@@ -1009,7 +1351,9 @@ discard block |
||
| 1009 | 1351 | $write = NULL; |
| 1010 | 1352 | $e = NULL; |
| 1011 | 1353 | $n = socket_select($read, $write, $e, $timeout); |
| 1012 | - if ($e != NULL) var_dump($e); |
|
| 1354 | + if ($e != NULL) { |
|
| 1355 | + var_dump($e); |
|
| 1356 | + } |
|
| 1013 | 1357 | if ($n > 0) { |
| 1014 | 1358 | $reset = 0; |
| 1015 | 1359 | foreach ($read as $nb => $r) { |
@@ -1028,12 +1372,16 @@ discard block |
||
| 1028 | 1372 | //$SI::del(); |
| 1029 | 1373 | if ($format == 'vrstcp') { |
| 1030 | 1374 | $buffer = explode('},{',$buffer); |
| 1031 | - } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
| 1375 | + } else { |
|
| 1376 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
| 1377 | + } |
|
| 1032 | 1378 | // SBS format is CSV format |
| 1033 | 1379 | if ($buffer !== FALSE && $buffer != '') { |
| 1034 | 1380 | $tt[$format] = 0; |
| 1035 | 1381 | if ($format == 'acarssbs3') { |
| 1036 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 1382 | + if ($globalDebug) { |
|
| 1383 | + echo 'ACARS : '.$buffer."\n"; |
|
| 1384 | + } |
|
| 1037 | 1385 | $ACARS->add(trim($buffer)); |
| 1038 | 1386 | $ACARS->deleteLiveAcarsData(); |
| 1039 | 1387 | } elseif ($format == 'raw') { |
@@ -1042,25 +1390,55 @@ discard block |
||
| 1042 | 1390 | if (is_array($data)) { |
| 1043 | 1391 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1044 | 1392 | $data['format_source'] = 'raw'; |
| 1045 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1046 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1047 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 1393 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
| 1394 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1395 | + } |
|
| 1396 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
| 1397 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1398 | + } |
|
| 1399 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 1400 | + $SI->add($data); |
|
| 1401 | + } |
|
| 1048 | 1402 | } |
| 1049 | 1403 | } elseif ($format == 'ais') { |
| 1050 | 1404 | $ais_data = $AIS->parse_line(trim($buffer)); |
| 1051 | 1405 | $data = array(); |
| 1052 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 1053 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
| 1054 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 1055 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 1056 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 1057 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 1058 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 1059 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 1060 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 1061 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 1062 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
| 1063 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 1406 | + if (isset($ais_data['ident'])) { |
|
| 1407 | + $data['ident'] = $ais_data['ident']; |
|
| 1408 | + } |
|
| 1409 | + if (isset($ais_data['mmsi'])) { |
|
| 1410 | + $data['mmsi'] = $ais_data['mmsi']; |
|
| 1411 | + } |
|
| 1412 | + if (isset($ais_data['speed'])) { |
|
| 1413 | + $data['speed'] = $ais_data['speed']; |
|
| 1414 | + } |
|
| 1415 | + if (isset($ais_data['heading'])) { |
|
| 1416 | + $data['heading'] = $ais_data['heading']; |
|
| 1417 | + } |
|
| 1418 | + if (isset($ais_data['latitude'])) { |
|
| 1419 | + $data['latitude'] = $ais_data['latitude']; |
|
| 1420 | + } |
|
| 1421 | + if (isset($ais_data['longitude'])) { |
|
| 1422 | + $data['longitude'] = $ais_data['longitude']; |
|
| 1423 | + } |
|
| 1424 | + if (isset($ais_data['status'])) { |
|
| 1425 | + $data['status'] = $ais_data['status']; |
|
| 1426 | + } |
|
| 1427 | + if (isset($ais_data['type'])) { |
|
| 1428 | + $data['type'] = $ais_data['type']; |
|
| 1429 | + } |
|
| 1430 | + if (isset($ais_data['imo'])) { |
|
| 1431 | + $data['imo'] = $ais_data['imo']; |
|
| 1432 | + } |
|
| 1433 | + if (isset($ais_data['callsign'])) { |
|
| 1434 | + $data['callsign'] = $ais_data['callsign']; |
|
| 1435 | + } |
|
| 1436 | + if (isset($ais_data['destination'])) { |
|
| 1437 | + $data['arrival_code'] = $ais_data['destination']; |
|
| 1438 | + } |
|
| 1439 | + if (isset($ais_data['eta_ts'])) { |
|
| 1440 | + $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 1441 | + } |
|
| 1064 | 1442 | |
| 1065 | 1443 | if (isset($ais_data['timestamp'])) { |
| 1066 | 1444 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
@@ -1069,7 +1447,9 @@ discard block |
||
| 1069 | 1447 | } |
| 1070 | 1448 | $data['format_source'] = 'aisnmea'; |
| 1071 | 1449 | $data['id_source'] = $id_source; |
| 1072 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
| 1450 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') { |
|
| 1451 | + $MI->add($data); |
|
| 1452 | + } |
|
| 1073 | 1453 | unset($data); |
| 1074 | 1454 | } elseif ($format == 'flightgearsp') { |
| 1075 | 1455 | //echo $buffer."\n"; |
@@ -1087,11 +1467,15 @@ discard block |
||
| 1087 | 1467 | $data['speed'] = round($line[5]*1.94384); |
| 1088 | 1468 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1089 | 1469 | $data['format_source'] = 'flightgearsp'; |
| 1090 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 1470 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 1471 | + $SI->add($data); |
|
| 1472 | + } |
|
| 1091 | 1473 | $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
| 1092 | 1474 | } |
| 1093 | 1475 | } elseif ($format == 'acars') { |
| 1094 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 1476 | + if ($globalDebug) { |
|
| 1477 | + echo 'ACARS : '.$buffer."\n"; |
|
| 1478 | + } |
|
| 1095 | 1479 | $ACARS->add(trim($buffer)); |
| 1096 | 1480 | socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
| 1097 | 1481 | $ACARS->deleteLiveAcarsData(); |
@@ -1112,7 +1496,9 @@ discard block |
||
| 1112 | 1496 | $aircraft_type = $line[10]; |
| 1113 | 1497 | $aircraft_type = preg_split(':/:',$aircraft_type); |
| 1114 | 1498 | $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
| 1115 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 1499 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 1500 | + $SI->add($data); |
|
| 1501 | + } |
|
| 1116 | 1502 | } |
| 1117 | 1503 | } |
| 1118 | 1504 | } elseif ($format == 'beast') { |
@@ -1122,27 +1508,59 @@ discard block |
||
| 1122 | 1508 | foreach($buffer as $all_data) { |
| 1123 | 1509 | $line = json_decode('{'.$all_data.'}',true); |
| 1124 | 1510 | $data = array(); |
| 1125 | - if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
|
| 1126 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
| 1127 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
| 1128 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
| 1129 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
| 1130 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
| 1131 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
| 1511 | + if (isset($line['Icao'])) { |
|
| 1512 | + $data['hex'] = $line['Icao']; |
|
| 1513 | + } |
|
| 1514 | + // hex |
|
| 1515 | + if (isset($line['Call'])) { |
|
| 1516 | + $data['ident'] = $line['Call']; |
|
| 1517 | + } |
|
| 1518 | + // ident |
|
| 1519 | + if (isset($line['Alt'])) { |
|
| 1520 | + $data['altitude'] = $line['Alt']; |
|
| 1521 | + } |
|
| 1522 | + // altitude |
|
| 1523 | + if (isset($line['Spd'])) { |
|
| 1524 | + $data['speed'] = $line['Spd']; |
|
| 1525 | + } |
|
| 1526 | + // speed |
|
| 1527 | + if (isset($line['Trak'])) { |
|
| 1528 | + $data['heading'] = $line['Trak']; |
|
| 1529 | + } |
|
| 1530 | + // heading |
|
| 1531 | + if (isset($line['Lat'])) { |
|
| 1532 | + $data['latitude'] = $line['Lat']; |
|
| 1533 | + } |
|
| 1534 | + // lat |
|
| 1535 | + if (isset($line['Long'])) { |
|
| 1536 | + $data['longitude'] = $line['Long']; |
|
| 1537 | + } |
|
| 1538 | + // long |
|
| 1132 | 1539 | //$data['verticalrate'] = $line['']; // verticale rate |
| 1133 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
| 1540 | + if (isset($line['Sqk'])) { |
|
| 1541 | + $data['squawk'] = $line['Sqk']; |
|
| 1542 | + } |
|
| 1543 | + // squawk |
|
| 1134 | 1544 | $data['emergency'] = ''; // emergency |
| 1135 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
| 1545 | + if (isset($line['Reg'])) { |
|
| 1546 | + $data['registration'] = $line['Reg']; |
|
| 1547 | + } |
|
| 1136 | 1548 | /* |
| 1137 | 1549 | if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000); |
| 1138 | 1550 | else $data['datetime'] = date('Y-m-d H:i:s'); |
| 1139 | 1551 | */ |
| 1140 | 1552 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1141 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
| 1553 | + if (isset($line['Type'])) { |
|
| 1554 | + $data['aircraft_icao'] = $line['Type']; |
|
| 1555 | + } |
|
| 1142 | 1556 | $data['format_source'] = 'vrstcp'; |
| 1143 | 1557 | $data['id_source'] = $id_source; |
| 1144 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1145 | - if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
|
| 1558 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1559 | + $data['source_name'] = $value['name']; |
|
| 1560 | + } |
|
| 1561 | + if (isset($data['latitude']) && isset($data['hex'])) { |
|
| 1562 | + $SI->add($data); |
|
| 1563 | + } |
|
| 1146 | 1564 | unset($data); |
| 1147 | 1565 | } |
| 1148 | 1566 | } elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') { |
@@ -1155,21 +1573,43 @@ discard block |
||
| 1155 | 1573 | $data['hex'] = $lined['hexid']; |
| 1156 | 1574 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
| 1157 | 1575 | $data['datetime'] = date('Y-m-d H:i:s');; |
| 1158 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
| 1159 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
| 1160 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
| 1161 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
| 1162 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
| 1163 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
| 1164 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
| 1576 | + if (isset($lined['ident'])) { |
|
| 1577 | + $data['ident'] = $lined['ident']; |
|
| 1578 | + } |
|
| 1579 | + if (isset($lined['lat'])) { |
|
| 1580 | + $data['latitude'] = $lined['lat']; |
|
| 1581 | + } |
|
| 1582 | + if (isset($lined['lon'])) { |
|
| 1583 | + $data['longitude'] = $lined['lon']; |
|
| 1584 | + } |
|
| 1585 | + if (isset($lined['speed'])) { |
|
| 1586 | + $data['speed'] = $lined['speed']; |
|
| 1587 | + } |
|
| 1588 | + if (isset($lined['squawk'])) { |
|
| 1589 | + $data['squawk'] = $lined['squawk']; |
|
| 1590 | + } |
|
| 1591 | + if (isset($lined['alt'])) { |
|
| 1592 | + $data['altitude'] = $lined['alt']; |
|
| 1593 | + } |
|
| 1594 | + if (isset($lined['heading'])) { |
|
| 1595 | + $data['heading'] = $lined['heading']; |
|
| 1596 | + } |
|
| 1165 | 1597 | $data['id_source'] = $id_source; |
| 1166 | 1598 | $data['format_source'] = 'tsv'; |
| 1167 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1168 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1169 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 1599 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
| 1600 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1601 | + } |
|
| 1602 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
| 1603 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1604 | + } |
|
| 1605 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 1606 | + $SI->add($data); |
|
| 1607 | + } |
|
| 1170 | 1608 | unset($lined); |
| 1171 | 1609 | unset($data); |
| 1172 | - } else $error = true; |
|
| 1610 | + } else { |
|
| 1611 | + $error = true; |
|
| 1612 | + } |
|
| 1173 | 1613 | } elseif ($format == 'aprs' && $use_aprs) { |
| 1174 | 1614 | if ($aprs_connect == 0) { |
| 1175 | 1615 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
@@ -1195,49 +1635,82 @@ discard block |
||
| 1195 | 1635 | $aprs_last_tx = time(); |
| 1196 | 1636 | $data = array(); |
| 1197 | 1637 | //print_r($line); |
| 1198 | - if (isset($line['address'])) $data['hex'] = $line['address']; |
|
| 1199 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
| 1200 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1638 | + if (isset($line['address'])) { |
|
| 1639 | + $data['hex'] = $line['address']; |
|
| 1640 | + } |
|
| 1641 | + if (isset($line['timestamp'])) { |
|
| 1642 | + $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
| 1643 | + } else { |
|
| 1644 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1645 | + } |
|
| 1201 | 1646 | //$data['datetime'] = date('Y-m-d H:i:s'); |
| 1202 | - if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
| 1647 | + if (isset($line['ident'])) { |
|
| 1648 | + $data['ident'] = $line['ident']; |
|
| 1649 | + } |
|
| 1203 | 1650 | $data['latitude'] = $line['latitude']; |
| 1204 | 1651 | $data['longitude'] = $line['longitude']; |
| 1205 | 1652 | //$data['verticalrate'] = $line[16]; |
| 1206 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
| 1207 | - else $data['speed'] = 0; |
|
| 1208 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
| 1209 | - if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
| 1210 | - if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
| 1211 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
| 1653 | + if (isset($line['speed'])) { |
|
| 1654 | + $data['speed'] = $line['speed']; |
|
| 1655 | + } else { |
|
| 1656 | + $data['speed'] = 0; |
|
| 1657 | + } |
|
| 1658 | + if (isset($line['altitude'])) { |
|
| 1659 | + $data['altitude'] = $line['altitude']; |
|
| 1660 | + } |
|
| 1661 | + if (isset($line['comment'])) { |
|
| 1662 | + $data['comment'] = $line['comment']; |
|
| 1663 | + } |
|
| 1664 | + if (isset($line['symbol'])) { |
|
| 1665 | + $data['type'] = $line['symbol']; |
|
| 1666 | + } |
|
| 1667 | + if (isset($line['heading'])) { |
|
| 1668 | + $data['heading'] = $line['heading']; |
|
| 1669 | + } |
|
| 1212 | 1670 | //else $data['heading'] = 0; |
| 1213 | - if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
| 1214 | - if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) $data['noarchive'] = true; |
|
| 1671 | + if (isset($line['stealth'])) { |
|
| 1672 | + $data['aircraft_type'] = $line['stealth']; |
|
| 1673 | + } |
|
| 1674 | + if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) { |
|
| 1675 | + $data['noarchive'] = true; |
|
| 1676 | + } |
|
| 1215 | 1677 | $data['id_source'] = $id_source; |
| 1216 | - if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
| 1217 | - else $data['format_source'] = 'aprs'; |
|
| 1678 | + if (isset($line['format_source'])) { |
|
| 1679 | + $data['format_source'] = $line['format_source']; |
|
| 1680 | + } else { |
|
| 1681 | + $data['format_source'] = 'aprs'; |
|
| 1682 | + } |
|
| 1218 | 1683 | $data['source_name'] = $line['source']; |
| 1219 | - if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
| 1220 | - else $data['source_type'] = 'flarm'; |
|
| 1221 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1684 | + if (isset($line['source_type'])) { |
|
| 1685 | + $data['source_type'] = $line['source_type']; |
|
| 1686 | + } else { |
|
| 1687 | + $data['source_type'] = 'flarm'; |
|
| 1688 | + } |
|
| 1689 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
| 1690 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1691 | + } |
|
| 1222 | 1692 | $currentdate = date('Y-m-d H:i:s'); |
| 1223 | 1693 | $aprsdate = strtotime($data['datetime']); |
| 1224 | 1694 | // Accept data if time <= system time + 20s |
| 1225 | 1695 | 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'])))) { |
| 1226 | 1696 | $send = $SI->add($data); |
| 1227 | 1697 | } elseif (isset($line['stealth'])) { |
| 1228 | - if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
|
| 1229 | - else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
|
| 1698 | + if ($line['stealth'] != 0) { |
|
| 1699 | + echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
|
| 1700 | + } else { |
|
| 1701 | + echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
|
| 1702 | + } |
|
| 1230 | 1703 | //} elseif (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' || $line['symbol'] == 'Police' || $line['symbol'] == 'Bike' || $line['symbol'] == 'Jogger' || $line['symbol'] == 'Bus' || $line['symbol'] == 'Jeep' || $line['symbol'] == 'Recreational Vehicle' || $line['symbol'] == 'Yacht (Sail)' || $line['symbol'] == 'Ship (Power Boat)' || $line['symbol'] == 'Firetruck' || $line['symbol'] == 'Balloon' || $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) { |
| 1231 | 1704 | } 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') { |
| 1232 | 1705 | //echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n"; |
| 1233 | - if (isset($globalTracker) && $globalTracker) $send = $TI->add($data); |
|
| 1706 | + if (isset($globalTracker) && $globalTracker) { |
|
| 1707 | + $send = $TI->add($data); |
|
| 1708 | + } |
|
| 1234 | 1709 | } |
| 1235 | 1710 | unset($data); |
| 1236 | - } |
|
| 1237 | - elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') { |
|
| 1711 | + } elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') { |
|
| 1238 | 1712 | echo '!! Weather Station not yet supported'."\n"; |
| 1239 | - } |
|
| 1240 | - 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')) { |
|
| 1713 | + } 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')) { |
|
| 1241 | 1714 | echo '!! Car & Trucks not yet supported'."\n"; |
| 1242 | 1715 | } |
| 1243 | 1716 | //elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n"; |
@@ -1270,25 +1743,42 @@ discard block |
||
| 1270 | 1743 | $data['ground'] = $line[21]; |
| 1271 | 1744 | $data['emergency'] = $line[19]; |
| 1272 | 1745 | $data['format_source'] = 'sbs'; |
| 1273 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1274 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1746 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
| 1747 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1748 | + } |
|
| 1749 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
| 1750 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1751 | + } |
|
| 1275 | 1752 | $data['id_source'] = $id_source; |
| 1276 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
| 1277 | - else $error = true; |
|
| 1753 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 1754 | + $send = $SI->add($data); |
|
| 1755 | + } else { |
|
| 1756 | + $error = true; |
|
| 1757 | + } |
|
| 1278 | 1758 | unset($data); |
| 1279 | - } else $error = true; |
|
| 1759 | + } else { |
|
| 1760 | + $error = true; |
|
| 1761 | + } |
|
| 1280 | 1762 | if ($error) { |
| 1281 | 1763 | if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { |
| 1282 | - if ($globalDebug) echo "Not a message. Ignoring... \n"; |
|
| 1764 | + if ($globalDebug) { |
|
| 1765 | + echo "Not a message. Ignoring... \n"; |
|
| 1766 | + } |
|
| 1283 | 1767 | } else { |
| 1284 | - if ($globalDebug) echo "Wrong line format. Ignoring... \n"; |
|
| 1768 | + if ($globalDebug) { |
|
| 1769 | + echo "Wrong line format. Ignoring... \n"; |
|
| 1770 | + } |
|
| 1285 | 1771 | if ($globalDebug) { |
| 1286 | 1772 | echo $buffer; |
| 1287 | 1773 | print_r($line); |
| 1288 | 1774 | } |
| 1289 | 1775 | //socket_close($r); |
| 1290 | - if ($globalDebug) echo "Reconnect after an error...\n"; |
|
| 1291 | - if ($format == 'aprs') $aprs_connect = 0; |
|
| 1776 | + if ($globalDebug) { |
|
| 1777 | + echo "Reconnect after an error...\n"; |
|
| 1778 | + } |
|
| 1779 | + if ($format == 'aprs') { |
|
| 1780 | + $aprs_connect = 0; |
|
| 1781 | + } |
|
| 1292 | 1782 | $sourceer[$nb] = $globalSources[$nb]; |
| 1293 | 1783 | connect_all($sourceer); |
| 1294 | 1784 | $sourceer = array(); |
@@ -1296,10 +1786,14 @@ discard block |
||
| 1296 | 1786 | } |
| 1297 | 1787 | } |
| 1298 | 1788 | // Sleep for xxx microseconds |
| 1299 | - if (isset($globalSBSSleep)) usleep($globalSBSSleep); |
|
| 1789 | + if (isset($globalSBSSleep)) { |
|
| 1790 | + usleep($globalSBSSleep); |
|
| 1791 | + } |
|
| 1300 | 1792 | } else { |
| 1301 | 1793 | if ($format == 'flightgearmp') { |
| 1302 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
| 1794 | + if ($globalDebug) { |
|
| 1795 | + echo "Reconnect FlightGear MP..."; |
|
| 1796 | + } |
|
| 1303 | 1797 | //@socket_close($r); |
| 1304 | 1798 | sleep($globalMinFetch); |
| 1305 | 1799 | $sourcefg[$nb] = $globalSources[$nb]; |
@@ -1308,10 +1802,15 @@ discard block |
||
| 1308 | 1802 | break; |
| 1309 | 1803 | |
| 1310 | 1804 | } elseif ($format != 'acars' && $format != 'flightgearsp') { |
| 1311 | - if (isset($tt[$format])) $tt[$format]++; |
|
| 1312 | - else $tt[$format] = 0; |
|
| 1805 | + if (isset($tt[$format])) { |
|
| 1806 | + $tt[$format]++; |
|
| 1807 | + } else { |
|
| 1808 | + $tt[$format] = 0; |
|
| 1809 | + } |
|
| 1313 | 1810 | if ($tt[$format] > 30) { |
| 1314 | - if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; |
|
| 1811 | + if ($globalDebug) { |
|
| 1812 | + echo "ERROR : Reconnect ".$format."..."; |
|
| 1813 | + } |
|
| 1315 | 1814 | //@socket_close($r); |
| 1316 | 1815 | sleep(2); |
| 1317 | 1816 | $aprs_connect = 0; |
@@ -1328,11 +1827,17 @@ discard block |
||
| 1328 | 1827 | } else { |
| 1329 | 1828 | $error = socket_strerror(socket_last_error()); |
| 1330 | 1829 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
| 1331 | - if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
|
| 1332 | - if (isset($globalDebug)) echo "Restarting...\n"; |
|
| 1830 | + if ($globalDebug) { |
|
| 1831 | + echo "ERROR : socket_select give this error ".$error . "\n"; |
|
| 1832 | + } |
|
| 1833 | + if (isset($globalDebug)) { |
|
| 1834 | + echo "Restarting...\n"; |
|
| 1835 | + } |
|
| 1333 | 1836 | // Restart the script if possible |
| 1334 | 1837 | if (is_array($sockets)) { |
| 1335 | - if ($globalDebug) echo "Shutdown all sockets..."; |
|
| 1838 | + if ($globalDebug) { |
|
| 1839 | + echo "Shutdown all sockets..."; |
|
| 1840 | + } |
|
| 1336 | 1841 | |
| 1337 | 1842 | foreach ($sockets as $sock) { |
| 1338 | 1843 | @socket_shutdown($sock,2); |
@@ -1340,18 +1845,24 @@ discard block |
||
| 1340 | 1845 | } |
| 1341 | 1846 | |
| 1342 | 1847 | } |
| 1343 | - if ($globalDebug) echo "Restart all connections..."; |
|
| 1848 | + if ($globalDebug) { |
|
| 1849 | + echo "Restart all connections..."; |
|
| 1850 | + } |
|
| 1344 | 1851 | sleep(2); |
| 1345 | 1852 | $time = time(); |
| 1346 | 1853 | //connect_all($hosts); |
| 1347 | 1854 | $aprs_connect = 0; |
| 1348 | - if ($reset > 40) exit('Too many attempts...'); |
|
| 1855 | + if ($reset > 40) { |
|
| 1856 | + exit('Too many attempts...'); |
|
| 1857 | + } |
|
| 1349 | 1858 | connect_all($globalSources); |
| 1350 | 1859 | } |
| 1351 | 1860 | } |
| 1352 | 1861 | } |
| 1353 | 1862 | if ($globalDaemon === false) { |
| 1354 | - if ($globalDebug) echo 'Check all...'."\n"; |
|
| 1863 | + if ($globalDebug) { |
|
| 1864 | + echo 'Check all...'."\n"; |
|
| 1865 | + } |
|
| 1355 | 1866 | $SI->checkAll(); |
| 1356 | 1867 | } |
| 1357 | 1868 | } |