@@ -45,20 +45,20 @@ 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::','aprsserverhost::','aprsserverport::','format::','noaprsserver')); |
|
| 52 | +$options = getopt('s::', array('source::', 'server', 'nodaemon', 'idsource::', 'aprsserverssid::', 'aprsserverpass::', 'aprsserverhost::', 'aprsserverport::', 'format::', 'noaprsserver')); |
|
| 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 | 56 | $globalSources = array(); |
| 57 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
| 57 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['s'], 'format' => $options['format']); |
|
| 58 | 58 | else $globalSources[] = array('host' => $options['s']); |
| 59 | 59 | } elseif (isset($options['source'])) { |
| 60 | 60 | $globalSources = array(); |
| 61 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
| 61 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['source'], 'format' => $options['format']); |
|
| 62 | 62 | else $globalSources[] = array('host' => $options['source']); |
| 63 | 63 | } |
| 64 | 64 | if (isset($options['aprsserverhost'])) { |
@@ -75,27 +75,27 @@ discard block |
||
| 75 | 75 | else $id_source = 1; |
| 76 | 76 | if (isset($globalServer) && $globalServer) { |
| 77 | 77 | if ($globalDebug) echo "Using Server Mode\n"; |
| 78 | - $SI=new SpotterServer(); |
|
| 78 | + $SI = new SpotterServer(); |
|
| 79 | 79 | /* |
| 80 | 80 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
| 81 | 81 | $SI = new adsb2aprs(); |
| 82 | 82 | $SI->connect(); |
| 83 | 83 | */ |
| 84 | -} else $SI=new SpotterImport($Connection->db); |
|
| 84 | +} else $SI = new SpotterImport($Connection->db); |
|
| 85 | 85 | if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db); |
| 86 | 86 | if (isset($globalMarine) && $globalMarine) { |
| 87 | 87 | $AIS = new AIS(); |
| 88 | 88 | $MI = new MarineImport($Connection->db); |
| 89 | 89 | } |
| 90 | 90 | //$APRS=new APRS($Connection->db); |
| 91 | -$SBS=new SBS(); |
|
| 92 | -$ACARS=new ACARS($Connection->db); |
|
| 93 | -$Common=new Common(); |
|
| 91 | +$SBS = new SBS(); |
|
| 92 | +$ACARS = new ACARS($Connection->db); |
|
| 93 | +$Common = new Common(); |
|
| 94 | 94 | date_default_timezone_set('UTC'); |
| 95 | 95 | //$servertz = system('date +%Z'); |
| 96 | 96 | // signal handler - playing nice with sockets and dump1090 |
| 97 | 97 | if (function_exists('pcntl_fork')) { |
| 98 | - pcntl_signal(SIGINT, function() { |
|
| 98 | + pcntl_signal(SIGINT, function() { |
|
| 99 | 99 | global $sockets; |
| 100 | 100 | echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
| 101 | 101 | die("Bye!\n"); |
@@ -111,35 +111,35 @@ discard block |
||
| 111 | 111 | |
| 112 | 112 | function connect_all($hosts) { |
| 113 | 113 | //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
| 114 | - global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
| 114 | + global $sockets, $httpfeeds, $globalSources, $globalDebug, $aprs_connect, $last_exec, $globalSourcesRights, $use_aprs, $reset, $context; |
|
| 115 | 115 | $reset++; |
| 116 | 116 | if ($globalDebug) echo 'Connect to all...'."\n"; |
| 117 | 117 | foreach ($hosts as $id => $value) { |
| 118 | 118 | $host = $value['host']; |
| 119 | 119 | $globalSources[$id]['last_exec'] = 0; |
| 120 | 120 | // Here we check type of source(s) |
| 121 | - if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
|
| 122 | - if (preg_match('/deltadb.txt$/i',$host)) { |
|
| 121 | + if (filter_var($host, FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
|
| 122 | + if (preg_match('/deltadb.txt$/i', $host)) { |
|
| 123 | 123 | //$formats[$id] = 'deltadbtxt'; |
| 124 | 124 | $globalSources[$id]['format'] = 'deltadbtxt'; |
| 125 | 125 | //$last_exec['deltadbtxt'] = 0; |
| 126 | 126 | if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
| 127 | - } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
| 127 | + } else if (preg_match('/vatsim-data.txt$/i', $host)) { |
|
| 128 | 128 | //$formats[$id] = 'vatsimtxt'; |
| 129 | 129 | $globalSources[$id]['format'] = 'vatsimtxt'; |
| 130 | 130 | //$last_exec['vatsimtxt'] = 0; |
| 131 | 131 | if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
| 132 | - } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
| 132 | + } else if (preg_match('/aircraftlist.json$/i', $host)) { |
|
| 133 | 133 | //$formats[$id] = 'aircraftlistjson'; |
| 134 | 134 | $globalSources[$id]['format'] = 'aircraftlistjson'; |
| 135 | 135 | //$last_exec['aircraftlistjson'] = 0; |
| 136 | 136 | if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
| 137 | - } else if (preg_match('/opensky/i',$host)) { |
|
| 137 | + } else if (preg_match('/opensky/i', $host)) { |
|
| 138 | 138 | //$formats[$id] = 'aircraftlistjson'; |
| 139 | 139 | $globalSources[$id]['format'] = 'opensky'; |
| 140 | 140 | //$last_exec['aircraftlistjson'] = 0; |
| 141 | 141 | if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
| 142 | - } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) { |
|
| 142 | + } else if (preg_match('/radarvirtuel.com\/file.json$/i', $host)) { |
|
| 143 | 143 | //$formats[$id] = 'radarvirtueljson'; |
| 144 | 144 | $globalSources[$id]['format'] = 'radarvirtueljson'; |
| 145 | 145 | //$last_exec['radarvirtueljson'] = 0; |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
| 149 | 149 | exit(0); |
| 150 | 150 | } |
| 151 | - } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
| 151 | + } else if (preg_match('/planeUpdateFAA.php$/i', $host)) { |
|
| 152 | 152 | //$formats[$id] = 'planeupdatefaa'; |
| 153 | 153 | $globalSources[$id]['format'] = 'planeupdatefaa'; |
| 154 | 154 | //$last_exec['planeupdatefaa'] = 0; |
@@ -157,26 +157,26 @@ discard block |
||
| 157 | 157 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
| 158 | 158 | exit(0); |
| 159 | 159 | } |
| 160 | - } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
| 160 | + } else if (preg_match('/\/action.php\/acars\/data$/i', $host)) { |
|
| 161 | 161 | //$formats[$id] = 'phpvmacars'; |
| 162 | 162 | $globalSources[$id]['format'] = 'phpvmacars'; |
| 163 | 163 | //$last_exec['phpvmacars'] = 0; |
| 164 | 164 | if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
| 165 | - } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
| 165 | + } else if (preg_match('/VAM-json.php$/i', $host)) { |
|
| 166 | 166 | //$formats[$id] = 'phpvmacars'; |
| 167 | 167 | $globalSources[$id]['format'] = 'vam'; |
| 168 | 168 | if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
| 169 | - } else if (preg_match('/whazzup/i',$host)) { |
|
| 169 | + } else if (preg_match('/whazzup/i', $host)) { |
|
| 170 | 170 | //$formats[$id] = 'whazzup'; |
| 171 | 171 | $globalSources[$id]['format'] = 'whazzup'; |
| 172 | 172 | //$last_exec['whazzup'] = 0; |
| 173 | 173 | if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
| 174 | - } else if (preg_match('/recentpireps/i',$host)) { |
|
| 174 | + } else if (preg_match('/recentpireps/i', $host)) { |
|
| 175 | 175 | //$formats[$id] = 'pirepsjson'; |
| 176 | 176 | $globalSources[$id]['format'] = 'pirepsjson'; |
| 177 | 177 | //$last_exec['pirepsjson'] = 0; |
| 178 | 178 | if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
| 179 | - } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
| 179 | + } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i', $host)) { |
|
| 180 | 180 | //$formats[$id] = 'fr24json'; |
| 181 | 181 | $globalSources[$id]['format'] = 'fr24json'; |
| 182 | 182 | //$last_exec['fr24json'] = 0; |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
| 186 | 186 | exit(0); |
| 187 | 187 | } |
| 188 | - } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
| 188 | + } else if (preg_match(':myshiptracking.com/:i', $host)) { |
|
| 189 | 189 | //$formats[$id] = 'fr24json'; |
| 190 | 190 | $globalSources[$id]['format'] = 'myshiptracking'; |
| 191 | 191 | //$last_exec['fr24json'] = 0; |
@@ -195,22 +195,22 @@ discard block |
||
| 195 | 195 | exit(0); |
| 196 | 196 | } |
| 197 | 197 | //} else if (preg_match('/10001/',$host)) { |
| 198 | - } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
| 198 | + } else if (preg_match('/10001/', $host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
| 199 | 199 | //$formats[$id] = 'tsv'; |
| 200 | 200 | $globalSources[$id]['format'] = 'tsv'; |
| 201 | 201 | if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
| 202 | 202 | } |
| 203 | - } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
| 203 | + } elseif (filter_var($host, FILTER_VALIDATE_URL)) { |
|
| 204 | 204 | if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
| 205 | - $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
| 205 | + $idf = fopen($globalSources[$id]['host'], 'r', false, $context); |
|
| 206 | 206 | if ($idf !== false) { |
| 207 | 207 | $httpfeeds[$id] = $idf; |
| 208 | 208 | if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
| 209 | 209 | } |
| 210 | 210 | elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
| 211 | 211 | } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
| 212 | - } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
| 213 | - $hostport = explode(':',$host); |
|
| 212 | + } elseif (!filter_var($host, FILTER_VALIDATE_URL)) { |
|
| 213 | + $hostport = explode(':', $host); |
|
| 214 | 214 | if (isset($hostport[1])) { |
| 215 | 215 | $port = $hostport[1]; |
| 216 | 216 | $hostn = $hostport[0]; |
@@ -220,19 +220,19 @@ discard block |
||
| 220 | 220 | } |
| 221 | 221 | $Common = new Common(); |
| 222 | 222 | if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
| 223 | - $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
| 223 | + $s = $Common->create_socket($hostn, $port, $errno, $errstr); |
|
| 224 | 224 | } else { |
| 225 | - $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
| 225 | + $s = $Common->create_socket_udp($hostn, $port, $errno, $errstr); |
|
| 226 | 226 | } |
| 227 | 227 | if ($s) { |
| 228 | 228 | $sockets[$id] = $s; |
| 229 | 229 | if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
| 230 | - if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
| 230 | + if (preg_match('/aprs/', $hostn) || $port == '10152' || $port == '14580') { |
|
| 231 | 231 | //$formats[$id] = 'aprs'; |
| 232 | 232 | $globalSources[$id]['format'] = 'aprs'; |
| 233 | 233 | //$aprs_connect = 0; |
| 234 | 234 | //$use_aprs = true; |
| 235 | - } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
| 235 | + } elseif (preg_match('/pub-vrs/', $hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
| 236 | 236 | $globalSources[$id]['format'] = 'vrstcp'; |
| 237 | 237 | } elseif ($port == '10001') { |
| 238 | 238 | //$formats[$id] = 'tsv'; |
@@ -271,7 +271,7 @@ discard block |
||
| 271 | 271 | else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut; |
| 272 | 272 | else $timeout = 20; |
| 273 | 273 | $errno = ''; |
| 274 | -$errstr=''; |
|
| 274 | +$errstr = ''; |
|
| 275 | 275 | |
| 276 | 276 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
| 277 | 277 | /* Initiate connections to all the hosts simultaneously */ |
@@ -279,7 +279,7 @@ discard block |
||
| 279 | 279 | //connect_all($globalSources); |
| 280 | 280 | |
| 281 | 281 | if (isset($globalProxy) && $globalProxy) { |
| 282 | - $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
| 282 | + $context = stream_context_create(array('http' => array('timeout' => $timeout, 'proxy' => $globalProxy, 'request_fulluri' => true))); |
|
| 283 | 283 | } else { |
| 284 | 284 | $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
| 285 | 285 | } |
@@ -306,16 +306,16 @@ discard block |
||
| 306 | 306 | |
| 307 | 307 | if ($use_aprs) { |
| 308 | 308 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
| 309 | - $APRS=new APRS(); |
|
| 309 | + $APRS = new APRS(); |
|
| 310 | 310 | $aprs_connect = 0; |
| 311 | 311 | $aprs_keep = 120; |
| 312 | 312 | $aprs_last_tx = time(); |
| 313 | 313 | if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; |
| 314 | - else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
| 314 | + else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName); |
|
| 315 | 315 | if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid; |
| 316 | - else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
| 316 | + else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8); |
|
| 317 | 317 | if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter; |
| 318 | - else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
| 318 | + else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
| 319 | 319 | if ($aprs_full) $aprs_filter = ''; |
| 320 | 320 | if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass; |
| 321 | 321 | else $aprs_pass = '-1'; |
@@ -329,12 +329,12 @@ discard block |
||
| 329 | 329 | sleep(1); |
| 330 | 330 | if ($globalDebug) echo "SCAN MODE \n\n"; |
| 331 | 331 | if (!isset($globalCronEnd)) $globalCronEnd = 60; |
| 332 | -$endtime = time()+$globalCronEnd; |
|
| 332 | +$endtime = time() + $globalCronEnd; |
|
| 333 | 333 | $i = 1; |
| 334 | 334 | $tt = array(); |
| 335 | 335 | // Delete all ATC |
| 336 | 336 | if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) { |
| 337 | - $ATC=new ATC($Connection->db); |
|
| 337 | + $ATC = new ATC($Connection->db); |
|
| 338 | 338 | } |
| 339 | 339 | if (!$globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
| 340 | 340 | $ATC->deleteAll(); |
@@ -342,7 +342,7 @@ discard block |
||
| 342 | 342 | |
| 343 | 343 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
| 344 | 344 | while ($i > 0) { |
| 345 | - if (!$globalDaemon) $i = $endtime-time(); |
|
| 345 | + if (!$globalDaemon) $i = $endtime - time(); |
|
| 346 | 346 | // Delete old ATC |
| 347 | 347 | if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
| 348 | 348 | if ($globalDebug) echo 'Delete old ATC...'."\n"; |
@@ -357,7 +357,7 @@ discard block |
||
| 357 | 357 | } |
| 358 | 358 | if ($max != $globalMinFetch) { |
| 359 | 359 | if ($globalDebug) echo 'Sleeping...'."\n"; |
| 360 | - sleep($globalMinFetch-$max+2); |
|
| 360 | + sleep($globalMinFetch - $max + 2); |
|
| 361 | 361 | } |
| 362 | 362 | } |
| 363 | 363 | |
@@ -370,8 +370,8 @@ discard block |
||
| 370 | 370 | //$buffer = $Common->getData($hosts[$id]); |
| 371 | 371 | $buffer = $Common->getData($value['host']); |
| 372 | 372 | if ($buffer != '') $reset = 0; |
| 373 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 374 | - $buffer = explode('\n',$buffer); |
|
| 373 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
| 374 | + $buffer = explode('\n', $buffer); |
|
| 375 | 375 | foreach ($buffer as $line) { |
| 376 | 376 | if ($line != '' && count($line) > 7) { |
| 377 | 377 | $line = explode(',', $line); |
@@ -399,11 +399,11 @@ discard block |
||
| 399 | 399 | $last_exec[$id]['last'] = time(); |
| 400 | 400 | } elseif ($value['format'] == 'aisnmeatxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
| 401 | 401 | date_default_timezone_set('CET'); |
| 402 | - $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
| 402 | + $buffer = $Common->getData(str_replace('{date}', date('Ymd'), $value['host'])); |
|
| 403 | 403 | date_default_timezone_set('UTC'); |
| 404 | 404 | if ($buffer != '') $reset = 0; |
| 405 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 406 | - $buffer = explode('\n',$buffer); |
|
| 405 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
| 406 | + $buffer = explode('\n', $buffer); |
|
| 407 | 407 | foreach ($buffer as $line) { |
| 408 | 408 | if ($line != '') { |
| 409 | 409 | echo "'".$line."'\n"; |
@@ -421,7 +421,7 @@ discard block |
||
| 421 | 421 | if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
| 422 | 422 | if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
| 423 | 423 | if (isset($ais_data['timestamp'])) { |
| 424 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
| 424 | + $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); |
|
| 425 | 425 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
| 426 | 426 | $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
| 427 | 427 | $add = true; |
@@ -445,12 +445,12 @@ discard block |
||
| 445 | 445 | $w = $e = null; |
| 446 | 446 | |
| 447 | 447 | if (isset($arr[$id])) { |
| 448 | - $nn = stream_select($arr,$w,$e,$timeout); |
|
| 448 | + $nn = stream_select($arr, $w, $e, $timeout); |
|
| 449 | 449 | if ($nn > 0) { |
| 450 | 450 | foreach ($httpfeeds as $feed) { |
| 451 | - $buffer = stream_get_line($feed,2000,"\n"); |
|
| 452 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 453 | - $buffer = explode('\n',$buffer); |
|
| 451 | + $buffer = stream_get_line($feed, 2000, "\n"); |
|
| 452 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
| 453 | + $buffer = explode('\n', $buffer); |
|
| 454 | 454 | foreach ($buffer as $line) { |
| 455 | 455 | if ($line != '') { |
| 456 | 456 | $ais_data = $AIS->parse_line(trim($line)); |
@@ -467,9 +467,9 @@ discard block |
||
| 467 | 467 | if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
| 468 | 468 | if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
| 469 | 469 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
| 470 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 470 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']); |
|
| 471 | 471 | if (isset($ais_data['timestamp'])) { |
| 472 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
| 472 | + $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); |
|
| 473 | 473 | } else { |
| 474 | 474 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 475 | 475 | } |
@@ -494,10 +494,10 @@ discard block |
||
| 494 | 494 | } |
| 495 | 495 | } |
| 496 | 496 | } elseif ($value['format'] == 'myshiptracking' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
| 497 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
| 497 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20'); |
|
| 498 | 498 | if ($buffer != '') { |
| 499 | 499 | //echo $buffer; |
| 500 | - $all_data = json_decode($buffer,true); |
|
| 500 | + $all_data = json_decode($buffer, true); |
|
| 501 | 501 | //print_r($all_data); |
| 502 | 502 | if (isset($all_data[0]['DATA'])) { |
| 503 | 503 | foreach ($all_data[0]['DATA'] as $line) { |
@@ -512,7 +512,7 @@ discard block |
||
| 512 | 512 | // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
| 513 | 513 | $data['imo'] = $line['IMO']; |
| 514 | 514 | //$data['arrival_code'] = $ais_data['destination']; |
| 515 | - $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
|
| 515 | + $data['datetime'] = date('Y-m-d H:i:s', $line['T']); |
|
| 516 | 516 | $data['format_source'] = 'myshiptracking'; |
| 517 | 517 | $data['id_source'] = $id_source; |
| 518 | 518 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
@@ -525,9 +525,9 @@ discard block |
||
| 525 | 525 | } |
| 526 | 526 | $last_exec[$id]['last'] = time(); |
| 527 | 527 | } elseif ($value['format'] == 'boatbeaconapp' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
| 528 | - $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
| 528 | + $buffer = $Common->getData(str_replace('{timestamp}', time(), $value['host'])); |
|
| 529 | 529 | if ($buffer != '') { |
| 530 | - $all_data = json_decode($buffer,true); |
|
| 530 | + $all_data = json_decode($buffer, true); |
|
| 531 | 531 | if (isset($all_data[0]['mmsi'])) { |
| 532 | 532 | foreach ($all_data as $line) { |
| 533 | 533 | if ($line != '') { |
@@ -555,27 +555,27 @@ discard block |
||
| 555 | 555 | $last_exec[$id]['last'] = time(); |
| 556 | 556 | } elseif ($value['format'] == 'shipplotter' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
| 557 | 557 | echo 'download...'; |
| 558 | - $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
| 558 | + $buffer = $Common->getData($value['host'], 'post', $value['post'], '', '', '', '', 'ShipPlotter'); |
|
| 559 | 559 | echo 'done !'."\n"; |
| 560 | 560 | if ($buffer != '') $reset = 0; |
| 561 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 562 | - $buffer = explode('\n',$buffer); |
|
| 561 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
| 562 | + $buffer = explode('\n', $buffer); |
|
| 563 | 563 | foreach ($buffer as $line) { |
| 564 | 564 | if ($line != '') { |
| 565 | 565 | $data = array(); |
| 566 | - $data['mmsi'] = (int)substr($line,0,9); |
|
| 567 | - $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
| 566 | + $data['mmsi'] = (int) substr($line, 0, 9); |
|
| 567 | + $data['datetime'] = date('Y-m-d H:i:s', substr($line, 10, 10)); |
|
| 568 | 568 | //$data['status'] = substr($line,21,2); |
| 569 | 569 | //$data['type'] = substr($line,24,3); |
| 570 | - $data['latitude'] = substr($line,29,9); |
|
| 571 | - $data['longitude'] = substr($line,41,9); |
|
| 572 | - $data['speed'] = round(substr($line,51,5)); |
|
| 570 | + $data['latitude'] = substr($line, 29, 9); |
|
| 571 | + $data['longitude'] = substr($line, 41, 9); |
|
| 572 | + $data['speed'] = round(substr($line, 51, 5)); |
|
| 573 | 573 | //$data['course'] = substr($line,57,5); |
| 574 | - $data['heading'] = round(substr($line,63,3)); |
|
| 574 | + $data['heading'] = round(substr($line, 63, 3)); |
|
| 575 | 575 | //$data['draft'] = substr($line,67,4); |
| 576 | 576 | //$data['length'] = substr($line,72,3); |
| 577 | 577 | //$data['beam'] = substr($line,76,2); |
| 578 | - $data['ident'] = trim(utf8_encode(substr($line,79,20))); |
|
| 578 | + $data['ident'] = trim(utf8_encode(substr($line, 79, 20))); |
|
| 579 | 579 | //$data['callsign'] = trim(substr($line,100,7); |
| 580 | 580 | //$data['dest'] = substr($line,108,20); |
| 581 | 581 | //$data['etaDate'] = substr($line,129,5); |
@@ -594,8 +594,8 @@ discard block |
||
| 594 | 594 | } elseif (($value['format'] == 'whazzup' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch))) { |
| 595 | 595 | //$buffer = $Common->getData($hosts[$id]); |
| 596 | 596 | $buffer = $Common->getData($value['host']); |
| 597 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 598 | - $buffer = explode('\n',$buffer); |
|
| 597 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
| 598 | + $buffer = explode('\n', $buffer); |
|
| 599 | 599 | $reset = 0; |
| 600 | 600 | foreach ($buffer as $line) { |
| 601 | 601 | if ($line != '') { |
@@ -606,7 +606,7 @@ discard block |
||
| 606 | 606 | else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
| 607 | 607 | $data['pilot_id'] = $line[1]; |
| 608 | 608 | $data['pilot_name'] = $line[2]; |
| 609 | - $data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT); |
|
| 609 | + $data['hex'] = str_pad(dechex($Common->str2int($line[1])), 6, '000000', STR_PAD_LEFT); |
|
| 610 | 610 | $data['ident'] = $line[0]; // ident |
| 611 | 611 | if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude |
| 612 | 612 | $data['speed'] = $line[8]; // speed |
@@ -622,7 +622,7 @@ discard block |
||
| 622 | 622 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); |
| 623 | 623 | //if (isset($line[37])) $data['last_update'] = $line[37]; |
| 624 | 624 | $data['departure_airport_icao'] = $line[11]; |
| 625 | - $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
| 625 | + $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':'); |
|
| 626 | 626 | $data['arrival_airport_icao'] = $line[13]; |
| 627 | 627 | $data['frequency'] = $line[4]; |
| 628 | 628 | $data['type'] = $line[18]; |
@@ -631,7 +631,7 @@ discard block |
||
| 631 | 631 | $data['id_source'] = $id_source; |
| 632 | 632 | //$data['arrival_airport_time'] = ; |
| 633 | 633 | if ($line[9] != '') { |
| 634 | - $aircraft_data = explode('/',$line[9]); |
|
| 634 | + $aircraft_data = explode('/', $line[9]); |
|
| 635 | 635 | if (isset($aircraft_data[1])) { |
| 636 | 636 | $data['aircraft_icao'] = $aircraft_data[1]; |
| 637 | 637 | } |
@@ -646,9 +646,9 @@ discard block |
||
| 646 | 646 | if ($line[3] == 'PILOT') $SI->add($data); |
| 647 | 647 | elseif ($line[3] == 'ATC') { |
| 648 | 648 | //print_r($data); |
| 649 | - $data['info'] = str_replace('^§','<br />',$data['info']); |
|
| 650 | - $data['info'] = str_replace('&sect;','',$data['info']); |
|
| 651 | - $typec = substr($data['ident'],-3); |
|
| 649 | + $data['info'] = str_replace('^§', '<br />', $data['info']); |
|
| 650 | + $data['info'] = str_replace('&sect;', '', $data['info']); |
|
| 651 | + $typec = substr($data['ident'], -3); |
|
| 652 | 652 | if ($typec == 'APP') $data['type'] = 'Approach'; |
| 653 | 653 | elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
| 654 | 654 | elseif ($typec == 'OBS') $data['type'] = 'Observer'; |
@@ -659,7 +659,7 @@ discard block |
||
| 659 | 659 | elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
| 660 | 660 | elseif ($data['type'] == '') $data['type'] = 'Observer'; |
| 661 | 661 | if (!isset($data['source_name'])) $data['source_name'] = ''; |
| 662 | - 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']); |
|
| 662 | + 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']); |
|
| 663 | 663 | } |
| 664 | 664 | unset($data); |
| 665 | 665 | } |
@@ -670,9 +670,9 @@ discard block |
||
| 670 | 670 | $last_exec[$id]['last'] = time(); |
| 671 | 671 | //} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) { |
| 672 | 672 | } elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
| 673 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
| 673 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20'); |
|
| 674 | 674 | if ($buffer != '') { |
| 675 | - $all_data = json_decode($buffer,true); |
|
| 675 | + $all_data = json_decode($buffer, true); |
|
| 676 | 676 | if (isset($all_data['acList'])) { |
| 677 | 677 | $reset = 0; |
| 678 | 678 | foreach ($all_data['acList'] as $line) { |
@@ -689,7 +689,7 @@ discard block |
||
| 689 | 689 | $data['emergency'] = ''; // emergency |
| 690 | 690 | if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
| 691 | 691 | |
| 692 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
| 692 | + if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000)); |
|
| 693 | 693 | else $data['datetime'] = date('Y-m-d H:i:s'); |
| 694 | 694 | |
| 695 | 695 | //$data['datetime'] = date('Y-m-d H:i:s'); |
@@ -715,7 +715,7 @@ discard block |
||
| 715 | 715 | $data['verticalrate'] = $line['vrt']; // verticale rate |
| 716 | 716 | $data['squawk'] = $line['squawk']; // squawk |
| 717 | 717 | $data['emergency'] = ''; // emergency |
| 718 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
| 718 | + if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000)); |
|
| 719 | 719 | else $data['datetime'] = date('Y-m-d H:i:s'); |
| 720 | 720 | $data['format_source'] = 'aircraftlistjson'; |
| 721 | 721 | $data['id_source'] = $id_source; |
@@ -731,7 +731,7 @@ discard block |
||
| 731 | 731 | //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
| 732 | 732 | } elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
| 733 | 733 | $buffer = $Common->getData($value['host']); |
| 734 | - $all_data = json_decode($buffer,true); |
|
| 734 | + $all_data = json_decode($buffer, true); |
|
| 735 | 735 | if (isset($all_data['planes'])) { |
| 736 | 736 | $reset = 0; |
| 737 | 737 | foreach ($all_data['planes'] as $key => $line) { |
@@ -748,12 +748,12 @@ discard block |
||
| 748 | 748 | $data['emergency'] = ''; // emergency |
| 749 | 749 | $data['registration'] = $line[2]; |
| 750 | 750 | $data['aircraft_icao'] = $line[0]; |
| 751 | - $deparr = explode('-',$line[1]); |
|
| 751 | + $deparr = explode('-', $line[1]); |
|
| 752 | 752 | if (count($deparr) == 2) { |
| 753 | 753 | $data['departure_airport_icao'] = $deparr[0]; |
| 754 | 754 | $data['arrival_airport_icao'] = $deparr[1]; |
| 755 | 755 | } |
| 756 | - $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
| 756 | + $data['datetime'] = date('Y-m-d H:i:s', $line[9]); |
|
| 757 | 757 | $data['format_source'] = 'planeupdatefaa'; |
| 758 | 758 | $data['id_source'] = $id_source; |
| 759 | 759 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
@@ -766,7 +766,7 @@ discard block |
||
| 766 | 766 | $last_exec[$id]['last'] = time(); |
| 767 | 767 | } elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
| 768 | 768 | $buffer = $Common->getData($value['host']); |
| 769 | - $all_data = json_decode($buffer,true); |
|
| 769 | + $all_data = json_decode($buffer, true); |
|
| 770 | 770 | if (isset($all_data['states'])) { |
| 771 | 771 | $reset = 0; |
| 772 | 772 | foreach ($all_data['states'] as $key => $line) { |
@@ -783,7 +783,7 @@ discard block |
||
| 783 | 783 | //$data['emergency'] = ''; // emergency |
| 784 | 784 | //$data['registration'] = $line[2]; |
| 785 | 785 | //$data['aircraft_icao'] = $line[0]; |
| 786 | - $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
| 786 | + $data['datetime'] = date('Y-m-d H:i:s', $line[3]); |
|
| 787 | 787 | $data['format_source'] = 'opensky'; |
| 788 | 788 | $data['id_source'] = $id_source; |
| 789 | 789 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
@@ -797,7 +797,7 @@ discard block |
||
| 797 | 797 | } elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
| 798 | 798 | //$buffer = $Common->getData($hosts[$id]); |
| 799 | 799 | $buffer = $Common->getData($value['host']); |
| 800 | - $all_data = json_decode($buffer,true); |
|
| 800 | + $all_data = json_decode($buffer, true); |
|
| 801 | 801 | if (!empty($all_data)) $reset = 0; |
| 802 | 802 | foreach ($all_data as $key => $line) { |
| 803 | 803 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
@@ -830,11 +830,11 @@ discard block |
||
| 830 | 830 | //} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
| 831 | 831 | } elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
| 832 | 832 | //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
| 833 | - $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
| 833 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150'); |
|
| 834 | 834 | //echo $buffer; |
| 835 | - $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
| 836 | - $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
| 837 | - $all_data = json_decode($buffer,true); |
|
| 835 | + $buffer = str_replace(array("\n", "\r"), "", $buffer); |
|
| 836 | + $buffer = preg_replace('/,"num":(.+)/', '}', $buffer); |
|
| 837 | + $all_data = json_decode($buffer, true); |
|
| 838 | 838 | if (json_last_error() != JSON_ERROR_NONE) { |
| 839 | 839 | die(json_last_error_msg()); |
| 840 | 840 | } |
@@ -857,7 +857,7 @@ discard block |
||
| 857 | 857 | //$data['departure_airport_iata'] = $line[11]; |
| 858 | 858 | //$data['arrival_airport_iata'] = $line[12]; |
| 859 | 859 | //$data['emergency'] = ''; // emergency |
| 860 | - $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
|
| 860 | + $data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10] |
|
| 861 | 861 | $data['format_source'] = 'radarvirtueljson'; |
| 862 | 862 | $data['id_source'] = $id_source; |
| 863 | 863 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
@@ -873,14 +873,14 @@ discard block |
||
| 873 | 873 | } elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
| 874 | 874 | //$buffer = $Common->getData($hosts[$id]); |
| 875 | 875 | $buffer = $Common->getData($value['host'].'?'.time()); |
| 876 | - $all_data = json_decode(utf8_encode($buffer),true); |
|
| 876 | + $all_data = json_decode(utf8_encode($buffer), true); |
|
| 877 | 877 | |
| 878 | 878 | if (isset($all_data['pireps'])) { |
| 879 | 879 | $reset = 0; |
| 880 | 880 | foreach ($all_data['pireps'] as $line) { |
| 881 | 881 | $data = array(); |
| 882 | 882 | $data['id'] = $line['id']; |
| 883 | - $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
| 883 | + $data['hex'] = substr(str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT), 0, 6); |
|
| 884 | 884 | $data['ident'] = $line['callsign']; // ident |
| 885 | 885 | if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
| 886 | 886 | if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
@@ -910,9 +910,9 @@ discard block |
||
| 910 | 910 | $SI->add($data); |
| 911 | 911 | // print_r($data); |
| 912 | 912 | } elseif ($line['icon'] == 'ct') { |
| 913 | - $data['info'] = str_replace('^§','<br />',$data['info']); |
|
| 914 | - $data['info'] = str_replace('&sect;','',$data['info']); |
|
| 915 | - $typec = substr($data['ident'],-3); |
|
| 913 | + $data['info'] = str_replace('^§', '<br />', $data['info']); |
|
| 914 | + $data['info'] = str_replace('&sect;', '', $data['info']); |
|
| 915 | + $typec = substr($data['ident'], -3); |
|
| 916 | 916 | $data['type'] = ''; |
| 917 | 917 | if ($typec == 'APP') $data['type'] = 'Approach'; |
| 918 | 918 | elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
@@ -923,7 +923,7 @@ discard block |
||
| 923 | 923 | elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station'; |
| 924 | 924 | elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
| 925 | 925 | else $data['type'] = 'Observer'; |
| 926 | - 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']); |
|
| 926 | + 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']); |
|
| 927 | 927 | } |
| 928 | 928 | unset($data); |
| 929 | 929 | } |
@@ -935,14 +935,14 @@ discard block |
||
| 935 | 935 | //$buffer = $Common->getData($hosts[$id]); |
| 936 | 936 | if ($globalDebug) echo 'Get Data...'."\n"; |
| 937 | 937 | $buffer = $Common->getData($value['host']); |
| 938 | - $all_data = json_decode($buffer,true); |
|
| 938 | + $all_data = json_decode($buffer, true); |
|
| 939 | 939 | if ($buffer != '' && is_array($all_data)) { |
| 940 | 940 | $reset = 0; |
| 941 | 941 | foreach ($all_data as $line) { |
| 942 | 942 | $data = array(); |
| 943 | 943 | //$data['id'] = $line['id']; // id not usable |
| 944 | 944 | if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
| 945 | - $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 945 | + $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex |
|
| 946 | 946 | if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
| 947 | 947 | if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
| 948 | 948 | $data['ident'] = $line['flightnum']; // ident |
@@ -966,14 +966,14 @@ discard block |
||
| 966 | 966 | if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
| 967 | 967 | if (isset($line['aircraftname'])) { |
| 968 | 968 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
| 969 | - $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
|
| 970 | - $aircraft_data = explode('-',$line['aircraftname']); |
|
| 969 | + $line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']); |
|
| 970 | + $aircraft_data = explode('-', $line['aircraftname']); |
|
| 971 | 971 | if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
| 972 | 972 | elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
| 973 | 973 | else { |
| 974 | - $aircraft_data = explode(' ',$line['aircraftname']); |
|
| 975 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
| 976 | - else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
| 974 | + $aircraft_data = explode(' ', $line['aircraftname']); |
|
| 975 | + if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-', '', $aircraft_data[1]); |
|
| 976 | + else $data['aircraft_icao'] = str_replace('-', '', $line['aircraftname']); |
|
| 977 | 977 | } |
| 978 | 978 | } |
| 979 | 979 | if (isset($line['route'])) $data['waypoints'] = $line['route']; |
@@ -993,14 +993,14 @@ discard block |
||
| 993 | 993 | //$buffer = $Common->getData($hosts[$id]); |
| 994 | 994 | if ($globalDebug) echo 'Get Data...'."\n"; |
| 995 | 995 | $buffer = $Common->getData($value['host']); |
| 996 | - $all_data = json_decode($buffer,true); |
|
| 996 | + $all_data = json_decode($buffer, true); |
|
| 997 | 997 | if ($buffer != '' && is_array($all_data)) { |
| 998 | 998 | $reset = 0; |
| 999 | 999 | foreach ($all_data as $line) { |
| 1000 | 1000 | $data = array(); |
| 1001 | 1001 | //$data['id'] = $line['id']; // id not usable |
| 1002 | 1002 | $data['id'] = trim($line['flight_id']); |
| 1003 | - $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 1003 | + $data['hex'] = substr(str_pad(bin2hex($line['callsign']), 6, '000000', STR_PAD_LEFT), -6); // hex |
|
| 1004 | 1004 | $data['pilot_name'] = $line['pilot_name']; |
| 1005 | 1005 | $data['pilot_id'] = $line['pilot_id']; |
| 1006 | 1006 | $data['ident'] = trim($line['callsign']); // ident |
@@ -1052,11 +1052,11 @@ discard block |
||
| 1052 | 1052 | //$value = $formats[$nb]; |
| 1053 | 1053 | $format = $globalSources[$nb]['format']; |
| 1054 | 1054 | if ($format == 'sbs' || $format == 'aprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') { |
| 1055 | - $buffer = @socket_read($r, 6000,PHP_NORMAL_READ); |
|
| 1055 | + $buffer = @socket_read($r, 6000, PHP_NORMAL_READ); |
|
| 1056 | 1056 | } elseif ($format == 'vrstcp') { |
| 1057 | 1057 | $buffer = @socket_read($r, 6000); |
| 1058 | 1058 | } else { |
| 1059 | - $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); |
|
| 1059 | + $az = socket_recvfrom($r, $buffer, 6000, 0, $remote_ip, $remote_port); |
|
| 1060 | 1060 | } |
| 1061 | 1061 | //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
| 1062 | 1062 | //echo $buffer."\n"; |
@@ -1065,8 +1065,8 @@ discard block |
||
| 1065 | 1065 | $error = false; |
| 1066 | 1066 | //$SI::del(); |
| 1067 | 1067 | if ($format == 'vrstcp') { |
| 1068 | - $buffer = explode('},{',$buffer); |
|
| 1069 | - } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
| 1068 | + $buffer = explode('},{', $buffer); |
|
| 1069 | + } else $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer)); |
|
| 1070 | 1070 | // SBS format is CSV format |
| 1071 | 1071 | if ($buffer !== FALSE && $buffer != '') { |
| 1072 | 1072 | $tt[$format] = 0; |
@@ -1100,11 +1100,11 @@ discard block |
||
| 1100 | 1100 | if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
| 1101 | 1101 | if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
| 1102 | 1102 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
| 1103 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 1103 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']); |
|
| 1104 | 1104 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
| 1105 | 1105 | |
| 1106 | 1106 | if (isset($ais_data['timestamp'])) { |
| 1107 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
| 1107 | + $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); |
|
| 1108 | 1108 | } else { |
| 1109 | 1109 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1110 | 1110 | } |
@@ -1115,10 +1115,10 @@ discard block |
||
| 1115 | 1115 | } elseif ($format == 'flightgearsp') { |
| 1116 | 1116 | //echo $buffer."\n"; |
| 1117 | 1117 | if (strlen($buffer) > 5) { |
| 1118 | - $line = explode(',',$buffer); |
|
| 1118 | + $line = explode(',', $buffer); |
|
| 1119 | 1119 | $data = array(); |
| 1120 | 1120 | //XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p |
| 1121 | - $data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]),6,'000000',STR_PAD_LEFT),0,6); |
|
| 1121 | + $data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]), 6, '000000', STR_PAD_LEFT), 0, 6); |
|
| 1122 | 1122 | $data['ident'] = $line[6]; |
| 1123 | 1123 | $data['aircraft_name'] = $line[7]; |
| 1124 | 1124 | $data['longitude'] = $line[1]; |
@@ -1130,21 +1130,21 @@ discard block |
||
| 1130 | 1130 | $data['format_source'] = 'flightgearsp'; |
| 1131 | 1131 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
| 1132 | 1132 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
| 1133 | - $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
|
| 1133 | + $send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0); |
|
| 1134 | 1134 | } |
| 1135 | 1135 | } elseif ($format == 'acars') { |
| 1136 | 1136 | if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
| 1137 | 1137 | $ACARS->add(trim($buffer)); |
| 1138 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
| 1138 | + socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port); |
|
| 1139 | 1139 | $ACARS->deleteLiveAcarsData(); |
| 1140 | 1140 | } elseif ($format == 'flightgearmp') { |
| 1141 | - if (substr($buffer,0,1) != '#') { |
|
| 1141 | + if (substr($buffer, 0, 1) != '#') { |
|
| 1142 | 1142 | $data = array(); |
| 1143 | 1143 | //echo $buffer."\n"; |
| 1144 | - $line = explode(' ',$buffer); |
|
| 1144 | + $line = explode(' ', $buffer); |
|
| 1145 | 1145 | if (count($line) == 11) { |
| 1146 | - $userserver = explode('@',$line[0]); |
|
| 1147 | - $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
| 1146 | + $userserver = explode('@', $line[0]); |
|
| 1147 | + $data['hex'] = substr(str_pad(bin2hex($line[0]), 6, '000000', STR_PAD_LEFT), 0, 6); // hex |
|
| 1148 | 1148 | $data['ident'] = $userserver[0]; |
| 1149 | 1149 | $data['registration'] = $userserver[0]; |
| 1150 | 1150 | $data['latitude'] = $line[4]; |
@@ -1152,8 +1152,8 @@ discard block |
||
| 1152 | 1152 | $data['altitude'] = $line[6]; |
| 1153 | 1153 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1154 | 1154 | $aircraft_type = $line[10]; |
| 1155 | - $aircraft_type = preg_split(':/:',$aircraft_type); |
|
| 1156 | - $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
| 1155 | + $aircraft_type = preg_split(':/:', $aircraft_type); |
|
| 1156 | + $data['aircraft_name'] = substr(end($aircraft_type), 0, -4); |
|
| 1157 | 1157 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
| 1158 | 1158 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
| 1159 | 1159 | } |
@@ -1162,8 +1162,8 @@ discard block |
||
| 1162 | 1162 | echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
| 1163 | 1163 | die; |
| 1164 | 1164 | } elseif ($format == 'vrstcp') { |
| 1165 | - foreach($buffer as $all_data) { |
|
| 1166 | - $line = json_decode('{'.$all_data.'}',true); |
|
| 1165 | + foreach ($buffer as $all_data) { |
|
| 1166 | + $line = json_decode('{'.$all_data.'}', true); |
|
| 1167 | 1167 | $data = array(); |
| 1168 | 1168 | if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
| 1169 | 1169 | if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
@@ -1189,16 +1189,16 @@ discard block |
||
| 1189 | 1189 | if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
| 1190 | 1190 | unset($data); |
| 1191 | 1191 | } |
| 1192 | - } elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') { |
|
| 1192 | + } elseif ($format == 'tsv' || substr($buffer, 0, 4) == 'clock') { |
|
| 1193 | 1193 | $line = explode("\t", $buffer); |
| 1194 | - for($k = 0; $k < count($line); $k=$k+2) { |
|
| 1194 | + for ($k = 0; $k < count($line); $k = $k + 2) { |
|
| 1195 | 1195 | $key = $line[$k]; |
| 1196 | - $lined[$key] = $line[$k+1]; |
|
| 1196 | + $lined[$key] = $line[$k + 1]; |
|
| 1197 | 1197 | } |
| 1198 | 1198 | if (count($lined) > 3) { |
| 1199 | 1199 | $data['hex'] = $lined['hexid']; |
| 1200 | 1200 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
| 1201 | - $data['datetime'] = date('Y-m-d H:i:s');; |
|
| 1201 | + $data['datetime'] = date('Y-m-d H:i:s'); ; |
|
| 1202 | 1202 | if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
| 1203 | 1203 | if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
| 1204 | 1204 | if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
@@ -1217,22 +1217,22 @@ discard block |
||
| 1217 | 1217 | } else $error = true; |
| 1218 | 1218 | } elseif ($format == 'aprs' && $use_aprs) { |
| 1219 | 1219 | if ($aprs_connect == 0) { |
| 1220 | - $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
|
| 1220 | + $send = @ socket_send($r, $aprs_login, strlen($aprs_login), 0); |
|
| 1221 | 1221 | $aprs_connect = 1; |
| 1222 | 1222 | } |
| 1223 | 1223 | |
| 1224 | - if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
| 1224 | + if ($aprs_keep > 60 && time() - $aprs_last_tx > $aprs_keep) { |
|
| 1225 | 1225 | $aprs_last_tx = time(); |
| 1226 | 1226 | $data_aprs = "# Keep alive"; |
| 1227 | - $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
|
| 1227 | + $send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0); |
|
| 1228 | 1228 | } |
| 1229 | 1229 | |
| 1230 | 1230 | //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
| 1231 | 1231 | //echo 'APRS data : '.$buffer."\n"; |
| 1232 | - $buffer = str_replace('APRS <- ','',$buffer); |
|
| 1233 | - $buffer = str_replace('APRS -> ','',$buffer); |
|
| 1232 | + $buffer = str_replace('APRS <- ', '', $buffer); |
|
| 1233 | + $buffer = str_replace('APRS -> ', '', $buffer); |
|
| 1234 | 1234 | //echo $buffer."\n"; |
| 1235 | - if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
| 1235 | + if (substr($buffer, 0, 1) != '#' && substr($buffer, 0, 1) != '@' && substr($buffer, 0, 5) != 'APRS ') { |
|
| 1236 | 1236 | $line = $APRS->parse($buffer); |
| 1237 | 1237 | //if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) { |
| 1238 | 1238 | if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) { |
@@ -1243,7 +1243,7 @@ discard block |
||
| 1243 | 1243 | if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
| 1244 | 1244 | if (isset($line['type_id'])) $data['type_id'] = $line['typeid']; |
| 1245 | 1245 | if (isset($line['status_id'])) $data['status_id'] = $line['statusid']; |
| 1246 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
| 1246 | + if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']); |
|
| 1247 | 1247 | else $data['datetime'] = date('Y-m-d H:i:s'); |
| 1248 | 1248 | //$data['datetime'] = date('Y-m-d H:i:s'); |
| 1249 | 1249 | if (isset($line['ident'])) $data['ident'] = $line['ident']; |
@@ -1372,7 +1372,7 @@ discard block |
||
| 1372 | 1372 | connect_all($sourceee); |
| 1373 | 1373 | $sourceee = array(); |
| 1374 | 1374 | //connect_all($globalSources); |
| 1375 | - $tt[$format]=0; |
|
| 1375 | + $tt[$format] = 0; |
|
| 1376 | 1376 | break; |
| 1377 | 1377 | } |
| 1378 | 1378 | } |
@@ -1381,14 +1381,14 @@ discard block |
||
| 1381 | 1381 | } else { |
| 1382 | 1382 | $error = socket_strerror(socket_last_error()); |
| 1383 | 1383 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
| 1384 | - if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
|
| 1384 | + if ($globalDebug) echo "ERROR : socket_select give this error ".$error."\n"; |
|
| 1385 | 1385 | if (isset($globalDebug)) echo "Restarting...\n"; |
| 1386 | 1386 | // Restart the script if possible |
| 1387 | 1387 | if (is_array($sockets)) { |
| 1388 | 1388 | if ($globalDebug) echo "Shutdown all sockets..."; |
| 1389 | 1389 | |
| 1390 | 1390 | foreach ($sockets as $sock) { |
| 1391 | - @socket_shutdown($sock,2); |
|
| 1391 | + @socket_shutdown($sock, 2); |
|
| 1392 | 1392 | @socket_close($sock); |
| 1393 | 1393 | } |
| 1394 | 1394 | |
@@ -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(); |
@@ -54,35 +58,62 @@ discard block |
||
| 54 | 58 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
| 55 | 59 | if (isset($options['s'])) { |
| 56 | 60 | $globalSources = array(); |
| 57 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
| 58 | - else $globalSources[] = array('host' => $options['s']); |
|
| 59 | -} elseif (isset($options['source'])) { |
|
| 61 | + if (isset($options['format'])) { |
|
| 62 | + $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
| 63 | + } else { |
|
| 64 | + $globalSources[] = array('host' => $options['s']); |
|
| 65 | + } |
|
| 66 | + } elseif (isset($options['source'])) { |
|
| 60 | 67 | $globalSources = array(); |
| 61 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
| 62 | - else $globalSources[] = array('host' => $options['source']); |
|
| 63 | -} |
|
| 68 | + if (isset($options['format'])) { |
|
| 69 | + $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
| 70 | + } else { |
|
| 71 | + $globalSources[] = array('host' => $options['source']); |
|
| 72 | + } |
|
| 73 | + } |
|
| 64 | 74 | if (isset($options['aprsserverhost'])) { |
| 65 | 75 | $globalServerAPRS = TRUE; |
| 66 | 76 | $globalServerAPRShost = $options['aprsserverhost']; |
| 67 | 77 | } |
| 68 | -if (isset($options['aprsserverport'])) $globalServerAPRSport = $options['aprsserverport']; |
|
| 69 | -if (isset($options['aprsserverssid'])) $globalServerAPRSssid = $options['aprsserverssid']; |
|
| 70 | -if (isset($options['aprsserverpass'])) $globalServerAPRSpass = $options['aprsserverpass']; |
|
| 71 | -if (isset($options['noaprsserver'])) $globalServerAPRS = FALSE; |
|
| 72 | -if (isset($options['nodaemon'])) $globalDaemon = FALSE; |
|
| 73 | -if (isset($options['server'])) $globalServer = TRUE; |
|
| 74 | -if (isset($options['idsource'])) $id_source = $options['idsource']; |
|
| 75 | -else $id_source = 1; |
|
| 78 | +if (isset($options['aprsserverport'])) { |
|
| 79 | + $globalServerAPRSport = $options['aprsserverport']; |
|
| 80 | +} |
|
| 81 | +if (isset($options['aprsserverssid'])) { |
|
| 82 | + $globalServerAPRSssid = $options['aprsserverssid']; |
|
| 83 | +} |
|
| 84 | +if (isset($options['aprsserverpass'])) { |
|
| 85 | + $globalServerAPRSpass = $options['aprsserverpass']; |
|
| 86 | +} |
|
| 87 | +if (isset($options['noaprsserver'])) { |
|
| 88 | + $globalServerAPRS = FALSE; |
|
| 89 | +} |
|
| 90 | +if (isset($options['nodaemon'])) { |
|
| 91 | + $globalDaemon = FALSE; |
|
| 92 | +} |
|
| 93 | +if (isset($options['server'])) { |
|
| 94 | + $globalServer = TRUE; |
|
| 95 | +} |
|
| 96 | +if (isset($options['idsource'])) { |
|
| 97 | + $id_source = $options['idsource']; |
|
| 98 | +} else { |
|
| 99 | + $id_source = 1; |
|
| 100 | +} |
|
| 76 | 101 | if (isset($globalServer) && $globalServer) { |
| 77 | - if ($globalDebug) echo "Using Server Mode\n"; |
|
| 102 | + if ($globalDebug) { |
|
| 103 | + echo "Using Server Mode\n"; |
|
| 104 | + } |
|
| 78 | 105 | $SI=new SpotterServer(); |
| 79 | 106 | /* |
| 80 | 107 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
| 81 | 108 | $SI = new adsb2aprs(); |
| 82 | 109 | $SI->connect(); |
| 83 | 110 | */ |
| 84 | -} else $SI=new SpotterImport($Connection->db); |
|
| 85 | -if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db); |
|
| 111 | +} else { |
|
| 112 | + $SI=new SpotterImport($Connection->db); |
|
| 113 | +} |
|
| 114 | +if (isset($globalTracker) && $globalTracker) { |
|
| 115 | + $TI = new TrackerImport($Connection->db); |
|
| 116 | +} |
|
| 86 | 117 | if (isset($globalMarine) && $globalMarine) { |
| 87 | 118 | $AIS = new AIS(); |
| 88 | 119 | $MI = new MarineImport($Connection->db); |
@@ -104,7 +135,9 @@ discard block |
||
| 104 | 135 | } |
| 105 | 136 | |
| 106 | 137 | // let's try and connect |
| 107 | -if ($globalDebug) echo "Connecting...\n"; |
|
| 138 | +if ($globalDebug) { |
|
| 139 | + echo "Connecting...\n"; |
|
| 140 | +} |
|
| 108 | 141 | $use_aprs = false; |
| 109 | 142 | $aprs_full = false; |
| 110 | 143 | $reset = 0; |
@@ -113,7 +146,9 @@ discard block |
||
| 113 | 146 | //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
| 114 | 147 | global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
| 115 | 148 | $reset++; |
| 116 | - if ($globalDebug) echo 'Connect to all...'."\n"; |
|
| 149 | + if ($globalDebug) { |
|
| 150 | + echo 'Connect to all...'."\n"; |
|
| 151 | + } |
|
| 117 | 152 | foreach ($hosts as $id => $value) { |
| 118 | 153 | $host = $value['host']; |
| 119 | 154 | $globalSources[$id]['last_exec'] = 0; |
@@ -123,27 +158,37 @@ discard block |
||
| 123 | 158 | //$formats[$id] = 'deltadbtxt'; |
| 124 | 159 | $globalSources[$id]['format'] = 'deltadbtxt'; |
| 125 | 160 | //$last_exec['deltadbtxt'] = 0; |
| 126 | - if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
| 161 | + if ($globalDebug) { |
|
| 162 | + echo "Connect to deltadb source (".$host.")...\n"; |
|
| 163 | + } |
|
| 127 | 164 | } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
| 128 | 165 | //$formats[$id] = 'vatsimtxt'; |
| 129 | 166 | $globalSources[$id]['format'] = 'vatsimtxt'; |
| 130 | 167 | //$last_exec['vatsimtxt'] = 0; |
| 131 | - if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
| 168 | + if ($globalDebug) { |
|
| 169 | + echo "Connect to vatsim source (".$host.")...\n"; |
|
| 170 | + } |
|
| 132 | 171 | } else if (preg_match('/aircraftlist.json$/i',$host)) { |
| 133 | 172 | //$formats[$id] = 'aircraftlistjson'; |
| 134 | 173 | $globalSources[$id]['format'] = 'aircraftlistjson'; |
| 135 | 174 | //$last_exec['aircraftlistjson'] = 0; |
| 136 | - if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
| 175 | + if ($globalDebug) { |
|
| 176 | + echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
| 177 | + } |
|
| 137 | 178 | } else if (preg_match('/opensky/i',$host)) { |
| 138 | 179 | //$formats[$id] = 'aircraftlistjson'; |
| 139 | 180 | $globalSources[$id]['format'] = 'opensky'; |
| 140 | 181 | //$last_exec['aircraftlistjson'] = 0; |
| 141 | - if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
| 182 | + if ($globalDebug) { |
|
| 183 | + echo "Connect to opensky source (".$host.")...\n"; |
|
| 184 | + } |
|
| 142 | 185 | } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) { |
| 143 | 186 | //$formats[$id] = 'radarvirtueljson'; |
| 144 | 187 | $globalSources[$id]['format'] = 'radarvirtueljson'; |
| 145 | 188 | //$last_exec['radarvirtueljson'] = 0; |
| 146 | - if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n"; |
|
| 189 | + if ($globalDebug) { |
|
| 190 | + echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n"; |
|
| 191 | + } |
|
| 147 | 192 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
| 148 | 193 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
| 149 | 194 | exit(0); |
@@ -152,7 +197,9 @@ discard block |
||
| 152 | 197 | //$formats[$id] = 'planeupdatefaa'; |
| 153 | 198 | $globalSources[$id]['format'] = 'planeupdatefaa'; |
| 154 | 199 | //$last_exec['planeupdatefaa'] = 0; |
| 155 | - if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
| 200 | + if ($globalDebug) { |
|
| 201 | + echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
| 202 | + } |
|
| 156 | 203 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
| 157 | 204 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
| 158 | 205 | exit(0); |
@@ -161,26 +208,36 @@ discard block |
||
| 161 | 208 | //$formats[$id] = 'phpvmacars'; |
| 162 | 209 | $globalSources[$id]['format'] = 'phpvmacars'; |
| 163 | 210 | //$last_exec['phpvmacars'] = 0; |
| 164 | - if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
| 211 | + if ($globalDebug) { |
|
| 212 | + echo "Connect to phpvmacars source (".$host.")...\n"; |
|
| 213 | + } |
|
| 165 | 214 | } else if (preg_match('/VAM-json.php$/i',$host)) { |
| 166 | 215 | //$formats[$id] = 'phpvmacars'; |
| 167 | 216 | $globalSources[$id]['format'] = 'vam'; |
| 168 | - if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
| 217 | + if ($globalDebug) { |
|
| 218 | + echo "Connect to Vam source (".$host.")...\n"; |
|
| 219 | + } |
|
| 169 | 220 | } else if (preg_match('/whazzup/i',$host)) { |
| 170 | 221 | //$formats[$id] = 'whazzup'; |
| 171 | 222 | $globalSources[$id]['format'] = 'whazzup'; |
| 172 | 223 | //$last_exec['whazzup'] = 0; |
| 173 | - if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
| 224 | + if ($globalDebug) { |
|
| 225 | + echo "Connect to whazzup source (".$host.")...\n"; |
|
| 226 | + } |
|
| 174 | 227 | } else if (preg_match('/recentpireps/i',$host)) { |
| 175 | 228 | //$formats[$id] = 'pirepsjson'; |
| 176 | 229 | $globalSources[$id]['format'] = 'pirepsjson'; |
| 177 | 230 | //$last_exec['pirepsjson'] = 0; |
| 178 | - if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
| 231 | + if ($globalDebug) { |
|
| 232 | + echo "Connect to pirepsjson source (".$host.")...\n"; |
|
| 233 | + } |
|
| 179 | 234 | } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
| 180 | 235 | //$formats[$id] = 'fr24json'; |
| 181 | 236 | $globalSources[$id]['format'] = 'fr24json'; |
| 182 | 237 | //$last_exec['fr24json'] = 0; |
| 183 | - if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
| 238 | + if ($globalDebug) { |
|
| 239 | + echo "Connect to fr24 source (".$host.")...\n"; |
|
| 240 | + } |
|
| 184 | 241 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
| 185 | 242 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
| 186 | 243 | exit(0); |
@@ -189,7 +246,9 @@ discard block |
||
| 189 | 246 | //$formats[$id] = 'fr24json'; |
| 190 | 247 | $globalSources[$id]['format'] = 'myshiptracking'; |
| 191 | 248 | //$last_exec['fr24json'] = 0; |
| 192 | - if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
| 249 | + if ($globalDebug) { |
|
| 250 | + echo "Connect to myshiptracking source (".$host.")...\n"; |
|
| 251 | + } |
|
| 193 | 252 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
| 194 | 253 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
| 195 | 254 | exit(0); |
@@ -198,17 +257,24 @@ discard block |
||
| 198 | 257 | } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
| 199 | 258 | //$formats[$id] = 'tsv'; |
| 200 | 259 | $globalSources[$id]['format'] = 'tsv'; |
| 201 | - if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
| 260 | + if ($globalDebug) { |
|
| 261 | + echo "Connect to tsv source (".$host.")...\n"; |
|
| 262 | + } |
|
| 202 | 263 | } |
| 203 | 264 | } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
| 204 | 265 | if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
| 205 | 266 | $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
| 206 | 267 | if ($idf !== false) { |
| 207 | 268 | $httpfeeds[$id] = $idf; |
| 208 | - if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 269 | + if ($globalDebug) { |
|
| 270 | + echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 271 | + } |
|
| 272 | + } elseif ($globalDebug) { |
|
| 273 | + echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
| 209 | 274 | } |
| 210 | - elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
| 211 | - } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 275 | + } elseif ($globalDebug) { |
|
| 276 | + echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 277 | + } |
|
| 212 | 278 | } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
| 213 | 279 | $hostport = explode(':',$host); |
| 214 | 280 | if (isset($hostport[1])) { |
@@ -248,17 +314,25 @@ discard block |
||
| 248 | 314 | //$formats[$id] = 'beast'; |
| 249 | 315 | $globalSources[$id]['format'] = 'beast'; |
| 250 | 316 | //} else $formats[$id] = 'sbs'; |
| 251 | - } else $globalSources[$id]['format'] = 'sbs'; |
|
| 317 | + } else { |
|
| 318 | + $globalSources[$id]['format'] = 'sbs'; |
|
| 319 | + } |
|
| 252 | 320 | //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
| 253 | 321 | } |
| 254 | - if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
|
| 322 | + if ($globalDebug) { |
|
| 323 | + echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
|
| 324 | + } |
|
| 255 | 325 | } else { |
| 256 | - if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
|
| 326 | + if ($globalDebug) { |
|
| 327 | + echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
|
| 328 | + } |
|
| 257 | 329 | } |
| 258 | 330 | } |
| 259 | 331 | } |
| 260 | 332 | } |
| 261 | -if (!isset($globalMinFetch)) $globalMinFetch = 15; |
|
| 333 | +if (!isset($globalMinFetch)) { |
|
| 334 | + $globalMinFetch = 15; |
|
| 335 | +} |
|
| 262 | 336 | |
| 263 | 337 | // Initialize all |
| 264 | 338 | $status = array(); |
@@ -267,13 +341,19 @@ discard block |
||
| 267 | 341 | $formats = array(); |
| 268 | 342 | $last_exec = array(); |
| 269 | 343 | $time = time(); |
| 270 | -if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut; |
|
| 271 | -else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut; |
|
| 272 | -else $timeout = 20; |
|
| 344 | +if (isset($globalSourcesTimeout)) { |
|
| 345 | + $timeout = $globalSourcesTimeOut; |
|
| 346 | +} else if (isset($globalSBS1TimeOut)) { |
|
| 347 | + $timeout = $globalSBS1TimeOut; |
|
| 348 | +} else { |
|
| 349 | + $timeout = 20; |
|
| 350 | +} |
|
| 273 | 351 | $errno = ''; |
| 274 | 352 | $errstr=''; |
| 275 | 353 | |
| 276 | -if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
| 354 | +if (!isset($globalDaemon)) { |
|
| 355 | + $globalDaemon = TRUE; |
|
| 356 | +} |
|
| 277 | 357 | /* Initiate connections to all the hosts simultaneously */ |
| 278 | 358 | //connect_all($hosts); |
| 279 | 359 | //connect_all($globalSources); |
@@ -299,7 +379,9 @@ discard block |
||
| 299 | 379 | if (isset($source['format']) && $source['format'] == 'aprs') { |
| 300 | 380 | $aprs_connect = 0; |
| 301 | 381 | $use_aprs = true; |
| 302 | - if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true; |
|
| 382 | + if (isset($source['port']) && $source['port'] == '10152') { |
|
| 383 | + $aprs_full = true; |
|
| 384 | + } |
|
| 303 | 385 | break; |
| 304 | 386 | } |
| 305 | 387 | } |
@@ -310,25 +392,48 @@ discard block |
||
| 310 | 392 | $aprs_connect = 0; |
| 311 | 393 | $aprs_keep = 120; |
| 312 | 394 | $aprs_last_tx = time(); |
| 313 | - if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; |
|
| 314 | - else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
| 315 | - if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid; |
|
| 316 | - else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
| 317 | - if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter; |
|
| 318 | - else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
| 319 | - if ($aprs_full) $aprs_filter = ''; |
|
| 320 | - if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass; |
|
| 321 | - else $aprs_pass = '-1'; |
|
| 395 | + if (isset($globalAPRSversion)) { |
|
| 396 | + $aprs_version = $globalAPRSversion; |
|
| 397 | + } else { |
|
| 398 | + $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
| 399 | + } |
|
| 400 | + if (isset($globalAPRSssid)) { |
|
| 401 | + $aprs_ssid = $globalAPRSssid; |
|
| 402 | + } else { |
|
| 403 | + $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
| 404 | + } |
|
| 405 | + if (isset($globalAPRSfilter)) { |
|
| 406 | + $aprs_filter = $globalAPRSfilter; |
|
| 407 | + } else { |
|
| 408 | + $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
| 409 | + } |
|
| 410 | + if ($aprs_full) { |
|
| 411 | + $aprs_filter = ''; |
|
| 412 | + } |
|
| 413 | + if (isset($globalAPRSpass)) { |
|
| 414 | + $aprs_pass = $globalAPRSpass; |
|
| 415 | + } else { |
|
| 416 | + $aprs_pass = '-1'; |
|
| 417 | + } |
|
| 322 | 418 | |
| 323 | - if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n"; |
|
| 324 | - else $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; |
|
| 325 | -} |
|
| 419 | + if ($aprs_filter != '') { |
|
| 420 | + $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n"; |
|
| 421 | + } else { |
|
| 422 | + $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; |
|
| 423 | + } |
|
| 424 | + } |
|
| 326 | 425 | |
| 327 | 426 | // connected - lets do some work |
| 328 | -if ($globalDebug) echo "Connected!\n"; |
|
| 427 | +if ($globalDebug) { |
|
| 428 | + echo "Connected!\n"; |
|
| 429 | +} |
|
| 329 | 430 | sleep(1); |
| 330 | -if ($globalDebug) echo "SCAN MODE \n\n"; |
|
| 331 | -if (!isset($globalCronEnd)) $globalCronEnd = 60; |
|
| 431 | +if ($globalDebug) { |
|
| 432 | + echo "SCAN MODE \n\n"; |
|
| 433 | +} |
|
| 434 | +if (!isset($globalCronEnd)) { |
|
| 435 | + $globalCronEnd = 60; |
|
| 436 | +} |
|
| 332 | 437 | $endtime = time()+$globalCronEnd; |
| 333 | 438 | $i = 1; |
| 334 | 439 | $tt = array(); |
@@ -342,10 +447,14 @@ discard block |
||
| 342 | 447 | |
| 343 | 448 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
| 344 | 449 | while ($i > 0) { |
| 345 | - if (!$globalDaemon) $i = $endtime-time(); |
|
| 450 | + if (!$globalDaemon) { |
|
| 451 | + $i = $endtime-time(); |
|
| 452 | + } |
|
| 346 | 453 | // Delete old ATC |
| 347 | 454 | if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
| 348 | - if ($globalDebug) echo 'Delete old ATC...'."\n"; |
|
| 455 | + if ($globalDebug) { |
|
| 456 | + echo 'Delete old ATC...'."\n"; |
|
| 457 | + } |
|
| 349 | 458 | $ATC->deleteOldATC(); |
| 350 | 459 | } |
| 351 | 460 | |
@@ -353,10 +462,14 @@ discard block |
||
| 353 | 462 | if (count($last_exec) == count($globalSources)) { |
| 354 | 463 | $max = $globalMinFetch; |
| 355 | 464 | foreach ($last_exec as $last) { |
| 356 | - if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
| 465 | + if ((time() - $last['last']) < $max) { |
|
| 466 | + $max = time() - $last['last']; |
|
| 467 | + } |
|
| 357 | 468 | } |
| 358 | 469 | if ($max != $globalMinFetch) { |
| 359 | - if ($globalDebug) echo 'Sleeping...'."\n"; |
|
| 470 | + if ($globalDebug) { |
|
| 471 | + echo 'Sleeping...'."\n"; |
|
| 472 | + } |
|
| 360 | 473 | sleep($globalMinFetch-$max+2); |
| 361 | 474 | } |
| 362 | 475 | } |
@@ -365,11 +478,15 @@ discard block |
||
| 365 | 478 | //foreach ($formats as $id => $value) { |
| 366 | 479 | foreach ($globalSources as $id => $value) { |
| 367 | 480 | date_default_timezone_set('UTC'); |
| 368 | - if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0; |
|
| 481 | + if (!isset($last_exec[$id]['last'])) { |
|
| 482 | + $last_exec[$id]['last'] = 0; |
|
| 483 | + } |
|
| 369 | 484 | if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
| 370 | 485 | //$buffer = $Common->getData($hosts[$id]); |
| 371 | 486 | $buffer = $Common->getData($value['host']); |
| 372 | - if ($buffer != '') $reset = 0; |
|
| 487 | + if ($buffer != '') { |
|
| 488 | + $reset = 0; |
|
| 489 | + } |
|
| 373 | 490 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
| 374 | 491 | $buffer = explode('\n',$buffer); |
| 375 | 492 | foreach ($buffer as $line) { |
@@ -378,20 +495,41 @@ discard block |
||
| 378 | 495 | $data = array(); |
| 379 | 496 | $data['hex'] = $line[1]; // hex |
| 380 | 497 | $data['ident'] = $line[2]; // ident |
| 381 | - if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
| 382 | - if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
| 383 | - if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
| 384 | - if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
| 385 | - if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
| 498 | + if (isset($line[3])) { |
|
| 499 | + $data['altitude'] = $line[3]; |
|
| 500 | + } |
|
| 501 | + // altitude |
|
| 502 | + if (isset($line[4])) { |
|
| 503 | + $data['speed'] = $line[4]; |
|
| 504 | + } |
|
| 505 | + // speed |
|
| 506 | + if (isset($line[5])) { |
|
| 507 | + $data['heading'] = $line[5]; |
|
| 508 | + } |
|
| 509 | + // heading |
|
| 510 | + if (isset($line[6])) { |
|
| 511 | + $data['latitude'] = $line[6]; |
|
| 512 | + } |
|
| 513 | + // lat |
|
| 514 | + if (isset($line[7])) { |
|
| 515 | + $data['longitude'] = $line[7]; |
|
| 516 | + } |
|
| 517 | + // long |
|
| 386 | 518 | $data['verticalrate'] = ''; // vertical rate |
| 387 | 519 | //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
| 388 | 520 | $data['emergency'] = ''; // emergency |
| 389 | 521 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 390 | 522 | $data['format_source'] = 'deltadbtxt'; |
| 391 | 523 | $data['id_source'] = $id_source; |
| 392 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 393 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 394 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
| 524 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 525 | + $data['source_name'] = $value['name']; |
|
| 526 | + } |
|
| 527 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 528 | + $data['noarchive'] = true; |
|
| 529 | + } |
|
| 530 | + if (isset($value['sourcestats'])) { |
|
| 531 | + $data['sourcestats'] = $value['sourcestats']; |
|
| 532 | + } |
|
| 395 | 533 | $SI->add($data); |
| 396 | 534 | unset($data); |
| 397 | 535 | } |
@@ -401,7 +539,9 @@ discard block |
||
| 401 | 539 | date_default_timezone_set('CET'); |
| 402 | 540 | $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
| 403 | 541 | date_default_timezone_set('UTC'); |
| 404 | - if ($buffer != '') $reset = 0; |
|
| 542 | + if ($buffer != '') { |
|
| 543 | + $reset = 0; |
|
| 544 | + } |
|
| 405 | 545 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
| 406 | 546 | $buffer = explode('\n',$buffer); |
| 407 | 547 | foreach ($buffer as $line) { |
@@ -410,16 +550,36 @@ discard block |
||
| 410 | 550 | $add = false; |
| 411 | 551 | $ais_data = $AIS->parse_line(trim($line)); |
| 412 | 552 | $data = array(); |
| 413 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 414 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
| 415 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 416 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 417 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 418 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 419 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 420 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 421 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 422 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 553 | + if (isset($ais_data['ident'])) { |
|
| 554 | + $data['ident'] = $ais_data['ident']; |
|
| 555 | + } |
|
| 556 | + if (isset($ais_data['mmsi'])) { |
|
| 557 | + $data['mmsi'] = $ais_data['mmsi']; |
|
| 558 | + } |
|
| 559 | + if (isset($ais_data['speed'])) { |
|
| 560 | + $data['speed'] = $ais_data['speed']; |
|
| 561 | + } |
|
| 562 | + if (isset($ais_data['heading'])) { |
|
| 563 | + $data['heading'] = $ais_data['heading']; |
|
| 564 | + } |
|
| 565 | + if (isset($ais_data['latitude'])) { |
|
| 566 | + $data['latitude'] = $ais_data['latitude']; |
|
| 567 | + } |
|
| 568 | + if (isset($ais_data['longitude'])) { |
|
| 569 | + $data['longitude'] = $ais_data['longitude']; |
|
| 570 | + } |
|
| 571 | + if (isset($ais_data['status'])) { |
|
| 572 | + $data['status'] = $ais_data['status']; |
|
| 573 | + } |
|
| 574 | + if (isset($ais_data['type'])) { |
|
| 575 | + $data['type'] = $ais_data['type']; |
|
| 576 | + } |
|
| 577 | + if (isset($ais_data['imo'])) { |
|
| 578 | + $data['imo'] = $ais_data['imo']; |
|
| 579 | + } |
|
| 580 | + if (isset($ais_data['callsign'])) { |
|
| 581 | + $data['callsign'] = $ais_data['callsign']; |
|
| 582 | + } |
|
| 423 | 583 | if (isset($ais_data['timestamp'])) { |
| 424 | 584 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
| 425 | 585 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
@@ -434,8 +594,12 @@ discard block |
||
| 434 | 594 | $data['id_source'] = $id_source; |
| 435 | 595 | //print_r($data); |
| 436 | 596 | echo 'Add...'."\n"; |
| 437 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 438 | - if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
| 597 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 598 | + $data['noarchive'] = true; |
|
| 599 | + } |
|
| 600 | + if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') { |
|
| 601 | + $MI->add($data); |
|
| 602 | + } |
|
| 439 | 603 | unset($data); |
| 440 | 604 | } |
| 441 | 605 | } |
@@ -455,19 +619,45 @@ discard block |
||
| 455 | 619 | if ($line != '') { |
| 456 | 620 | $ais_data = $AIS->parse_line(trim($line)); |
| 457 | 621 | $data = array(); |
| 458 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 459 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
| 460 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 461 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 462 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 463 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 464 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 465 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
| 466 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 467 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 468 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 469 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
| 470 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 622 | + if (isset($ais_data['ident'])) { |
|
| 623 | + $data['ident'] = $ais_data['ident']; |
|
| 624 | + } |
|
| 625 | + if (isset($ais_data['mmsi'])) { |
|
| 626 | + $data['mmsi'] = $ais_data['mmsi']; |
|
| 627 | + } |
|
| 628 | + if (isset($ais_data['speed'])) { |
|
| 629 | + $data['speed'] = $ais_data['speed']; |
|
| 630 | + } |
|
| 631 | + if (isset($ais_data['heading'])) { |
|
| 632 | + $data['heading'] = $ais_data['heading']; |
|
| 633 | + } |
|
| 634 | + if (isset($ais_data['latitude'])) { |
|
| 635 | + $data['latitude'] = $ais_data['latitude']; |
|
| 636 | + } |
|
| 637 | + if (isset($ais_data['longitude'])) { |
|
| 638 | + $data['longitude'] = $ais_data['longitude']; |
|
| 639 | + } |
|
| 640 | + if (isset($ais_data['status'])) { |
|
| 641 | + $data['status'] = $ais_data['status']; |
|
| 642 | + } |
|
| 643 | + if (isset($ais_data['statusid'])) { |
|
| 644 | + $data['status_id'] = $ais_data['statusid']; |
|
| 645 | + } |
|
| 646 | + if (isset($ais_data['type'])) { |
|
| 647 | + $data['type'] = $ais_data['type']; |
|
| 648 | + } |
|
| 649 | + if (isset($ais_data['imo'])) { |
|
| 650 | + $data['imo'] = $ais_data['imo']; |
|
| 651 | + } |
|
| 652 | + if (isset($ais_data['callsign'])) { |
|
| 653 | + $data['callsign'] = $ais_data['callsign']; |
|
| 654 | + } |
|
| 655 | + if (isset($ais_data['destination'])) { |
|
| 656 | + $data['arrival_code'] = $ais_data['destination']; |
|
| 657 | + } |
|
| 658 | + if (isset($ais_data['eta_ts'])) { |
|
| 659 | + $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 660 | + } |
|
| 471 | 661 | if (isset($ais_data['timestamp'])) { |
| 472 | 662 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
| 473 | 663 | } else { |
@@ -475,16 +665,23 @@ discard block |
||
| 475 | 665 | } |
| 476 | 666 | $data['format_source'] = 'aisnmeahttp'; |
| 477 | 667 | $data['id_source'] = $id_source; |
| 478 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 479 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
| 668 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 669 | + $data['noarchive'] = true; |
|
| 670 | + } |
|
| 671 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') { |
|
| 672 | + $MI->add($data); |
|
| 673 | + } |
|
| 480 | 674 | unset($data); |
| 481 | 675 | } |
| 482 | 676 | } |
| 483 | 677 | } |
| 484 | 678 | } else { |
| 485 | 679 | $format = $value['format']; |
| 486 | - if (isset($tt[$format])) $tt[$format]++; |
|
| 487 | - else $tt[$format] = 0; |
|
| 680 | + if (isset($tt[$format])) { |
|
| 681 | + $tt[$format]++; |
|
| 682 | + } else { |
|
| 683 | + $tt[$format] = 0; |
|
| 684 | + } |
|
| 488 | 685 | if ($tt[$format] > 30) { |
| 489 | 686 | sleep(2); |
| 490 | 687 | $sourceeen[] = $value; |
@@ -515,7 +712,9 @@ discard block |
||
| 515 | 712 | $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
| 516 | 713 | $data['format_source'] = 'myshiptracking'; |
| 517 | 714 | $data['id_source'] = $id_source; |
| 518 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 715 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 716 | + $data['noarchive'] = true; |
|
| 717 | + } |
|
| 519 | 718 | $MI->add($data); |
| 520 | 719 | unset($data); |
| 521 | 720 | } |
@@ -536,7 +735,9 @@ discard block |
||
| 536 | 735 | $data['callsign'] = $line['callsign']; |
| 537 | 736 | $data['mmsi'] = $line['mmsi']; |
| 538 | 737 | $data['speed'] = $line['sog']; |
| 539 | - if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
| 738 | + if ($line['heading'] != '511') { |
|
| 739 | + $data['heading'] = $line['heading']; |
|
| 740 | + } |
|
| 540 | 741 | $data['latitude'] = $line['latitude']; |
| 541 | 742 | $data['longitude'] = $line['longitude']; |
| 542 | 743 | $data['type_id'] = $line['shiptype']; |
@@ -544,7 +745,9 @@ discard block |
||
| 544 | 745 | $data['datetime'] = $line['time']; |
| 545 | 746 | $data['format_source'] = 'boatbeaconapp'; |
| 546 | 747 | $data['id_source'] = $id_source; |
| 547 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 748 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 749 | + $data['noarchive'] = true; |
|
| 750 | + } |
|
| 548 | 751 | $MI->add($data); |
| 549 | 752 | unset($data); |
| 550 | 753 | } |
@@ -557,7 +760,9 @@ discard block |
||
| 557 | 760 | echo 'download...'; |
| 558 | 761 | $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
| 559 | 762 | echo 'done !'."\n"; |
| 560 | - if ($buffer != '') $reset = 0; |
|
| 763 | + if ($buffer != '') { |
|
| 764 | + $reset = 0; |
|
| 765 | + } |
|
| 561 | 766 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
| 562 | 767 | $buffer = explode('\n',$buffer); |
| 563 | 768 | foreach ($buffer as $line) { |
@@ -582,7 +787,9 @@ discard block |
||
| 582 | 787 | //$data['etaTime'] = substr($line,135,5); |
| 583 | 788 | $data['format_source'] = 'shipplotter'; |
| 584 | 789 | $data['id_source'] = $id_source; |
| 585 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 790 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 791 | + $data['noarchive'] = true; |
|
| 792 | + } |
|
| 586 | 793 | //print_r($data); |
| 587 | 794 | echo 'Add...'."\n"; |
| 588 | 795 | $MI->add($data); |
@@ -602,16 +809,28 @@ discard block |
||
| 602 | 809 | $line = explode(':', $line); |
| 603 | 810 | if (count($line) > 30 && $line[0] != 'callsign') { |
| 604 | 811 | $data = array(); |
| 605 | - if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
|
| 606 | - else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
|
| 812 | + if (isset($line[37]) && $line[37] != '') { |
|
| 813 | + $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
|
| 814 | + } else { |
|
| 815 | + $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
|
| 816 | + } |
|
| 607 | 817 | $data['pilot_id'] = $line[1]; |
| 608 | 818 | $data['pilot_name'] = $line[2]; |
| 609 | 819 | $data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT); |
| 610 | 820 | $data['ident'] = $line[0]; // ident |
| 611 | - if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude |
|
| 821 | + if ($line[7] != '' && $line[7] != 0) { |
|
| 822 | + $data['altitude'] = $line[7]; |
|
| 823 | + } |
|
| 824 | + // altitude |
|
| 612 | 825 | $data['speed'] = $line[8]; // speed |
| 613 | - if (isset($line[45])) $data['heading'] = $line[45]; // heading |
|
| 614 | - elseif (isset($line[38])) $data['heading'] = $line[38]; // heading |
|
| 826 | + if (isset($line[45])) { |
|
| 827 | + $data['heading'] = $line[45]; |
|
| 828 | + } |
|
| 829 | + // heading |
|
| 830 | + elseif (isset($line[38])) { |
|
| 831 | + $data['heading'] = $line[38]; |
|
| 832 | + } |
|
| 833 | + // heading |
|
| 615 | 834 | $data['latitude'] = $line[5]; // lat |
| 616 | 835 | $data['longitude'] = $line[6]; // long |
| 617 | 836 | $data['verticalrate'] = ''; // vertical rate |
@@ -627,7 +846,9 @@ discard block |
||
| 627 | 846 | $data['frequency'] = $line[4]; |
| 628 | 847 | $data['type'] = $line[18]; |
| 629 | 848 | $data['range'] = $line[19]; |
| 630 | - if (isset($line[35])) $data['info'] = $line[35]; |
|
| 849 | + if (isset($line[35])) { |
|
| 850 | + $data['info'] = $line[35]; |
|
| 851 | + } |
|
| 631 | 852 | $data['id_source'] = $id_source; |
| 632 | 853 | //$data['arrival_airport_time'] = ; |
| 633 | 854 | if ($line[9] != '') { |
@@ -641,25 +862,44 @@ discard block |
||
| 641 | 862 | elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; |
| 642 | 863 | */ |
| 643 | 864 | $data['format_source'] = $value['format']; |
| 644 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 645 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 646 | - if ($line[3] == 'PILOT') $SI->add($data); |
|
| 647 | - elseif ($line[3] == 'ATC') { |
|
| 865 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 866 | + $data['noarchive'] = true; |
|
| 867 | + } |
|
| 868 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 869 | + $data['source_name'] = $value['name']; |
|
| 870 | + } |
|
| 871 | + if ($line[3] == 'PILOT') { |
|
| 872 | + $SI->add($data); |
|
| 873 | + } elseif ($line[3] == 'ATC') { |
|
| 648 | 874 | //print_r($data); |
| 649 | 875 | $data['info'] = str_replace('^§','<br />',$data['info']); |
| 650 | 876 | $data['info'] = str_replace('&sect;','',$data['info']); |
| 651 | 877 | $typec = substr($data['ident'],-3); |
| 652 | - if ($typec == 'APP') $data['type'] = 'Approach'; |
|
| 653 | - elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
|
| 654 | - elseif ($typec == 'OBS') $data['type'] = 'Observer'; |
|
| 655 | - elseif ($typec == 'GND') $data['type'] = 'Ground'; |
|
| 656 | - elseif ($typec == 'DEL') $data['type'] = 'Delivery'; |
|
| 657 | - elseif ($typec == 'DEP') $data['type'] = 'Departure'; |
|
| 658 | - elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station'; |
|
| 659 | - elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
|
| 660 | - elseif ($data['type'] == '') $data['type'] = 'Observer'; |
|
| 661 | - if (!isset($data['source_name'])) $data['source_name'] = ''; |
|
| 662 | - 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']); |
|
| 878 | + if ($typec == 'APP') { |
|
| 879 | + $data['type'] = 'Approach'; |
|
| 880 | + } elseif ($typec == 'TWR') { |
|
| 881 | + $data['type'] = 'Tower'; |
|
| 882 | + } elseif ($typec == 'OBS') { |
|
| 883 | + $data['type'] = 'Observer'; |
|
| 884 | + } elseif ($typec == 'GND') { |
|
| 885 | + $data['type'] = 'Ground'; |
|
| 886 | + } elseif ($typec == 'DEL') { |
|
| 887 | + $data['type'] = 'Delivery'; |
|
| 888 | + } elseif ($typec == 'DEP') { |
|
| 889 | + $data['type'] = 'Departure'; |
|
| 890 | + } elseif ($typec == 'FSS') { |
|
| 891 | + $data['type'] = 'Flight Service Station'; |
|
| 892 | + } elseif ($typec == 'CTR') { |
|
| 893 | + $data['type'] = 'Control Radar or Centre'; |
|
| 894 | + } elseif ($data['type'] == '') { |
|
| 895 | + $data['type'] = 'Observer'; |
|
| 896 | + } |
|
| 897 | + if (!isset($data['source_name'])) { |
|
| 898 | + $data['source_name'] = ''; |
|
| 899 | + } |
|
| 900 | + if (isset($ATC)) { |
|
| 901 | + 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']); |
|
| 902 | + } |
|
| 663 | 903 | } |
| 664 | 904 | unset($data); |
| 665 | 905 | } |
@@ -678,27 +918,61 @@ discard block |
||
| 678 | 918 | foreach ($all_data['acList'] as $line) { |
| 679 | 919 | $data = array(); |
| 680 | 920 | $data['hex'] = $line['Icao']; // hex |
| 681 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
| 682 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
| 683 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
| 684 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
| 685 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
| 686 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
| 921 | + if (isset($line['Call'])) { |
|
| 922 | + $data['ident'] = $line['Call']; |
|
| 923 | + } |
|
| 924 | + // ident |
|
| 925 | + if (isset($line['Alt'])) { |
|
| 926 | + $data['altitude'] = $line['Alt']; |
|
| 927 | + } |
|
| 928 | + // altitude |
|
| 929 | + if (isset($line['Spd'])) { |
|
| 930 | + $data['speed'] = $line['Spd']; |
|
| 931 | + } |
|
| 932 | + // speed |
|
| 933 | + if (isset($line['Trak'])) { |
|
| 934 | + $data['heading'] = $line['Trak']; |
|
| 935 | + } |
|
| 936 | + // heading |
|
| 937 | + if (isset($line['Lat'])) { |
|
| 938 | + $data['latitude'] = $line['Lat']; |
|
| 939 | + } |
|
| 940 | + // lat |
|
| 941 | + if (isset($line['Long'])) { |
|
| 942 | + $data['longitude'] = $line['Long']; |
|
| 943 | + } |
|
| 944 | + // long |
|
| 687 | 945 | //$data['verticalrate'] = $line['']; // verticale rate |
| 688 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
| 946 | + if (isset($line['Sqk'])) { |
|
| 947 | + $data['squawk'] = $line['Sqk']; |
|
| 948 | + } |
|
| 949 | + // squawk |
|
| 689 | 950 | $data['emergency'] = ''; // emergency |
| 690 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
| 951 | + if (isset($line['Reg'])) { |
|
| 952 | + $data['registration'] = $line['Reg']; |
|
| 953 | + } |
|
| 691 | 954 | |
| 692 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
| 693 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 955 | + if (isset($line['PosTime'])) { |
|
| 956 | + $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
| 957 | + } else { |
|
| 958 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 959 | + } |
|
| 694 | 960 | |
| 695 | 961 | //$data['datetime'] = date('Y-m-d H:i:s'); |
| 696 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
| 962 | + if (isset($line['Type'])) { |
|
| 963 | + $data['aircraft_icao'] = $line['Type']; |
|
| 964 | + } |
|
| 697 | 965 | $data['format_source'] = 'aircraftlistjson'; |
| 698 | 966 | $data['id_source'] = $id_source; |
| 699 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 700 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 701 | - if (isset($data['latitude'])) $SI->add($data); |
|
| 967 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 968 | + $data['source_name'] = $value['name']; |
|
| 969 | + } |
|
| 970 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 971 | + $data['noarchive'] = true; |
|
| 972 | + } |
|
| 973 | + if (isset($data['latitude'])) { |
|
| 974 | + $SI->add($data); |
|
| 975 | + } |
|
| 702 | 976 | unset($data); |
| 703 | 977 | } |
| 704 | 978 | } elseif (is_array($all_data)) { |
@@ -715,12 +989,19 @@ discard block |
||
| 715 | 989 | $data['verticalrate'] = $line['vrt']; // verticale rate |
| 716 | 990 | $data['squawk'] = $line['squawk']; // squawk |
| 717 | 991 | $data['emergency'] = ''; // emergency |
| 718 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
| 719 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 992 | + if (isset($line['PosTime'])) { |
|
| 993 | + $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
| 994 | + } else { |
|
| 995 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 996 | + } |
|
| 720 | 997 | $data['format_source'] = 'aircraftlistjson'; |
| 721 | 998 | $data['id_source'] = $id_source; |
| 722 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 723 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 999 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1000 | + $data['noarchive'] = true; |
|
| 1001 | + } |
|
| 1002 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1003 | + $data['source_name'] = $value['name']; |
|
| 1004 | + } |
|
| 724 | 1005 | $SI->add($data); |
| 725 | 1006 | unset($data); |
| 726 | 1007 | } |
@@ -756,8 +1037,12 @@ discard block |
||
| 756 | 1037 | $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
| 757 | 1038 | $data['format_source'] = 'planeupdatefaa'; |
| 758 | 1039 | $data['id_source'] = $id_source; |
| 759 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 760 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1040 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1041 | + $data['noarchive'] = true; |
|
| 1042 | + } |
|
| 1043 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1044 | + $data['source_name'] = $value['name']; |
|
| 1045 | + } |
|
| 761 | 1046 | $SI->add($data); |
| 762 | 1047 | unset($data); |
| 763 | 1048 | } |
@@ -786,7 +1071,9 @@ discard block |
||
| 786 | 1071 | $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
| 787 | 1072 | $data['format_source'] = 'opensky'; |
| 788 | 1073 | $data['id_source'] = $id_source; |
| 789 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1074 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1075 | + $data['noarchive'] = true; |
|
| 1076 | + } |
|
| 790 | 1077 | $SI->add($data); |
| 791 | 1078 | unset($data); |
| 792 | 1079 | } |
@@ -798,7 +1085,9 @@ discard block |
||
| 798 | 1085 | //$buffer = $Common->getData($hosts[$id]); |
| 799 | 1086 | $buffer = $Common->getData($value['host']); |
| 800 | 1087 | $all_data = json_decode($buffer,true); |
| 801 | - if (!empty($all_data)) $reset = 0; |
|
| 1088 | + if (!empty($all_data)) { |
|
| 1089 | + $reset = 0; |
|
| 1090 | + } |
|
| 802 | 1091 | foreach ($all_data as $key => $line) { |
| 803 | 1092 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
| 804 | 1093 | $data = array(); |
@@ -819,8 +1108,12 @@ discard block |
||
| 819 | 1108 | $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
| 820 | 1109 | $data['format_source'] = 'fr24json'; |
| 821 | 1110 | $data['id_source'] = $id_source; |
| 822 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 823 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1111 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1112 | + $data['noarchive'] = true; |
|
| 1113 | + } |
|
| 1114 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1115 | + $data['source_name'] = $value['name']; |
|
| 1116 | + } |
|
| 824 | 1117 | $SI->add($data); |
| 825 | 1118 | unset($data); |
| 826 | 1119 | } |
@@ -844,24 +1137,42 @@ discard block |
||
| 844 | 1137 | if (isset($line['inf'])) { |
| 845 | 1138 | $data = array(); |
| 846 | 1139 | $data['hex'] = $line['inf']['ia']; |
| 847 | - if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] |
|
| 1140 | + if (isset($line['inf']['cs'])) { |
|
| 1141 | + $data['ident'] = $line['inf']['cs']; |
|
| 1142 | + } |
|
| 1143 | + //$line[13] |
|
| 848 | 1144 | $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
| 849 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
| 850 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
| 1145 | + if (isset($line['inf']['gs'])) { |
|
| 1146 | + $data['speed'] = round($line['inf']['gs']*0.539957); |
|
| 1147 | + } |
|
| 1148 | + // speed |
|
| 1149 | + if (isset($line['inf']['tr'])) { |
|
| 1150 | + $data['heading'] = $line['inf']['tr']; |
|
| 1151 | + } |
|
| 1152 | + // heading |
|
| 851 | 1153 | $data['latitude'] = $line['pt'][0]; // lat |
| 852 | 1154 | $data['longitude'] = $line['pt'][1]; // long |
| 853 | 1155 | //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
| 854 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
| 1156 | + if (isset($line['inf']['sq'])) { |
|
| 1157 | + $data['squawk'] = $line['inf']['sq']; |
|
| 1158 | + } |
|
| 1159 | + // squawk |
|
| 855 | 1160 | //$data['aircraft_icao'] = $line[8]; |
| 856 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
| 1161 | + if (isset($line['inf']['rc'])) { |
|
| 1162 | + $data['registration'] = $line['inf']['rc']; |
|
| 1163 | + } |
|
| 857 | 1164 | //$data['departure_airport_iata'] = $line[11]; |
| 858 | 1165 | //$data['arrival_airport_iata'] = $line[12]; |
| 859 | 1166 | //$data['emergency'] = ''; // emergency |
| 860 | 1167 | $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
| 861 | 1168 | $data['format_source'] = 'radarvirtueljson'; |
| 862 | 1169 | $data['id_source'] = $id_source; |
| 863 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 864 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1170 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1171 | + $data['noarchive'] = true; |
|
| 1172 | + } |
|
| 1173 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1174 | + $data['source_name'] = $value['name']; |
|
| 1175 | + } |
|
| 865 | 1176 | $SI->add($data); |
| 866 | 1177 | unset($data); |
| 867 | 1178 | } |
@@ -882,30 +1193,65 @@ discard block |
||
| 882 | 1193 | $data['id'] = $line['id']; |
| 883 | 1194 | $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
| 884 | 1195 | $data['ident'] = $line['callsign']; // ident |
| 885 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
| 886 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
| 887 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
| 888 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
| 889 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
| 890 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1196 | + if (isset($line['pilotid'])) { |
|
| 1197 | + $data['pilot_id'] = $line['pilotid']; |
|
| 1198 | + } |
|
| 1199 | + // pilot id |
|
| 1200 | + if (isset($line['name'])) { |
|
| 1201 | + $data['pilot_name'] = $line['name']; |
|
| 1202 | + } |
|
| 1203 | + // pilot name |
|
| 1204 | + if (isset($line['alt'])) { |
|
| 1205 | + $data['altitude'] = $line['alt']; |
|
| 1206 | + } |
|
| 1207 | + // altitude |
|
| 1208 | + if (isset($line['gs'])) { |
|
| 1209 | + $data['speed'] = $line['gs']; |
|
| 1210 | + } |
|
| 1211 | + // speed |
|
| 1212 | + if (isset($line['heading'])) { |
|
| 1213 | + $data['heading'] = $line['heading']; |
|
| 1214 | + } |
|
| 1215 | + // heading |
|
| 1216 | + if (isset($line['route'])) { |
|
| 1217 | + $data['waypoints'] = $line['route']; |
|
| 1218 | + } |
|
| 1219 | + // route |
|
| 891 | 1220 | $data['latitude'] = $line['lat']; // lat |
| 892 | 1221 | $data['longitude'] = $line['lon']; // long |
| 893 | 1222 | //$data['verticalrate'] = $line['vrt']; // verticale rate |
| 894 | 1223 | //$data['squawk'] = $line['squawk']; // squawk |
| 895 | 1224 | //$data['emergency'] = ''; // emergency |
| 896 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
| 897 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
| 898 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
| 1225 | + if (isset($line['depicao'])) { |
|
| 1226 | + $data['departure_airport_icao'] = $line['depicao']; |
|
| 1227 | + } |
|
| 1228 | + if (isset($line['deptime'])) { |
|
| 1229 | + $data['departure_airport_time'] = $line['deptime']; |
|
| 1230 | + } |
|
| 1231 | + if (isset($line['arricao'])) { |
|
| 1232 | + $data['arrival_airport_icao'] = $line['arricao']; |
|
| 1233 | + } |
|
| 899 | 1234 | //$data['arrival_airport_time'] = $line['arrtime']; |
| 900 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
| 901 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
| 902 | - if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
| 903 | - else $data['info'] = ''; |
|
| 1235 | + if (isset($line['aircraft'])) { |
|
| 1236 | + $data['aircraft_icao'] = $line['aircraft']; |
|
| 1237 | + } |
|
| 1238 | + if (isset($line['transponder'])) { |
|
| 1239 | + $data['squawk'] = $line['transponder']; |
|
| 1240 | + } |
|
| 1241 | + if (isset($line['atis'])) { |
|
| 1242 | + $data['info'] = $line['atis']; |
|
| 1243 | + } else { |
|
| 1244 | + $data['info'] = ''; |
|
| 1245 | + } |
|
| 904 | 1246 | $data['format_source'] = 'pireps'; |
| 905 | 1247 | $data['id_source'] = $id_source; |
| 906 | 1248 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 907 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 908 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1249 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1250 | + $data['noarchive'] = true; |
|
| 1251 | + } |
|
| 1252 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1253 | + $data['source_name'] = $value['name']; |
|
| 1254 | + } |
|
| 909 | 1255 | if ($line['icon'] == 'plane') { |
| 910 | 1256 | $SI->add($data); |
| 911 | 1257 | // print_r($data); |
@@ -914,16 +1260,28 @@ discard block |
||
| 914 | 1260 | $data['info'] = str_replace('&sect;','',$data['info']); |
| 915 | 1261 | $typec = substr($data['ident'],-3); |
| 916 | 1262 | $data['type'] = ''; |
| 917 | - if ($typec == 'APP') $data['type'] = 'Approach'; |
|
| 918 | - elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
|
| 919 | - elseif ($typec == 'OBS') $data['type'] = 'Observer'; |
|
| 920 | - elseif ($typec == 'GND') $data['type'] = 'Ground'; |
|
| 921 | - elseif ($typec == 'DEL') $data['type'] = 'Delivery'; |
|
| 922 | - elseif ($typec == 'DEP') $data['type'] = 'Departure'; |
|
| 923 | - elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station'; |
|
| 924 | - elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
|
| 925 | - else $data['type'] = 'Observer'; |
|
| 926 | - 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']); |
|
| 1263 | + if ($typec == 'APP') { |
|
| 1264 | + $data['type'] = 'Approach'; |
|
| 1265 | + } elseif ($typec == 'TWR') { |
|
| 1266 | + $data['type'] = 'Tower'; |
|
| 1267 | + } elseif ($typec == 'OBS') { |
|
| 1268 | + $data['type'] = 'Observer'; |
|
| 1269 | + } elseif ($typec == 'GND') { |
|
| 1270 | + $data['type'] = 'Ground'; |
|
| 1271 | + } elseif ($typec == 'DEL') { |
|
| 1272 | + $data['type'] = 'Delivery'; |
|
| 1273 | + } elseif ($typec == 'DEP') { |
|
| 1274 | + $data['type'] = 'Departure'; |
|
| 1275 | + } elseif ($typec == 'FSS') { |
|
| 1276 | + $data['type'] = 'Flight Service Station'; |
|
| 1277 | + } elseif ($typec == 'CTR') { |
|
| 1278 | + $data['type'] = 'Control Radar or Centre'; |
|
| 1279 | + } else { |
|
| 1280 | + $data['type'] = 'Observer'; |
|
| 1281 | + } |
|
| 1282 | + if (isset($ATC)) { |
|
| 1283 | + 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']); |
|
| 1284 | + } |
|
| 927 | 1285 | } |
| 928 | 1286 | unset($data); |
| 929 | 1287 | } |
@@ -933,7 +1291,9 @@ discard block |
||
| 933 | 1291 | //} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
| 934 | 1292 | } elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
| 935 | 1293 | //$buffer = $Common->getData($hosts[$id]); |
| 936 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 1294 | + if ($globalDebug) { |
|
| 1295 | + echo 'Get Data...'."\n"; |
|
| 1296 | + } |
|
| 937 | 1297 | $buffer = $Common->getData($value['host']); |
| 938 | 1298 | $all_data = json_decode($buffer,true); |
| 939 | 1299 | if ($buffer != '' && is_array($all_data)) { |
@@ -941,10 +1301,16 @@ discard block |
||
| 941 | 1301 | foreach ($all_data as $line) { |
| 942 | 1302 | $data = array(); |
| 943 | 1303 | //$data['id'] = $line['id']; // id not usable |
| 944 | - if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
| 1304 | + if (isset($line['pilotid'])) { |
|
| 1305 | + $data['id'] = $line['pilotid'].$line['flightnum']; |
|
| 1306 | + } |
|
| 945 | 1307 | $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
| 946 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
| 947 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
| 1308 | + if (isset($line['pilotname'])) { |
|
| 1309 | + $data['pilot_name'] = $line['pilotname']; |
|
| 1310 | + } |
|
| 1311 | + if (isset($line['pilotid'])) { |
|
| 1312 | + $data['pilot_id'] = $line['pilotid']; |
|
| 1313 | + } |
|
| 948 | 1314 | $data['ident'] = $line['flightnum']; // ident |
| 949 | 1315 | $data['altitude'] = $line['alt']; // altitude |
| 950 | 1316 | $data['speed'] = $line['gs']; // speed |
@@ -962,28 +1328,44 @@ discard block |
||
| 962 | 1328 | $data['arrival_airport_icao'] = $line['arricao']; |
| 963 | 1329 | $data['arrival_airport_time'] = $line['arrtime']; |
| 964 | 1330 | $data['registration'] = $line['aircraft']; |
| 965 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 966 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1331 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1332 | + $data['noarchive'] = true; |
|
| 1333 | + } |
|
| 1334 | + if (isset($line['route'])) { |
|
| 1335 | + $data['waypoints'] = $line['route']; |
|
| 1336 | + } |
|
| 1337 | + // route |
|
| 967 | 1338 | if (isset($line['aircraftname'])) { |
| 968 | 1339 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
| 969 | 1340 | $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
| 970 | 1341 | $aircraft_data = explode('-',$line['aircraftname']); |
| 971 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
| 972 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 973 | - else { |
|
| 1342 | + if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) { |
|
| 1343 | + $data['aircraft_icao'] = $aircraft_data[0]; |
|
| 1344 | + } elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) { |
|
| 1345 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 1346 | + } else { |
|
| 974 | 1347 | $aircraft_data = explode(' ',$line['aircraftname']); |
| 975 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
| 976 | - else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
| 1348 | + if (isset($aircraft_data[1])) { |
|
| 1349 | + $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
| 1350 | + } else { |
|
| 1351 | + $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
| 1352 | + } |
|
| 977 | 1353 | } |
| 978 | 1354 | } |
| 979 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
| 1355 | + if (isset($line['route'])) { |
|
| 1356 | + $data['waypoints'] = $line['route']; |
|
| 1357 | + } |
|
| 980 | 1358 | $data['id_source'] = $id_source; |
| 981 | 1359 | $data['format_source'] = 'phpvmacars'; |
| 982 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1360 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1361 | + $data['source_name'] = $value['name']; |
|
| 1362 | + } |
|
| 983 | 1363 | $SI->add($data); |
| 984 | 1364 | unset($data); |
| 985 | 1365 | } |
| 986 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
| 1366 | + if ($globalDebug) { |
|
| 1367 | + echo 'No more data...'."\n"; |
|
| 1368 | + } |
|
| 987 | 1369 | unset($buffer); |
| 988 | 1370 | unset($all_data); |
| 989 | 1371 | } |
@@ -991,7 +1373,9 @@ discard block |
||
| 991 | 1373 | $last_exec[$id]['last'] = time(); |
| 992 | 1374 | } elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
| 993 | 1375 | //$buffer = $Common->getData($hosts[$id]); |
| 994 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 1376 | + if ($globalDebug) { |
|
| 1377 | + echo 'Get Data...'."\n"; |
|
| 1378 | + } |
|
| 995 | 1379 | $buffer = $Common->getData($value['host']); |
| 996 | 1380 | $all_data = json_decode($buffer,true); |
| 997 | 1381 | if ($buffer != '' && is_array($all_data)) { |
@@ -1020,16 +1404,25 @@ discard block |
||
| 1020 | 1404 | $data['arrival_airport_icao'] = $line['arrival']; |
| 1021 | 1405 | //$data['arrival_airport_time'] = $line['arrival_time']; |
| 1022 | 1406 | //$data['registration'] = $line['aircraft']; |
| 1023 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1407 | + if (isset($line['route'])) { |
|
| 1408 | + $data['waypoints'] = $line['route']; |
|
| 1409 | + } |
|
| 1410 | + // route |
|
| 1024 | 1411 | $data['aircraft_icao'] = $line['plane_type']; |
| 1025 | 1412 | $data['id_source'] = $id_source; |
| 1026 | 1413 | $data['format_source'] = 'vam'; |
| 1027 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1028 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1414 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
| 1415 | + $data['noarchive'] = true; |
|
| 1416 | + } |
|
| 1417 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1418 | + $data['source_name'] = $value['name']; |
|
| 1419 | + } |
|
| 1029 | 1420 | $SI->add($data); |
| 1030 | 1421 | unset($data); |
| 1031 | 1422 | } |
| 1032 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
| 1423 | + if ($globalDebug) { |
|
| 1424 | + echo 'No more data...'."\n"; |
|
| 1425 | + } |
|
| 1033 | 1426 | unset($buffer); |
| 1034 | 1427 | unset($all_data); |
| 1035 | 1428 | } |
@@ -1037,7 +1430,9 @@ discard block |
||
| 1037 | 1430 | $last_exec[$id]['last'] = time(); |
| 1038 | 1431 | //} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') { |
| 1039 | 1432 | } 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') { |
| 1040 | - if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
| 1433 | + if (function_exists('pcntl_fork')) { |
|
| 1434 | + pcntl_signal_dispatch(); |
|
| 1435 | + } |
|
| 1041 | 1436 | //$last_exec[$id]['last'] = time(); |
| 1042 | 1437 | |
| 1043 | 1438 | //$read = array( $sockets[$id] ); |
@@ -1045,7 +1440,9 @@ discard block |
||
| 1045 | 1440 | $write = NULL; |
| 1046 | 1441 | $e = NULL; |
| 1047 | 1442 | $n = socket_select($read, $write, $e, $timeout); |
| 1048 | - if ($e != NULL) var_dump($e); |
|
| 1443 | + if ($e != NULL) { |
|
| 1444 | + var_dump($e); |
|
| 1445 | + } |
|
| 1049 | 1446 | if ($n > 0) { |
| 1050 | 1447 | $reset = 0; |
| 1051 | 1448 | foreach ($read as $nb => $r) { |
@@ -1066,12 +1463,16 @@ discard block |
||
| 1066 | 1463 | //$SI::del(); |
| 1067 | 1464 | if ($format == 'vrstcp') { |
| 1068 | 1465 | $buffer = explode('},{',$buffer); |
| 1069 | - } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
| 1466 | + } else { |
|
| 1467 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
| 1468 | + } |
|
| 1070 | 1469 | // SBS format is CSV format |
| 1071 | 1470 | if ($buffer !== FALSE && $buffer != '') { |
| 1072 | 1471 | $tt[$format] = 0; |
| 1073 | 1472 | if ($format == 'acarssbs3') { |
| 1074 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 1473 | + if ($globalDebug) { |
|
| 1474 | + echo 'ACARS : '.$buffer."\n"; |
|
| 1475 | + } |
|
| 1075 | 1476 | $ACARS->add(trim($buffer)); |
| 1076 | 1477 | $ACARS->deleteLiveAcarsData(); |
| 1077 | 1478 | } elseif ($format == 'raw') { |
@@ -1080,28 +1481,64 @@ discard block |
||
| 1080 | 1481 | if (is_array($data)) { |
| 1081 | 1482 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1082 | 1483 | $data['format_source'] = 'raw'; |
| 1083 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1084 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1085 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1086 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 1484 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
| 1485 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1486 | + } |
|
| 1487 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
| 1488 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1489 | + } |
|
| 1490 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 1491 | + $data['noarchive'] = true; |
|
| 1492 | + } |
|
| 1493 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 1494 | + $SI->add($data); |
|
| 1495 | + } |
|
| 1087 | 1496 | } |
| 1088 | 1497 | } elseif ($format == 'ais') { |
| 1089 | 1498 | $ais_data = $AIS->parse_line(trim($buffer)); |
| 1090 | 1499 | $data = array(); |
| 1091 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
| 1092 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
| 1093 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
| 1094 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
| 1095 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
| 1096 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
| 1097 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
| 1098 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
| 1099 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
| 1100 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
| 1101 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
| 1102 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
| 1103 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 1104 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1500 | + if (isset($ais_data['ident'])) { |
|
| 1501 | + $data['ident'] = $ais_data['ident']; |
|
| 1502 | + } |
|
| 1503 | + if (isset($ais_data['mmsi'])) { |
|
| 1504 | + $data['mmsi'] = $ais_data['mmsi']; |
|
| 1505 | + } |
|
| 1506 | + if (isset($ais_data['speed'])) { |
|
| 1507 | + $data['speed'] = $ais_data['speed']; |
|
| 1508 | + } |
|
| 1509 | + if (isset($ais_data['heading'])) { |
|
| 1510 | + $data['heading'] = $ais_data['heading']; |
|
| 1511 | + } |
|
| 1512 | + if (isset($ais_data['latitude'])) { |
|
| 1513 | + $data['latitude'] = $ais_data['latitude']; |
|
| 1514 | + } |
|
| 1515 | + if (isset($ais_data['longitude'])) { |
|
| 1516 | + $data['longitude'] = $ais_data['longitude']; |
|
| 1517 | + } |
|
| 1518 | + if (isset($ais_data['status'])) { |
|
| 1519 | + $data['status'] = $ais_data['status']; |
|
| 1520 | + } |
|
| 1521 | + if (isset($ais_data['statusid'])) { |
|
| 1522 | + $data['status_id'] = $ais_data['statusid']; |
|
| 1523 | + } |
|
| 1524 | + if (isset($ais_data['type'])) { |
|
| 1525 | + $data['type'] = $ais_data['type']; |
|
| 1526 | + } |
|
| 1527 | + if (isset($ais_data['imo'])) { |
|
| 1528 | + $data['imo'] = $ais_data['imo']; |
|
| 1529 | + } |
|
| 1530 | + if (isset($ais_data['callsign'])) { |
|
| 1531 | + $data['callsign'] = $ais_data['callsign']; |
|
| 1532 | + } |
|
| 1533 | + if (isset($ais_data['destination'])) { |
|
| 1534 | + $data['arrival_code'] = $ais_data['destination']; |
|
| 1535 | + } |
|
| 1536 | + if (isset($ais_data['eta_ts'])) { |
|
| 1537 | + $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 1538 | + } |
|
| 1539 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 1540 | + $data['noarchive'] = true; |
|
| 1541 | + } |
|
| 1105 | 1542 | |
| 1106 | 1543 | if (isset($ais_data['timestamp'])) { |
| 1107 | 1544 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
@@ -1110,7 +1547,9 @@ discard block |
||
| 1110 | 1547 | } |
| 1111 | 1548 | $data['format_source'] = 'aisnmea'; |
| 1112 | 1549 | $data['id_source'] = $id_source; |
| 1113 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
| 1550 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') { |
|
| 1551 | + $MI->add($data); |
|
| 1552 | + } |
|
| 1114 | 1553 | unset($data); |
| 1115 | 1554 | } elseif ($format == 'flightgearsp') { |
| 1116 | 1555 | //echo $buffer."\n"; |
@@ -1128,12 +1567,18 @@ discard block |
||
| 1128 | 1567 | $data['speed'] = round($line[5]*1.94384); |
| 1129 | 1568 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1130 | 1569 | $data['format_source'] = 'flightgearsp'; |
| 1131 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1132 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 1570 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 1571 | + $data['noarchive'] = true; |
|
| 1572 | + } |
|
| 1573 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 1574 | + $SI->add($data); |
|
| 1575 | + } |
|
| 1133 | 1576 | $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
| 1134 | 1577 | } |
| 1135 | 1578 | } elseif ($format == 'acars') { |
| 1136 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 1579 | + if ($globalDebug) { |
|
| 1580 | + echo 'ACARS : '.$buffer."\n"; |
|
| 1581 | + } |
|
| 1137 | 1582 | $ACARS->add(trim($buffer)); |
| 1138 | 1583 | socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
| 1139 | 1584 | $ACARS->deleteLiveAcarsData(); |
@@ -1154,8 +1599,12 @@ discard block |
||
| 1154 | 1599 | $aircraft_type = $line[10]; |
| 1155 | 1600 | $aircraft_type = preg_split(':/:',$aircraft_type); |
| 1156 | 1601 | $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
| 1157 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1158 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 1602 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 1603 | + $data['noarchive'] = true; |
|
| 1604 | + } |
|
| 1605 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 1606 | + $SI->add($data); |
|
| 1607 | + } |
|
| 1159 | 1608 | } |
| 1160 | 1609 | } |
| 1161 | 1610 | } elseif ($format == 'beast') { |
@@ -1165,28 +1614,62 @@ discard block |
||
| 1165 | 1614 | foreach($buffer as $all_data) { |
| 1166 | 1615 | $line = json_decode('{'.$all_data.'}',true); |
| 1167 | 1616 | $data = array(); |
| 1168 | - if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
|
| 1169 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
| 1170 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
| 1171 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
| 1172 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
| 1173 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
| 1174 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
| 1617 | + if (isset($line['Icao'])) { |
|
| 1618 | + $data['hex'] = $line['Icao']; |
|
| 1619 | + } |
|
| 1620 | + // hex |
|
| 1621 | + if (isset($line['Call'])) { |
|
| 1622 | + $data['ident'] = $line['Call']; |
|
| 1623 | + } |
|
| 1624 | + // ident |
|
| 1625 | + if (isset($line['Alt'])) { |
|
| 1626 | + $data['altitude'] = $line['Alt']; |
|
| 1627 | + } |
|
| 1628 | + // altitude |
|
| 1629 | + if (isset($line['Spd'])) { |
|
| 1630 | + $data['speed'] = $line['Spd']; |
|
| 1631 | + } |
|
| 1632 | + // speed |
|
| 1633 | + if (isset($line['Trak'])) { |
|
| 1634 | + $data['heading'] = $line['Trak']; |
|
| 1635 | + } |
|
| 1636 | + // heading |
|
| 1637 | + if (isset($line['Lat'])) { |
|
| 1638 | + $data['latitude'] = $line['Lat']; |
|
| 1639 | + } |
|
| 1640 | + // lat |
|
| 1641 | + if (isset($line['Long'])) { |
|
| 1642 | + $data['longitude'] = $line['Long']; |
|
| 1643 | + } |
|
| 1644 | + // long |
|
| 1175 | 1645 | //$data['verticalrate'] = $line['']; // verticale rate |
| 1176 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
| 1646 | + if (isset($line['Sqk'])) { |
|
| 1647 | + $data['squawk'] = $line['Sqk']; |
|
| 1648 | + } |
|
| 1649 | + // squawk |
|
| 1177 | 1650 | $data['emergency'] = ''; // emergency |
| 1178 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
| 1651 | + if (isset($line['Reg'])) { |
|
| 1652 | + $data['registration'] = $line['Reg']; |
|
| 1653 | + } |
|
| 1179 | 1654 | /* |
| 1180 | 1655 | if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000); |
| 1181 | 1656 | else $data['datetime'] = date('Y-m-d H:i:s'); |
| 1182 | 1657 | */ |
| 1183 | 1658 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1184 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
| 1659 | + if (isset($line['Type'])) { |
|
| 1660 | + $data['aircraft_icao'] = $line['Type']; |
|
| 1661 | + } |
|
| 1185 | 1662 | $data['format_source'] = 'vrstcp'; |
| 1186 | 1663 | $data['id_source'] = $id_source; |
| 1187 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1188 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1189 | - if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
|
| 1664 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 1665 | + $data['noarchive'] = true; |
|
| 1666 | + } |
|
| 1667 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1668 | + $data['source_name'] = $value['name']; |
|
| 1669 | + } |
|
| 1670 | + if (isset($data['latitude']) && isset($data['hex'])) { |
|
| 1671 | + $SI->add($data); |
|
| 1672 | + } |
|
| 1190 | 1673 | unset($data); |
| 1191 | 1674 | } |
| 1192 | 1675 | } elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') { |
@@ -1199,22 +1682,46 @@ discard block |
||
| 1199 | 1682 | $data['hex'] = $lined['hexid']; |
| 1200 | 1683 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
| 1201 | 1684 | $data['datetime'] = date('Y-m-d H:i:s');; |
| 1202 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
| 1203 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
| 1204 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
| 1205 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
| 1206 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
| 1207 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
| 1208 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
| 1685 | + if (isset($lined['ident'])) { |
|
| 1686 | + $data['ident'] = $lined['ident']; |
|
| 1687 | + } |
|
| 1688 | + if (isset($lined['lat'])) { |
|
| 1689 | + $data['latitude'] = $lined['lat']; |
|
| 1690 | + } |
|
| 1691 | + if (isset($lined['lon'])) { |
|
| 1692 | + $data['longitude'] = $lined['lon']; |
|
| 1693 | + } |
|
| 1694 | + if (isset($lined['speed'])) { |
|
| 1695 | + $data['speed'] = $lined['speed']; |
|
| 1696 | + } |
|
| 1697 | + if (isset($lined['squawk'])) { |
|
| 1698 | + $data['squawk'] = $lined['squawk']; |
|
| 1699 | + } |
|
| 1700 | + if (isset($lined['alt'])) { |
|
| 1701 | + $data['altitude'] = $lined['alt']; |
|
| 1702 | + } |
|
| 1703 | + if (isset($lined['heading'])) { |
|
| 1704 | + $data['heading'] = $lined['heading']; |
|
| 1705 | + } |
|
| 1209 | 1706 | $data['id_source'] = $id_source; |
| 1210 | 1707 | $data['format_source'] = 'tsv'; |
| 1211 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1212 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1213 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1214 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 1708 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
| 1709 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1710 | + } |
|
| 1711 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
| 1712 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1713 | + } |
|
| 1714 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 1715 | + $data['noarchive'] = true; |
|
| 1716 | + } |
|
| 1717 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 1718 | + $SI->add($data); |
|
| 1719 | + } |
|
| 1215 | 1720 | unset($lined); |
| 1216 | 1721 | unset($data); |
| 1217 | - } else $error = true; |
|
| 1722 | + } else { |
|
| 1723 | + $error = true; |
|
| 1724 | + } |
|
| 1218 | 1725 | } elseif ($format == 'aprs' && $use_aprs) { |
| 1219 | 1726 | if ($aprs_connect == 0) { |
| 1220 | 1727 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
@@ -1239,34 +1746,72 @@ discard block |
||
| 1239 | 1746 | $aprs_last_tx = time(); |
| 1240 | 1747 | $data = array(); |
| 1241 | 1748 | //print_r($line); |
| 1242 | - if (isset($line['address'])) $data['hex'] = $line['address']; |
|
| 1243 | - if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
| 1244 | - if (isset($line['type_id'])) $data['type_id'] = $line['typeid']; |
|
| 1245 | - if (isset($line['status_id'])) $data['status_id'] = $line['statusid']; |
|
| 1246 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
| 1247 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1749 | + if (isset($line['address'])) { |
|
| 1750 | + $data['hex'] = $line['address']; |
|
| 1751 | + } |
|
| 1752 | + if (isset($line['mmsi'])) { |
|
| 1753 | + $data['mmsi'] = $line['mmsi']; |
|
| 1754 | + } |
|
| 1755 | + if (isset($line['type_id'])) { |
|
| 1756 | + $data['type_id'] = $line['typeid']; |
|
| 1757 | + } |
|
| 1758 | + if (isset($line['status_id'])) { |
|
| 1759 | + $data['status_id'] = $line['statusid']; |
|
| 1760 | + } |
|
| 1761 | + if (isset($line['timestamp'])) { |
|
| 1762 | + $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
| 1763 | + } else { |
|
| 1764 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1765 | + } |
|
| 1248 | 1766 | //$data['datetime'] = date('Y-m-d H:i:s'); |
| 1249 | - if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
| 1767 | + if (isset($line['ident'])) { |
|
| 1768 | + $data['ident'] = $line['ident']; |
|
| 1769 | + } |
|
| 1250 | 1770 | $data['latitude'] = $line['latitude']; |
| 1251 | 1771 | $data['longitude'] = $line['longitude']; |
| 1252 | 1772 | //$data['verticalrate'] = $line[16]; |
| 1253 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
| 1254 | - else $data['speed'] = 0; |
|
| 1255 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
| 1256 | - if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
| 1257 | - if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
| 1258 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
| 1773 | + if (isset($line['speed'])) { |
|
| 1774 | + $data['speed'] = $line['speed']; |
|
| 1775 | + } else { |
|
| 1776 | + $data['speed'] = 0; |
|
| 1777 | + } |
|
| 1778 | + if (isset($line['altitude'])) { |
|
| 1779 | + $data['altitude'] = $line['altitude']; |
|
| 1780 | + } |
|
| 1781 | + if (isset($line['comment'])) { |
|
| 1782 | + $data['comment'] = $line['comment']; |
|
| 1783 | + } |
|
| 1784 | + if (isset($line['symbol'])) { |
|
| 1785 | + $data['type'] = $line['symbol']; |
|
| 1786 | + } |
|
| 1787 | + if (isset($line['heading'])) { |
|
| 1788 | + $data['heading'] = $line['heading']; |
|
| 1789 | + } |
|
| 1259 | 1790 | //else $data['heading'] = 0; |
| 1260 | - if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
| 1261 | - if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
|
| 1262 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1791 | + if (isset($line['stealth'])) { |
|
| 1792 | + $data['aircraft_type'] = $line['stealth']; |
|
| 1793 | + } |
|
| 1794 | + if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) { |
|
| 1795 | + $data['noarchive'] = true; |
|
| 1796 | + } |
|
| 1797 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 1798 | + $data['noarchive'] = true; |
|
| 1799 | + } |
|
| 1263 | 1800 | $data['id_source'] = $id_source; |
| 1264 | - if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
| 1265 | - else $data['format_source'] = 'aprs'; |
|
| 1801 | + if (isset($line['format_source'])) { |
|
| 1802 | + $data['format_source'] = $line['format_source']; |
|
| 1803 | + } else { |
|
| 1804 | + $data['format_source'] = 'aprs'; |
|
| 1805 | + } |
|
| 1266 | 1806 | $data['source_name'] = $line['source']; |
| 1267 | - if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
| 1268 | - else $data['source_type'] = 'flarm'; |
|
| 1269 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1807 | + if (isset($line['source_type'])) { |
|
| 1808 | + $data['source_type'] = $line['source_type']; |
|
| 1809 | + } else { |
|
| 1810 | + $data['source_type'] = 'flarm'; |
|
| 1811 | + } |
|
| 1812 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
| 1813 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1814 | + } |
|
| 1270 | 1815 | $currentdate = date('Y-m-d H:i:s'); |
| 1271 | 1816 | $aprsdate = strtotime($data['datetime']); |
| 1272 | 1817 | // Accept data if time <= system time + 20s |
@@ -1277,19 +1822,22 @@ discard block |
||
| 1277 | 1822 | echo 'add...'."\n"; |
| 1278 | 1823 | $send = $MI->add($data); |
| 1279 | 1824 | } elseif (isset($line['stealth'])) { |
| 1280 | - if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
|
| 1281 | - else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
|
| 1825 | + if ($line['stealth'] != 0) { |
|
| 1826 | + echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
|
| 1827 | + } else { |
|
| 1828 | + echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
|
| 1829 | + } |
|
| 1282 | 1830 | //} 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')) { |
| 1283 | 1831 | } 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') { |
| 1284 | 1832 | //echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n"; |
| 1285 | - if (isset($globalTracker) && $globalTracker) $send = $TI->add($data); |
|
| 1833 | + if (isset($globalTracker) && $globalTracker) { |
|
| 1834 | + $send = $TI->add($data); |
|
| 1835 | + } |
|
| 1286 | 1836 | } |
| 1287 | 1837 | unset($data); |
| 1288 | - } |
|
| 1289 | - elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') { |
|
| 1838 | + } elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') { |
|
| 1290 | 1839 | echo '!! Weather Station not yet supported'."\n"; |
| 1291 | - } |
|
| 1292 | - 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')) { |
|
| 1840 | + } 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')) { |
|
| 1293 | 1841 | echo '!! Car & Trucks not yet supported'."\n"; |
| 1294 | 1842 | } |
| 1295 | 1843 | //elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n"; |
@@ -1322,26 +1870,45 @@ discard block |
||
| 1322 | 1870 | $data['ground'] = $line[21]; |
| 1323 | 1871 | $data['emergency'] = $line[19]; |
| 1324 | 1872 | $data['format_source'] = 'sbs'; |
| 1325 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1326 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1327 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
| 1873 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
| 1874 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1875 | + } |
|
| 1876 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
| 1877 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1878 | + } |
|
| 1879 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
| 1880 | + $data['noarchive'] = true; |
|
| 1881 | + } |
|
| 1328 | 1882 | $data['id_source'] = $id_source; |
| 1329 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
| 1330 | - else $error = true; |
|
| 1883 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 1884 | + $send = $SI->add($data); |
|
| 1885 | + } else { |
|
| 1886 | + $error = true; |
|
| 1887 | + } |
|
| 1331 | 1888 | unset($data); |
| 1332 | - } else $error = true; |
|
| 1889 | + } else { |
|
| 1890 | + $error = true; |
|
| 1891 | + } |
|
| 1333 | 1892 | if ($error) { |
| 1334 | 1893 | if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { |
| 1335 | - if ($globalDebug) echo "Not a message. Ignoring... \n"; |
|
| 1894 | + if ($globalDebug) { |
|
| 1895 | + echo "Not a message. Ignoring... \n"; |
|
| 1896 | + } |
|
| 1336 | 1897 | } else { |
| 1337 | - if ($globalDebug) echo "Wrong line format. Ignoring... \n"; |
|
| 1898 | + if ($globalDebug) { |
|
| 1899 | + echo "Wrong line format. Ignoring... \n"; |
|
| 1900 | + } |
|
| 1338 | 1901 | if ($globalDebug) { |
| 1339 | 1902 | echo $buffer; |
| 1340 | 1903 | //print_r($line); |
| 1341 | 1904 | } |
| 1342 | 1905 | //socket_close($r); |
| 1343 | - if ($globalDebug) echo "Reconnect after an error...\n"; |
|
| 1344 | - if ($format == 'aprs') $aprs_connect = 0; |
|
| 1906 | + if ($globalDebug) { |
|
| 1907 | + echo "Reconnect after an error...\n"; |
|
| 1908 | + } |
|
| 1909 | + if ($format == 'aprs') { |
|
| 1910 | + $aprs_connect = 0; |
|
| 1911 | + } |
|
| 1345 | 1912 | $sourceer[$nb] = $globalSources[$nb]; |
| 1346 | 1913 | connect_all($sourceer); |
| 1347 | 1914 | $sourceer = array(); |
@@ -1349,10 +1916,14 @@ discard block |
||
| 1349 | 1916 | } |
| 1350 | 1917 | } |
| 1351 | 1918 | // Sleep for xxx microseconds |
| 1352 | - if (isset($globalSBSSleep)) usleep($globalSBSSleep); |
|
| 1919 | + if (isset($globalSBSSleep)) { |
|
| 1920 | + usleep($globalSBSSleep); |
|
| 1921 | + } |
|
| 1353 | 1922 | } else { |
| 1354 | 1923 | if ($format == 'flightgearmp') { |
| 1355 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
| 1924 | + if ($globalDebug) { |
|
| 1925 | + echo "Reconnect FlightGear MP..."; |
|
| 1926 | + } |
|
| 1356 | 1927 | //@socket_close($r); |
| 1357 | 1928 | sleep($globalMinFetch); |
| 1358 | 1929 | $sourcefg[$nb] = $globalSources[$nb]; |
@@ -1361,10 +1932,15 @@ discard block |
||
| 1361 | 1932 | break; |
| 1362 | 1933 | |
| 1363 | 1934 | } elseif ($format != 'acars' && $format != 'flightgearsp') { |
| 1364 | - if (isset($tt[$format])) $tt[$format]++; |
|
| 1365 | - else $tt[$format] = 0; |
|
| 1935 | + if (isset($tt[$format])) { |
|
| 1936 | + $tt[$format]++; |
|
| 1937 | + } else { |
|
| 1938 | + $tt[$format] = 0; |
|
| 1939 | + } |
|
| 1366 | 1940 | if ($tt[$format] > 30) { |
| 1367 | - if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; |
|
| 1941 | + if ($globalDebug) { |
|
| 1942 | + echo "ERROR : Reconnect ".$format."..."; |
|
| 1943 | + } |
|
| 1368 | 1944 | //@socket_close($r); |
| 1369 | 1945 | sleep(2); |
| 1370 | 1946 | $aprs_connect = 0; |
@@ -1381,11 +1957,17 @@ discard block |
||
| 1381 | 1957 | } else { |
| 1382 | 1958 | $error = socket_strerror(socket_last_error()); |
| 1383 | 1959 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
| 1384 | - if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
|
| 1385 | - if (isset($globalDebug)) echo "Restarting...\n"; |
|
| 1960 | + if ($globalDebug) { |
|
| 1961 | + echo "ERROR : socket_select give this error ".$error . "\n"; |
|
| 1962 | + } |
|
| 1963 | + if (isset($globalDebug)) { |
|
| 1964 | + echo "Restarting...\n"; |
|
| 1965 | + } |
|
| 1386 | 1966 | // Restart the script if possible |
| 1387 | 1967 | if (is_array($sockets)) { |
| 1388 | - if ($globalDebug) echo "Shutdown all sockets..."; |
|
| 1968 | + if ($globalDebug) { |
|
| 1969 | + echo "Shutdown all sockets..."; |
|
| 1970 | + } |
|
| 1389 | 1971 | |
| 1390 | 1972 | foreach ($sockets as $sock) { |
| 1391 | 1973 | @socket_shutdown($sock,2); |
@@ -1393,22 +1975,36 @@ discard block |
||
| 1393 | 1975 | } |
| 1394 | 1976 | |
| 1395 | 1977 | } |
| 1396 | - if ($globalDebug) echo "Waiting..."; |
|
| 1978 | + if ($globalDebug) { |
|
| 1979 | + echo "Waiting..."; |
|
| 1980 | + } |
|
| 1397 | 1981 | sleep(2); |
| 1398 | 1982 | $time = time(); |
| 1399 | 1983 | //connect_all($hosts); |
| 1400 | 1984 | $aprs_connect = 0; |
| 1401 | - if ($reset%5 == 0) sleep(20); |
|
| 1402 | - if ($reset%10 == 0) sleep(100); |
|
| 1403 | - if ($reset%20 == 0) sleep(200); |
|
| 1404 | - if ($reset > 100) exit('Too many attempts...'); |
|
| 1405 | - if ($globalDebug) echo "Restart all connections..."; |
|
| 1985 | + if ($reset%5 == 0) { |
|
| 1986 | + sleep(20); |
|
| 1987 | + } |
|
| 1988 | + if ($reset%10 == 0) { |
|
| 1989 | + sleep(100); |
|
| 1990 | + } |
|
| 1991 | + if ($reset%20 == 0) { |
|
| 1992 | + sleep(200); |
|
| 1993 | + } |
|
| 1994 | + if ($reset > 100) { |
|
| 1995 | + exit('Too many attempts...'); |
|
| 1996 | + } |
|
| 1997 | + if ($globalDebug) { |
|
| 1998 | + echo "Restart all connections..."; |
|
| 1999 | + } |
|
| 1406 | 2000 | connect_all($globalSources); |
| 1407 | 2001 | } |
| 1408 | 2002 | } |
| 1409 | 2003 | } |
| 1410 | 2004 | if ($globalDaemon === false) { |
| 1411 | - if ($globalDebug) echo 'Check all...'."\n"; |
|
| 2005 | + if ($globalDebug) { |
|
| 2006 | + echo 'Check all...'."\n"; |
|
| 2007 | + } |
|
| 1412 | 2008 | $SI->checkAll(); |
| 1413 | 2009 | } |
| 1414 | 2010 | } |
@@ -14,11 +14,11 @@ discard block |
||
| 14 | 14 | try { |
| 15 | 15 | $sth = $Connection->db->prepare($query); |
| 16 | 16 | $sth->execute(); |
| 17 | - } catch(PDOException $e) { |
|
| 17 | + } catch (PDOException $e) { |
|
| 18 | 18 | return "error : ".$e->getMessage()."\n"; |
| 19 | 19 | } |
| 20 | 20 | while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
| 21 | - $Schedule->addSchedule($row['ident'],$row['departure_airport_icao'],$row['departure_airport_time'],$row['arrival_airport_icao'],$row['arrival_airport_time']); |
|
| 21 | + $Schedule->addSchedule($row['ident'], $row['departure_airport_icao'], $row['departure_airport_time'], $row['arrival_airport_icao'], $row['arrival_airport_time']); |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | } |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | try { |
| 51 | 51 | $sth = $Connection->db->prepare($query); |
| 52 | 52 | $sth->execute(); |
| 53 | - } catch(PDOException $e) { |
|
| 53 | + } catch (PDOException $e) { |
|
| 54 | 54 | return "error (add new columns to routes table) : ".$e->getMessage()."\n"; |
| 55 | 55 | } |
| 56 | 56 | // Copy schedules data to routes table |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | try { |
| 61 | 61 | $sth = $Connection->db->prepare($query); |
| 62 | 62 | $sth->execute(); |
| 63 | - } catch(PDOException $e) { |
|
| 63 | + } catch (PDOException $e) { |
|
| 64 | 64 | return "error (delete schedule table) : ".$e->getMessage()."\n"; |
| 65 | 65 | } |
| 66 | 66 | // Add source column |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | try { |
| 69 | 69 | $sth = $Connection->db->prepare($query); |
| 70 | 70 | $sth->execute(); |
| 71 | - } catch(PDOException $e) { |
|
| 71 | + } catch (PDOException $e) { |
|
| 72 | 72 | return "error (add source column to aircraft_modes) : ".$e->getMessage()."\n"; |
| 73 | 73 | } |
| 74 | 74 | // Delete unused column |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | try { |
| 77 | 77 | $sth = $Connection->db->prepare($query); |
| 78 | 78 | $sth->execute(); |
| 79 | - } catch(PDOException $e) { |
|
| 79 | + } catch (PDOException $e) { |
|
| 80 | 80 | return "error (Delete unused column of aircraft_modes) : ".$e->getMessage()."\n"; |
| 81 | 81 | } |
| 82 | 82 | // Add ModeS column |
@@ -84,14 +84,14 @@ discard block |
||
| 84 | 84 | try { |
| 85 | 85 | $sth = $Connection->db->prepare($query); |
| 86 | 86 | $sth->execute(); |
| 87 | - } catch(PDOException $e) { |
|
| 87 | + } catch (PDOException $e) { |
|
| 88 | 88 | return "error (Add ModeS column in spotter_output) : ".$e->getMessage()."\n"; |
| 89 | 89 | } |
| 90 | 90 | $query = "ALTER TABLE `spotter_live` ADD `ModeS` VARCHAR(255)"; |
| 91 | 91 | try { |
| 92 | 92 | $sth = $Connection->db->prepare($query); |
| 93 | 93 | $sth->execute(); |
| 94 | - } catch(PDOException $e) { |
|
| 94 | + } catch (PDOException $e) { |
|
| 95 | 95 | return "error (Add ModeS column in spotter_live) : ".$e->getMessage()."\n"; |
| 96 | 96 | } |
| 97 | 97 | // Add auto_increment for aircraft_modes |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | try { |
| 100 | 100 | $sth = $Connection->db->prepare($query); |
| 101 | 101 | $sth->execute(); |
| 102 | - } catch(PDOException $e) { |
|
| 102 | + } catch (PDOException $e) { |
|
| 103 | 103 | return "error (Add Auto increment in aircraft_modes) : ".$e->getMessage()."\n"; |
| 104 | 104 | } |
| 105 | 105 | $error = ''; |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | try { |
| 111 | 111 | $sth = $Connection->db->prepare($query); |
| 112 | 112 | $sth->execute(); |
| 113 | - } catch(PDOException $e) { |
|
| 113 | + } catch (PDOException $e) { |
|
| 114 | 114 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
| 115 | 115 | } |
| 116 | 116 | return $error; |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | try { |
| 124 | 124 | $sth = $Connection->db->prepare($query); |
| 125 | 125 | $sth->execute(); |
| 126 | - } catch(PDOException $e) { |
|
| 126 | + } catch (PDOException $e) { |
|
| 127 | 127 | return "error (add new columns to routes table) : ".$e->getMessage()."\n"; |
| 128 | 128 | } |
| 129 | 129 | $error = ''; |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | try { |
| 135 | 135 | $sth = $Connection->db->prepare($query); |
| 136 | 136 | $sth->execute(); |
| 137 | - } catch(PDOException $e) { |
|
| 137 | + } catch (PDOException $e) { |
|
| 138 | 138 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
| 139 | 139 | } |
| 140 | 140 | return $error; |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | try { |
| 148 | 148 | $sth = $Connection->db->prepare($query); |
| 149 | 149 | $sth->execute(); |
| 150 | - } catch(PDOException $e) { |
|
| 150 | + } catch (PDOException $e) { |
|
| 151 | 151 | return "error (add new columns to aircraft_modes) : ".$e->getMessage()."\n"; |
| 152 | 152 | } |
| 153 | 153 | // Add image_source_website column to spotter_image |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | try { |
| 156 | 156 | $sth = $Connection->db->prepare($query); |
| 157 | 157 | $sth->execute(); |
| 158 | - } catch(PDOException $e) { |
|
| 158 | + } catch (PDOException $e) { |
|
| 159 | 159 | return "error (add new columns to spotter_image) : ".$e->getMessage()."\n"; |
| 160 | 160 | } |
| 161 | 161 | $error = ''; |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | try { |
| 165 | 165 | $sth = $Connection->db->prepare($query); |
| 166 | 166 | $sth->execute(); |
| 167 | - } catch(PDOException $e) { |
|
| 167 | + } catch (PDOException $e) { |
|
| 168 | 168 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
| 169 | 169 | } |
| 170 | 170 | return $error; |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | try { |
| 183 | 183 | $sth = $Connection->db->prepare($query); |
| 184 | 184 | $sth->execute(); |
| 185 | - } catch(PDOException $e) { |
|
| 185 | + } catch (PDOException $e) { |
|
| 186 | 186 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
| 187 | 187 | } |
| 188 | 188 | } |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | try { |
| 197 | 197 | $sth = $Connection->db->prepare($query); |
| 198 | 198 | $sth->execute(); |
| 199 | - } catch(PDOException $e) { |
|
| 199 | + } catch (PDOException $e) { |
|
| 200 | 200 | return "error (add new columns to translation) : ".$e->getMessage()."\n"; |
| 201 | 201 | } |
| 202 | 202 | // Add aircraft_shadow column to aircraft |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | try { |
| 205 | 205 | $sth = $Connection->db->prepare($query); |
| 206 | 206 | $sth->execute(); |
| 207 | - } catch(PDOException $e) { |
|
| 207 | + } catch (PDOException $e) { |
|
| 208 | 208 | return "error (add new column to aircraft) : ".$e->getMessage()."\n"; |
| 209 | 209 | } |
| 210 | 210 | // Add aircraft_shadow column to spotter_live |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | try { |
| 213 | 213 | $sth = $Connection->db->prepare($query); |
| 214 | 214 | $sth->execute(); |
| 215 | - } catch(PDOException $e) { |
|
| 215 | + } catch (PDOException $e) { |
|
| 216 | 216 | return "error (add new column to spotter_live) : ".$e->getMessage()."\n"; |
| 217 | 217 | } |
| 218 | 218 | $error = ''; |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | try { |
| 226 | 226 | $sth = $Connection->db->prepare($query); |
| 227 | 227 | $sth->execute(); |
| 228 | - } catch(PDOException $e) { |
|
| 228 | + } catch (PDOException $e) { |
|
| 229 | 229 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
| 230 | 230 | } |
| 231 | 231 | return $error; |
@@ -233,7 +233,7 @@ discard block |
||
| 233 | 233 | |
| 234 | 234 | private static function update_from_6() { |
| 235 | 235 | $Connection = new Connection(); |
| 236 | - if (!$Connection->indexExists('spotter_output','flightaware_id')) { |
|
| 236 | + if (!$Connection->indexExists('spotter_output', 'flightaware_id')) { |
|
| 237 | 237 | $query = "ALTER TABLE spotter_output ADD INDEX(flightaware_id); |
| 238 | 238 | ALTER TABLE spotter_output ADD INDEX(date); |
| 239 | 239 | ALTER TABLE spotter_output ADD INDEX(ident); |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | try { |
| 251 | 251 | $sth = $Connection->db->prepare($query); |
| 252 | 252 | $sth->execute(); |
| 253 | - } catch(PDOException $e) { |
|
| 253 | + } catch (PDOException $e) { |
|
| 254 | 254 | return "error (add some indexes) : ".$e->getMessage()."\n"; |
| 255 | 255 | } |
| 256 | 256 | } |
@@ -265,7 +265,7 @@ discard block |
||
| 265 | 265 | try { |
| 266 | 266 | $sth = $Connection->db->prepare($query); |
| 267 | 267 | $sth->execute(); |
| 268 | - } catch(PDOException $e) { |
|
| 268 | + } catch (PDOException $e) { |
|
| 269 | 269 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
| 270 | 270 | } |
| 271 | 271 | return $error; |
@@ -274,12 +274,12 @@ discard block |
||
| 274 | 274 | private static function update_from_7() { |
| 275 | 275 | global $globalDBname, $globalDBdriver; |
| 276 | 276 | $Connection = new Connection(); |
| 277 | - $query="ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL; |
|
| 277 | + $query = "ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL; |
|
| 278 | 278 | ALTER TABLE spotter_output ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;"; |
| 279 | 279 | try { |
| 280 | 280 | $sth = $Connection->db->prepare($query); |
| 281 | 281 | $sth->execute(); |
| 282 | - } catch(PDOException $e) { |
|
| 282 | + } catch (PDOException $e) { |
|
| 283 | 283 | return "error (add pilot column to spotter_live and spotter_output) : ".$e->getMessage()."\n"; |
| 284 | 284 | } |
| 285 | 285 | if ($globalDBdriver == 'mysql') { |
@@ -287,7 +287,7 @@ discard block |
||
| 287 | 287 | try { |
| 288 | 288 | $sth = $Connection->db->prepare($query); |
| 289 | 289 | $sth->execute(); |
| 290 | - } catch(PDOException $e) { |
|
| 290 | + } catch (PDOException $e) { |
|
| 291 | 291 | return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n"; |
| 292 | 292 | } |
| 293 | 293 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -299,15 +299,15 @@ discard block |
||
| 299 | 299 | DROP TABLE spotter_archive; |
| 300 | 300 | RENAME TABLE copy TO spotter_archive;"; |
| 301 | 301 | } else { |
| 302 | - $query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL"; |
|
| 302 | + $query = "ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL"; |
|
| 303 | 303 | } |
| 304 | 304 | } else { |
| 305 | - $query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL"; |
|
| 305 | + $query = "ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL"; |
|
| 306 | 306 | } |
| 307 | 307 | try { |
| 308 | 308 | $sth = $Connection->db->prepare($query); |
| 309 | 309 | $sth->execute(); |
| 310 | - } catch(PDOException $e) { |
|
| 310 | + } catch (PDOException $e) { |
|
| 311 | 311 | return "error (add pilot column to spotter_archive) : ".$e->getMessage()."\n"; |
| 312 | 312 | } |
| 313 | 313 | |
@@ -320,7 +320,7 @@ discard block |
||
| 320 | 320 | try { |
| 321 | 321 | $sth = $Connection->db->prepare($query); |
| 322 | 322 | $sth->execute(); |
| 323 | - } catch(PDOException $e) { |
|
| 323 | + } catch (PDOException $e) { |
|
| 324 | 324 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
| 325 | 325 | } |
| 326 | 326 | return $error; |
@@ -339,14 +339,14 @@ discard block |
||
| 339 | 339 | try { |
| 340 | 340 | $sth = $Connection->db->prepare($query); |
| 341 | 341 | $sth->execute(); |
| 342 | - } catch(PDOException $e) { |
|
| 342 | + } catch (PDOException $e) { |
|
| 343 | 343 | return "error (insert last_update values) : ".$e->getMessage()."\n"; |
| 344 | 344 | } |
| 345 | 345 | $query = "UPDATE `config` SET `value` = '9' WHERE `name` = 'schema_version'"; |
| 346 | 346 | try { |
| 347 | 347 | $sth = $Connection->db->prepare($query); |
| 348 | 348 | $sth->execute(); |
| 349 | - } catch(PDOException $e) { |
|
| 349 | + } catch (PDOException $e) { |
|
| 350 | 350 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
| 351 | 351 | } |
| 352 | 352 | return $error; |
@@ -354,12 +354,12 @@ discard block |
||
| 354 | 354 | |
| 355 | 355 | private static function update_from_9() { |
| 356 | 356 | $Connection = new Connection(); |
| 357 | - $query="ALTER TABLE spotter_live ADD verticalrate INT(11) NULL; |
|
| 357 | + $query = "ALTER TABLE spotter_live ADD verticalrate INT(11) NULL; |
|
| 358 | 358 | ALTER TABLE spotter_output ADD verticalrate INT(11) NULL;"; |
| 359 | 359 | try { |
| 360 | 360 | $sth = $Connection->db->prepare($query); |
| 361 | 361 | $sth->execute(); |
| 362 | - } catch(PDOException $e) { |
|
| 362 | + } catch (PDOException $e) { |
|
| 363 | 363 | return "error (add verticalrate column to spotter_live and spotter_output) : ".$e->getMessage()."\n"; |
| 364 | 364 | } |
| 365 | 365 | $error = ''; |
@@ -371,7 +371,7 @@ discard block |
||
| 371 | 371 | try { |
| 372 | 372 | $sth = $Connection->db->prepare($query); |
| 373 | 373 | $sth->execute(); |
| 374 | - } catch(PDOException $e) { |
|
| 374 | + } catch (PDOException $e) { |
|
| 375 | 375 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
| 376 | 376 | } |
| 377 | 377 | return $error; |
@@ -379,11 +379,11 @@ discard block |
||
| 379 | 379 | |
| 380 | 380 | private static function update_from_10() { |
| 381 | 381 | $Connection = new Connection(); |
| 382 | - $query="ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL"; |
|
| 382 | + $query = "ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL"; |
|
| 383 | 383 | try { |
| 384 | 384 | $sth = $Connection->db->prepare($query); |
| 385 | 385 | $sth->execute(); |
| 386 | - } catch(PDOException $e) { |
|
| 386 | + } catch (PDOException $e) { |
|
| 387 | 387 | return "error (add new enum to ATC table) : ".$e->getMessage()."\n"; |
| 388 | 388 | } |
| 389 | 389 | $error = ''; |
@@ -401,7 +401,7 @@ discard block |
||
| 401 | 401 | try { |
| 402 | 402 | $sth = $Connection->db->prepare($query); |
| 403 | 403 | $sth->execute(); |
| 404 | - } catch(PDOException $e) { |
|
| 404 | + } catch (PDOException $e) { |
|
| 405 | 405 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
| 406 | 406 | } |
| 407 | 407 | return $error; |
@@ -410,18 +410,18 @@ discard block |
||
| 410 | 410 | private static function update_from_11() { |
| 411 | 411 | global $globalDBdriver, $globalDBname; |
| 412 | 412 | $Connection = new Connection(); |
| 413 | - $query="ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)"; |
|
| 413 | + $query = "ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)"; |
|
| 414 | 414 | try { |
| 415 | 415 | $sth = $Connection->db->prepare($query); |
| 416 | 416 | $sth->execute(); |
| 417 | - } catch(PDOException $e) { |
|
| 417 | + } catch (PDOException $e) { |
|
| 418 | 418 | return "error (add owner_name & format_source column to spotter_output) : ".$e->getMessage()."\n"; |
| 419 | 419 | } |
| 420 | - $query="ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
| 420 | + $query = "ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
| 421 | 421 | try { |
| 422 | 422 | $sth = $Connection->db->prepare($query); |
| 423 | 423 | $sth->execute(); |
| 424 | - } catch(PDOException $e) { |
|
| 424 | + } catch (PDOException $e) { |
|
| 425 | 425 | return "error (format_source column to spotter_live) : ".$e->getMessage()."\n"; |
| 426 | 426 | } |
| 427 | 427 | if ($globalDBdriver == 'mysql') { |
@@ -429,7 +429,7 @@ discard block |
||
| 429 | 429 | try { |
| 430 | 430 | $sth = $Connection->db->prepare($query); |
| 431 | 431 | $sth->execute(); |
| 432 | - } catch(PDOException $e) { |
|
| 432 | + } catch (PDOException $e) { |
|
| 433 | 433 | return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n"; |
| 434 | 434 | } |
| 435 | 435 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -441,15 +441,15 @@ discard block |
||
| 441 | 441 | DROP TABLE spotter_archive; |
| 442 | 442 | RENAME TABLE copy TO spotter_archive;"; |
| 443 | 443 | } else { |
| 444 | - $query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
| 444 | + $query = "ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
| 445 | 445 | } |
| 446 | 446 | } else { |
| 447 | - $query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
| 447 | + $query = "ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
| 448 | 448 | } |
| 449 | 449 | try { |
| 450 | 450 | $sth = $Connection->db->prepare($query); |
| 451 | 451 | $sth->execute(); |
| 452 | - } catch(PDOException $e) { |
|
| 452 | + } catch (PDOException $e) { |
|
| 453 | 453 | return "error (add columns to spotter_archive) : ".$e->getMessage()."\n"; |
| 454 | 454 | } |
| 455 | 455 | |
@@ -459,7 +459,7 @@ discard block |
||
| 459 | 459 | try { |
| 460 | 460 | $sth = $Connection->db->prepare($query); |
| 461 | 461 | $sth->execute(); |
| 462 | - } catch(PDOException $e) { |
|
| 462 | + } catch (PDOException $e) { |
|
| 463 | 463 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
| 464 | 464 | } |
| 465 | 465 | return $error; |
@@ -487,7 +487,7 @@ discard block |
||
| 487 | 487 | try { |
| 488 | 488 | $sth = $Connection->db->prepare($query); |
| 489 | 489 | $sth->execute(); |
| 490 | - } catch(PDOException $e) { |
|
| 490 | + } catch (PDOException $e) { |
|
| 491 | 491 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
| 492 | 492 | } |
| 493 | 493 | return $error; |
@@ -495,12 +495,12 @@ discard block |
||
| 495 | 495 | |
| 496 | 496 | private static function update_from_13() { |
| 497 | 497 | $Connection = new Connection(); |
| 498 | - if (!$Connection->checkColumnName('spotter_archive_output','real_departure_airport_icao')) { |
|
| 499 | - $query="ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)"; |
|
| 498 | + if (!$Connection->checkColumnName('spotter_archive_output', 'real_departure_airport_icao')) { |
|
| 499 | + $query = "ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)"; |
|
| 500 | 500 | try { |
| 501 | 501 | $sth = $Connection->db->prepare($query); |
| 502 | 502 | $sth->execute(); |
| 503 | - } catch(PDOException $e) { |
|
| 503 | + } catch (PDOException $e) { |
|
| 504 | 504 | return "error (update spotter_archive_output) : ".$e->getMessage()."\n"; |
| 505 | 505 | } |
| 506 | 506 | } |
@@ -509,7 +509,7 @@ discard block |
||
| 509 | 509 | try { |
| 510 | 510 | $sth = $Connection->db->prepare($query); |
| 511 | 511 | $sth->execute(); |
| 512 | - } catch(PDOException $e) { |
|
| 512 | + } catch (PDOException $e) { |
|
| 513 | 513 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
| 514 | 514 | } |
| 515 | 515 | return $error; |
@@ -527,7 +527,7 @@ discard block |
||
| 527 | 527 | try { |
| 528 | 528 | $sth = $Connection->db->prepare($query); |
| 529 | 529 | $sth->execute(); |
| 530 | - } catch(PDOException $e) { |
|
| 530 | + } catch (PDOException $e) { |
|
| 531 | 531 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
| 532 | 532 | } |
| 533 | 533 | return $error; |
@@ -538,11 +538,11 @@ discard block |
||
| 538 | 538 | $Connection = new Connection(); |
| 539 | 539 | $error = ''; |
| 540 | 540 | // Add tables |
| 541 | - $query="ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP"; |
|
| 541 | + $query = "ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP"; |
|
| 542 | 542 | try { |
| 543 | 543 | $sth = $Connection->db->prepare($query); |
| 544 | 544 | $sth->execute(); |
| 545 | - } catch(PDOException $e) { |
|
| 545 | + } catch (PDOException $e) { |
|
| 546 | 546 | return "error (update stats) : ".$e->getMessage()."\n"; |
| 547 | 547 | } |
| 548 | 548 | if ($error != '') return $error; |
@@ -550,7 +550,7 @@ discard block |
||
| 550 | 550 | try { |
| 551 | 551 | $sth = $Connection->db->prepare($query); |
| 552 | 552 | $sth->execute(); |
| 553 | - } catch(PDOException $e) { |
|
| 553 | + } catch (PDOException $e) { |
|
| 554 | 554 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
| 555 | 555 | } |
| 556 | 556 | return $error; |
@@ -571,7 +571,7 @@ discard block |
||
| 571 | 571 | try { |
| 572 | 572 | $sth = $Connection->db->prepare($query); |
| 573 | 573 | $sth->execute(); |
| 574 | - } catch(PDOException $e) { |
|
| 574 | + } catch (PDOException $e) { |
|
| 575 | 575 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
| 576 | 576 | } |
| 577 | 577 | return $error; |
@@ -589,7 +589,7 @@ discard block |
||
| 589 | 589 | try { |
| 590 | 590 | $sth = $Connection->db->prepare($query); |
| 591 | 591 | $sth->execute(); |
| 592 | - } catch(PDOException $e) { |
|
| 592 | + } catch (PDOException $e) { |
|
| 593 | 593 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
| 594 | 594 | } |
| 595 | 595 | return $error; |
@@ -598,12 +598,12 @@ discard block |
||
| 598 | 598 | $Connection = new Connection(); |
| 599 | 599 | $error = ''; |
| 600 | 600 | // Modify stats_airport table |
| 601 | - if (!$Connection->checkColumnName('stats_airport','airport_name')) { |
|
| 601 | + if (!$Connection->checkColumnName('stats_airport', 'airport_name')) { |
|
| 602 | 602 | $query = "ALTER TABLE `stats_airport` ADD `stats_type` VARCHAR(50) NOT NULL DEFAULT 'yearly', ADD `airport_name` VARCHAR(255) NOT NULL, ADD `date` DATE NULL DEFAULT NULL, DROP INDEX `airport_icao`, ADD UNIQUE `airport_icao` (`airport_icao`, `type`, `date`)"; |
| 603 | 603 | try { |
| 604 | 604 | $sth = $Connection->db->prepare($query); |
| 605 | 605 | $sth->execute(); |
| 606 | - } catch(PDOException $e) { |
|
| 606 | + } catch (PDOException $e) { |
|
| 607 | 607 | return "error (update stats) : ".$e->getMessage()."\n"; |
| 608 | 608 | } |
| 609 | 609 | } |
@@ -612,7 +612,7 @@ discard block |
||
| 612 | 612 | try { |
| 613 | 613 | $sth = $Connection->db->prepare($query); |
| 614 | 614 | $sth->execute(); |
| 615 | - } catch(PDOException $e) { |
|
| 615 | + } catch (PDOException $e) { |
|
| 616 | 616 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
| 617 | 617 | } |
| 618 | 618 | return $error; |
@@ -629,73 +629,73 @@ discard block |
||
| 629 | 629 | try { |
| 630 | 630 | $sth = $Connection->db->prepare($query); |
| 631 | 631 | $sth->execute(); |
| 632 | - } catch(PDOException $e) { |
|
| 632 | + } catch (PDOException $e) { |
|
| 633 | 633 | return "error (remove primary key on spotter_archive) : ".$e->getMessage()."\n"; |
| 634 | 634 | } |
| 635 | 635 | $query = "alter table spotter_archive add spotter_archive_id INT(11)"; |
| 636 | 636 | try { |
| 637 | 637 | $sth = $Connection->db->prepare($query); |
| 638 | 638 | $sth->execute(); |
| 639 | - } catch(PDOException $e) { |
|
| 639 | + } catch (PDOException $e) { |
|
| 640 | 640 | return "error (add id again on spotter_archive) : ".$e->getMessage()."\n"; |
| 641 | 641 | } |
| 642 | - if (!$Connection->checkColumnName('spotter_archive','over_country')) { |
|
| 642 | + if (!$Connection->checkColumnName('spotter_archive', 'over_country')) { |
|
| 643 | 643 | // Add column over_country |
| 644 | 644 | $query = "ALTER TABLE `spotter_archive` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL"; |
| 645 | 645 | try { |
| 646 | 646 | $sth = $Connection->db->prepare($query); |
| 647 | 647 | $sth->execute(); |
| 648 | - } catch(PDOException $e) { |
|
| 648 | + } catch (PDOException $e) { |
|
| 649 | 649 | return "error (add over_country) : ".$e->getMessage()."\n"; |
| 650 | 650 | } |
| 651 | 651 | } |
| 652 | - if (!$Connection->checkColumnName('spotter_live','over_country')) { |
|
| 652 | + if (!$Connection->checkColumnName('spotter_live', 'over_country')) { |
|
| 653 | 653 | // Add column over_country |
| 654 | 654 | $query = "ALTER TABLE `spotter_live` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL"; |
| 655 | 655 | try { |
| 656 | 656 | $sth = $Connection->db->prepare($query); |
| 657 | 657 | $sth->execute(); |
| 658 | - } catch(PDOException $e) { |
|
| 658 | + } catch (PDOException $e) { |
|
| 659 | 659 | return "error (add over_country) : ".$e->getMessage()."\n"; |
| 660 | 660 | } |
| 661 | 661 | } |
| 662 | - if (!$Connection->checkColumnName('spotter_output','source_name')) { |
|
| 662 | + if (!$Connection->checkColumnName('spotter_output', 'source_name')) { |
|
| 663 | 663 | // Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output |
| 664 | 664 | $query = "ALTER TABLE `spotter_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`"; |
| 665 | 665 | try { |
| 666 | 666 | $sth = $Connection->db->prepare($query); |
| 667 | 667 | $sth->execute(); |
| 668 | - } catch(PDOException $e) { |
|
| 668 | + } catch (PDOException $e) { |
|
| 669 | 669 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
| 670 | 670 | } |
| 671 | 671 | } |
| 672 | - if (!$Connection->checkColumnName('spotter_live','source_name')) { |
|
| 672 | + if (!$Connection->checkColumnName('spotter_live', 'source_name')) { |
|
| 673 | 673 | // Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output |
| 674 | 674 | $query = "ALTER TABLE `spotter_live` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`"; |
| 675 | 675 | try { |
| 676 | 676 | $sth = $Connection->db->prepare($query); |
| 677 | 677 | $sth->execute(); |
| 678 | - } catch(PDOException $e) { |
|
| 678 | + } catch (PDOException $e) { |
|
| 679 | 679 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
| 680 | 680 | } |
| 681 | 681 | } |
| 682 | - if (!$Connection->checkColumnName('spotter_archive_output','source_name')) { |
|
| 682 | + if (!$Connection->checkColumnName('spotter_archive_output', 'source_name')) { |
|
| 683 | 683 | // Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output |
| 684 | 684 | $query = "ALTER TABLE `spotter_archive_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`"; |
| 685 | 685 | try { |
| 686 | 686 | $sth = $Connection->db->prepare($query); |
| 687 | 687 | $sth->execute(); |
| 688 | - } catch(PDOException $e) { |
|
| 688 | + } catch (PDOException $e) { |
|
| 689 | 689 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
| 690 | 690 | } |
| 691 | 691 | } |
| 692 | - if (!$Connection->checkColumnName('spotter_archive','source_name')) { |
|
| 692 | + if (!$Connection->checkColumnName('spotter_archive', 'source_name')) { |
|
| 693 | 693 | // Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output |
| 694 | 694 | $query = "ALTER TABLE `spotter_archive` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`;"; |
| 695 | 695 | try { |
| 696 | 696 | $sth = $Connection->db->prepare($query); |
| 697 | 697 | $sth->execute(); |
| 698 | - } catch(PDOException $e) { |
|
| 698 | + } catch (PDOException $e) { |
|
| 699 | 699 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
| 700 | 700 | } |
| 701 | 701 | } |
@@ -704,7 +704,7 @@ discard block |
||
| 704 | 704 | try { |
| 705 | 705 | $sth = $Connection->db->prepare($query); |
| 706 | 706 | $sth->execute(); |
| 707 | - } catch(PDOException $e) { |
|
| 707 | + } catch (PDOException $e) { |
|
| 708 | 708 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
| 709 | 709 | } |
| 710 | 710 | return $error; |
@@ -719,13 +719,13 @@ discard block |
||
| 719 | 719 | $error .= create_db::import_file('../db/airlines.sql'); |
| 720 | 720 | if ($error != '') return 'Import airlines.sql : '.$error; |
| 721 | 721 | } |
| 722 | - if (!$Connection->checkColumnName('aircraft_modes','type_flight')) { |
|
| 722 | + if (!$Connection->checkColumnName('aircraft_modes', 'type_flight')) { |
|
| 723 | 723 | // Add column over_country |
| 724 | 724 | $query = "ALTER TABLE `aircraft_modes` ADD `type_flight` VARCHAR(50) NULL DEFAULT NULL;"; |
| 725 | 725 | try { |
| 726 | 726 | $sth = $Connection->db->prepare($query); |
| 727 | 727 | $sth->execute(); |
| 728 | - } catch(PDOException $e) { |
|
| 728 | + } catch (PDOException $e) { |
|
| 729 | 729 | return "error (add over_country) : ".$e->getMessage()."\n"; |
| 730 | 730 | } |
| 731 | 731 | } |
@@ -741,7 +741,7 @@ discard block |
||
| 741 | 741 | try { |
| 742 | 742 | $sth = $Connection->db->prepare($query); |
| 743 | 743 | $sth->execute(); |
| 744 | - } catch(PDOException $e) { |
|
| 744 | + } catch (PDOException $e) { |
|
| 745 | 745 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
| 746 | 746 | } |
| 747 | 747 | return $error; |
@@ -750,13 +750,13 @@ discard block |
||
| 750 | 750 | private static function update_from_21() { |
| 751 | 751 | $Connection = new Connection(); |
| 752 | 752 | $error = ''; |
| 753 | - if (!$Connection->checkColumnName('stats_airport','stats_type')) { |
|
| 753 | + if (!$Connection->checkColumnName('stats_airport', 'stats_type')) { |
|
| 754 | 754 | // Rename type to stats_type |
| 755 | 755 | $query = "ALTER TABLE `stats_airport` CHANGE `type` `stats_type` VARCHAR(50);ALTER TABLE `stats` CHANGE `type` `stats_type` VARCHAR(50);ALTER TABLE `stats_flight` CHANGE `type` `stats_type` VARCHAR(50);"; |
| 756 | 756 | try { |
| 757 | 757 | $sth = $Connection->db->prepare($query); |
| 758 | 758 | $sth->execute(); |
| 759 | - } catch(PDOException $e) { |
|
| 759 | + } catch (PDOException $e) { |
|
| 760 | 760 | return "error (rename type to stats_type on stats*) : ".$e->getMessage()."\n"; |
| 761 | 761 | } |
| 762 | 762 | if ($error != '') return $error; |
@@ -765,7 +765,7 @@ discard block |
||
| 765 | 765 | try { |
| 766 | 766 | $sth = $Connection->db->prepare($query); |
| 767 | 767 | $sth->execute(); |
| 768 | - } catch(PDOException $e) { |
|
| 768 | + } catch (PDOException $e) { |
|
| 769 | 769 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
| 770 | 770 | } |
| 771 | 771 | return $error; |
@@ -788,7 +788,7 @@ discard block |
||
| 788 | 788 | try { |
| 789 | 789 | $sth = $Connection->db->prepare($query); |
| 790 | 790 | $sth->execute(); |
| 791 | - } catch(PDOException $e) { |
|
| 791 | + } catch (PDOException $e) { |
|
| 792 | 792 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
| 793 | 793 | } |
| 794 | 794 | return $error; |
@@ -815,17 +815,17 @@ discard block |
||
| 815 | 815 | try { |
| 816 | 816 | $sth = $Connection->db->prepare($query); |
| 817 | 817 | $sth->execute(); |
| 818 | - } catch(PDOException $e) { |
|
| 818 | + } catch (PDOException $e) { |
|
| 819 | 819 | return "error (create index on spotter_archive) : ".$e->getMessage()."\n"; |
| 820 | 820 | } |
| 821 | 821 | } |
| 822 | - if (!$Connection->checkColumnName('stats_aircraft','aircraft_manufacturer')) { |
|
| 822 | + if (!$Connection->checkColumnName('stats_aircraft', 'aircraft_manufacturer')) { |
|
| 823 | 823 | // Add aircraft_manufacturer to stats_aircraft |
| 824 | 824 | $query = "ALTER TABLE stats_aircraft ADD aircraft_manufacturer VARCHAR(255) NULL"; |
| 825 | 825 | try { |
| 826 | 826 | $sth = $Connection->db->prepare($query); |
| 827 | 827 | $sth->execute(); |
| 828 | - } catch(PDOException $e) { |
|
| 828 | + } catch (PDOException $e) { |
|
| 829 | 829 | return "error (add aircraft_manufacturer column) : ".$e->getMessage()."\n"; |
| 830 | 830 | } |
| 831 | 831 | } |
@@ -834,7 +834,7 @@ discard block |
||
| 834 | 834 | try { |
| 835 | 835 | $sth = $Connection->db->prepare($query); |
| 836 | 836 | $sth->execute(); |
| 837 | - } catch(PDOException $e) { |
|
| 837 | + } catch (PDOException $e) { |
|
| 838 | 838 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
| 839 | 839 | } |
| 840 | 840 | return $error; |
@@ -850,23 +850,23 @@ discard block |
||
| 850 | 850 | $error .= create_db::import_file('../db/pgsql/airlines.sql'); |
| 851 | 851 | } |
| 852 | 852 | if ($error != '') return 'Import airlines.sql : '.$error; |
| 853 | - if (!$Connection->checkColumnName('airlines','forsource')) { |
|
| 853 | + if (!$Connection->checkColumnName('airlines', 'forsource')) { |
|
| 854 | 854 | // Add forsource to airlines |
| 855 | 855 | $query = "ALTER TABLE airlines ADD forsource VARCHAR(255) NULL DEFAULT NULL"; |
| 856 | 856 | try { |
| 857 | 857 | $sth = $Connection->db->prepare($query); |
| 858 | 858 | $sth->execute(); |
| 859 | - } catch(PDOException $e) { |
|
| 859 | + } catch (PDOException $e) { |
|
| 860 | 860 | return "error (add forsource column) : ".$e->getMessage()."\n"; |
| 861 | 861 | } |
| 862 | 862 | } |
| 863 | - if (!$Connection->checkColumnName('stats_aircraft','stats_airline')) { |
|
| 863 | + if (!$Connection->checkColumnName('stats_aircraft', 'stats_airline')) { |
|
| 864 | 864 | // Add forsource to airlines |
| 865 | 865 | $query = "ALTER TABLE stats_aircraft ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
| 866 | 866 | try { |
| 867 | 867 | $sth = $Connection->db->prepare($query); |
| 868 | 868 | $sth->execute(); |
| 869 | - } catch(PDOException $e) { |
|
| 869 | + } catch (PDOException $e) { |
|
| 870 | 870 | return "error (add stats_airline & filter_name column in stats_aircraft) : ".$e->getMessage()."\n"; |
| 871 | 871 | } |
| 872 | 872 | // Add unique key |
@@ -878,17 +878,17 @@ discard block |
||
| 878 | 878 | try { |
| 879 | 879 | $sth = $Connection->db->prepare($query); |
| 880 | 880 | $sth->execute(); |
| 881 | - } catch(PDOException $e) { |
|
| 881 | + } catch (PDOException $e) { |
|
| 882 | 882 | return "error (add unique key in stats_aircraft) : ".$e->getMessage()."\n"; |
| 883 | 883 | } |
| 884 | 884 | } |
| 885 | - if (!$Connection->checkColumnName('stats_airport','stats_airline')) { |
|
| 885 | + if (!$Connection->checkColumnName('stats_airport', 'stats_airline')) { |
|
| 886 | 886 | // Add forsource to airlines |
| 887 | 887 | $query = "ALTER TABLE stats_airport ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
| 888 | 888 | try { |
| 889 | 889 | $sth = $Connection->db->prepare($query); |
| 890 | 890 | $sth->execute(); |
| 891 | - } catch(PDOException $e) { |
|
| 891 | + } catch (PDOException $e) { |
|
| 892 | 892 | return "error (add filter_name column in stats_airport) : ".$e->getMessage()."\n"; |
| 893 | 893 | } |
| 894 | 894 | // Add unique key |
@@ -900,17 +900,17 @@ discard block |
||
| 900 | 900 | try { |
| 901 | 901 | $sth = $Connection->db->prepare($query); |
| 902 | 902 | $sth->execute(); |
| 903 | - } catch(PDOException $e) { |
|
| 903 | + } catch (PDOException $e) { |
|
| 904 | 904 | return "error (add unique key in stats_airport) : ".$e->getMessage()."\n"; |
| 905 | 905 | } |
| 906 | 906 | } |
| 907 | - if (!$Connection->checkColumnName('stats_country','stats_airline')) { |
|
| 907 | + if (!$Connection->checkColumnName('stats_country', 'stats_airline')) { |
|
| 908 | 908 | // Add forsource to airlines |
| 909 | 909 | $query = "ALTER TABLE stats_country ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
| 910 | 910 | try { |
| 911 | 911 | $sth = $Connection->db->prepare($query); |
| 912 | 912 | $sth->execute(); |
| 913 | - } catch(PDOException $e) { |
|
| 913 | + } catch (PDOException $e) { |
|
| 914 | 914 | return "error (add stats_airline & filter_name column in stats_country) : ".$e->getMessage()."\n"; |
| 915 | 915 | } |
| 916 | 916 | // Add unique key |
@@ -922,36 +922,36 @@ discard block |
||
| 922 | 922 | try { |
| 923 | 923 | $sth = $Connection->db->prepare($query); |
| 924 | 924 | $sth->execute(); |
| 925 | - } catch(PDOException $e) { |
|
| 925 | + } catch (PDOException $e) { |
|
| 926 | 926 | return "error (add unique key in stats_airline) : ".$e->getMessage()."\n"; |
| 927 | 927 | } |
| 928 | 928 | } |
| 929 | - if (!$Connection->checkColumnName('stats_flight','stats_airline')) { |
|
| 929 | + if (!$Connection->checkColumnName('stats_flight', 'stats_airline')) { |
|
| 930 | 930 | // Add forsource to airlines |
| 931 | 931 | $query = "ALTER TABLE stats_flight ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
| 932 | 932 | try { |
| 933 | 933 | $sth = $Connection->db->prepare($query); |
| 934 | 934 | $sth->execute(); |
| 935 | - } catch(PDOException $e) { |
|
| 935 | + } catch (PDOException $e) { |
|
| 936 | 936 | return "error (add stats_airline & filter_name column in stats_flight) : ".$e->getMessage()."\n"; |
| 937 | 937 | } |
| 938 | 938 | } |
| 939 | - if (!$Connection->checkColumnName('stats','stats_airline')) { |
|
| 939 | + if (!$Connection->checkColumnName('stats', 'stats_airline')) { |
|
| 940 | 940 | // Add forsource to airlines |
| 941 | 941 | $query = "ALTER TABLE stats ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
| 942 | 942 | try { |
| 943 | 943 | $sth = $Connection->db->prepare($query); |
| 944 | 944 | $sth->execute(); |
| 945 | - } catch(PDOException $e) { |
|
| 945 | + } catch (PDOException $e) { |
|
| 946 | 946 | return "error (add stats_airline & filter_name column in stats) : ".$e->getMessage()."\n"; |
| 947 | 947 | } |
| 948 | - if ($globalDBdriver == 'mysql' && $Connection->indexExists('stats','type')) { |
|
| 948 | + if ($globalDBdriver == 'mysql' && $Connection->indexExists('stats', 'type')) { |
|
| 949 | 949 | // Add unique key |
| 950 | 950 | $query = "drop index type on stats;ALTER TABLE stats ADD UNIQUE stats_type (stats_type,stats_date,stats_airline,filter_name);"; |
| 951 | 951 | try { |
| 952 | 952 | $sth = $Connection->db->prepare($query); |
| 953 | 953 | $sth->execute(); |
| 954 | - } catch(PDOException $e) { |
|
| 954 | + } catch (PDOException $e) { |
|
| 955 | 955 | return "error (add unique key in stats) : ".$e->getMessage()."\n"; |
| 956 | 956 | } |
| 957 | 957 | } else { |
@@ -964,18 +964,18 @@ discard block |
||
| 964 | 964 | try { |
| 965 | 965 | $sth = $Connection->db->prepare($query); |
| 966 | 966 | $sth->execute(); |
| 967 | - } catch(PDOException $e) { |
|
| 967 | + } catch (PDOException $e) { |
|
| 968 | 968 | return "error (add unique key in stats) : ".$e->getMessage()."\n"; |
| 969 | 969 | } |
| 970 | 970 | } |
| 971 | 971 | } |
| 972 | - if (!$Connection->checkColumnName('stats_registration','stats_airline')) { |
|
| 972 | + if (!$Connection->checkColumnName('stats_registration', 'stats_airline')) { |
|
| 973 | 973 | // Add forsource to airlines |
| 974 | 974 | $query = "ALTER TABLE stats_registration ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
| 975 | 975 | try { |
| 976 | 976 | $sth = $Connection->db->prepare($query); |
| 977 | 977 | $sth->execute(); |
| 978 | - } catch(PDOException $e) { |
|
| 978 | + } catch (PDOException $e) { |
|
| 979 | 979 | return "error (add stats_airline & filter_name column in stats_registration) : ".$e->getMessage()."\n"; |
| 980 | 980 | } |
| 981 | 981 | // Add unique key |
@@ -987,17 +987,17 @@ discard block |
||
| 987 | 987 | try { |
| 988 | 988 | $sth = $Connection->db->prepare($query); |
| 989 | 989 | $sth->execute(); |
| 990 | - } catch(PDOException $e) { |
|
| 990 | + } catch (PDOException $e) { |
|
| 991 | 991 | return "error (add unique key in stats_registration) : ".$e->getMessage()."\n"; |
| 992 | 992 | } |
| 993 | 993 | } |
| 994 | - if (!$Connection->checkColumnName('stats_callsign','filter_name')) { |
|
| 994 | + if (!$Connection->checkColumnName('stats_callsign', 'filter_name')) { |
|
| 995 | 995 | // Add forsource to airlines |
| 996 | 996 | $query = "ALTER TABLE stats_callsign ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
| 997 | 997 | try { |
| 998 | 998 | $sth = $Connection->db->prepare($query); |
| 999 | 999 | $sth->execute(); |
| 1000 | - } catch(PDOException $e) { |
|
| 1000 | + } catch (PDOException $e) { |
|
| 1001 | 1001 | return "error (add filter_name column in stats_callsign) : ".$e->getMessage()."\n"; |
| 1002 | 1002 | } |
| 1003 | 1003 | // Add unique key |
@@ -1009,17 +1009,17 @@ discard block |
||
| 1009 | 1009 | try { |
| 1010 | 1010 | $sth = $Connection->db->prepare($query); |
| 1011 | 1011 | $sth->execute(); |
| 1012 | - } catch(PDOException $e) { |
|
| 1012 | + } catch (PDOException $e) { |
|
| 1013 | 1013 | return "error (add unique key in stats_callsign) : ".$e->getMessage()."\n"; |
| 1014 | 1014 | } |
| 1015 | 1015 | } |
| 1016 | - if (!$Connection->checkColumnName('stats_airline','filter_name')) { |
|
| 1016 | + if (!$Connection->checkColumnName('stats_airline', 'filter_name')) { |
|
| 1017 | 1017 | // Add forsource to airlines |
| 1018 | 1018 | $query = "ALTER TABLE stats_airline ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
| 1019 | 1019 | try { |
| 1020 | 1020 | $sth = $Connection->db->prepare($query); |
| 1021 | 1021 | $sth->execute(); |
| 1022 | - } catch(PDOException $e) { |
|
| 1022 | + } catch (PDOException $e) { |
|
| 1023 | 1023 | return "error (add filter_name column in stats_airline) : ".$e->getMessage()."\n"; |
| 1024 | 1024 | } |
| 1025 | 1025 | // Add unique key |
@@ -1031,7 +1031,7 @@ discard block |
||
| 1031 | 1031 | try { |
| 1032 | 1032 | $sth = $Connection->db->prepare($query); |
| 1033 | 1033 | $sth->execute(); |
| 1034 | - } catch(PDOException $e) { |
|
| 1034 | + } catch (PDOException $e) { |
|
| 1035 | 1035 | return "error (add unique key in stats_callsign) : ".$e->getMessage()."\n"; |
| 1036 | 1036 | } |
| 1037 | 1037 | } |
@@ -1040,7 +1040,7 @@ discard block |
||
| 1040 | 1040 | try { |
| 1041 | 1041 | $sth = $Connection->db->prepare($query); |
| 1042 | 1042 | $sth->execute(); |
| 1043 | - } catch(PDOException $e) { |
|
| 1043 | + } catch (PDOException $e) { |
|
| 1044 | 1044 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
| 1045 | 1045 | } |
| 1046 | 1046 | return $error; |
@@ -1050,13 +1050,13 @@ discard block |
||
| 1050 | 1050 | global $globalDBdriver; |
| 1051 | 1051 | $Connection = new Connection(); |
| 1052 | 1052 | $error = ''; |
| 1053 | - if (!$Connection->checkColumnName('stats_owner','stats_airline')) { |
|
| 1053 | + if (!$Connection->checkColumnName('stats_owner', 'stats_airline')) { |
|
| 1054 | 1054 | // Add forsource to airlines |
| 1055 | 1055 | $query = "ALTER TABLE stats_owner ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
| 1056 | 1056 | try { |
| 1057 | 1057 | $sth = $Connection->db->prepare($query); |
| 1058 | 1058 | $sth->execute(); |
| 1059 | - } catch(PDOException $e) { |
|
| 1059 | + } catch (PDOException $e) { |
|
| 1060 | 1060 | return "error (add stats_airline & filter_name column in stats_owner) : ".$e->getMessage()."\n"; |
| 1061 | 1061 | } |
| 1062 | 1062 | // Add unique key |
@@ -1068,17 +1068,17 @@ discard block |
||
| 1068 | 1068 | try { |
| 1069 | 1069 | $sth = $Connection->db->prepare($query); |
| 1070 | 1070 | $sth->execute(); |
| 1071 | - } catch(PDOException $e) { |
|
| 1071 | + } catch (PDOException $e) { |
|
| 1072 | 1072 | return "error (add unique key in stats_owner) : ".$e->getMessage()."\n"; |
| 1073 | 1073 | } |
| 1074 | 1074 | } |
| 1075 | - if (!$Connection->checkColumnName('stats_pilot','stats_airline')) { |
|
| 1075 | + if (!$Connection->checkColumnName('stats_pilot', 'stats_airline')) { |
|
| 1076 | 1076 | // Add forsource to airlines |
| 1077 | 1077 | $query = "ALTER TABLE stats_pilot ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
| 1078 | 1078 | try { |
| 1079 | 1079 | $sth = $Connection->db->prepare($query); |
| 1080 | 1080 | $sth->execute(); |
| 1081 | - } catch(PDOException $e) { |
|
| 1081 | + } catch (PDOException $e) { |
|
| 1082 | 1082 | return "error (add stats_airline & filter_name column in stats_pilot) : ".$e->getMessage()."\n"; |
| 1083 | 1083 | } |
| 1084 | 1084 | // Add unique key |
@@ -1090,7 +1090,7 @@ discard block |
||
| 1090 | 1090 | try { |
| 1091 | 1091 | $sth = $Connection->db->prepare($query); |
| 1092 | 1092 | $sth->execute(); |
| 1093 | - } catch(PDOException $e) { |
|
| 1093 | + } catch (PDOException $e) { |
|
| 1094 | 1094 | return "error (add unique key in stats_pilot) : ".$e->getMessage()."\n"; |
| 1095 | 1095 | } |
| 1096 | 1096 | } |
@@ -1098,7 +1098,7 @@ discard block |
||
| 1098 | 1098 | try { |
| 1099 | 1099 | $sth = $Connection->db->prepare($query); |
| 1100 | 1100 | $sth->execute(); |
| 1101 | - } catch(PDOException $e) { |
|
| 1101 | + } catch (PDOException $e) { |
|
| 1102 | 1102 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
| 1103 | 1103 | } |
| 1104 | 1104 | return $error; |
@@ -1108,12 +1108,12 @@ discard block |
||
| 1108 | 1108 | global $globalDBdriver; |
| 1109 | 1109 | $Connection = new Connection(); |
| 1110 | 1110 | $error = ''; |
| 1111 | - if (!$Connection->checkColumnName('atc','format_source')) { |
|
| 1111 | + if (!$Connection->checkColumnName('atc', 'format_source')) { |
|
| 1112 | 1112 | $query = "ALTER TABLE atc ADD format_source VARCHAR(255) DEFAULT NULL, ADD source_name VARCHAR(255) DEFAULT NULL"; |
| 1113 | 1113 | try { |
| 1114 | 1114 | $sth = $Connection->db->prepare($query); |
| 1115 | 1115 | $sth->execute(); |
| 1116 | - } catch(PDOException $e) { |
|
| 1116 | + } catch (PDOException $e) { |
|
| 1117 | 1117 | return "error (add format_source & source_name column in atc) : ".$e->getMessage()."\n"; |
| 1118 | 1118 | } |
| 1119 | 1119 | } |
@@ -1121,7 +1121,7 @@ discard block |
||
| 1121 | 1121 | try { |
| 1122 | 1122 | $sth = $Connection->db->prepare($query); |
| 1123 | 1123 | $sth->execute(); |
| 1124 | - } catch(PDOException $e) { |
|
| 1124 | + } catch (PDOException $e) { |
|
| 1125 | 1125 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
| 1126 | 1126 | } |
| 1127 | 1127 | return $error; |
@@ -1131,13 +1131,13 @@ discard block |
||
| 1131 | 1131 | global $globalDBdriver; |
| 1132 | 1132 | $Connection = new Connection(); |
| 1133 | 1133 | $error = ''; |
| 1134 | - if (!$Connection->checkColumnName('stats_pilot','format_source')) { |
|
| 1134 | + if (!$Connection->checkColumnName('stats_pilot', 'format_source')) { |
|
| 1135 | 1135 | // Add forsource to airlines |
| 1136 | 1136 | $query = "ALTER TABLE stats_pilot ADD format_source VARCHAR(255) NULL DEFAULT ''"; |
| 1137 | 1137 | try { |
| 1138 | 1138 | $sth = $Connection->db->prepare($query); |
| 1139 | 1139 | $sth->execute(); |
| 1140 | - } catch(PDOException $e) { |
|
| 1140 | + } catch (PDOException $e) { |
|
| 1141 | 1141 | return "error (add format_source column in stats_pilot) : ".$e->getMessage()."\n"; |
| 1142 | 1142 | } |
| 1143 | 1143 | // Add unique key |
@@ -1149,7 +1149,7 @@ discard block |
||
| 1149 | 1149 | try { |
| 1150 | 1150 | $sth = $Connection->db->prepare($query); |
| 1151 | 1151 | $sth->execute(); |
| 1152 | - } catch(PDOException $e) { |
|
| 1152 | + } catch (PDOException $e) { |
|
| 1153 | 1153 | return "error (modify unique key in stats_pilot) : ".$e->getMessage()."\n"; |
| 1154 | 1154 | } |
| 1155 | 1155 | } |
@@ -1157,7 +1157,7 @@ discard block |
||
| 1157 | 1157 | try { |
| 1158 | 1158 | $sth = $Connection->db->prepare($query); |
| 1159 | 1159 | $sth->execute(); |
| 1160 | - } catch(PDOException $e) { |
|
| 1160 | + } catch (PDOException $e) { |
|
| 1161 | 1161 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
| 1162 | 1162 | } |
| 1163 | 1163 | return $error; |
@@ -1167,23 +1167,23 @@ discard block |
||
| 1167 | 1167 | global $globalDBdriver; |
| 1168 | 1168 | $Connection = new Connection(); |
| 1169 | 1169 | $error = ''; |
| 1170 | - if ($globalDBdriver == 'mysql' && !$Connection->indexExists('spotter_live','latitude')) { |
|
| 1170 | + if ($globalDBdriver == 'mysql' && !$Connection->indexExists('spotter_live', 'latitude')) { |
|
| 1171 | 1171 | // Add unique key |
| 1172 | 1172 | $query = "alter table spotter_live add index(latitude,longitude)"; |
| 1173 | 1173 | try { |
| 1174 | 1174 | $sth = $Connection->db->prepare($query); |
| 1175 | 1175 | $sth->execute(); |
| 1176 | - } catch(PDOException $e) { |
|
| 1176 | + } catch (PDOException $e) { |
|
| 1177 | 1177 | return "error (add index latitude,longitude on spotter_live) : ".$e->getMessage()."\n"; |
| 1178 | 1178 | } |
| 1179 | 1179 | } |
| 1180 | - if (!$Connection->checkColumnName('aircraft','mfr')) { |
|
| 1180 | + if (!$Connection->checkColumnName('aircraft', 'mfr')) { |
|
| 1181 | 1181 | // Add mfr to aircraft |
| 1182 | 1182 | $query = "ALTER TABLE aircraft ADD mfr VARCHAR(255) NULL"; |
| 1183 | 1183 | try { |
| 1184 | 1184 | $sth = $Connection->db->prepare($query); |
| 1185 | 1185 | $sth->execute(); |
| 1186 | - } catch(PDOException $e) { |
|
| 1186 | + } catch (PDOException $e) { |
|
| 1187 | 1187 | return "error (add mfr column in aircraft) : ".$e->getMessage()."\n"; |
| 1188 | 1188 | } |
| 1189 | 1189 | } |
@@ -1199,7 +1199,7 @@ discard block |
||
| 1199 | 1199 | try { |
| 1200 | 1200 | $sth = $Connection->db->prepare($query); |
| 1201 | 1201 | $sth->execute(); |
| 1202 | - } catch(PDOException $e) { |
|
| 1202 | + } catch (PDOException $e) { |
|
| 1203 | 1203 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
| 1204 | 1204 | } |
| 1205 | 1205 | return $error; |
@@ -1209,13 +1209,13 @@ discard block |
||
| 1209 | 1209 | global $globalDBdriver; |
| 1210 | 1210 | $Connection = new Connection(); |
| 1211 | 1211 | $error = ''; |
| 1212 | - if ($Connection->checkColumnName('aircraft','mfr')) { |
|
| 1212 | + if ($Connection->checkColumnName('aircraft', 'mfr')) { |
|
| 1213 | 1213 | // drop mfr to aircraft |
| 1214 | 1214 | $query = "ALTER TABLE aircraft DROP COLUMN mfr"; |
| 1215 | 1215 | try { |
| 1216 | 1216 | $sth = $Connection->db->prepare($query); |
| 1217 | 1217 | $sth->execute(); |
| 1218 | - } catch(PDOException $e) { |
|
| 1218 | + } catch (PDOException $e) { |
|
| 1219 | 1219 | return "error (drop mfr column in aircraft) : ".$e->getMessage()."\n"; |
| 1220 | 1220 | } |
| 1221 | 1221 | } |
@@ -1231,7 +1231,7 @@ discard block |
||
| 1231 | 1231 | try { |
| 1232 | 1232 | $sth = $Connection->db->prepare($query); |
| 1233 | 1233 | $sth->execute(); |
| 1234 | - } catch(PDOException $e) { |
|
| 1234 | + } catch (PDOException $e) { |
|
| 1235 | 1235 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
| 1236 | 1236 | } |
| 1237 | 1237 | return $error; |
@@ -1241,33 +1241,33 @@ discard block |
||
| 1241 | 1241 | global $globalDBdriver; |
| 1242 | 1242 | $Connection = new Connection(); |
| 1243 | 1243 | $error = ''; |
| 1244 | - if (!$Connection->indexExists('notam','ref_idx')) { |
|
| 1244 | + if (!$Connection->indexExists('notam', 'ref_idx')) { |
|
| 1245 | 1245 | // Add index key |
| 1246 | 1246 | $query = "create index ref_idx on notam (ref)"; |
| 1247 | 1247 | try { |
| 1248 | 1248 | $sth = $Connection->db->prepare($query); |
| 1249 | 1249 | $sth->execute(); |
| 1250 | - } catch(PDOException $e) { |
|
| 1250 | + } catch (PDOException $e) { |
|
| 1251 | 1251 | return "error (add index ref on notam) : ".$e->getMessage()."\n"; |
| 1252 | 1252 | } |
| 1253 | 1253 | } |
| 1254 | - if (!$Connection->indexExists('accidents','registration_idx')) { |
|
| 1254 | + if (!$Connection->indexExists('accidents', 'registration_idx')) { |
|
| 1255 | 1255 | // Add index key |
| 1256 | 1256 | $query = "create index registration_idx on accidents (registration)"; |
| 1257 | 1257 | try { |
| 1258 | 1258 | $sth = $Connection->db->prepare($query); |
| 1259 | 1259 | $sth->execute(); |
| 1260 | - } catch(PDOException $e) { |
|
| 1260 | + } catch (PDOException $e) { |
|
| 1261 | 1261 | return "error (add index registration on accidents) : ".$e->getMessage()."\n"; |
| 1262 | 1262 | } |
| 1263 | 1263 | } |
| 1264 | - if (!$Connection->indexExists('accidents','rdts')) { |
|
| 1264 | + if (!$Connection->indexExists('accidents', 'rdts')) { |
|
| 1265 | 1265 | // Add index key |
| 1266 | 1266 | $query = "create index rdts on accidents (registration,date,type,source)"; |
| 1267 | 1267 | try { |
| 1268 | 1268 | $sth = $Connection->db->prepare($query); |
| 1269 | 1269 | $sth->execute(); |
| 1270 | - } catch(PDOException $e) { |
|
| 1270 | + } catch (PDOException $e) { |
|
| 1271 | 1271 | return "error (add index registration, date, type & source on accidents) : ".$e->getMessage()."\n"; |
| 1272 | 1272 | } |
| 1273 | 1273 | } |
@@ -1276,7 +1276,7 @@ discard block |
||
| 1276 | 1276 | try { |
| 1277 | 1277 | $sth = $Connection->db->prepare($query); |
| 1278 | 1278 | $sth->execute(); |
| 1279 | - } catch(PDOException $e) { |
|
| 1279 | + } catch (PDOException $e) { |
|
| 1280 | 1280 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
| 1281 | 1281 | } |
| 1282 | 1282 | return $error; |
@@ -1286,23 +1286,23 @@ discard block |
||
| 1286 | 1286 | global $globalDBdriver; |
| 1287 | 1287 | $Connection = new Connection(); |
| 1288 | 1288 | $error = ''; |
| 1289 | - if (!$Connection->checkColumnName('accidents','airline_name')) { |
|
| 1289 | + if (!$Connection->checkColumnName('accidents', 'airline_name')) { |
|
| 1290 | 1290 | // Add airline_name to accidents |
| 1291 | 1291 | $query = "ALTER TABLE accidents ADD airline_name VARCHAR(255) NULL"; |
| 1292 | 1292 | try { |
| 1293 | 1293 | $sth = $Connection->db->prepare($query); |
| 1294 | 1294 | $sth->execute(); |
| 1295 | - } catch(PDOException $e) { |
|
| 1295 | + } catch (PDOException $e) { |
|
| 1296 | 1296 | return "error (add airline_name column in accidents) : ".$e->getMessage()."\n"; |
| 1297 | 1297 | } |
| 1298 | 1298 | } |
| 1299 | - if (!$Connection->checkColumnName('accidents','airline_icao')) { |
|
| 1299 | + if (!$Connection->checkColumnName('accidents', 'airline_icao')) { |
|
| 1300 | 1300 | // Add airline_icao to accidents |
| 1301 | 1301 | $query = "ALTER TABLE accidents ADD airline_icao VARCHAR(10) NULL"; |
| 1302 | 1302 | try { |
| 1303 | 1303 | $sth = $Connection->db->prepare($query); |
| 1304 | 1304 | $sth->execute(); |
| 1305 | - } catch(PDOException $e) { |
|
| 1305 | + } catch (PDOException $e) { |
|
| 1306 | 1306 | return "error (add airline_icao column in accidents) : ".$e->getMessage()."\n"; |
| 1307 | 1307 | } |
| 1308 | 1308 | } |
@@ -1310,7 +1310,7 @@ discard block |
||
| 1310 | 1310 | try { |
| 1311 | 1311 | $sth = $Connection->db->prepare($query); |
| 1312 | 1312 | $sth->execute(); |
| 1313 | - } catch(PDOException $e) { |
|
| 1313 | + } catch (PDOException $e) { |
|
| 1314 | 1314 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
| 1315 | 1315 | } |
| 1316 | 1316 | return $error; |
@@ -1320,13 +1320,13 @@ discard block |
||
| 1320 | 1320 | global $globalDBdriver, $globalVATSIM, $globalIVAO; |
| 1321 | 1321 | $Connection = new Connection(); |
| 1322 | 1322 | $error = ''; |
| 1323 | - if (!$Connection->checkColumnName('airlines','alliance')) { |
|
| 1323 | + if (!$Connection->checkColumnName('airlines', 'alliance')) { |
|
| 1324 | 1324 | // Add alliance to airlines |
| 1325 | 1325 | $query = "ALTER TABLE airlines ADD alliance VARCHAR(255) NULL"; |
| 1326 | 1326 | try { |
| 1327 | 1327 | $sth = $Connection->db->prepare($query); |
| 1328 | 1328 | $sth->execute(); |
| 1329 | - } catch(PDOException $e) { |
|
| 1329 | + } catch (PDOException $e) { |
|
| 1330 | 1330 | return "error (add alliance column in airlines) : ".$e->getMessage()."\n"; |
| 1331 | 1331 | } |
| 1332 | 1332 | } |
@@ -1353,7 +1353,7 @@ discard block |
||
| 1353 | 1353 | try { |
| 1354 | 1354 | $sth = $Connection->db->prepare($query); |
| 1355 | 1355 | $sth->execute(); |
| 1356 | - } catch(PDOException $e) { |
|
| 1356 | + } catch (PDOException $e) { |
|
| 1357 | 1357 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
| 1358 | 1358 | } |
| 1359 | 1359 | return $error; |
@@ -1363,13 +1363,13 @@ discard block |
||
| 1363 | 1363 | global $globalDBdriver, $globalVATSIM, $globalIVAO; |
| 1364 | 1364 | $Connection = new Connection(); |
| 1365 | 1365 | $error = ''; |
| 1366 | - if (!$Connection->checkColumnName('airlines','ban_eu')) { |
|
| 1366 | + if (!$Connection->checkColumnName('airlines', 'ban_eu')) { |
|
| 1367 | 1367 | // Add ban_eu to airlines |
| 1368 | 1368 | $query = "ALTER TABLE airlines ADD ban_eu INTEGER NOT NULL DEFAULT '0'"; |
| 1369 | 1369 | try { |
| 1370 | 1370 | $sth = $Connection->db->prepare($query); |
| 1371 | 1371 | $sth->execute(); |
| 1372 | - } catch(PDOException $e) { |
|
| 1372 | + } catch (PDOException $e) { |
|
| 1373 | 1373 | return "error (add ban_eu column in airlines) : ".$e->getMessage()."\n"; |
| 1374 | 1374 | } |
| 1375 | 1375 | } |
@@ -1377,7 +1377,7 @@ discard block |
||
| 1377 | 1377 | try { |
| 1378 | 1378 | $sth = $Connection->db->prepare($query); |
| 1379 | 1379 | $sth->execute(); |
| 1380 | - } catch(PDOException $e) { |
|
| 1380 | + } catch (PDOException $e) { |
|
| 1381 | 1381 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
| 1382 | 1382 | } |
| 1383 | 1383 | return $error; |
@@ -1388,19 +1388,19 @@ discard block |
||
| 1388 | 1388 | $Connection = new Connection(); |
| 1389 | 1389 | $error = ''; |
| 1390 | 1390 | if ($globalDBdriver == 'mysql') { |
| 1391 | - if ($Connection->getColumnType('spotter_output','date') == 'TIMESTAMP' && $Connection->getColumnType('spotter_output','last_seen') != 'TIMESTAMP') { |
|
| 1391 | + if ($Connection->getColumnType('spotter_output', 'date') == 'TIMESTAMP' && $Connection->getColumnType('spotter_output', 'last_seen') != 'TIMESTAMP') { |
|
| 1392 | 1392 | $query = "ALTER TABLE spotter_output CHANGE date date TIMESTAMP NULL DEFAULT NULL"; |
| 1393 | 1393 | try { |
| 1394 | 1394 | $sth = $Connection->db->prepare($query); |
| 1395 | 1395 | $sth->execute(); |
| 1396 | - } catch(PDOException $e) { |
|
| 1396 | + } catch (PDOException $e) { |
|
| 1397 | 1397 | return "error (delete default timestamp spotter_output) : ".$e->getMessage()."\n"; |
| 1398 | 1398 | } |
| 1399 | 1399 | $query = "ALTER TABLE spotter_output MODIFY COLUMN last_seen timestamp not null default current_timestamp()"; |
| 1400 | 1400 | try { |
| 1401 | 1401 | $sth = $Connection->db->prepare($query); |
| 1402 | 1402 | $sth->execute(); |
| 1403 | - } catch(PDOException $e) { |
|
| 1403 | + } catch (PDOException $e) { |
|
| 1404 | 1404 | return "error (convert spotter_output last_seen to timestamp) : ".$e->getMessage()."\n"; |
| 1405 | 1405 | } |
| 1406 | 1406 | |
@@ -1408,7 +1408,7 @@ discard block |
||
| 1408 | 1408 | try { |
| 1409 | 1409 | $sth = $Connection->db->prepare($query); |
| 1410 | 1410 | $sth->execute(); |
| 1411 | - } catch(PDOException $e) { |
|
| 1411 | + } catch (PDOException $e) { |
|
| 1412 | 1412 | return "error (delete default timestamp spotter_output) : ".$e->getMessage()."\n"; |
| 1413 | 1413 | } |
| 1414 | 1414 | /*$query = "SELECT date,last_seen FROM spotter_output WHERE last_seen < date ORDER BY date DESC LIMIT 150"; |
@@ -1459,7 +1459,7 @@ discard block |
||
| 1459 | 1459 | try { |
| 1460 | 1460 | $sth = $Connection->db->prepare($query); |
| 1461 | 1461 | $sth->execute(); |
| 1462 | - } catch(PDOException $e) { |
|
| 1462 | + } catch (PDOException $e) { |
|
| 1463 | 1463 | return "error (fix date) : ".$e->getMessage()."\n"; |
| 1464 | 1464 | } |
| 1465 | 1465 | } |
@@ -1544,7 +1544,7 @@ discard block |
||
| 1544 | 1544 | try { |
| 1545 | 1545 | $sth = $Connection->db->prepare($query); |
| 1546 | 1546 | $sth->execute(); |
| 1547 | - } catch(PDOException $e) { |
|
| 1547 | + } catch (PDOException $e) { |
|
| 1548 | 1548 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
| 1549 | 1549 | } |
| 1550 | 1550 | return $error; |
@@ -1553,13 +1553,13 @@ discard block |
||
| 1553 | 1553 | global $globalDBdriver; |
| 1554 | 1554 | $Connection = new Connection(); |
| 1555 | 1555 | $error = ''; |
| 1556 | - if (!$Connection->indexExists('accidents','type')) { |
|
| 1556 | + if (!$Connection->indexExists('accidents', 'type')) { |
|
| 1557 | 1557 | // Add index key |
| 1558 | 1558 | $query = "create index type on accidents (type,date)"; |
| 1559 | 1559 | try { |
| 1560 | 1560 | $sth = $Connection->db->prepare($query); |
| 1561 | 1561 | $sth->execute(); |
| 1562 | - } catch(PDOException $e) { |
|
| 1562 | + } catch (PDOException $e) { |
|
| 1563 | 1563 | return "error (add index type on accidents) : ".$e->getMessage()."\n"; |
| 1564 | 1564 | } |
| 1565 | 1565 | } |
@@ -1567,7 +1567,7 @@ discard block |
||
| 1567 | 1567 | try { |
| 1568 | 1568 | $sth = $Connection->db->prepare($query); |
| 1569 | 1569 | $sth->execute(); |
| 1570 | - } catch(PDOException $e) { |
|
| 1570 | + } catch (PDOException $e) { |
|
| 1571 | 1571 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
| 1572 | 1572 | } |
| 1573 | 1573 | return $error; |
@@ -1577,12 +1577,12 @@ discard block |
||
| 1577 | 1577 | global $globalDBdriver; |
| 1578 | 1578 | $Connection = new Connection(); |
| 1579 | 1579 | $error = ''; |
| 1580 | - if (!$Connection->checkColumnName('aircraft_modes','source_type')) { |
|
| 1580 | + if (!$Connection->checkColumnName('aircraft_modes', 'source_type')) { |
|
| 1581 | 1581 | $query = "ALTER TABLE aircraft_modes ADD source_type VARCHAR(255) DEFAULT 'modes'"; |
| 1582 | 1582 | try { |
| 1583 | 1583 | $sth = $Connection->db->prepare($query); |
| 1584 | 1584 | $sth->execute(); |
| 1585 | - } catch(PDOException $e) { |
|
| 1585 | + } catch (PDOException $e) { |
|
| 1586 | 1586 | return "error (add source_type column in aircraft_modes) : ".$e->getMessage()."\n"; |
| 1587 | 1587 | } |
| 1588 | 1588 | } |
@@ -1648,7 +1648,7 @@ discard block |
||
| 1648 | 1648 | try { |
| 1649 | 1649 | $sth = $Connection->db->prepare($query); |
| 1650 | 1650 | $sth->execute(); |
| 1651 | - } catch(PDOException $e) { |
|
| 1651 | + } catch (PDOException $e) { |
|
| 1652 | 1652 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
| 1653 | 1653 | } |
| 1654 | 1654 | return $error; |
@@ -1691,13 +1691,13 @@ discard block |
||
| 1691 | 1691 | $error .= create_db::import_file('../db/pgsql/tracker_archive_output.sql'); |
| 1692 | 1692 | if ($error != '') return $error; |
| 1693 | 1693 | } |
| 1694 | - if (!$Connection->indexExists('spotter_archive','flightaware_id_date_idx') && !$Connection->indexExists('spotter_archive','flightaware_id')) { |
|
| 1694 | + if (!$Connection->indexExists('spotter_archive', 'flightaware_id_date_idx') && !$Connection->indexExists('spotter_archive', 'flightaware_id')) { |
|
| 1695 | 1695 | // Add index key |
| 1696 | 1696 | $query = "create index flightaware_id_date_idx on spotter_archive (flightaware_id,date)"; |
| 1697 | 1697 | try { |
| 1698 | 1698 | $sth = $Connection->db->prepare($query); |
| 1699 | 1699 | $sth->execute(); |
| 1700 | - } catch(PDOException $e) { |
|
| 1700 | + } catch (PDOException $e) { |
|
| 1701 | 1701 | return "error (add index flightaware_id, date on spotter_archive) : ".$e->getMessage()."\n"; |
| 1702 | 1702 | } |
| 1703 | 1703 | } |
@@ -1705,7 +1705,7 @@ discard block |
||
| 1705 | 1705 | try { |
| 1706 | 1706 | $sth = $Connection->db->prepare($query); |
| 1707 | 1707 | $sth->execute(); |
| 1708 | - } catch(PDOException $e) { |
|
| 1708 | + } catch (PDOException $e) { |
|
| 1709 | 1709 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
| 1710 | 1710 | } |
| 1711 | 1711 | return $error; |
@@ -1716,148 +1716,148 @@ discard block |
||
| 1716 | 1716 | $Connection = new Connection(); |
| 1717 | 1717 | $error = ''; |
| 1718 | 1718 | if ($globalDBdriver == 'mysql') { |
| 1719 | - if (!$Connection->checkColumnName('marine_output','type_id')) { |
|
| 1719 | + if (!$Connection->checkColumnName('marine_output', 'type_id')) { |
|
| 1720 | 1720 | $query = "ALTER TABLE marine_output ADD COLUMN type_id int(11) DEFAULT NULL"; |
| 1721 | 1721 | try { |
| 1722 | 1722 | $sth = $Connection->db->prepare($query); |
| 1723 | 1723 | $sth->execute(); |
| 1724 | - } catch(PDOException $e) { |
|
| 1724 | + } catch (PDOException $e) { |
|
| 1725 | 1725 | return "error (add column type_id in marine_output) : ".$e->getMessage()."\n"; |
| 1726 | 1726 | } |
| 1727 | 1727 | } |
| 1728 | - if (!$Connection->checkColumnName('marine_live','type_id')) { |
|
| 1728 | + if (!$Connection->checkColumnName('marine_live', 'type_id')) { |
|
| 1729 | 1729 | $query = "ALTER TABLE marine_live ADD COLUMN type_id int(11) DEFAULT NULL"; |
| 1730 | 1730 | try { |
| 1731 | 1731 | $sth = $Connection->db->prepare($query); |
| 1732 | 1732 | $sth->execute(); |
| 1733 | - } catch(PDOException $e) { |
|
| 1733 | + } catch (PDOException $e) { |
|
| 1734 | 1734 | return "error (add column type_id in marine_live) : ".$e->getMessage()."\n"; |
| 1735 | 1735 | } |
| 1736 | 1736 | } |
| 1737 | - if (!$Connection->checkColumnName('marine_archive','type_id')) { |
|
| 1737 | + if (!$Connection->checkColumnName('marine_archive', 'type_id')) { |
|
| 1738 | 1738 | $query = "ALTER TABLE marine_archive ADD COLUMN type_id int(11) DEFAULT NULL"; |
| 1739 | 1739 | try { |
| 1740 | 1740 | $sth = $Connection->db->prepare($query); |
| 1741 | 1741 | $sth->execute(); |
| 1742 | - } catch(PDOException $e) { |
|
| 1742 | + } catch (PDOException $e) { |
|
| 1743 | 1743 | return "error (add column type_id in marine_archive) : ".$e->getMessage()."\n"; |
| 1744 | 1744 | } |
| 1745 | 1745 | } |
| 1746 | - if (!$Connection->checkColumnName('marine_archive_output','type_id')) { |
|
| 1746 | + if (!$Connection->checkColumnName('marine_archive_output', 'type_id')) { |
|
| 1747 | 1747 | $query = "ALTER TABLE marine_archive_output ADD COLUMN type_id int(11) DEFAULT NULL"; |
| 1748 | 1748 | try { |
| 1749 | 1749 | $sth = $Connection->db->prepare($query); |
| 1750 | 1750 | $sth->execute(); |
| 1751 | - } catch(PDOException $e) { |
|
| 1751 | + } catch (PDOException $e) { |
|
| 1752 | 1752 | return "error (add column type_id in marine_archive_output) : ".$e->getMessage()."\n"; |
| 1753 | 1753 | } |
| 1754 | 1754 | } |
| 1755 | - if (!$Connection->checkColumnName('marine_output','status_id')) { |
|
| 1755 | + if (!$Connection->checkColumnName('marine_output', 'status_id')) { |
|
| 1756 | 1756 | $query = "ALTER TABLE marine_output ADD COLUMN status_id int(11) DEFAULT NULL"; |
| 1757 | 1757 | try { |
| 1758 | 1758 | $sth = $Connection->db->prepare($query); |
| 1759 | 1759 | $sth->execute(); |
| 1760 | - } catch(PDOException $e) { |
|
| 1760 | + } catch (PDOException $e) { |
|
| 1761 | 1761 | return "error (add column status_id in marine_output) : ".$e->getMessage()."\n"; |
| 1762 | 1762 | } |
| 1763 | 1763 | } |
| 1764 | - if (!$Connection->checkColumnName('marine_live','status_id')) { |
|
| 1764 | + if (!$Connection->checkColumnName('marine_live', 'status_id')) { |
|
| 1765 | 1765 | $query = "ALTER TABLE marine_live ADD COLUMN status_id int(11) DEFAULT NULL"; |
| 1766 | 1766 | try { |
| 1767 | 1767 | $sth = $Connection->db->prepare($query); |
| 1768 | 1768 | $sth->execute(); |
| 1769 | - } catch(PDOException $e) { |
|
| 1769 | + } catch (PDOException $e) { |
|
| 1770 | 1770 | return "error (add column status_id in marine_live) : ".$e->getMessage()."\n"; |
| 1771 | 1771 | } |
| 1772 | 1772 | } |
| 1773 | - if (!$Connection->checkColumnName('marine_archive','status_id')) { |
|
| 1773 | + if (!$Connection->checkColumnName('marine_archive', 'status_id')) { |
|
| 1774 | 1774 | $query = "ALTER TABLE marine_archive ADD COLUMN status_id int(11) DEFAULT NULL"; |
| 1775 | 1775 | try { |
| 1776 | 1776 | $sth = $Connection->db->prepare($query); |
| 1777 | 1777 | $sth->execute(); |
| 1778 | - } catch(PDOException $e) { |
|
| 1778 | + } catch (PDOException $e) { |
|
| 1779 | 1779 | return "error (add column status_id in marine_archive) : ".$e->getMessage()."\n"; |
| 1780 | 1780 | } |
| 1781 | 1781 | } |
| 1782 | - if (!$Connection->checkColumnName('marine_archive_output','status_id')) { |
|
| 1782 | + if (!$Connection->checkColumnName('marine_archive_output', 'status_id')) { |
|
| 1783 | 1783 | $query = "ALTER TABLE marine_archive_output ADD COLUMN status_id int(11) DEFAULT NULL"; |
| 1784 | 1784 | try { |
| 1785 | 1785 | $sth = $Connection->db->prepare($query); |
| 1786 | 1786 | $sth->execute(); |
| 1787 | - } catch(PDOException $e) { |
|
| 1787 | + } catch (PDOException $e) { |
|
| 1788 | 1788 | return "error (add column status_id in marine_archive_output) : ".$e->getMessage()."\n"; |
| 1789 | 1789 | } |
| 1790 | 1790 | } |
| 1791 | 1791 | } else { |
| 1792 | - if (!$Connection->checkColumnName('marine_output','type_id')) { |
|
| 1792 | + if (!$Connection->checkColumnName('marine_output', 'type_id')) { |
|
| 1793 | 1793 | $query = "ALTER TABLE marine_output ADD COLUMN type_id integer DEFAULT NULL"; |
| 1794 | 1794 | try { |
| 1795 | 1795 | $sth = $Connection->db->prepare($query); |
| 1796 | 1796 | $sth->execute(); |
| 1797 | - } catch(PDOException $e) { |
|
| 1797 | + } catch (PDOException $e) { |
|
| 1798 | 1798 | return "error (add column type_id in marine_output) : ".$e->getMessage()."\n"; |
| 1799 | 1799 | } |
| 1800 | 1800 | } |
| 1801 | - if (!$Connection->checkColumnName('marine_live','type_id')) { |
|
| 1801 | + if (!$Connection->checkColumnName('marine_live', 'type_id')) { |
|
| 1802 | 1802 | $query = "ALTER TABLE marine_live ADD COLUMN type_id integer DEFAULT NULL"; |
| 1803 | 1803 | try { |
| 1804 | 1804 | $sth = $Connection->db->prepare($query); |
| 1805 | 1805 | $sth->execute(); |
| 1806 | - } catch(PDOException $e) { |
|
| 1806 | + } catch (PDOException $e) { |
|
| 1807 | 1807 | return "error (add column type_id in marine_live) : ".$e->getMessage()."\n"; |
| 1808 | 1808 | } |
| 1809 | 1809 | } |
| 1810 | - if (!$Connection->checkColumnName('marine_archive','type_id')) { |
|
| 1810 | + if (!$Connection->checkColumnName('marine_archive', 'type_id')) { |
|
| 1811 | 1811 | $query = "ALTER TABLE marine_archive ADD COLUMN type_id integer DEFAULT NULL"; |
| 1812 | 1812 | try { |
| 1813 | 1813 | $sth = $Connection->db->prepare($query); |
| 1814 | 1814 | $sth->execute(); |
| 1815 | - } catch(PDOException $e) { |
|
| 1815 | + } catch (PDOException $e) { |
|
| 1816 | 1816 | return "error (add column type_id in marine_archive) : ".$e->getMessage()."\n"; |
| 1817 | 1817 | } |
| 1818 | 1818 | } |
| 1819 | - if (!$Connection->checkColumnName('marine_archive_output','type_id')) { |
|
| 1819 | + if (!$Connection->checkColumnName('marine_archive_output', 'type_id')) { |
|
| 1820 | 1820 | $query = "ALTER TABLE marine_archive_output ADD COLUMN type_id integer DEFAULT NULL"; |
| 1821 | 1821 | try { |
| 1822 | 1822 | $sth = $Connection->db->prepare($query); |
| 1823 | 1823 | $sth->execute(); |
| 1824 | - } catch(PDOException $e) { |
|
| 1824 | + } catch (PDOException $e) { |
|
| 1825 | 1825 | return "error (add column type_id in marine_archive_output) : ".$e->getMessage()."\n"; |
| 1826 | 1826 | } |
| 1827 | 1827 | } |
| 1828 | - if (!$Connection->checkColumnName('marine_output','status_id')) { |
|
| 1828 | + if (!$Connection->checkColumnName('marine_output', 'status_id')) { |
|
| 1829 | 1829 | $query = "ALTER TABLE marine_output ADD COLUMN status_id integer DEFAULT NULL"; |
| 1830 | 1830 | try { |
| 1831 | 1831 | $sth = $Connection->db->prepare($query); |
| 1832 | 1832 | $sth->execute(); |
| 1833 | - } catch(PDOException $e) { |
|
| 1833 | + } catch (PDOException $e) { |
|
| 1834 | 1834 | return "error (add column status_id in marine_output) : ".$e->getMessage()."\n"; |
| 1835 | 1835 | } |
| 1836 | 1836 | } |
| 1837 | - if (!$Connection->checkColumnName('marine_live','status_id')) { |
|
| 1837 | + if (!$Connection->checkColumnName('marine_live', 'status_id')) { |
|
| 1838 | 1838 | $query = "ALTER TABLE marine_live ADD COLUMN status_id integer DEFAULT NULL"; |
| 1839 | 1839 | try { |
| 1840 | 1840 | $sth = $Connection->db->prepare($query); |
| 1841 | 1841 | $sth->execute(); |
| 1842 | - } catch(PDOException $e) { |
|
| 1842 | + } catch (PDOException $e) { |
|
| 1843 | 1843 | return "error (add column status_id in marine_live) : ".$e->getMessage()."\n"; |
| 1844 | 1844 | } |
| 1845 | 1845 | } |
| 1846 | - if (!$Connection->checkColumnName('marine_archive','status_id')) { |
|
| 1846 | + if (!$Connection->checkColumnName('marine_archive', 'status_id')) { |
|
| 1847 | 1847 | $query = "ALTER TABLE marine_archive ADD COLUMN status_id integer DEFAULT NULL"; |
| 1848 | 1848 | try { |
| 1849 | 1849 | $sth = $Connection->db->prepare($query); |
| 1850 | 1850 | $sth->execute(); |
| 1851 | - } catch(PDOException $e) { |
|
| 1851 | + } catch (PDOException $e) { |
|
| 1852 | 1852 | return "error (add column status_id in marine_archive) : ".$e->getMessage()."\n"; |
| 1853 | 1853 | } |
| 1854 | 1854 | } |
| 1855 | - if (!$Connection->checkColumnName('marine_archive_output','status_id')) { |
|
| 1855 | + if (!$Connection->checkColumnName('marine_archive_output', 'status_id')) { |
|
| 1856 | 1856 | $query = "ALTER TABLE marine_archive_output ADD COLUMN status_id integer DEFAULT NULL"; |
| 1857 | 1857 | try { |
| 1858 | 1858 | $sth = $Connection->db->prepare($query); |
| 1859 | 1859 | $sth->execute(); |
| 1860 | - } catch(PDOException $e) { |
|
| 1860 | + } catch (PDOException $e) { |
|
| 1861 | 1861 | return "error (add column status_id in marine_archive_output) : ".$e->getMessage()."\n"; |
| 1862 | 1862 | } |
| 1863 | 1863 | } |
@@ -1866,7 +1866,7 @@ discard block |
||
| 1866 | 1866 | try { |
| 1867 | 1867 | $sth = $Connection->db->prepare($query); |
| 1868 | 1868 | $sth->execute(); |
| 1869 | - } catch(PDOException $e) { |
|
| 1869 | + } catch (PDOException $e) { |
|
| 1870 | 1870 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
| 1871 | 1871 | } |
| 1872 | 1872 | return $error; |
@@ -1888,7 +1888,7 @@ discard block |
||
| 1888 | 1888 | try { |
| 1889 | 1889 | $sth = $Connection->db->prepare($query); |
| 1890 | 1890 | $sth->execute(); |
| 1891 | - } catch(PDOException $e) { |
|
| 1891 | + } catch (PDOException $e) { |
|
| 1892 | 1892 | return "error : ".$e->getMessage()."\n"; |
| 1893 | 1893 | } |
| 1894 | 1894 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -258,7 +258,9 @@ discard block |
||
| 258 | 258 | // Update table countries |
| 259 | 259 | if ($Connection->tableExists('airspace')) { |
| 260 | 260 | $error .= update_db::update_countries(); |
| 261 | - if ($error != '') return $error; |
|
| 261 | + if ($error != '') { |
|
| 262 | + return $error; |
|
| 263 | + } |
|
| 262 | 264 | } |
| 263 | 265 | // Update schema_version to 7 |
| 264 | 266 | $query = "UPDATE `config` SET `value` = '7' WHERE `name` = 'schema_version'"; |
@@ -314,7 +316,9 @@ discard block |
||
| 314 | 316 | $error = ''; |
| 315 | 317 | // Update table aircraft |
| 316 | 318 | $error .= create_db::import_file('../db/source_location.sql'); |
| 317 | - if ($error != '') return $error; |
|
| 319 | + if ($error != '') { |
|
| 320 | + return $error; |
|
| 321 | + } |
|
| 318 | 322 | // Update schema_version to 6 |
| 319 | 323 | $query = "UPDATE `config` SET `value` = '8' WHERE `name` = 'schema_version'"; |
| 320 | 324 | try { |
@@ -331,7 +335,9 @@ discard block |
||
| 331 | 335 | $error = ''; |
| 332 | 336 | // Update table aircraft |
| 333 | 337 | $error .= create_db::import_file('../db/notam.sql'); |
| 334 | - if ($error != '') return $error; |
|
| 338 | + if ($error != '') { |
|
| 339 | + return $error; |
|
| 340 | + } |
|
| 335 | 341 | $query = "DELETE FROM config WHERE name = 'last_update_db'; |
| 336 | 342 | INSERT INTO config (name,value) VALUES ('last_update_db',NOW()); |
| 337 | 343 | DELETE FROM config WHERE name = 'last_update_notam_db'; |
@@ -365,7 +371,9 @@ discard block |
||
| 365 | 371 | $error = ''; |
| 366 | 372 | // Update table atc |
| 367 | 373 | $error .= create_db::import_file('../db/atc.sql'); |
| 368 | - if ($error != '') return $error; |
|
| 374 | + if ($error != '') { |
|
| 375 | + return $error; |
|
| 376 | + } |
|
| 369 | 377 | |
| 370 | 378 | $query = "UPDATE `config` SET `value` = '10' WHERE `name` = 'schema_version'"; |
| 371 | 379 | try { |
@@ -389,13 +397,21 @@ discard block |
||
| 389 | 397 | $error = ''; |
| 390 | 398 | // Add tables |
| 391 | 399 | $error .= create_db::import_file('../db/aircraft_owner.sql'); |
| 392 | - if ($error != '') return $error; |
|
| 400 | + if ($error != '') { |
|
| 401 | + return $error; |
|
| 402 | + } |
|
| 393 | 403 | $error .= create_db::import_file('../db/metar.sql'); |
| 394 | - if ($error != '') return $error; |
|
| 404 | + if ($error != '') { |
|
| 405 | + return $error; |
|
| 406 | + } |
|
| 395 | 407 | $error .= create_db::import_file('../db/taf.sql'); |
| 396 | - if ($error != '') return $error; |
|
| 408 | + if ($error != '') { |
|
| 409 | + return $error; |
|
| 410 | + } |
|
| 397 | 411 | $error .= create_db::import_file('../db/airport.sql'); |
| 398 | - if ($error != '') return $error; |
|
| 412 | + if ($error != '') { |
|
| 413 | + return $error; |
|
| 414 | + } |
|
| 399 | 415 | |
| 400 | 416 | $query = "UPDATE `config` SET `value` = '11' WHERE `name` = 'schema_version'"; |
| 401 | 417 | try { |
@@ -469,19 +485,33 @@ discard block |
||
| 469 | 485 | $error = ''; |
| 470 | 486 | // Add tables |
| 471 | 487 | $error .= create_db::import_file('../db/stats.sql'); |
| 472 | - if ($error != '') return $error; |
|
| 488 | + if ($error != '') { |
|
| 489 | + return $error; |
|
| 490 | + } |
|
| 473 | 491 | $error .= create_db::import_file('../db/stats_aircraft.sql'); |
| 474 | - if ($error != '') return $error; |
|
| 492 | + if ($error != '') { |
|
| 493 | + return $error; |
|
| 494 | + } |
|
| 475 | 495 | $error .= create_db::import_file('../db/stats_airline.sql'); |
| 476 | - if ($error != '') return $error; |
|
| 496 | + if ($error != '') { |
|
| 497 | + return $error; |
|
| 498 | + } |
|
| 477 | 499 | $error .= create_db::import_file('../db/stats_airport.sql'); |
| 478 | - if ($error != '') return $error; |
|
| 500 | + if ($error != '') { |
|
| 501 | + return $error; |
|
| 502 | + } |
|
| 479 | 503 | $error .= create_db::import_file('../db/stats_owner.sql'); |
| 480 | - if ($error != '') return $error; |
|
| 504 | + if ($error != '') { |
|
| 505 | + return $error; |
|
| 506 | + } |
|
| 481 | 507 | $error .= create_db::import_file('../db/stats_pilot.sql'); |
| 482 | - if ($error != '') return $error; |
|
| 508 | + if ($error != '') { |
|
| 509 | + return $error; |
|
| 510 | + } |
|
| 483 | 511 | $error .= create_db::import_file('../db/spotter_archive_output.sql'); |
| 484 | - if ($error != '') return $error; |
|
| 512 | + if ($error != '') { |
|
| 513 | + return $error; |
|
| 514 | + } |
|
| 485 | 515 | |
| 486 | 516 | $query = "UPDATE `config` SET `value` = '13' WHERE `name` = 'schema_version'"; |
| 487 | 517 | try { |
@@ -521,7 +551,9 @@ discard block |
||
| 521 | 551 | // Add tables |
| 522 | 552 | if (!$Connection->tableExists('stats_flight')) { |
| 523 | 553 | $error .= create_db::import_file('../db/stats_flight.sql'); |
| 524 | - if ($error != '') return $error; |
|
| 554 | + if ($error != '') { |
|
| 555 | + return $error; |
|
| 556 | + } |
|
| 525 | 557 | } |
| 526 | 558 | $query = "UPDATE `config` SET `value` = '15' WHERE `name` = 'schema_version'"; |
| 527 | 559 | try { |
@@ -545,7 +577,9 @@ discard block |
||
| 545 | 577 | } catch(PDOException $e) { |
| 546 | 578 | return "error (update stats) : ".$e->getMessage()."\n"; |
| 547 | 579 | } |
| 548 | - if ($error != '') return $error; |
|
| 580 | + if ($error != '') { |
|
| 581 | + return $error; |
|
| 582 | + } |
|
| 549 | 583 | $query = "UPDATE `config` SET `value` = '16' WHERE `name` = 'schema_version'"; |
| 550 | 584 | try { |
| 551 | 585 | $sth = $Connection->db->prepare($query); |
@@ -566,7 +600,9 @@ discard block |
||
| 566 | 600 | if (!$Connection->tableExists('stats_callsign')) { |
| 567 | 601 | $error .= create_db::import_file('../db/stats_callsign.sql'); |
| 568 | 602 | } |
| 569 | - if ($error != '') return $error; |
|
| 603 | + if ($error != '') { |
|
| 604 | + return $error; |
|
| 605 | + } |
|
| 570 | 606 | $query = "UPDATE `config` SET `value` = '17' WHERE `name` = 'schema_version'"; |
| 571 | 607 | try { |
| 572 | 608 | $sth = $Connection->db->prepare($query); |
@@ -584,7 +620,9 @@ discard block |
||
| 584 | 620 | if (!$Connection->tableExists('stats_country')) { |
| 585 | 621 | $error .= create_db::import_file('../db/stats_country.sql'); |
| 586 | 622 | } |
| 587 | - if ($error != '') return $error; |
|
| 623 | + if ($error != '') { |
|
| 624 | + return $error; |
|
| 625 | + } |
|
| 588 | 626 | $query = "UPDATE `config` SET `value` = '18' WHERE `name` = 'schema_version'"; |
| 589 | 627 | try { |
| 590 | 628 | $sth = $Connection->db->prepare($query); |
@@ -607,7 +645,9 @@ discard block |
||
| 607 | 645 | return "error (update stats) : ".$e->getMessage()."\n"; |
| 608 | 646 | } |
| 609 | 647 | } |
| 610 | - if ($error != '') return $error; |
|
| 648 | + if ($error != '') { |
|
| 649 | + return $error; |
|
| 650 | + } |
|
| 611 | 651 | $query = "UPDATE `config` SET `value` = '19' WHERE `name` = 'schema_version'"; |
| 612 | 652 | try { |
| 613 | 653 | $sth = $Connection->db->prepare($query); |
@@ -623,7 +663,9 @@ discard block |
||
| 623 | 663 | $error = ''; |
| 624 | 664 | // Update airport table |
| 625 | 665 | $error .= create_db::import_file('../db/airport.sql'); |
| 626 | - if ($error != '') return 'Import airport.sql : '.$error; |
|
| 666 | + if ($error != '') { |
|
| 667 | + return 'Import airport.sql : '.$error; |
|
| 668 | + } |
|
| 627 | 669 | // Remove primary key on Spotter_Archive |
| 628 | 670 | $query = "alter table spotter_archive drop spotter_archive_id"; |
| 629 | 671 | try { |
@@ -699,7 +741,9 @@ discard block |
||
| 699 | 741 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
| 700 | 742 | } |
| 701 | 743 | } |
| 702 | - if ($error != '') return $error; |
|
| 744 | + if ($error != '') { |
|
| 745 | + return $error; |
|
| 746 | + } |
|
| 703 | 747 | $query = "UPDATE `config` SET `value` = '20' WHERE `name` = 'schema_version'"; |
| 704 | 748 | try { |
| 705 | 749 | $sth = $Connection->db->prepare($query); |
@@ -717,7 +761,9 @@ discard block |
||
| 717 | 761 | // Update airline table |
| 718 | 762 | if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) { |
| 719 | 763 | $error .= create_db::import_file('../db/airlines.sql'); |
| 720 | - if ($error != '') return 'Import airlines.sql : '.$error; |
|
| 764 | + if ($error != '') { |
|
| 765 | + return 'Import airlines.sql : '.$error; |
|
| 766 | + } |
|
| 721 | 767 | } |
| 722 | 768 | if (!$Connection->checkColumnName('aircraft_modes','type_flight')) { |
| 723 | 769 | // Add column over_country |
@@ -729,7 +775,9 @@ discard block |
||
| 729 | 775 | return "error (add over_country) : ".$e->getMessage()."\n"; |
| 730 | 776 | } |
| 731 | 777 | } |
| 732 | - if ($error != '') return $error; |
|
| 778 | + if ($error != '') { |
|
| 779 | + return $error; |
|
| 780 | + } |
|
| 733 | 781 | /* |
| 734 | 782 | if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) { |
| 735 | 783 | // Force update ModeS (this will put type_flight data |
@@ -759,7 +807,9 @@ discard block |
||
| 759 | 807 | } catch(PDOException $e) { |
| 760 | 808 | return "error (rename type to stats_type on stats*) : ".$e->getMessage()."\n"; |
| 761 | 809 | } |
| 762 | - if ($error != '') return $error; |
|
| 810 | + if ($error != '') { |
|
| 811 | + return $error; |
|
| 812 | + } |
|
| 763 | 813 | } |
| 764 | 814 | $query = "UPDATE `config` SET `value` = '22' WHERE `name` = 'schema_version'"; |
| 765 | 815 | try { |
@@ -782,7 +832,9 @@ discard block |
||
| 782 | 832 | } else { |
| 783 | 833 | $error .= create_db::import_file('../db/pgsql/stats_source.sql'); |
| 784 | 834 | } |
| 785 | - if ($error != '') return $error; |
|
| 835 | + if ($error != '') { |
|
| 836 | + return $error; |
|
| 837 | + } |
|
| 786 | 838 | } |
| 787 | 839 | $query = "UPDATE config SET value = '23' WHERE name = 'schema_version'"; |
| 788 | 840 | try { |
@@ -804,12 +856,16 @@ discard block |
||
| 804 | 856 | if ($globalDBdriver == 'mysql') { |
| 805 | 857 | if (!$Connection->tableExists('tle')) { |
| 806 | 858 | $error .= create_db::import_file('../db/tle.sql'); |
| 807 | - if ($error != '') return $error; |
|
| 859 | + if ($error != '') { |
|
| 860 | + return $error; |
|
| 861 | + } |
|
| 808 | 862 | } |
| 809 | 863 | } else { |
| 810 | 864 | if (!$Connection->tableExists('tle')) { |
| 811 | 865 | $error .= create_db::import_file('../db/pgsql/tle.sql'); |
| 812 | - if ($error != '') return $error; |
|
| 866 | + if ($error != '') { |
|
| 867 | + return $error; |
|
| 868 | + } |
|
| 813 | 869 | } |
| 814 | 870 | $query = "create index flightaware_id_idx ON spotter_archive USING btree(flightaware_id)"; |
| 815 | 871 | try { |
@@ -849,7 +905,9 @@ discard block |
||
| 849 | 905 | } else { |
| 850 | 906 | $error .= create_db::import_file('../db/pgsql/airlines.sql'); |
| 851 | 907 | } |
| 852 | - if ($error != '') return 'Import airlines.sql : '.$error; |
|
| 908 | + if ($error != '') { |
|
| 909 | + return 'Import airlines.sql : '.$error; |
|
| 910 | + } |
|
| 853 | 911 | if (!$Connection->checkColumnName('airlines','forsource')) { |
| 854 | 912 | // Add forsource to airlines |
| 855 | 913 | $query = "ALTER TABLE airlines ADD forsource VARCHAR(255) NULL DEFAULT NULL"; |
@@ -1332,20 +1390,28 @@ discard block |
||
| 1332 | 1390 | } |
| 1333 | 1391 | if ($globalDBdriver == 'mysql') { |
| 1334 | 1392 | $error .= create_db::import_file('../db/airlines.sql'); |
| 1335 | - if ($error != '') return $error; |
|
| 1393 | + if ($error != '') { |
|
| 1394 | + return $error; |
|
| 1395 | + } |
|
| 1336 | 1396 | } else { |
| 1337 | 1397 | $error .= create_db::import_file('../db/pgsql/airlines.sql'); |
| 1338 | - if ($error != '') return $error; |
|
| 1398 | + if ($error != '') { |
|
| 1399 | + return $error; |
|
| 1400 | + } |
|
| 1339 | 1401 | } |
| 1340 | 1402 | if ((isset($globalVATSIM) && $globalVATSIM) || (isset($globalIVAO) && $globalIVAO)) { |
| 1341 | 1403 | include_once(dirname(__FILE__).'/class.update_db.php'); |
| 1342 | 1404 | if (isset($globalVATSIM) && $globalVATSIM) { |
| 1343 | 1405 | $error .= update_db::update_vatsim(); |
| 1344 | - if ($error != '') return $error; |
|
| 1406 | + if ($error != '') { |
|
| 1407 | + return $error; |
|
| 1408 | + } |
|
| 1345 | 1409 | } |
| 1346 | 1410 | if (isset($globalIVAO) && $globalIVAO && file_exists('tmp/ivae_feb2013.zip')) { |
| 1347 | 1411 | $error .= update_db::update_IVAO(); |
| 1348 | - if ($error != '') return $error; |
|
| 1412 | + if ($error != '') { |
|
| 1413 | + return $error; |
|
| 1414 | + } |
|
| 1349 | 1415 | } |
| 1350 | 1416 | } |
| 1351 | 1417 | |
@@ -1608,41 +1674,65 @@ discard block |
||
| 1608 | 1674 | if ($globalDBdriver == 'mysql') { |
| 1609 | 1675 | if (!$Connection->tableExists('tracker_output')) { |
| 1610 | 1676 | $error .= create_db::import_file('../db/tracker_output.sql'); |
| 1611 | - if ($error != '') return $error; |
|
| 1677 | + if ($error != '') { |
|
| 1678 | + return $error; |
|
| 1679 | + } |
|
| 1612 | 1680 | } |
| 1613 | 1681 | if (!$Connection->tableExists('tracker_live')) { |
| 1614 | 1682 | $error .= create_db::import_file('../db/tracker_live.sql'); |
| 1615 | - if ($error != '') return $error; |
|
| 1683 | + if ($error != '') { |
|
| 1684 | + return $error; |
|
| 1685 | + } |
|
| 1616 | 1686 | } |
| 1617 | 1687 | if (!$Connection->tableExists('marine_output')) { |
| 1618 | 1688 | $error .= create_db::import_file('../db/marine_output.sql'); |
| 1619 | - if ($error != '') return $error; |
|
| 1689 | + if ($error != '') { |
|
| 1690 | + return $error; |
|
| 1691 | + } |
|
| 1620 | 1692 | } |
| 1621 | 1693 | if (!$Connection->tableExists('marine_live')) { |
| 1622 | 1694 | $error .= create_db::import_file('../db/marine_live.sql'); |
| 1623 | - if ($error != '') return $error; |
|
| 1695 | + if ($error != '') { |
|
| 1696 | + return $error; |
|
| 1697 | + } |
|
| 1624 | 1698 | } |
| 1625 | 1699 | if (!$Connection->tableExists('marine_identity')) { |
| 1626 | 1700 | $error .= create_db::import_file('../db/marine_identity.sql'); |
| 1627 | - if ($error != '') return $error; |
|
| 1701 | + if ($error != '') { |
|
| 1702 | + return $error; |
|
| 1703 | + } |
|
| 1628 | 1704 | } |
| 1629 | 1705 | if (!$Connection->tableExists('marine_mid')) { |
| 1630 | 1706 | $error .= create_db::import_file('../db/marine_mid.sql'); |
| 1631 | - if ($error != '') return $error; |
|
| 1707 | + if ($error != '') { |
|
| 1708 | + return $error; |
|
| 1709 | + } |
|
| 1632 | 1710 | } |
| 1633 | 1711 | } else { |
| 1634 | 1712 | $error .= create_db::import_file('../db/pgsql/tracker_output.sql'); |
| 1635 | - if ($error != '') return $error; |
|
| 1713 | + if ($error != '') { |
|
| 1714 | + return $error; |
|
| 1715 | + } |
|
| 1636 | 1716 | $error .= create_db::import_file('../db/pgsql/tracker_live.sql'); |
| 1637 | - if ($error != '') return $error; |
|
| 1717 | + if ($error != '') { |
|
| 1718 | + return $error; |
|
| 1719 | + } |
|
| 1638 | 1720 | $error .= create_db::import_file('../db/pgsql/marine_output.sql'); |
| 1639 | - if ($error != '') return $error; |
|
| 1721 | + if ($error != '') { |
|
| 1722 | + return $error; |
|
| 1723 | + } |
|
| 1640 | 1724 | $error .= create_db::import_file('../db/pgsql/marine_live.sql'); |
| 1641 | - if ($error != '') return $error; |
|
| 1725 | + if ($error != '') { |
|
| 1726 | + return $error; |
|
| 1727 | + } |
|
| 1642 | 1728 | $error .= create_db::import_file('../db/pgsql/marine_identity.sql'); |
| 1643 | - if ($error != '') return $error; |
|
| 1729 | + if ($error != '') { |
|
| 1730 | + return $error; |
|
| 1731 | + } |
|
| 1644 | 1732 | $error .= create_db::import_file('../db/pgsql/marine_mid.sql'); |
| 1645 | - if ($error != '') return $error; |
|
| 1733 | + if ($error != '') { |
|
| 1734 | + return $error; |
|
| 1735 | + } |
|
| 1646 | 1736 | } |
| 1647 | 1737 | $query = "UPDATE config SET value = '37' WHERE name = 'schema_version'"; |
| 1648 | 1738 | try { |
@@ -1661,35 +1751,55 @@ discard block |
||
| 1661 | 1751 | if ($globalDBdriver == 'mysql') { |
| 1662 | 1752 | if (!$Connection->tableExists('marine_image')) { |
| 1663 | 1753 | $error .= create_db::import_file('../db/marine_image.sql'); |
| 1664 | - if ($error != '') return $error; |
|
| 1754 | + if ($error != '') { |
|
| 1755 | + return $error; |
|
| 1756 | + } |
|
| 1665 | 1757 | } |
| 1666 | 1758 | if (!$Connection->tableExists('marine_archive')) { |
| 1667 | 1759 | $error .= create_db::import_file('../db/marine_archive.sql'); |
| 1668 | - if ($error != '') return $error; |
|
| 1760 | + if ($error != '') { |
|
| 1761 | + return $error; |
|
| 1762 | + } |
|
| 1669 | 1763 | } |
| 1670 | 1764 | if (!$Connection->tableExists('marine_archive_output')) { |
| 1671 | 1765 | $error .= create_db::import_file('../db/marine_archive_output.sql'); |
| 1672 | - if ($error != '') return $error; |
|
| 1766 | + if ($error != '') { |
|
| 1767 | + return $error; |
|
| 1768 | + } |
|
| 1673 | 1769 | } |
| 1674 | 1770 | if (!$Connection->tableExists('tracker_archive')) { |
| 1675 | 1771 | $error .= create_db::import_file('../db/tracker_archive.sql'); |
| 1676 | - if ($error != '') return $error; |
|
| 1772 | + if ($error != '') { |
|
| 1773 | + return $error; |
|
| 1774 | + } |
|
| 1677 | 1775 | } |
| 1678 | 1776 | if (!$Connection->tableExists('marine_archive_output')) { |
| 1679 | 1777 | $error .= create_db::import_file('../db/tracker_archive_output.sql'); |
| 1680 | - if ($error != '') return $error; |
|
| 1778 | + if ($error != '') { |
|
| 1779 | + return $error; |
|
| 1780 | + } |
|
| 1681 | 1781 | } |
| 1682 | 1782 | } else { |
| 1683 | 1783 | $error .= create_db::import_file('../db/pgsql/marine_image.sql'); |
| 1684 | - if ($error != '') return $error; |
|
| 1784 | + if ($error != '') { |
|
| 1785 | + return $error; |
|
| 1786 | + } |
|
| 1685 | 1787 | $error .= create_db::import_file('../db/pgsql/marine_archive.sql'); |
| 1686 | - if ($error != '') return $error; |
|
| 1788 | + if ($error != '') { |
|
| 1789 | + return $error; |
|
| 1790 | + } |
|
| 1687 | 1791 | $error .= create_db::import_file('../db/pgsql/marine_archive_output.sql'); |
| 1688 | - if ($error != '') return $error; |
|
| 1792 | + if ($error != '') { |
|
| 1793 | + return $error; |
|
| 1794 | + } |
|
| 1689 | 1795 | $error .= create_db::import_file('../db/pgsql/tracker_archive.sql'); |
| 1690 | - if ($error != '') return $error; |
|
| 1796 | + if ($error != '') { |
|
| 1797 | + return $error; |
|
| 1798 | + } |
|
| 1691 | 1799 | $error .= create_db::import_file('../db/pgsql/tracker_archive_output.sql'); |
| 1692 | - if ($error != '') return $error; |
|
| 1800 | + if ($error != '') { |
|
| 1801 | + return $error; |
|
| 1802 | + } |
|
| 1693 | 1803 | } |
| 1694 | 1804 | if (!$Connection->indexExists('spotter_archive','flightaware_id_date_idx') && !$Connection->indexExists('spotter_archive','flightaware_id')) { |
| 1695 | 1805 | // Add index key |
@@ -1880,8 +1990,11 @@ discard block |
||
| 1880 | 1990 | if ($Connection->tableExists('aircraft')) { |
| 1881 | 1991 | if (!$Connection->tableExists('config')) { |
| 1882 | 1992 | $version = '1'; |
| 1883 | - if ($update) return self::update_from_1(); |
|
| 1884 | - else return $version; |
|
| 1993 | + if ($update) { |
|
| 1994 | + return self::update_from_1(); |
|
| 1995 | + } else { |
|
| 1996 | + return $version; |
|
| 1997 | + } |
|
| 1885 | 1998 | } else { |
| 1886 | 1999 | $Connection = new Connection(); |
| 1887 | 2000 | $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1"; |
@@ -1895,158 +2008,274 @@ discard block |
||
| 1895 | 2008 | if ($update) { |
| 1896 | 2009 | if ($result['value'] == '2') { |
| 1897 | 2010 | $error = self::update_from_2(); |
| 1898 | - if ($error != '') return $error; |
|
| 1899 | - else return self::check_version(true); |
|
| 2011 | + if ($error != '') { |
|
| 2012 | + return $error; |
|
| 2013 | + } else { |
|
| 2014 | + return self::check_version(true); |
|
| 2015 | + } |
|
| 1900 | 2016 | } elseif ($result['value'] == '3') { |
| 1901 | 2017 | $error = self::update_from_3(); |
| 1902 | - if ($error != '') return $error; |
|
| 1903 | - else return self::check_version(true); |
|
| 2018 | + if ($error != '') { |
|
| 2019 | + return $error; |
|
| 2020 | + } else { |
|
| 2021 | + return self::check_version(true); |
|
| 2022 | + } |
|
| 1904 | 2023 | } elseif ($result['value'] == '4') { |
| 1905 | 2024 | $error = self::update_from_4(); |
| 1906 | - if ($error != '') return $error; |
|
| 1907 | - else return self::check_version(true); |
|
| 2025 | + if ($error != '') { |
|
| 2026 | + return $error; |
|
| 2027 | + } else { |
|
| 2028 | + return self::check_version(true); |
|
| 2029 | + } |
|
| 1908 | 2030 | } elseif ($result['value'] == '5') { |
| 1909 | 2031 | $error = self::update_from_5(); |
| 1910 | - if ($error != '') return $error; |
|
| 1911 | - else return self::check_version(true); |
|
| 2032 | + if ($error != '') { |
|
| 2033 | + return $error; |
|
| 2034 | + } else { |
|
| 2035 | + return self::check_version(true); |
|
| 2036 | + } |
|
| 1912 | 2037 | } elseif ($result['value'] == '6') { |
| 1913 | 2038 | $error = self::update_from_6(); |
| 1914 | - if ($error != '') return $error; |
|
| 1915 | - else return self::check_version(true); |
|
| 2039 | + if ($error != '') { |
|
| 2040 | + return $error; |
|
| 2041 | + } else { |
|
| 2042 | + return self::check_version(true); |
|
| 2043 | + } |
|
| 1916 | 2044 | } elseif ($result['value'] == '7') { |
| 1917 | 2045 | $error = self::update_from_7(); |
| 1918 | - if ($error != '') return $error; |
|
| 1919 | - else return self::check_version(true); |
|
| 2046 | + if ($error != '') { |
|
| 2047 | + return $error; |
|
| 2048 | + } else { |
|
| 2049 | + return self::check_version(true); |
|
| 2050 | + } |
|
| 1920 | 2051 | } elseif ($result['value'] == '8') { |
| 1921 | 2052 | $error = self::update_from_8(); |
| 1922 | - if ($error != '') return $error; |
|
| 1923 | - else return self::check_version(true); |
|
| 2053 | + if ($error != '') { |
|
| 2054 | + return $error; |
|
| 2055 | + } else { |
|
| 2056 | + return self::check_version(true); |
|
| 2057 | + } |
|
| 1924 | 2058 | } elseif ($result['value'] == '9') { |
| 1925 | 2059 | $error = self::update_from_9(); |
| 1926 | - if ($error != '') return $error; |
|
| 1927 | - else return self::check_version(true); |
|
| 2060 | + if ($error != '') { |
|
| 2061 | + return $error; |
|
| 2062 | + } else { |
|
| 2063 | + return self::check_version(true); |
|
| 2064 | + } |
|
| 1928 | 2065 | } elseif ($result['value'] == '10') { |
| 1929 | 2066 | $error = self::update_from_10(); |
| 1930 | - if ($error != '') return $error; |
|
| 1931 | - else return self::check_version(true); |
|
| 2067 | + if ($error != '') { |
|
| 2068 | + return $error; |
|
| 2069 | + } else { |
|
| 2070 | + return self::check_version(true); |
|
| 2071 | + } |
|
| 1932 | 2072 | } elseif ($result['value'] == '11') { |
| 1933 | 2073 | $error = self::update_from_11(); |
| 1934 | - if ($error != '') return $error; |
|
| 1935 | - else return self::check_version(true); |
|
| 2074 | + if ($error != '') { |
|
| 2075 | + return $error; |
|
| 2076 | + } else { |
|
| 2077 | + return self::check_version(true); |
|
| 2078 | + } |
|
| 1936 | 2079 | } elseif ($result['value'] == '12') { |
| 1937 | 2080 | $error = self::update_from_12(); |
| 1938 | - if ($error != '') return $error; |
|
| 1939 | - else return self::check_version(true); |
|
| 2081 | + if ($error != '') { |
|
| 2082 | + return $error; |
|
| 2083 | + } else { |
|
| 2084 | + return self::check_version(true); |
|
| 2085 | + } |
|
| 1940 | 2086 | } elseif ($result['value'] == '13') { |
| 1941 | 2087 | $error = self::update_from_13(); |
| 1942 | - if ($error != '') return $error; |
|
| 1943 | - else return self::check_version(true); |
|
| 2088 | + if ($error != '') { |
|
| 2089 | + return $error; |
|
| 2090 | + } else { |
|
| 2091 | + return self::check_version(true); |
|
| 2092 | + } |
|
| 1944 | 2093 | } elseif ($result['value'] == '14') { |
| 1945 | 2094 | $error = self::update_from_14(); |
| 1946 | - if ($error != '') return $error; |
|
| 1947 | - else return self::check_version(true); |
|
| 2095 | + if ($error != '') { |
|
| 2096 | + return $error; |
|
| 2097 | + } else { |
|
| 2098 | + return self::check_version(true); |
|
| 2099 | + } |
|
| 1948 | 2100 | } elseif ($result['value'] == '15') { |
| 1949 | 2101 | $error = self::update_from_15(); |
| 1950 | - if ($error != '') return $error; |
|
| 1951 | - else return self::check_version(true); |
|
| 2102 | + if ($error != '') { |
|
| 2103 | + return $error; |
|
| 2104 | + } else { |
|
| 2105 | + return self::check_version(true); |
|
| 2106 | + } |
|
| 1952 | 2107 | } elseif ($result['value'] == '16') { |
| 1953 | 2108 | $error = self::update_from_16(); |
| 1954 | - if ($error != '') return $error; |
|
| 1955 | - else return self::check_version(true); |
|
| 2109 | + if ($error != '') { |
|
| 2110 | + return $error; |
|
| 2111 | + } else { |
|
| 2112 | + return self::check_version(true); |
|
| 2113 | + } |
|
| 1956 | 2114 | } elseif ($result['value'] == '17') { |
| 1957 | 2115 | $error = self::update_from_17(); |
| 1958 | - if ($error != '') return $error; |
|
| 1959 | - else return self::check_version(true); |
|
| 2116 | + if ($error != '') { |
|
| 2117 | + return $error; |
|
| 2118 | + } else { |
|
| 2119 | + return self::check_version(true); |
|
| 2120 | + } |
|
| 1960 | 2121 | } elseif ($result['value'] == '18') { |
| 1961 | 2122 | $error = self::update_from_18(); |
| 1962 | - if ($error != '') return $error; |
|
| 1963 | - else return self::check_version(true); |
|
| 2123 | + if ($error != '') { |
|
| 2124 | + return $error; |
|
| 2125 | + } else { |
|
| 2126 | + return self::check_version(true); |
|
| 2127 | + } |
|
| 1964 | 2128 | } elseif ($result['value'] == '19') { |
| 1965 | 2129 | $error = self::update_from_19(); |
| 1966 | - if ($error != '') return $error; |
|
| 1967 | - else return self::check_version(true); |
|
| 2130 | + if ($error != '') { |
|
| 2131 | + return $error; |
|
| 2132 | + } else { |
|
| 2133 | + return self::check_version(true); |
|
| 2134 | + } |
|
| 1968 | 2135 | } elseif ($result['value'] == '20') { |
| 1969 | 2136 | $error = self::update_from_20(); |
| 1970 | - if ($error != '') return $error; |
|
| 1971 | - else return self::check_version(true); |
|
| 2137 | + if ($error != '') { |
|
| 2138 | + return $error; |
|
| 2139 | + } else { |
|
| 2140 | + return self::check_version(true); |
|
| 2141 | + } |
|
| 1972 | 2142 | } elseif ($result['value'] == '21') { |
| 1973 | 2143 | $error = self::update_from_21(); |
| 1974 | - if ($error != '') return $error; |
|
| 1975 | - else return self::check_version(true); |
|
| 2144 | + if ($error != '') { |
|
| 2145 | + return $error; |
|
| 2146 | + } else { |
|
| 2147 | + return self::check_version(true); |
|
| 2148 | + } |
|
| 1976 | 2149 | } elseif ($result['value'] == '22') { |
| 1977 | 2150 | $error = self::update_from_22(); |
| 1978 | - if ($error != '') return $error; |
|
| 1979 | - else return self::check_version(true); |
|
| 2151 | + if ($error != '') { |
|
| 2152 | + return $error; |
|
| 2153 | + } else { |
|
| 2154 | + return self::check_version(true); |
|
| 2155 | + } |
|
| 1980 | 2156 | } elseif ($result['value'] == '23') { |
| 1981 | 2157 | $error = self::update_from_23(); |
| 1982 | - if ($error != '') return $error; |
|
| 1983 | - else return self::check_version(true); |
|
| 2158 | + if ($error != '') { |
|
| 2159 | + return $error; |
|
| 2160 | + } else { |
|
| 2161 | + return self::check_version(true); |
|
| 2162 | + } |
|
| 1984 | 2163 | } elseif ($result['value'] == '24') { |
| 1985 | 2164 | $error = self::update_from_24(); |
| 1986 | - if ($error != '') return $error; |
|
| 1987 | - else return self::check_version(true); |
|
| 2165 | + if ($error != '') { |
|
| 2166 | + return $error; |
|
| 2167 | + } else { |
|
| 2168 | + return self::check_version(true); |
|
| 2169 | + } |
|
| 1988 | 2170 | } elseif ($result['value'] == '25') { |
| 1989 | 2171 | $error = self::update_from_25(); |
| 1990 | - if ($error != '') return $error; |
|
| 1991 | - else return self::check_version(true); |
|
| 2172 | + if ($error != '') { |
|
| 2173 | + return $error; |
|
| 2174 | + } else { |
|
| 2175 | + return self::check_version(true); |
|
| 2176 | + } |
|
| 1992 | 2177 | } elseif ($result['value'] == '26') { |
| 1993 | 2178 | $error = self::update_from_26(); |
| 1994 | - if ($error != '') return $error; |
|
| 1995 | - else return self::check_version(true); |
|
| 2179 | + if ($error != '') { |
|
| 2180 | + return $error; |
|
| 2181 | + } else { |
|
| 2182 | + return self::check_version(true); |
|
| 2183 | + } |
|
| 1996 | 2184 | } elseif ($result['value'] == '27') { |
| 1997 | 2185 | $error = self::update_from_27(); |
| 1998 | - if ($error != '') return $error; |
|
| 1999 | - else return self::check_version(true); |
|
| 2186 | + if ($error != '') { |
|
| 2187 | + return $error; |
|
| 2188 | + } else { |
|
| 2189 | + return self::check_version(true); |
|
| 2190 | + } |
|
| 2000 | 2191 | } elseif ($result['value'] == '28') { |
| 2001 | 2192 | $error = self::update_from_28(); |
| 2002 | - if ($error != '') return $error; |
|
| 2003 | - else return self::check_version(true); |
|
| 2193 | + if ($error != '') { |
|
| 2194 | + return $error; |
|
| 2195 | + } else { |
|
| 2196 | + return self::check_version(true); |
|
| 2197 | + } |
|
| 2004 | 2198 | } elseif ($result['value'] == '29') { |
| 2005 | 2199 | $error = self::update_from_29(); |
| 2006 | - if ($error != '') return $error; |
|
| 2007 | - else return self::check_version(true); |
|
| 2200 | + if ($error != '') { |
|
| 2201 | + return $error; |
|
| 2202 | + } else { |
|
| 2203 | + return self::check_version(true); |
|
| 2204 | + } |
|
| 2008 | 2205 | } elseif ($result['value'] == '30') { |
| 2009 | 2206 | $error = self::update_from_30(); |
| 2010 | - if ($error != '') return $error; |
|
| 2011 | - else return self::check_version(true); |
|
| 2207 | + if ($error != '') { |
|
| 2208 | + return $error; |
|
| 2209 | + } else { |
|
| 2210 | + return self::check_version(true); |
|
| 2211 | + } |
|
| 2012 | 2212 | } elseif ($result['value'] == '31') { |
| 2013 | 2213 | $error = self::update_from_31(); |
| 2014 | - if ($error != '') return $error; |
|
| 2015 | - else return self::check_version(true); |
|
| 2214 | + if ($error != '') { |
|
| 2215 | + return $error; |
|
| 2216 | + } else { |
|
| 2217 | + return self::check_version(true); |
|
| 2218 | + } |
|
| 2016 | 2219 | } elseif ($result['value'] == '32') { |
| 2017 | 2220 | $error = self::update_from_32(); |
| 2018 | - if ($error != '') return $error; |
|
| 2019 | - else return self::check_version(true); |
|
| 2221 | + if ($error != '') { |
|
| 2222 | + return $error; |
|
| 2223 | + } else { |
|
| 2224 | + return self::check_version(true); |
|
| 2225 | + } |
|
| 2020 | 2226 | } elseif ($result['value'] == '33') { |
| 2021 | 2227 | $error = self::update_from_33(); |
| 2022 | - if ($error != '') return $error; |
|
| 2023 | - else return self::check_version(true); |
|
| 2228 | + if ($error != '') { |
|
| 2229 | + return $error; |
|
| 2230 | + } else { |
|
| 2231 | + return self::check_version(true); |
|
| 2232 | + } |
|
| 2024 | 2233 | } elseif ($result['value'] == '34') { |
| 2025 | 2234 | $error = self::update_from_34(); |
| 2026 | - if ($error != '') return $error; |
|
| 2027 | - else return self::check_version(true); |
|
| 2235 | + if ($error != '') { |
|
| 2236 | + return $error; |
|
| 2237 | + } else { |
|
| 2238 | + return self::check_version(true); |
|
| 2239 | + } |
|
| 2028 | 2240 | } elseif ($result['value'] == '35') { |
| 2029 | 2241 | $error = self::update_from_35(); |
| 2030 | - if ($error != '') return $error; |
|
| 2031 | - else return self::check_version(true); |
|
| 2242 | + if ($error != '') { |
|
| 2243 | + return $error; |
|
| 2244 | + } else { |
|
| 2245 | + return self::check_version(true); |
|
| 2246 | + } |
|
| 2032 | 2247 | } elseif ($result['value'] == '36') { |
| 2033 | 2248 | $error = self::update_from_36(); |
| 2034 | - if ($error != '') return $error; |
|
| 2035 | - else return self::check_version(true); |
|
| 2249 | + if ($error != '') { |
|
| 2250 | + return $error; |
|
| 2251 | + } else { |
|
| 2252 | + return self::check_version(true); |
|
| 2253 | + } |
|
| 2036 | 2254 | } elseif ($result['value'] == '37') { |
| 2037 | 2255 | $error = self::update_from_37(); |
| 2038 | - if ($error != '') return $error; |
|
| 2039 | - else return self::check_version(true); |
|
| 2256 | + if ($error != '') { |
|
| 2257 | + return $error; |
|
| 2258 | + } else { |
|
| 2259 | + return self::check_version(true); |
|
| 2260 | + } |
|
| 2040 | 2261 | } elseif ($result['value'] == '38') { |
| 2041 | 2262 | $error = self::update_from_38(); |
| 2042 | - if ($error != '') return $error; |
|
| 2043 | - else return self::check_version(true); |
|
| 2044 | - } else return ''; |
|
| 2263 | + if ($error != '') { |
|
| 2264 | + return $error; |
|
| 2265 | + } else { |
|
| 2266 | + return self::check_version(true); |
|
| 2267 | + } |
|
| 2268 | + } else { |
|
| 2269 | + return ''; |
|
| 2270 | + } |
|
| 2271 | + } else { |
|
| 2272 | + return $result['value']; |
|
| 2045 | 2273 | } |
| 2046 | - else return $result['value']; |
|
| 2047 | 2274 | } |
| 2048 | 2275 | |
| 2049 | - } else return $version; |
|
| 2276 | + } else { |
|
| 2277 | + return $version; |
|
| 2278 | + } |
|
| 2050 | 2279 | } |
| 2051 | 2280 | |
| 2052 | 2281 | } |
@@ -1,12 +1,12 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | require_once(dirname(__FILE__).'/settings.php'); |
| 3 | 3 | |
| 4 | -class Connection{ |
|
| 4 | +class Connection { |
|
| 5 | 5 | public $db = null; |
| 6 | 6 | public $dbs = array(); |
| 7 | 7 | public $latest_schema = 39; |
| 8 | 8 | |
| 9 | - public function __construct($dbc = null,$dbname = null,$user = null,$pass = null) { |
|
| 9 | + public function __construct($dbc = null, $dbname = null, $user = null, $pass = null) { |
|
| 10 | 10 | global $globalDBdriver, $globalNoDB; |
| 11 | 11 | if (isset($globalNoDB) && $globalNoDB === TRUE) { |
| 12 | 12 | $this->db = null; |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | if ($user === null && $pass === null) { |
| 17 | 17 | $this->createDBConnection(); |
| 18 | 18 | } else { |
| 19 | - $this->createDBConnection(null,$user,$pass); |
|
| 19 | + $this->createDBConnection(null, $user, $pass); |
|
| 20 | 20 | } |
| 21 | 21 | } else { |
| 22 | 22 | $this->createDBConnection($dbname); |
@@ -100,14 +100,14 @@ discard block |
||
| 100 | 100 | while (true) { |
| 101 | 101 | try { |
| 102 | 102 | if ($globalDBSdriver == 'mysql') { |
| 103 | - $this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;charset=utf8", $globalDBSuser, $globalDBSpass); |
|
| 103 | + $this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;charset=utf8", $globalDBSuser, $globalDBSpass); |
|
| 104 | 104 | $this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'"); |
| 105 | 105 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
| 106 | - $this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER); |
|
| 107 | - if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,500); |
|
| 108 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut); |
|
| 109 | - if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true); |
|
| 110 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent); |
|
| 106 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER); |
|
| 107 | + if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, 500); |
|
| 108 | + else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, $globalDBTimeOut); |
|
| 109 | + if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, true); |
|
| 110 | + else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, $globalDBPersistent); |
|
| 111 | 111 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); |
| 112 | 112 | $this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); |
| 113 | 113 | // Workaround against "ONLY_FULL_GROUP_BY" mode |
@@ -117,19 +117,19 @@ discard block |
||
| 117 | 117 | $this->dbs[$DBname]->exec('SET SESSION time_zone = "+00:00"'); |
| 118 | 118 | //$this->dbs[$DBname]->exec('SET @@session.time_zone = "+00:00"'); |
| 119 | 119 | } else { |
| 120 | - $this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;options='--client_encoding=utf8'", $globalDBSuser, $globalDBSpass); |
|
| 120 | + $this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;options='--client_encoding=utf8'", $globalDBSuser, $globalDBSpass); |
|
| 121 | 121 | //$this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'"); |
| 122 | 122 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
| 123 | - $this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER); |
|
| 124 | - if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,200); |
|
| 125 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut); |
|
| 126 | - if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true); |
|
| 127 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent); |
|
| 123 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER); |
|
| 124 | + if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, 200); |
|
| 125 | + else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, $globalDBTimeOut); |
|
| 126 | + if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, true); |
|
| 127 | + else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, $globalDBPersistent); |
|
| 128 | 128 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); |
| 129 | 129 | $this->dbs[$DBname]->exec('SET timezone="UTC"'); |
| 130 | 130 | } |
| 131 | 131 | break; |
| 132 | - } catch(PDOException $e) { |
|
| 132 | + } catch (PDOException $e) { |
|
| 133 | 133 | $i++; |
| 134 | 134 | if (isset($globalDebug) && $globalDebug) echo 'Error connecting to DB: '.$globalDBSname.' - Error: '.$e->getMessage()."\n"; |
| 135 | 135 | //exit; |
@@ -153,10 +153,10 @@ discard block |
||
| 153 | 153 | try { |
| 154 | 154 | //$Connection = new Connection(); |
| 155 | 155 | $results = $this->db->query($query); |
| 156 | - } catch(PDOException $e) { |
|
| 156 | + } catch (PDOException $e) { |
|
| 157 | 157 | return false; |
| 158 | 158 | } |
| 159 | - if($results->rowCount()>0) { |
|
| 159 | + if ($results->rowCount() > 0) { |
|
| 160 | 160 | return true; |
| 161 | 161 | } |
| 162 | 162 | else return false; |
@@ -177,8 +177,8 @@ discard block |
||
| 177 | 177 | return false; |
| 178 | 178 | } |
| 179 | 179 | |
| 180 | - } catch(PDOException $e) { |
|
| 181 | - if($e->getCode() != 'HY000' || !stristr($e->getMessage(), 'server has gone away')) { |
|
| 180 | + } catch (PDOException $e) { |
|
| 181 | + if ($e->getCode() != 'HY000' || !stristr($e->getMessage(), 'server has gone away')) { |
|
| 182 | 182 | throw $e; |
| 183 | 183 | } |
| 184 | 184 | //echo 'error ! '.$e->getMessage(); |
@@ -190,7 +190,7 @@ discard block |
||
| 190 | 190 | /* |
| 191 | 191 | * Check if index exist |
| 192 | 192 | */ |
| 193 | - public function indexExists($table,$index) |
|
| 193 | + public function indexExists($table, $index) |
|
| 194 | 194 | { |
| 195 | 195 | global $globalDBdriver, $globalDBname; |
| 196 | 196 | if ($globalDBdriver == 'mysql') { |
@@ -201,11 +201,11 @@ discard block |
||
| 201 | 201 | try { |
| 202 | 202 | //$Connection = new Connection(); |
| 203 | 203 | $results = $this->db->query($query); |
| 204 | - } catch(PDOException $e) { |
|
| 204 | + } catch (PDOException $e) { |
|
| 205 | 205 | return false; |
| 206 | 206 | } |
| 207 | 207 | $nb = $results->fetchAll(PDO::FETCH_ASSOC); |
| 208 | - if($nb[0]['nb'] > 0) { |
|
| 208 | + if ($nb[0]['nb'] > 0) { |
|
| 209 | 209 | return true; |
| 210 | 210 | } |
| 211 | 211 | else return false; |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | $query = "SELECT * FROM ".$table." LIMIT 0"; |
| 221 | 221 | try { |
| 222 | 222 | $results = $this->db->query($query); |
| 223 | - } catch(PDOException $e) { |
|
| 223 | + } catch (PDOException $e) { |
|
| 224 | 224 | return "error : ".$e->getMessage()."\n"; |
| 225 | 225 | } |
| 226 | 226 | $columns = array(); |
@@ -232,7 +232,7 @@ discard block |
||
| 232 | 232 | return $columns; |
| 233 | 233 | } |
| 234 | 234 | |
| 235 | - public function getColumnType($table,$column) { |
|
| 235 | + public function getColumnType($table, $column) { |
|
| 236 | 236 | $select = $this->db->query('SELECT '.$column.' FROM '.$table); |
| 237 | 237 | $tomet = $select->getColumnMeta(0); |
| 238 | 238 | return $tomet['native_type']; |
@@ -242,7 +242,7 @@ discard block |
||
| 242 | 242 | * Check if a column name exist in a table |
| 243 | 243 | * @return Boolean column exist or not |
| 244 | 244 | */ |
| 245 | - public function checkColumnName($table,$name) |
|
| 245 | + public function checkColumnName($table, $name) |
|
| 246 | 246 | { |
| 247 | 247 | global $globalDBdriver, $globalDBname; |
| 248 | 248 | if ($globalDBdriver == 'mysql') { |
@@ -252,8 +252,8 @@ discard block |
||
| 252 | 252 | } |
| 253 | 253 | try { |
| 254 | 254 | $sth = $this->db()->prepare($query); |
| 255 | - $sth->execute(array(':database' => $globalDBname,':table' => $table,':name' => $name)); |
|
| 256 | - } catch(PDOException $e) { |
|
| 255 | + $sth->execute(array(':database' => $globalDBname, ':table' => $table, ':name' => $name)); |
|
| 256 | + } catch (PDOException $e) { |
|
| 257 | 257 | echo "error : ".$e->getMessage()."\n"; |
| 258 | 258 | } |
| 259 | 259 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -292,7 +292,7 @@ discard block |
||
| 292 | 292 | try { |
| 293 | 293 | $sth = $this->db->prepare($query); |
| 294 | 294 | $sth->execute(); |
| 295 | - } catch(PDOException $e) { |
|
| 295 | + } catch (PDOException $e) { |
|
| 296 | 296 | return "error : ".$e->getMessage()."\n"; |
| 297 | 297 | } |
| 298 | 298 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -35,7 +35,9 @@ discard block |
||
| 35 | 35 | $temp += 1; |
| 36 | 36 | $flat = (float)($temp / (60.0 * 10000.0)); |
| 37 | 37 | $flat *= -1.0; |
| 38 | - } else $flat = (float)($temp / (60.0 * 10000.0)); |
|
| 38 | + } else { |
|
| 39 | + $flat = (float)($temp / (60.0 * 10000.0)); |
|
| 40 | + } |
|
| 39 | 41 | return $flat; // float |
| 40 | 42 | } |
| 41 | 43 | |
@@ -47,7 +49,9 @@ discard block |
||
| 47 | 49 | $temp += 1; |
| 48 | 50 | $flon = (float)($temp / (60.0 * 10000.0)); |
| 49 | 51 | $flon *= -1.0; |
| 50 | - } else $flon = (float)($temp / (60.0 * 10000.0)); |
|
| 52 | + } else { |
|
| 53 | + $flon = (float)($temp / (60.0 * 10000.0)); |
|
| 54 | + } |
|
| 51 | 55 | return $flon; |
| 52 | 56 | } |
| 53 | 57 | |
@@ -70,10 +74,8 @@ discard block |
||
| 70 | 74 | */ |
| 71 | 75 | private function asciidec_2_8bit($ascii) { |
| 72 | 76 | //only process in the following range: 48-87, 96-119 |
| 73 | - if ($ascii < 48) { } |
|
| 74 | - else { |
|
| 75 | - if($ascii>119) { } |
|
| 76 | - else { |
|
| 77 | + if ($ascii < 48) { } else { |
|
| 78 | + if($ascii>119) { } else { |
|
| 77 | 79 | if ($ascii>87 && $ascii<96) ; |
| 78 | 80 | else { |
| 79 | 81 | $ascii=$ascii+40; |
@@ -175,7 +177,9 @@ discard block |
||
| 175 | 177 | $ro->lon = $this->make_lonf(bindec(substr($_aisdata,57,28))); |
| 176 | 178 | $ro->lat = $this->make_latf(bindec(substr($_aisdata,85,27))); |
| 177 | 179 | $ro->heading = bindec(substr($_aisdata,124,9)); |
| 178 | - if ($ro->heading == 511) $ro->heading = ''; |
|
| 180 | + if ($ro->heading == 511) { |
|
| 181 | + $ro->heading = ''; |
|
| 182 | + } |
|
| 179 | 183 | $ro->cls = 2; // class B |
| 180 | 184 | } else if ($ro->id == 19) { |
| 181 | 185 | $ro->cog = bindec(substr($_aisdata,112,12))/10; |
@@ -185,7 +189,9 @@ discard block |
||
| 185 | 189 | $ro->name = $this->binchar($_aisdata,143,120); |
| 186 | 190 | $ro->cls = 2; // class B |
| 187 | 191 | $ro->heading = bindec(substr($_aisdata,124,9)); |
| 188 | - if ($ro->heading == 511) $ro->heading = ''; |
|
| 192 | + if ($ro->heading == 511) { |
|
| 193 | + $ro->heading = ''; |
|
| 194 | + } |
|
| 189 | 195 | $ro->typeid = bindec(substr($_aisdata,263,8)); |
| 190 | 196 | $ro->type = $this->getShipType($ro->typeid); |
| 191 | 197 | //$ro->to_bow = bindec(substr($_aisdata,271,9)); |
@@ -216,9 +222,13 @@ discard block |
||
| 216 | 222 | $ro->cls = 2; // class B |
| 217 | 223 | } else if ($ro->id == 27) { |
| 218 | 224 | $ro->cog = bindec(substr($_aisdata,85,9)); |
| 219 | - if ($ro->cog == 511) $ro->cog = 0.0; |
|
| 225 | + if ($ro->cog == 511) { |
|
| 226 | + $ro->cog = 0.0; |
|
| 227 | + } |
|
| 220 | 228 | $ro->sog = bindec(substr($_aisdata,79,6)); |
| 221 | - if ($ro->sog == 63) $ro->sog = 0.0; |
|
| 229 | + if ($ro->sog == 63) { |
|
| 230 | + $ro->sog = 0.0; |
|
| 231 | + } |
|
| 222 | 232 | $ro->lon = $this->make_lonf(bindec(substr($_aisdata,44,18))*10); |
| 223 | 233 | $ro->lat = $this->make_latf(bindec(substr($_aisdata,62,17))*10); |
| 224 | 234 | $ro->cls = 1; // class A |
@@ -267,88 +277,171 @@ discard block |
||
| 267 | 277 | } |
| 268 | 278 | |
| 269 | 279 | public function getShipType($code) { |
| 270 | - if ($code == 0) return 'Not available (default)'; |
|
| 271 | - elseif ($code >= 1 && $code <= 19) return 'Reserved for future use'; |
|
| 272 | - elseif ($code == 20) return 'Wing in ground (WIG), all ships of this type'; |
|
| 273 | - elseif ($code == 21) return 'Wing in ground (WIG), Hazardous category A'; |
|
| 274 | - elseif ($code == 22) return 'Wing in ground (WIG), Hazardous category B'; |
|
| 275 | - elseif ($code == 23) return 'Wing in ground (WIG), Hazardous category C'; |
|
| 276 | - elseif ($code == 24) return 'Wing in ground (WIG), Hazardous category D'; |
|
| 277 | - elseif ($code == 25) return 'Wing in ground (WIG), Reserved for future use'; |
|
| 278 | - elseif ($code == 26) return 'Wing in ground (WIG), Reserved for future use'; |
|
| 279 | - elseif ($code == 27) return 'Wing in ground (WIG), Reserved for future use'; |
|
| 280 | - elseif ($code == 28) return 'Wing in ground (WIG), Reserved for future use'; |
|
| 281 | - elseif ($code == 29) return 'Wing in ground (WIG), Reserved for future use'; |
|
| 282 | - elseif ($code == 30) return 'Fishing'; |
|
| 283 | - elseif ($code == 31) return 'Towing'; |
|
| 284 | - elseif ($code == 32) return 'Towing: length exceeds 200m or breadth exceeds 25m'; |
|
| 285 | - elseif ($code == 33) return 'Dredging or underwater ops'; |
|
| 286 | - elseif ($code == 34) return 'Diving ops'; |
|
| 287 | - elseif ($code == 35) return 'Military ops'; |
|
| 288 | - elseif ($code == 36) return 'Sailing'; |
|
| 289 | - elseif ($code == 37) return 'Pleasure Craft'; |
|
| 290 | - elseif ($code == 38) return 'Reserved'; |
|
| 291 | - elseif ($code == 39) return 'Reserved'; |
|
| 292 | - elseif ($code == 40) return 'High speed craft (HSC), all ships of this type'; |
|
| 293 | - elseif ($code == 41) return 'High speed craft (HSC), Hazardous category A'; |
|
| 294 | - elseif ($code == 42) return 'High speed craft (HSC), Hazardous category B'; |
|
| 295 | - elseif ($code == 43) return 'High speed craft (HSC), Hazardous category C'; |
|
| 296 | - elseif ($code == 44) return 'High speed craft (HSC), Hazardous category D'; |
|
| 297 | - elseif ($code == 45) return 'High speed craft (HSC), Reserved for future use'; |
|
| 298 | - elseif ($code == 46) return 'High speed craft (HSC), Reserved for future use'; |
|
| 299 | - elseif ($code == 47) return 'High speed craft (HSC), Reserved for future use'; |
|
| 300 | - elseif ($code == 48) return 'High speed craft (HSC), Reserved for future use'; |
|
| 301 | - elseif ($code == 49) return 'High speed craft (HSC), No additional information'; |
|
| 302 | - elseif ($code == 50) return 'Pilot Vessel'; |
|
| 303 | - elseif ($code == 51) return 'Search and Rescue vessel'; |
|
| 304 | - elseif ($code == 52) return 'Tug'; |
|
| 305 | - elseif ($code == 53) return 'Port Tender'; |
|
| 306 | - elseif ($code == 54) return 'Anti-pollution equipment'; |
|
| 307 | - elseif ($code == 55) return 'Law Enforcement'; |
|
| 308 | - elseif ($code == 56) return 'Spare - Local Vessel'; |
|
| 309 | - elseif ($code == 57) return 'Spare - Local Vessel'; |
|
| 310 | - elseif ($code == 58) return 'Medical Transport'; |
|
| 311 | - elseif ($code == 59) return 'Noncombatant ship according to RR Resolution No. 18'; |
|
| 312 | - elseif ($code == 60) return 'Passenger, all ships of this type'; |
|
| 313 | - elseif ($code == 61) return 'Passenger, Hazardous category A'; |
|
| 314 | - elseif ($code == 62) return 'Passenger, Hazardous category B'; |
|
| 315 | - elseif ($code == 63) return 'Passenger, Hazardous category C'; |
|
| 316 | - elseif ($code == 64) return 'Passenger, Hazardous category D'; |
|
| 317 | - elseif ($code == 65) return 'Passenger, Reserved for future use'; |
|
| 318 | - elseif ($code == 66) return 'Passenger, Reserved for future use'; |
|
| 319 | - elseif ($code == 67) return 'Passenger, Reserved for future use'; |
|
| 320 | - elseif ($code == 68) return 'Passenger, Reserved for future use'; |
|
| 321 | - elseif ($code == 69) return 'Passenger, No additional information'; |
|
| 322 | - elseif ($code == 70) return 'Cargo, all ships of this type'; |
|
| 323 | - elseif ($code == 71) return 'Cargo, Hazardous category A'; |
|
| 324 | - elseif ($code == 72) return 'Cargo, Hazardous category B'; |
|
| 325 | - elseif ($code == 73) return 'Cargo, Hazardous category C'; |
|
| 326 | - elseif ($code == 74) return 'Cargo, Hazardous category D'; |
|
| 327 | - elseif ($code == 75) return 'Cargo, Reserved for future use'; |
|
| 328 | - elseif ($code == 76) return 'Cargo, Reserved for future use'; |
|
| 329 | - elseif ($code == 77) return 'Cargo, Reserved for future use'; |
|
| 330 | - elseif ($code == 78) return 'Cargo, Reserved for future use'; |
|
| 331 | - elseif ($code == 79) return 'Cargo, No additional information'; |
|
| 332 | - elseif ($code == 80) return 'Tanker, all ships of this type'; |
|
| 333 | - elseif ($code == 81) return 'Tanker, Hazardous category A'; |
|
| 334 | - elseif ($code == 82) return 'Tanker, Hazardous category B'; |
|
| 335 | - elseif ($code == 83) return 'Tanker, Hazardous category C'; |
|
| 336 | - elseif ($code == 84) return 'Tanker, Hazardous category D'; |
|
| 337 | - elseif ($code == 85) return 'Tanker, Reserved for future use'; |
|
| 338 | - elseif ($code == 86) return 'Tanker, Reserved for future use'; |
|
| 339 | - elseif ($code == 87) return 'Tanker, Reserved for future use'; |
|
| 340 | - elseif ($code == 88) return 'Tanker, Reserved for future use'; |
|
| 341 | - elseif ($code == 89) return 'Tanker, No additional information'; |
|
| 342 | - elseif ($code == 90) return 'Other Type, all ships of this type'; |
|
| 343 | - elseif ($code == 91) return 'Other Type, Hazardous category A'; |
|
| 344 | - elseif ($code == 92) return 'Other Type, Hazardous category B'; |
|
| 345 | - elseif ($code == 93) return 'Other Type, Hazardous category C'; |
|
| 346 | - elseif ($code == 94) return 'Other Type, Hazardous category D'; |
|
| 347 | - elseif ($code == 95) return 'Other Type, Reserved for future use'; |
|
| 348 | - elseif ($code == 96) return 'Other Type, Reserved for future use'; |
|
| 349 | - elseif ($code == 97) return 'Other Type, Reserved for future use'; |
|
| 350 | - elseif ($code == 98) return 'Other Type, Reserved for future use'; |
|
| 351 | - elseif ($code == 99) return 'Other Type, no additional information'; |
|
| 280 | + if ($code == 0) { |
|
| 281 | + return 'Not available (default)'; |
|
| 282 | + } elseif ($code >= 1 && $code <= 19) { |
|
| 283 | + return 'Reserved for future use'; |
|
| 284 | + } elseif ($code == 20) { |
|
| 285 | + return 'Wing in ground (WIG), all ships of this type'; |
|
| 286 | + } elseif ($code == 21) { |
|
| 287 | + return 'Wing in ground (WIG), Hazardous category A'; |
|
| 288 | + } elseif ($code == 22) { |
|
| 289 | + return 'Wing in ground (WIG), Hazardous category B'; |
|
| 290 | + } elseif ($code == 23) { |
|
| 291 | + return 'Wing in ground (WIG), Hazardous category C'; |
|
| 292 | + } elseif ($code == 24) { |
|
| 293 | + return 'Wing in ground (WIG), Hazardous category D'; |
|
| 294 | + } elseif ($code == 25) { |
|
| 295 | + return 'Wing in ground (WIG), Reserved for future use'; |
|
| 296 | + } elseif ($code == 26) { |
|
| 297 | + return 'Wing in ground (WIG), Reserved for future use'; |
|
| 298 | + } elseif ($code == 27) { |
|
| 299 | + return 'Wing in ground (WIG), Reserved for future use'; |
|
| 300 | + } elseif ($code == 28) { |
|
| 301 | + return 'Wing in ground (WIG), Reserved for future use'; |
|
| 302 | + } elseif ($code == 29) { |
|
| 303 | + return 'Wing in ground (WIG), Reserved for future use'; |
|
| 304 | + } elseif ($code == 30) { |
|
| 305 | + return 'Fishing'; |
|
| 306 | + } elseif ($code == 31) { |
|
| 307 | + return 'Towing'; |
|
| 308 | + } elseif ($code == 32) { |
|
| 309 | + return 'Towing: length exceeds 200m or breadth exceeds 25m'; |
|
| 310 | + } elseif ($code == 33) { |
|
| 311 | + return 'Dredging or underwater ops'; |
|
| 312 | + } elseif ($code == 34) { |
|
| 313 | + return 'Diving ops'; |
|
| 314 | + } elseif ($code == 35) { |
|
| 315 | + return 'Military ops'; |
|
| 316 | + } elseif ($code == 36) { |
|
| 317 | + return 'Sailing'; |
|
| 318 | + } elseif ($code == 37) { |
|
| 319 | + return 'Pleasure Craft'; |
|
| 320 | + } elseif ($code == 38) { |
|
| 321 | + return 'Reserved'; |
|
| 322 | + } elseif ($code == 39) { |
|
| 323 | + return 'Reserved'; |
|
| 324 | + } elseif ($code == 40) { |
|
| 325 | + return 'High speed craft (HSC), all ships of this type'; |
|
| 326 | + } elseif ($code == 41) { |
|
| 327 | + return 'High speed craft (HSC), Hazardous category A'; |
|
| 328 | + } elseif ($code == 42) { |
|
| 329 | + return 'High speed craft (HSC), Hazardous category B'; |
|
| 330 | + } elseif ($code == 43) { |
|
| 331 | + return 'High speed craft (HSC), Hazardous category C'; |
|
| 332 | + } elseif ($code == 44) { |
|
| 333 | + return 'High speed craft (HSC), Hazardous category D'; |
|
| 334 | + } elseif ($code == 45) { |
|
| 335 | + return 'High speed craft (HSC), Reserved for future use'; |
|
| 336 | + } elseif ($code == 46) { |
|
| 337 | + return 'High speed craft (HSC), Reserved for future use'; |
|
| 338 | + } elseif ($code == 47) { |
|
| 339 | + return 'High speed craft (HSC), Reserved for future use'; |
|
| 340 | + } elseif ($code == 48) { |
|
| 341 | + return 'High speed craft (HSC), Reserved for future use'; |
|
| 342 | + } elseif ($code == 49) { |
|
| 343 | + return 'High speed craft (HSC), No additional information'; |
|
| 344 | + } elseif ($code == 50) { |
|
| 345 | + return 'Pilot Vessel'; |
|
| 346 | + } elseif ($code == 51) { |
|
| 347 | + return 'Search and Rescue vessel'; |
|
| 348 | + } elseif ($code == 52) { |
|
| 349 | + return 'Tug'; |
|
| 350 | + } elseif ($code == 53) { |
|
| 351 | + return 'Port Tender'; |
|
| 352 | + } elseif ($code == 54) { |
|
| 353 | + return 'Anti-pollution equipment'; |
|
| 354 | + } elseif ($code == 55) { |
|
| 355 | + return 'Law Enforcement'; |
|
| 356 | + } elseif ($code == 56) { |
|
| 357 | + return 'Spare - Local Vessel'; |
|
| 358 | + } elseif ($code == 57) { |
|
| 359 | + return 'Spare - Local Vessel'; |
|
| 360 | + } elseif ($code == 58) { |
|
| 361 | + return 'Medical Transport'; |
|
| 362 | + } elseif ($code == 59) { |
|
| 363 | + return 'Noncombatant ship according to RR Resolution No. 18'; |
|
| 364 | + } elseif ($code == 60) { |
|
| 365 | + return 'Passenger, all ships of this type'; |
|
| 366 | + } elseif ($code == 61) { |
|
| 367 | + return 'Passenger, Hazardous category A'; |
|
| 368 | + } elseif ($code == 62) { |
|
| 369 | + return 'Passenger, Hazardous category B'; |
|
| 370 | + } elseif ($code == 63) { |
|
| 371 | + return 'Passenger, Hazardous category C'; |
|
| 372 | + } elseif ($code == 64) { |
|
| 373 | + return 'Passenger, Hazardous category D'; |
|
| 374 | + } elseif ($code == 65) { |
|
| 375 | + return 'Passenger, Reserved for future use'; |
|
| 376 | + } elseif ($code == 66) { |
|
| 377 | + return 'Passenger, Reserved for future use'; |
|
| 378 | + } elseif ($code == 67) { |
|
| 379 | + return 'Passenger, Reserved for future use'; |
|
| 380 | + } elseif ($code == 68) { |
|
| 381 | + return 'Passenger, Reserved for future use'; |
|
| 382 | + } elseif ($code == 69) { |
|
| 383 | + return 'Passenger, No additional information'; |
|
| 384 | + } elseif ($code == 70) { |
|
| 385 | + return 'Cargo, all ships of this type'; |
|
| 386 | + } elseif ($code == 71) { |
|
| 387 | + return 'Cargo, Hazardous category A'; |
|
| 388 | + } elseif ($code == 72) { |
|
| 389 | + return 'Cargo, Hazardous category B'; |
|
| 390 | + } elseif ($code == 73) { |
|
| 391 | + return 'Cargo, Hazardous category C'; |
|
| 392 | + } elseif ($code == 74) { |
|
| 393 | + return 'Cargo, Hazardous category D'; |
|
| 394 | + } elseif ($code == 75) { |
|
| 395 | + return 'Cargo, Reserved for future use'; |
|
| 396 | + } elseif ($code == 76) { |
|
| 397 | + return 'Cargo, Reserved for future use'; |
|
| 398 | + } elseif ($code == 77) { |
|
| 399 | + return 'Cargo, Reserved for future use'; |
|
| 400 | + } elseif ($code == 78) { |
|
| 401 | + return 'Cargo, Reserved for future use'; |
|
| 402 | + } elseif ($code == 79) { |
|
| 403 | + return 'Cargo, No additional information'; |
|
| 404 | + } elseif ($code == 80) { |
|
| 405 | + return 'Tanker, all ships of this type'; |
|
| 406 | + } elseif ($code == 81) { |
|
| 407 | + return 'Tanker, Hazardous category A'; |
|
| 408 | + } elseif ($code == 82) { |
|
| 409 | + return 'Tanker, Hazardous category B'; |
|
| 410 | + } elseif ($code == 83) { |
|
| 411 | + return 'Tanker, Hazardous category C'; |
|
| 412 | + } elseif ($code == 84) { |
|
| 413 | + return 'Tanker, Hazardous category D'; |
|
| 414 | + } elseif ($code == 85) { |
|
| 415 | + return 'Tanker, Reserved for future use'; |
|
| 416 | + } elseif ($code == 86) { |
|
| 417 | + return 'Tanker, Reserved for future use'; |
|
| 418 | + } elseif ($code == 87) { |
|
| 419 | + return 'Tanker, Reserved for future use'; |
|
| 420 | + } elseif ($code == 88) { |
|
| 421 | + return 'Tanker, Reserved for future use'; |
|
| 422 | + } elseif ($code == 89) { |
|
| 423 | + return 'Tanker, No additional information'; |
|
| 424 | + } elseif ($code == 90) { |
|
| 425 | + return 'Other Type, all ships of this type'; |
|
| 426 | + } elseif ($code == 91) { |
|
| 427 | + return 'Other Type, Hazardous category A'; |
|
| 428 | + } elseif ($code == 92) { |
|
| 429 | + return 'Other Type, Hazardous category B'; |
|
| 430 | + } elseif ($code == 93) { |
|
| 431 | + return 'Other Type, Hazardous category C'; |
|
| 432 | + } elseif ($code == 94) { |
|
| 433 | + return 'Other Type, Hazardous category D'; |
|
| 434 | + } elseif ($code == 95) { |
|
| 435 | + return 'Other Type, Reserved for future use'; |
|
| 436 | + } elseif ($code == 96) { |
|
| 437 | + return 'Other Type, Reserved for future use'; |
|
| 438 | + } elseif ($code == 97) { |
|
| 439 | + return 'Other Type, Reserved for future use'; |
|
| 440 | + } elseif ($code == 98) { |
|
| 441 | + return 'Other Type, Reserved for future use'; |
|
| 442 | + } elseif ($code == 99) { |
|
| 443 | + return 'Other Type, no additional information'; |
|
| 444 | + } |
|
| 352 | 445 | } |
| 353 | 446 | |
| 354 | 447 | public function process_ais_itu($_itu, $_len, $_filler, $aux /*, $ais_ch*/) { |
@@ -386,19 +479,34 @@ discard block |
||
| 386 | 479 | // assume 1st ! is valid |
| 387 | 480 | // find * ensure that it is at correct position |
| 388 | 481 | $end = strrpos ( $rawdata , '*' ); |
| 389 | - if ($end === FALSE) return -1; // check for NULLS!!! |
|
| 482 | + if ($end === FALSE) { |
|
| 483 | + return -1; |
|
| 484 | + } |
|
| 485 | + // check for NULLS!!! |
|
| 390 | 486 | $cs = substr( $rawdata, $end + 1 ); |
| 391 | - if ( strlen($cs) != 2 ) return -1; // correct cs length |
|
| 487 | + if ( strlen($cs) != 2 ) { |
|
| 488 | + return -1; |
|
| 489 | + } |
|
| 490 | + // correct cs length |
|
| 392 | 491 | $dcs = (int)hexdec( $cs ); |
| 393 | - for ( $alias=1; $alias<$end; $alias++) $chksum ^= ord( $rawdata[$alias] ); // perform XOR for NMEA checksum |
|
| 492 | + for ( $alias=1; $alias<$end; $alias++) { |
|
| 493 | + $chksum ^= ord( $rawdata[$alias] ); |
|
| 494 | + } |
|
| 495 | + // perform XOR for NMEA checksum |
|
| 394 | 496 | if ( $chksum == $dcs ) { // NMEA checksum pass |
| 395 | 497 | $pcs = explode(',', $rawdata); |
| 396 | 498 | // !AI??? identifier |
| 397 | 499 | $num_seq = (int)$pcs[1]; // number of sequences |
| 398 | 500 | $seq = (int)$pcs[2]; // get sequence |
| 399 | 501 | // get msg sequence id |
| 400 | - if ($pcs[3] == '') $msg_sid = -1; // non-multipart message, set to -1 |
|
| 401 | - else $msg_sid = (int)$pcs[3]; // multipart message |
|
| 502 | + if ($pcs[3] == '') { |
|
| 503 | + $msg_sid = -1; |
|
| 504 | + } |
|
| 505 | + // non-multipart message, set to -1 |
|
| 506 | + else { |
|
| 507 | + $msg_sid = (int)$pcs[3]; |
|
| 508 | + } |
|
| 509 | + // multipart message |
|
| 402 | 510 | $ais_ch = $pcs[4]; // get AIS channel |
| 403 | 511 | // message sequence checking |
| 404 | 512 | if ($num_seq < 1 || $num_seq > 9) { |
@@ -459,10 +567,18 @@ discard block |
||
| 459 | 567 | //DEBUG echo "[$start $end $tst]\n"; |
| 460 | 568 | $result = $this->process_ais_raw( $tst, "" ); |
| 461 | 569 | $last_pos = $end + 1; |
| 462 | - } else break; |
|
| 570 | + } else { |
|
| 571 | + break; |
|
| 572 | + } |
|
| 573 | + } |
|
| 574 | + if ($last_pos > 0) { |
|
| 575 | + $cbuf = substr($cbuf, $last_pos); |
|
| 576 | + } |
|
| 577 | + // move... |
|
| 578 | + if (strlen($cbuf) > 1024) { |
|
| 579 | + $cbuf = ""; |
|
| 463 | 580 | } |
| 464 | - if ($last_pos > 0) $cbuf = substr($cbuf, $last_pos); // move... |
|
| 465 | - if (strlen($cbuf) > 1024) $cbuf = ""; // prevent overflow simple mode... |
|
| 581 | + // prevent overflow simple mode... |
|
| 466 | 582 | return $result; |
| 467 | 583 | } |
| 468 | 584 | |
@@ -482,7 +598,9 @@ discard block |
||
| 482 | 598 | if ($lat<0.0) { |
| 483 | 599 | $lat = -$lat; |
| 484 | 600 | $neg=true; |
| 485 | - } else $neg=false; |
|
| 601 | + } else { |
|
| 602 | + $neg=false; |
|
| 603 | + } |
|
| 486 | 604 | $latd = 0x00000000; |
| 487 | 605 | $latd = intval ($lat * 600000.0); |
| 488 | 606 | if ($neg==true) { |
@@ -498,7 +616,9 @@ discard block |
||
| 498 | 616 | if ($lon<0.0) { |
| 499 | 617 | $lon = -$lon; |
| 500 | 618 | $neg=true; |
| 501 | - } else $neg=false; |
|
| 619 | + } else { |
|
| 620 | + $neg=false; |
|
| 621 | + } |
|
| 502 | 622 | $lond = 0x00000000; |
| 503 | 623 | $lond = intval ($lon * 600000.0); |
| 504 | 624 | if ($neg==true) { |
@@ -511,9 +631,14 @@ discard block |
||
| 511 | 631 | |
| 512 | 632 | private function char2bin($name, $max_len) { |
| 513 | 633 | $len = strlen($name); |
| 514 | - if ($len > $max_len) $name = substr($name,0,$max_len); |
|
| 515 | - if ($len < $max_len) $pad = str_repeat('0', ($max_len - $len) * 6); |
|
| 516 | - else $pad = ''; |
|
| 634 | + if ($len > $max_len) { |
|
| 635 | + $name = substr($name,0,$max_len); |
|
| 636 | + } |
|
| 637 | + if ($len < $max_len) { |
|
| 638 | + $pad = str_repeat('0', ($max_len - $len) * 6); |
|
| 639 | + } else { |
|
| 640 | + $pad = ''; |
|
| 641 | + } |
|
| 517 | 642 | $rv = ''; |
| 518 | 643 | $ais_chars = array( |
| 519 | 644 | '@'=>0, 'A'=>1, 'B'=>2, 'C'=>3, 'D'=>4, 'E'=>5, 'F'=>6, 'G'=>7, 'H'=>8, 'I'=>9, |
@@ -526,9 +651,12 @@ discard block |
||
| 526 | 651 | ); |
| 527 | 652 | // " |
| 528 | 653 | $_a = str_split($name); |
| 529 | - if ($_a) foreach ($_a as $_1) { |
|
| 654 | + if ($_a) { |
|
| 655 | + foreach ($_a as $_1) { |
|
| 530 | 656 | if (isset($ais_chars[$_1])) $dec = $ais_chars[$_1]; |
| 531 | - else $dec = 0; |
|
| 657 | + } else { |
|
| 658 | + $dec = 0; |
|
| 659 | + } |
|
| 532 | 660 | $bin = str_pad(decbin( $dec ), 6, '0', STR_PAD_LEFT); |
| 533 | 661 | $rv .= $bin; |
| 534 | 662 | //echo "$_1 $dec ($bin)<br/>"; |
@@ -540,7 +668,9 @@ discard block |
||
| 540 | 668 | $len_bit = strlen($_enc); |
| 541 | 669 | $rem6 = $len_bit % 6; |
| 542 | 670 | $pad6_len = 0; |
| 543 | - if ($rem6) $pad6_len = 6 - $rem6; |
|
| 671 | + if ($rem6) { |
|
| 672 | + $pad6_len = 6 - $rem6; |
|
| 673 | + } |
|
| 544 | 674 | //echo $pad6_len.'<br>'; |
| 545 | 675 | $_enc .= str_repeat("0", $pad6_len); // pad the text... |
| 546 | 676 | $len_enc = strlen($_enc) / 6; |
@@ -549,8 +679,11 @@ discard block |
||
| 549 | 679 | for ($i=0; $i<$len_enc; $i++) { |
| 550 | 680 | $offset = $i * 6; |
| 551 | 681 | $dec = bindec(substr($_enc,$offset,6)); |
| 552 | - if ($dec < 40) $dec += 48; |
|
| 553 | - else $dec += 56; |
|
| 682 | + if ($dec < 40) { |
|
| 683 | + $dec += 48; |
|
| 684 | + } else { |
|
| 685 | + $dec += 56; |
|
| 686 | + } |
|
| 554 | 687 | //echo chr($dec)." $dec<br/>"; |
| 555 | 688 | $itu .= chr($dec); |
| 556 | 689 | } |
@@ -563,25 +696,41 @@ discard block |
||
| 563 | 696 | } |
| 564 | 697 | $hex_arr = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'); |
| 565 | 698 | $lsb = $chksum & 0x0F; |
| 566 | - if ($lsb >=0 && $lsb <= 15 ) $lsbc = $hex_arr[$lsb]; |
|
| 567 | - else $lsbc = '0'; |
|
| 699 | + if ($lsb >=0 && $lsb <= 15 ) { |
|
| 700 | + $lsbc = $hex_arr[$lsb]; |
|
| 701 | + } else { |
|
| 702 | + $lsbc = '0'; |
|
| 703 | + } |
|
| 568 | 704 | $msb = (($chksum & 0xF0) >> 4) & 0x0F; |
| 569 | - if ($msb >=0 && $msb <= 15 ) $msbc = $hex_arr[$msb]; |
|
| 570 | - else $msbc = '0'; |
|
| 705 | + if ($msb >=0 && $msb <= 15 ) { |
|
| 706 | + $msbc = $hex_arr[$msb]; |
|
| 707 | + } else { |
|
| 708 | + $msbc = '0'; |
|
| 709 | + } |
|
| 571 | 710 | $itu = '!'.$itu."*{$msbc}{$lsbc}\r\n"; |
| 572 | 711 | return $itu; |
| 573 | 712 | } |
| 574 | 713 | |
| 575 | 714 | public function parse($buffer) { |
| 576 | 715 | $data = $this->process_ais_buf($buffer); |
| 577 | - if (!is_object($data)) return array(); |
|
| 578 | - if ($data->lon != 0) $result['longitude'] = $data->lon; |
|
| 579 | - if ($data->lat != 0) $result['latitude'] = $data->lat; |
|
| 716 | + if (!is_object($data)) { |
|
| 717 | + return array(); |
|
| 718 | + } |
|
| 719 | + if ($data->lon != 0) { |
|
| 720 | + $result['longitude'] = $data->lon; |
|
| 721 | + } |
|
| 722 | + if ($data->lat != 0) { |
|
| 723 | + $result['latitude'] = $data->lat; |
|
| 724 | + } |
|
| 580 | 725 | $result['ident'] = trim($data->name); |
| 581 | 726 | $result['timestamp'] = $data->ts; |
| 582 | 727 | $result['mmsi'] = $data->mmsi; |
| 583 | - if ($data->sog != -1.0) $result['speed'] = $data->sog; |
|
| 584 | - if ($data->cog != 0) $result['heading'] = $data->cog; |
|
| 728 | + if ($data->sog != -1.0) { |
|
| 729 | + $result['speed'] = $data->sog; |
|
| 730 | + } |
|
| 731 | + if ($data->cog != 0) { |
|
| 732 | + $result['heading'] = $data->cog; |
|
| 733 | + } |
|
| 585 | 734 | /* |
| 586 | 735 | $ro->cls = 0; // AIS class undefined, also indicate unparsed msg |
| 587 | 736 | $ro->id = bindec(substr($_aisdata,0,6)); |
@@ -591,15 +740,25 @@ discard block |
||
| 591 | 740 | |
| 592 | 741 | public function mmsitype($mmsi) { |
| 593 | 742 | if (strlen($mmsi) == 9) { |
| 594 | - if (substr($mmsi,0,3) == '974') return 'EPIRB (Emergency Position Indicating Radio Beacon) AIS'; |
|
| 595 | - elseif (substr($mmsi,0,3) == '972') return 'MOB (Man Overboard) device'; |
|
| 596 | - elseif (substr($mmsi,0,3) == '970') return 'AIS SART (Search and Rescue Transmitter)'; |
|
| 597 | - elseif (substr($mmsi,0,3) == '111') return 'SAR (Search and Rescue) aircraft'; |
|
| 598 | - elseif (substr($mmsi,0,2) == '98') return 'Auxiliary craft associated with a parent ship'; |
|
| 599 | - elseif (substr($mmsi,0,2) == '99') return 'Aids to Navigation'; |
|
| 600 | - elseif (substr($mmsi,0,2) == '00') return 'Coastal stations'; |
|
| 601 | - elseif (substr($mmsi,0,1) == '0') return 'Group of ships'; |
|
| 602 | - else return 'Ship'; |
|
| 743 | + if (substr($mmsi,0,3) == '974') { |
|
| 744 | + return 'EPIRB (Emergency Position Indicating Radio Beacon) AIS'; |
|
| 745 | + } elseif (substr($mmsi,0,3) == '972') { |
|
| 746 | + return 'MOB (Man Overboard) device'; |
|
| 747 | + } elseif (substr($mmsi,0,3) == '970') { |
|
| 748 | + return 'AIS SART (Search and Rescue Transmitter)'; |
|
| 749 | + } elseif (substr($mmsi,0,3) == '111') { |
|
| 750 | + return 'SAR (Search and Rescue) aircraft'; |
|
| 751 | + } elseif (substr($mmsi,0,2) == '98') { |
|
| 752 | + return 'Auxiliary craft associated with a parent ship'; |
|
| 753 | + } elseif (substr($mmsi,0,2) == '99') { |
|
| 754 | + return 'Aids to Navigation'; |
|
| 755 | + } elseif (substr($mmsi,0,2) == '00') { |
|
| 756 | + return 'Coastal stations'; |
|
| 757 | + } elseif (substr($mmsi,0,1) == '0') { |
|
| 758 | + return 'Group of ships'; |
|
| 759 | + } else { |
|
| 760 | + return 'Ship'; |
|
| 761 | + } |
|
| 603 | 762 | } |
| 604 | 763 | |
| 605 | 764 | |
@@ -616,32 +775,61 @@ discard block |
||
| 616 | 775 | //if ($globalDebug) echo '==== Line format not supported : '.$buffer."\n"; |
| 617 | 776 | return array(); |
| 618 | 777 | } |
| 619 | - if ($data->lon != 0) $result['longitude'] = $data->lon; |
|
| 620 | - if ($data->lat != 0) $result['latitude'] = $data->lat; |
|
| 778 | + if ($data->lon != 0) { |
|
| 779 | + $result['longitude'] = $data->lon; |
|
| 780 | + } |
|
| 781 | + if ($data->lat != 0) { |
|
| 782 | + $result['latitude'] = $data->lat; |
|
| 783 | + } |
|
| 621 | 784 | $result['ident'] = trim(str_replace('@','',$data->name)); |
| 622 | 785 | $result['timestamp'] = $data->ts; |
| 623 | 786 | $result['mmsi'] = $data->mmsi; |
| 624 | - if (strlen($result['mmsi']) == 8 && substr($result['mmsi'],0,3) == '669') $result['mmsi'] = '3'.$result['mmsi']; |
|
| 787 | + if (strlen($result['mmsi']) == 8 && substr($result['mmsi'],0,3) == '669') { |
|
| 788 | + $result['mmsi'] = '3'.$result['mmsi']; |
|
| 789 | + } |
|
| 625 | 790 | $result['mmsi_type'] = $this->mmsitype($result['mmsi']); |
| 626 | - if ($data->sog != -1.0) $result['speed'] = $data->sog; |
|
| 627 | - if ($data->heading != '') $result['heading'] = $data->heading; |
|
| 628 | - elseif ($data->cog != 0) $result['heading'] = $data->cog; |
|
| 629 | - if ($data->status != '') $result['status'] = $data->status; |
|
| 630 | - if ($data->statusid != '') $result['statusid'] = $data->statusid; |
|
| 631 | - if ($data->type != '') $result['type'] = $data->type; |
|
| 632 | - if ($data->typeid != '') $result['typeid'] = $data->typeid; |
|
| 633 | - if ($data->imo != '') $result['imo'] = $data->imo; |
|
| 634 | - if ($data->callsign != '') $result['callsign'] = trim(str_replace('@','',$data->callsign)); |
|
| 791 | + if ($data->sog != -1.0) { |
|
| 792 | + $result['speed'] = $data->sog; |
|
| 793 | + } |
|
| 794 | + if ($data->heading != '') { |
|
| 795 | + $result['heading'] = $data->heading; |
|
| 796 | + } elseif ($data->cog != 0) { |
|
| 797 | + $result['heading'] = $data->cog; |
|
| 798 | + } |
|
| 799 | + if ($data->status != '') { |
|
| 800 | + $result['status'] = $data->status; |
|
| 801 | + } |
|
| 802 | + if ($data->statusid != '') { |
|
| 803 | + $result['statusid'] = $data->statusid; |
|
| 804 | + } |
|
| 805 | + if ($data->type != '') { |
|
| 806 | + $result['type'] = $data->type; |
|
| 807 | + } |
|
| 808 | + if ($data->typeid != '') { |
|
| 809 | + $result['typeid'] = $data->typeid; |
|
| 810 | + } |
|
| 811 | + if ($data->imo != '') { |
|
| 812 | + $result['imo'] = $data->imo; |
|
| 813 | + } |
|
| 814 | + if ($data->callsign != '') { |
|
| 815 | + $result['callsign'] = trim(str_replace('@','',$data->callsign)); |
|
| 816 | + } |
|
| 635 | 817 | if (is_numeric($data->eta_month) && $data->eta_month != 0 && is_numeric($data->eta_day) && $data->eta_day != 0 && $data->eta_hour !== '' && $data->eta_minute !== '') { |
| 636 | 818 | $eta_ts = strtotime(date('Y').'-'.sprintf("%02d",$data->eta_month).'-'.sprintf("%02d",$data->eta_day).' '.sprintf("%02d",$data->eta_hour).':'.sprintf("%02d",$data->eta_minute).':00'); |
| 637 | - if ($eta_ts != '') $result['eta_ts'] = $eta_ts; |
|
| 819 | + if ($eta_ts != '') { |
|
| 820 | + $result['eta_ts'] = $eta_ts; |
|
| 821 | + } |
|
| 638 | 822 | } elseif (is_numeric($data->eta_hour) && is_numeric($data->eta_minute)) { |
| 639 | 823 | $eta_ts = strtotime(date('Y-m-d').' '.sprintf("%02d",$data->eta_hour).':'.sprintf("%02d",$data->eta_minute).':00'); |
| 640 | - if ($eta_ts != '') $result['eta_ts'] = $eta_ts; |
|
| 824 | + if ($eta_ts != '') { |
|
| 825 | + $result['eta_ts'] = $eta_ts; |
|
| 826 | + } |
|
| 641 | 827 | } |
| 642 | 828 | if ($data->destination != '') { |
| 643 | 829 | $dest = trim(str_replace('@','',$data->destination)); |
| 644 | - if ($dest != '') $result['destination'] = $dest; |
|
| 830 | + if ($dest != '') { |
|
| 831 | + $result['destination'] = $dest; |
|
| 832 | + } |
|
| 645 | 833 | } |
| 646 | 834 | $result['all'] = (array) $data; |
| 647 | 835 | /* |
@@ -16,33 +16,33 @@ discard block |
||
| 16 | 16 | * @param Array $filter the filter |
| 17 | 17 | * @return Array the SQL part |
| 18 | 18 | */ |
| 19 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
| 19 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
| 20 | 20 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
| 21 | 21 | $filters = array(); |
| 22 | 22 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
| 23 | 23 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
| 24 | 24 | $filters = $globalStatsFilters[$globalFilterName]; |
| 25 | 25 | } else { |
| 26 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
| 26 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
| 27 | 27 | } |
| 28 | 28 | } |
| 29 | 29 | if (isset($filter[0]['source'])) { |
| 30 | - $filters = array_merge($filters,$filter); |
|
| 30 | + $filters = array_merge($filters, $filter); |
|
| 31 | 31 | } |
| 32 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 32 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
| 33 | 33 | $filter_query_join = ''; |
| 34 | 34 | $filter_query_where = ''; |
| 35 | - foreach($filters as $flt) { |
|
| 35 | + foreach ($filters as $flt) { |
|
| 36 | 36 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
| 37 | 37 | if (isset($flt['source'])) { |
| 38 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."') AND marine_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id"; |
|
| 38 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."') AND marine_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id"; |
|
| 39 | 39 | } else { |
| 40 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id"; |
|
| 40 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id"; |
|
| 41 | 41 | } |
| 42 | 42 | } |
| 43 | 43 | } |
| 44 | 44 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 45 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
| 45 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
| 46 | 46 | } |
| 47 | 47 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
| 48 | 48 | $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
@@ -71,15 +71,15 @@ discard block |
||
| 71 | 71 | $filter_query_date .= " AND EXTRACT(DAY FROM marine_output.date) = '".$filter['day']."'"; |
| 72 | 72 | } |
| 73 | 73 | } |
| 74 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.fammarine_id = marine_live.fammarine_id"; |
|
| 74 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.fammarine_id = marine_live.fammarine_id"; |
|
| 75 | 75 | } |
| 76 | 76 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 77 | - $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 77 | + $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 78 | 78 | } |
| 79 | 79 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
| 80 | 80 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
| 81 | 81 | if ($filter_query_where != '') { |
| 82 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
| 82 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
| 83 | 83 | } |
| 84 | 84 | $filter_query = $filter_query_join.$filter_query_where; |
| 85 | 85 | return $filter_query; |
@@ -102,8 +102,8 @@ discard block |
||
| 102 | 102 | if ($limit != '') |
| 103 | 103 | { |
| 104 | 104 | $limit_array = explode(',', $limit); |
| 105 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 106 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 105 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 106 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 107 | 107 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 108 | 108 | { |
| 109 | 109 | $limit_query = ' LIMIT '.$limit_array[1].' OFFSET '.$limit_array[0]; |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | } else { |
| 127 | 127 | $query = "SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate".$filter_query.$orderby_query; |
| 128 | 128 | } |
| 129 | - $spotter_array = $Marine->getDataFromDB($query.$limit_query,array(),'',true); |
|
| 129 | + $spotter_array = $Marine->getDataFromDB($query.$limit_query, array(), '', true); |
|
| 130 | 130 | |
| 131 | 131 | return $spotter_array; |
| 132 | 132 | } |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | global $globalDBdriver, $globalLiveInterval; |
| 143 | 143 | date_default_timezone_set('UTC'); |
| 144 | 144 | |
| 145 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 145 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 146 | 146 | |
| 147 | 147 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
| 148 | 148 | if ($globalDBdriver == 'mysql') { |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | try { |
| 157 | 157 | $sth = $this->db->prepare($query); |
| 158 | 158 | $sth->execute(); |
| 159 | - } catch(PDOException $e) { |
|
| 159 | + } catch (PDOException $e) { |
|
| 160 | 160 | echo $e->getMessage(); |
| 161 | 161 | die; |
| 162 | 162 | } |
@@ -176,15 +176,15 @@ discard block |
||
| 176 | 176 | global $globalDBdriver, $globalLiveInterval; |
| 177 | 177 | date_default_timezone_set('UTC'); |
| 178 | 178 | |
| 179 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 179 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 180 | 180 | |
| 181 | 181 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
| 182 | 182 | if ($globalDBdriver == 'mysql') { |
| 183 | - $query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
|
| 183 | + $query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
|
| 184 | 184 | FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' |
| 185 | 185 | ORDER BY marine_live.fammarine_id, marine_live.date"; |
| 186 | 186 | } else { |
| 187 | - $query = "SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
|
| 187 | + $query = "SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
|
| 188 | 188 | FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' |
| 189 | 189 | ORDER BY marine_live.fammarine_id, marine_live.date"; |
| 190 | 190 | } |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | try { |
| 193 | 193 | $sth = $this->db->prepare($query); |
| 194 | 194 | $sth->execute(); |
| 195 | - } catch(PDOException $e) { |
|
| 195 | + } catch (PDOException $e) { |
|
| 196 | 196 | echo $e->getMessage(); |
| 197 | 197 | die; |
| 198 | 198 | } |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | public function getLiveMarineCount($filter = array()) |
| 210 | 210 | { |
| 211 | 211 | global $globalDBdriver, $globalLiveInterval; |
| 212 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 212 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 213 | 213 | |
| 214 | 214 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
| 215 | 215 | if ($globalDBdriver == 'mysql') { |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | try { |
| 221 | 221 | $sth = $this->db->prepare($query); |
| 222 | 222 | $sth->execute(); |
| 223 | - } catch(PDOException $e) { |
|
| 223 | + } catch (PDOException $e) { |
|
| 224 | 224 | echo $e->getMessage(); |
| 225 | 225 | die; |
| 226 | 226 | } |
@@ -243,10 +243,10 @@ discard block |
||
| 243 | 243 | $filter_query = $this->getFilter($filter); |
| 244 | 244 | |
| 245 | 245 | if (is_array($coord)) { |
| 246 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 247 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 248 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 249 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 246 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 247 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 248 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 249 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 250 | 250 | } else return array(); |
| 251 | 251 | if ($globalDBdriver == 'mysql') { |
| 252 | 252 | $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND marine_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY marine_live.fammarine_id'.$filter_query; |
@@ -271,17 +271,17 @@ discard block |
||
| 271 | 271 | $filter_query = $this->getFilter($filter); |
| 272 | 272 | |
| 273 | 273 | if (is_array($coord)) { |
| 274 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 275 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 276 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 277 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 274 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 275 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 276 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 277 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 278 | 278 | } else return array(); |
| 279 | 279 | if ($globalDBdriver == 'mysql') { |
| 280 | 280 | $query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
| 281 | 281 | FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' AND marine_live.latitude BETWEEN ".$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong." |
| 282 | 282 | ORDER BY marine_live.fammarine_id, marine_live.date"; |
| 283 | 283 | } else { |
| 284 | - $query = "SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
|
| 284 | + $query = "SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
|
| 285 | 285 | FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong." |
| 286 | 286 | ORDER BY marine_live.fammarine_id, marine_live.date"; |
| 287 | 287 | } |
@@ -330,7 +330,7 @@ discard block |
||
| 330 | 330 | if ($interval == '1m') |
| 331 | 331 | { |
| 332 | 332 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
| 333 | - } else if ($interval == '15m'){ |
|
| 333 | + } else if ($interval == '15m') { |
|
| 334 | 334 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= marine_live.date '; |
| 335 | 335 | } |
| 336 | 336 | } |
@@ -338,14 +338,14 @@ discard block |
||
| 338 | 338 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
| 339 | 339 | } |
| 340 | 340 | |
| 341 | - $query = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live |
|
| 341 | + $query = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live |
|
| 342 | 342 | WHERE marine_live.latitude <> '' |
| 343 | 343 | AND marine_live.longitude <> '' |
| 344 | 344 | ".$additional_query." |
| 345 | 345 | HAVING distance < :radius |
| 346 | 346 | ORDER BY distance"; |
| 347 | 347 | |
| 348 | - $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
| 348 | + $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius)); |
|
| 349 | 349 | |
| 350 | 350 | return $spotter_array; |
| 351 | 351 | } |
@@ -363,9 +363,9 @@ discard block |
||
| 363 | 363 | date_default_timezone_set('UTC'); |
| 364 | 364 | |
| 365 | 365 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 366 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
| 366 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
| 367 | 367 | |
| 368 | - $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident),'',true); |
|
| 368 | + $spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident), '', true); |
|
| 369 | 369 | |
| 370 | 370 | return $spotter_array; |
| 371 | 371 | } |
@@ -376,16 +376,16 @@ discard block |
||
| 376 | 376 | * @return Array the spotter information |
| 377 | 377 | * |
| 378 | 378 | */ |
| 379 | - public function getDateLiveMarineDataByIdent($ident,$date) |
|
| 379 | + public function getDateLiveMarineDataByIdent($ident, $date) |
|
| 380 | 380 | { |
| 381 | 381 | $Marine = new Marine($this->db); |
| 382 | 382 | date_default_timezone_set('UTC'); |
| 383 | 383 | |
| 384 | 384 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 385 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
| 385 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
| 386 | 386 | |
| 387 | - $date = date('c',$date); |
|
| 388 | - $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
| 387 | + $date = date('c', $date); |
|
| 388 | + $spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
| 389 | 389 | |
| 390 | 390 | return $spotter_array; |
| 391 | 391 | } |
@@ -402,9 +402,9 @@ discard block |
||
| 402 | 402 | date_default_timezone_set('UTC'); |
| 403 | 403 | |
| 404 | 404 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 405 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
| 405 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
| 406 | 406 | |
| 407 | - $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id),'',true); |
|
| 407 | + $spotter_array = $Marine->getDataFromDB($query, array(':id' => $id), '', true); |
|
| 408 | 408 | |
| 409 | 409 | return $spotter_array; |
| 410 | 410 | } |
@@ -415,15 +415,15 @@ discard block |
||
| 415 | 415 | * @return Array the spotter information |
| 416 | 416 | * |
| 417 | 417 | */ |
| 418 | - public function getDateLiveMarineDataById($id,$date) |
|
| 418 | + public function getDateLiveMarineDataById($id, $date) |
|
| 419 | 419 | { |
| 420 | 420 | $Marine = new Marine($this->db); |
| 421 | 421 | date_default_timezone_set('UTC'); |
| 422 | 422 | |
| 423 | 423 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 424 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
| 425 | - $date = date('c',$date); |
|
| 426 | - $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
|
| 424 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
| 425 | + $date = date('c', $date); |
|
| 426 | + $spotter_array = $Marine->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true); |
|
| 427 | 427 | |
| 428 | 428 | return $spotter_array; |
| 429 | 429 | } |
@@ -435,7 +435,7 @@ discard block |
||
| 435 | 435 | * @return Array the spotter information |
| 436 | 436 | * |
| 437 | 437 | */ |
| 438 | - public function getAllLiveMarineDataById($id,$liveinterval = false) |
|
| 438 | + public function getAllLiveMarineDataById($id, $liveinterval = false) |
|
| 439 | 439 | { |
| 440 | 440 | global $globalDBdriver, $globalLiveInterval; |
| 441 | 441 | date_default_timezone_set('UTC'); |
@@ -454,7 +454,7 @@ discard block |
||
| 454 | 454 | try { |
| 455 | 455 | $sth = $this->db->prepare($query); |
| 456 | 456 | $sth->execute(array(':id' => $id)); |
| 457 | - } catch(PDOException $e) { |
|
| 457 | + } catch (PDOException $e) { |
|
| 458 | 458 | echo $e->getMessage(); |
| 459 | 459 | die; |
| 460 | 460 | } |
@@ -472,12 +472,12 @@ discard block |
||
| 472 | 472 | { |
| 473 | 473 | date_default_timezone_set('UTC'); |
| 474 | 474 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 475 | - $query = self::$global_query.' WHERE marine_live.ident = :ident'; |
|
| 475 | + $query = self::$global_query.' WHERE marine_live.ident = :ident'; |
|
| 476 | 476 | try { |
| 477 | 477 | |
| 478 | 478 | $sth = $this->db->prepare($query); |
| 479 | 479 | $sth->execute(array(':ident' => $ident)); |
| 480 | - } catch(PDOException $e) { |
|
| 480 | + } catch (PDOException $e) { |
|
| 481 | 481 | echo $e->getMessage(); |
| 482 | 482 | die; |
| 483 | 483 | } |
@@ -507,7 +507,7 @@ discard block |
||
| 507 | 507 | |
| 508 | 508 | $sth = $this->db->prepare($query); |
| 509 | 509 | $sth->execute(); |
| 510 | - } catch(PDOException $e) { |
|
| 510 | + } catch (PDOException $e) { |
|
| 511 | 511 | return "error"; |
| 512 | 512 | } |
| 513 | 513 | |
@@ -530,14 +530,14 @@ discard block |
||
| 530 | 530 | |
| 531 | 531 | $sth = $this->db->prepare($query); |
| 532 | 532 | $sth->execute(); |
| 533 | - } catch(PDOException $e) { |
|
| 533 | + } catch (PDOException $e) { |
|
| 534 | 534 | return "error"; |
| 535 | 535 | } |
| 536 | 536 | $query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; |
| 537 | 537 | $i = 0; |
| 538 | - $j =0; |
|
| 538 | + $j = 0; |
|
| 539 | 539 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 540 | - foreach($all as $row) |
|
| 540 | + foreach ($all as $row) |
|
| 541 | 541 | { |
| 542 | 542 | $i++; |
| 543 | 543 | $j++; |
@@ -545,9 +545,9 @@ discard block |
||
| 545 | 545 | if ($globalDebug) echo "."; |
| 546 | 546 | try { |
| 547 | 547 | |
| 548 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
| 548 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
| 549 | 549 | $sth->execute(); |
| 550 | - } catch(PDOException $e) { |
|
| 550 | + } catch (PDOException $e) { |
|
| 551 | 551 | return "error"; |
| 552 | 552 | } |
| 553 | 553 | $query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; |
@@ -558,9 +558,9 @@ discard block |
||
| 558 | 558 | if ($i > 0) { |
| 559 | 559 | try { |
| 560 | 560 | |
| 561 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
| 561 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
| 562 | 562 | $sth->execute(); |
| 563 | - } catch(PDOException $e) { |
|
| 563 | + } catch (PDOException $e) { |
|
| 564 | 564 | return "error"; |
| 565 | 565 | } |
| 566 | 566 | } |
@@ -573,7 +573,7 @@ discard block |
||
| 573 | 573 | |
| 574 | 574 | $sth = $this->db->prepare($query); |
| 575 | 575 | $sth->execute(); |
| 576 | - } catch(PDOException $e) { |
|
| 576 | + } catch (PDOException $e) { |
|
| 577 | 577 | return "error"; |
| 578 | 578 | } |
| 579 | 579 | /* $query_delete = "DELETE FROM marine_live WHERE fammarine_id IN ("; |
@@ -621,13 +621,13 @@ discard block |
||
| 621 | 621 | public function deleteLiveMarineDataByIdent($ident) |
| 622 | 622 | { |
| 623 | 623 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 624 | - $query = 'DELETE FROM marine_live WHERE ident = :ident'; |
|
| 624 | + $query = 'DELETE FROM marine_live WHERE ident = :ident'; |
|
| 625 | 625 | |
| 626 | 626 | try { |
| 627 | 627 | |
| 628 | 628 | $sth = $this->db->prepare($query); |
| 629 | 629 | $sth->execute(array(':ident' => $ident)); |
| 630 | - } catch(PDOException $e) { |
|
| 630 | + } catch (PDOException $e) { |
|
| 631 | 631 | return "error"; |
| 632 | 632 | } |
| 633 | 633 | |
@@ -643,13 +643,13 @@ discard block |
||
| 643 | 643 | public function deleteLiveMarineDataById($id) |
| 644 | 644 | { |
| 645 | 645 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 646 | - $query = 'DELETE FROM marine_live WHERE fammarine_id = :id'; |
|
| 646 | + $query = 'DELETE FROM marine_live WHERE fammarine_id = :id'; |
|
| 647 | 647 | |
| 648 | 648 | try { |
| 649 | 649 | |
| 650 | 650 | $sth = $this->db->prepare($query); |
| 651 | 651 | $sth->execute(array(':id' => $id)); |
| 652 | - } catch(PDOException $e) { |
|
| 652 | + } catch (PDOException $e) { |
|
| 653 | 653 | return "error"; |
| 654 | 654 | } |
| 655 | 655 | |
@@ -667,13 +667,13 @@ discard block |
||
| 667 | 667 | { |
| 668 | 668 | global $globalDBdriver, $globalTimezone; |
| 669 | 669 | if ($globalDBdriver == 'mysql') { |
| 670 | - $query = 'SELECT marine_live.ident FROM marine_live |
|
| 670 | + $query = 'SELECT marine_live.ident FROM marine_live |
|
| 671 | 671 | WHERE marine_live.ident = :ident |
| 672 | 672 | AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
| 673 | 673 | AND marine_live.date < UTC_TIMESTAMP()'; |
| 674 | 674 | $query_data = array(':ident' => $ident); |
| 675 | 675 | } else { |
| 676 | - $query = "SELECT marine_live.ident FROM marine_live |
|
| 676 | + $query = "SELECT marine_live.ident FROM marine_live |
|
| 677 | 677 | WHERE marine_live.ident = :ident |
| 678 | 678 | AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
| 679 | 679 | AND marine_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -682,8 +682,8 @@ discard block |
||
| 682 | 682 | |
| 683 | 683 | $sth = $this->db->prepare($query); |
| 684 | 684 | $sth->execute($query_data); |
| 685 | - $ident_result=''; |
|
| 686 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 685 | + $ident_result = ''; |
|
| 686 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 687 | 687 | { |
| 688 | 688 | $ident_result = $row['ident']; |
| 689 | 689 | } |
@@ -700,13 +700,13 @@ discard block |
||
| 700 | 700 | { |
| 701 | 701 | global $globalDBdriver, $globalTimezone; |
| 702 | 702 | if ($globalDBdriver == 'mysql') { |
| 703 | - $query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
| 703 | + $query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
| 704 | 704 | WHERE marine_live.ident = :ident |
| 705 | 705 | AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; |
| 706 | 706 | // AND marine_live.date < UTC_TIMESTAMP()"; |
| 707 | 707 | $query_data = array(':ident' => $ident); |
| 708 | 708 | } else { |
| 709 | - $query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
| 709 | + $query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
| 710 | 710 | WHERE marine_live.ident = :ident |
| 711 | 711 | AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '30 MINUTES'"; |
| 712 | 712 | // AND marine_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -715,8 +715,8 @@ discard block |
||
| 715 | 715 | |
| 716 | 716 | $sth = $this->db->prepare($query); |
| 717 | 717 | $sth->execute($query_data); |
| 718 | - $ident_result=''; |
|
| 719 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 718 | + $ident_result = ''; |
|
| 719 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 720 | 720 | { |
| 721 | 721 | $ident_result = $row['fammarine_id']; |
| 722 | 722 | } |
@@ -733,13 +733,13 @@ discard block |
||
| 733 | 733 | { |
| 734 | 734 | global $globalDBdriver, $globalTimezone; |
| 735 | 735 | if ($globalDBdriver == 'mysql') { |
| 736 | - $query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
| 736 | + $query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
| 737 | 737 | WHERE marine_live.fammarine_id = :id |
| 738 | 738 | AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; |
| 739 | 739 | // AND marine_live.date < UTC_TIMESTAMP()"; |
| 740 | 740 | $query_data = array(':id' => $id); |
| 741 | 741 | } else { |
| 742 | - $query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
| 742 | + $query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
| 743 | 743 | WHERE marine_live.fammarine_id = :id |
| 744 | 744 | AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'"; |
| 745 | 745 | // AND marine_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -748,8 +748,8 @@ discard block |
||
| 748 | 748 | |
| 749 | 749 | $sth = $this->db->prepare($query); |
| 750 | 750 | $sth->execute($query_data); |
| 751 | - $ident_result=''; |
|
| 752 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 751 | + $ident_result = ''; |
|
| 752 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 753 | 753 | { |
| 754 | 754 | $ident_result = $row['fammarine_id']; |
| 755 | 755 | } |
@@ -766,13 +766,13 @@ discard block |
||
| 766 | 766 | { |
| 767 | 767 | global $globalDBdriver, $globalTimezone; |
| 768 | 768 | if ($globalDBdriver == 'mysql') { |
| 769 | - $query = 'SELECT marine_live.fammarine_id FROM marine_live |
|
| 769 | + $query = 'SELECT marine_live.fammarine_id FROM marine_live |
|
| 770 | 770 | WHERE marine_live.mmsi = :mmsi |
| 771 | 771 | AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; |
| 772 | 772 | // AND marine_live.date < UTC_TIMESTAMP()"; |
| 773 | 773 | $query_data = array(':mmsi' => $mmsi); |
| 774 | 774 | } else { |
| 775 | - $query = "SELECT marine_live.fammarine_id FROM marine_live |
|
| 775 | + $query = "SELECT marine_live.fammarine_id FROM marine_live |
|
| 776 | 776 | WHERE marine_live.mmsi = :mmsi |
| 777 | 777 | AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'"; |
| 778 | 778 | // AND marine_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -781,8 +781,8 @@ discard block |
||
| 781 | 781 | |
| 782 | 782 | $sth = $this->db->prepare($query); |
| 783 | 783 | $sth->execute($query_data); |
| 784 | - $ident_result=''; |
|
| 785 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 784 | + $ident_result = ''; |
|
| 785 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 786 | 786 | { |
| 787 | 787 | $ident_result = $row['fammarine_id']; |
| 788 | 788 | } |
@@ -800,7 +800,7 @@ discard block |
||
| 800 | 800 | * @return String success or false |
| 801 | 801 | * |
| 802 | 802 | */ |
| 803 | - public function addLiveMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '',$type = '',$typeid = '',$imo = '', $callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '') |
|
| 803 | + public function addLiveMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '', $type = '', $typeid = '', $imo = '', $callsign = '', $arrival_code = '', $arrival_date = '', $status = '', $statusid = '', $noarchive = false, $format_source = '', $source_name = '', $over_country = '') |
|
| 804 | 804 | { |
| 805 | 805 | global $globalURL, $globalArchive, $globalDebug; |
| 806 | 806 | $Common = new Common(); |
@@ -852,26 +852,26 @@ discard block |
||
| 852 | 852 | if ($date == '') $date = date("Y-m-d H:i:s", time()); |
| 853 | 853 | |
| 854 | 854 | |
| 855 | - $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
|
| 856 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
| 857 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 858 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 859 | - $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
|
| 860 | - $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 861 | - $format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
|
| 862 | - $source_name = filter_var($source_name,FILTER_SANITIZE_STRING); |
|
| 863 | - $over_country = filter_var($over_country,FILTER_SANITIZE_STRING); |
|
| 864 | - $type = filter_var($type,FILTER_SANITIZE_STRING); |
|
| 865 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); |
|
| 866 | - $status = filter_var($status,FILTER_SANITIZE_STRING); |
|
| 867 | - $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
|
| 868 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
| 869 | - $arrival_code = filter_var($arrival_code,FILTER_SANITIZE_STRING); |
|
| 870 | - $arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING); |
|
| 855 | + $fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING); |
|
| 856 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 857 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 858 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 859 | + $heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT); |
|
| 860 | + $groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 861 | + $format_source = filter_var($format_source, FILTER_SANITIZE_STRING); |
|
| 862 | + $source_name = filter_var($source_name, FILTER_SANITIZE_STRING); |
|
| 863 | + $over_country = filter_var($over_country, FILTER_SANITIZE_STRING); |
|
| 864 | + $type = filter_var($type, FILTER_SANITIZE_STRING); |
|
| 865 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT); |
|
| 866 | + $status = filter_var($status, FILTER_SANITIZE_STRING); |
|
| 867 | + $imo = filter_var($imo, FILTER_SANITIZE_STRING); |
|
| 868 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
| 869 | + $arrival_code = filter_var($arrival_code, FILTER_SANITIZE_STRING); |
|
| 870 | + $arrival_date = filter_var($arrival_date, FILTER_SANITIZE_STRING); |
|
| 871 | 871 | |
| 872 | 872 | |
| 873 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
| 874 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
| 873 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
| 874 | + if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
| 875 | 875 | if ($arrival_date == '') $arrival_date = NULL; |
| 876 | 876 | $query = ''; |
| 877 | 877 | if ($globalArchive) { |
@@ -881,18 +881,18 @@ discard block |
||
| 881 | 881 | $query .= 'INSERT INTO marine_live (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,status,imo,arrival_port_name,arrival_port_date) |
| 882 | 882 | VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)'; |
| 883 | 883 | |
| 884 | - $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country,':mmsi' => $mmsi,':type' => $type,':status' => $status,':imo' => $imo,':arrival_port_name' => $arrival_code,':arrival_port_date' => $arrival_date); |
|
| 884 | + $query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country, ':mmsi' => $mmsi, ':type' => $type, ':status' => $status, ':imo' => $imo, ':arrival_port_name' => $arrival_code, ':arrival_port_date' => $arrival_date); |
|
| 885 | 885 | try { |
| 886 | 886 | $sth = $this->db->prepare($query); |
| 887 | 887 | $sth->execute($query_values); |
| 888 | - } catch(PDOException $e) { |
|
| 888 | + } catch (PDOException $e) { |
|
| 889 | 889 | return "error : ".$e->getMessage(); |
| 890 | 890 | } |
| 891 | 891 | |
| 892 | 892 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
| 893 | 893 | if ($globalDebug) echo '(Add to Marine archive : '; |
| 894 | 894 | $MarineArchive = new MarineArchive($this->db); |
| 895 | - $result = $MarineArchive->addMarineArchiveData($fammarine_id, $ident, $latitude, $longitude, $heading, $groundspeed, $date, $putinarchive, $mmsi,$type,$typeid,$imo, $callsign,$arrival_code,$arrival_date,$status,$noarchive,$format_source, $source_name, $over_country); |
|
| 895 | + $result = $MarineArchive->addMarineArchiveData($fammarine_id, $ident, $latitude, $longitude, $heading, $groundspeed, $date, $putinarchive, $mmsi, $type, $typeid, $imo, $callsign, $arrival_code, $arrival_date, $status, $noarchive, $format_source, $source_name, $over_country); |
|
| 896 | 896 | if ($globalDebug) echo $result.')'; |
| 897 | 897 | } |
| 898 | 898 | return "success"; |
@@ -900,7 +900,7 @@ discard block |
||
| 900 | 900 | |
| 901 | 901 | public function getOrderBy() |
| 902 | 902 | { |
| 903 | - $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY marine_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY marine_live.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_live.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_live.date DESC")); |
|
| 903 | + $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY marine_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY marine_live.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_live.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_live.date DESC")); |
|
| 904 | 904 | return $orderby; |
| 905 | 905 | } |
| 906 | 906 | |
@@ -90,8 +90,7 @@ discard block |
||
| 90 | 90 | |
| 91 | 91 | |
| 92 | 92 | private function urshift($n, $s) { |
| 93 | - return ($n >= 0) ? ($n >> $s) : |
|
| 94 | - (($n & 0x7fffffff) >> $s) | |
|
| 93 | + return ($n >= 0) ? ($n >> $s) : (($n&0x7fffffff) >> $s)| |
|
| 95 | 94 | (0x40000000 >> ($s - 1)); |
| 96 | 95 | } |
| 97 | 96 | |
@@ -103,7 +102,7 @@ discard block |
||
| 103 | 102 | //$split_input = str_split($input); |
| 104 | 103 | |
| 105 | 104 | /* Find the end of header checking for NULL bytes while doing it. */ |
| 106 | - $splitpos = strpos($input,':'); |
|
| 105 | + $splitpos = strpos($input, ':'); |
|
| 107 | 106 | |
| 108 | 107 | /* Check that end was found and body has at least one byte. */ |
| 109 | 108 | if ($splitpos == 0 || $splitpos + 1 == $input_len || $splitpos === FALSE) { |
@@ -113,15 +112,15 @@ discard block |
||
| 113 | 112 | |
| 114 | 113 | if ($debug) echo 'input : '.$input."\n"; |
| 115 | 114 | /* Save header and body. */ |
| 116 | - $body = substr($input,$splitpos+1,$input_len); |
|
| 115 | + $body = substr($input, $splitpos + 1, $input_len); |
|
| 117 | 116 | $body_len = strlen($body); |
| 118 | - $header = substr($input,0,$splitpos); |
|
| 117 | + $header = substr($input, 0, $splitpos); |
|
| 119 | 118 | //$header_len = strlen($header); |
| 120 | 119 | if ($debug) echo 'header : '.$header."\n"; |
| 121 | 120 | |
| 122 | 121 | /* Parse source, target and path. */ |
| 123 | 122 | //FLRDF0A52>APRS,qAS,LSTB |
| 124 | - if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/',$header,$matches)) { |
|
| 123 | + if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/', $header, $matches)) { |
|
| 125 | 124 | $ident = $matches[1]; |
| 126 | 125 | $all_elements = $matches[2]; |
| 127 | 126 | if ($ident == 'AIRCRAFT') { |
@@ -135,14 +134,14 @@ discard block |
||
| 135 | 134 | $result['ident'] = $ident; |
| 136 | 135 | } |
| 137 | 136 | } else return false; |
| 138 | - $elements = explode(',',$all_elements); |
|
| 137 | + $elements = explode(',', $all_elements); |
|
| 139 | 138 | $source = end($elements); |
| 140 | 139 | $result['source'] = $source; |
| 141 | 140 | foreach ($elements as $element) { |
| 142 | - if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) { |
|
| 141 | + if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/', $element)) { |
|
| 143 | 142 | //echo "ok"; |
| 144 | 143 | //if ($element == 'TCPIP*') return false; |
| 145 | - } elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) { |
|
| 144 | + } elseif (!preg_match('/^([0-9A-F]{32})$/', $element)) { |
|
| 146 | 145 | if ($debug) echo 'element : '.$element."\n"; |
| 147 | 146 | return false; |
| 148 | 147 | } |
@@ -155,14 +154,14 @@ discard block |
||
| 155 | 154 | */ |
| 156 | 155 | } |
| 157 | 156 | |
| 158 | - $type = substr($body,0,1); |
|
| 157 | + $type = substr($body, 0, 1); |
|
| 159 | 158 | if ($debug) echo 'type : '.$type."\n"; |
| 160 | 159 | if ($type == ';') { |
| 161 | 160 | if (isset($result['source_type']) && $result['source_type'] == 'modes') { |
| 162 | - $result['address'] = trim(substr($body,1,9)); |
|
| 161 | + $result['address'] = trim(substr($body, 1, 9)); |
|
| 163 | 162 | } elseif (isset($result['source_type']) && $result['source_type'] == 'ais') { |
| 164 | - $result['mmsi'] = trim(substr($body,1,9)); |
|
| 165 | - } else $result['ident'] = trim(substr($body,1,9)); |
|
| 163 | + $result['mmsi'] = trim(substr($body, 1, 9)); |
|
| 164 | + } else $result['ident'] = trim(substr($body, 1, 9)); |
|
| 166 | 165 | } elseif ($type == ',') { |
| 167 | 166 | // Invalid data or test data |
| 168 | 167 | return false; |
@@ -170,24 +169,24 @@ discard block |
||
| 170 | 169 | |
| 171 | 170 | // Check for Timestamp |
| 172 | 171 | $find = false; |
| 173 | - $body_parse = substr($body,1); |
|
| 172 | + $body_parse = substr($body, 1); |
|
| 174 | 173 | //echo 'Body : '.$body."\n"; |
| 175 | - if (preg_match('/^;(.){9}\*/',$body,$matches)) { |
|
| 176 | - $body_parse = substr($body_parse,10); |
|
| 174 | + if (preg_match('/^;(.){9}\*/', $body, $matches)) { |
|
| 175 | + $body_parse = substr($body_parse, 10); |
|
| 177 | 176 | $find = true; |
| 178 | 177 | //echo $body_parse."\n"; |
| 179 | 178 | } |
| 180 | - if (preg_match('/^`(.*)\//',$body,$matches)) { |
|
| 181 | - $body_parse = substr($body_parse,strlen($matches[1])-1); |
|
| 179 | + if (preg_match('/^`(.*)\//', $body, $matches)) { |
|
| 180 | + $body_parse = substr($body_parse, strlen($matches[1]) - 1); |
|
| 182 | 181 | $find = true; |
| 183 | 182 | //echo $body_parse."\n"; |
| 184 | 183 | } |
| 185 | - if (preg_match("/^'(.*)\//",$body,$matches)) { |
|
| 186 | - $body_parse = substr($body_parse,strlen($matches[1])-1); |
|
| 184 | + if (preg_match("/^'(.*)\//", $body, $matches)) { |
|
| 185 | + $body_parse = substr($body_parse, strlen($matches[1]) - 1); |
|
| 187 | 186 | $find = true; |
| 188 | 187 | //echo $body_parse."\n"; |
| 189 | 188 | } |
| 190 | - if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/',$body_parse,$matches)) { |
|
| 189 | + if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/', $body_parse, $matches)) { |
|
| 191 | 190 | $find = true; |
| 192 | 191 | //print_r($matches); |
| 193 | 192 | $timestamp = $matches[0]; |
@@ -202,19 +201,19 @@ discard block |
||
| 202 | 201 | // This work or not ? |
| 203 | 202 | $timestamp = strtotime(date('Ym').$matches[1].' '.$matches[2].':'.$matches[3]); |
| 204 | 203 | } |
| 205 | - $body_parse = substr($body_parse,7); |
|
| 204 | + $body_parse = substr($body_parse, 7); |
|
| 206 | 205 | $result['timestamp'] = $timestamp; |
| 207 | 206 | //echo date('Ymd H:i:s',$timestamp); |
| 208 | 207 | } |
| 209 | - if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/',$body_parse,$matches)) { |
|
| 208 | + if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/', $body_parse, $matches)) { |
|
| 210 | 209 | $find = true; |
| 211 | 210 | $timestamp = strtotime(date('Y').$matches[1].$matches[2].' '.$matches[3].':'.$matches[4]); |
| 212 | - $body_parse = substr($body_parse,8); |
|
| 211 | + $body_parse = substr($body_parse, 8); |
|
| 213 | 212 | $result['timestamp'] = $timestamp; |
| 214 | 213 | //echo date('Ymd H:i:s',$timestamp); |
| 215 | 214 | } |
| 216 | 215 | //if (strlen($body_parse) > 19) { |
| 217 | - if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/',$body_parse,$matches)) { |
|
| 216 | + if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/', $body_parse, $matches)) { |
|
| 218 | 217 | $find = true; |
| 219 | 218 | // 4658.70N/00707.78Ez |
| 220 | 219 | //print_r(str_split($body_parse)); |
@@ -240,11 +239,11 @@ discard block |
||
| 240 | 239 | */ |
| 241 | 240 | $latitude = $lat + floatval($lat_min)/60; |
| 242 | 241 | $longitude = $lon + floatval($lon_min)/60; |
| 243 | - if ($sind == 'S') $latitude = 0-$latitude; |
|
| 244 | - if ($wind == 'W') $longitude = 0-$longitude; |
|
| 242 | + if ($sind == 'S') $latitude = 0 - $latitude; |
|
| 243 | + if ($wind == 'W') $longitude = 0 - $longitude; |
|
| 245 | 244 | $result['latitude'] = $latitude; |
| 246 | 245 | $result['longitude'] = $longitude; |
| 247 | - $body_parse = substr($body_parse,18); |
|
| 246 | + $body_parse = substr($body_parse, 18); |
|
| 248 | 247 | $body_parse_len = strlen($body_parse); |
| 249 | 248 | } |
| 250 | 249 | $body_parse_len = strlen($body_parse); |
@@ -272,7 +271,7 @@ discard block |
||
| 272 | 271 | //echo $body_parse; |
| 273 | 272 | //if ($type != ';' && $type != '>') { |
| 274 | 273 | if ($type != '') { |
| 275 | - $body_parse = substr($body_parse,1); |
|
| 274 | + $body_parse = substr($body_parse, 1); |
|
| 276 | 275 | $body_parse_len = strlen($body_parse); |
| 277 | 276 | $result['symbol_code'] = $symbol_code; |
| 278 | 277 | if (isset($this->symbols[$symbol_code])) $result['symbol'] = $this->symbols[$symbol_code]; |
@@ -283,16 +282,16 @@ discard block |
||
| 283 | 282 | //$body_parse_len = strlen($body_parse); |
| 284 | 283 | if ($body_parse_len >= 7) { |
| 285 | 284 | |
| 286 | - if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) { |
|
| 287 | - $course = substr($body_parse,0,3); |
|
| 285 | + if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/', $body_parse)) { |
|
| 286 | + $course = substr($body_parse, 0, 3); |
|
| 288 | 287 | $tmp_s = intval($course); |
| 289 | 288 | if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course); |
| 290 | - $speed = substr($body_parse,4,3); |
|
| 289 | + $speed = substr($body_parse, 4, 3); |
|
| 291 | 290 | if ($speed != '...') { |
| 292 | 291 | //$result['speed'] = round($speed*1.852); |
| 293 | 292 | $result['speed'] = intval($speed); |
| 294 | 293 | } |
| 295 | - $body_parse = substr($body_parse,7); |
|
| 294 | + $body_parse = substr($body_parse, 7); |
|
| 296 | 295 | } |
| 297 | 296 | // Check PHGR, PHG, RNG |
| 298 | 297 | } |
@@ -302,12 +301,12 @@ discard block |
||
| 302 | 301 | } |
| 303 | 302 | */ |
| 304 | 303 | if (strlen($body_parse) > 0) { |
| 305 | - if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/',$body_parse,$matches)) { |
|
| 304 | + if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/', $body_parse, $matches)) { |
|
| 306 | 305 | $altitude = intval($matches[1]); |
| 307 | 306 | //$result['altitude'] = round($altitude*0.3048); |
| 308 | 307 | $result['altitude'] = $altitude; |
| 309 | 308 | //$body_parse = trim(substr($body_parse,strlen($matches[0]))); |
| 310 | - $body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/','',$body_parse)); |
|
| 309 | + $body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/', '', $body_parse)); |
|
| 311 | 310 | } |
| 312 | 311 | } |
| 313 | 312 | |
@@ -319,13 +318,13 @@ discard block |
||
| 319 | 318 | */ |
| 320 | 319 | // DAO |
| 321 | 320 | |
| 322 | - if (preg_match('/^!([0-9A-Z]{3})/',$body_parse,$matches)) { |
|
| 321 | + if (preg_match('/^!([0-9A-Z]{3})/', $body_parse, $matches)) { |
|
| 323 | 322 | |
| 324 | 323 | $dao = $matches[1]; |
| 325 | - if (preg_match('/^([A-Z])([0-9]{2})/',$dao)) { |
|
| 324 | + if (preg_match('/^([A-Z])([0-9]{2})/', $dao)) { |
|
| 326 | 325 | $dao_split = str_split($dao); |
| 327 | - $lat_off = (($dao_split[1])-48.0)*0.001/60.0; |
|
| 328 | - $lon_off = (($dao_split[2])-48.0)*0.001/60.0; |
|
| 326 | + $lat_off = (($dao_split[1]) - 48.0)*0.001/60.0; |
|
| 327 | + $lon_off = (($dao_split[2]) - 48.0)*0.001/60.0; |
|
| 329 | 328 | |
| 330 | 329 | if ($result['latitude'] < 0) $result['latitude'] -= $lat_off; |
| 331 | 330 | else $result['latitude'] += $lat_off; |
@@ -333,47 +332,47 @@ discard block |
||
| 333 | 332 | else $result['longitude'] += $lon_off; |
| 334 | 333 | } |
| 335 | 334 | |
| 336 | - $body_parse = substr($body_parse,6); |
|
| 335 | + $body_parse = substr($body_parse, 6); |
|
| 337 | 336 | } |
| 338 | 337 | |
| 339 | - if (preg_match('/CS=([0-9A-Z]*)/',$body_parse,$matches)) { |
|
| 338 | + if (preg_match('/CS=([0-9A-Z]*)/', $body_parse, $matches)) { |
|
| 340 | 339 | $result['ident'] = $matches[1]; |
| 341 | 340 | } |
| 342 | - if (preg_match('/SQ=([0-9]{4})/',$body_parse,$matches)) { |
|
| 341 | + if (preg_match('/SQ=([0-9]{4})/', $body_parse, $matches)) { |
|
| 343 | 342 | $result['squawk'] = $matches[1]; |
| 344 | 343 | } |
| 345 | - if (preg_match('/AI=([0-9A-Z]{4})/',$body_parse,$matches)) { |
|
| 344 | + if (preg_match('/AI=([0-9A-Z]{4})/', $body_parse, $matches)) { |
|
| 346 | 345 | $result['aircraft_icao'] = $matches[1]; |
| 347 | 346 | } |
| 348 | - if (preg_match('/TI=([0-9]*)/',$body_parse,$matches)) { |
|
| 347 | + if (preg_match('/TI=([0-9]*)/', $body_parse, $matches)) { |
|
| 349 | 348 | $result['typeid'] = $matches[1]; |
| 350 | 349 | } |
| 351 | - if (preg_match('/SI=([0-9]*)/',$body_parse,$matches)) { |
|
| 350 | + if (preg_match('/SI=([0-9]*)/', $body_parse, $matches)) { |
|
| 352 | 351 | $result['statusid'] = $matches[1]; |
| 353 | 352 | } |
| 354 | - if (preg_match('/IMO=([0-9]{7})/',$body_parse,$matches)) { |
|
| 353 | + if (preg_match('/IMO=([0-9]{7})/', $body_parse, $matches)) { |
|
| 355 | 354 | $result['imo'] = $matches[1]; |
| 356 | 355 | } |
| 357 | - if (preg_match('/AD=([0-9]*)/',$body_parse,$matches)) { |
|
| 356 | + if (preg_match('/AD=([0-9]*)/', $body_parse, $matches)) { |
|
| 358 | 357 | $result['arrival_date'] = $matches[1]; |
| 359 | 358 | } |
| 360 | - if (preg_match('/AC=([0-9A-Z]*)/',$body_parse,$matches)) { |
|
| 359 | + if (preg_match('/AC=([0-9A-Z]*)/', $body_parse, $matches)) { |
|
| 361 | 360 | $result['arrival_code'] = $matches[1]; |
| 362 | 361 | } |
| 363 | 362 | // OGN comment |
| 364 | 363 | // echo "Before OGN : ".$body_parse."\n"; |
| 365 | 364 | //if (preg_match('/^id([0-9A-F]{8}) ([+-])([0-9]{3,4})fpm ([+-])([0-9.]{3,4})rot (.*)$/',$body_parse,$matches)) { |
| 366 | - if (preg_match('/^id([0-9A-F]{8})/',$body_parse,$matches)) { |
|
| 365 | + if (preg_match('/^id([0-9A-F]{8})/', $body_parse, $matches)) { |
|
| 367 | 366 | $id = $matches[1]; |
| 368 | 367 | //$mode = substr($id,0,2); |
| 369 | - $address = substr($id,2); |
|
| 368 | + $address = substr($id, 2); |
|
| 370 | 369 | //print_r($matches); |
| 371 | - $addressType = (intval(substr($id,0,2),16))&3; |
|
| 370 | + $addressType = (intval(substr($id, 0, 2), 16))&3; |
|
| 372 | 371 | if ($addressType == 0) $result['addresstype'] = "RANDOM"; |
| 373 | 372 | elseif ($addressType == 1) $result['addresstype'] = "ICAO"; |
| 374 | 373 | elseif ($addressType == 2) $result['addresstype'] = "FLARM"; |
| 375 | 374 | elseif ($addressType == 3) $result['addresstype'] = "OGN"; |
| 376 | - $aircraftType = $this->urshift(((intval(substr($id,0,2),16)) & 0b1111100),2); |
|
| 375 | + $aircraftType = $this->urshift(((intval(substr($id, 0, 2), 16))&0b1111100), 2); |
|
| 377 | 376 | $result['aircrafttype_code'] = $aircraftType; |
| 378 | 377 | if ($aircraftType == 0) $result['aircrafttype'] = "UNKNOWN"; |
| 379 | 378 | elseif ($aircraftType == 1) $result['aircrafttype'] = "GLIDER"; |
@@ -390,7 +389,7 @@ discard block |
||
| 390 | 389 | elseif ($aircraftType == 12) $result['aircrafttype'] = "AIRSHIP"; |
| 391 | 390 | elseif ($aircraftType == 13) $result['aircrafttype'] = "UAV"; |
| 392 | 391 | elseif ($aircraftType == 15) $result['aircrafttype'] = "STATIC_OBJECT"; |
| 393 | - $stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0; |
|
| 392 | + $stealth = (intval(substr($id, 0, 2), 16)&0b10000000) != 0; |
|
| 394 | 393 | $result['stealth'] = $stealth; |
| 395 | 394 | $result['address'] = $address; |
| 396 | 395 | } |
@@ -402,77 +401,77 @@ discard block |
||
| 402 | 401 | //$body_parse = substr($body_parse,1); |
| 403 | 402 | //$body_parse_len = strlen($body_parse); |
| 404 | 403 | |
| 405 | - if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
| 404 | + if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) { |
|
| 406 | 405 | $result['wind_dir'] = intval($matches[1]); |
| 407 | - $result['wind_speed'] = round(intval($matches[2])*1.60934,1); |
|
| 408 | - $result['wind_gust'] = round(intval($matches[3])*1.60934,1); |
|
| 409 | - $result['temp'] = round(5/9*((intval($matches[4]))-32),1); |
|
| 410 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
| 411 | - } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
| 406 | + $result['wind_speed'] = round(intval($matches[2])*1.60934, 1); |
|
| 407 | + $result['wind_gust'] = round(intval($matches[3])*1.60934, 1); |
|
| 408 | + $result['temp'] = round(5/9*((intval($matches[4])) - 32), 1); |
|
| 409 | + $body_parse = substr($body_parse, strlen($matches[0]) + 1); |
|
| 410 | + } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) { |
|
| 412 | 411 | $result['wind_dir'] = intval($matches[1]); |
| 413 | - $result['wind_speed'] = round($matches[2]*1.60934,1); |
|
| 414 | - $result['wind_gust'] = round($matches[3]*1.60934,1); |
|
| 415 | - $result['temp'] = round(5/9*(($matches[4])-32),1); |
|
| 416 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
| 417 | - } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
| 412 | + $result['wind_speed'] = round($matches[2]*1.60934, 1); |
|
| 413 | + $result['wind_gust'] = round($matches[3]*1.60934, 1); |
|
| 414 | + $result['temp'] = round(5/9*(($matches[4]) - 32), 1); |
|
| 415 | + $body_parse = substr($body_parse, strlen($matches[0]) + 1); |
|
| 416 | + } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) { |
|
| 418 | 417 | $result['wind_dir'] = intval($matches[1]); |
| 419 | - $result['wind_speed'] = round($matches[2]*1.60934,1); |
|
| 420 | - $result['wind_gust'] = round($matches[3]*1.60934,1); |
|
| 421 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
| 422 | - } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/',$body_parse,$matches)) { |
|
| 418 | + $result['wind_speed'] = round($matches[2]*1.60934, 1); |
|
| 419 | + $result['wind_gust'] = round($matches[3]*1.60934, 1); |
|
| 420 | + $body_parse = substr($body_parse, strlen($matches[0]) + 1); |
|
| 421 | + } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/', $body_parse, $matches)) { |
|
| 423 | 422 | $result['wind_dir'] = intval($matches[1]); |
| 424 | - $result['wind_speed'] = round($matches[2]*1.60934,1); |
|
| 425 | - $result['wind_gust'] = round($matches[3]*1.60934,1); |
|
| 426 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
| 423 | + $result['wind_speed'] = round($matches[2]*1.60934, 1); |
|
| 424 | + $result['wind_gust'] = round($matches[3]*1.60934, 1); |
|
| 425 | + $body_parse = substr($body_parse, strlen($matches[0]) + 1); |
|
| 427 | 426 | } |
| 428 | - if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/',$body_parse,$matches)) { |
|
| 429 | - $result['temp'] = round(5/9*(($matches[1])-32),1); |
|
| 427 | + if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/', $body_parse, $matches)) { |
|
| 428 | + $result['temp'] = round(5/9*(($matches[1]) - 32), 1); |
|
| 430 | 429 | } |
| 431 | 430 | } |
| 432 | 431 | } else $result['comment'] = trim($body_parse); |
| 433 | 432 | |
| 434 | 433 | } |
| 435 | 434 | //} |
| 436 | - if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4); |
|
| 437 | - if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4); |
|
| 435 | + if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'], 4); |
|
| 436 | + if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'], 4); |
|
| 438 | 437 | if ($debug) print_r($result); |
| 439 | 438 | return $result; |
| 440 | 439 | } |
| 441 | 440 | |
| 442 | 441 | public function connect() { |
| 443 | - global $globalAPRSversion, $globalServerAPRSssid, $globalServerAPRSpass,$globalName, $globalServerAPRShost, $globalServerAPRSport; |
|
| 442 | + global $globalAPRSversion, $globalServerAPRSssid, $globalServerAPRSpass, $globalName, $globalServerAPRShost, $globalServerAPRSport; |
|
| 444 | 443 | $aprs_connect = 0; |
| 445 | 444 | $aprs_keep = 120; |
| 446 | 445 | $aprs_last_tx = time(); |
| 447 | 446 | if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; |
| 448 | - else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
| 447 | + else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName); |
|
| 449 | 448 | if (isset($globalServerAPRSssid)) $aprs_ssid = $globalServerAPRSssid; |
| 450 | - else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
| 449 | + else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8); |
|
| 451 | 450 | if (isset($globalServerAPRSpass)) $aprs_pass = $globalServerAPRSpass; |
| 452 | 451 | else $aprs_pass = '-1'; |
| 453 | 452 | |
| 454 | - $aprs_filter = ''; |
|
| 453 | + $aprs_filter = ''; |
|
| 455 | 454 | $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; |
| 456 | 455 | $Common = new Common(); |
| 457 | - $s = $Common->create_socket($globalServerAPRShost,$globalServerAPRSport,$errno,$errstr); |
|
| 456 | + $s = $Common->create_socket($globalServerAPRShost, $globalServerAPRSport, $errno, $errstr); |
|
| 458 | 457 | if ($s !== false) { |
| 459 | 458 | echo 'Connected to APRS server! '."\n"; |
| 460 | 459 | $authstart = time(); |
| 461 | 460 | $this->socket = $s; |
| 462 | - $send = socket_send( $this->socket , $aprs_login , strlen($aprs_login) , 0 ); |
|
| 463 | - while ($msgin = socket_read($this->socket, 1000,PHP_NORMAL_READ)) { |
|
| 461 | + $send = socket_send($this->socket, $aprs_login, strlen($aprs_login), 0); |
|
| 462 | + while ($msgin = socket_read($this->socket, 1000, PHP_NORMAL_READ)) { |
|
| 464 | 463 | if (strpos($msgin, "$aprs_ssid verified") !== FALSE) { |
| 465 | 464 | echo 'APRS user verified !'."\n"; |
| 466 | 465 | $this->connected = true; |
| 467 | 466 | return true; |
| 468 | 467 | break; |
| 469 | 468 | } |
| 470 | - if (time()-$authstart > 5) { |
|
| 469 | + if (time() - $authstart > 5) { |
|
| 471 | 470 | echo 'APRS timeout'."\n"; |
| 472 | 471 | break; |
| 473 | 472 | } |
| 474 | 473 | } |
| 475 | - socket_set_option($this->socket,SOL_SOCKET,SO_KEEPALIVE); |
|
| 474 | + socket_set_option($this->socket, SOL_SOCKET, SO_KEEPALIVE); |
|
| 476 | 475 | } |
| 477 | 476 | } |
| 478 | 477 | |
@@ -482,7 +481,7 @@ discard block |
||
| 482 | 481 | |
| 483 | 482 | public function send($data) { |
| 484 | 483 | if ($this->connected === false) $this->connect(); |
| 485 | - $send = socket_send( $this->socket , $data , strlen($data),0); |
|
| 484 | + $send = socket_send($this->socket, $data, strlen($data), 0); |
|
| 486 | 485 | if ($send === FALSE) { |
| 487 | 486 | socket_close($this->socket); |
| 488 | 487 | $this->connect(); |
@@ -491,14 +490,14 @@ discard block |
||
| 491 | 490 | } |
| 492 | 491 | |
| 493 | 492 | class APRSSpotter extends APRS { |
| 494 | - public function addLiveSpotterData($id,$ident,$aircraft_icao,$departure_airport,$arrival_airport,$latitude,$longitude,$waypoints,$altitude,$altitude_real,$heading,$speed,$datetime,$departure_airport_time,$arrival_airport_time,$squawk,$route_stop,$hex,$putinarchive,$registration,$pilot_id,$pilot_name, $verticalrate, $noarchive, $ground,$format_source,$source_name,$over_country) { |
|
| 493 | + public function addLiveSpotterData($id, $ident, $aircraft_icao, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $altitude_real, $heading, $speed, $datetime, $departure_airport_time, $arrival_airport_time, $squawk, $route_stop, $hex, $putinarchive, $registration, $pilot_id, $pilot_name, $verticalrate, $noarchive, $ground, $format_source, $source_name, $over_country) { |
|
| 495 | 494 | $Common = new Common(); |
| 496 | 495 | if ($latitude != '' && $longitude != '') { |
| 497 | - $latitude = $Common->convertDM($latitude,'latitude'); |
|
| 498 | - $longitude = $Common->convertDM($longitude,'longitude'); |
|
| 499 | - $coordinate = sprintf("%02d",$latitude['deg']).str_pad(number_format($latitude['min'],2,'.',''),5,'0',STR_PAD_LEFT).$latitude['NSEW'].'/'.sprintf("%03d",$longitude['deg']).str_pad(number_format($longitude['min'],2,'.',''),5,'0',STR_PAD_LEFT).$longitude['NSEW']; |
|
| 500 | - $w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'],2,'.',''))*1000)); |
|
| 501 | - $w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'],2,'.',''))*1000)); |
|
| 496 | + $latitude = $Common->convertDM($latitude, 'latitude'); |
|
| 497 | + $longitude = $Common->convertDM($longitude, 'longitude'); |
|
| 498 | + $coordinate = sprintf("%02d", $latitude['deg']).str_pad(number_format($latitude['min'], 2, '.', ''), 5, '0', STR_PAD_LEFT).$latitude['NSEW'].'/'.sprintf("%03d", $longitude['deg']).str_pad(number_format($longitude['min'], 2, '.', ''), 5, '0', STR_PAD_LEFT).$longitude['NSEW']; |
|
| 499 | + $w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'], 2, '.', ''))*1000)); |
|
| 500 | + $w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'], 2, '.', ''))*1000)); |
|
| 502 | 501 | $w = $w1.$w2; |
| 503 | 502 | //$w = '00'; |
| 504 | 503 | $custom = ''; |
@@ -515,19 +514,19 @@ discard block |
||
| 515 | 514 | $custom .= 'AI='.$aircraft_icao; |
| 516 | 515 | } |
| 517 | 516 | if ($custom != '') $custom = ' '.$custom; |
| 518 | - $this->send('AIRCRAFT>APRS,TCPIP*:;'.$hex.' *'.date('His',strtotime($datetime)).'h'.$coordinate.'^'.str_pad($heading,3,'0',STR_PAD_LEFT).'/'.str_pad($speed,3,'0',STR_PAD_LEFT).'/A='.str_pad($altitude_real,6,'0',STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n"); |
|
| 517 | + $this->send('AIRCRAFT>APRS,TCPIP*:;'.$hex.' *'.date('His', strtotime($datetime)).'h'.$coordinate.'^'.str_pad($heading, 3, '0', STR_PAD_LEFT).'/'.str_pad($speed, 3, '0', STR_PAD_LEFT).'/A='.str_pad($altitude_real, 6, '0', STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n"); |
|
| 519 | 518 | } |
| 520 | 519 | } |
| 521 | 520 | } |
| 522 | 521 | class APRSMarine extends APRS { |
| 523 | - public function addLiveMarineData($id, $ident, $latitude, $longitude, $heading, $speed,$datetime, $putinarchive,$mmsi,$type,$typeid,$imo,$callsign,$arrival_code,$arrival_date,$status,$statusid,$noarchive,$format_source,$source_name,$over_country) { |
|
| 522 | + public function addLiveMarineData($id, $ident, $latitude, $longitude, $heading, $speed, $datetime, $putinarchive, $mmsi, $type, $typeid, $imo, $callsign, $arrival_code, $arrival_date, $status, $statusid, $noarchive, $format_source, $source_name, $over_country) { |
|
| 524 | 523 | $Common = new Common(); |
| 525 | 524 | if ($latitude != '' && $longitude != '') { |
| 526 | - $latitude = $Common->convertDM($latitude,'latitude'); |
|
| 527 | - $longitude = $Common->convertDM($longitude,'longitude'); |
|
| 528 | - $coordinate = sprintf("%02d",$latitude['deg']).str_pad(number_format($latitude['min'],2,'.',''),5,'0',STR_PAD_LEFT).$latitude['NSEW'].'/'.sprintf("%03d",$longitude['deg']).str_pad(number_format($longitude['min'],2,'.',''),5,'0',STR_PAD_LEFT).$longitude['NSEW']; |
|
| 529 | - $w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'],2,'.',''))*1000)); |
|
| 530 | - $w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'],2,'.',''))*1000)); |
|
| 525 | + $latitude = $Common->convertDM($latitude, 'latitude'); |
|
| 526 | + $longitude = $Common->convertDM($longitude, 'longitude'); |
|
| 527 | + $coordinate = sprintf("%02d", $latitude['deg']).str_pad(number_format($latitude['min'], 2, '.', ''), 5, '0', STR_PAD_LEFT).$latitude['NSEW'].'/'.sprintf("%03d", $longitude['deg']).str_pad(number_format($longitude['min'], 2, '.', ''), 5, '0', STR_PAD_LEFT).$longitude['NSEW']; |
|
| 528 | + $w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'], 2, '.', ''))*1000)); |
|
| 529 | + $w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'], 2, '.', ''))*1000)); |
|
| 531 | 530 | $w = $w1.$w2; |
| 532 | 531 | //$w = '00'; |
| 533 | 532 | $custom = ''; |
@@ -557,7 +556,7 @@ discard block |
||
| 557 | 556 | } |
| 558 | 557 | if ($custom != '') $custom = ' '.$custom; |
| 559 | 558 | $altitude = 0; |
| 560 | - $this->send('MARINE>APRS,TCPIP*:;'.$mmsi.'*'.date('His',strtotime($datetime)).'h'.$coordinate.'s'.str_pad($heading,3,'0',STR_PAD_LEFT).'/'.str_pad($speed,3,'0',STR_PAD_LEFT).'/A='.str_pad($altitude,6,'0',STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n"); |
|
| 559 | + $this->send('MARINE>APRS,TCPIP*:;'.$mmsi.'*'.date('His', strtotime($datetime)).'h'.$coordinate.'s'.str_pad($heading, 3, '0', STR_PAD_LEFT).'/'.str_pad($speed, 3, '0', STR_PAD_LEFT).'/A='.str_pad($altitude, 6, '0', STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n"); |
|
| 561 | 560 | } |
| 562 | 561 | } |
| 563 | 562 | } |
@@ -107,17 +107,23 @@ discard block |
||
| 107 | 107 | |
| 108 | 108 | /* Check that end was found and body has at least one byte. */ |
| 109 | 109 | if ($splitpos == 0 || $splitpos + 1 == $input_len || $splitpos === FALSE) { |
| 110 | - if ($globalDebug) echo '!!! APRS invalid : '.$input."\n"; |
|
| 110 | + if ($globalDebug) { |
|
| 111 | + echo '!!! APRS invalid : '.$input."\n"; |
|
| 112 | + } |
|
| 111 | 113 | return false; |
| 112 | 114 | } |
| 113 | 115 | |
| 114 | - if ($debug) echo 'input : '.$input."\n"; |
|
| 116 | + if ($debug) { |
|
| 117 | + echo 'input : '.$input."\n"; |
|
| 118 | + } |
|
| 115 | 119 | /* Save header and body. */ |
| 116 | 120 | $body = substr($input,$splitpos+1,$input_len); |
| 117 | 121 | $body_len = strlen($body); |
| 118 | 122 | $header = substr($input,0,$splitpos); |
| 119 | 123 | //$header_len = strlen($header); |
| 120 | - if ($debug) echo 'header : '.$header."\n"; |
|
| 124 | + if ($debug) { |
|
| 125 | + echo 'header : '.$header."\n"; |
|
| 126 | + } |
|
| 121 | 127 | |
| 122 | 128 | /* Parse source, target and path. */ |
| 123 | 129 | //FLRDF0A52>APRS,qAS,LSTB |
@@ -131,10 +137,14 @@ discard block |
||
| 131 | 137 | $result['format_source'] = 'famaprs'; |
| 132 | 138 | $result['source_type'] = 'ais'; |
| 133 | 139 | } else { |
| 134 | - if ($debug) echo 'ident : '.$ident."\n"; |
|
| 140 | + if ($debug) { |
|
| 141 | + echo 'ident : '.$ident."\n"; |
|
| 142 | + } |
|
| 135 | 143 | $result['ident'] = $ident; |
| 136 | 144 | } |
| 137 | - } else return false; |
|
| 145 | + } else { |
|
| 146 | + return false; |
|
| 147 | + } |
|
| 138 | 148 | $elements = explode(',',$all_elements); |
| 139 | 149 | $source = end($elements); |
| 140 | 150 | $result['source'] = $source; |
@@ -143,7 +153,9 @@ discard block |
||
| 143 | 153 | //echo "ok"; |
| 144 | 154 | //if ($element == 'TCPIP*') return false; |
| 145 | 155 | } elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) { |
| 146 | - if ($debug) echo 'element : '.$element."\n"; |
|
| 156 | + if ($debug) { |
|
| 157 | + echo 'element : '.$element."\n"; |
|
| 158 | + } |
|
| 147 | 159 | return false; |
| 148 | 160 | } |
| 149 | 161 | /* |
@@ -156,13 +168,17 @@ discard block |
||
| 156 | 168 | } |
| 157 | 169 | |
| 158 | 170 | $type = substr($body,0,1); |
| 159 | - if ($debug) echo 'type : '.$type."\n"; |
|
| 171 | + if ($debug) { |
|
| 172 | + echo 'type : '.$type."\n"; |
|
| 173 | + } |
|
| 160 | 174 | if ($type == ';') { |
| 161 | 175 | if (isset($result['source_type']) && $result['source_type'] == 'modes') { |
| 162 | 176 | $result['address'] = trim(substr($body,1,9)); |
| 163 | 177 | } elseif (isset($result['source_type']) && $result['source_type'] == 'ais') { |
| 164 | 178 | $result['mmsi'] = trim(substr($body,1,9)); |
| 165 | - } else $result['ident'] = trim(substr($body,1,9)); |
|
| 179 | + } else { |
|
| 180 | + $result['ident'] = trim(substr($body,1,9)); |
|
| 181 | + } |
|
| 166 | 182 | } elseif ($type == ',') { |
| 167 | 183 | // Invalid data or test data |
| 168 | 184 | return false; |
@@ -230,7 +246,9 @@ discard block |
||
| 230 | 246 | //$symbol_table = $matches[4]; |
| 231 | 247 | $lat = intval($lat_deg); |
| 232 | 248 | $lon = intval($lon_deg); |
| 233 | - if ($lat > 89 || $lon > 179) return false; |
|
| 249 | + if ($lat > 89 || $lon > 179) { |
|
| 250 | + return false; |
|
| 251 | + } |
|
| 234 | 252 | |
| 235 | 253 | /* |
| 236 | 254 | $tmp_5b = str_replace('.','',$lat_min); |
@@ -240,8 +258,12 @@ discard block |
||
| 240 | 258 | */ |
| 241 | 259 | $latitude = $lat + floatval($lat_min)/60; |
| 242 | 260 | $longitude = $lon + floatval($lon_min)/60; |
| 243 | - if ($sind == 'S') $latitude = 0-$latitude; |
|
| 244 | - if ($wind == 'W') $longitude = 0-$longitude; |
|
| 261 | + if ($sind == 'S') { |
|
| 262 | + $latitude = 0-$latitude; |
|
| 263 | + } |
|
| 264 | + if ($wind == 'W') { |
|
| 265 | + $longitude = 0-$longitude; |
|
| 266 | + } |
|
| 245 | 267 | $result['latitude'] = $latitude; |
| 246 | 268 | $result['longitude'] = $longitude; |
| 247 | 269 | $body_parse = substr($body_parse,18); |
@@ -275,7 +297,9 @@ discard block |
||
| 275 | 297 | $body_parse = substr($body_parse,1); |
| 276 | 298 | $body_parse_len = strlen($body_parse); |
| 277 | 299 | $result['symbol_code'] = $symbol_code; |
| 278 | - if (isset($this->symbols[$symbol_code])) $result['symbol'] = $this->symbols[$symbol_code]; |
|
| 300 | + if (isset($this->symbols[$symbol_code])) { |
|
| 301 | + $result['symbol'] = $this->symbols[$symbol_code]; |
|
| 302 | + } |
|
| 279 | 303 | if ($symbol_code != '_') { |
| 280 | 304 | } |
| 281 | 305 | //$body_parse = substr($body_parse,1); |
@@ -286,7 +310,9 @@ discard block |
||
| 286 | 310 | if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) { |
| 287 | 311 | $course = substr($body_parse,0,3); |
| 288 | 312 | $tmp_s = intval($course); |
| 289 | - if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course); |
|
| 313 | + if ($tmp_s >= 1 && $tmp_s <= 360) { |
|
| 314 | + $result['heading'] = intval($course); |
|
| 315 | + } |
|
| 290 | 316 | $speed = substr($body_parse,4,3); |
| 291 | 317 | if ($speed != '...') { |
| 292 | 318 | //$result['speed'] = round($speed*1.852); |
@@ -327,10 +353,16 @@ discard block |
||
| 327 | 353 | $lat_off = (($dao_split[1])-48.0)*0.001/60.0; |
| 328 | 354 | $lon_off = (($dao_split[2])-48.0)*0.001/60.0; |
| 329 | 355 | |
| 330 | - if ($result['latitude'] < 0) $result['latitude'] -= $lat_off; |
|
| 331 | - else $result['latitude'] += $lat_off; |
|
| 332 | - if ($result['longitude'] < 0) $result['longitude'] -= $lon_off; |
|
| 333 | - else $result['longitude'] += $lon_off; |
|
| 356 | + if ($result['latitude'] < 0) { |
|
| 357 | + $result['latitude'] -= $lat_off; |
|
| 358 | + } else { |
|
| 359 | + $result['latitude'] += $lat_off; |
|
| 360 | + } |
|
| 361 | + if ($result['longitude'] < 0) { |
|
| 362 | + $result['longitude'] -= $lon_off; |
|
| 363 | + } else { |
|
| 364 | + $result['longitude'] += $lon_off; |
|
| 365 | + } |
|
| 334 | 366 | } |
| 335 | 367 | |
| 336 | 368 | $body_parse = substr($body_parse,6); |
@@ -369,27 +401,48 @@ discard block |
||
| 369 | 401 | $address = substr($id,2); |
| 370 | 402 | //print_r($matches); |
| 371 | 403 | $addressType = (intval(substr($id,0,2),16))&3; |
| 372 | - if ($addressType == 0) $result['addresstype'] = "RANDOM"; |
|
| 373 | - elseif ($addressType == 1) $result['addresstype'] = "ICAO"; |
|
| 374 | - elseif ($addressType == 2) $result['addresstype'] = "FLARM"; |
|
| 375 | - elseif ($addressType == 3) $result['addresstype'] = "OGN"; |
|
| 404 | + if ($addressType == 0) { |
|
| 405 | + $result['addresstype'] = "RANDOM"; |
|
| 406 | + } elseif ($addressType == 1) { |
|
| 407 | + $result['addresstype'] = "ICAO"; |
|
| 408 | + } elseif ($addressType == 2) { |
|
| 409 | + $result['addresstype'] = "FLARM"; |
|
| 410 | + } elseif ($addressType == 3) { |
|
| 411 | + $result['addresstype'] = "OGN"; |
|
| 412 | + } |
|
| 376 | 413 | $aircraftType = $this->urshift(((intval(substr($id,0,2),16)) & 0b1111100),2); |
| 377 | 414 | $result['aircrafttype_code'] = $aircraftType; |
| 378 | - if ($aircraftType == 0) $result['aircrafttype'] = "UNKNOWN"; |
|
| 379 | - elseif ($aircraftType == 1) $result['aircrafttype'] = "GLIDER"; |
|
| 380 | - elseif ($aircraftType == 2) $result['aircrafttype'] = "TOW_PLANE"; |
|
| 381 | - elseif ($aircraftType == 3) $result['aircrafttype'] = "HELICOPTER_ROTORCRAFT"; |
|
| 382 | - elseif ($aircraftType == 4) $result['aircrafttype'] = "PARACHUTE"; |
|
| 383 | - elseif ($aircraftType == 5) $result['aircrafttype'] = "DROP_PLANE"; |
|
| 384 | - elseif ($aircraftType == 6) $result['aircrafttype'] = "HANG_GLIDER"; |
|
| 385 | - elseif ($aircraftType == 7) $result['aircrafttype'] = "PARA_GLIDER"; |
|
| 386 | - elseif ($aircraftType == 8) $result['aircrafttype'] = "POWERED_AIRCRAFT"; |
|
| 387 | - elseif ($aircraftType == 9) $result['aircrafttype'] = "JET_AIRCRAFT"; |
|
| 388 | - elseif ($aircraftType == 10) $result['aircrafttype'] = "UFO"; |
|
| 389 | - elseif ($aircraftType == 11) $result['aircrafttype'] = "BALLOON"; |
|
| 390 | - elseif ($aircraftType == 12) $result['aircrafttype'] = "AIRSHIP"; |
|
| 391 | - elseif ($aircraftType == 13) $result['aircrafttype'] = "UAV"; |
|
| 392 | - elseif ($aircraftType == 15) $result['aircrafttype'] = "STATIC_OBJECT"; |
|
| 415 | + if ($aircraftType == 0) { |
|
| 416 | + $result['aircrafttype'] = "UNKNOWN"; |
|
| 417 | + } elseif ($aircraftType == 1) { |
|
| 418 | + $result['aircrafttype'] = "GLIDER"; |
|
| 419 | + } elseif ($aircraftType == 2) { |
|
| 420 | + $result['aircrafttype'] = "TOW_PLANE"; |
|
| 421 | + } elseif ($aircraftType == 3) { |
|
| 422 | + $result['aircrafttype'] = "HELICOPTER_ROTORCRAFT"; |
|
| 423 | + } elseif ($aircraftType == 4) { |
|
| 424 | + $result['aircrafttype'] = "PARACHUTE"; |
|
| 425 | + } elseif ($aircraftType == 5) { |
|
| 426 | + $result['aircrafttype'] = "DROP_PLANE"; |
|
| 427 | + } elseif ($aircraftType == 6) { |
|
| 428 | + $result['aircrafttype'] = "HANG_GLIDER"; |
|
| 429 | + } elseif ($aircraftType == 7) { |
|
| 430 | + $result['aircrafttype'] = "PARA_GLIDER"; |
|
| 431 | + } elseif ($aircraftType == 8) { |
|
| 432 | + $result['aircrafttype'] = "POWERED_AIRCRAFT"; |
|
| 433 | + } elseif ($aircraftType == 9) { |
|
| 434 | + $result['aircrafttype'] = "JET_AIRCRAFT"; |
|
| 435 | + } elseif ($aircraftType == 10) { |
|
| 436 | + $result['aircrafttype'] = "UFO"; |
|
| 437 | + } elseif ($aircraftType == 11) { |
|
| 438 | + $result['aircrafttype'] = "BALLOON"; |
|
| 439 | + } elseif ($aircraftType == 12) { |
|
| 440 | + $result['aircrafttype'] = "AIRSHIP"; |
|
| 441 | + } elseif ($aircraftType == 13) { |
|
| 442 | + $result['aircrafttype'] = "UAV"; |
|
| 443 | + } elseif ($aircraftType == 15) { |
|
| 444 | + $result['aircrafttype'] = "STATIC_OBJECT"; |
|
| 445 | + } |
|
| 393 | 446 | $stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0; |
| 394 | 447 | $result['stealth'] = $stealth; |
| 395 | 448 | $result['address'] = $address; |
@@ -429,13 +482,21 @@ discard block |
||
| 429 | 482 | $result['temp'] = round(5/9*(($matches[1])-32),1); |
| 430 | 483 | } |
| 431 | 484 | } |
| 432 | - } else $result['comment'] = trim($body_parse); |
|
| 485 | + } else { |
|
| 486 | + $result['comment'] = trim($body_parse); |
|
| 487 | + } |
|
| 433 | 488 | |
| 434 | 489 | } |
| 435 | 490 | //} |
| 436 | - if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4); |
|
| 437 | - if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4); |
|
| 438 | - if ($debug) print_r($result); |
|
| 491 | + if (isset($result['latitude'])) { |
|
| 492 | + $result['latitude'] = round($result['latitude'],4); |
|
| 493 | + } |
|
| 494 | + if (isset($result['longitude'])) { |
|
| 495 | + $result['longitude'] = round($result['longitude'],4); |
|
| 496 | + } |
|
| 497 | + if ($debug) { |
|
| 498 | + print_r($result); |
|
| 499 | + } |
|
| 439 | 500 | return $result; |
| 440 | 501 | } |
| 441 | 502 | |
@@ -444,12 +505,21 @@ discard block |
||
| 444 | 505 | $aprs_connect = 0; |
| 445 | 506 | $aprs_keep = 120; |
| 446 | 507 | $aprs_last_tx = time(); |
| 447 | - if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; |
|
| 448 | - else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
| 449 | - if (isset($globalServerAPRSssid)) $aprs_ssid = $globalServerAPRSssid; |
|
| 450 | - else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
| 451 | - if (isset($globalServerAPRSpass)) $aprs_pass = $globalServerAPRSpass; |
|
| 452 | - else $aprs_pass = '-1'; |
|
| 508 | + if (isset($globalAPRSversion)) { |
|
| 509 | + $aprs_version = $globalAPRSversion; |
|
| 510 | + } else { |
|
| 511 | + $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
| 512 | + } |
|
| 513 | + if (isset($globalServerAPRSssid)) { |
|
| 514 | + $aprs_ssid = $globalServerAPRSssid; |
|
| 515 | + } else { |
|
| 516 | + $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
| 517 | + } |
|
| 518 | + if (isset($globalServerAPRSpass)) { |
|
| 519 | + $aprs_pass = $globalServerAPRSpass; |
|
| 520 | + } else { |
|
| 521 | + $aprs_pass = '-1'; |
|
| 522 | + } |
|
| 453 | 523 | |
| 454 | 524 | $aprs_filter = ''; |
| 455 | 525 | $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; |
@@ -481,7 +551,9 @@ discard block |
||
| 481 | 551 | } |
| 482 | 552 | |
| 483 | 553 | public function send($data) { |
| 484 | - if ($this->connected === false) $this->connect(); |
|
| 554 | + if ($this->connected === false) { |
|
| 555 | + $this->connect(); |
|
| 556 | + } |
|
| 485 | 557 | $send = socket_send( $this->socket , $data , strlen($data),0); |
| 486 | 558 | if ($send === FALSE) { |
| 487 | 559 | socket_close($this->socket); |
@@ -503,18 +575,26 @@ discard block |
||
| 503 | 575 | //$w = '00'; |
| 504 | 576 | $custom = ''; |
| 505 | 577 | if ($ident != '') { |
| 506 | - if ($custom != '') $custom .= '/'; |
|
| 578 | + if ($custom != '') { |
|
| 579 | + $custom .= '/'; |
|
| 580 | + } |
|
| 507 | 581 | $custom .= 'CS='.$ident; |
| 508 | 582 | } |
| 509 | 583 | if ($squawk != '') { |
| 510 | - if ($custom != '') $custom .= '/'; |
|
| 584 | + if ($custom != '') { |
|
| 585 | + $custom .= '/'; |
|
| 586 | + } |
|
| 511 | 587 | $custom .= 'SQ='.$squawk; |
| 512 | 588 | } |
| 513 | 589 | if ($aircraft_icao != '' && $aircraft_icao != 'NA') { |
| 514 | - if ($custom != '') $custom .= '/'; |
|
| 590 | + if ($custom != '') { |
|
| 591 | + $custom .= '/'; |
|
| 592 | + } |
|
| 515 | 593 | $custom .= 'AI='.$aircraft_icao; |
| 516 | 594 | } |
| 517 | - if ($custom != '') $custom = ' '.$custom; |
|
| 595 | + if ($custom != '') { |
|
| 596 | + $custom = ' '.$custom; |
|
| 597 | + } |
|
| 518 | 598 | $this->send('AIRCRAFT>APRS,TCPIP*:;'.$hex.' *'.date('His',strtotime($datetime)).'h'.$coordinate.'^'.str_pad($heading,3,'0',STR_PAD_LEFT).'/'.str_pad($speed,3,'0',STR_PAD_LEFT).'/A='.str_pad($altitude_real,6,'0',STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n"); |
| 519 | 599 | } |
| 520 | 600 | } |
@@ -532,30 +612,44 @@ discard block |
||
| 532 | 612 | //$w = '00'; |
| 533 | 613 | $custom = ''; |
| 534 | 614 | if ($ident != '') { |
| 535 | - if ($custom != '') $custom .= '/'; |
|
| 615 | + if ($custom != '') { |
|
| 616 | + $custom .= '/'; |
|
| 617 | + } |
|
| 536 | 618 | $custom .= 'CS='.$ident; |
| 537 | 619 | } |
| 538 | 620 | if ($typeid != '') { |
| 539 | - if ($custom != '') $custom .= '/'; |
|
| 621 | + if ($custom != '') { |
|
| 622 | + $custom .= '/'; |
|
| 623 | + } |
|
| 540 | 624 | $custom .= 'TI='.$typeid; |
| 541 | 625 | } |
| 542 | 626 | if ($statusid != '') { |
| 543 | - if ($custom != '') $custom .= '/'; |
|
| 627 | + if ($custom != '') { |
|
| 628 | + $custom .= '/'; |
|
| 629 | + } |
|
| 544 | 630 | $custom .= 'SI='.$statusid; |
| 545 | 631 | } |
| 546 | 632 | if ($imo != '') { |
| 547 | - if ($custom != '') $custom .= '/'; |
|
| 633 | + if ($custom != '') { |
|
| 634 | + $custom .= '/'; |
|
| 635 | + } |
|
| 548 | 636 | $custom .= 'IMO='.$imo; |
| 549 | 637 | } |
| 550 | 638 | if ($arrival_date != '') { |
| 551 | - if ($custom != '') $custom .= '/'; |
|
| 639 | + if ($custom != '') { |
|
| 640 | + $custom .= '/'; |
|
| 641 | + } |
|
| 552 | 642 | $custom .= 'AD='.strtotime($arrival_date); |
| 553 | 643 | } |
| 554 | 644 | if ($arrival_code != '') { |
| 555 | - if ($custom != '') $custom .= '/'; |
|
| 645 | + if ($custom != '') { |
|
| 646 | + $custom .= '/'; |
|
| 647 | + } |
|
| 556 | 648 | $custom .= 'AC='.$arrival_code; |
| 557 | 649 | } |
| 558 | - if ($custom != '') $custom = ' '.$custom; |
|
| 650 | + if ($custom != '') { |
|
| 651 | + $custom = ' '.$custom; |
|
| 652 | + } |
|
| 559 | 653 | $altitude = 0; |
| 560 | 654 | $this->send('MARINE>APRS,TCPIP*:;'.$mmsi.'*'.date('His',strtotime($datetime)).'h'.$coordinate.'s'.str_pad($heading,3,'0',STR_PAD_LEFT).'/'.str_pad($speed,3,'0',STR_PAD_LEFT).'/A='.str_pad($altitude,6,'0',STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n"); |
| 561 | 655 | } |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | if (isset($this->all_tracked[$key]['id'])) { |
| 59 | 59 | //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].' '.$this->all_tracked[$key]['longitude']."\n"; |
| 60 | 60 | $Marine = new Marine($this->db); |
| 61 | - $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']); |
|
| 61 | + $Marine->updateLatestMarineData($this->all_tracked[$key]['id'], $this->all_tracked[$key]['ident'], $this->all_tracked[$key]['latitude'], $this->all_tracked[$key]['longitude'], $this->all_tracked[$key]['speed'], $this->all_tracked[$key]['datetime']); |
|
| 62 | 62 | } |
| 63 | 63 | } |
| 64 | 64 | } |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
| 70 | 70 | foreach ($this->all_tracked as $key => $flight) { |
| 71 | 71 | if (isset($flight['lastupdate'])) { |
| 72 | - if ($flight['lastupdate'] < (time()-3000)) { |
|
| 72 | + if ($flight['lastupdate'] < (time() - 3000)) { |
|
| 73 | 73 | if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
| 74 | 74 | if (isset($this->all_tracked[$key]['id'])) { |
| 75 | 75 | if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | //$real_arrival = $this->arrival($key); |
| 82 | 82 | $Marine = new Marine($this->db); |
| 83 | 83 | if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
| 84 | - $result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']); |
|
| 84 | + $result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'], $this->all_tracked[$key]['ident'], $this->all_tracked[$key]['latitude'], $this->all_tracked[$key]['longitude'], $this->all_tracked[$key]['speed'], $this->all_tracked[$key]['datetime']); |
|
| 85 | 85 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
| 86 | 86 | } |
| 87 | 87 | // Put in archive |
@@ -95,14 +95,14 @@ discard block |
||
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | public function add($line) { |
| 98 | - global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS,$APRSMarine; |
|
| 98 | + global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS, $APRSMarine; |
|
| 99 | 99 | if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
| 100 | 100 | date_default_timezone_set('UTC'); |
| 101 | 101 | $dataFound = false; |
| 102 | 102 | $send = false; |
| 103 | 103 | |
| 104 | 104 | // SBS format is CSV format |
| 105 | - if(is_array($line) && isset($line['mmsi'])) { |
|
| 105 | + if (is_array($line) && isset($line['mmsi'])) { |
|
| 106 | 106 | //print_r($line); |
| 107 | 107 | if (isset($line['mmsi'])) { |
| 108 | 108 | |
@@ -126,18 +126,18 @@ discard block |
||
| 126 | 126 | |
| 127 | 127 | if (!isset($this->all_tracked[$id])) { |
| 128 | 128 | $this->all_tracked[$id] = array(); |
| 129 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedMarine' => 0)); |
|
| 130 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '0', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','status_id' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '','mmsi_type' => '')); |
|
| 131 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
|
| 129 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('addedMarine' => 0)); |
|
| 130 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('ident' => '', 'latitude' => '', 'longitude' => '', 'speed' => '0', 'heading' => '', 'format_source' => '', 'source_name' => '', 'comment'=> '', 'type' => '', 'typeid' => '', 'noarchive' => false, 'putinarchive' => true, 'over_country' => '', 'mmsi' => '', 'status' => '', 'status_id' => '', 'imo' => '', 'callsign' => '', 'arrival_code' => '', 'arrival_date' => '', 'mmsi_type' => '')); |
|
| 131 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('lastupdate' => time())); |
|
| 132 | 132 | if (!isset($line['id'])) { |
| 133 | 133 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
| 134 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
| 135 | - } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
| 134 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $id.'-'.date('YmdHi'))); |
|
| 135 | + } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $line['id'])); |
|
| 136 | 136 | if ($globalAllTracked !== FALSE) $dataFound = true; |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) { |
| 140 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi' => $line['mmsi'])); |
|
| 140 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('mmsi' => $line['mmsi'])); |
|
| 141 | 141 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 142 | 142 | $Marine = new Marine($this->db); |
| 143 | 143 | $identity = $Marine->getIdentity($line['mmsi']); |
@@ -151,64 +151,64 @@ discard block |
||
| 151 | 151 | } |
| 152 | 152 | } |
| 153 | 153 | if (isset($line['type_id']) && $line['type_id'] != '') { |
| 154 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $AIS->getShipType($line['type_id']))); |
|
| 154 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('type' => $AIS->getShipType($line['type_id']))); |
|
| 155 | 155 | } |
| 156 | 156 | if (isset($line['type']) && $line['type'] != '') { |
| 157 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
| 157 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('type' => $line['type'])); |
|
| 158 | 158 | } |
| 159 | 159 | if (isset($line['mmsi_type']) && $line['mmsi_type'] != '') { |
| 160 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi_type' => $line['mmsi_type'])); |
|
| 160 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('mmsi_type' => $line['mmsi_type'])); |
|
| 161 | 161 | } |
| 162 | 162 | if (isset($line['imo']) && $line['imo'] != '') { |
| 163 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo'])); |
|
| 163 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('imo' => $line['imo'])); |
|
| 164 | 164 | } |
| 165 | 165 | if (isset($line['callsign']) && $line['callsign'] != '') { |
| 166 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign'])); |
|
| 166 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('callsign' => $line['callsign'])); |
|
| 167 | 167 | } |
| 168 | 168 | if (isset($line['arrival_code']) && $line['arrival_code'] != '') { |
| 169 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code'])); |
|
| 169 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('arrival_code' => $line['arrival_code'])); |
|
| 170 | 170 | } |
| 171 | 171 | if (isset($line['arrival_date']) && $line['arrival_date'] != '') { |
| 172 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date'])); |
|
| 172 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('arrival_date' => $line['arrival_date'])); |
|
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | |
| 176 | 176 | //if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9-]+$/', $line['ident'])) { |
| 177 | 177 | if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) { |
| 178 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident']))); |
|
| 178 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('ident' => trim($line['ident']))); |
|
| 179 | 179 | if ($this->all_tracked[$id]['addedMarine'] == 1) { |
| 180 | 180 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
| 181 | 181 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 182 | 182 | $timeelapsed = microtime(true); |
| 183 | 183 | $Marine = new Marine($this->db); |
| 184 | 184 | $fromsource = NULL; |
| 185 | - $result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource); |
|
| 185 | + $result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $fromsource); |
|
| 186 | 186 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
| 187 | 187 | $Marine->db = null; |
| 188 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 188 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 189 | 189 | } |
| 190 | 190 | } |
| 191 | 191 | } |
| 192 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
| 192 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $this->all_tracked[$id]['ident'])); |
|
| 193 | 193 | } |
| 194 | 194 | |
| 195 | - if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) { |
|
| 195 | + if (isset($line['datetime']) && strtotime($line['datetime']) > time() - 20*60 && strtotime($line['datetime']) < time() + 20*60) { |
|
| 196 | 196 | if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) { |
| 197 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
|
| 197 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => $line['datetime'])); |
|
| 198 | 198 | } else { |
| 199 | 199 | if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n"; |
| 200 | 200 | elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n"; |
| 201 | 201 | return ''; |
| 202 | 202 | } |
| 203 | - } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) { |
|
| 203 | + } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time() - 20*60) { |
|
| 204 | 204 | if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!"; |
| 205 | 205 | return ''; |
| 206 | - } elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) { |
|
| 206 | + } elseif (isset($line['datetime']) && strtotime($line['datetime']) > time() + 20*60) { |
|
| 207 | 207 | if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!"; |
| 208 | 208 | return ''; |
| 209 | 209 | } elseif (!isset($line['datetime'])) { |
| 210 | 210 | date_default_timezone_set('UTC'); |
| 211 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
| 211 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => date('Y-m-d H:i:s'))); |
|
| 212 | 212 | } else { |
| 213 | 213 | if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!"; |
| 214 | 214 | return ''; |
@@ -216,24 +216,24 @@ discard block |
||
| 216 | 216 | |
| 217 | 217 | |
| 218 | 218 | if (isset($line['speed']) && $line['speed'] != '') { |
| 219 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed']))); |
|
| 220 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true)); |
|
| 219 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($line['speed']))); |
|
| 220 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed_fromsrc' => true)); |
|
| 221 | 221 | } else if (!isset($this->all_tracked[$id]['speed_fromsrc']) && isset($this->all_tracked[$id]['time_last_coord']) && $this->all_tracked[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) { |
| 222 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'); |
|
| 222 | + $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm'); |
|
| 223 | 223 | if ($distance > 1000 && $distance < 10000) { |
| 224 | 224 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
| 225 | 225 | $speed = $speed*3.6; |
| 226 | - if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
|
| 226 | + if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($speed))); |
|
| 227 | 227 | if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
| 228 | 228 | } |
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
| 232 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
| 232 | + if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time() - $this->all_tracked[$id]['time_last_coord']); |
|
| 233 | 233 | else unset($timediff); |
| 234 | - if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) { |
|
| 234 | + if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff, $Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')))) { |
|
| 235 | 235 | if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) { |
| 236 | - if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
|
| 236 | + if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'], $this->all_tracked[$id]['archive_longitude'], $this->all_tracked[$id]['livedb_latitude'], $this->all_tracked[$id]['livedb_longitude'], $line['latitude'], $line['longitude'])) { |
|
| 237 | 237 | $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
| 238 | 238 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
| 239 | 239 | $this->all_tracked[$id]['putinarchive'] = true; |
@@ -242,10 +242,10 @@ discard block |
||
| 242 | 242 | $timeelapsed = microtime(true); |
| 243 | 243 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 244 | 244 | $Marine = new Marine($this->db); |
| 245 | - $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
| 245 | + $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']); |
|
| 246 | 246 | if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
| 247 | 247 | $Marine->db = null; |
| 248 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 248 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 249 | 249 | } |
| 250 | 250 | $this->tmd = 0; |
| 251 | 251 | if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
@@ -254,62 +254,62 @@ discard block |
||
| 254 | 254 | |
| 255 | 255 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
| 256 | 256 | if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
| 257 | - if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
|
| 257 | + if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude'] - $line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
|
| 258 | 258 | $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
| 259 | 259 | $dataFound = true; |
| 260 | 260 | $this->all_tracked[$id]['time_last_coord'] = time(); |
| 261 | 261 | } |
| 262 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
|
| 262 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('latitude' => $line['latitude'])); |
|
| 263 | 263 | } |
| 264 | 264 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
| 265 | 265 | if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
| 266 | 266 | if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
| 267 | - if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
|
| 267 | + if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude'] - $line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
|
| 268 | 268 | $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
| 269 | 269 | $dataFound = true; |
| 270 | 270 | $this->all_tracked[$id]['time_last_coord'] = time(); |
| 271 | 271 | } |
| 272 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude'])); |
|
| 272 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('longitude' => $line['longitude'])); |
|
| 273 | 273 | } |
| 274 | 274 | |
| 275 | 275 | } else if ($globalDebug && $timediff > 20) { |
| 276 | 276 | $this->tmd = $this->tmd + 1; |
| 277 | 277 | echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n"; |
| 278 | - echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -"; |
|
| 279 | - echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
|
| 278 | + echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')."m -"; |
|
| 279 | + echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - "; |
|
| 280 | 280 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n"; |
| 281 | 281 | } |
| 282 | 282 | } |
| 283 | 283 | if (isset($line['last_update']) && $line['last_update'] != '') { |
| 284 | 284 | if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
| 285 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
|
| 285 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('last_update' => $line['last_update'])); |
|
| 286 | 286 | } |
| 287 | 287 | if (isset($line['format_source']) && $line['format_source'] != '') { |
| 288 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source'])); |
|
| 288 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('format_source' => $line['format_source'])); |
|
| 289 | 289 | } |
| 290 | 290 | if (isset($line['source_name']) && $line['source_name'] != '') { |
| 291 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name'])); |
|
| 291 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('source_name' => $line['source_name'])); |
|
| 292 | 292 | } |
| 293 | 293 | if (isset($line['status']) && $line['status'] != '') { |
| 294 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status'])); |
|
| 294 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('status' => $line['status'])); |
|
| 295 | 295 | } |
| 296 | 296 | if (isset($line['status_id']) && $line['status_id'] != '') { |
| 297 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status_id' => $line['status_id'])); |
|
| 297 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('status_id' => $line['status_id'])); |
|
| 298 | 298 | } |
| 299 | 299 | |
| 300 | 300 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
| 301 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true)); |
|
| 301 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('noarchive' => true)); |
|
| 302 | 302 | } |
| 303 | 303 | |
| 304 | 304 | if (isset($line['heading']) && $line['heading'] != '') { |
| 305 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 306 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
|
| 307 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
|
| 305 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading'] - round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 306 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($line['heading']))); |
|
| 307 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading_fromsrc' => true)); |
|
| 308 | 308 | //$dataFound = true; |
| 309 | 309 | } elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) { |
| 310 | - $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
|
| 311 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
|
| 312 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 310 | + $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'], $this->all_tracked[$id]['archive_longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']); |
|
| 311 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($heading))); |
|
| 312 | + if (abs($this->all_tracked[$id]['heading'] - round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 313 | 313 | if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
| 314 | 314 | } |
| 315 | 315 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
@@ -319,7 +319,7 @@ discard block |
||
| 319 | 319 | if ($dataFound === true && isset($this->all_tracked[$id]['mmsi'])) { |
| 320 | 320 | $this->all_tracked[$id]['lastupdate'] = time(); |
| 321 | 321 | if ($this->all_tracked[$id]['addedMarine'] == 0) { |
| 322 | - if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
| 322 | + if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
| 323 | 323 | if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
| 324 | 324 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 325 | 325 | if ($globalDebug) echo "Check if aircraft is already in DB..."; |
@@ -327,37 +327,37 @@ discard block |
||
| 327 | 327 | $MarineLive = new MarineLive($this->db); |
| 328 | 328 | if (isset($line['id'])) { |
| 329 | 329 | $recent_ident = $MarineLive->checkIdRecent($line['id']); |
| 330 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 330 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 331 | 331 | } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') { |
| 332 | 332 | $recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']); |
| 333 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 333 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 334 | 334 | } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
| 335 | 335 | $recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
| 336 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 336 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 337 | 337 | } else $recent_ident = ''; |
| 338 | - $MarineLive->db=null; |
|
| 338 | + $MarineLive->db = null; |
|
| 339 | 339 | if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
| 340 | 340 | elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
| 341 | 341 | } else $recent_ident = ''; |
| 342 | 342 | } else { |
| 343 | 343 | $recent_ident = ''; |
| 344 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
|
| 344 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('forcenew' => 0)); |
|
| 345 | 345 | } |
| 346 | 346 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
| 347 | - if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
|
| 347 | + if ($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
|
| 348 | 348 | { |
| 349 | 349 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
| 350 | 350 | //adds the spotter data for the archive |
| 351 | 351 | $highlight = ''; |
| 352 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi'))); |
|
| 352 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi'))); |
|
| 353 | 353 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
| 354 | 354 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 355 | 355 | $timeelapsed = microtime(true); |
| 356 | 356 | $Marine = new Marine($this->db); |
| 357 | - $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']); |
|
| 357 | + $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['typeid'], $this->all_tracked[$id]['imo'], $this->all_tracked[$id]['callsign'], $this->all_tracked[$id]['arrival_code'], $this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name']); |
|
| 358 | 358 | $Marine->db = null; |
| 359 | 359 | if ($globalDebug && isset($result)) echo $result."\n"; |
| 360 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 360 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 361 | 361 | } |
| 362 | 362 | } |
| 363 | 363 | /* |
@@ -397,7 +397,7 @@ discard block |
||
| 397 | 397 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 398 | 398 | $MarineLive = new MarineLive($this->db); |
| 399 | 399 | $MarineLive->deleteLiveMarineData(); |
| 400 | - $MarineLive->db=null; |
|
| 400 | + $MarineLive->db = null; |
|
| 401 | 401 | if ($globalDebug) echo " Done\n"; |
| 402 | 402 | } |
| 403 | 403 | $this->last_delete = time(); |
@@ -408,7 +408,7 @@ discard block |
||
| 408 | 408 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 409 | 409 | if (isset($globalDaemon) && !$globalDaemon) { |
| 410 | 410 | $Marine = new Marine($this->db); |
| 411 | - $Marine->updateLatestMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime']); |
|
| 411 | + $Marine->updateLatestMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime']); |
|
| 412 | 412 | $Marine->db = null; |
| 413 | 413 | } |
| 414 | 414 | } |
@@ -423,20 +423,20 @@ discard block |
||
| 423 | 423 | $ignoreImport = false; |
| 424 | 424 | |
| 425 | 425 | if (!$ignoreImport) { |
| 426 | - if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
| 426 | + if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
| 427 | 427 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
| 428 | 428 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
| 429 | 429 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 430 | 430 | $timeelapsed = microtime(true); |
| 431 | 431 | $MarineLive = new MarineLive($this->db); |
| 432 | - $result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']); |
|
| 432 | + $result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['typeid'], $this->all_tracked[$id]['imo'], $this->all_tracked[$id]['callsign'], $this->all_tracked[$id]['arrival_code'], $this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'], $this->all_tracked[$id]['noarchive'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name'], $this->all_tracked[$id]['over_country']); |
|
| 433 | 433 | $MarineLive->db = null; |
| 434 | 434 | if ($globalDebug) echo $result."\n"; |
| 435 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 435 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 436 | 436 | } |
| 437 | 437 | } |
| 438 | 438 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) { |
| 439 | - $APRSMarine->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']); |
|
| 439 | + $APRSMarine->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['typeid'], $this->all_tracked[$id]['imo'], $this->all_tracked[$id]['callsign'], $this->all_tracked[$id]['arrival_code'], $this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['noarchive'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name'], $this->all_tracked[$id]['over_country']); |
|
| 440 | 440 | } |
| 441 | 441 | $this->all_tracked[$id]['putinarchive'] = false; |
| 442 | 442 | |
@@ -496,7 +496,7 @@ discard block |
||
| 496 | 496 | |
| 497 | 497 | $this->all_tracked[$id]['lastupdate'] = time(); |
| 498 | 498 | if ($this->all_tracked[$id]['putinarchive']) $send = true; |
| 499 | - } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
| 499 | + } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude'])."\n"; |
|
| 500 | 500 | //$this->del(); |
| 501 | 501 | |
| 502 | 502 | |
@@ -53,7 +53,9 @@ discard block |
||
| 53 | 53 | |
| 54 | 54 | public function checkAll() { |
| 55 | 55 | global $globalDebug; |
| 56 | - if ($globalDebug) echo "Update last seen tracked data...\n"; |
|
| 56 | + if ($globalDebug) { |
|
| 57 | + echo "Update last seen tracked data...\n"; |
|
| 58 | + } |
|
| 57 | 59 | foreach ($this->all_tracked as $key => $flight) { |
| 58 | 60 | if (isset($this->all_tracked[$key]['id'])) { |
| 59 | 61 | //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].' '.$this->all_tracked[$key]['longitude']."\n"; |
@@ -66,13 +68,17 @@ discard block |
||
| 66 | 68 | public function del() { |
| 67 | 69 | global $globalDebug, $globalNoDB, $globalNoImport; |
| 68 | 70 | // Delete old infos |
| 69 | - if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
|
| 71 | + if ($globalDebug) { |
|
| 72 | + echo 'Delete old values and update latest data...'."\n"; |
|
| 73 | + } |
|
| 70 | 74 | foreach ($this->all_tracked as $key => $flight) { |
| 71 | 75 | if (isset($flight['lastupdate'])) { |
| 72 | 76 | if ($flight['lastupdate'] < (time()-3000)) { |
| 73 | 77 | if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
| 74 | 78 | if (isset($this->all_tracked[$key]['id'])) { |
| 75 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
| 79 | + if ($globalDebug) { |
|
| 80 | + echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
| 81 | + } |
|
| 76 | 82 | /* |
| 77 | 83 | $MarineLive = new MarineLive(); |
| 78 | 84 | $MarineLive->deleteLiveMarineDataById($this->all_tracked[$key]['id']); |
@@ -82,7 +88,9 @@ discard block |
||
| 82 | 88 | $Marine = new Marine($this->db); |
| 83 | 89 | if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
| 84 | 90 | $result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']); |
| 85 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
| 91 | + if ($globalDebug && $result != 'success') { |
|
| 92 | + echo '!!! ERROR : '.$result."\n"; |
|
| 93 | + } |
|
| 86 | 94 | } |
| 87 | 95 | // Put in archive |
| 88 | 96 | // $Marine->db = null; |
@@ -96,7 +104,9 @@ discard block |
||
| 96 | 104 | |
| 97 | 105 | public function add($line) { |
| 98 | 106 | global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS,$APRSMarine; |
| 99 | - if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
|
| 107 | + if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') { |
|
| 108 | + $globalCoordMinChange = '0.02'; |
|
| 109 | + } |
|
| 100 | 110 | date_default_timezone_set('UTC'); |
| 101 | 111 | $dataFound = false; |
| 102 | 112 | $send = false; |
@@ -121,8 +131,11 @@ discard block |
||
| 121 | 131 | |
| 122 | 132 | $Common = new Common(); |
| 123 | 133 | $AIS = new AIS(); |
| 124 | - if (!isset($line['id'])) $id = trim($line['mmsi']); |
|
| 125 | - else $id = trim($line['id']); |
|
| 134 | + if (!isset($line['id'])) { |
|
| 135 | + $id = trim($line['mmsi']); |
|
| 136 | + } else { |
|
| 137 | + $id = trim($line['id']); |
|
| 138 | + } |
|
| 126 | 139 | |
| 127 | 140 | if (!isset($this->all_tracked[$id])) { |
| 128 | 141 | $this->all_tracked[$id] = array(); |
@@ -130,10 +143,16 @@ discard block |
||
| 130 | 143 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '0', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','status_id' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '','mmsi_type' => '')); |
| 131 | 144 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
| 132 | 145 | if (!isset($line['id'])) { |
| 133 | - if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
| 146 | + if (!isset($globalDaemon)) { |
|
| 147 | + $globalDaemon = TRUE; |
|
| 148 | + } |
|
| 134 | 149 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi'))); |
| 135 | - } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
| 136 | - if ($globalAllTracked !== FALSE) $dataFound = true; |
|
| 150 | + } else { |
|
| 151 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
| 152 | + } |
|
| 153 | + if ($globalAllTracked !== FALSE) { |
|
| 154 | + $dataFound = true; |
|
| 155 | + } |
|
| 137 | 156 | } |
| 138 | 157 | |
| 139 | 158 | if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) { |
@@ -183,34 +202,49 @@ discard block |
||
| 183 | 202 | $Marine = new Marine($this->db); |
| 184 | 203 | $fromsource = NULL; |
| 185 | 204 | $result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource); |
| 186 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
| 205 | + if ($globalDebug && $result != 'success') { |
|
| 206 | + echo '!!! ERROR : '.$result."\n"; |
|
| 207 | + } |
|
| 187 | 208 | $Marine->db = null; |
| 188 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 209 | + if ($globalDebugTimeElapsed) { |
|
| 210 | + echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 211 | + } |
|
| 189 | 212 | } |
| 190 | 213 | } |
| 191 | 214 | } |
| 192 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
| 215 | + if (!isset($this->all_tracked[$id]['id'])) { |
|
| 216 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
| 217 | + } |
|
| 193 | 218 | } |
| 194 | 219 | |
| 195 | 220 | if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) { |
| 196 | 221 | if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) { |
| 197 | 222 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
| 198 | 223 | } else { |
| 199 | - if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n"; |
|
| 200 | - elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
| 224 | + if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) { |
|
| 225 | + echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n"; |
|
| 226 | + } elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) { |
|
| 227 | + echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
| 228 | + } |
|
| 201 | 229 | return ''; |
| 202 | 230 | } |
| 203 | 231 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) { |
| 204 | - if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!"; |
|
| 232 | + if ($globalDebug) { |
|
| 233 | + echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!"; |
|
| 234 | + } |
|
| 205 | 235 | return ''; |
| 206 | 236 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) { |
| 207 | - if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!"; |
|
| 237 | + if ($globalDebug) { |
|
| 238 | + echo "!!! Date is in the future ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!"; |
|
| 239 | + } |
|
| 208 | 240 | return ''; |
| 209 | 241 | } elseif (!isset($line['datetime'])) { |
| 210 | 242 | date_default_timezone_set('UTC'); |
| 211 | 243 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s'))); |
| 212 | 244 | } else { |
| 213 | - if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!"; |
|
| 245 | + if ($globalDebug) { |
|
| 246 | + echo "!!! Unknow date error ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!"; |
|
| 247 | + } |
|
| 214 | 248 | return ''; |
| 215 | 249 | } |
| 216 | 250 | |
@@ -223,14 +257,21 @@ discard block |
||
| 223 | 257 | if ($distance > 1000 && $distance < 10000) { |
| 224 | 258 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
| 225 | 259 | $speed = $speed*3.6; |
| 226 | - if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
|
| 227 | - if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
|
| 260 | + if ($speed < 1000) { |
|
| 261 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
|
| 262 | + } |
|
| 263 | + if ($globalDebug) { |
|
| 264 | + echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
|
| 265 | + } |
|
| 228 | 266 | } |
| 229 | 267 | } |
| 230 | 268 | |
| 231 | 269 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
| 232 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
| 233 | - else unset($timediff); |
|
| 270 | + if (isset($this->all_tracked[$id]['time_last_coord'])) { |
|
| 271 | + $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
| 272 | + } else { |
|
| 273 | + unset($timediff); |
|
| 274 | + } |
|
| 234 | 275 | if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) { |
| 235 | 276 | if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) { |
| 236 | 277 | if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
@@ -238,22 +279,32 @@ discard block |
||
| 238 | 279 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
| 239 | 280 | $this->all_tracked[$id]['putinarchive'] = true; |
| 240 | 281 | |
| 241 | - if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
| 282 | + if ($globalDebug) { |
|
| 283 | + echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
| 284 | + } |
|
| 242 | 285 | $timeelapsed = microtime(true); |
| 243 | 286 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 244 | 287 | $Marine = new Marine($this->db); |
| 245 | 288 | $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
| 246 | - if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
| 289 | + if (!empty($all_country)) { |
|
| 290 | + $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
| 291 | + } |
|
| 247 | 292 | $Marine->db = null; |
| 248 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 293 | + if ($globalDebugTimeElapsed) { |
|
| 294 | + echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 295 | + } |
|
| 249 | 296 | } |
| 250 | 297 | $this->tmd = 0; |
| 251 | - if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
|
| 298 | + if ($globalDebug) { |
|
| 299 | + echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
|
| 300 | + } |
|
| 252 | 301 | } |
| 253 | 302 | } |
| 254 | 303 | |
| 255 | 304 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
| 256 | - if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
|
| 305 | + if (!isset($this->all_tracked[$id]['archive_latitude'])) { |
|
| 306 | + $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
|
| 307 | + } |
|
| 257 | 308 | if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
| 258 | 309 | $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
| 259 | 310 | $dataFound = true; |
@@ -262,8 +313,12 @@ discard block |
||
| 262 | 313 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
| 263 | 314 | } |
| 264 | 315 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
| 265 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
| 266 | - if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
|
| 316 | + if ($line['longitude'] > 180) { |
|
| 317 | + $line['longitude'] = $line['longitude'] - 360; |
|
| 318 | + } |
|
| 319 | + if (!isset($this->all_tracked[$id]['archive_longitude'])) { |
|
| 320 | + $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
|
| 321 | + } |
|
| 267 | 322 | if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
| 268 | 323 | $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
| 269 | 324 | $dataFound = true; |
@@ -281,7 +336,9 @@ discard block |
||
| 281 | 336 | } |
| 282 | 337 | } |
| 283 | 338 | if (isset($line['last_update']) && $line['last_update'] != '') { |
| 284 | - if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
| 339 | + if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) { |
|
| 340 | + $dataFound = true; |
|
| 341 | + } |
|
| 285 | 342 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
| 286 | 343 | } |
| 287 | 344 | if (isset($line['format_source']) && $line['format_source'] != '') { |
@@ -302,15 +359,21 @@ discard block |
||
| 302 | 359 | } |
| 303 | 360 | |
| 304 | 361 | if (isset($line['heading']) && $line['heading'] != '') { |
| 305 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 362 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) { |
|
| 363 | + $this->all_tracked[$id]['putinarchive'] = true; |
|
| 364 | + } |
|
| 306 | 365 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
| 307 | 366 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
| 308 | 367 | //$dataFound = true; |
| 309 | 368 | } elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) { |
| 310 | 369 | $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
| 311 | 370 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
| 312 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
| 313 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
| 371 | + if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) { |
|
| 372 | + $this->all_tracked[$id]['putinarchive'] = true; |
|
| 373 | + } |
|
| 374 | + if ($globalDebug) { |
|
| 375 | + echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
| 376 | + } |
|
| 314 | 377 | } |
| 315 | 378 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
| 316 | 379 | |
@@ -322,23 +385,38 @@ discard block |
||
| 322 | 385 | if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
| 323 | 386 | if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
| 324 | 387 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 325 | - if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
| 388 | + if ($globalDebug) { |
|
| 389 | + echo "Check if aircraft is already in DB..."; |
|
| 390 | + } |
|
| 326 | 391 | $timeelapsed = microtime(true); |
| 327 | 392 | $MarineLive = new MarineLive($this->db); |
| 328 | 393 | if (isset($line['id'])) { |
| 329 | 394 | $recent_ident = $MarineLive->checkIdRecent($line['id']); |
| 330 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 395 | + if ($globalDebugTimeElapsed) { |
|
| 396 | + echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 397 | + } |
|
| 331 | 398 | } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') { |
| 332 | 399 | $recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']); |
| 333 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 400 | + if ($globalDebugTimeElapsed) { |
|
| 401 | + echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 402 | + } |
|
| 334 | 403 | } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
| 335 | 404 | $recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
| 336 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 337 | - } else $recent_ident = ''; |
|
| 405 | + if ($globalDebugTimeElapsed) { |
|
| 406 | + echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 407 | + } |
|
| 408 | + } else { |
|
| 409 | + $recent_ident = ''; |
|
| 410 | + } |
|
| 338 | 411 | $MarineLive->db=null; |
| 339 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
| 340 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
| 341 | - } else $recent_ident = ''; |
|
| 412 | + if ($globalDebug && $recent_ident == '') { |
|
| 413 | + echo " Not in DB.\n"; |
|
| 414 | + } elseif ($globalDebug && $recent_ident != '') { |
|
| 415 | + echo " Already in DB.\n"; |
|
| 416 | + } |
|
| 417 | + } else { |
|
| 418 | + $recent_ident = ''; |
|
| 419 | + } |
|
| 342 | 420 | } else { |
| 343 | 421 | $recent_ident = ''; |
| 344 | 422 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
@@ -346,18 +424,26 @@ discard block |
||
| 346 | 424 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
| 347 | 425 | if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
| 348 | 426 | { |
| 349 | - if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
|
| 427 | + if ($globalDebug) { |
|
| 428 | + echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
|
| 429 | + } |
|
| 350 | 430 | //adds the spotter data for the archive |
| 351 | 431 | $highlight = ''; |
| 352 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi'))); |
|
| 432 | + if (!isset($this->all_tracked[$id]['id'])) { |
|
| 433 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi'))); |
|
| 434 | + } |
|
| 353 | 435 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
| 354 | 436 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 355 | 437 | $timeelapsed = microtime(true); |
| 356 | 438 | $Marine = new Marine($this->db); |
| 357 | 439 | $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']); |
| 358 | 440 | $Marine->db = null; |
| 359 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
| 360 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 441 | + if ($globalDebug && isset($result)) { |
|
| 442 | + echo $result."\n"; |
|
| 443 | + } |
|
| 444 | + if ($globalDebugTimeElapsed) { |
|
| 445 | + echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 446 | + } |
|
| 361 | 447 | } |
| 362 | 448 | } |
| 363 | 449 | /* |
@@ -392,13 +478,17 @@ discard block |
||
| 392 | 478 | $this->all_tracked[$id]['addedMarine'] = 1; |
| 393 | 479 | //print_r($this->all_tracked[$id]); |
| 394 | 480 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
| 395 | - if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours..."; |
|
| 481 | + if ($globalDebug) { |
|
| 482 | + echo "---- Deleting Live Marine data older than 9 hours..."; |
|
| 483 | + } |
|
| 396 | 484 | //MarineLive->deleteLiveMarineDataNotUpdated(); |
| 397 | 485 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 398 | 486 | $MarineLive = new MarineLive($this->db); |
| 399 | 487 | $MarineLive->deleteLiveMarineData(); |
| 400 | 488 | $MarineLive->db=null; |
| 401 | - if ($globalDebug) echo " Done\n"; |
|
| 489 | + if ($globalDebug) { |
|
| 490 | + echo " Done\n"; |
|
| 491 | + } |
|
| 402 | 492 | } |
| 403 | 493 | $this->last_delete = time(); |
| 404 | 494 | } |
@@ -424,15 +514,21 @@ discard block |
||
| 424 | 514 | |
| 425 | 515 | if (!$ignoreImport) { |
| 426 | 516 | if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
| 427 | - if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
|
| 517 | + if ($globalDebug) { |
|
| 518 | + echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
|
| 519 | + } |
|
| 428 | 520 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
| 429 | 521 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 430 | 522 | $timeelapsed = microtime(true); |
| 431 | 523 | $MarineLive = new MarineLive($this->db); |
| 432 | 524 | $result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']); |
| 433 | 525 | $MarineLive->db = null; |
| 434 | - if ($globalDebug) echo $result."\n"; |
|
| 435 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 526 | + if ($globalDebug) { |
|
| 527 | + echo $result."\n"; |
|
| 528 | + } |
|
| 529 | + if ($globalDebugTimeElapsed) { |
|
| 530 | + echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 531 | + } |
|
| 436 | 532 | } |
| 437 | 533 | } |
| 438 | 534 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) { |
@@ -495,19 +591,27 @@ discard block |
||
| 495 | 591 | */ |
| 496 | 592 | |
| 497 | 593 | $this->all_tracked[$id]['lastupdate'] = time(); |
| 498 | - if ($this->all_tracked[$id]['putinarchive']) $send = true; |
|
| 499 | - } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
| 594 | + if ($this->all_tracked[$id]['putinarchive']) { |
|
| 595 | + $send = true; |
|
| 596 | + } |
|
| 597 | + } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) { |
|
| 598 | + echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
| 599 | + } |
|
| 500 | 600 | //$this->del(); |
| 501 | 601 | |
| 502 | 602 | |
| 503 | 603 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
| 504 | 604 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 505 | - if ($globalDebug) echo "---- Deleting Live Marine data Not updated since 2 hour..."; |
|
| 605 | + if ($globalDebug) { |
|
| 606 | + echo "---- Deleting Live Marine data Not updated since 2 hour..."; |
|
| 607 | + } |
|
| 506 | 608 | $MarineLive = new MarineLive($this->db); |
| 507 | 609 | $MarineLive->deleteLiveMarineDataNotUpdated(); |
| 508 | 610 | $MarineLive->db = null; |
| 509 | 611 | //MarineLive->deleteLiveMarineData(); |
| 510 | - if ($globalDebug) echo " Done\n"; |
|
| 612 | + if ($globalDebug) { |
|
| 613 | + echo " Done\n"; |
|
| 614 | + } |
|
| 511 | 615 | } |
| 512 | 616 | $this->last_delete_hourly = time(); |
| 513 | 617 | } |
@@ -516,7 +620,9 @@ discard block |
||
| 516 | 620 | //$ignoreImport = false; |
| 517 | 621 | } |
| 518 | 622 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
| 519 | - if ($send) return $this->all_tracked[$id]; |
|
| 623 | + if ($send) { |
|
| 624 | + return $this->all_tracked[$id]; |
|
| 625 | + } |
|
| 520 | 626 | } |
| 521 | 627 | } |
| 522 | 628 | } |
@@ -2,7 +2,7 @@ discard block |
||
| 2 | 2 | require_once(dirname(__FILE__).'/class.Image.php'); |
| 3 | 3 | $global_query = "SELECT marine_output.* FROM marine_output"; |
| 4 | 4 | |
| 5 | -class Marine{ |
|
| 5 | +class Marine { |
|
| 6 | 6 | public $db; |
| 7 | 7 | |
| 8 | 8 | public function __construct($dbc = null) { |
@@ -16,33 +16,33 @@ discard block |
||
| 16 | 16 | * @return Array the SQL part |
| 17 | 17 | */ |
| 18 | 18 | |
| 19 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
| 19 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
| 20 | 20 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
| 21 | 21 | $filters = array(); |
| 22 | 22 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
| 23 | 23 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
| 24 | 24 | $filters = $globalStatsFilters[$globalFilterName]; |
| 25 | 25 | } else { |
| 26 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
| 26 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
| 27 | 27 | } |
| 28 | 28 | } |
| 29 | 29 | if (isset($filter[0]['source'])) { |
| 30 | - $filters = array_merge($filters,$filter); |
|
| 30 | + $filters = array_merge($filters, $filter); |
|
| 31 | 31 | } |
| 32 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 32 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
| 33 | 33 | $filter_query_join = ''; |
| 34 | 34 | $filter_query_where = ''; |
| 35 | - foreach($filters as $flt) { |
|
| 35 | + foreach ($filters as $flt) { |
|
| 36 | 36 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
| 37 | 37 | if (isset($flt['source'])) { |
| 38 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id"; |
|
| 38 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id"; |
|
| 39 | 39 | } else { |
| 40 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id"; |
|
| 40 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id"; |
|
| 41 | 41 | } |
| 42 | 42 | } |
| 43 | 43 | } |
| 44 | 44 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 45 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
| 45 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
| 46 | 46 | } |
| 47 | 47 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
| 48 | 48 | $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
| 72 | 72 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
| 73 | 73 | if ($filter_query_where != '') { |
| 74 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
| 74 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
| 75 | 75 | } |
| 76 | 76 | $filter_query = $filter_query_join.$filter_query_where; |
| 77 | 77 | return $filter_query; |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | * @return Array the spotter information |
| 87 | 87 | * |
| 88 | 88 | */ |
| 89 | - public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false) |
|
| 89 | + public function getDataFromDB($query, $params = array(), $limitQuery = '', $schedules = false) |
|
| 90 | 90 | { |
| 91 | 91 | date_default_timezone_set('UTC'); |
| 92 | 92 | if (!is_string($query)) |
@@ -106,13 +106,13 @@ discard block |
||
| 106 | 106 | $sth = $this->db->prepare($query.$limitQuery); |
| 107 | 107 | $sth->execute($params); |
| 108 | 108 | } catch (PDOException $e) { |
| 109 | - printf("Invalid query : %s\nWhole query: %s\n",$e->getMessage(), $query.$limitQuery); |
|
| 109 | + printf("Invalid query : %s\nWhole query: %s\n", $e->getMessage(), $query.$limitQuery); |
|
| 110 | 110 | exit(); |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | $num_rows = 0; |
| 114 | 114 | $spotter_array = array(); |
| 115 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 115 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 116 | 116 | { |
| 117 | 117 | $num_rows++; |
| 118 | 118 | $temp_array = array(); |
@@ -144,10 +144,10 @@ discard block |
||
| 144 | 144 | } |
| 145 | 145 | if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed']; |
| 146 | 146 | |
| 147 | - if($temp_array['mmsi'] != "" && isset($globalMarineImageFetch) && $globalMarineImageFetch === TRUE) |
|
| 147 | + if ($temp_array['mmsi'] != "" && isset($globalMarineImageFetch) && $globalMarineImageFetch === TRUE) |
|
| 148 | 148 | { |
| 149 | 149 | $Image = new Image($this->db); |
| 150 | - if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']); |
|
| 150 | + if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'], '', $temp_array['ident']); |
|
| 151 | 151 | else $image_array = $Image->getMarineImage($temp_array['mmsi']); |
| 152 | 152 | unset($Image); |
| 153 | 153 | if (count($image_array) > 0) { |
@@ -183,17 +183,17 @@ discard block |
||
| 183 | 183 | { |
| 184 | 184 | $temp_array['date'] = "about ".$dateArray['hours']." hours ago"; |
| 185 | 185 | } else { |
| 186 | - $temp_array['date'] = date("M j Y, g:i a",strtotime($row['date']." UTC")); |
|
| 186 | + $temp_array['date'] = date("M j Y, g:i a", strtotime($row['date']." UTC")); |
|
| 187 | 187 | } |
| 188 | 188 | $temp_array['date_minutes_past'] = $dateArray['minutes']; |
| 189 | - $temp_array['date_iso_8601'] = date("c",strtotime($row['date']." UTC")); |
|
| 190 | - $temp_array['date_rfc_2822'] = date("r",strtotime($row['date']." UTC")); |
|
| 189 | + $temp_array['date_iso_8601'] = date("c", strtotime($row['date']." UTC")); |
|
| 190 | + $temp_array['date_rfc_2822'] = date("r", strtotime($row['date']." UTC")); |
|
| 191 | 191 | $temp_array['date_unix'] = strtotime($row['date']." UTC"); |
| 192 | 192 | if (isset($row['last_seen']) && $row['last_seen'] != '') { |
| 193 | 193 | if (strtotime($row['last_seen']) > strtotime($row['date'])) { |
| 194 | 194 | $temp_array['duration'] = strtotime($row['last_seen']) - strtotime($row['date']); |
| 195 | - $temp_array['last_seen_date_iso_8601'] = date("c",strtotime($row['last_seen']." UTC")); |
|
| 196 | - $temp_array['last_seen_date_rfc_2822'] = date("r",strtotime($row['last_seen']." UTC")); |
|
| 195 | + $temp_array['last_seen_date_iso_8601'] = date("c", strtotime($row['last_seen']." UTC")); |
|
| 196 | + $temp_array['last_seen_date_rfc_2822'] = date("r", strtotime($row['last_seen']." UTC")); |
|
| 197 | 197 | $temp_array['last_seen_date_unix'] = strtotime($row['last_seen']." UTC"); |
| 198 | 198 | } |
| 199 | 199 | } |
@@ -230,8 +230,8 @@ discard block |
||
| 230 | 230 | { |
| 231 | 231 | $limit_array = explode(",", $limit); |
| 232 | 232 | |
| 233 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 234 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 233 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 234 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 235 | 235 | |
| 236 | 236 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 237 | 237 | { |
@@ -248,9 +248,9 @@ discard block |
||
| 248 | 248 | $orderby_query = " ORDER BY marine_output.date DESC"; |
| 249 | 249 | } |
| 250 | 250 | |
| 251 | - $query = $global_query.$filter_query." ".$orderby_query; |
|
| 251 | + $query = $global_query.$filter_query." ".$orderby_query; |
|
| 252 | 252 | |
| 253 | - $spotter_array = $this->getDataFromDB($query, array(),$limit_query,true); |
|
| 253 | + $spotter_array = $this->getDataFromDB($query, array(), $limit_query, true); |
|
| 254 | 254 | |
| 255 | 255 | return $spotter_array; |
| 256 | 256 | } |
@@ -269,8 +269,8 @@ discard block |
||
| 269 | 269 | if ($id == '') return array(); |
| 270 | 270 | $additional_query = "marine_output.fammarine_id = :id"; |
| 271 | 271 | $query_values = array(':id' => $id); |
| 272 | - $query = $global_query." WHERE ".$additional_query." "; |
|
| 273 | - $spotter_array = $this->getDataFromDB($query,$query_values); |
|
| 272 | + $query = $global_query." WHERE ".$additional_query." "; |
|
| 273 | + $spotter_array = $this->getDataFromDB($query, $query_values); |
|
| 274 | 274 | return $spotter_array; |
| 275 | 275 | } |
| 276 | 276 | |
@@ -289,7 +289,7 @@ discard block |
||
| 289 | 289 | $query_values = array(); |
| 290 | 290 | $limit_query = ''; |
| 291 | 291 | $additional_query = ''; |
| 292 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 292 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 293 | 293 | if ($ident != "") |
| 294 | 294 | { |
| 295 | 295 | if (!is_string($ident)) |
@@ -305,8 +305,8 @@ discard block |
||
| 305 | 305 | { |
| 306 | 306 | $limit_array = explode(",", $limit); |
| 307 | 307 | |
| 308 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 309 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 308 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 309 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 310 | 310 | |
| 311 | 311 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 312 | 312 | { |
@@ -330,7 +330,7 @@ discard block |
||
| 330 | 330 | return $spotter_array; |
| 331 | 331 | } |
| 332 | 332 | |
| 333 | - public function getMarineDataByDate($date = '', $limit = '', $sort = '',$filter = array()) |
|
| 333 | + public function getMarineDataByDate($date = '', $limit = '', $sort = '', $filter = array()) |
|
| 334 | 334 | { |
| 335 | 335 | global $global_query, $globalTimezone, $globalDBdriver; |
| 336 | 336 | |
@@ -338,7 +338,7 @@ discard block |
||
| 338 | 338 | $limit_query = ''; |
| 339 | 339 | $additional_query = ''; |
| 340 | 340 | |
| 341 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 341 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 342 | 342 | |
| 343 | 343 | if ($date != "") |
| 344 | 344 | { |
@@ -364,8 +364,8 @@ discard block |
||
| 364 | 364 | { |
| 365 | 365 | $limit_array = explode(",", $limit); |
| 366 | 366 | |
| 367 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 368 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 367 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 368 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 369 | 369 | |
| 370 | 370 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 371 | 371 | { |
@@ -396,11 +396,11 @@ discard block |
||
| 396 | 396 | * @return Array list of source name |
| 397 | 397 | * |
| 398 | 398 | */ |
| 399 | - public function getAllSourceName($type = '',$filters = array()) |
|
| 399 | + public function getAllSourceName($type = '', $filters = array()) |
|
| 400 | 400 | { |
| 401 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 401 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 402 | 402 | $query_values = array(); |
| 403 | - $query = "SELECT DISTINCT marine_output.source_name |
|
| 403 | + $query = "SELECT DISTINCT marine_output.source_name |
|
| 404 | 404 | FROM marine_output".$filter_query." marine_output.source_name <> ''"; |
| 405 | 405 | if ($type != '') { |
| 406 | 406 | $query_values = array(':type' => $type); |
@@ -415,7 +415,7 @@ discard block |
||
| 415 | 415 | $source_array = array(); |
| 416 | 416 | $temp_array = array(); |
| 417 | 417 | |
| 418 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 418 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 419 | 419 | { |
| 420 | 420 | $temp_array['source_name'] = $row['source_name']; |
| 421 | 421 | $source_array[] = $temp_array; |
@@ -432,8 +432,8 @@ discard block |
||
| 432 | 432 | */ |
| 433 | 433 | public function getAllIdents($filters = array()) |
| 434 | 434 | { |
| 435 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 436 | - $query = "SELECT DISTINCT marine_output.ident |
|
| 435 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 436 | + $query = "SELECT DISTINCT marine_output.ident |
|
| 437 | 437 | FROM marine_output".$filter_query." marine_output.ident <> '' |
| 438 | 438 | ORDER BY marine_output.date ASC LIMIT 700 OFFSET 0"; |
| 439 | 439 | |
@@ -443,7 +443,7 @@ discard block |
||
| 443 | 443 | $ident_array = array(); |
| 444 | 444 | $temp_array = array(); |
| 445 | 445 | |
| 446 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 446 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 447 | 447 | { |
| 448 | 448 | $temp_array['ident'] = $row['ident']; |
| 449 | 449 | $ident_array[] = $temp_array; |
@@ -460,7 +460,7 @@ discard block |
||
| 460 | 460 | */ |
| 461 | 461 | public function getIdentity($mmsi) |
| 462 | 462 | { |
| 463 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); |
|
| 463 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT); |
|
| 464 | 464 | $query = "SELECT * FROM marine_identity WHERE mmsi = :mmsi LIMIT 1"; |
| 465 | 465 | $sth = $this->db->prepare($query); |
| 466 | 466 | $sth->execute(array(':mmsi' => $mmsi)); |
@@ -485,12 +485,12 @@ discard block |
||
| 485 | 485 | } else $offset = '+00:00'; |
| 486 | 486 | |
| 487 | 487 | if ($globalDBdriver == 'mysql') { |
| 488 | - $query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date |
|
| 488 | + $query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date |
|
| 489 | 489 | FROM marine_output |
| 490 | 490 | WHERE marine_output.date <> '' |
| 491 | 491 | ORDER BY marine_output.date ASC LIMIT 0,200"; |
| 492 | 492 | } else { |
| 493 | - $query = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date |
|
| 493 | + $query = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date |
|
| 494 | 494 | FROM marine_output |
| 495 | 495 | WHERE marine_output.date <> '' |
| 496 | 496 | ORDER BY marine_output.date ASC LIMIT 0,200"; |
@@ -502,7 +502,7 @@ discard block |
||
| 502 | 502 | $date_array = array(); |
| 503 | 503 | $temp_array = array(); |
| 504 | 504 | |
| 505 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 505 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 506 | 506 | { |
| 507 | 507 | $temp_array['date'] = $row['date']; |
| 508 | 508 | |
@@ -521,11 +521,11 @@ discard block |
||
| 521 | 521 | * @return String success or false |
| 522 | 522 | * |
| 523 | 523 | */ |
| 524 | - public function updateIdentMarineData($fammarine_id = '', $ident = '',$fromsource = NULL) |
|
| 524 | + public function updateIdentMarineData($fammarine_id = '', $ident = '', $fromsource = NULL) |
|
| 525 | 525 | { |
| 526 | 526 | |
| 527 | 527 | $query = 'UPDATE marine_output SET ident = :ident WHERE fammarine_id = :fammarine_id'; |
| 528 | - $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident); |
|
| 528 | + $query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident); |
|
| 529 | 529 | |
| 530 | 530 | try { |
| 531 | 531 | $sth = $this->db->prepare($query); |
@@ -548,7 +548,7 @@ discard block |
||
| 548 | 548 | public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '') |
| 549 | 549 | { |
| 550 | 550 | $query = 'UPDATE marine_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_seen = :last_seen, last_ground_speed = :last_ground_speed WHERE fammarine_id = :fammarine_id'; |
| 551 | - $query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident); |
|
| 551 | + $query_values = array(':fammarine_id' => $fammarine_id, ':last_latitude' => $latitude, ':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed, ':last_seen' => $date, ':ident' => $ident); |
|
| 552 | 552 | |
| 553 | 553 | try { |
| 554 | 554 | $sth = $this->db->prepare($query); |
@@ -586,7 +586,7 @@ discard block |
||
| 586 | 586 | * @param String $verticalrate vertival rate of flight |
| 587 | 587 | * @return String success or false |
| 588 | 588 | */ |
| 589 | - public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '',$type = '',$typeid = '',$imo = '',$callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$format_source = '', $source_name = '') |
|
| 589 | + public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '', $type = '', $typeid = '', $imo = '', $callsign = '', $arrival_code = '', $arrival_date = '', $status = '', $statusid = '', $format_source = '', $source_name = '') |
|
| 590 | 590 | { |
| 591 | 591 | global $globalURL, $globalMarineImageFetch; |
| 592 | 592 | |
@@ -653,31 +653,31 @@ discard block |
||
| 653 | 653 | } |
| 654 | 654 | |
| 655 | 655 | |
| 656 | - if ($date == "" || strtotime($date) < time()-20*60) |
|
| 656 | + if ($date == "" || strtotime($date) < time() - 20*60) |
|
| 657 | 657 | { |
| 658 | 658 | $date = date("Y-m-d H:i:s", time()); |
| 659 | 659 | } |
| 660 | 660 | |
| 661 | - $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
|
| 662 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
| 663 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 664 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 665 | - $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
|
| 666 | - $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 667 | - $format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
|
| 668 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); |
|
| 669 | - $type = filter_var($type,FILTER_SANITIZE_STRING); |
|
| 670 | - $status = filter_var($status,FILTER_SANITIZE_STRING); |
|
| 671 | - $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
|
| 672 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
| 673 | - $arrival_code = filter_var($arrival_code,FILTER_SANITIZE_STRING); |
|
| 674 | - $arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING); |
|
| 661 | + $fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING); |
|
| 662 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 663 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 664 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 665 | + $heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT); |
|
| 666 | + $groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 667 | + $format_source = filter_var($format_source, FILTER_SANITIZE_STRING); |
|
| 668 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING); |
|
| 669 | + $type = filter_var($type, FILTER_SANITIZE_STRING); |
|
| 670 | + $status = filter_var($status, FILTER_SANITIZE_STRING); |
|
| 671 | + $imo = filter_var($imo, FILTER_SANITIZE_STRING); |
|
| 672 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
| 673 | + $arrival_code = filter_var($arrival_code, FILTER_SANITIZE_STRING); |
|
| 674 | + $arrival_date = filter_var($arrival_date, FILTER_SANITIZE_STRING); |
|
| 675 | 675 | |
| 676 | 676 | if (isset($globalMarineImageFetch) && $globalMarineImageFetch === TRUE) { |
| 677 | 677 | $Image = new Image($this->db); |
| 678 | - $image_array = $Image->getMarineImage($mmsi,$imo,$ident); |
|
| 678 | + $image_array = $Image->getMarineImage($mmsi, $imo, $ident); |
|
| 679 | 679 | if (!isset($image_array[0]['mmsi'])) { |
| 680 | - $Image->addMarineImage($mmsi,$imo,$ident); |
|
| 680 | + $Image->addMarineImage($mmsi, $imo, $ident); |
|
| 681 | 681 | } |
| 682 | 682 | unset($Image); |
| 683 | 683 | } |
@@ -689,10 +689,10 @@ discard block |
||
| 689 | 689 | if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
| 690 | 690 | if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
| 691 | 691 | if ($arrival_date == '') $arrival_date = NULL; |
| 692 | - $query = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, status,imo,arrival_port_name,arrival_port_date) |
|
| 692 | + $query = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, status,imo,arrival_port_name,arrival_port_date) |
|
| 693 | 693 | VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)"; |
| 694 | 694 | |
| 695 | - $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':heading' => $heading,':speed' => $groundspeed,':date' => $date,':format_source' => $format_source, ':source_name' => $source_name,':mmsi' => $mmsi,':type' => $type,':status' => $status,':imo' => $imo,':arrival_port_name' => $arrival_code,':arrival_port_date' => $arrival_date); |
|
| 695 | + $query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':heading' => $heading, ':speed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':mmsi' => $mmsi, ':type' => $type, ':status' => $status, ':imo' => $imo, ':arrival_port_name' => $arrival_code, ':arrival_port_date' => $arrival_date); |
|
| 696 | 696 | try { |
| 697 | 697 | |
| 698 | 698 | $sth = $this->db->prepare($query); |
@@ -717,13 +717,13 @@ discard block |
||
| 717 | 717 | { |
| 718 | 718 | global $globalDBdriver, $globalTimezone; |
| 719 | 719 | if ($globalDBdriver == 'mysql') { |
| 720 | - $query = "SELECT marine_output.ident FROM marine_output |
|
| 720 | + $query = "SELECT marine_output.ident FROM marine_output |
|
| 721 | 721 | WHERE marine_output.ident = :ident |
| 722 | 722 | AND marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
| 723 | 723 | AND marine_output.date < UTC_TIMESTAMP()"; |
| 724 | 724 | $query_data = array(':ident' => $ident); |
| 725 | 725 | } else { |
| 726 | - $query = "SELECT marine_output.ident FROM marine_output |
|
| 726 | + $query = "SELECT marine_output.ident FROM marine_output |
|
| 727 | 727 | WHERE marine_output.ident = :ident |
| 728 | 728 | AND marine_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
| 729 | 729 | AND marine_output.date < now() AT TIME ZONE 'UTC'"; |
@@ -732,8 +732,8 @@ discard block |
||
| 732 | 732 | |
| 733 | 733 | $sth = $this->db->prepare($query); |
| 734 | 734 | $sth->execute($query_data); |
| 735 | - $ident_result=''; |
|
| 736 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 735 | + $ident_result = ''; |
|
| 736 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 737 | 737 | { |
| 738 | 738 | $ident_result = $row['ident']; |
| 739 | 739 | } |
@@ -759,8 +759,8 @@ discard block |
||
| 759 | 759 | return false; |
| 760 | 760 | } else { |
| 761 | 761 | $q_array = explode(" ", $q); |
| 762 | - foreach ($q_array as $q_item){ |
|
| 763 | - $q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
|
| 762 | + foreach ($q_array as $q_item) { |
|
| 763 | + $q_item = filter_var($q_item, FILTER_SANITIZE_STRING); |
|
| 764 | 764 | $additional_query .= " AND ("; |
| 765 | 765 | $additional_query .= "(marine_output.ident like '%".$q_item."%')"; |
| 766 | 766 | $additional_query .= ")"; |
@@ -768,11 +768,11 @@ discard block |
||
| 768 | 768 | } |
| 769 | 769 | } |
| 770 | 770 | if ($globalDBdriver == 'mysql') { |
| 771 | - $query = "SELECT marine_output.* FROM marine_output |
|
| 771 | + $query = "SELECT marine_output.* FROM marine_output |
|
| 772 | 772 | WHERE marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 SECOND) ".$additional_query." |
| 773 | 773 | AND marine_output.date < UTC_TIMESTAMP()"; |
| 774 | 774 | } else { |
| 775 | - $query = "SELECT marine_output.* FROM marine_output |
|
| 775 | + $query = "SELECT marine_output.* FROM marine_output |
|
| 776 | 776 | WHERE marine_output.date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 SECONDS' ".$additional_query." |
| 777 | 777 | AND marine_output.date::timestamp < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'"; |
| 778 | 778 | } |
@@ -845,11 +845,11 @@ discard block |
||
| 845 | 845 | * @return Array the callsign list |
| 846 | 846 | * |
| 847 | 847 | */ |
| 848 | - public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '') |
|
| 848 | + public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '') |
|
| 849 | 849 | { |
| 850 | 850 | global $globalDBdriver; |
| 851 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 852 | - $query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count |
|
| 851 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 852 | + $query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count |
|
| 853 | 853 | FROM marine_output".$filter_query." marine_output.ident <> ''"; |
| 854 | 854 | if ($olderthanmonths > 0) { |
| 855 | 855 | if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
@@ -863,28 +863,28 @@ discard block |
||
| 863 | 863 | if ($year != '') { |
| 864 | 864 | if ($globalDBdriver == 'mysql') { |
| 865 | 865 | $query .= " AND YEAR(marine_output.date) = :year"; |
| 866 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 866 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 867 | 867 | } else { |
| 868 | 868 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
| 869 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 869 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 870 | 870 | } |
| 871 | 871 | } |
| 872 | 872 | if ($month != '') { |
| 873 | 873 | if ($globalDBdriver == 'mysql') { |
| 874 | 874 | $query .= " AND MONTH(marine_output.date) = :month"; |
| 875 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 875 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 876 | 876 | } else { |
| 877 | 877 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
| 878 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 878 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 879 | 879 | } |
| 880 | 880 | } |
| 881 | 881 | if ($day != '') { |
| 882 | 882 | if ($globalDBdriver == 'mysql') { |
| 883 | 883 | $query .= " AND DAY(marine_output.date) = :day"; |
| 884 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 884 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 885 | 885 | } else { |
| 886 | 886 | $query .= " AND EXTRACT(DAY FROM marine_output.date) = :day"; |
| 887 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 887 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 888 | 888 | } |
| 889 | 889 | } |
| 890 | 890 | $query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC"; |
@@ -896,7 +896,7 @@ discard block |
||
| 896 | 896 | $callsign_array = array(); |
| 897 | 897 | $temp_array = array(); |
| 898 | 898 | |
| 899 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 899 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 900 | 900 | { |
| 901 | 901 | $temp_array['callsign_icao'] = $row['ident']; |
| 902 | 902 | $temp_array['airline_name'] = $row['airline_name']; |
@@ -948,7 +948,7 @@ discard block |
||
| 948 | 948 | $date_array = array(); |
| 949 | 949 | $temp_array = array(); |
| 950 | 950 | |
| 951 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 951 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 952 | 952 | { |
| 953 | 953 | $temp_array['date_name'] = $row['date_name']; |
| 954 | 954 | $temp_array['date_count'] = $row['date_count']; |
@@ -974,7 +974,7 @@ discard block |
||
| 974 | 974 | $datetime = new DateTime(); |
| 975 | 975 | $offset = $datetime->format('P'); |
| 976 | 976 | } else $offset = '+00:00'; |
| 977 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 977 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 978 | 978 | if ($globalDBdriver == 'mysql') { |
| 979 | 979 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
| 980 | 980 | FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY)"; |
@@ -995,7 +995,7 @@ discard block |
||
| 995 | 995 | $date_array = array(); |
| 996 | 996 | $temp_array = array(); |
| 997 | 997 | |
| 998 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 998 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 999 | 999 | { |
| 1000 | 1000 | $temp_array['date_name'] = $row['date_name']; |
| 1001 | 1001 | $temp_array['date_count'] = $row['date_count']; |
@@ -1020,7 +1020,7 @@ discard block |
||
| 1020 | 1020 | $datetime = new DateTime(); |
| 1021 | 1021 | $offset = $datetime->format('P'); |
| 1022 | 1022 | } else $offset = '+00:00'; |
| 1023 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1023 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1024 | 1024 | if ($globalDBdriver == 'mysql') { |
| 1025 | 1025 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
| 1026 | 1026 | FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MONTH)"; |
@@ -1041,7 +1041,7 @@ discard block |
||
| 1041 | 1041 | $date_array = array(); |
| 1042 | 1042 | $temp_array = array(); |
| 1043 | 1043 | |
| 1044 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1044 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1045 | 1045 | { |
| 1046 | 1046 | $temp_array['date_name'] = $row['date_name']; |
| 1047 | 1047 | $temp_array['date_count'] = $row['date_count']; |
@@ -1088,7 +1088,7 @@ discard block |
||
| 1088 | 1088 | $date_array = array(); |
| 1089 | 1089 | $temp_array = array(); |
| 1090 | 1090 | |
| 1091 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1091 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1092 | 1092 | { |
| 1093 | 1093 | $temp_array['month_name'] = $row['month_name']; |
| 1094 | 1094 | $temp_array['year_name'] = $row['year_name']; |
@@ -1117,7 +1117,7 @@ discard block |
||
| 1117 | 1117 | $datetime = new DateTime(); |
| 1118 | 1118 | $offset = $datetime->format('P'); |
| 1119 | 1119 | } else $offset = '+00:00'; |
| 1120 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1120 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1121 | 1121 | if ($globalDBdriver == 'mysql') { |
| 1122 | 1122 | $query = "SELECT MONTH(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count |
| 1123 | 1123 | FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 YEAR)"; |
@@ -1138,7 +1138,7 @@ discard block |
||
| 1138 | 1138 | $date_array = array(); |
| 1139 | 1139 | $temp_array = array(); |
| 1140 | 1140 | |
| 1141 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1141 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1142 | 1142 | { |
| 1143 | 1143 | $temp_array['year_name'] = $row['year_name']; |
| 1144 | 1144 | $temp_array['month_name'] = $row['month_name']; |
@@ -1158,7 +1158,7 @@ discard block |
||
| 1158 | 1158 | * @return Array the hour list |
| 1159 | 1159 | * |
| 1160 | 1160 | */ |
| 1161 | - public function countAllHours($orderby,$filters = array()) |
|
| 1161 | + public function countAllHours($orderby, $filters = array()) |
|
| 1162 | 1162 | { |
| 1163 | 1163 | global $globalTimezone, $globalDBdriver; |
| 1164 | 1164 | if ($globalTimezone != '') { |
@@ -1206,7 +1206,7 @@ discard block |
||
| 1206 | 1206 | $hour_array = array(); |
| 1207 | 1207 | $temp_array = array(); |
| 1208 | 1208 | |
| 1209 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1209 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1210 | 1210 | { |
| 1211 | 1211 | $temp_array['hour_name'] = $row['hour_name']; |
| 1212 | 1212 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1228,8 +1228,8 @@ discard block |
||
| 1228 | 1228 | public function countAllHoursByDate($date, $filters = array()) |
| 1229 | 1229 | { |
| 1230 | 1230 | global $globalTimezone, $globalDBdriver; |
| 1231 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1232 | - $date = filter_var($date,FILTER_SANITIZE_STRING); |
|
| 1231 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1232 | + $date = filter_var($date, FILTER_SANITIZE_STRING); |
|
| 1233 | 1233 | if ($globalTimezone != '') { |
| 1234 | 1234 | date_default_timezone_set($globalTimezone); |
| 1235 | 1235 | $datetime = new DateTime($date); |
@@ -1237,12 +1237,12 @@ discard block |
||
| 1237 | 1237 | } else $offset = '+00:00'; |
| 1238 | 1238 | |
| 1239 | 1239 | if ($globalDBdriver == 'mysql') { |
| 1240 | - $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 1240 | + $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 1241 | 1241 | FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = :date |
| 1242 | 1242 | GROUP BY hour_name |
| 1243 | 1243 | ORDER BY hour_name ASC"; |
| 1244 | 1244 | } else { |
| 1245 | - $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1245 | + $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1246 | 1246 | FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset, 'YYYY-mm-dd') = :date |
| 1247 | 1247 | GROUP BY hour_name |
| 1248 | 1248 | ORDER BY hour_name ASC"; |
@@ -1254,7 +1254,7 @@ discard block |
||
| 1254 | 1254 | $hour_array = array(); |
| 1255 | 1255 | $temp_array = array(); |
| 1256 | 1256 | |
| 1257 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1257 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1258 | 1258 | { |
| 1259 | 1259 | $temp_array['hour_name'] = $row['hour_name']; |
| 1260 | 1260 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1276,8 +1276,8 @@ discard block |
||
| 1276 | 1276 | public function countAllHoursByIdent($ident, $filters = array()) |
| 1277 | 1277 | { |
| 1278 | 1278 | global $globalTimezone, $globalDBdriver; |
| 1279 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1280 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
| 1279 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1280 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 1281 | 1281 | if ($globalTimezone != '') { |
| 1282 | 1282 | date_default_timezone_set($globalTimezone); |
| 1283 | 1283 | $datetime = new DateTime(); |
@@ -1285,12 +1285,12 @@ discard block |
||
| 1285 | 1285 | } else $offset = '+00:00'; |
| 1286 | 1286 | |
| 1287 | 1287 | if ($globalDBdriver == 'mysql') { |
| 1288 | - $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 1288 | + $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 1289 | 1289 | FROM marine_output".$filter_query." marine_output.ident = :ident |
| 1290 | 1290 | GROUP BY hour_name |
| 1291 | 1291 | ORDER BY hour_name ASC"; |
| 1292 | 1292 | } else { |
| 1293 | - $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1293 | + $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1294 | 1294 | FROM marine_output".$filter_query." marine_output.ident = :ident |
| 1295 | 1295 | GROUP BY hour_name |
| 1296 | 1296 | ORDER BY hour_name ASC"; |
@@ -1298,12 +1298,12 @@ discard block |
||
| 1298 | 1298 | |
| 1299 | 1299 | |
| 1300 | 1300 | $sth = $this->db->prepare($query); |
| 1301 | - $sth->execute(array(':ident' => $ident,':offset' => $offset)); |
|
| 1301 | + $sth->execute(array(':ident' => $ident, ':offset' => $offset)); |
|
| 1302 | 1302 | |
| 1303 | 1303 | $hour_array = array(); |
| 1304 | 1304 | $temp_array = array(); |
| 1305 | 1305 | |
| 1306 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1306 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1307 | 1307 | { |
| 1308 | 1308 | $temp_array['hour_name'] = $row['hour_name']; |
| 1309 | 1309 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1322,32 +1322,32 @@ discard block |
||
| 1322 | 1322 | * @return Integer the number of flights |
| 1323 | 1323 | * |
| 1324 | 1324 | */ |
| 1325 | - public function countOverallTracked($filters = array(),$year = '',$month = '') |
|
| 1325 | + public function countOverallTracked($filters = array(), $year = '', $month = '') |
|
| 1326 | 1326 | { |
| 1327 | 1327 | global $globalDBdriver; |
| 1328 | - $queryi = "SELECT COUNT(marine_output.marine_id) AS flight_count FROM marine_output"; |
|
| 1328 | + $queryi = "SELECT COUNT(marine_output.marine_id) AS flight_count FROM marine_output"; |
|
| 1329 | 1329 | $query_values = array(); |
| 1330 | 1330 | $query = ''; |
| 1331 | 1331 | if ($year != '') { |
| 1332 | 1332 | if ($globalDBdriver == 'mysql') { |
| 1333 | 1333 | $query .= " AND YEAR(marine_output.date) = :year"; |
| 1334 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 1334 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 1335 | 1335 | } else { |
| 1336 | 1336 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
| 1337 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 1337 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 1338 | 1338 | } |
| 1339 | 1339 | } |
| 1340 | 1340 | if ($month != '') { |
| 1341 | 1341 | if ($globalDBdriver == 'mysql') { |
| 1342 | 1342 | $query .= " AND MONTH(marine_output.date) = :month"; |
| 1343 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 1343 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 1344 | 1344 | } else { |
| 1345 | 1345 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
| 1346 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 1346 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 1347 | 1347 | } |
| 1348 | 1348 | } |
| 1349 | 1349 | if (empty($query_values)) $queryi .= $this->getFilter($filters); |
| 1350 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
| 1350 | + else $queryi .= $this->getFilter($filters, true, true).substr($query, 4); |
|
| 1351 | 1351 | |
| 1352 | 1352 | $sth = $this->db->prepare($queryi); |
| 1353 | 1353 | $sth->execute($query_values); |
@@ -1364,7 +1364,7 @@ discard block |
||
| 1364 | 1364 | public function countAllHoursFromToday($filters = array()) |
| 1365 | 1365 | { |
| 1366 | 1366 | global $globalTimezone, $globalDBdriver; |
| 1367 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1367 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1368 | 1368 | if ($globalTimezone != '') { |
| 1369 | 1369 | date_default_timezone_set($globalTimezone); |
| 1370 | 1370 | $datetime = new DateTime(); |
@@ -1372,12 +1372,12 @@ discard block |
||
| 1372 | 1372 | } else $offset = '+00:00'; |
| 1373 | 1373 | |
| 1374 | 1374 | if ($globalDBdriver == 'mysql') { |
| 1375 | - $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 1375 | + $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 1376 | 1376 | FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = CURDATE() |
| 1377 | 1377 | GROUP BY hour_name |
| 1378 | 1378 | ORDER BY hour_name ASC"; |
| 1379 | 1379 | } else { |
| 1380 | - $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1380 | + $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1381 | 1381 | FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = CAST(NOW() AS date) |
| 1382 | 1382 | GROUP BY hour_name |
| 1383 | 1383 | ORDER BY hour_name ASC"; |
@@ -1389,7 +1389,7 @@ discard block |
||
| 1389 | 1389 | $hour_array = array(); |
| 1390 | 1390 | $temp_array = array(); |
| 1391 | 1391 | |
| 1392 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1392 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1393 | 1393 | { |
| 1394 | 1394 | $temp_array['hour_name'] = $row['hour_name']; |
| 1395 | 1395 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1408,9 +1408,9 @@ discard block |
||
| 1408 | 1408 | */ |
| 1409 | 1409 | public function getMarineIDBasedOnFamMarineID($fammarine_id) |
| 1410 | 1410 | { |
| 1411 | - $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
|
| 1411 | + $fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING); |
|
| 1412 | 1412 | |
| 1413 | - $query = "SELECT marine_output.marine_id |
|
| 1413 | + $query = "SELECT marine_output.marine_id |
|
| 1414 | 1414 | FROM marine_output |
| 1415 | 1415 | WHERE marine_output.fammarine_id = '".$fammarine_id."'"; |
| 1416 | 1416 | |
@@ -1418,7 +1418,7 @@ discard block |
||
| 1418 | 1418 | $sth = $this->db->prepare($query); |
| 1419 | 1419 | $sth->execute(); |
| 1420 | 1420 | |
| 1421 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1421 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1422 | 1422 | { |
| 1423 | 1423 | return $row['marine_id']; |
| 1424 | 1424 | } |
@@ -1443,23 +1443,23 @@ discard block |
||
| 1443 | 1443 | } |
| 1444 | 1444 | |
| 1445 | 1445 | $current_date = date("Y-m-d H:i:s"); |
| 1446 | - $date = date("Y-m-d H:i:s",strtotime($dateString." UTC")); |
|
| 1446 | + $date = date("Y-m-d H:i:s", strtotime($dateString." UTC")); |
|
| 1447 | 1447 | |
| 1448 | 1448 | $diff = abs(strtotime($current_date) - strtotime($date)); |
| 1449 | 1449 | |
| 1450 | - $time_array['years'] = floor($diff / (365*60*60*24)); |
|
| 1450 | + $time_array['years'] = floor($diff/(365*60*60*24)); |
|
| 1451 | 1451 | $years = $time_array['years']; |
| 1452 | 1452 | |
| 1453 | - $time_array['months'] = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); |
|
| 1453 | + $time_array['months'] = floor(($diff - $years*365*60*60*24)/(30*60*60*24)); |
|
| 1454 | 1454 | $months = $time_array['months']; |
| 1455 | 1455 | |
| 1456 | - $time_array['days'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); |
|
| 1456 | + $time_array['days'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24)/(60*60*24)); |
|
| 1457 | 1457 | $days = $time_array['days']; |
| 1458 | - $time_array['hours'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/ (60*60)); |
|
| 1458 | + $time_array['hours'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/(60*60)); |
|
| 1459 | 1459 | $hours = $time_array['hours']; |
| 1460 | - $time_array['minutes'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/ 60); |
|
| 1460 | + $time_array['minutes'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/60); |
|
| 1461 | 1461 | $minutes = $time_array['minutes']; |
| 1462 | - $time_array['seconds'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60)); |
|
| 1462 | + $time_array['seconds'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60)); |
|
| 1463 | 1463 | |
| 1464 | 1464 | return $time_array; |
| 1465 | 1465 | } |
@@ -1482,63 +1482,63 @@ discard block |
||
| 1482 | 1482 | $temp_array['direction_degree'] = $direction; |
| 1483 | 1483 | $temp_array['direction_shortname'] = "N"; |
| 1484 | 1484 | $temp_array['direction_fullname'] = "North"; |
| 1485 | - } elseif ($direction >= 22.5 && $direction < 45){ |
|
| 1485 | + } elseif ($direction >= 22.5 && $direction < 45) { |
|
| 1486 | 1486 | $temp_array['direction_degree'] = $direction; |
| 1487 | 1487 | $temp_array['direction_shortname'] = "NNE"; |
| 1488 | 1488 | $temp_array['direction_fullname'] = "North-Northeast"; |
| 1489 | - } elseif ($direction >= 45 && $direction < 67.5){ |
|
| 1489 | + } elseif ($direction >= 45 && $direction < 67.5) { |
|
| 1490 | 1490 | $temp_array['direction_degree'] = $direction; |
| 1491 | 1491 | $temp_array['direction_shortname'] = "NE"; |
| 1492 | 1492 | $temp_array['direction_fullname'] = "Northeast"; |
| 1493 | - } elseif ($direction >= 67.5 && $direction < 90){ |
|
| 1493 | + } elseif ($direction >= 67.5 && $direction < 90) { |
|
| 1494 | 1494 | $temp_array['direction_degree'] = $direction; |
| 1495 | 1495 | $temp_array['direction_shortname'] = "ENE"; |
| 1496 | 1496 | $temp_array['direction_fullname'] = "East-Northeast"; |
| 1497 | - } elseif ($direction >= 90 && $direction < 112.5){ |
|
| 1497 | + } elseif ($direction >= 90 && $direction < 112.5) { |
|
| 1498 | 1498 | $temp_array['direction_degree'] = $direction; |
| 1499 | 1499 | $temp_array['direction_shortname'] = "E"; |
| 1500 | 1500 | $temp_array['direction_fullname'] = "East"; |
| 1501 | - } elseif ($direction >= 112.5 && $direction < 135){ |
|
| 1501 | + } elseif ($direction >= 112.5 && $direction < 135) { |
|
| 1502 | 1502 | $temp_array['direction_degree'] = $direction; |
| 1503 | 1503 | $temp_array['direction_shortname'] = "ESE"; |
| 1504 | 1504 | $temp_array['direction_fullname'] = "East-Southeast"; |
| 1505 | - } elseif ($direction >= 135 && $direction < 157.5){ |
|
| 1505 | + } elseif ($direction >= 135 && $direction < 157.5) { |
|
| 1506 | 1506 | $temp_array['direction_degree'] = $direction; |
| 1507 | 1507 | $temp_array['direction_shortname'] = "SE"; |
| 1508 | 1508 | $temp_array['direction_fullname'] = "Southeast"; |
| 1509 | - } elseif ($direction >= 157.5 && $direction < 180){ |
|
| 1509 | + } elseif ($direction >= 157.5 && $direction < 180) { |
|
| 1510 | 1510 | $temp_array['direction_degree'] = $direction; |
| 1511 | 1511 | $temp_array['direction_shortname'] = "SSE"; |
| 1512 | 1512 | $temp_array['direction_fullname'] = "South-Southeast"; |
| 1513 | - } elseif ($direction >= 180 && $direction < 202.5){ |
|
| 1513 | + } elseif ($direction >= 180 && $direction < 202.5) { |
|
| 1514 | 1514 | $temp_array['direction_degree'] = $direction; |
| 1515 | 1515 | $temp_array['direction_shortname'] = "S"; |
| 1516 | 1516 | $temp_array['direction_fullname'] = "South"; |
| 1517 | - } elseif ($direction >= 202.5 && $direction < 225){ |
|
| 1517 | + } elseif ($direction >= 202.5 && $direction < 225) { |
|
| 1518 | 1518 | $temp_array['direction_degree'] = $direction; |
| 1519 | 1519 | $temp_array['direction_shortname'] = "SSW"; |
| 1520 | 1520 | $temp_array['direction_fullname'] = "South-Southwest"; |
| 1521 | - } elseif ($direction >= 225 && $direction < 247.5){ |
|
| 1521 | + } elseif ($direction >= 225 && $direction < 247.5) { |
|
| 1522 | 1522 | $temp_array['direction_degree'] = $direction; |
| 1523 | 1523 | $temp_array['direction_shortname'] = "SW"; |
| 1524 | 1524 | $temp_array['direction_fullname'] = "Southwest"; |
| 1525 | - } elseif ($direction >= 247.5 && $direction < 270){ |
|
| 1525 | + } elseif ($direction >= 247.5 && $direction < 270) { |
|
| 1526 | 1526 | $temp_array['direction_degree'] = $direction; |
| 1527 | 1527 | $temp_array['direction_shortname'] = "WSW"; |
| 1528 | 1528 | $temp_array['direction_fullname'] = "West-Southwest"; |
| 1529 | - } elseif ($direction >= 270 && $direction < 292.5){ |
|
| 1529 | + } elseif ($direction >= 270 && $direction < 292.5) { |
|
| 1530 | 1530 | $temp_array['direction_degree'] = $direction; |
| 1531 | 1531 | $temp_array['direction_shortname'] = "W"; |
| 1532 | 1532 | $temp_array['direction_fullname'] = "West"; |
| 1533 | - } elseif ($direction >= 292.5 && $direction < 315){ |
|
| 1533 | + } elseif ($direction >= 292.5 && $direction < 315) { |
|
| 1534 | 1534 | $temp_array['direction_degree'] = $direction; |
| 1535 | 1535 | $temp_array['direction_shortname'] = "WNW"; |
| 1536 | 1536 | $temp_array['direction_fullname'] = "West-Northwest"; |
| 1537 | - } elseif ($direction >= 315 && $direction < 337.5){ |
|
| 1537 | + } elseif ($direction >= 315 && $direction < 337.5) { |
|
| 1538 | 1538 | $temp_array['direction_degree'] = $direction; |
| 1539 | 1539 | $temp_array['direction_shortname'] = "NW"; |
| 1540 | 1540 | $temp_array['direction_fullname'] = "Northwest"; |
| 1541 | - } elseif ($direction >= 337.5 && $direction < 360){ |
|
| 1541 | + } elseif ($direction >= 337.5 && $direction < 360) { |
|
| 1542 | 1542 | $temp_array['direction_degree'] = $direction; |
| 1543 | 1543 | $temp_array['direction_shortname'] = "NNW"; |
| 1544 | 1544 | $temp_array['direction_fullname'] = "North-Northwest"; |
@@ -1555,11 +1555,11 @@ discard block |
||
| 1555 | 1555 | * @param Float $longitude longitute of the flight |
| 1556 | 1556 | * @return String the countrie |
| 1557 | 1557 | */ |
| 1558 | - public function getCountryFromLatitudeLongitude($latitude,$longitude) |
|
| 1558 | + public function getCountryFromLatitudeLongitude($latitude, $longitude) |
|
| 1559 | 1559 | { |
| 1560 | 1560 | global $globalDBdriver, $globalDebug; |
| 1561 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1562 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1561 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1562 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1563 | 1563 | |
| 1564 | 1564 | $Connection = new Connection($this->db); |
| 1565 | 1565 | if (!$Connection->tableExists('countries')) return ''; |
@@ -1599,7 +1599,7 @@ discard block |
||
| 1599 | 1599 | public function getCountryFromISO2($iso2) |
| 1600 | 1600 | { |
| 1601 | 1601 | global $globalDBdriver, $globalDebug; |
| 1602 | - $iso2 = filter_var($iso2,FILTER_SANITIZE_STRING); |
|
| 1602 | + $iso2 = filter_var($iso2, FILTER_SANITIZE_STRING); |
|
| 1603 | 1603 | |
| 1604 | 1604 | $Connection = new Connection($this->db); |
| 1605 | 1605 | if (!$Connection->tableExists('countries')) return ''; |
@@ -1647,7 +1647,7 @@ discard block |
||
| 1647 | 1647 | |
| 1648 | 1648 | $bitly_data = json_decode($bitly_data); |
| 1649 | 1649 | $bitly_url = ''; |
| 1650 | - if ($bitly_data->status_txt = "OK"){ |
|
| 1650 | + if ($bitly_data->status_txt = "OK") { |
|
| 1651 | 1651 | $bitly_url = $bitly_data->data->url; |
| 1652 | 1652 | } |
| 1653 | 1653 | |
@@ -1657,7 +1657,7 @@ discard block |
||
| 1657 | 1657 | |
| 1658 | 1658 | public function getOrderBy() |
| 1659 | 1659 | { |
| 1660 | - $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY marine_output.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY marine_output.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_output.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_output.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_output.date DESC"),"distance_asc" => array("key" => "distance_asc","value" => "Distance - ASC","sql" => "ORDER BY distance ASC"),"distance_desc" => array("key" => "distance_desc","value" => "Distance - DESC","sql" => "ORDER BY distance DESC")); |
|
| 1660 | + $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY marine_output.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY marine_output.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_output.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_output.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_output.date DESC"), "distance_asc" => array("key" => "distance_asc", "value" => "Distance - ASC", "sql" => "ORDER BY distance ASC"), "distance_desc" => array("key" => "distance_desc", "value" => "Distance - DESC", "sql" => "ORDER BY distance DESC")); |
|
| 1661 | 1661 | |
| 1662 | 1662 | return $orderby; |
| 1663 | 1663 | |
@@ -29,7 +29,9 @@ discard block |
||
| 29 | 29 | if (isset($filter[0]['source'])) { |
| 30 | 30 | $filters = array_merge($filters,$filter); |
| 31 | 31 | } |
| 32 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 32 | + if (is_array($globalFilter)) { |
|
| 33 | + $filter = array_merge($filter,$globalFilter); |
|
| 34 | + } |
|
| 33 | 35 | $filter_query_join = ''; |
| 34 | 36 | $filter_query_where = ''; |
| 35 | 37 | foreach($filters as $flt) { |
@@ -68,8 +70,11 @@ discard block |
||
| 68 | 70 | $filter_query_where .= " AND EXTRACT(DAY FROM marine_output.date) = '".$filter['day']."'"; |
| 69 | 71 | } |
| 70 | 72 | } |
| 71 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
| 72 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
| 73 | + if ($filter_query_where == '' && $where) { |
|
| 74 | + $filter_query_where = ' WHERE'; |
|
| 75 | + } elseif ($filter_query_where != '' && $and) { |
|
| 76 | + $filter_query_where .= ' AND'; |
|
| 77 | + } |
|
| 73 | 78 | if ($filter_query_where != '') { |
| 74 | 79 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
| 75 | 80 | } |
@@ -123,32 +128,54 @@ discard block |
||
| 123 | 128 | $temp_array['spotter_id'] = $row['spotter_archive_id']; |
| 124 | 129 | } elseif (isset($row['spotter_archive_output_id'])) { |
| 125 | 130 | $temp_array['spotter_id'] = $row['spotter_archive_output_id']; |
| 126 | - */} |
|
| 127 | - elseif (isset($row['marineid'])) { |
|
| 131 | + */} elseif (isset($row['marineid'])) { |
|
| 128 | 132 | $temp_array['marineid'] = $row['marineid']; |
| 129 | 133 | } else { |
| 130 | 134 | $temp_array['marineid'] = ''; |
| 131 | 135 | } |
| 132 | - if (isset($row['fammarine_id'])) $temp_array['fammarine_id'] = $row['fammarine_id']; |
|
| 133 | - if (isset($row['mmsi'])) $temp_array['mmsi'] = $row['mmsi']; |
|
| 134 | - if (isset($row['type'])) $temp_array['type'] = $row['type']; |
|
| 135 | - if (isset($row['type_id'])) $temp_array['type_id'] = $row['type_id']; |
|
| 136 | - if (isset($row['ident'])) $temp_array['ident'] = $row['ident']; |
|
| 137 | - if (isset($row['latitude'])) $temp_array['latitude'] = $row['latitude']; |
|
| 138 | - if (isset($row['longitude'])) $temp_array['longitude'] = $row['longitude']; |
|
| 139 | - if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source']; |
|
| 136 | + if (isset($row['fammarine_id'])) { |
|
| 137 | + $temp_array['fammarine_id'] = $row['fammarine_id']; |
|
| 138 | + } |
|
| 139 | + if (isset($row['mmsi'])) { |
|
| 140 | + $temp_array['mmsi'] = $row['mmsi']; |
|
| 141 | + } |
|
| 142 | + if (isset($row['type'])) { |
|
| 143 | + $temp_array['type'] = $row['type']; |
|
| 144 | + } |
|
| 145 | + if (isset($row['type_id'])) { |
|
| 146 | + $temp_array['type_id'] = $row['type_id']; |
|
| 147 | + } |
|
| 148 | + if (isset($row['ident'])) { |
|
| 149 | + $temp_array['ident'] = $row['ident']; |
|
| 150 | + } |
|
| 151 | + if (isset($row['latitude'])) { |
|
| 152 | + $temp_array['latitude'] = $row['latitude']; |
|
| 153 | + } |
|
| 154 | + if (isset($row['longitude'])) { |
|
| 155 | + $temp_array['longitude'] = $row['longitude']; |
|
| 156 | + } |
|
| 157 | + if (isset($row['format_source'])) { |
|
| 158 | + $temp_array['format_source'] = $row['format_source']; |
|
| 159 | + } |
|
| 140 | 160 | if (isset($row['heading'])) { |
| 141 | 161 | $temp_array['heading'] = $row['heading']; |
| 142 | 162 | $heading_direction = $this->parseDirection($row['heading']); |
| 143 | - if (isset($heading_direction[0]['direction_fullname'])) $temp_array['heading_name'] = $heading_direction[0]['direction_fullname']; |
|
| 163 | + if (isset($heading_direction[0]['direction_fullname'])) { |
|
| 164 | + $temp_array['heading_name'] = $heading_direction[0]['direction_fullname']; |
|
| 165 | + } |
|
| 166 | + } |
|
| 167 | + if (isset($row['ground_speed'])) { |
|
| 168 | + $temp_array['ground_speed'] = $row['ground_speed']; |
|
| 144 | 169 | } |
| 145 | - if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed']; |
|
| 146 | 170 | |
| 147 | 171 | if($temp_array['mmsi'] != "" && isset($globalMarineImageFetch) && $globalMarineImageFetch === TRUE) |
| 148 | 172 | { |
| 149 | 173 | $Image = new Image($this->db); |
| 150 | - if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']); |
|
| 151 | - else $image_array = $Image->getMarineImage($temp_array['mmsi']); |
|
| 174 | + if (isset($temp_array['ident']) && $temp_array['ident'] != '') { |
|
| 175 | + $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']); |
|
| 176 | + } else { |
|
| 177 | + $image_array = $Image->getMarineImage($temp_array['mmsi']); |
|
| 178 | + } |
|
| 152 | 179 | unset($Image); |
| 153 | 180 | if (count($image_array) > 0) { |
| 154 | 181 | $temp_array['image'] = $image_array[0]['image']; |
@@ -200,13 +227,21 @@ discard block |
||
| 200 | 227 | } |
| 201 | 228 | |
| 202 | 229 | $fromsource = NULL; |
| 203 | - if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name']; |
|
| 204 | - if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country']; |
|
| 205 | - if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance']; |
|
| 230 | + if (isset($row['source_name']) && $row['source_name'] != '') { |
|
| 231 | + $temp_array['source_name'] = $row['source_name']; |
|
| 232 | + } |
|
| 233 | + if (isset($row['over_country']) && $row['over_country'] != '') { |
|
| 234 | + $temp_array['over_country'] = $row['over_country']; |
|
| 235 | + } |
|
| 236 | + if (isset($row['distance']) && $row['distance'] != '') { |
|
| 237 | + $temp_array['distance'] = $row['distance']; |
|
| 238 | + } |
|
| 206 | 239 | $temp_array['query_number_rows'] = $num_rows; |
| 207 | 240 | $spotter_array[] = $temp_array; |
| 208 | 241 | } |
| 209 | - if ($num_rows == 0) return array(); |
|
| 242 | + if ($num_rows == 0) { |
|
| 243 | + return array(); |
|
| 244 | + } |
|
| 210 | 245 | $spotter_array[0]['query_number_rows'] = $num_rows; |
| 211 | 246 | return $spotter_array; |
| 212 | 247 | } |
@@ -237,8 +272,12 @@ discard block |
||
| 237 | 272 | { |
| 238 | 273 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
| 239 | 274 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
| 240 | - } else $limit_query = ""; |
|
| 241 | - } else $limit_query = ""; |
|
| 275 | + } else { |
|
| 276 | + $limit_query = ""; |
|
| 277 | + } |
|
| 278 | + } else { |
|
| 279 | + $limit_query = ""; |
|
| 280 | + } |
|
| 242 | 281 | |
| 243 | 282 | if ($sort != "") |
| 244 | 283 | { |
@@ -266,7 +305,9 @@ discard block |
||
| 266 | 305 | global $global_query; |
| 267 | 306 | |
| 268 | 307 | date_default_timezone_set('UTC'); |
| 269 | - if ($id == '') return array(); |
|
| 308 | + if ($id == '') { |
|
| 309 | + return array(); |
|
| 310 | + } |
|
| 270 | 311 | $additional_query = "marine_output.fammarine_id = :id"; |
| 271 | 312 | $query_values = array(':id' => $id); |
| 272 | 313 | $query = $global_query." WHERE ".$additional_query." "; |
@@ -409,8 +450,11 @@ discard block |
||
| 409 | 450 | $query .= " ORDER BY marine_output.source_name ASC"; |
| 410 | 451 | |
| 411 | 452 | $sth = $this->db->prepare($query); |
| 412 | - if (!empty($query_values)) $sth->execute($query_values); |
|
| 413 | - else $sth->execute(); |
|
| 453 | + if (!empty($query_values)) { |
|
| 454 | + $sth->execute($query_values); |
|
| 455 | + } else { |
|
| 456 | + $sth->execute(); |
|
| 457 | + } |
|
| 414 | 458 | |
| 415 | 459 | $source_array = array(); |
| 416 | 460 | $temp_array = array(); |
@@ -465,8 +509,11 @@ discard block |
||
| 465 | 509 | $sth = $this->db->prepare($query); |
| 466 | 510 | $sth->execute(array(':mmsi' => $mmsi)); |
| 467 | 511 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 468 | - if (isset($result[0])) return $result[0]; |
|
| 469 | - else return array(); |
|
| 512 | + if (isset($result[0])) { |
|
| 513 | + return $result[0]; |
|
| 514 | + } else { |
|
| 515 | + return array(); |
|
| 516 | + } |
|
| 470 | 517 | } |
| 471 | 518 | |
| 472 | 519 | /* |
@@ -482,7 +529,9 @@ discard block |
||
| 482 | 529 | date_default_timezone_set($globalTimezone); |
| 483 | 530 | $datetime = new DateTime(); |
| 484 | 531 | $offset = $datetime->format('P'); |
| 485 | - } else $offset = '+00:00'; |
|
| 532 | + } else { |
|
| 533 | + $offset = '+00:00'; |
|
| 534 | + } |
|
| 486 | 535 | |
| 487 | 536 | if ($globalDBdriver == 'mysql') { |
| 488 | 537 | $query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date |
@@ -686,9 +735,15 @@ discard block |
||
| 686 | 735 | $latitude = 0; |
| 687 | 736 | $longitude = 0; |
| 688 | 737 | } |
| 689 | - if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
| 690 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
| 691 | - if ($arrival_date == '') $arrival_date = NULL; |
|
| 738 | + if ($heading == '' || $Common->isInteger($heading) === false) { |
|
| 739 | + $heading = 0; |
|
| 740 | + } |
|
| 741 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) { |
|
| 742 | + $groundspeed = 0; |
|
| 743 | + } |
|
| 744 | + if ($arrival_date == '') { |
|
| 745 | + $arrival_date = NULL; |
|
| 746 | + } |
|
| 692 | 747 | $query = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, status,imo,arrival_port_name,arrival_port_date) |
| 693 | 748 | VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)"; |
| 694 | 749 | |
@@ -852,12 +907,18 @@ discard block |
||
| 852 | 907 | $query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count |
| 853 | 908 | FROM marine_output".$filter_query." marine_output.ident <> ''"; |
| 854 | 909 | if ($olderthanmonths > 0) { |
| 855 | - if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
|
| 856 | - else $query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
| 910 | + if ($globalDBdriver == 'mysql') { |
|
| 911 | + $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
|
| 912 | + } else { |
|
| 913 | + $query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
| 914 | + } |
|
| 857 | 915 | } |
| 858 | 916 | if ($sincedate != '') { |
| 859 | - if ($globalDBdriver == 'mysql') $query .= " AND marine_output.date > '".$sincedate."'"; |
|
| 860 | - else $query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
| 917 | + if ($globalDBdriver == 'mysql') { |
|
| 918 | + $query .= " AND marine_output.date > '".$sincedate."'"; |
|
| 919 | + } else { |
|
| 920 | + $query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
| 921 | + } |
|
| 861 | 922 | } |
| 862 | 923 | $query_values = array(); |
| 863 | 924 | if ($year != '') { |
@@ -888,7 +949,9 @@ discard block |
||
| 888 | 949 | } |
| 889 | 950 | } |
| 890 | 951 | $query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC"; |
| 891 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
| 952 | + if ($limit) { |
|
| 953 | + $query .= " LIMIT 10 OFFSET 0"; |
|
| 954 | + } |
|
| 892 | 955 | |
| 893 | 956 | $sth = $this->db->prepare($query); |
| 894 | 957 | $sth->execute($query_values); |
@@ -923,7 +986,9 @@ discard block |
||
| 923 | 986 | date_default_timezone_set($globalTimezone); |
| 924 | 987 | $datetime = new DateTime(); |
| 925 | 988 | $offset = $datetime->format('P'); |
| 926 | - } else $offset = '+00:00'; |
|
| 989 | + } else { |
|
| 990 | + $offset = '+00:00'; |
|
| 991 | + } |
|
| 927 | 992 | |
| 928 | 993 | if ($globalDBdriver == 'mysql') { |
| 929 | 994 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -973,7 +1038,9 @@ discard block |
||
| 973 | 1038 | date_default_timezone_set($globalTimezone); |
| 974 | 1039 | $datetime = new DateTime(); |
| 975 | 1040 | $offset = $datetime->format('P'); |
| 976 | - } else $offset = '+00:00'; |
|
| 1041 | + } else { |
|
| 1042 | + $offset = '+00:00'; |
|
| 1043 | + } |
|
| 977 | 1044 | $filter_query = $this->getFilter($filters,true,true); |
| 978 | 1045 | if ($globalDBdriver == 'mysql') { |
| 979 | 1046 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -1019,7 +1086,9 @@ discard block |
||
| 1019 | 1086 | date_default_timezone_set($globalTimezone); |
| 1020 | 1087 | $datetime = new DateTime(); |
| 1021 | 1088 | $offset = $datetime->format('P'); |
| 1022 | - } else $offset = '+00:00'; |
|
| 1089 | + } else { |
|
| 1090 | + $offset = '+00:00'; |
|
| 1091 | + } |
|
| 1023 | 1092 | $filter_query = $this->getFilter($filters,true,true); |
| 1024 | 1093 | if ($globalDBdriver == 'mysql') { |
| 1025 | 1094 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -1067,7 +1136,9 @@ discard block |
||
| 1067 | 1136 | date_default_timezone_set($globalTimezone); |
| 1068 | 1137 | $datetime = new DateTime(); |
| 1069 | 1138 | $offset = $datetime->format('P'); |
| 1070 | - } else $offset = '+00:00'; |
|
| 1139 | + } else { |
|
| 1140 | + $offset = '+00:00'; |
|
| 1141 | + } |
|
| 1071 | 1142 | |
| 1072 | 1143 | if ($globalDBdriver == 'mysql') { |
| 1073 | 1144 | $query = "SELECT YEAR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count |
@@ -1116,7 +1187,9 @@ discard block |
||
| 1116 | 1187 | date_default_timezone_set($globalTimezone); |
| 1117 | 1188 | $datetime = new DateTime(); |
| 1118 | 1189 | $offset = $datetime->format('P'); |
| 1119 | - } else $offset = '+00:00'; |
|
| 1190 | + } else { |
|
| 1191 | + $offset = '+00:00'; |
|
| 1192 | + } |
|
| 1120 | 1193 | $filter_query = $this->getFilter($filters,true,true); |
| 1121 | 1194 | if ($globalDBdriver == 'mysql') { |
| 1122 | 1195 | $query = "SELECT MONTH(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count |
@@ -1165,7 +1238,9 @@ discard block |
||
| 1165 | 1238 | date_default_timezone_set($globalTimezone); |
| 1166 | 1239 | $datetime = new DateTime(); |
| 1167 | 1240 | $offset = $datetime->format('P'); |
| 1168 | - } else $offset = '+00:00'; |
|
| 1241 | + } else { |
|
| 1242 | + $offset = '+00:00'; |
|
| 1243 | + } |
|
| 1169 | 1244 | |
| 1170 | 1245 | $orderby_sql = ''; |
| 1171 | 1246 | if ($orderby == "hour") |
@@ -1234,7 +1309,9 @@ discard block |
||
| 1234 | 1309 | date_default_timezone_set($globalTimezone); |
| 1235 | 1310 | $datetime = new DateTime($date); |
| 1236 | 1311 | $offset = $datetime->format('P'); |
| 1237 | - } else $offset = '+00:00'; |
|
| 1312 | + } else { |
|
| 1313 | + $offset = '+00:00'; |
|
| 1314 | + } |
|
| 1238 | 1315 | |
| 1239 | 1316 | if ($globalDBdriver == 'mysql') { |
| 1240 | 1317 | $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1282,7 +1359,9 @@ discard block |
||
| 1282 | 1359 | date_default_timezone_set($globalTimezone); |
| 1283 | 1360 | $datetime = new DateTime(); |
| 1284 | 1361 | $offset = $datetime->format('P'); |
| 1285 | - } else $offset = '+00:00'; |
|
| 1362 | + } else { |
|
| 1363 | + $offset = '+00:00'; |
|
| 1364 | + } |
|
| 1286 | 1365 | |
| 1287 | 1366 | if ($globalDBdriver == 'mysql') { |
| 1288 | 1367 | $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1346,8 +1425,11 @@ discard block |
||
| 1346 | 1425 | $query_values = array_merge($query_values,array(':month' => $month)); |
| 1347 | 1426 | } |
| 1348 | 1427 | } |
| 1349 | - if (empty($query_values)) $queryi .= $this->getFilter($filters); |
|
| 1350 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
| 1428 | + if (empty($query_values)) { |
|
| 1429 | + $queryi .= $this->getFilter($filters); |
|
| 1430 | + } else { |
|
| 1431 | + $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
| 1432 | + } |
|
| 1351 | 1433 | |
| 1352 | 1434 | $sth = $this->db->prepare($queryi); |
| 1353 | 1435 | $sth->execute($query_values); |
@@ -1369,7 +1451,9 @@ discard block |
||
| 1369 | 1451 | date_default_timezone_set($globalTimezone); |
| 1370 | 1452 | $datetime = new DateTime(); |
| 1371 | 1453 | $offset = $datetime->format('P'); |
| 1372 | - } else $offset = '+00:00'; |
|
| 1454 | + } else { |
|
| 1455 | + $offset = '+00:00'; |
|
| 1456 | + } |
|
| 1373 | 1457 | |
| 1374 | 1458 | if ($globalDBdriver == 'mysql') { |
| 1375 | 1459 | $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1473,7 +1557,9 @@ discard block |
||
| 1473 | 1557 | */ |
| 1474 | 1558 | public function parseDirection($direction = 0) |
| 1475 | 1559 | { |
| 1476 | - if ($direction == '') $direction = 0; |
|
| 1560 | + if ($direction == '') { |
|
| 1561 | + $direction = 0; |
|
| 1562 | + } |
|
| 1477 | 1563 | $direction_array = array(); |
| 1478 | 1564 | $temp_array = array(); |
| 1479 | 1565 | |
@@ -1562,7 +1648,9 @@ discard block |
||
| 1562 | 1648 | $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 1563 | 1649 | |
| 1564 | 1650 | $Connection = new Connection($this->db); |
| 1565 | - if (!$Connection->tableExists('countries')) return ''; |
|
| 1651 | + if (!$Connection->tableExists('countries')) { |
|
| 1652 | + return ''; |
|
| 1653 | + } |
|
| 1566 | 1654 | |
| 1567 | 1655 | try { |
| 1568 | 1656 | /* |
@@ -1582,9 +1670,13 @@ discard block |
||
| 1582 | 1670 | $sth->closeCursor(); |
| 1583 | 1671 | if (count($row) > 0) { |
| 1584 | 1672 | return $row; |
| 1585 | - } else return ''; |
|
| 1673 | + } else { |
|
| 1674 | + return ''; |
|
| 1675 | + } |
|
| 1586 | 1676 | } catch (PDOException $e) { |
| 1587 | - if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n"; |
|
| 1677 | + if (isset($globalDebug) && $globalDebug) { |
|
| 1678 | + echo 'Error : '.$e->getMessage()."\n"; |
|
| 1679 | + } |
|
| 1588 | 1680 | return ''; |
| 1589 | 1681 | } |
| 1590 | 1682 | |
@@ -1602,7 +1694,9 @@ discard block |
||
| 1602 | 1694 | $iso2 = filter_var($iso2,FILTER_SANITIZE_STRING); |
| 1603 | 1695 | |
| 1604 | 1696 | $Connection = new Connection($this->db); |
| 1605 | - if (!$Connection->tableExists('countries')) return ''; |
|
| 1697 | + if (!$Connection->tableExists('countries')) { |
|
| 1698 | + return ''; |
|
| 1699 | + } |
|
| 1606 | 1700 | |
| 1607 | 1701 | try { |
| 1608 | 1702 | $query = "SELECT name,iso2,iso3 FROM countries WHERE iso2 = :iso2 LIMIT 1"; |
@@ -1614,9 +1708,13 @@ discard block |
||
| 1614 | 1708 | $sth->closeCursor(); |
| 1615 | 1709 | if (count($row) > 0) { |
| 1616 | 1710 | return $row; |
| 1617 | - } else return ''; |
|
| 1711 | + } else { |
|
| 1712 | + return ''; |
|
| 1713 | + } |
|
| 1618 | 1714 | } catch (PDOException $e) { |
| 1619 | - if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n"; |
|
| 1715 | + if (isset($globalDebug) && $globalDebug) { |
|
| 1716 | + echo 'Error : '.$e->getMessage()."\n"; |
|
| 1717 | + } |
|
| 1620 | 1718 | return ''; |
| 1621 | 1719 | } |
| 1622 | 1720 | |
@@ -1634,7 +1732,9 @@ discard block |
||
| 1634 | 1732 | { |
| 1635 | 1733 | global $globalBitlyAccessToken; |
| 1636 | 1734 | |
| 1637 | - if ($globalBitlyAccessToken == '') return $url; |
|
| 1735 | + if ($globalBitlyAccessToken == '') { |
|
| 1736 | + return $url; |
|
| 1737 | + } |
|
| 1638 | 1738 | |
| 1639 | 1739 | $google_url = 'https://api-ssl.bitly.com/v3/shorten?access_token='.$globalBitlyAccessToken.'&longUrl='.$url; |
| 1640 | 1740 | |
@@ -13,33 +13,33 @@ discard block |
||
| 13 | 13 | * @param Array $filter the filter |
| 14 | 14 | * @return Array the SQL part |
| 15 | 15 | */ |
| 16 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
| 16 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
| 17 | 17 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
| 18 | 18 | $filters = array(); |
| 19 | 19 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
| 20 | 20 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
| 21 | 21 | $filters = $globalStatsFilters[$globalFilterName]; |
| 22 | 22 | } else { |
| 23 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
| 23 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
| 24 | 24 | } |
| 25 | 25 | } |
| 26 | 26 | if (isset($filter[0]['source'])) { |
| 27 | - $filters = array_merge($filters,$filter); |
|
| 27 | + $filters = array_merge($filters, $filter); |
|
| 28 | 28 | } |
| 29 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 29 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
| 30 | 30 | $filter_query_join = ''; |
| 31 | 31 | $filter_query_where = ''; |
| 32 | - foreach($filters as $flt) { |
|
| 32 | + foreach ($filters as $flt) { |
|
| 33 | 33 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
| 34 | 34 | if (isset($flt['source'])) { |
| 35 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.ident IN ('".implode("','",$flt['idents'])."') AND marine_archive_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.fammarine_id = marine_archive.fammarine_id"; |
|
| 35 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.ident IN ('".implode("','", $flt['idents'])."') AND marine_archive_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.fammarine_id = marine_archive.fammarine_id"; |
|
| 36 | 36 | } else { |
| 37 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.fammarine_id = marine_archive.fammarine_id"; |
|
| 37 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.fammarine_id = marine_archive.fammarine_id"; |
|
| 38 | 38 | } |
| 39 | 39 | } |
| 40 | 40 | } |
| 41 | 41 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 42 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
| 42 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
| 43 | 43 | } |
| 44 | 44 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
| 45 | 45 | $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
@@ -67,22 +67,22 @@ discard block |
||
| 67 | 67 | $filter_query_date .= " AND EXTRACT(DAY FROM marine_archive_output.date) = '".$filter['day']."'"; |
| 68 | 68 | } |
| 69 | 69 | } |
| 70 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.fammarine_id = marine_archive.fammarine_id"; |
|
| 70 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.fammarine_id = marine_archive.fammarine_id"; |
|
| 71 | 71 | } |
| 72 | 72 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 73 | - $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 73 | + $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 74 | 74 | } |
| 75 | 75 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
| 76 | 76 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
| 77 | 77 | if ($filter_query_where != '') { |
| 78 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
| 78 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
| 79 | 79 | } |
| 80 | 80 | $filter_query = $filter_query_join.$filter_query_where; |
| 81 | 81 | return $filter_query; |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | // marine_archive |
| 85 | - public function addMarineArchiveData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '',$type = '',$typeid = '',$imo = '', $callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '') { |
|
| 85 | + public function addMarineArchiveData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '', $type = '', $typeid = '', $imo = '', $callsign = '', $arrival_code = '', $arrival_date = '', $status = '', $statusid = '', $noarchive = false, $format_source = '', $source_name = '', $over_country = '') { |
|
| 86 | 86 | /* |
| 87 | 87 | require_once(dirname(__FILE__).'/class.Marine.php'); |
| 88 | 88 | if ($over_country == '') { |
@@ -94,16 +94,16 @@ discard block |
||
| 94 | 94 | */ |
| 95 | 95 | $country = $over_country; |
| 96 | 96 | // Route is not added in marine_archive |
| 97 | - $query = 'INSERT INTO marine_archive (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,status,imo,arrival_port_name,arrival_port_date) |
|
| 97 | + $query = 'INSERT INTO marine_archive (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,status,imo,arrival_port_name,arrival_port_date) |
|
| 98 | 98 | VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)'; |
| 99 | 99 | |
| 100 | - $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country,':mmsi' => $mmsi,':type' => $type,':status' => $status,':imo' => $imo,':arrival_port_name' => $arrival_code,':arrival_port_date' => $arrival_date); |
|
| 100 | + $query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country, ':mmsi' => $mmsi, ':type' => $type, ':status' => $status, ':imo' => $imo, ':arrival_port_name' => $arrival_code, ':arrival_port_date' => $arrival_date); |
|
| 101 | 101 | |
| 102 | 102 | try { |
| 103 | 103 | $sth = $this->db->prepare($query); |
| 104 | 104 | $sth->execute($query_values); |
| 105 | 105 | $sth->closeCursor(); |
| 106 | - } catch(PDOException $e) { |
|
| 106 | + } catch (PDOException $e) { |
|
| 107 | 107 | return "error : ".$e->getMessage(); |
| 108 | 108 | } |
| 109 | 109 | return "success"; |
@@ -123,9 +123,9 @@ discard block |
||
| 123 | 123 | |
| 124 | 124 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 125 | 125 | //$query = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
| 126 | - $query = "SELECT marine_archive.* FROM marine_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
| 126 | + $query = "SELECT marine_archive.* FROM marine_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
| 127 | 127 | |
| 128 | - $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident)); |
|
| 128 | + $spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident)); |
|
| 129 | 129 | |
| 130 | 130 | return $spotter_array; |
| 131 | 131 | } |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 145 | 145 | //$query = MarineArchive->$global_query." WHERE marine_archive.fammarine_id = :id"; |
| 146 | 146 | //$query = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
| 147 | - $query = "SELECT * FROM marine_archive WHERE fammarine_id = :id ORDER BY date DESC LIMIT 1"; |
|
| 147 | + $query = "SELECT * FROM marine_archive WHERE fammarine_id = :id ORDER BY date DESC LIMIT 1"; |
|
| 148 | 148 | |
| 149 | 149 | // $spotter_array = Marine->getDataFromDB($query,array(':id' => $id)); |
| 150 | 150 | /* |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | } |
| 158 | 158 | $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC); |
| 159 | 159 | */ |
| 160 | - $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id)); |
|
| 160 | + $spotter_array = $Marine->getDataFromDB($query, array(':id' => $id)); |
|
| 161 | 161 | |
| 162 | 162 | return $spotter_array; |
| 163 | 163 | } |
@@ -172,14 +172,14 @@ discard block |
||
| 172 | 172 | { |
| 173 | 173 | date_default_timezone_set('UTC'); |
| 174 | 174 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 175 | - $query = $this->global_query." WHERE marine_archive.fammarine_id = :id ORDER BY date"; |
|
| 175 | + $query = $this->global_query." WHERE marine_archive.fammarine_id = :id ORDER BY date"; |
|
| 176 | 176 | |
| 177 | 177 | // $spotter_array = Marine->getDataFromDB($query,array(':id' => $id)); |
| 178 | 178 | |
| 179 | 179 | try { |
| 180 | 180 | $sth = $this->db->prepare($query); |
| 181 | 181 | $sth->execute(array(':id' => $id)); |
| 182 | - } catch(PDOException $e) { |
|
| 182 | + } catch (PDOException $e) { |
|
| 183 | 183 | echo $e->getMessage(); |
| 184 | 184 | die; |
| 185 | 185 | } |
@@ -198,14 +198,14 @@ discard block |
||
| 198 | 198 | { |
| 199 | 199 | date_default_timezone_set('UTC'); |
| 200 | 200 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 201 | - $query = "SELECT marine_archive.latitude, marine_archive.longitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id"; |
|
| 201 | + $query = "SELECT marine_archive.latitude, marine_archive.longitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id"; |
|
| 202 | 202 | |
| 203 | 203 | // $spotter_array = Marine->getDataFromDB($query,array(':id' => $id)); |
| 204 | 204 | |
| 205 | 205 | try { |
| 206 | 206 | $sth = $this->db->prepare($query); |
| 207 | 207 | $sth->execute(array(':id' => $id)); |
| 208 | - } catch(PDOException $e) { |
|
| 208 | + } catch (PDOException $e) { |
|
| 209 | 209 | echo $e->getMessage(); |
| 210 | 210 | die; |
| 211 | 211 | } |
@@ -227,12 +227,12 @@ discard block |
||
| 227 | 227 | date_default_timezone_set('UTC'); |
| 228 | 228 | |
| 229 | 229 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 230 | - $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date"; |
|
| 230 | + $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date"; |
|
| 231 | 231 | |
| 232 | 232 | try { |
| 233 | 233 | $sth = $this->db->prepare($query); |
| 234 | 234 | $sth->execute(array(':ident' => $ident)); |
| 235 | - } catch(PDOException $e) { |
|
| 235 | + } catch (PDOException $e) { |
|
| 236 | 236 | echo $e->getMessage(); |
| 237 | 237 | die; |
| 238 | 238 | } |
@@ -253,12 +253,12 @@ discard block |
||
| 253 | 253 | date_default_timezone_set('UTC'); |
| 254 | 254 | |
| 255 | 255 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 256 | - $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date"; |
|
| 256 | + $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date"; |
|
| 257 | 257 | |
| 258 | 258 | try { |
| 259 | 259 | $sth = $this->db->prepare($query); |
| 260 | 260 | $sth->execute(array(':id' => $id)); |
| 261 | - } catch(PDOException $e) { |
|
| 261 | + } catch (PDOException $e) { |
|
| 262 | 262 | echo $e->getMessage(); |
| 263 | 263 | die; |
| 264 | 264 | } |
@@ -279,12 +279,12 @@ discard block |
||
| 279 | 279 | date_default_timezone_set('UTC'); |
| 280 | 280 | |
| 281 | 281 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 282 | - $query = "SELECT marine_archive.altitude, marine_archive.ground_speed, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id ORDER BY date"; |
|
| 282 | + $query = "SELECT marine_archive.altitude, marine_archive.ground_speed, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id ORDER BY date"; |
|
| 283 | 283 | |
| 284 | 284 | try { |
| 285 | 285 | $sth = $this->db->prepare($query); |
| 286 | 286 | $sth->execute(array(':id' => $id)); |
| 287 | - } catch(PDOException $e) { |
|
| 287 | + } catch (PDOException $e) { |
|
| 288 | 288 | echo $e->getMessage(); |
| 289 | 289 | die; |
| 290 | 290 | } |
@@ -306,13 +306,13 @@ discard block |
||
| 306 | 306 | date_default_timezone_set('UTC'); |
| 307 | 307 | |
| 308 | 308 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 309 | - $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
|
| 309 | + $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
|
| 310 | 310 | // $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident"; |
| 311 | 311 | |
| 312 | 312 | try { |
| 313 | 313 | $sth = $this->db->prepare($query); |
| 314 | 314 | $sth->execute(array(':ident' => $ident)); |
| 315 | - } catch(PDOException $e) { |
|
| 315 | + } catch (PDOException $e) { |
|
| 316 | 316 | echo $e->getMessage(); |
| 317 | 317 | die; |
| 318 | 318 | } |
@@ -329,13 +329,13 @@ discard block |
||
| 329 | 329 | * @return Array the spotter information |
| 330 | 330 | * |
| 331 | 331 | */ |
| 332 | - public function getMarineArchiveData($ident,$fammarine_id,$date) |
|
| 332 | + public function getMarineArchiveData($ident, $fammarine_id, $date) |
|
| 333 | 333 | { |
| 334 | 334 | $Marine = new Marine($this->db); |
| 335 | 335 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 336 | - $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.fammarine_id = :fammarine_id AND l.date LIKE :date GROUP BY l.fammarine_id) s on spotter_live.fammarine_id = s.fammarine_id AND spotter_live.date = s.maxdate"; |
|
| 336 | + $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.fammarine_id = :fammarine_id AND l.date LIKE :date GROUP BY l.fammarine_id) s on spotter_live.fammarine_id = s.fammarine_id AND spotter_live.date = s.maxdate"; |
|
| 337 | 337 | |
| 338 | - $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':fammarine_id' => $fammarine_id,':date' => $date.'%')); |
|
| 338 | + $spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident, ':fammarine_id' => $fammarine_id, ':date' => $date.'%')); |
|
| 339 | 339 | |
| 340 | 340 | return $spotter_array; |
| 341 | 341 | } |
@@ -348,7 +348,7 @@ discard block |
||
| 348 | 348 | try { |
| 349 | 349 | $sth = $this->db->prepare($query); |
| 350 | 350 | $sth->execute(); |
| 351 | - } catch(PDOException $e) { |
|
| 351 | + } catch (PDOException $e) { |
|
| 352 | 352 | echo $e->getMessage(); |
| 353 | 353 | die; |
| 354 | 354 | } |
@@ -360,24 +360,24 @@ discard block |
||
| 360 | 360 | * @return Array the spotter information |
| 361 | 361 | * |
| 362 | 362 | */ |
| 363 | - public function getMinLiveMarineData($begindate,$enddate,$filter = array()) |
|
| 363 | + public function getMinLiveMarineData($begindate, $enddate, $filter = array()) |
|
| 364 | 364 | { |
| 365 | 365 | global $globalDBdriver, $globalLiveInterval; |
| 366 | 366 | date_default_timezone_set('UTC'); |
| 367 | 367 | |
| 368 | 368 | $filter_query = ''; |
| 369 | 369 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 370 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 370 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
| 371 | 371 | } |
| 372 | 372 | // Use spotter_output also ? |
| 373 | 373 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
| 374 | - $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
| 374 | + $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
| 375 | 375 | } |
| 376 | 376 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
| 377 | 377 | $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id "; |
| 378 | 378 | } |
| 379 | 379 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 380 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 380 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 381 | 381 | } |
| 382 | 382 | |
| 383 | 383 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -396,14 +396,14 @@ discard block |
||
| 396 | 396 | GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id |
| 397 | 397 | AND marine_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive.aircraft_icao = a.icao'; |
| 398 | 398 | */ |
| 399 | - $query = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 399 | + $query = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 400 | 400 | FROM marine_archive |
| 401 | 401 | INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao |
| 402 | 402 | WHERE marine_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' |
| 403 | 403 | '.$filter_query.' ORDER BY fammarine_id'; |
| 404 | 404 | } else { |
| 405 | 405 | //$query = 'SELECT marine_archive.ident, marine_archive.fammarine_id, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao'; |
| 406 | - $query = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 406 | + $query = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 407 | 407 | FROM marine_archive |
| 408 | 408 | INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao |
| 409 | 409 | WHERE marine_archive.date >= '."'".$begindate."'".' AND marine_archive.date <= '."'".$enddate."'".' |
@@ -413,7 +413,7 @@ discard block |
||
| 413 | 413 | try { |
| 414 | 414 | $sth = $this->db->prepare($query); |
| 415 | 415 | $sth->execute(); |
| 416 | - } catch(PDOException $e) { |
|
| 416 | + } catch (PDOException $e) { |
|
| 417 | 417 | echo $e->getMessage(); |
| 418 | 418 | die; |
| 419 | 419 | } |
@@ -428,24 +428,24 @@ discard block |
||
| 428 | 428 | * @return Array the spotter information |
| 429 | 429 | * |
| 430 | 430 | */ |
| 431 | - public function getMinLiveMarineDataPlayback($begindate,$enddate,$filter = array()) |
|
| 431 | + public function getMinLiveMarineDataPlayback($begindate, $enddate, $filter = array()) |
|
| 432 | 432 | { |
| 433 | 433 | global $globalDBdriver, $globalLiveInterval; |
| 434 | 434 | date_default_timezone_set('UTC'); |
| 435 | 435 | |
| 436 | 436 | $filter_query = ''; |
| 437 | 437 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 438 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 438 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
| 439 | 439 | } |
| 440 | 440 | // Should use spotter_output also ? |
| 441 | 441 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
| 442 | - $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
| 442 | + $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
| 443 | 443 | } |
| 444 | 444 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
| 445 | 445 | $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id "; |
| 446 | 446 | } |
| 447 | 447 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 448 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 448 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 449 | 449 | } |
| 450 | 450 | |
| 451 | 451 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -455,7 +455,7 @@ discard block |
||
| 455 | 455 | FROM marine_archive |
| 456 | 456 | INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive.aircraft_icao = a.icao'; |
| 457 | 457 | */ |
| 458 | - $query = 'SELECT a.aircraft_shadow, marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk |
|
| 458 | + $query = 'SELECT a.aircraft_shadow, marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk |
|
| 459 | 459 | FROM marine_archive_output |
| 460 | 460 | LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive_output.aircraft_icao = a.icao |
| 461 | 461 | WHERE (marine_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') |
@@ -470,7 +470,7 @@ discard block |
||
| 470 | 470 | WHERE marine_archive_output.date >= '."'".$begindate."'".' AND marine_archive_output.date <= '."'".$enddate."'".' |
| 471 | 471 | '.$filter_query.' GROUP BY marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao, marine_archive_output.arrival_airport_icao, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow'; |
| 472 | 472 | */ |
| 473 | - $query = 'SELECT DISTINCT marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow |
|
| 473 | + $query = 'SELECT DISTINCT marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow |
|
| 474 | 474 | FROM marine_archive_output |
| 475 | 475 | INNER JOIN (SELECT * FROM aircraft) a on marine_archive_output.aircraft_icao = a.icao |
| 476 | 476 | WHERE marine_archive_output.date >= '."'".$begindate."'".' AND marine_archive_output.date <= '."'".$enddate."'".' |
@@ -482,7 +482,7 @@ discard block |
||
| 482 | 482 | try { |
| 483 | 483 | $sth = $this->db->prepare($query); |
| 484 | 484 | $sth->execute(); |
| 485 | - } catch(PDOException $e) { |
|
| 485 | + } catch (PDOException $e) { |
|
| 486 | 486 | echo $e->getMessage(); |
| 487 | 487 | die; |
| 488 | 488 | } |
@@ -497,23 +497,23 @@ discard block |
||
| 497 | 497 | * @return Array the spotter information |
| 498 | 498 | * |
| 499 | 499 | */ |
| 500 | - public function getLiveMarineCount($begindate,$enddate,$filter = array()) |
|
| 500 | + public function getLiveMarineCount($begindate, $enddate, $filter = array()) |
|
| 501 | 501 | { |
| 502 | 502 | global $globalDBdriver, $globalLiveInterval; |
| 503 | 503 | date_default_timezone_set('UTC'); |
| 504 | 504 | |
| 505 | 505 | $filter_query = ''; |
| 506 | 506 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 507 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 507 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
| 508 | 508 | } |
| 509 | 509 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
| 510 | - $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
| 510 | + $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
| 511 | 511 | } |
| 512 | 512 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
| 513 | 513 | $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id "; |
| 514 | 514 | } |
| 515 | 515 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 516 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 516 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 517 | 517 | } |
| 518 | 518 | |
| 519 | 519 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -528,7 +528,7 @@ discard block |
||
| 528 | 528 | try { |
| 529 | 529 | $sth = $this->db->prepare($query); |
| 530 | 530 | $sth->execute(); |
| 531 | - } catch(PDOException $e) { |
|
| 531 | + } catch (PDOException $e) { |
|
| 532 | 532 | echo $e->getMessage(); |
| 533 | 533 | die; |
| 534 | 534 | } |
@@ -548,7 +548,7 @@ discard block |
||
| 548 | 548 | * @return Array the spotter information |
| 549 | 549 | * |
| 550 | 550 | */ |
| 551 | - public function searchMarineData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array()) |
|
| 551 | + public function searchMarineData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '', $pilot_id = '', $pilot_name = '', $altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '', $origLat = '', $origLon = '', $dist = '', $filters = array()) |
|
| 552 | 552 | { |
| 553 | 553 | global $globalTimezone, $globalDBdriver; |
| 554 | 554 | require_once(dirname(__FILE__).'/class.Translation.php'); |
@@ -570,7 +570,7 @@ discard block |
||
| 570 | 570 | |
| 571 | 571 | $q_array = explode(" ", $q); |
| 572 | 572 | |
| 573 | - foreach ($q_array as $q_item){ |
|
| 573 | + foreach ($q_array as $q_item) { |
|
| 574 | 574 | $additional_query .= " AND ("; |
| 575 | 575 | $additional_query .= "(marine_archive_output.spotter_id like '%".$q_item."%') OR "; |
| 576 | 576 | $additional_query .= "(marine_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
@@ -602,7 +602,7 @@ discard block |
||
| 602 | 602 | |
| 603 | 603 | if ($registration != "") |
| 604 | 604 | { |
| 605 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
| 605 | + $registration = filter_var($registration, FILTER_SANITIZE_STRING); |
|
| 606 | 606 | if (!is_string($registration)) |
| 607 | 607 | { |
| 608 | 608 | return false; |
@@ -613,7 +613,7 @@ discard block |
||
| 613 | 613 | |
| 614 | 614 | if ($aircraft_icao != "") |
| 615 | 615 | { |
| 616 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
| 616 | + $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
| 617 | 617 | if (!is_string($aircraft_icao)) |
| 618 | 618 | { |
| 619 | 619 | return false; |
@@ -624,7 +624,7 @@ discard block |
||
| 624 | 624 | |
| 625 | 625 | if ($aircraft_manufacturer != "") |
| 626 | 626 | { |
| 627 | - $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
| 627 | + $aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING); |
|
| 628 | 628 | if (!is_string($aircraft_manufacturer)) |
| 629 | 629 | { |
| 630 | 630 | return false; |
@@ -645,7 +645,7 @@ discard block |
||
| 645 | 645 | |
| 646 | 646 | if ($airline_icao != "") |
| 647 | 647 | { |
| 648 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
| 648 | + $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING); |
|
| 649 | 649 | if (!is_string($airline_icao)) |
| 650 | 650 | { |
| 651 | 651 | return false; |
@@ -656,7 +656,7 @@ discard block |
||
| 656 | 656 | |
| 657 | 657 | if ($airline_country != "") |
| 658 | 658 | { |
| 659 | - $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
| 659 | + $airline_country = filter_var($airline_country, FILTER_SANITIZE_STRING); |
|
| 660 | 660 | if (!is_string($airline_country)) |
| 661 | 661 | { |
| 662 | 662 | return false; |
@@ -667,7 +667,7 @@ discard block |
||
| 667 | 667 | |
| 668 | 668 | if ($airline_type != "") |
| 669 | 669 | { |
| 670 | - $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
| 670 | + $airline_type = filter_var($airline_type, FILTER_SANITIZE_STRING); |
|
| 671 | 671 | if (!is_string($airline_type)) |
| 672 | 672 | { |
| 673 | 673 | return false; |
@@ -689,7 +689,7 @@ discard block |
||
| 689 | 689 | |
| 690 | 690 | if ($airport != "") |
| 691 | 691 | { |
| 692 | - $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
| 692 | + $airport = filter_var($airport, FILTER_SANITIZE_STRING); |
|
| 693 | 693 | if (!is_string($airport)) |
| 694 | 694 | { |
| 695 | 695 | return false; |
@@ -700,7 +700,7 @@ discard block |
||
| 700 | 700 | |
| 701 | 701 | if ($airport_country != "") |
| 702 | 702 | { |
| 703 | - $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
| 703 | + $airport_country = filter_var($airport_country, FILTER_SANITIZE_STRING); |
|
| 704 | 704 | if (!is_string($airport_country)) |
| 705 | 705 | { |
| 706 | 706 | return false; |
@@ -711,7 +711,7 @@ discard block |
||
| 711 | 711 | |
| 712 | 712 | if ($callsign != "") |
| 713 | 713 | { |
| 714 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
| 714 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
| 715 | 715 | if (!is_string($callsign)) |
| 716 | 716 | { |
| 717 | 717 | return false; |
@@ -719,7 +719,7 @@ discard block |
||
| 719 | 719 | $translate = $Translation->ident2icao($callsign); |
| 720 | 720 | if ($translate != $callsign) { |
| 721 | 721 | $additional_query .= " AND (marine_archive_output.ident = :callsign OR marine_archive_output.ident = :translate)"; |
| 722 | - $query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate)); |
|
| 722 | + $query_values = array_merge($query_values, array(':callsign' => $callsign, ':translate' => $translate)); |
|
| 723 | 723 | } else { |
| 724 | 724 | $additional_query .= " AND (marine_archive_output.ident = '".$callsign."')"; |
| 725 | 725 | } |
@@ -728,7 +728,7 @@ discard block |
||
| 728 | 728 | |
| 729 | 729 | if ($owner != "") |
| 730 | 730 | { |
| 731 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
| 731 | + $owner = filter_var($owner, FILTER_SANITIZE_STRING); |
|
| 732 | 732 | if (!is_string($owner)) |
| 733 | 733 | { |
| 734 | 734 | return false; |
@@ -739,7 +739,7 @@ discard block |
||
| 739 | 739 | |
| 740 | 740 | if ($pilot_name != "") |
| 741 | 741 | { |
| 742 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
| 742 | + $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING); |
|
| 743 | 743 | if (!is_string($pilot_name)) |
| 744 | 744 | { |
| 745 | 745 | return false; |
@@ -750,7 +750,7 @@ discard block |
||
| 750 | 750 | |
| 751 | 751 | if ($pilot_id != "") |
| 752 | 752 | { |
| 753 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
| 753 | + $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_NUMBER_INT); |
|
| 754 | 754 | if (!is_string($pilot_id)) |
| 755 | 755 | { |
| 756 | 756 | return false; |
@@ -761,7 +761,7 @@ discard block |
||
| 761 | 761 | |
| 762 | 762 | if ($departure_airport_route != "") |
| 763 | 763 | { |
| 764 | - $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
| 764 | + $departure_airport_route = filter_var($departure_airport_route, FILTER_SANITIZE_STRING); |
|
| 765 | 765 | if (!is_string($departure_airport_route)) |
| 766 | 766 | { |
| 767 | 767 | return false; |
@@ -772,7 +772,7 @@ discard block |
||
| 772 | 772 | |
| 773 | 773 | if ($arrival_airport_route != "") |
| 774 | 774 | { |
| 775 | - $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
| 775 | + $arrival_airport_route = filter_var($arrival_airport_route, FILTER_SANITIZE_STRING); |
|
| 776 | 776 | if (!is_string($arrival_airport_route)) |
| 777 | 777 | { |
| 778 | 778 | return false; |
@@ -785,8 +785,8 @@ discard block |
||
| 785 | 785 | { |
| 786 | 786 | $altitude_array = explode(",", $altitude); |
| 787 | 787 | |
| 788 | - $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 789 | - $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 788 | + $altitude_array[0] = filter_var($altitude_array[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 789 | + $altitude_array[1] = filter_var($altitude_array[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 790 | 790 | |
| 791 | 791 | |
| 792 | 792 | if ($altitude_array[1] != "") |
@@ -804,8 +804,8 @@ discard block |
||
| 804 | 804 | { |
| 805 | 805 | $date_array = explode(",", $date_posted); |
| 806 | 806 | |
| 807 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
| 808 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
| 807 | + $date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING); |
|
| 808 | + $date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING); |
|
| 809 | 809 | |
| 810 | 810 | if ($globalTimezone != '') { |
| 811 | 811 | date_default_timezone_set($globalTimezone); |
@@ -837,8 +837,8 @@ discard block |
||
| 837 | 837 | { |
| 838 | 838 | $limit_array = explode(",", $limit); |
| 839 | 839 | |
| 840 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 841 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 840 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 841 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 842 | 842 | |
| 843 | 843 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 844 | 844 | { |
@@ -849,8 +849,8 @@ discard block |
||
| 849 | 849 | |
| 850 | 850 | |
| 851 | 851 | if ($origLat != "" && $origLon != "" && $dist != "") { |
| 852 | - $dist = number_format($dist*0.621371,2,'.',''); |
|
| 853 | - $query="SELECT marine_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(marine_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(marine_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
| 852 | + $dist = number_format($dist*0.621371, 2, '.', ''); |
|
| 853 | + $query = "SELECT marine_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(marine_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(marine_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
| 854 | 854 | FROM marine_archive_output, marine_archive WHERE spotter_output_archive.fammarine_id = marine_archive.fammarine_id AND spotter_output.ident <> '' ".$additional_query."AND CAST(marine_archive.longitude as double precision) between ($origLon-$dist/ABS(cos(radians($origLat))*69)) and ($origLon+$dist/ABS(cos(radians($origLat))*69)) and CAST(marine_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) |
| 855 | 855 | AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(marine_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(marine_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2)))) < $dist".$filter_query." ORDER BY distance"; |
| 856 | 856 | } else { |
@@ -867,12 +867,12 @@ discard block |
||
| 867 | 867 | $additional_query .= " AND (marine_archive_output.waypoints <> '')"; |
| 868 | 868 | } |
| 869 | 869 | |
| 870 | - $query = "SELECT marine_archive_output.* FROM marine_archive_output |
|
| 870 | + $query = "SELECT marine_archive_output.* FROM marine_archive_output |
|
| 871 | 871 | WHERE marine_archive_output.ident <> '' |
| 872 | 872 | ".$additional_query." |
| 873 | 873 | ".$filter_query.$orderby_query; |
| 874 | 874 | } |
| 875 | - $spotter_array = $Marine->getDataFromDB($query, $query_values,$limit_query); |
|
| 875 | + $spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query); |
|
| 876 | 876 | |
| 877 | 877 | return $spotter_array; |
| 878 | 878 | } |
@@ -889,7 +889,7 @@ discard block |
||
| 889 | 889 | try { |
| 890 | 890 | $sth = $this->db->prepare($query); |
| 891 | 891 | $sth->execute(); |
| 892 | - } catch(PDOException $e) { |
|
| 892 | + } catch (PDOException $e) { |
|
| 893 | 893 | return "error"; |
| 894 | 894 | } |
| 895 | 895 | } |
@@ -926,8 +926,8 @@ discard block |
||
| 926 | 926 | { |
| 927 | 927 | $limit_array = explode(",", $limit); |
| 928 | 928 | |
| 929 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 930 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 929 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 930 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 931 | 931 | |
| 932 | 932 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 933 | 933 | { |
@@ -968,7 +968,7 @@ discard block |
||
| 968 | 968 | $query_values = array(); |
| 969 | 969 | $limit_query = ''; |
| 970 | 970 | $additional_query = ''; |
| 971 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 971 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 972 | 972 | |
| 973 | 973 | if ($owner != "") |
| 974 | 974 | { |
@@ -985,8 +985,8 @@ discard block |
||
| 985 | 985 | { |
| 986 | 986 | $limit_array = explode(",", $limit); |
| 987 | 987 | |
| 988 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 989 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 988 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 989 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 990 | 990 | |
| 991 | 991 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 992 | 992 | { |
@@ -1026,7 +1026,7 @@ discard block |
||
| 1026 | 1026 | $query_values = array(); |
| 1027 | 1027 | $limit_query = ''; |
| 1028 | 1028 | $additional_query = ''; |
| 1029 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 1029 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 1030 | 1030 | |
| 1031 | 1031 | if ($pilot != "") |
| 1032 | 1032 | { |
@@ -1038,8 +1038,8 @@ discard block |
||
| 1038 | 1038 | { |
| 1039 | 1039 | $limit_array = explode(",", $limit); |
| 1040 | 1040 | |
| 1041 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1042 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1041 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 1042 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 1043 | 1043 | |
| 1044 | 1044 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 1045 | 1045 | { |
@@ -1069,7 +1069,7 @@ discard block |
||
| 1069 | 1069 | * @return Array the airline country list |
| 1070 | 1070 | * |
| 1071 | 1071 | */ |
| 1072 | - public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 1072 | + public function countAllFlightOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '') |
|
| 1073 | 1073 | { |
| 1074 | 1074 | global $globalDBdriver; |
| 1075 | 1075 | /* |
@@ -1098,7 +1098,7 @@ discard block |
||
| 1098 | 1098 | $flight_array = array(); |
| 1099 | 1099 | $temp_array = array(); |
| 1100 | 1100 | |
| 1101 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1101 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1102 | 1102 | { |
| 1103 | 1103 | $temp_array['flight_count'] = $row['nb']; |
| 1104 | 1104 | $temp_array['flight_country'] = $row['name']; |
@@ -1115,7 +1115,7 @@ discard block |
||
| 1115 | 1115 | * @return Array the airline country list |
| 1116 | 1116 | * |
| 1117 | 1117 | */ |
| 1118 | - public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 1118 | + public function countAllFlightOverCountriesByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '') |
|
| 1119 | 1119 | { |
| 1120 | 1120 | global $globalDBdriver; |
| 1121 | 1121 | /* |
@@ -1144,7 +1144,7 @@ discard block |
||
| 1144 | 1144 | $flight_array = array(); |
| 1145 | 1145 | $temp_array = array(); |
| 1146 | 1146 | |
| 1147 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1147 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1148 | 1148 | { |
| 1149 | 1149 | $temp_array['airline_icao'] = $row['airline_icao']; |
| 1150 | 1150 | $temp_array['flight_count'] = $row['nb']; |
@@ -1162,14 +1162,14 @@ discard block |
||
| 1162 | 1162 | * @return Array the spotter information |
| 1163 | 1163 | * |
| 1164 | 1164 | */ |
| 1165 | - public function getDateArchiveMarineDataById($id,$date) |
|
| 1165 | + public function getDateArchiveMarineDataById($id, $date) |
|
| 1166 | 1166 | { |
| 1167 | 1167 | $Marine = new Marine($this->db); |
| 1168 | 1168 | date_default_timezone_set('UTC'); |
| 1169 | 1169 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 1170 | 1170 | $query = 'SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate ORDER BY marine_archive.date DESC'; |
| 1171 | - $date = date('c',$date); |
|
| 1172 | - $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date)); |
|
| 1171 | + $date = date('c', $date); |
|
| 1172 | + $spotter_array = $Marine->getDataFromDB($query, array(':id' => $id, ':date' => $date)); |
|
| 1173 | 1173 | return $spotter_array; |
| 1174 | 1174 | } |
| 1175 | 1175 | |
@@ -1179,14 +1179,14 @@ discard block |
||
| 1179 | 1179 | * @return Array the spotter information |
| 1180 | 1180 | * |
| 1181 | 1181 | */ |
| 1182 | - public function getDateArchiveMarineDataByIdent($ident,$date) |
|
| 1182 | + public function getDateArchiveMarineDataByIdent($ident, $date) |
|
| 1183 | 1183 | { |
| 1184 | 1184 | $Marine = new Marine($this->db); |
| 1185 | 1185 | date_default_timezone_set('UTC'); |
| 1186 | 1186 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 1187 | 1187 | $query = 'SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate ORDER BY marine_archive.date DESC'; |
| 1188 | - $date = date('c',$date); |
|
| 1189 | - $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
| 1188 | + $date = date('c', $date); |
|
| 1189 | + $spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
| 1190 | 1190 | return $spotter_array; |
| 1191 | 1191 | } |
| 1192 | 1192 | |
@@ -1196,7 +1196,7 @@ discard block |
||
| 1196 | 1196 | * @return Array the spotter information |
| 1197 | 1197 | * |
| 1198 | 1198 | */ |
| 1199 | - public function getMarineDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
| 1199 | + public function getMarineDataByAirport($airport = '', $limit = '', $sort = '', $filters = array()) |
|
| 1200 | 1200 | { |
| 1201 | 1201 | global $global_query; |
| 1202 | 1202 | $Marine = new Marine(); |
@@ -1204,7 +1204,7 @@ discard block |
||
| 1204 | 1204 | $query_values = array(); |
| 1205 | 1205 | $limit_query = ''; |
| 1206 | 1206 | $additional_query = ''; |
| 1207 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1207 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1208 | 1208 | |
| 1209 | 1209 | if ($airport != "") |
| 1210 | 1210 | { |
@@ -1221,8 +1221,8 @@ discard block |
||
| 1221 | 1221 | { |
| 1222 | 1222 | $limit_array = explode(",", $limit); |
| 1223 | 1223 | |
| 1224 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1225 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1224 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 1225 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 1226 | 1226 | |
| 1227 | 1227 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 1228 | 1228 | { |